Merge branch 'master' of github.com:open-cloud/xos
diff --git a/views/README.md b/views/README.md
index fb0c5bc..34915a3 100644
--- a/views/README.md
+++ b/views/README.md
@@ -6,14 +6,6 @@
These tools are designed to help develop a graphical view. They assume XOS is running on your system and responding at: `localhost:9999`. The `xos/configurations/frontend` is normally sufficient for GUI development.
-### Apigen
-
-Usage: `npm run apigen`
-
-This tool generates an angular resource file for each endpoint available in Swagger.
-
->You can generate api related documentation with: `npm run apidoc`. The output is locate in `api/docs`. You can also see a list of available methods through Swagger at `http://localhost:9999/docs/`
-
### Vendors
XOS comes with a set of common libraries, as listed in `bower.json`:
@@ -59,6 +51,20 @@
## How to Create a View
+### Environment setup
+
+Before getting started with new views you should create a configuration file to define the backend environment to be used. This file have to be in `views/env/default.js` and it content have to be:
+
+```
+module.exports = {
+ host: 'XOS Url',
+ xoscsrftoken: 'CSRF Token',
+ xossessionid: 'Sessio ID'
+};
+```
+
+You can define multiple environment creating other configurations (eg: `views/env/production.js`) with the same structure.
+
### Getting Started
We have created a [yeoman](http://yeoman.io/) generator to help scaffold views.
@@ -77,6 +83,8 @@
This will install the required dependencies and start a local server with [BrowserSync](http://www.browsersync.io/).
+>If you want to use a different backend environment you can call the command with an environment variable: `NODE_ENV=production.js npm start`
+
#### Publish Your View
Once your view is done, from your view root folder, run: `npm run build`.
diff --git a/views/env/.gitignore b/views/env/.gitignore
new file mode 100644
index 0000000..5edb50a
--- /dev/null
+++ b/views/env/.gitignore
@@ -0,0 +1,3 @@
+*
+!.gitignore
+!sample-config.js
\ No newline at end of file
diff --git a/views/env/sample-config.js b/views/env/sample-config.js
new file mode 100644
index 0000000..05809f0
--- /dev/null
+++ b/views/env/sample-config.js
@@ -0,0 +1,12 @@
+// 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`
+
+// You can retrieve token and sessionId from your browser cookies.
+
+module.exports = {
+ host: 'http://localhost:9999/', // XOS Url
+ xoscsrftoken: 'ogrMpnJgOGq43OxGd8jIKIx2aY1vl1Ci', // XOS token
+ xossessionid: 'l49h474keq0vsk6car6l1quz0oeyvohh' // XOS session id
+};
diff --git a/views/ngXosLib/.eslintrc b/views/ngXosLib/.eslintrc
index cf02168..1cd7d33 100644
--- a/views/ngXosLib/.eslintrc
+++ b/views/ngXosLib/.eslintrc
@@ -17,7 +17,7 @@
"rules": {
"quotes": [2, "single"],
"camelcase": [0, {"properties": "always"}],
- "no-underscore-dangle": 1,
+ "no-underscore-dangle": 0,
"eqeqeq": [2, "smart"],
"no-alert": 1,
"key-spacing": [1, { "beforeColon": false, "afterColon": true }],
diff --git a/views/ngXosLib/generator-xos/app/index.js b/views/ngXosLib/generator-xos/app/index.js
index 57eee8c..0368fd2 100755
--- a/views/ngXosLib/generator-xos/app/index.js
+++ b/views/ngXosLib/generator-xos/app/index.js
@@ -11,57 +11,24 @@
return string.replace(/^./, string[0].toUpperCase());
},
prompting: {
- name:function(){
+ name: function(){
var done = this.async();
this.prompt({
- type : 'input',
- name : 'name',
- message : 'Your project name',
- default : this.config.get('name') // value set in .yo-rc.json
+ type: 'input',
+ name: 'name',
+ message: 'Your project name',
+ default: this.config.get('name') // value set in .yo-rc.json
}, function (answers) {
// TODO check if this view already exist
config.name = answers.name;
done();
}.bind(this));
- },
- host:function(){
- var done = this.async();
- this.prompt({
- type : 'input',
- name : 'host',
- message : 'Your project remote host (with port)'
- }, function (answers) {
- config.host = answers.host;
- done();
- }.bind(this));
- },
- token:function(){
- var done = this.async();
- this.prompt({
- type : 'input',
- name : 'token',
- message : 'Insert your active session token'
- }, function (answers) {
- config.token = answers.token;
- done();
- }.bind(this));
- },
- session:function(){
- var done = this.async();
- this.prompt({
- type : 'input',
- name : 'session',
- message : 'Insert your active session id'
- }, function (answers) {
- config.session = answers.session;
- done();
- }.bind(this));
}
},
writing: {
rcFiles: function(){
if (!user.git.name()){
- userName = ['','']
+ userName = ['', '']
}
else {
userName = user.git.name().split(' ');
@@ -73,21 +40,14 @@
this.fs.copyTpl(
this.templatePath('package.json'),
this.destinationPath(`${this.config.get('folder')}/${config.name}/package.json`),
- { name: config.name, author: {name:user.git.name()} }
- );
- },
- envConfig: function(){
- this.fs.copyTpl(
- this.templatePath('env/default.js'),
- this.destinationPath(`${this.config.get('folder')}/${config.name}/env/default.js`),
- { host: config.host, token: config.token, session: config.session }
+ { name: config.name, author: {name: user.git.name()} }
);
},
bowerJson: function(){
this.fs.copyTpl(
this.templatePath('bower.json'),
this.destinationPath(`${this.config.get('folder')}/${config.name}/bower.json`),
- { name: config.name, author: {name:user.git.name(), email: user.git.email()} }
+ { name: config.name, author: {name: user.git.name(), email: user.git.email()} }
);
},
index: function(){
@@ -125,7 +85,7 @@
this.fs.copyTpl(
this.templatePath('gulp/*.js'),
this.destinationPath(`${this.config.get('folder')}/${config.name}/gulp`),
- {name:config.name, fileName: this._fistCharToUpper(config.name)}
+ {name: config.name, fileName: this._fistCharToUpper(config.name)}
);
this.fs.copy(this.templatePath('gulpfile.js'), this.destinationPath(`${this.config.get('folder')}/${config.name}/gulpfile.js`));
},
@@ -152,10 +112,10 @@
install: function(){
var done = this.async();
this.prompt({
- type : 'confirm',
- name : 'deps',
- message : 'Install dependecies?',
- default : false // value set in .yo-rc.json
+ type: 'confirm',
+ name: 'deps',
+ message: 'Install dependecies?',
+ default: false // value set in .yo-rc.json
}, function (answers) {
if(answers.deps){
process.chdir(`${this.config.get('folder')}/${config.name}`);
diff --git a/views/ngXosLib/generator-xos/app/templates/env/default.js b/views/ngXosLib/generator-xos/app/templates/env/default.js
deleted file mode 100644
index 5db8632..0000000
--- a/views/ngXosLib/generator-xos/app/templates/env/default.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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: '<%= host %>',
- xoscsrftoken: '<%= token %>',
- xossessionid: '<%= session %>'
-};
diff --git a/views/ngXosLib/generator-xos/app/templates/gulp/server.js b/views/ngXosLib/generator-xos/app/templates/gulp/server.js
index c0678d9..1e40a34 100644
--- a/views/ngXosLib/generator-xos/app/templates/gulp/server.js
+++ b/views/ngXosLib/generator-xos/app/templates/gulp/server.js
@@ -10,18 +10,24 @@
var httpProxy = require('http-proxy');
var del = require('del');
var sass = require('gulp-sass');
+var fs = require('fs');
+var path = require('path');
const environment = process.env.NODE_ENV;
-if (environment){
- var conf = require(`../env/${environment}.js`);
-}
-else{
- var conf = require('../env/default.js')
+if(!fs.existsSync(path.join(__dirname, `../../../env/${environment || 'default'}.js`))){
+ if(!environment){
+ throw new Error('You should define a default.js config in /views/env folder.');
+ }
+ else{
+ throw new Error(`Since you are loading a custom environment, you should define a ${environment}.js config in /views/env folder.`);
+ }
}
+var conf = require(path.join(__dirname, `../../../env/${environment || 'default'}.js`));
+
var proxy = httpProxy.createProxyServer({
- target: conf.host || 'http://0.0.0.0:9999'
+ target: conf.host
});
@@ -51,10 +57,6 @@
},
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){
diff --git a/views/ngXosLib/generator-xos/test/build.spec.js b/views/ngXosLib/generator-xos/test/build.spec.js
index dd49b03..19c338b 100644
--- a/views/ngXosLib/generator-xos/test/build.spec.js
+++ b/views/ngXosLib/generator-xos/test/build.spec.js
@@ -14,6 +14,9 @@
}
}
+// config files
+const cfg = path.join(__dirname, `../../../env/default.js`);
+
// source files
const viewName = 'testDashboard';
const fileName = viewName.replace(/^./, viewName[0].toUpperCase());
@@ -32,6 +35,12 @@
this.timeout(getMillisec(5));
before(done => {
+ // if `default.js` config is not present
+ // create one (we check to avoid screwing up local envs)
+ if(!fs.existsSync(cfg)){
+ fs.writeFileSync(cfg, 'module.exports = {}');
+ }
+
console.log('Running generator');
this.generator = helpers
.run(require.resolve('../app'))
diff --git a/views/ngXosLib/generator-xos/test/generator.spec.js b/views/ngXosLib/generator-xos/test/generator.spec.js
index 4ae1602..2c7abb5 100644
--- a/views/ngXosLib/generator-xos/test/generator.spec.js
+++ b/views/ngXosLib/generator-xos/test/generator.spec.js
@@ -65,10 +65,7 @@
.inDir(testPath)
.withOptions({ 'skip-install': true })
.withPrompts({
- name: viewName,
- host: 'test-host',
- token: 'test-token',
- session: 'test-session'
+ name: viewName
})
.on('end', done);
});
@@ -78,12 +75,6 @@
assert.file(getDefaultFiles());
});
- it('should create the env file with correct params', () => {
- assert.fileContent(`${testPath}env/default.js`, 'host: \'test-host\'');
- assert.fileContent(`${testPath}env/default.js`, 'xoscsrftoken: \'test-token\'');
- assert.fileContent(`${testPath}env/default.js`, 'xossessionid: \'test-session\'');
- });
-
it('should write username in package & bower json', () => {
assert.fileContent(`${testPath}package.json`, '"author": "Test User"');
assert.fileContent(`${testPath}bower.json`, '"Test User <test@mail.org>"')
diff --git a/views/ngXosViews/ceilometerDashboard/env/default.js b/views/ngXosViews/ceilometerDashboard/env/default.js
deleted file mode 100644
index d6dcddd..0000000
--- a/views/ngXosViews/ceilometerDashboard/env/default.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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://apt020.apt.emulab.net:9999/',
- xoscsrftoken: 'Z5RslzJ4IpxQ22c9pLyQalRnMbIGuK6p',
- xossessionid: '0fqmxa903dhj7pjkwk21lmhako9qgdi8'
-};
diff --git a/views/ngXosViews/ceilometerDashboard/env/srikanth.js b/views/ngXosViews/ceilometerDashboard/env/srikanth.js
deleted file mode 100644
index 388abf7..0000000
--- a/views/ngXosViews/ceilometerDashboard/env/srikanth.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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://130.127.133.41:9999',
- xoscsrftoken: 'pZAcFg4SqcXajLsk46cPypotlUyi8Y2R',
- xossessionid: 'qir5ym7n86zivh3dhv6ne2wgcjwsfyop'
-};
diff --git a/views/ngXosViews/ceilometerDashboard/gulp/server.js b/views/ngXosViews/ceilometerDashboard/gulp/server.js
index c0678d9..19caf89 100644
--- a/views/ngXosViews/ceilometerDashboard/gulp/server.js
+++ b/views/ngXosViews/ceilometerDashboard/gulp/server.js
@@ -10,21 +10,26 @@
var httpProxy = require('http-proxy');
var del = require('del');
var sass = require('gulp-sass');
+var fs = require('fs');
+var path = require('path');
const environment = process.env.NODE_ENV;
-if (environment){
- var conf = require(`../env/${environment}.js`);
+if(!fs.existsSync(path.join(__dirname, `../../../env/${environment || 'default'}.js`))){
+ if(!environment){
+ throw new Error('You should define a default.js config in /views/env folder.');
+ }
+ else{
+ throw new Error(`Since you are loading a custom environment, you should define a ${environment}.js config in /views/env folder.`);
+ }
}
-else{
- var conf = require('../env/default.js')
-}
+
+var conf = require(path.join(__dirname, `../../../env/${environment || 'default'}.js`));
var proxy = httpProxy.createProxyServer({
- target: conf.host || 'http://0.0.0.0:9999'
+ target: conf.host
});
-
proxy.on('error', function(error, req, res) {
res.writeHead(500, {
'Content-Type': 'text/plain'
@@ -51,10 +56,7 @@
},
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('?no_hyperlinks=1') !== -1 ||
req.url.indexOf('/api/') !== -1
){
if(conf.xoscsrftoken && conf.xossessionid){
diff --git a/views/ngXosViews/truckroll/src/templates/users-list.tpl.html b/views/ngXosViews/ceilometerDashboard/src/templates/users-list.tpl.html
similarity index 100%
copy from views/ngXosViews/truckroll/src/templates/users-list.tpl.html
copy to views/ngXosViews/ceilometerDashboard/src/templates/users-list.tpl.html
diff --git a/views/ngXosViews/contentProvider/env/default.js b/views/ngXosViews/contentProvider/env/default.js
deleted file mode 100644
index e4f9b73..0000000
--- a/views/ngXosViews/contentProvider/env/default.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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: 'v9QmTQomVGdvkps5K3AxWfTJeidrFOvt',
- xossessionid: 'h0chy2q37rrd8vpbt62c89wvp31b0ycb'
-};
diff --git a/views/ngXosViews/contentProvider/gulp/server.js b/views/ngXosViews/contentProvider/gulp/server.js
index 78c1620..0bc2bd3 100644
--- a/views/ngXosViews/contentProvider/gulp/server.js
+++ b/views/ngXosViews/contentProvider/gulp/server.js
@@ -10,18 +10,24 @@
var httpProxy = require('http-proxy');
var del = require('del');
var sass = require('gulp-sass');
+var fs = require('fs');
+var path = require('path');
const environment = process.env.NODE_ENV;
-if (environment){
- var conf = require(`../env/${environment}.js`);
-}
-else{
- var conf = require('../env/default.js')
+if(!fs.existsSync(path.join(__dirname, `../../../env/${environment || 'default'}.js`))){
+ if(!environment){
+ throw new Error('You should define a default.js config in /views/env folder.');
+ }
+ else{
+ throw new Error(`Since you are loading a custom environment, you should define a ${environment}.js config in /views/env folder.`);
+ }
}
+var conf = require(path.join(__dirname, `../../../env/${environment || 'default'}.js`));
+
var proxy = httpProxy.createProxyServer({
- target: conf.host || 'http://0.0.0.0:9999'
+ target: conf.host
});
@@ -51,11 +57,8 @@
},
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
+ req.url.indexOf('/api/') !== -1 ||
+ req.url.indexOf('/hpcapi/') !== -1
){
if(conf.xoscsrftoken && conf.xossessionid){
req.headers.cookie = `xoscsrftoken=${conf.xoscsrftoken}; xossessionid=${conf.xossessionid}`;
diff --git a/views/ngXosViews/truckroll/src/templates/users-list.tpl.html b/views/ngXosViews/contentProvider/src/templates/users-list.tpl.html
similarity index 100%
copy from views/ngXosViews/truckroll/src/templates/users-list.tpl.html
copy to views/ngXosViews/contentProvider/src/templates/users-list.tpl.html
diff --git a/views/ngXosViews/developer/env/default.js b/views/ngXosViews/developer/env/default.js
deleted file mode 100644
index 56a6b77..0000000
--- a/views/ngXosViews/developer/env/default.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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: 'Di0iR0Sjg6ZLb0icOtuBqnh5AmE1ddKW',
- xossessionid: 'oem5kppdaihc6pa5qa2ojtxt1r0xterh'
-};
diff --git a/views/ngXosViews/developer/env/mock.js b/views/ngXosViews/developer/env/mock.js
deleted file mode 100644
index 777c149..0000000
--- a/views/ngXosViews/developer/env/mock.js
+++ /dev/null
@@ -1,11 +0,0 @@
-// 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://127.0.0.1:4000/'
-};
diff --git a/views/ngXosViews/developer/gulp/build.js b/views/ngXosViews/developer/gulp/build.js
index f86af0f..87e68d8 100644
--- a/views/ngXosViews/developer/gulp/build.js
+++ b/views/ngXosViews/developer/gulp/build.js
@@ -150,6 +150,7 @@
gulp.task('build', function() {
runSequence(
'clean',
+ 'sass',
'templates',
'babel',
'scripts',
diff --git a/views/ngXosViews/developer/gulp/server.js b/views/ngXosViews/developer/gulp/server.js
index c0678d9..1e40a34 100644
--- a/views/ngXosViews/developer/gulp/server.js
+++ b/views/ngXosViews/developer/gulp/server.js
@@ -10,18 +10,24 @@
var httpProxy = require('http-proxy');
var del = require('del');
var sass = require('gulp-sass');
+var fs = require('fs');
+var path = require('path');
const environment = process.env.NODE_ENV;
-if (environment){
- var conf = require(`../env/${environment}.js`);
-}
-else{
- var conf = require('../env/default.js')
+if(!fs.existsSync(path.join(__dirname, `../../../env/${environment || 'default'}.js`))){
+ if(!environment){
+ throw new Error('You should define a default.js config in /views/env folder.');
+ }
+ else{
+ throw new Error(`Since you are loading a custom environment, you should define a ${environment}.js config in /views/env folder.`);
+ }
}
+var conf = require(path.join(__dirname, `../../../env/${environment || 'default'}.js`));
+
var proxy = httpProxy.createProxyServer({
- target: conf.host || 'http://0.0.0.0:9999'
+ target: conf.host
});
@@ -51,10 +57,6 @@
},
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){
diff --git a/views/ngXosViews/truckroll/src/templates/users-list.tpl.html b/views/ngXosViews/developer/src/templates/users-list.tpl.html
similarity index 100%
rename from views/ngXosViews/truckroll/src/templates/users-list.tpl.html
rename to views/ngXosViews/developer/src/templates/users-list.tpl.html
diff --git a/views/ngXosViews/diagnostic/.eslintrc b/views/ngXosViews/diagnostic/.eslintrc
index ef5b468..c852748 100644
--- a/views/ngXosViews/diagnostic/.eslintrc
+++ b/views/ngXosViews/diagnostic/.eslintrc
@@ -16,7 +16,6 @@
],
"rules": {
"quotes": [2, "single"],
- "no-undef": 2,
"camelcase": [1, {"properties": "always"}],
"no-underscore-dangle": 1,
"eqeqeq": [2, "smart"],
@@ -38,7 +37,6 @@
//"angular/ng_di": [0, "function or array"]
},
"globals" :{
- "angular": true,
- "d3": true
+ "angular": true
}
}
\ No newline at end of file
diff --git a/views/ngXosViews/diagnostic/bower.json b/views/ngXosViews/diagnostic/bower.json
index afb3524..9279b8e 100644
--- a/views/ngXosViews/diagnostic/bower.json
+++ b/views/ngXosViews/diagnostic/bower.json
@@ -1,10 +1,10 @@
{
- "name": "xos-serviceTopology",
+ "name": "xos-diagnostic",
"version": "0.0.0",
"authors": [
"Matteo Scandolo <teo@onlab.us>"
],
- "description": "The serviceTopology view",
+ "description": "The diagnostic view",
"license": "MIT",
"ignore": [
"**/.*",
@@ -14,18 +14,21 @@
"test",
"tests"
],
- "dependencies": {
- "d3": "~3.5.13",
- "lodash": "~4.0.0",
- "angular-animate": "~1.4.9"
- },
+ "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-resource": "~1.4.7",
- "bootstrap-css": "~3.3.6"
+ "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"
+ },
+ "resolutions": {
+ "angular": "1.4.7"
}
}
diff --git a/views/ngXosViews/diagnostic/env/default.js b/views/ngXosViews/diagnostic/env/default.js
deleted file mode 100644
index e9ed236..0000000
--- a/views/ngXosViews/diagnostic/env/default.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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://clnode067.clemson.cloudlab.us:9999/',
- xoscsrftoken: 'ZhPiXOVgQH2S0QQtLTkx3DaESR7IOvQc',
- xossessionid: '49cjbceeg483ife9rocex8h1st360ii3'
-};
diff --git a/views/ngXosViews/diagnostic/env/local.js b/views/ngXosViews/diagnostic/env/local.js
deleted file mode 100644
index 3a17b94..0000000
--- a/views/ngXosViews/diagnostic/env/local.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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: 'oPSbkruovBQoKcAOUVdX39Ncxt9E93MO',
- xossessionid: 'cy1kwat93lomok0d180c4c0cwvi5fpnn'
-};
diff --git a/views/ngXosViews/diagnostic/env/mock.js b/views/ngXosViews/diagnostic/env/mock.js
deleted file mode 100644
index c65eb2f..0000000
--- a/views/ngXosViews/diagnostic/env/mock.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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://localhost:4000/',
- xoscsrftoken: 'IGSrPSAOmBorK8uxbbscQbn3ODPb9dDW',
- xossessionid: 'i8hltbdt3po3uxkbvfmzy15o98p9s157'
-};
diff --git a/views/ngXosViews/diagnostic/env/onlab_pod.js b/views/ngXosViews/diagnostic/env/onlab_pod.js
deleted file mode 100644
index 42211be..0000000
--- a/views/ngXosViews/diagnostic/env/onlab_pod.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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://10.90.0.132/',
- xoscsrftoken: 'JmfZETFs72GiVGxIJkCPSrybZvTtJLwF',
- xossessionid: 'jmf3z9wat049cmrh91ppg37pn4yj3830'
-};
diff --git a/views/ngXosViews/diagnostic/gulp/build.js b/views/ngXosViews/diagnostic/gulp/build.js
index 1a1be80..20bbc14 100644
--- a/views/ngXosViews/diagnostic/gulp/build.js
+++ b/views/ngXosViews/diagnostic/gulp/build.js
@@ -39,7 +39,10 @@
// delete previous builded file
gulp.task('clean', function(){
return del(
- [options.dashboards + 'xosDiagnostic.html'],
+ [
+ options.dashboards + 'xosDiagnostic.html',
+ options.static + 'css/xosDiagnostic.css'
+ ],
{force: true}
);
});
@@ -60,7 +63,8 @@
.pipe(gulp.dest(options.tmp + '/css/'));
});
- gulp.task('copyCss', ['css'], function(){
+ // copy css in correct folder
+ gulp.task('copyCss', ['wait'], function(){
return gulp.src([`${options.tmp}/css/*.css`])
.pipe(concat('xosDiagnostic.css'))
.pipe(gulp.dest(options.static + 'css/'))
@@ -69,8 +73,7 @@
// compile and minify scripts
gulp.task('scripts', function() {
return gulp.src([
- options.tmp + '**/*.js',
- options.tmp + 'templates.js'
+ options.tmp + '**/*.js'
])
.pipe(ngAnnotate())
.pipe(angularFilesort())
@@ -86,19 +89,17 @@
return gulp.src('./src/templates/*.html')
.pipe(templateCache({
module: 'xos.diagnostic',
- root: 'templates/',
- // templateFooter: TEMPLATE_FOOTER
+ root: 'templates/'
}))
.pipe(gulp.dest(options.tmp));
});
// copy html index to Django Folder
- gulp.task('copyHtml', ['clean'], function(){
+ gulp.task('copyHtml', function(){
return gulp.src(options.src + 'index.html')
// remove dev dependencies from html
- .pipe(replace(/<!-- bower:css -->(\n.*)*\n<!-- endbower --><!-- endcss -->/, ''))
- .pipe(replace(/<!-- bower:js -->(\n.*)*\n<!-- endbower --><!-- endjs -->/, ''))
- // .pipe(replace(/ng-app=".*"\s/, ''))
+ .pipe(replace(/<!-- bower:css -->(\n^<link.*)*\n<!-- endbower -->/gmi, ''))
+ .pipe(replace(/<!-- bower:js -->(\n^<script.*)*\n<!-- endbower -->/gmi, ''))
// injecting minified files
.pipe(
inject(
@@ -139,30 +140,25 @@
.pipe(eslint.failAfterError());
});
- // inject CSS
- gulp.task('injectCss', function(){
- return gulp.src(options.src + 'index.html')
- .pipe(
- inject(
- gulp.src(options.src + 'css/*.css'),
- {
- ignorePath: [options.src]
- }
- )
- )
- .pipe(gulp.dest(options.src));
+ gulp.task('wait', function (cb) {
+ // setTimeout could be any async task
+ setTimeout(function () {
+ cb();
+ }, 1000);
});
gulp.task('build', function() {
runSequence(
- 'lint',
+ 'clean',
+ 'sass',
'templates',
'babel',
'scripts',
'wiredep',
- 'injectCss',
+ 'css',
+ 'copyCss',
'copyHtml',
- 'copyCss'
+ 'cleanTmp'
);
});
};
\ No newline at end of file
diff --git a/views/ngXosViews/diagnostic/gulp/server.js b/views/ngXosViews/diagnostic/gulp/server.js
index 194bd45..fbc605b 100644
--- a/views/ngXosViews/diagnostic/gulp/server.js
+++ b/views/ngXosViews/diagnostic/gulp/server.js
@@ -10,18 +10,24 @@
var httpProxy = require('http-proxy');
var del = require('del');
var sass = require('gulp-sass');
+var fs = require('fs');
+var path = require('path');
const environment = process.env.NODE_ENV;
-if (environment){
- var conf = require(`../env/${environment}.js`);
-}
-else{
- var conf = require('../env/default.js')
+if(!fs.existsSync(path.join(__dirname, `../../../env/${environment || 'default'}.js`))){
+ if(!environment){
+ throw new Error('You should define a default.js config in /views/env folder.');
+ }
+ else{
+ throw new Error(`Since you are loading a custom environment, you should define a ${environment}.js config in /views/env folder.`);
+ }
}
+var conf = require(path.join(__dirname, `../../../env/${environment || 'default'}.js`));
+
var proxy = httpProxy.createProxyServer({
- target: conf.host || 'http://0.0.0.0:9999'
+ target: conf.host
});
@@ -35,12 +41,8 @@
module.exports = function(options){
- // open in browser with sync and proxy to 0.0.0.0
gulp.task('browser', function() {
browserSync.init({
- // reloadDelay: 500,
- // logLevel: 'debug',
- // logConnections: true,
startPath: '#/',
snippetOptions: {
rule: {
@@ -50,14 +52,13 @@
server: {
baseDir: options.src,
routes: {
- '/api': options.api,
- '/xosHelpers/src': options.helpers
+ '/xos/core/xoslib/static/js/vendor': options.helpers,
+ '/xos/core/static': options.static + '../../static/'
},
middleware: function(req, res, next){
if(
- req.url.indexOf('/xos/') !== -1 ||
- req.url.indexOf('/xoslib/') !== -1 ||
- req.url.indexOf('/hpcapi/') !== -1
+ req.url.indexOf('/?no_hyperlinks') !== -1 ||
+ req.url.indexOf('/api/') !== -1
){
if(conf.xoscsrftoken && conf.xossessionid){
req.headers.cookie = `xoscsrftoken=${conf.xoscsrftoken}; xossessionid=${conf.xossessionid}`;
@@ -85,17 +86,21 @@
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));
});
-
- // gulp.task('sass:watch', function () {
- // gulp.watch('./sass/**/*.scss', ['sass']);
- // });
// transpile js with sourceMaps
gulp.task('babel', function(){
@@ -111,8 +116,7 @@
inject(
gulp.src([
options.tmp + '**/*.js',
- options.api + '*.js',
- options.helpers + '**/*.js'
+ options.helpers + 'ngXosHelpers.js'
])
.pipe(angularFilesort()),
{
@@ -128,7 +132,10 @@
return gulp.src(options.src + 'index.html')
.pipe(
inject(
- gulp.src(options.src + 'css/*.css'),
+ gulp.src([
+ options.src + 'css/*.css',
+ options.static + '../../static/xosNgLib.css'
+ ]),
{
ignorePath: [options.src]
}
diff --git a/views/ngXosViews/diagnostic/gulpfile.js b/views/ngXosViews/diagnostic/gulpfile.js
index 3f1e899..08df554 100644
--- a/views/ngXosViews/diagnostic/gulpfile.js
+++ b/views/ngXosViews/diagnostic/gulpfile.js
@@ -11,8 +11,8 @@
tmp: 'src/.tmp',
dist: 'dist/',
api: '../../ngXosLib/api/',
- helpers: '../../ngXosLib/xosHelpers/src/',
- static: '../../../xos/core/xoslib/static/', // this is the django static folder from dev environment
+ 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
};
diff --git a/views/ngXosViews/diagnostic/karma.conf.js b/views/ngXosViews/diagnostic/karma.conf.js
index 5e312fa..44283c8 100644
--- a/views/ngXosViews/diagnostic/karma.conf.js
+++ b/views/ngXosViews/diagnostic/karma.conf.js
@@ -28,7 +28,6 @@
files: bowerComponents.concat([
'../../../xos/core/xoslib/static/js/vendor/ngXosVendor.js',
'../../../xos/core/xoslib/static/js/vendor/ngXosHelpers.js',
- '../../../xos/core/xoslib/static/js/xosApi.js',
'src/js/main.js',
'src/js/**/*.js',
'spec/**/*.mock.js',
diff --git a/views/ngXosViews/diagnostic/src/index.html b/views/ngXosViews/diagnostic/src/index.html
index f728df3..f91ebbb 100644
--- a/views/ngXosViews/diagnostic/src/index.html
+++ b/views/ngXosViews/diagnostic/src/index.html
@@ -1,9 +1,11 @@
<!-- 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 -->
<div ng-app="xos.diagnostic" id="xosDiagnostic">
@@ -11,28 +13,21 @@
</div>
<!-- bower:js -->
-<script src="vendor/d3/d3.js"></script>
-<script src="vendor/lodash/lodash.js"></script>
-<script src="vendor/angular/angular.js"></script>
-<script src="vendor/angular-animate/angular-animate.js"></script>
<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/ng-lodash/build/ng-lodash.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>
<!-- endbower --><!-- endjs -->
<!-- inject:js -->
-<script src="/xosHelpers/src/xosHelpers.module.js"></script>
-<script src="/xosHelpers/src/ui_components/table/table.component.js"></script>
-<script src="/xosHelpers/src/ui_components/ui-components.module.js"></script>
-<script src="/xosHelpers/src/services/noHyperlinks.interceptor.js"></script>
-<script src="/xosHelpers/src/services/csrfToken.interceptor.js"></script>
-<script src="/xosHelpers/src/services/api.services.js"></script>
-<script src="/api/ng-xoslib.js"></script>
-<script src="/api/ng-xos.js"></script>
-<script src="/api/ng-hpcapi.js"></script>
+<script src="/../../../xos/core/xoslib/static/js/vendor/ngXosHelpers.js"></script>
<script src="/.tmp/main.js"></script>
<script src="/.tmp/subscriber-modal.js"></script>
<script src="/.tmp/serviceTopologyHelper.js"></script>
diff --git a/views/ngXosViews/diagnostic/src/js/rest_services.js b/views/ngXosViews/diagnostic/src/js/rest_services.js
index d8dfaf3..fa2fc8f 100644
--- a/views/ngXosViews/diagnostic/src/js/rest_services.js
+++ b/views/ngXosViews/diagnostic/src/js/rest_services.js
@@ -3,10 +3,10 @@
angular.module('xos.diagnostic')
.service('Services', function($resource){
- return $resource('/xos/services/:id', {id: '@id'});
+ return $resource('/api/core/services/:id', {id: '@id'});
})
.service('Tenant', function($resource){
- return $resource('/xos/tenants', {id: '@id'}, {
+ return $resource('/api/core/tenants', {id: '@id'}, {
queryVsgInstances: {
method: 'GET',
isArray: true,
@@ -124,13 +124,13 @@
}
})
.service('Slice', function($resource){
- return $resource('/xos/slices', {id: '@id'});
+ return $resource('/api/core/slices', {id: '@id'});
})
.service('Instances', function($resource){
- return $resource('/xos/instances/:id', {id: '@id'});
+ return $resource('/api/core/instances/:id', {id: '@id'});
})
.service('Node', function($resource, $q, Instances){
- return $resource('/xos/nodes', {id: '@id'}, {
+ return $resource('/api/core/nodes', {id: '@id'}, {
queryWithInstances: {
method: 'GET',
isArray: true,
diff --git a/views/ngXosViews/truckroll/src/templates/users-list.tpl.html b/views/ngXosViews/diagnostic/src/templates/users-list.tpl.html
similarity index 100%
copy from views/ngXosViews/truckroll/src/templates/users-list.tpl.html
copy to views/ngXosViews/diagnostic/src/templates/users-list.tpl.html
diff --git a/views/ngXosViews/openVPNDashboard/env/default.js b/views/ngXosViews/openVPNDashboard/env/default.js
deleted file mode 100644
index 5f463b3..0000000
--- a/views/ngXosViews/openVPNDashboard/env/default.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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: 'rDX21sz1qNQeClOj1zvDu1yMqUBtzl0i',
- xossessionid: '7ouvstt0dgpq2um4cak8uunp1ssl8cs6'
-};
diff --git a/views/ngXosViews/openVPNDashboard/gulp/server.js b/views/ngXosViews/openVPNDashboard/gulp/server.js
index c0678d9..1e40a34 100644
--- a/views/ngXosViews/openVPNDashboard/gulp/server.js
+++ b/views/ngXosViews/openVPNDashboard/gulp/server.js
@@ -10,18 +10,24 @@
var httpProxy = require('http-proxy');
var del = require('del');
var sass = require('gulp-sass');
+var fs = require('fs');
+var path = require('path');
const environment = process.env.NODE_ENV;
-if (environment){
- var conf = require(`../env/${environment}.js`);
-}
-else{
- var conf = require('../env/default.js')
+if(!fs.existsSync(path.join(__dirname, `../../../env/${environment || 'default'}.js`))){
+ if(!environment){
+ throw new Error('You should define a default.js config in /views/env folder.');
+ }
+ else{
+ throw new Error(`Since you are loading a custom environment, you should define a ${environment}.js config in /views/env folder.`);
+ }
}
+var conf = require(path.join(__dirname, `../../../env/${environment || 'default'}.js`));
+
var proxy = httpProxy.createProxyServer({
- target: conf.host || 'http://0.0.0.0:9999'
+ target: conf.host
});
@@ -51,10 +57,6 @@
},
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){
diff --git a/views/ngXosViews/openVPNDashboard/src/index.html b/views/ngXosViews/openVPNDashboard/src/index.html
index 96dca68..8a97f14 100644
--- a/views/ngXosViews/openVPNDashboard/src/index.html
+++ b/views/ngXosViews/openVPNDashboard/src/index.html
@@ -5,7 +5,6 @@
<!-- endbower --><!-- endcss -->
<!-- inject:css -->
<link rel="stylesheet" href="/css/main.css">
-<link rel="stylesheet" href="/css/openVPNDashboard.css">
<link rel="stylesheet" href="/../../../xos/core/static/xosNgLib.css">
<!-- endinject -->
diff --git a/views/ngXosViews/serviceGrid/bower.json b/views/ngXosViews/serviceGrid/bower.json
index 0cac826..bae4e4d 100644
--- a/views/ngXosViews/serviceGrid/bower.json
+++ b/views/ngXosViews/serviceGrid/bower.json
@@ -27,6 +27,6 @@
"lodash": "~4.11.1",
"bootstrap-css": "3.3.6",
"angular-chart.js": "~0.10.2",
- "d3": "~3.5.13"
+ "d3": "~3.5.17"
}
}
diff --git a/views/ngXosViews/serviceGrid/env/default.js b/views/ngXosViews/serviceGrid/env/default.js
deleted file mode 100644
index c93b55c..0000000
--- a/views/ngXosViews/serviceGrid/env/default.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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: 'QVWEAqnNKBLT7pzsjpgiL10eGSKeCxxN',
- xossessionid: 'qrb3fxh8uz3abxjy59w8uccpm6u2twa8'
-};
diff --git a/views/ngXosViews/serviceGrid/gulp/build.js b/views/ngXosViews/serviceGrid/gulp/build.js
index b582642..2916028 100644
--- a/views/ngXosViews/serviceGrid/gulp/build.js
+++ b/views/ngXosViews/serviceGrid/gulp/build.js
@@ -98,8 +98,8 @@
gulp.task('copyHtml', function(){
return gulp.src(options.src + 'index.html')
// remove dev dependencies from html
- .pipe(replace(/<!-- bower:css -->(\n.*)*\n<!-- endbower --><!-- endcss -->/, ''))
- .pipe(replace(/<!-- bower:js -->(\n.*)*\n<!-- endbower --><!-- endjs -->/, ''))
+ .pipe(replace(/<!-- bower:css -->(\n^<link.*)*\n<!-- endbower -->/gmi, ''))
+ .pipe(replace(/<!-- bower:js -->(\n^<script.*)*\n<!-- endbower -->/gmi, ''))
// injecting minified files
.pipe(
inject(
@@ -150,6 +150,7 @@
gulp.task('build', function() {
runSequence(
'clean',
+ 'sass',
'templates',
'babel',
'scripts',
diff --git a/views/ngXosViews/serviceGrid/gulp/server.js b/views/ngXosViews/serviceGrid/gulp/server.js
index c0678d9..1e40a34 100644
--- a/views/ngXosViews/serviceGrid/gulp/server.js
+++ b/views/ngXosViews/serviceGrid/gulp/server.js
@@ -10,18 +10,24 @@
var httpProxy = require('http-proxy');
var del = require('del');
var sass = require('gulp-sass');
+var fs = require('fs');
+var path = require('path');
const environment = process.env.NODE_ENV;
-if (environment){
- var conf = require(`../env/${environment}.js`);
-}
-else{
- var conf = require('../env/default.js')
+if(!fs.existsSync(path.join(__dirname, `../../../env/${environment || 'default'}.js`))){
+ if(!environment){
+ throw new Error('You should define a default.js config in /views/env folder.');
+ }
+ else{
+ throw new Error(`Since you are loading a custom environment, you should define a ${environment}.js config in /views/env folder.`);
+ }
}
+var conf = require(path.join(__dirname, `../../../env/${environment || 'default'}.js`));
+
var proxy = httpProxy.createProxyServer({
- target: conf.host || 'http://0.0.0.0:9999'
+ target: conf.host
});
@@ -51,10 +57,6 @@
},
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){
diff --git a/views/ngXosViews/truckroll/env/default.js b/views/ngXosViews/truckroll/env/default.js
deleted file mode 100644
index 3cb3cc2..0000000
--- a/views/ngXosViews/truckroll/env/default.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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: 'AJkHTtR8zZi8UAZsH7RjEj6qvvV8DjAL',
- xossessionid: '1mtzd7n9l3qkck4hc8tmuii491ovg07w'
-};
diff --git a/views/ngXosViews/truckroll/gulp/server.js b/views/ngXosViews/truckroll/gulp/server.js
index c0678d9..1e40a34 100644
--- a/views/ngXosViews/truckroll/gulp/server.js
+++ b/views/ngXosViews/truckroll/gulp/server.js
@@ -10,18 +10,24 @@
var httpProxy = require('http-proxy');
var del = require('del');
var sass = require('gulp-sass');
+var fs = require('fs');
+var path = require('path');
const environment = process.env.NODE_ENV;
-if (environment){
- var conf = require(`../env/${environment}.js`);
-}
-else{
- var conf = require('../env/default.js')
+if(!fs.existsSync(path.join(__dirname, `../../../env/${environment || 'default'}.js`))){
+ if(!environment){
+ throw new Error('You should define a default.js config in /views/env folder.');
+ }
+ else{
+ throw new Error(`Since you are loading a custom environment, you should define a ${environment}.js config in /views/env folder.`);
+ }
}
+var conf = require(path.join(__dirname, `../../../env/${environment || 'default'}.js`));
+
var proxy = httpProxy.createProxyServer({
- target: conf.host || 'http://0.0.0.0:9999'
+ target: conf.host
});
@@ -51,10 +57,6 @@
},
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){
diff --git a/views/ngXosViews/truckroll/spec/sample.test.js b/views/ngXosViews/truckroll/spec/sample.test.js
index 06ebc1b..52ebe84 100644
--- a/views/ngXosViews/truckroll/spec/sample.test.js
+++ b/views/ngXosViews/truckroll/spec/sample.test.js
@@ -26,7 +26,7 @@
isolatedScope = element.isolateScope().vm;
}));
- it('should load 1 users', () => {
+ it('should load 1 subscriber', () => {
httpBackend.flush();
expect(isolatedScope.subscribers.length).toBe(1);
});
diff --git a/xos/api/utility/sliceplus.py b/xos/api/utility/sliceplus.py
index ca52125..cecea4d 100644
--- a/xos/api/utility/sliceplus.py
+++ b/xos/api/utility/sliceplus.py
@@ -19,6 +19,7 @@
DictionaryField = serializers.DictField
ListField = serializers.ListField
+
class SlicePlus(Slice, PlusObjectMixin):
class Meta:
proxy = True
@@ -82,7 +83,8 @@
if network.ports:
networkPorts = network.ports
- self._sliceInfo= {"sitesUsed": used_sites,
+ self._sliceInfo = {
+ "sitesUsed": used_sites,
"sitesReady": ready_sites,
"instanceStatus": instance_status,
"deploymentsUsed": used_deployments,
@@ -134,7 +136,7 @@
@user_names.setter
def user_names(self, value):
- pass # it's read-only
+ pass # it's read-only
@property
def users(self):
@@ -168,13 +170,13 @@
if (node.site_deployment.site.id in siteIDList):
node.instanceCount = 0
for instance in node.instances.all():
- if instance.slice.id == self.id:
- node.instanceCount = node.instanceCount + 1
+ if instance.slice.id == self.id:
+ node.instanceCount = node.instanceCount + 1
nodeList.append(node)
return nodeList
def save(self, *args, **kwargs):
- if (not hasattr(self,"caller")) or self.caller==None:
+ if (not hasattr(self, "caller")) or self.caller==None:
raise APIException("no self.caller in SlicePlus.save")
updated_image = self.has_field_changed("default_image")
@@ -224,7 +226,7 @@
instances.append(instance)
# delete extra instances
- while (reset and len(instances)>0) or (len(instances) > desired_allocation):
+ while (reset and len(instances) > 0) or (len(instances) > desired_allocation):
instance = instances.pop()
if (not noAct):
print "deleting instance", instance
@@ -234,7 +236,7 @@
# add more instances
if (len(instances) < desired_allocation):
- site = Site.objects.get(name = site_name)
+ site = Site.objects.get(name=site_name)
nodes = self.get_node_allocation([site])
if (not nodes):
@@ -246,12 +248,12 @@
node = nodes[0]
instance = Instance(name=node.name,
- slice=self,
- node=node,
- image = self.default_image,
- flavor = self.default_flavor,
- creator = self.creator,
- deployment = node.site_deployment.deployment)
+ slice=self,
+ node=node,
+ image=self.default_image,
+ flavor=self.default_flavor,
+ creator=self.creator,
+ deployment=node.site_deployment.deployment)
instance.caller = self.caller
instances.append(instance)
if (not noAct):
@@ -262,7 +264,7 @@
node.instanceCount = node.instanceCount + 1
- def save_users(self, noAct = False):
+ def save_users(self, noAct=False):
new_users = self._update_users
try:
@@ -283,15 +285,15 @@
print "added user id", user_id
for priv in slice_privs:
- if (priv.role.id != default_role.id):
- # only mess with 'default' users; don't kill an admin
- continue
+ if (priv.role.id != default_role.id):
+ # only mess with 'default' users; don't kill an admin
+ continue
- if (priv.user.id not in new_users):
- if (not noAct):
- priv.delete()
+ if (priv.user.id not in new_users):
+ if (not noAct):
+ priv.delete()
- print "deleted user id", user_id
+ print "deleted user id", user_id
def save_network_ports(self, noAct=False):
# First search for any network that already has a filled in 'ports'
@@ -314,7 +316,7 @@
network = networkSlice.network
if (network.owner.id != self.id):
continue
- if network.template.translation=="NAT":
+ if network.template.translation == "NAT":
network.ports = self._network_ports
network.caller = self.caller
if (not noAct):
@@ -325,6 +327,7 @@
raise APIException(detail="No network was found that ports could be set on")
+
class SlicePlusIdSerializer(PlusModelSerializer):
id = IdField()
@@ -336,14 +339,14 @@
instance_total_ready = serializers.IntegerField(read_only=True)
instance_status = DictionaryField(read_only=True)
users = ListField(required=False)
- user_names = ListField(required=False) # readonly = True ?
+ user_names = ListField(required=False) # readonly = True ?
current_user_can_see = serializers.SerializerMethodField("getCurrentUserCanSee")
def getCurrentUserCanSee(self, slice):
# user can 'see' the slice if he is the creator or he has a role
current_user = self.context['request'].user
- if (slice.creator and slice.creator==current_user):
- return True;
+ if (slice.creator and slice.creator == current_user):
+ return True
return (len(slice.getSliceInfo(current_user)["roles"]) > 0)
def getSliceInfo(self, slice):
@@ -356,13 +359,16 @@
class Meta:
model = SlicePlus
- fields = ('humanReadableName', 'id','created','updated','enacted','name','enabled','omf_friendly','description','slice_url','site','max_instances','service','network','mount_data_sets',
+ fields = ('humanReadableName', 'id', 'created', 'updated', 'enacted', 'name', 'enabled', 'omf_friendly',
+ 'description', 'slice_url', 'site', 'max_instances', 'service', 'network', 'mount_data_sets',
'default_image', 'default_flavor',
- 'serviceClass','creator',
+ 'serviceClass', 'creator',
# these are the value-added fields from SlicePlus
- 'networks','network_ports','backendIcon','backendHtml',
- 'current_user_roles', 'instance_distribution','instance_distribution_ready','instance_total','instance_total_ready','instance_status','users',"user_names","current_user_can_see")
+ 'networks', 'network_ports', 'backendIcon', 'backendHtml',
+ 'current_user_roles', 'instance_distribution', 'instance_distribution_ready', 'instance_total',
+ 'instance_total_ready', 'instance_status', 'users', "user_names", "current_user_can_see")
+
class SlicePlusList(XOSListCreateAPIView):
queryset = SlicePlus.objects.select_related().all()
@@ -373,12 +379,16 @@
def get_queryset(self):
current_user_can_see = self.request.query_params.get('current_user_can_see', False)
+ site_filter = self.request.query_params.get('site', False)
if (not self.request.user.is_authenticated()):
raise XOSPermissionDenied("You must be authenticated in order to use this API")
slices = SlicePlus.select_by_user(self.request.user)
+ if (site_filter and not current_user_can_see):
+ slices = SlicePlus.objects.filter(site=site_filter)
+
# If current_user_can_see is set, then filter the queryset to return
# only those slices that the user is either creator or has privilege
# on.
@@ -387,11 +397,14 @@
for slice in slices:
if (self.request.user == slice.creator) or (len(slice.getSliceInfo(self.request.user)["roles"]) > 0):
slice_ids.append(slice.id)
-
- slices = SlicePlus.objects.filter(id__in=slice_ids)
+ if (site_filter):
+ slices = SlicePlus.objects.filter(id__in=slice_ids, site=site_filter)
+ else:
+ slices = SlicePlus.objects.filter(id__in=slice_ids)
return slices
+
class SlicePlusDetail(XOSRetrieveUpdateDestroyAPIView):
queryset = SlicePlus.objects.select_related().all()
serializer_class = SlicePlusIdSerializer
@@ -403,5 +416,3 @@
if (not self.request.user.is_authenticated()):
raise XOSPermissionDenied("You must be authenticated in order to use this API")
return SlicePlus.select_by_user(self.request.user)
-
-
diff --git a/xos/configurations/frontend/docker-compose.yml b/xos/configurations/frontend/docker-compose.yml
index 7e98da4..722ef96 100644
--- a/xos/configurations/frontend/docker-compose.yml
+++ b/xos/configurations/frontend/docker-compose.yml
@@ -29,3 +29,4 @@
- ../../templates:/opt/xos/templates
- ../../configurations:/opt/xos/configurations
- ../../xos:/opt/xos/xos
+ - ../../api:/opt/xos/api
diff --git a/xos/core/xoslib/methods/sliceplus.py b/xos/core/xoslib/methods/sliceplus.py
index 9e5b4a1..6908d3c 100644
--- a/xos/core/xoslib/methods/sliceplus.py
+++ b/xos/core/xoslib/methods/sliceplus.py
@@ -77,12 +77,16 @@
def get_queryset(self):
current_user_can_see = self.request.query_params.get('current_user_can_see', False)
+ site_filter = self.request.query_params.get('site', False)
if (not self.request.user.is_authenticated()):
raise XOSPermissionDenied("You must be authenticated in order to use this API")
slices = SlicePlus.select_by_user(self.request.user)
+ if (site_filter and not current_user_can_see):
+ slices = SlicePlus.objects.filter(site=site_filter)
+
# If current_user_can_see is set, then filter the queryset to return
# only those slices that the user is either creator or has privilege
# on.
@@ -91,11 +95,14 @@
for slice in slices:
if (self.request.user == slice.creator) or (len(slice.getSliceInfo(self.request.user)["roles"]) > 0):
slice_ids.append(slice.id)
-
- slices = SlicePlus.objects.filter(id__in=slice_ids)
+ if (site_filter):
+ slices = SlicePlus.objects.filter(id__in=slice_ids, site=site_filter)
+ else:
+ slices = SlicePlus.objects.filter(id__in=slice_ids)
return slices
+
class SlicePlusDetail(XOSRetrieveUpdateDestroyAPIView):
queryset = SlicePlus.objects.select_related().all()
serializer_class = SlicePlusIdSerializer