Changes to xos dumbComponent
diff --git a/views/ngXosLib/xosHelpers/src/styles/main.scss b/views/ngXosLib/xosHelpers/src/styles/main.scss
index cc02e6f..9dc34e7 100644
--- a/views/ngXosLib/xosHelpers/src/styles/main.scss
+++ b/views/ngXosLib/xosHelpers/src/styles/main.scss
@@ -5,6 +5,7 @@
@import '../ui_components/dumbComponents/alert/alert.scss';
@import '../ui_components/dumbComponents/validation/validation.scss';
@import '../ui_components/dumbComponents/field/field.scss';
+@import '../ui_components/dumbComponents/form/form.scss';
@import '../ui_components/smartComponents/smartTable/smartTable.scss';
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/alert/alert.scss b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/alert/alert.scss
index f1330fe..f031ba6 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/alert/alert.scss
+++ b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/alert/alert.scss
@@ -1,6 +1,8 @@
@import '../../../styles/animations.scss';
xos-alert {
+ margin-top: $form-group-margin-bottom;
+ display: block;
/* when hiding */
.ng-hide-add { animation:0.5s fadeOutDown ease-in-out; }
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/field/field.component.js b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/field/field.component.js
index ea9e0ab..138e220 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/field/field.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/field/field.component.js
@@ -130,7 +130,7 @@
},
template: `
<label ng-if="vm.field.type !== 'object'">{{vm.field.label}}</label>
- <!--<pre>{{vm.field.options | json}}</pre>-->
+ <!--<pre>{{vm.field | json}}</pre>-->
<!--<pre>{{vm.ngModel | json}}</pre>-->
<input
ng-if="vm.field.type !== 'boolean' && vm.field.type !== 'object' && vm.field.type !== 'select'"
@@ -148,18 +148,18 @@
ng-required="vm.field.validators.required || false">
</select>
<span class="boolean-field" ng-if="vm.field.type === 'boolean'">
- <button
+ <a
class="btn btn-success"
ng-show="vm.ngModel"
ng-click="vm.ngModel = false">
<i class="glyphicon glyphicon-ok"></i>
- </button>
- <button
+ </a>
+ <a
class="btn btn-danger"
ng-show="!vm.ngModel"
ng-click="vm.ngModel = true">
<i class="glyphicon glyphicon-remove"></i>
- </button>
+ </a>
</span>
<div
class="panel panel-default object-field"
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js
index 2a9f00c..986e589 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js
@@ -161,10 +161,14 @@
ngModel: '='
},
template: `
- <ng-form name="vm.{{vm.config.formName || 'form'}}">
+ <form name="vm.{{vm.config.formName || 'form'}}" novalidate>
<div class="form-group" ng-repeat="(name, field) in vm.formField">
+ <!--{{vm.ngModel[name] | json}}-->
<xos-field name="name" field="field" ng-model="vm.ngModel[name]"></xos-field>
- <xos-validation field="vm[vm.config.formName || 'form'][name]" form="vm[vm.config.formName || 'form']"></xos-validation>
+ <!--<pre>{{vm[vm.config.formName] || 'form' | json }}</pre>-->
+ <!--{{field}}-->
+ <xos-validation field="vm[vm.config.formName || 'form'][name]" form = "vm[vm.config.formName || 'form']"></xos-validation>
+ <div class="alert alert-info" ng-show="(field.hint).length >0" role="alert">{{field.hint}}</div>
</div>
<div class="form-group" ng-if="vm.config.actions">
<button role="button" href=""
@@ -175,8 +179,9 @@
<i class="glyphicon glyphicon-{{action.icon}}"></i>
{{action.label}}
</button>
+
</div>
- </ng-form>
+ </form>
`,
bindToController: true,
controllerAs: 'vm',
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.scss b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.scss
new file mode 100644
index 0000000..b61f8e2
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.scss
@@ -0,0 +1,8 @@
+@import '../../../styles/animations.scss';
+@import '../../../../../../style/sass/bootstrap/bootstrap/_variables.scss';
+
+xos-form {
+ button {
+ margin-bottom: $form-group-margin-bottom;
+ }
+}
\ No newline at end of file
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/validation/validation.component.js b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/validation/validation.component.js
index 37cfbd5..e9ed574 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/validation/validation.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/validation/validation.component.js
@@ -82,7 +82,7 @@
},
template: `
<div ng-cloak>
- <pre>{{vm.field | json}}</pre>
+ <!--<pre>{{vm.field | json}}</pre>-->
<!--<pre>{{vm.form.$submitted | json}}</pre>-->
<!--<pre>{{vm.field.$error.required !== false}}</pre>-->
<xos-alert config="vm.config" show="vm.field.$error.required !== undefined && vm.field.$error.required !== false && (vm.field.$touched || vm.form.$submitted)">
diff --git a/views/ngXosViews/tenant/.bowerrc b/views/ngXosViews/tenant/.bowerrc
new file mode 100644
index 0000000..e491038
--- /dev/null
+++ b/views/ngXosViews/tenant/.bowerrc
@@ -0,0 +1,3 @@
+{
+ "directory": "src/vendor/"
+}
\ No newline at end of file
diff --git a/views/ngXosViews/tenant/.eslintrc b/views/ngXosViews/tenant/.eslintrc
new file mode 100644
index 0000000..c852748
--- /dev/null
+++ b/views/ngXosViews/tenant/.eslintrc
@@ -0,0 +1,42 @@
+{
+ "ecmaFeatures": {
+ "blockBindings": true,
+ "forOf": true,
+ "destructuring": true,
+ "arrowFunctions": true,
+ "templateStrings": true
+ },
+ "env": {
+ "browser": true,
+ "node": true,
+ "es6": true
+ },
+ "plugins": [
+ //"angular"
+ ],
+ "rules": {
+ "quotes": [2, "single"],
+ "camelcase": [1, {"properties": "always"}],
+ "no-underscore-dangle": 1,
+ "eqeqeq": [2, "smart"],
+ "no-alert": 1,
+ "key-spacing": [1, { "beforeColon": false, "afterColon": true }],
+ "indent": [2, 2],
+ "no-irregular-whitespace": 1,
+ "eol-last": 0,
+ "max-nested-callbacks": [2, 4],
+ "comma-spacing": [1, {"before": false, "after": true}],
+ "no-trailing-spaces": [1, { skipBlankLines: true }],
+ "no-unused-vars": [1, {"vars": "all", "args": "after-used"}],
+ "new-cap": 0,
+
+ //"angular/ng_module_name": [2, '/^xos\.*[a-z]*$/'],
+ //"angular/ng_controller_name": [2, '/^[a-z].*Ctrl$/'],
+ //"angular/ng_service_name": [2, '/^[A-Z].*Service$/'],
+ //"angular/ng_directive_name": [2, '/^[a-z]+[[A-Z].*]*$/'],
+ //"angular/ng_di": [0, "function or array"]
+ },
+ "globals" :{
+ "angular": true
+ }
+}
\ No newline at end of file
diff --git a/views/ngXosViews/tenant/.gitignore b/views/ngXosViews/tenant/.gitignore
new file mode 100644
index 0000000..567aee4
--- /dev/null
+++ b/views/ngXosViews/tenant/.gitignore
@@ -0,0 +1,6 @@
+dist/
+src/vendor
+.tmp
+node_modules
+npm-debug.log
+dist/
\ No newline at end of file
diff --git a/views/ngXosViews/tenant/bower.json b/views/ngXosViews/tenant/bower.json
new file mode 100644
index 0000000..c37483b
--- /dev/null
+++ b/views/ngXosViews/tenant/bower.json
@@ -0,0 +1,32 @@
+{
+ "name": "xos-tenant",
+ "version": "0.0.0",
+ "authors": [
+ " <>"
+ ],
+ "description": "The tenant view",
+ "license": "MIT",
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "static/js/vendor/",
+ "test",
+ "tests"
+ ],
+ "dependencies": {},
+ "devDependencies": {
+ "jquery": "2.1.4",
+ "angular-mocks": "1.4.7",
+ "angular": "1.4.7",
+ "angular-ui-router": "0.2.15",
+ "angular-cookies": "1.4.7",
+ "angular-animate": "1.4.7",
+ "angular-resource": "1.4.7",
+ "lodash": "~4.11.1",
+ "bootstrap-css": "3.3.6",
+ "angular-chart.js": "~0.10.2",
+ "d3": "~3.5.17",
+ "angular-recursion": "^1.0.5"
+ }
+}
diff --git a/views/ngXosViews/tenant/env/default.js b/views/ngXosViews/tenant/env/default.js
new file mode 100644
index 0000000..e8b1522
--- /dev/null
+++ b/views/ngXosViews/tenant/env/default.js
@@ -0,0 +1,13 @@
+// This is a default configuration for your development environment.
+// You can duplicate this configuration for any of your Backend Environments.
+// Different configurations are loaded setting a NODE_ENV variable that contain the config file name.
+// `NODE_ENV=local npm start`
+//
+// If xoscsrftoken or xossessionid are not specified the browser value are used
+// (works only for local environment as both application are served on the same domain)
+
+module.exports = {
+ host: 'http://xos.dev:9999',
+ xoscsrftoken: 'FIdWwEI8XNESlpH3Wr6Hu5ORJs2EkIYl',
+ xossessionid: 'six66atpd31hh0b131zh9bc05t6f77d4'
+};
diff --git a/views/ngXosViews/tenant/gulp/build.js b/views/ngXosViews/tenant/gulp/build.js
new file mode 100644
index 0000000..8a7b279
--- /dev/null
+++ b/views/ngXosViews/tenant/gulp/build.js
@@ -0,0 +1,164 @@
+'use strict';
+
+// BUILD
+//
+// The only purpose of this gulpfile is to build a XOS view and copy the correct files into
+// .html => dashboards
+// .js (minified and concat) => static/js
+//
+// The template are parsed and added to js with angular $templateCache
+
+var gulp = require('gulp');
+var ngAnnotate = require('gulp-ng-annotate');
+var uglify = require('gulp-uglify');
+var templateCache = require('gulp-angular-templatecache');
+var runSequence = require('run-sequence');
+var concat = require('gulp-concat-util');
+var del = require('del');
+var wiredep = require('wiredep');
+var angularFilesort = require('gulp-angular-filesort');
+var _ = require('lodash');
+var eslint = require('gulp-eslint');
+var inject = require('gulp-inject');
+var rename = require('gulp-rename');
+var replace = require('gulp-replace');
+var postcss = require('gulp-postcss');
+var autoprefixer = require('autoprefixer');
+var mqpacker = require('css-mqpacker');
+var csswring = require('csswring');
+
+const TEMPLATE_FOOTER = `
+angular.module('xos.tenant')
+.run(['$location', function(a){
+ a.path('/');
+}])
+`
+
+module.exports = function(options){
+
+ // delete previous builded file
+ gulp.task('clean', function(){
+ return del(
+ [
+ options.dashboards + 'xosTenant.html',
+ options.static + 'css/xosTenant.css'
+ ],
+ {force: true}
+ );
+ });
+
+ // minify css
+ gulp.task('css', function () {
+ var processors = [
+ autoprefixer({browsers: ['last 1 version']}),
+ mqpacker,
+ csswring
+ ];
+
+ gulp.src([
+ `${options.css}**/*.css`,
+ `!${options.css}dev.css`
+ ])
+ .pipe(postcss(processors))
+ .pipe(gulp.dest(options.tmp + '/css/'));
+ });
+
+ // copy css in correct folder
+ gulp.task('copyCss', ['wait'], function(){
+ return gulp.src([`${options.tmp}/css/*.css`])
+ .pipe(concat('xosTenant.css'))
+ .pipe(gulp.dest(options.static + 'css/'))
+ });
+
+ // compile and minify scripts
+ gulp.task('scripts', function() {
+ return gulp.src([
+ options.tmp + '**/*.js'
+ ])
+ .pipe(ngAnnotate())
+ .pipe(angularFilesort())
+ .pipe(concat('xosTenant.js'))
+ .pipe(concat.header('//Autogenerated, do not edit!!!\n'))
+ .pipe(concat.footer(TEMPLATE_FOOTER))
+ .pipe(uglify())
+ .pipe(gulp.dest(options.static + 'js/'));
+ });
+
+ // set templates in cache
+ gulp.task('templates', function(){
+ return gulp.src('./src/templates/*.html')
+ .pipe(templateCache({
+ module: 'xos.tenant',
+ root: 'templates/'
+ }))
+ .pipe(gulp.dest(options.tmp));
+ });
+
+ // copy html index to Django Folder
+ gulp.task('copyHtml', function(){
+ return gulp.src(options.src + 'index.html')
+ // remove dev dependencies from html
+ .pipe(replace(/<!-- bower:css -->(\n^<link.*)*\n<!-- endbower -->/gmi, ''))
+ .pipe(replace(/<!-- bower:js -->(\n^<script.*)*\n<!-- endbower -->/gmi, ''))
+ // injecting minified files
+ .pipe(
+ inject(
+ gulp.src([
+ options.static + 'js/vendor/xosTenantVendor.js',
+ options.static + 'js/xosTenant.js',
+ options.static + 'css/xosTenant.css'
+ ]),
+ {ignorePath: '/../../../xos/core/xoslib'}
+ )
+ )
+ .pipe(rename('xosTenant.html'))
+ .pipe(gulp.dest(options.dashboards));
+ });
+
+ // minify vendor js files
+ gulp.task('wiredep', function(){
+ var bowerDeps = wiredep().js;
+ if(!bowerDeps){
+ return;
+ }
+
+ // remove angular (it's already loaded)
+ _.remove(bowerDeps, function(dep){
+ return dep.indexOf('angular/angular.js') !== -1;
+ });
+
+ return gulp.src(bowerDeps)
+ .pipe(concat('xosTenantVendor.js'))
+ .pipe(uglify())
+ .pipe(gulp.dest(options.static + 'js/vendor/'));
+ });
+
+ gulp.task('lint', function () {
+ return gulp.src(['src/js/**/*.js'])
+ .pipe(eslint())
+ .pipe(eslint.format())
+ .pipe(eslint.failAfterError());
+ });
+
+ gulp.task('wait', function (cb) {
+ // setTimeout could be any async task
+ setTimeout(function () {
+ cb();
+ }, 1000);
+ });
+
+ gulp.task('build', function() {
+ runSequence(
+ 'clean',
+ 'sass',
+ 'templates',
+ 'babel',
+ 'scripts',
+ 'wiredep',
+ 'css',
+ 'copyCss',
+ 'copyHtml',
+ 'cleanTmp'
+ );
+ });
+};
\ No newline at end of file
diff --git a/views/ngXosViews/tenant/gulp/server.js b/views/ngXosViews/tenant/gulp/server.js
new file mode 100644
index 0000000..c0678d9
--- /dev/null
+++ b/views/ngXosViews/tenant/gulp/server.js
@@ -0,0 +1,168 @@
+'use strict';
+
+var gulp = require('gulp');
+var browserSync = require('browser-sync').create();
+var inject = require('gulp-inject');
+var runSequence = require('run-sequence');
+var angularFilesort = require('gulp-angular-filesort');
+var babel = require('gulp-babel');
+var wiredep = require('wiredep').stream;
+var httpProxy = require('http-proxy');
+var del = require('del');
+var sass = require('gulp-sass');
+
+const environment = process.env.NODE_ENV;
+
+if (environment){
+ var conf = require(`../env/${environment}.js`);
+}
+else{
+ var conf = require('../env/default.js')
+}
+
+var proxy = httpProxy.createProxyServer({
+ target: conf.host || 'http://0.0.0.0:9999'
+});
+
+
+proxy.on('error', function(error, req, res) {
+ res.writeHead(500, {
+ 'Content-Type': 'text/plain'
+ });
+
+ console.error('[Proxy]', error);
+});
+
+module.exports = function(options){
+
+ gulp.task('browser', function() {
+ browserSync.init({
+ startPath: '#/',
+ snippetOptions: {
+ rule: {
+ match: /<!-- browserSync -->/i
+ }
+ },
+ server: {
+ baseDir: options.src,
+ routes: {
+ '/xos/core/xoslib/static/js/vendor': options.helpers,
+ '/xos/core/static': options.static + '../../static/'
+ },
+ middleware: function(req, res, next){
+ if(
+ // to be removed, deprecated API
+ // req.url.indexOf('/xos/') !== -1 ||
+ // req.url.indexOf('/xoslib/') !== -1 ||
+ // req.url.indexOf('/hpcapi/') !== -1 ||
+ req.url.indexOf('/api/') !== -1
+ ){
+ if(conf.xoscsrftoken && conf.xossessionid){
+ req.headers.cookie = `xoscsrftoken=${conf.xoscsrftoken}; xossessionid=${conf.xossessionid}`;
+ req.headers['x-csrftoken'] = conf.xoscsrftoken;
+ }
+ proxy.web(req, res);
+ }
+ else{
+ next();
+ }
+ }
+ }
+ });
+
+ gulp.watch(options.src + 'js/**/*.js', ['js-watch']);
+ gulp.watch(options.src + 'vendor/**/*.js', ['bower'], function(){
+ browserSync.reload();
+ });
+ gulp.watch(options.src + '**/*.html', function(){
+ browserSync.reload();
+ });
+ gulp.watch(options.css + '**/*.css', function(){
+ browserSync.reload();
+ });
+ gulp.watch(`${options.sass}/**/*.scss`, ['sass'], function(){
+ browserSync.reload();
+ });
+
+ gulp.watch([
+ options.helpers + 'ngXosHelpers.js',
+ options.static + '../../static/xosNgLib.css'
+ ], function(){
+ browserSync.reload();
+ });
+ });
+
+ // compile sass
+ gulp.task('sass', function () {
+ return gulp.src(`${options.sass}/**/*.scss`)
+ .pipe(sass().on('error', sass.logError))
+ .pipe(gulp.dest(options.css));
+ });
+
+ // transpile js with sourceMaps
+ gulp.task('babel', function(){
+ return gulp.src(options.scripts + '**/*.js')
+ .pipe(babel({sourceMaps: true}))
+ .pipe(gulp.dest(options.tmp));
+ });
+
+ // inject scripts
+ gulp.task('injectScript', ['cleanTmp', 'babel'], function(){
+ return gulp.src(options.src + 'index.html')
+ .pipe(
+ inject(
+ gulp.src([
+ options.tmp + '**/*.js',
+ options.helpers + 'ngXosHelpers.js'
+ ])
+ .pipe(angularFilesort()),
+ {
+ ignorePath: [options.src, '/../../ngXosLib']
+ }
+ )
+ )
+ .pipe(gulp.dest(options.src));
+ });
+
+ // inject CSS
+ gulp.task('injectCss', function(){
+ return gulp.src(options.src + 'index.html')
+ .pipe(
+ inject(
+ gulp.src([
+ options.src + 'css/*.css',
+ options.static + '../../static/xosNgLib.css'
+ ]),
+ {
+ ignorePath: [options.src]
+ }
+ )
+ )
+ .pipe(gulp.dest(options.src));
+ });
+
+ // inject bower dependencies with wiredep
+ gulp.task('bower', function () {
+ return gulp.src(options.src + 'index.html')
+ .pipe(wiredep({devDependencies: true}))
+ .pipe(gulp.dest(options.src));
+ });
+
+ gulp.task('js-watch', ['injectScript'], function(){
+ browserSync.reload();
+ });
+
+ gulp.task('cleanTmp', function(){
+ return del([options.tmp + '**/*']);
+ });
+
+ gulp.task('serve', function() {
+ runSequence(
+ 'sass',
+ 'bower',
+ 'injectScript',
+ 'injectCss',
+ ['browser']
+ );
+ });
+};
diff --git a/views/ngXosViews/tenant/gulpfile.js b/views/ngXosViews/tenant/gulpfile.js
new file mode 100644
index 0000000..08df554
--- /dev/null
+++ b/views/ngXosViews/tenant/gulpfile.js
@@ -0,0 +1,26 @@
+'use strict';
+
+var gulp = require('gulp');
+var wrench = require('wrench');
+
+var options = {
+ src: 'src/',
+ css: 'src/css/',
+ sass: 'src/sass/',
+ scripts: 'src/js/',
+ tmp: 'src/.tmp',
+ dist: 'dist/',
+ api: '../../ngXosLib/api/',
+ helpers: '../../../xos/core/xoslib/static/js/vendor/',
+ static: '../../../xos/core/xoslib/static/', // this is the django static folder
+ dashboards: '../../../xos/core/xoslib/dashboards/' // this is the django html folder
+};
+
+wrench.readdirSyncRecursive('./gulp')
+.map(function(file) {
+ require('./gulp/' + file)(options);
+});
+
+gulp.task('default', function () {
+ gulp.start('build');
+});
diff --git a/views/ngXosViews/tenant/karma.conf.js b/views/ngXosViews/tenant/karma.conf.js
new file mode 100644
index 0000000..4123be9
--- /dev/null
+++ b/views/ngXosViews/tenant/karma.conf.js
@@ -0,0 +1,88 @@
+// Karma configuration
+// Generated on Tue Oct 06 2015 09:27:10 GMT+0000 (UTC)
+
+/* eslint indent: [2,2], quotes: [2, "single"]*/
+
+/*eslint-disable*/
+var wiredep = require('wiredep');
+var path = require('path');
+
+var bowerComponents = wiredep( {devDependencies: true} )[ 'js' ].map(function( file ){
+ return path.relative(process.cwd(), file);
+});
+
+module.exports = function(config) {
+/*eslint-enable*/
+ config.set({
+
+ // base path that will be used to resolve all patterns (eg. files, exclude)
+ basePath: '',
+
+
+ // frameworks to use
+ // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
+ frameworks: ['jasmine'],
+
+
+ // list of files / patterns to load in the browser
+ files: bowerComponents.concat([
+ '../../../xos/core/xoslib/static/js/vendor/ngXosVendor.js',
+ '../../../xos/core/xoslib/static/js/vendor/ngXosHelpers.js',
+ 'src/js/**/*.js',
+ 'spec/**/*.mock.js',
+ 'spec/**/*.test.js',
+ 'src/**/*.html'
+ ]),
+
+
+ // list of files to exclude
+ exclude: [
+ ],
+
+
+ // preprocess matching files before serving them to the browser
+ // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
+ preprocessors: {
+ 'src/js/**/*.js': ['babel'],
+ 'spec/**/*.test.js': ['babel'],
+ 'src/**/*.html': ['ng-html2js']
+ },
+
+ ngHtml2JsPreprocessor: {
+ stripPrefix: 'src/', //strip the src path from template url (http://stackoverflow.com/questions/22869668/karma-unexpected-request-when-testing-angular-directive-even-with-ng-html2js)
+ moduleName: 'templates' // define the template module name
+ },
+
+ // test results reporter to use
+ // possible values: 'dots', 'progress'
+ // available reporters: https://npmjs.org/browse/keyword/karma-reporter
+ reporters: ['mocha'],
+
+
+ // web server port
+ port: 9876,
+
+
+ // enable / disable colors in the output (reporters and logs)
+ colors: true,
+
+
+ // level of logging
+ // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
+ logLevel: config.LOG_INFO,
+
+
+ // enable / disable watching file and executing tests whenever any file changes
+ autoWatch: true,
+
+
+ // start these browsers
+ // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
+ browsers: ['PhantomJS'],
+
+
+ // Continuous Integration mode
+ // if true, Karma captures browsers, runs the tests and exits
+ singleRun: false
+ });
+};
diff --git a/views/ngXosViews/tenant/package.json b/views/ngXosViews/tenant/package.json
new file mode 100644
index 0000000..ed04285
--- /dev/null
+++ b/views/ngXosViews/tenant/package.json
@@ -0,0 +1,63 @@
+{
+ "name": "xos-tenant",
+ "version": "1.0.0",
+ "description": "Angular Application for XOS, created with generator-xos",
+ "scripts": {
+ "prestart": "npm install && bower install",
+ "start": "gulp serve",
+ "prebuild": "npm install && bower install",
+ "build": "gulp",
+ "test": "karma start",
+ "test:ci": "karma start --single-run",
+ "lint": "eslint src/js/"
+ },
+ "keywords": [
+ "XOS",
+ "Angular",
+ "XOSlib"
+ ],
+ "author": "",
+ "license": "MIT",
+ "dependencies": {},
+ "devDependencies": {
+ "autoprefixer": "^6.3.3",
+ "browser-sync": "^2.9.11",
+ "css-mqpacker": "^4.0.0",
+ "csswring": "^4.2.1",
+ "del": "^2.0.2",
+ "easy-mocker": "^1.2.0",
+ "eslint": "^1.8.0",
+ "eslint-plugin-angular": "linkmesrl/eslint-plugin-angular",
+ "gulp": "^3.9.0",
+ "gulp-angular-filesort": "^1.1.1",
+ "gulp-angular-templatecache": "^1.8.0",
+ "gulp-babel": "^5.3.0",
+ "gulp-concat": "^2.6.0",
+ "gulp-concat-util": "^0.5.5",
+ "gulp-eslint": "^1.0.0",
+ "gulp-inject": "^3.0.0",
+ "gulp-minify-html": "^1.0.4",
+ "gulp-ng-annotate": "^1.1.0",
+ "gulp-postcss": "^6.0.1",
+ "gulp-rename": "^1.2.2",
+ "gulp-replace": "^0.5.4",
+ "gulp-sass": "^2.2.0",
+ "gulp-uglify": "^1.4.2",
+ "http-proxy": "^1.12.0",
+ "ink-docstrap": "^0.5.2",
+ "jasmine-core": "~2.3.4",
+ "karma": "^0.13.14",
+ "karma-babel-preprocessor": "~5.2.2",
+ "karma-coverage": "^0.5.3",
+ "karma-jasmine": "~0.3.6",
+ "karma-mocha-reporter": "~1.1.1",
+ "karma-ng-html2js-preprocessor": "^0.2.0",
+ "karma-phantomjs-launcher": "~0.2.1",
+ "lodash": "^3.10.1",
+ "phantomjs": "^1.9.19",
+ "proxy-middleware": "^0.15.0",
+ "run-sequence": "^1.1.4",
+ "wiredep": "^3.0.0-beta",
+ "wrench": "^1.5.8"
+ }
+}
diff --git a/views/ngXosViews/tenant/spec/sample.test.js b/views/ngXosViews/tenant/spec/sample.test.js
new file mode 100644
index 0000000..bd0fd92
--- /dev/null
+++ b/views/ngXosViews/tenant/spec/sample.test.js
@@ -0,0 +1,54 @@
+'use strict';
+
+describe('Tenant View', () => {
+
+ var scope, element, isolatedScope, httpBackend;
+
+ beforeEach(module('xos.tenant'));
+ beforeEach(module('templates'));
+
+ beforeEach(inject(function($httpBackend, $compile, $rootScope){
+
+ httpBackend = $httpBackend;
+ // Setting up mock request
+ scope = $rootScope.$new();
+ element = angular.element('<users-list></users-list>');
+ $compile(element)(scope);
+ scope.$digest();
+ isolatedScope = element.isolateScope().vm;
+ }));
+describe('site list table',() =>{
+ it('site list ', () => {
+ var sites = [
+ {
+ 'name':'Mysite',
+ 'id':'1'
+
+ }];
+ var slices = [{
+ 'site':'1',
+ 'instance_total':1,
+ 'instance_total_ready':1
+ },
+ {
+ 'site':'1',
+ 'instance_total':2,
+ 'instance_total_ready':3
+ },
+ {
+ 'site':'2',
+ 'instance_total':'1',
+ 'instance_total_ready':'2'
+ }];
+ var result = isolatedScope.returnData(sites,slices);
+ expect(result).toEqual([{
+ 'name':'Mysite',
+ 'id':'1',
+ 'instance_total':3,
+ 'instance_total_ready':4
+ }
+])
+//httpBackend.flush();
+ });
+});
+});
\ No newline at end of file
diff --git a/views/ngXosViews/tenant/src/css/main.css b/views/ngXosViews/tenant/src/css/main.css
new file mode 100644
index 0000000..a22d515
--- /dev/null
+++ b/views/ngXosViews/tenant/src/css/main.css
@@ -0,0 +1,2 @@
+#xosTenant a {
+ margin-bottom: 15px; }
diff --git a/views/ngXosViews/tenant/src/index.html b/views/ngXosViews/tenant/src/index.html
new file mode 100644
index 0000000..16822bf
--- /dev/null
+++ b/views/ngXosViews/tenant/src/index.html
@@ -0,0 +1,40 @@
+<!-- browserSync -->
+<!-- bower:css -->
+<link rel="stylesheet" href="vendor/bootstrap-css/css/bootstrap.min.css" />
+<link rel="stylesheet" href="vendor/angular-chart.js/dist/angular-chart.css" />
+<!-- endbower -->
+<!-- endcss -->
+<!-- inject:css -->
+<link rel="stylesheet" href="/css/main.css">
+<link rel="stylesheet" href="/../../../xos/core/static/xosNgLib.css">
+<!-- endinject -->
+<p>
+ hello
+</p>
+
+<div ng-app="xos.tenant" id="xosTenant" class="container-fluid">
+ <div ui-sref="createslice"></div>
+ <div ui-view></div>
+ <div></div>
+</div>
+
+<!-- bower:js -->
+<script src="vendor/jquery/dist/jquery.js"></script>
+<script src="vendor/angular/angular.js"></script>
+<script src="vendor/angular-mocks/angular-mocks.js"></script>
+<script src="vendor/angular-ui-router/release/angular-ui-router.js"></script>
+<script src="vendor/angular-cookies/angular-cookies.js"></script>
+<script src="vendor/angular-animate/angular-animate.js"></script>
+<script src="vendor/angular-resource/angular-resource.js"></script>
+<script src="vendor/lodash/lodash.js"></script>
+<script src="vendor/bootstrap-css/js/bootstrap.min.js"></script>
+<script src="vendor/Chart.js/Chart.js"></script>
+<script src="vendor/angular-chart.js/dist/angular-chart.js"></script>
+<script src="vendor/d3/d3.js"></script>
+<script src="vendor/angular-recursion/angular-recursion.js"></script>
+<!-- endbower -->
+<!-- endjs -->
+<!-- inject:js -->
+<script src="/../../../xos/core/xoslib/static/js/vendor/ngXosHelpers.js"></script>
+<script src="/.tmp/main.js"></script>
+<!-- endinject -->
\ No newline at end of file
diff --git a/views/ngXosViews/tenant/src/js/main.js b/views/ngXosViews/tenant/src/js/main.js
new file mode 100644
index 0000000..105e54e
--- /dev/null
+++ b/views/ngXosViews/tenant/src/js/main.js
@@ -0,0 +1,547 @@
+'use strict';
+
+angular.module('xos.tenant', [
+ 'ngResource',
+ 'ngCookies',
+ 'ui.router',
+ 'xos.helpers'
+])
+.config(($stateProvider) => {
+ $stateProvider
+ .state('user-list', {
+ url: '/',
+ template: '<users-list></users-list>'
+ })
+ .state('site', {
+ url:'/site/:id',
+ template:'<site-detail></site-detail>'
+
+ })
+ .state('createslice', {
+ url:'/site/:site/slice/',
+ template:'<create-slice></create-slice>'
+
+ })
+ .state('editslice', {
+ url:'/site/:site/slice/:id?',
+ template:'<edit-slice></edit-slice>'
+
+ });;
+
+})
+.config(function($httpProvider){
+ $httpProvider.interceptors.push('NoHyperlinks');
+})
+.directive('usersList', function(){
+ return {
+ //sites : {},
+ restrict: 'E',
+ scope: {},
+ bindToController: true,
+ controllerAs: 'vm',
+ templateUrl: 'templates/users-list.tpl.html',
+ controller: function(Sites,SlicesPlus){
+
+
+
+ this.tableConfig = {
+ columns: [
+ {
+ label: 'Site1',
+ prop: 'name',
+ link: item => `/#/site/${item.id}`
+ },
+ {
+ label: 'Allocated',
+ prop: 'instance_total'
+ },
+ {
+ label: 'Ready',
+ prop: 'instance_total_ready'
+ }
+ ]
+ };
+
+ var sites;
+ // retrieving user list
+ Sites.query().$promise
+ .then((users) => {
+ this.sites = users;
+ return SlicesPlus.query().$promise
+ })
+ .then((users) => {
+ this.slices = users;
+ //console.log(this.sites,this.slices);
+ this.site_list = this.returnData(this.sites,this.slices);
+ })
+ .catch((e) => {
+ throw new Error(e);
+ });
+ //console.log(sites);
+
+
+ this.returnData = (sites,slices) => {
+ //console.log(sites,slices);
+ //console.log(sites.length)
+ var i,j=0;
+ var site_list=[];
+ var slice_list = [];
+
+ for(i = 0; i<sites.length; i++){
+ var instance_t = 0;
+ var instance_t_r = 0;
+ for(j=0;j<slices.length;j++){
+ if (sites[i].id != null && slices[j].site !=null && sites[i].id == slices[j].site){
+ console.log(sites[i].id,slices[j].id);
+ instance_t = instance_t + slices[j].instance_total;
+ instance_t_r = instance_t_r + slices[j].instance_total_ready;
+ }
+ }
+ var data_sites = {
+ 'id': sites[i].id,
+ 'name': sites[i].name,
+ 'instance_total' :instance_t,
+ 'instance_total_ready' : instance_t_r
+ };
+ //console.log(sites[i].id);
+ site_list.push(data_sites);
+ }
+ return site_list
+ //this.site_list = site_list;
+ }
+ }
+ };
+})
+.directive('siteDetail', function(){
+ return {
+ restrict: 'E',
+ scope: {},
+ bindToController: true,
+ controllerAs: 'sl',
+ templateUrl: 'templates/slicelist.html',
+ controller: function(SlicesPlus,$stateParams){
+ console.log($stateParams);
+ this.siteId = $stateParams.id;
+ this.tableConfig = {
+ columns: [
+ {
+ label: 'Slice List',
+ prop: 'name',
+ link: item => `/#/site/${item.site}/slice/${item.id}`
+ },
+ {
+ label: 'Allocated',
+ prop: 'instance_total'
+ },
+ {
+ label: 'Ready',
+ prop: 'instance_total_ready'
+ }
+ ]
+ };
+
+ // retrieving user list
+ SlicesPlus.query({
+ site:$stateParams.id
+ }).$promise
+ .then((users) => {
+ this.users = users;
+ })
+ .catch((e) => {
+ throw new Error(e);
+ });
+ }
+ };
+})
+.directive('createSlice', function(){
+ return {
+ //sites : {},
+ restrict: 'E',
+ scope: {},
+ bindToController: true,
+ controllerAs: 'cs',
+ templateUrl: 'templates/createslice.html',
+ controller: function(Slices,SlicesPlus,$stateParams){
+ //var sites;
+ //console.log(this.users.name);
+
+ //console.log(this.config);
+ this.config = {
+ exclude: ['password', 'last_login'],
+ formName: 'SliceDetails',
+ actions: [
+ {
+ label: 'Save',
+ icon: 'ok', // refers to bootstraps glyphicon
+ cb: (user) => { // receive the model
+ console.log(user);
+ },
+ class: 'success'
+ },{
+ label: 'Save and continue editing',
+ icon: 'ok', // refers to bootstraps glyphicon
+ cb: (user) => { // receive the model
+ console.log(user);
+ },
+ class: 'primary'
+ },{
+ label: 'Save and add another',
+ icon: 'ok', // refers to bootstraps glyphicon
+ cb: (user) => { // receive the model
+ console.log(user);
+ },
+ class: 'primary'
+ }
+ ],
+ fields:
+ {
+ site_select : {
+ label:'Site',
+ type:'select',
+ validators:{ required: true,},
+ hint : 'The Site this Slice belongs to',
+ options:[
+ {
+ id:0,
+ label:"---Site---"
+ },
+ {
+ id:1,
+ label:"---Site1---"
+ }],
+
+ },
+ first_name: {
+ label:'Name',
+ type: 'string',
+ hint: 'The Name of the Slice',
+ validators: {
+ required: true
+ }
+ },
+ service_class : {
+ label:'ServiceClass',
+ type:'select',
+ validators:{ required: true,},
+ hint : 'The Site this Slice belongs to',
+ options:[
+ {
+ id:0,
+ label:"Best effort"
+ },
+ ],
+ },
+ enabled: {
+ label: 'Enabled',
+ type : 'boolean',
+ hint:'Status for this Slice'
+ },
+ description: {
+ label: 'Description',
+ type : 'string',
+ hint:'High level description of the slice and expected activities',
+ validators: {
+ required: false,
+ minlength: 10
+ }
+ },
+ service : {
+ label:'Service',
+ type:'select',
+ validators:{ required: false,},
+ options:[
+ {
+ id:0,
+ label:"--------"
+ },
+ ],
+ },
+ slice_url: {
+ label: 'Slice url',
+ type : 'string',
+ validators: {
+ required: false,
+ minlength: 10
+ }
+ },
+ max_instances: {
+ type: 'Max Instances',
+ validators: {
+ required: false,
+ min: 0
+ }
+ },
+ default_isolation : {
+ label:'Default Isolation',
+ type:'select',
+ validators:{ required: false,},
+ options:[
+ {
+ id:0,
+ label:"Virtual Machine"
+ },{
+ id:1,
+ label:"Container"
+ },{
+ id:2,
+ label:"Container in VM"
+ },
+ ],
+ },
+ default_image : {
+ label:'Default image',
+ type:'select',
+ validators:{ required: false,},
+ options:[
+ {
+ id:0,
+ label:"trusty-server-multi-nic"
+ },
+ ],
+ },
+ network : {
+ label:'Network',
+ type:'select',
+ validators:{ required: false,},
+ options:[
+ {
+ id:0,
+ label:"Default"
+ },
+ {
+ id:1,
+ label:"Host"
+ },
+ {
+ id:2,
+ label:"Bridged"
+ },
+ {
+ id:3,
+ label:"No Automatic Networks"
+ },
+ ],
+ },
+
+ }
+ };
+
+ var data;
+ // retrieving user list
+
+
+ //Slices.get({id :$stateParams.id}).$promise
+ //.then((users) => {
+ // this.users = users;
+ // //console.log(users.name);
+ // data = users;
+ //})
+ //.catch((e) => {
+ // throw new Error(e);
+ //});
+
+ //console.log(this.users);
+//console.log(this.config.fields.site_select.options);
+ this.model = {
+ };
+ }
+ };
+})
+.directive('editSlice', function(){
+ return {
+ //sites : {},
+ restrict: 'E',
+ scope: {},
+ bindToController: true,
+ controllerAs: 'cs',
+ templateUrl: 'templates/createslice.html',
+ controller: function(Slices,SlicesPlus,$stateParams){
+ //var sites;
+ //console.log(this.users.name);
+
+ //console.log(this.config);
+ this.config = {
+ exclude: ['password', 'last_login'],
+ formName: 'SliceDetails',
+ actions: [
+ {
+ label: 'Save',
+ icon: 'ok', // refers to bootstraps glyphicon
+ cb: (user) => { // receive the model
+ console.log(user);
+ },
+ class: 'success'
+ },{
+ label: 'Save and continue editing',
+ icon: 'ok', // refers to bootstraps glyphicon
+ cb: (user) => { // receive the model
+ console.log(user);
+ },
+ class: 'primary'
+ },{
+ label: 'Save and add another',
+ icon: 'ok', // refers to bootstraps glyphicon
+ cb: (user) => { // receive the model
+ console.log(user);
+ },
+ class: 'primary'
+ }
+ ],
+ fields:
+ {
+ site_select : {
+ label:'Site',
+ type:'select',
+ validators:{ required: true,},
+ hint : 'The Site this Slice belongs to',
+ options:[
+ {
+ id:0,
+ label:"---Site---"
+ },
+ {
+ id:1,
+ label:"---Site1---"
+ }],
+
+ },
+ first_name: {
+ label:'Name',
+ type: 'string',
+ hint: 'The Name of the Slice',
+ validators: {
+ required: true
+ }
+ },
+ service_class : {
+ label:'ServiceClass',
+ type:'select',
+ validators:{ required: true,},
+ hint : 'The Site this Slice belongs to',
+ options:[
+ {
+ id:0,
+ label:"Best effort"
+ },
+ ],
+ },
+ enabled: {
+ label: 'Enabled',
+ type : 'boolean',
+ hint:'Status for this Slice'
+ },
+ description: {
+ label: 'Description',
+ type : 'string',
+ hint:'High level description of the slice and expected activities',
+ validators: {
+ required: false,
+ minlength: 10
+ }
+ },
+ service : {
+ label:'Service',
+ type:'select',
+ validators:{ required: false,},
+ options:[
+ {
+ id:0,
+ label:"--------"
+ },
+ ],
+ },
+ slice_url: {
+ label: 'Slice url',
+ type : 'string',
+ validators: {
+ required: false,
+ minlength: 10
+ }
+ },
+ max_instances: {
+ type: 'Max Instances',
+ validators: {
+ required: false,
+ min: 0
+ }
+ },
+ default_isolation : {
+ label:'Default Isolation',
+ type:'select',
+ validators:{ required: false,},
+ options:[
+ {
+ id:0,
+ label:"Virtual Machine"
+ },{
+ id:1,
+ label:"Container"
+ },{
+ id:2,
+ label:"Container in VM"
+ },
+ ],
+ },
+ default_image : {
+ label:'Default image',
+ type:'select',
+ validators:{ required: false,},
+ options:[
+ {
+ id:0,
+ label:"trusty-server-multi-nic"
+ },
+ ],
+ },
+ network : {
+ label:'Network',
+ type:'select',
+ validators:{ required: false,},
+ options:[
+ {
+ id:0,
+ label:"Default"
+ },
+ {
+ id:1,
+ label:"Host"
+ },
+ {
+ id:2,
+ label:"Bridged"
+ },
+ {
+ id:3,
+ label:"No Automatic Networks"
+ },
+ ],
+ },
+
+ }
+ };
+
+ var data;
+ // retrieving user list
+
+
+ Slices.get({id :$stateParams.id}).$promise
+ .then((users) => {
+ this.users = users;
+ //console.log(users.name);
+ data = users;
+ })
+ .catch((e) => {
+ throw new Error(e);
+ });
+
+ //console.log(this.users);
+//console.log(this.config.fields.site_select.options);
+ this.model = {
+ first_name : "Teo"
+ };
+ }
+ };
+});
+
+
+
diff --git a/views/ngXosViews/tenant/src/sass/main.scss b/views/ngXosViews/tenant/src/sass/main.scss
new file mode 100644
index 0000000..268f1b4
--- /dev/null
+++ b/views/ngXosViews/tenant/src/sass/main.scss
@@ -0,0 +1,9 @@
+@import '../../../../style/sass/lib/_variables.scss';
+@import '../../../../../views/style/sass/bootstrap/bootstrap/_variables.scss';
+
+
+#xosTenant {
+ a{
+ margin-bottom: $form-group-margin-bottom;
+ }
+}
\ No newline at end of file
diff --git a/views/ngXosViews/tenant/src/templates/createslice.html b/views/ngXosViews/tenant/src/templates/createslice.html
new file mode 100644
index 0000000..b04ee28
--- /dev/null
+++ b/views/ngXosViews/tenant/src/templates/createslice.html
@@ -0,0 +1,11 @@
+<!--<xos-table config="cs.tableConfig" data="cs.sites"></xos-table>-->
+<h2>Slice Details</h2>
+<hr></hr>
+<xos-form ng-model="cs.model" config="cs.config" ></xos-form>
+
+<!--<pre>-->
+<!--<!–{{cs.users | json}}–>-->
+
+<!--{{cs.users.name | json}}-->
+
+<!--</pre>-->
\ No newline at end of file
diff --git a/views/ngXosViews/tenant/src/templates/slicelist.html b/views/ngXosViews/tenant/src/templates/slicelist.html
new file mode 100644
index 0000000..555d3dc
--- /dev/null
+++ b/views/ngXosViews/tenant/src/templates/slicelist.html
@@ -0,0 +1,6 @@
+<!--<span ng-bind="siteNameSe"></span>-->
+<!--<xos-field></xos-field>-->
+
+<a class="addlink btn btn-info" ui-sref="createslice({site: sl.siteId})"><i class="glyphicon glyphicon-plus-sign"></i> Create Slice</a>
+<xos-table config="sl.tableConfig" data="sl.users"></xos-table>
+<!--<div ui-view="sliceDetails"></div>-->
\ No newline at end of file
diff --git a/views/ngXosViews/tenant/src/templates/users-list.tpl.html b/views/ngXosViews/tenant/src/templates/users-list.tpl.html
new file mode 100644
index 0000000..1242734
--- /dev/null
+++ b/views/ngXosViews/tenant/src/templates/users-list.tpl.html
@@ -0,0 +1 @@
+<xos-table config="vm.tableConfig" data="vm.site_list"></xos-table>
\ No newline at end of file