Merge branch 'master' of github.com:open-cloud/xos
diff --git a/apiary.apib b/apiary.apib
index c94fe2d..d7034d8 100644
--- a/apiary.apib
+++ b/apiary.apib
@@ -3,97 +3,6 @@
# XOS
-# Group Instances
-
-List of the XOS instances
-
-## Instances [/api/core/instances/{instance_id}/]
-
-### List all Instances [GET]
-
-+ Response 200 (application/json)
-
- [
- {
- "id": 1,
- "humanReadableName": "uninstantiated-1",
- "created": "2016-04-26T00:36:22.465259Z",
- "updated": "2016-04-26T00:36:22.465288Z",
- "enacted": null,
- "policed": null,
- "backend_register": "{}",
- "backend_status": "0 - Provisioning in progress",
- "deleted": false,
- "write_protect": false,
- "lazy_blocked": false,
- "no_sync": false,
- "instance_id": null,
- "instance_uuid": null,
- "name": "mysite_vcpe",
- "instance_name": null,
- "ip": null,
- "image": "http://xos.dev:9999/api/core/images/1/",
- "creator": "http://xos.dev:9999/api/core/users/1/",
- "slice": "http://xos.dev:9999/api/core/slices/1/",
- "deployment": "http://xos.dev:9999/api/core/deployments/1/",
- "node": "http://xos.dev:9999/api/core/nodes/1/",
- "numberCores": 0,
- "flavor": "http://xos.dev:9999/api/core/flavors/1/",
- "userData": null,
- "isolation": "vm",
- "volumes": "/etc/dnsmasq.d,/etc/ufw",
- "parent": null,
- "networks": [
- "http://xos.dev:9999/api/core/networks/2/"
- ]
- }
- ]
-
-
-
-# Group Users
-
-List of the XOS users
-
-## Users [/api/core/users/{user_id}/]
-
-### List all Users [GET]
-
-+ Response 200 (application/json)
-
- [
- {
- "id": 2,
- "password": "pbkdf2_sha256$12000$9gn8DmZuIoz2$YPQkx3AOOV7jZNYr2ddrgUCkiuaPpvb8+aJR7RwLZNA=",
- "last_login": "2016-04-12T18:50:45.880823Z",
- "email": "johndoe@myhouse.com",
- "username": "johndoe@myhouse.com",
- "firstname": "john",
- "lastname": "doe",
- "phone": null,
- "user_url": null,
- "site": "http://xos.dev:9999/api/core/sites/1/",
- "public_key": null,
- "is_active": true,
- "is_admin": false,
- "is_staff": true,
- "is_readonly": false,
- "is_registering": false,
- "is_appuser": false,
- "login_page": null,
- "created": "2016-04-12T18:50:45.912602Z",
- "updated": "2016-04-12T18:50:45.912671Z",
- "enacted": null,
- "policed": null,
- "backend_status": "Provisioning in progress",
- "deleted": false,
- "write_protect": false,
- "timezone": "America/New_York"
- }
- ]
-
-
-
# Group Example
## Example Services Collection [/api/service/exampleservice/]
@@ -152,6 +61,326 @@
]
+# Group Deployments
+
+List of the XOS deployments
+
+## Deployments [/api/core/deployments/{id}/]
+
+### List all deployments [GET]
+
++ Response 200 (application/json)
+
+ {
+ "humanReadableName": "MyDeployment",
+ "id": 1,
+ "created": "2016-04-29T16:19:03.549901Z",
+ "updated": "2016-04-29T16:19:05.624151Z",
+ "enacted": null,
+ "policed": null,
+ "backend_register": "{}",
+ "backend_status": "0 - Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "lazy_blocked": false,
+ "no_sync": true,
+ "name": "MyDeployment",
+ "accessControl": "allow all",
+ "images": [
+ "1"
+ ],
+ "sites": [
+ "1"
+ ],
+ "flavors": [
+ "1",
+ "2",
+ "3"
+ ],
+ "dashboardviews": [
+ "1"
+ ]
+ }
+
+
+# Group Flavors
+
+List of the XOS flavors
+
+## Flavors [/api/core/flavors/{id}/]
+
+### List all flavors [GET]
+
++ Response 200 (application/json)
+
+ [
+ {
+ "humanReadableName": "m1.large",
+ "id": 1,
+ "created": "2016-04-29T16:19:01.979548Z",
+ "updated": "2016-04-29T16:19:03.568238Z",
+ "enacted": null,
+ "policed": null,
+ "backend_register": "{}",
+ "backend_status": "0 - Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "lazy_blocked": false,
+ "no_sync": true,
+ "name": "m1.large",
+ "description": null,
+ "flavor": "m1.large",
+ "order": 0,
+ "default": false,
+ "deployments": [
+ "1"
+ ]
+ }
+ ]
+
+### View a Flavors Detail [GET]
+
++ Parameters
+ + id: 1 (number) - ID of the Flavors in the form of an integer
+
++ Response 200 (application/json)
+
+ {
+ "humanReadableName": "m1.large",
+ "id": 1,
+ "created": "2016-04-29T16:19:01.979548Z",
+ "updated": "2016-04-29T16:19:03.568238Z",
+ "enacted": null,
+ "policed": null,
+ "backend_register": "{}",
+ "backend_status": "0 - Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "lazy_blocked": false,
+ "no_sync": true,
+ "name": "m1.large",
+ "description": null,
+ "flavor": "m1.large",
+ "order": 0,
+ "default": false,
+ "deployments": [
+ "1"
+ ]
+ }
+
+
+# Group Instances
+
+List of the XOS instances
+
+## Instances [/api/core/instances/{id}/]
+
+### List all Instances [GET]
+
++ Response 200 (application/json)
+
+ [
+ {
+ "id": 1,
+ "humanReadableName": "uninstantiated-1",
+ "created": "2016-04-26T00:36:22.465259Z",
+ "updated": "2016-04-26T00:36:22.465288Z",
+ "enacted": null,
+ "policed": null,
+ "backend_register": "{}",
+ "backend_status": "0 - Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "lazy_blocked": false,
+ "no_sync": false,
+ "instance_id": null,
+ "instance_uuid": null,
+ "name": "mysite_vcpe",
+ "instance_name": null,
+ "ip": null,
+ "image": "1",
+ "creator": "1",
+ "slice": "1",
+ "deployment": "1",
+ "node": "1",
+ "numberCores": 0,
+ "flavor": "1",
+ "userData": null,
+ "isolation": "vm",
+ "volumes": "/etc/dnsmasq.d,/etc/ufw",
+ "parent": null,
+ "networks": [
+ "1"
+ ]
+ }
+ ]
+
+
+
+# Group Nodes
+
+List of the XOS nodes
+
+## Nodes [/api/core/nodes/{id}/]
+
+### List all nodes [GET]
+
++ Response 200 (application/json)
+
+ [
+ {
+ "humanReadableName": "node2.opencloud.us",
+ "id": 1,
+ "created": "2016-04-29T16:19:05.661567Z",
+ "updated": "2016-04-29T16:19:05.661454Z",
+ "enacted": null,
+ "policed": null,
+ "backend_register": "{}",
+ "backend_status": "0 - Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "lazy_blocked": false,
+ "no_sync": true,
+ "name": "node2.opencloud.us",
+ "site_deployment": "1",
+ "site": "1",
+ "nodelabels": []
+ }
+ ]
+
+
+
+# Group Sites
+
+List of the XOS sites
+
+## Sites [/api/core/sites/{id}/]
+
+### List all sites [GET]
+
++ Response 200 (application/json)
+
+ {
+ "humanReadableName": "MySite",
+ "id": 1,
+ "created": "2016-04-29T16:19:03.587770Z",
+ "updated": "2016-04-29T16:19:05.651933Z",
+ "enacted": null,
+ "policed": null,
+ "backend_register": "{}",
+ "backend_status": "0 - Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "lazy_blocked": false,
+ "no_sync": false,
+ "name": "MySite",
+ "site_url": "http://opencord.us/",
+ "enabled": true,
+ "hosts_nodes": true,
+ "hosts_users": true,
+ "location": null,
+ "longitude": null,
+ "latitude": null,
+ "login_base": "mysite",
+ "is_public": true,
+ "abbreviated_name": "",
+ "deployments": [
+ "1"
+ ]
+ }
+
+
+# Group Slices
+
+List of the XOS slices
+
+## Slices [/api/core/slices/{id}/]
+
+### List all slices [GET]
+
++ Response 200 (application/json)
+
+ [
+ {
+ "humanReadableName": "mysite_slice",
+ "id": 1,
+ "created": "2016-04-29T16:23:22.505072Z",
+ "updated": "2016-04-29T16:23:22.504691Z",
+ "enacted": null,
+ "policed": "2016-04-29T16:23:22.781298Z",
+ "backend_register": "{}",
+ "backend_status": "0 - Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "lazy_blocked": false,
+ "no_sync": false,
+ "name": "mysite_slice",
+ "enabled": true,
+ "omf_friendly": false,
+ "description": "",
+ "slice_url": "",
+ "site": "http://apt118.apt.emulab.net/api/core/sites/1/",
+ "max_instances": 10,
+ "service": null,
+ "network": null,
+ "exposed_ports": null,
+ "serviceClass": "http://apt118.apt.emulab.net/api/core/serviceclasses/1/",
+ "creator": "http://apt118.apt.emulab.net/api/core/users/1/",
+ "default_flavor": null,
+ "default_image": null,
+ "mount_data_sets": "GenBank",
+ "default_isolation": "vm",
+ "networks": [
+ "http://apt118.apt.emulab.net/api/core/networks/1/"
+ ]
+ }
+ ]
+
+
+
+# Group Users
+
+List of the XOS users
+
+## Users [/api/core/users/{id}/]
+
+### List all Users [GET]
+
++ Response 200 (application/json)
+
+ [
+ {
+ "id": 2,
+ "password": "pbkdf2_sha256$12000$9gn8DmZuIoz2$YPQkx3AOOV7jZNYr2ddrgUCkiuaPpvb8+aJR7RwLZNA=",
+ "last_login": "2016-04-12T18:50:45.880823Z",
+ "email": "johndoe@myhouse.com",
+ "username": "johndoe@myhouse.com",
+ "firstname": "john",
+ "lastname": "doe",
+ "phone": null,
+ "user_url": null,
+ "site": "http://xos.dev:9999/api/core/sites/1/",
+ "public_key": null,
+ "is_active": true,
+ "is_admin": false,
+ "is_staff": true,
+ "is_readonly": false,
+ "is_registering": false,
+ "is_appuser": false,
+ "login_page": null,
+ "created": "2016-04-12T18:50:45.912602Z",
+ "updated": "2016-04-12T18:50:45.912671Z",
+ "enacted": null,
+ "policed": null,
+ "backend_status": "Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "timezone": "America/New_York"
+ }
+ ]
+
+
+
# Group Subscribers
Resource related to the CORD Subscribers.
diff --git a/views/ngXosLib/apigen/blueprintToNgResource.js b/views/ngXosLib/apigen/blueprintToNgResource.js
index 2a3cde3..21d65e7 100644
--- a/views/ngXosLib/apigen/blueprintToNgResource.js
+++ b/views/ngXosLib/apigen/blueprintToNgResource.js
@@ -70,7 +70,7 @@
fs.readFileAsync(path.join(__dirname, './ngResourceTemplate.handlebars'), 'utf8')
.then((template) => {
handlebarsTemplate = Handlebars.compile(template);
- return fs.readFileAsync(path.join(__dirname, '../../../xos/tests/api/apiary.apib'), 'utf8')
+ return fs.readFileAsync(path.join(__dirname, '../../../apiary.apib'), 'utf8')
})
.then(data => protagonist.parseAsync(data))
.then(result => loopApiDefinitions(result.content))
diff --git a/views/ngXosLib/apigen/ngResourceTemplate.handlebars b/views/ngXosLib/apigen/ngResourceTemplate.handlebars
index 6176633..c1bc8f5 100644
--- a/views/ngXosLib/apigen/ngResourceTemplate.handlebars
+++ b/views/ngXosLib/apigen/ngResourceTemplate.handlebars
@@ -9,7 +9,9 @@
* @description Angular resource to fetch {{param.href}}
**/
.service('{{name}}', function($resource){
- return $resource('{{param.href}}'{{#if param.name}}, { {{param.name}}: '@id' }{{/if}});
+ return $resource('{{param.href}}'{{#if param.name}}, { {{param.name}}: '@id' }, {
+ update: { method: 'PUT' }
+ }{{/if}});
})
{{/each}}
})();
\ No newline at end of file
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/Example.js b/views/ngXosLib/xosHelpers/src/services/rest/Example.js
new file mode 100644
index 0000000..b13ccda
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/services/rest/Example.js
@@ -0,0 +1,13 @@
+(function() {
+ 'use strict';
+
+ angular.module('xos.helpers')
+ /**
+ * @ngdoc service
+ * @name xos.helpers.Example-Services-Collection
+ * @description Angular resource to fetch /api/service/exampleservice/
+ **/
+ .service('Example-Services-Collection', function($resource){
+ return $resource('/api/service/exampleservice/');
+ })
+})();
\ No newline at end of file
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/Instances.js b/views/ngXosLib/xosHelpers/src/services/rest/Instances.js
index 57e5537..f1e8521 100644
--- a/views/ngXosLib/xosHelpers/src/services/rest/Instances.js
+++ b/views/ngXosLib/xosHelpers/src/services/rest/Instances.js
@@ -5,9 +5,11 @@
/**
* @ngdoc service
* @name xos.helpers.Instances
- * @description Angular resource to fetch /api/core/instances/:instance_id/
+ * @description Angular resource to fetch /api/core/instances/:id/
**/
.service('Instances', function($resource){
- return $resource('/api/core/instances/:instance_id/', { instance_id: '@id' });
+ return $resource('/api/core/instances/:id/', { id: '@id' }, {
+ update: { method: 'PUT' }
+ });
})
})();
\ No newline at end of file
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/Slices.js b/views/ngXosLib/xosHelpers/src/services/rest/Slices.js
new file mode 100644
index 0000000..5a0da11
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/services/rest/Slices.js
@@ -0,0 +1,15 @@
+(function() {
+ 'use strict';
+
+ angular.module('xos.helpers')
+ /**
+ * @ngdoc service
+ * @name xos.helpers.Slices
+ * @description Angular resource to fetch /api/core/slices/:id/
+ **/
+ .service('Slices', function($resource){
+ return $resource('/api/core/slices/:id/', { id: '@id' }, {
+ update: { method: 'PUT' }
+ });
+ })
+})();
\ No newline at end of file
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/Subscribers.js b/views/ngXosLib/xosHelpers/src/services/rest/Subscribers.js
index ebab252..342d856 100644
--- a/views/ngXosLib/xosHelpers/src/services/rest/Subscribers.js
+++ b/views/ngXosLib/xosHelpers/src/services/rest/Subscribers.js
@@ -8,7 +8,9 @@
* @description Angular resource to fetch /api/tenant/cord/subscriber/:subscriber_id/
**/
.service('Subscribers', function($resource){
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/', { subscriber_id: '@id' });
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/', { subscriber_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
})
/**
* @ngdoc service
@@ -16,7 +18,9 @@
* @description Angular resource to fetch /api/tenant/cord/subscriber/:subscriber_id/features/
**/
.service('Subscriber-features', function($resource){
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/', { subscriber_id: '@id' });
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/', { subscriber_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
})
/**
* @ngdoc service
@@ -24,7 +28,9 @@
* @description Angular resource to fetch /api/tenant/cord/subscriber/:subscriber_id/features/uplink_speed/
**/
.service('Subscriber-features-uplink_speed', function($resource){
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/uplink_speed/', { subscriber_id: '@id' });
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/uplink_speed/', { subscriber_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
})
/**
* @ngdoc service
@@ -32,7 +38,9 @@
* @description Angular resource to fetch /api/tenant/cord/subscriber/:subscriber_id/features/downlink_speed/
**/
.service('Subscriber-features-downlink_speed', function($resource){
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/downlink_speed/', { subscriber_id: '@id' });
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/downlink_speed/', { subscriber_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
})
/**
* @ngdoc service
@@ -40,7 +48,9 @@
* @description Angular resource to fetch /api/tenant/cord/subscriber/:subscriber_id/features/cdn/
**/
.service('Subscriber-features-cdn', function($resource){
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/cdn/', { subscriber_id: '@id' });
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/cdn/', { subscriber_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
})
/**
* @ngdoc service
@@ -48,7 +58,9 @@
* @description Angular resource to fetch /api/tenant/cord/subscriber/:subscriber_id/features/uverse/
**/
.service('Subscriber-features-uverse', function($resource){
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/uverse/', { subscriber_id: '@id' });
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/uverse/', { subscriber_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
})
/**
* @ngdoc service
@@ -56,6 +68,8 @@
* @description Angular resource to fetch /api/tenant/cord/subscriber/:subscriber_id/features/status/
**/
.service('Subscriber-features-status', function($resource){
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/status/', { subscriber_id: '@id' });
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/status/', { subscriber_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
})
})();
\ No newline at end of file
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/Truckroll.js b/views/ngXosLib/xosHelpers/src/services/rest/Truckroll.js
index 9927967..0895a99 100644
--- a/views/ngXosLib/xosHelpers/src/services/rest/Truckroll.js
+++ b/views/ngXosLib/xosHelpers/src/services/rest/Truckroll.js
@@ -8,6 +8,8 @@
* @description Angular resource to fetch /api/tenant/truckroll/:truckroll_id/
**/
.service('Truckroll-Collection', function($resource){
- return $resource('/api/tenant/truckroll/:truckroll_id/', { truckroll_id: '@id' });
+ return $resource('/api/tenant/truckroll/:truckroll_id/', { truckroll_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
})
})();
\ No newline at end of file
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/Users.js b/views/ngXosLib/xosHelpers/src/services/rest/Users.js
index cb93866..8be0fdd 100644
--- a/views/ngXosLib/xosHelpers/src/services/rest/Users.js
+++ b/views/ngXosLib/xosHelpers/src/services/rest/Users.js
@@ -5,9 +5,11 @@
/**
* @ngdoc service
* @name xos.helpers.Users
- * @description Angular resource to fetch /api/core/users/:user_id/
+ * @description Angular resource to fetch /api/core/users/:id/
**/
.service('Users', function($resource){
- return $resource('/api/core/users/:user_id/', { user_id: '@id' });
+ return $resource('/api/core/users/:id/', { id: '@id' }, {
+ update: { method: 'PUT' }
+ });
})
})();
\ No newline at end of file
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/vOLT.js b/views/ngXosLib/xosHelpers/src/services/rest/vOLT.js
index f182c06..424c48d 100644
--- a/views/ngXosLib/xosHelpers/src/services/rest/vOLT.js
+++ b/views/ngXosLib/xosHelpers/src/services/rest/vOLT.js
@@ -8,6 +8,8 @@
* @description Angular resource to fetch /api/tenant/cord/volt/:volt_id/
**/
.service('vOLT-Collection', function($resource){
- return $resource('/api/tenant/cord/volt/:volt_id/', { volt_id: '@id' });
+ return $resource('/api/tenant/cord/volt/:volt_id/', { volt_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
})
})();
\ No newline at end of file
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js b/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js
index 5f2443b..8cbe0af 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js
@@ -122,6 +122,9 @@
controllerAs: 'vm',
controller: function($injector, LabelFormatter, _, XosFormHelpers){
+ // TODO
+ // - Validate the config (what if resource does not exist?)
+
// NOTE
// Corner case
// - if response is empty, how can we generate a form ?
@@ -137,6 +140,7 @@
label: 'delete',
icon: 'remove',
cb: (item) => {
+ console.log(item);
this.Resource.delete({id: item.id}).$promise
.then(() => {
_.remove(this.data, (d) => d.id === item.id);
@@ -173,9 +177,21 @@
label: 'Save',
icon: 'ok',
cb: (item) => {
- item.$save()
- .then((res) => {
- this.data.push(angular.copy(res));
+ let p;
+ let isNew = true;
+
+ if(item.id){
+ p = item.$update();
+ isNew = false;
+ }
+ else {
+ p = item.$save();
+ }
+
+ p.then((res) => {
+ if(isNew){
+ this.data.push(angular.copy(res));
+ }
delete this.detailedItem;
this.responseMsg = `${this.config.resource} with id ${item.id} successfully saved`;
})
@@ -210,7 +226,7 @@
let props = Object.keys(item);
_.remove(props, p => {
- return p == 'id' || p == 'password' || p == 'validators'
+ return p == 'id' || p == 'validators'
});
// TODO move out cb
diff --git a/views/ngXosViews/helperView/.bowerrc b/views/ngXosViews/helperView/.bowerrc
new file mode 100644
index 0000000..e491038
--- /dev/null
+++ b/views/ngXosViews/helperView/.bowerrc
@@ -0,0 +1,3 @@
+{
+ "directory": "src/vendor/"
+}
\ No newline at end of file
diff --git a/views/ngXosViews/helperView/.eslintrc b/views/ngXosViews/helperView/.eslintrc
new file mode 100644
index 0000000..c852748
--- /dev/null
+++ b/views/ngXosViews/helperView/.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/helperView/.gitignore b/views/ngXosViews/helperView/.gitignore
new file mode 100644
index 0000000..567aee4
--- /dev/null
+++ b/views/ngXosViews/helperView/.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/helperView/bower.json b/views/ngXosViews/helperView/bower.json
new file mode 100644
index 0000000..d369cab
--- /dev/null
+++ b/views/ngXosViews/helperView/bower.json
@@ -0,0 +1,30 @@
+{
+ "name": "xos-helperView",
+ "version": "0.0.0",
+ "authors": [
+ "Matteo Scandolo <teo@onlab.us>"
+ ],
+ "description": "The helperView 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"
+ }
+}
diff --git a/views/ngXosViews/helperView/env/default.js b/views/ngXosViews/helperView/env/default.js
new file mode 100644
index 0000000..8df1415
--- /dev/null
+++ b/views/ngXosViews/helperView/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: 'Y5oPUJm4WNZJ1FXhdHoHA2Q6nDGZICtm',
+ xossessionid: '0fogbjmioma94ukjeoe0xrktfdk3yd7l'
+};
diff --git a/views/ngXosViews/helperView/gulp/build.js b/views/ngXosViews/helperView/gulp/build.js
new file mode 100644
index 0000000..2ca4b74
--- /dev/null
+++ b/views/ngXosViews/helperView/gulp/build.js
@@ -0,0 +1,163 @@
+'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.helperView')
+.run(['$location', function(a){
+ a.path('/');
+}])
+`
+
+module.exports = function(options){
+
+ // delete previous builded file
+ gulp.task('clean', function(){
+ return del(
+ [
+ options.dashboards + 'xosHelperView.html',
+ options.static + 'css/xosHelperView.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('xosHelperView.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('xosHelperView.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.helperView',
+ 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.*)*\n<!-- endbower --><!-- endcss -->/, ''))
+ .pipe(replace(/<!-- bower:js -->(\n.*)*\n<!-- endbower --><!-- endjs -->/, ''))
+ // injecting minified files
+ .pipe(
+ inject(
+ gulp.src([
+ options.static + 'js/vendor/xosHelperViewVendor.js',
+ options.static + 'js/xosHelperView.js',
+ options.static + 'css/xosHelperView.css'
+ ]),
+ {ignorePath: '/../../../xos/core/xoslib'}
+ )
+ )
+ .pipe(rename('xosHelperView.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('xosHelperViewVendor.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',
+ 'templates',
+ 'babel',
+ 'scripts',
+ 'wiredep',
+ 'css',
+ 'copyCss',
+ 'copyHtml',
+ 'cleanTmp'
+ );
+ });
+};
\ No newline at end of file
diff --git a/views/ngXosViews/helperView/gulp/server.js b/views/ngXosViews/helperView/gulp/server.js
new file mode 100644
index 0000000..c0678d9
--- /dev/null
+++ b/views/ngXosViews/helperView/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/helperView/gulpfile.js b/views/ngXosViews/helperView/gulpfile.js
new file mode 100644
index 0000000..08df554
--- /dev/null
+++ b/views/ngXosViews/helperView/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/helperView/karma.conf.js b/views/ngXosViews/helperView/karma.conf.js
new file mode 100644
index 0000000..4123be9
--- /dev/null
+++ b/views/ngXosViews/helperView/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/helperView/package.json b/views/ngXosViews/helperView/package.json
new file mode 100644
index 0000000..e301a17
--- /dev/null
+++ b/views/ngXosViews/helperView/package.json
@@ -0,0 +1,63 @@
+{
+ "name": "xos-helperView",
+ "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": "Matteo Scandolo",
+ "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/helperView/spec/sample.test.js b/views/ngXosViews/helperView/spec/sample.test.js
new file mode 100644
index 0000000..edf6ef4
--- /dev/null
+++ b/views/ngXosViews/helperView/spec/sample.test.js
@@ -0,0 +1,37 @@
+'use strict';
+
+describe('The User List', () => {
+
+ var scope, element, isolatedScope, httpBackend;
+
+ beforeEach(module('xos.helperView'));
+ beforeEach(module('templates'));
+
+ beforeEach(inject(function($httpBackend, $compile, $rootScope){
+
+ httpBackend = $httpBackend;
+ // Setting up mock request
+ $httpBackend.expectGET('/api/core/users/?no_hyperlinks=1').respond([
+ {
+ email: 'teo@onlab.us',
+ firstname: 'Matteo',
+ lastname: 'Scandolo'
+ }
+ ]);
+
+ scope = $rootScope.$new();
+ element = angular.element('<users-list></users-list>');
+ $compile(element)(scope);
+ scope.$digest();
+ isolatedScope = element.isolateScope().vm;
+ }));
+
+ it('should load 1 users', () => {
+ httpBackend.flush();
+ expect(isolatedScope.users.length).toBe(1);
+ expect(isolatedScope.users[0].email).toEqual('teo@onlab.us');
+ expect(isolatedScope.users[0].firstname).toEqual('Matteo');
+ expect(isolatedScope.users[0].lastname).toEqual('Scandolo');
+ });
+
+});
\ No newline at end of file
diff --git a/views/ngXosViews/helperView/src/css/main.css b/views/ngXosViews/helperView/src/css/main.css
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/views/ngXosViews/helperView/src/css/main.css
diff --git a/views/ngXosViews/helperView/src/index.html b/views/ngXosViews/helperView/src/index.html
new file mode 100644
index 0000000..1f21510
--- /dev/null
+++ b/views/ngXosViews/helperView/src/index.html
@@ -0,0 +1,105 @@
+<!-- browserSync -->
+<!-- bower:css -->
+<link rel="stylesheet" href="vendor/bootstrap-css/css/bootstrap.min.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.helperView" id="xosHelperView" class="container-fluid">
+ <div class="row">
+ <div class="col-xs-12">
+ <h1>Hi Matteo!</h1>
+ <h3>Welcome to you development environment.</h3>
+ <p>
+ We provided this environment to help you creating a custom view.
+ </p>
+ <p>
+ When the environment is running you will have an
+ <code>auto-reload</code>
+ feature enabled, so any time you update one of your files, the browser will be reloaded.
+ </p>
+ <p> <i>Note that is environment is already functional and that it is loading information from the XOS APIs and presenting them using the
+ <code>xos-table</code>
+ component.</i>
+ </p>
+ <h3>Development notes:</h3>
+ <p>
+ This views are designed using
+ <a href="https://angularjs.org/" target="_blank">Angular Js</a>
+ version 1.4.7 and
+ <a href="http://getbootstrap.com/" target="_blank">Bootstrap</a>
+ 3.3.6 is included.
+ </p>
+ <p>
+ We just want to remind you that this development environment provide you three helper command:
+ <ul>
+ <li>
+ <code>npm start</code>
+ - will start your setup (you should already be familiar with it)
+ </li>
+ <li>
+ <code>npm test</code>
+ - will execute your unit tests defined with
+ <a href="https://karma-runner.github.io/0.13/index.html" target="_blank">Karma</a>
+ and
+ <a href="jasmine.github.io" target="_blank">Jasmine</a>
+ . You can check the
+ <code>spec/</code>
+ folder to see an example of your first test.
+ </li>
+ <li>
+ <code>npm run build</code>
+ - will build your dashboard and make it available to XOS
+ </li>
+ </ul>
+ </p>
+ <h3>Helpers:</h3>
+ <p>
+ We provide a set of helpers that you can leverage in your dashboard:
+ <ul>
+ <li>
+ <code>xos.helpers</code>
+ - A set of
+ <a href="https://docs.angularjs.org/guide/services" target="_blank">Angular Services</a>
+ </li>
+ <li>
+ <code>xos.uiComponents</code>
+ - A set of
+ <a href="https://docs.angularjs.org/guide/directive" target="_blank">Angular Directives</a>
+ </li>
+ <li>
+ <code>xos.rest</code>
+ - A set of
+ <a href="https://docs.angularjs.org/api/ngResource/service/$resource" target="_blank">Angular $resources</a>
+ </li>
+ </ul>
+ To know more about this helpers you can naviate to
+ <code>/views/ngXosLib/</code>
+ and generate the documentation with
+ <code>npm run doc</code>
+ </p>
+ <h3>Example:</h3>
+ </div>
+ </div>
+ <div ui-view></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>
+<!-- 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/helperView/src/js/main.js b/views/ngXosViews/helperView/src/js/main.js
new file mode 100644
index 0000000..6dc1d0f
--- /dev/null
+++ b/views/ngXosViews/helperView/src/js/main.js
@@ -0,0 +1,42 @@
+'use strict';
+
+angular.module('xos.helperView', [
+ 'ngResource',
+ 'ngCookies',
+ 'ui.router',
+ 'xos.helpers'
+])
+.config(($stateProvider) => {
+ $stateProvider
+ .state('user-list', {
+ url: '/',
+ template: '<users-list></users-list>'
+ });
+})
+.config(function($httpProvider){
+ $httpProvider.interceptors.push('NoHyperlinks');
+})
+.directive('usersList', function(){
+ return {
+ restrict: 'E',
+ scope: {},
+ bindToController: true,
+ controllerAs: 'vm',
+ templateUrl: 'templates/users-list.tpl.html',
+ controller: function(Users){
+
+ this.tableConfig = {
+ resource: 'Instances'
+ };
+
+ // retrieving user list
+ Users.query().$promise
+ .then((users) => {
+ this.users = users;
+ })
+ .catch((e) => {
+ throw new Error(e);
+ });
+ }
+ };
+});
\ No newline at end of file
diff --git a/views/ngXosViews/helperView/src/sass/main.scss b/views/ngXosViews/helperView/src/sass/main.scss
new file mode 100644
index 0000000..9d457ab
--- /dev/null
+++ b/views/ngXosViews/helperView/src/sass/main.scss
@@ -0,0 +1,5 @@
+@import '../../../../style/sass/lib/_variables.scss';
+
+#xosHelperView {
+
+}
\ No newline at end of file
diff --git a/views/ngXosViews/helperView/src/templates/users-list.tpl.html b/views/ngXosViews/helperView/src/templates/users-list.tpl.html
new file mode 100644
index 0000000..0641dd9
--- /dev/null
+++ b/views/ngXosViews/helperView/src/templates/users-list.tpl.html
@@ -0,0 +1 @@
+<xos-smart-table config="vm.tableConfig"></xos-smart-table>
\ No newline at end of file
diff --git a/xos/api/examples/misc/add_slice.sh b/xos/api/examples/misc/add_slice.sh
new file mode 100755
index 0000000..b2d7adc
--- /dev/null
+++ b/xos/api/examples/misc/add_slice.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+source ./config.sh
+
+SITE_ID=1
+USER_ID=1
+
+DATA=$(cat <<EOF
+{"name": "mysite_test1",
+ "site": $SITE_ID,
+ "creator": $USER_ID
+}
+EOF
+)
+
+curl -H "Accept: application/json; indent=4" -H "Content-Type: application/json" -u $AUTH -X POST -d "$DATA" $HOST/xos/slices/?no_hyperlinks=1
diff --git a/xos/api/examples/misc/config.sh b/xos/api/examples/misc/config.sh
new file mode 100644
index 0000000..92d703c
--- /dev/null
+++ b/xos/api/examples/misc/config.sh
@@ -0,0 +1,2 @@
+# see config.sh in the parent directory
+source ../config.sh
diff --git a/xos/api/examples/misc/delete_slice.sh b/xos/api/examples/misc/delete_slice.sh
new file mode 100755
index 0000000..1113d4f
--- /dev/null
+++ b/xos/api/examples/misc/delete_slice.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+source ./config.sh
+source ./util.sh
+
+SLICE_NAME=mysite_test1
+
+SLICE_ID=$(lookup_slice_id $SLICE_NAME)
+if [[ $? != 0 ]]; then
+ exit -1
+fi
+
+curl -u $AUTH -X DELETE $HOST/xos/slices/$SLICE_ID/
diff --git a/xos/api/examples/misc/update_slice.sh b/xos/api/examples/misc/update_slice.sh
new file mode 100755
index 0000000..94e82cd
--- /dev/null
+++ b/xos/api/examples/misc/update_slice.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+source ./config.sh
+source ./util.sh
+
+SLICE_NAME=mysite_test1
+
+SLICE_ID=$(lookup_slice_id $SLICE_NAME)
+if [[ $? != 0 ]]; then
+ exit -1
+fi
+
+DATA=$(cat <<EOF
+{"description": "foo"}
+EOF
+)
+
+curl -H "Accept: application/json; indent=4" -H "Content-Type: application/json" -u $AUTH -X PATCH -d "$DATA" $HOST/xos/slices/$SLICE_ID/
diff --git a/xos/api/examples/misc/util.sh b/xos/api/examples/misc/util.sh
new file mode 100644
index 0000000..7b66903
--- /dev/null
+++ b/xos/api/examples/misc/util.sh
@@ -0,0 +1 @@
+source ../util.sh
diff --git a/xos/api/examples/util.sh b/xos/api/examples/util.sh
index 648b32c..73cc039 100644
--- a/xos/api/examples/util.sh
+++ b/xos/api/examples/util.sh
@@ -12,6 +12,19 @@
echo $ID
}
+function lookup_slice_id {
+ JSON=`curl -f -s -u $AUTH -X GET $HOST/xos/slices/?name=$1`
+ if [[ $? != 0 ]]; then
+ echo "function lookup_slice_id with arguments $1 failed" >&2
+ echo "See CURL output below:" >&2
+ curl -s -u $AUTH -X GET $HOST/xos/slices/?name=$1 >&2
+ exit -1
+ fi
+ ID=`echo $JSON | python -c "import json,sys; print json.load(sys.stdin)[0].get('id','')"`
+ #echo "(mapped slice_name to id $ID)" >&2
+ echo $ID
+}
+
function lookup_subscriber_volt {
JSON=`curl -f -s -u $AUTH -X GET $HOST/api/tenant/cord/subscriber/$1/`
if [[ $? != 0 ]]; then
diff --git a/xos/core/xoslib/static/js/vendor/ngXosHelpers.js b/xos/core/xoslib/static/js/vendor/ngXosHelpers.js
index 9b1588a..fe5cc8f 100644
--- a/xos/core/xoslib/static/js/vendor/ngXosHelpers.js
+++ b/xos/core/xoslib/static/js/vendor/ngXosHelpers.js
@@ -119,6 +119,9 @@
controller: ["$injector", "LabelFormatter", "_", "XosFormHelpers", function controller($injector, LabelFormatter, _, XosFormHelpers) {
var _this = this;
+ // TODO
+ // - Validate the config (what if resource does not exist?)
+
// NOTE
// Corner case
// - if response is empty, how can we generate a form ?
@@ -132,6 +135,7 @@
label: 'delete',
icon: 'remove',
cb: function cb(item) {
+ console.log(item);
_this.Resource.delete({ id: item.id }).$promise.then(function () {
_.remove(_this.data, function (d) {
return d.id === item.id;
@@ -165,8 +169,20 @@
label: 'Save',
icon: 'ok',
cb: function cb(item) {
- item.$save().then(function (res) {
- _this.data.push(angular.copy(res));
+ var p = void 0;
+ var isNew = true;
+
+ if (item.id) {
+ p = item.$update();
+ isNew = false;
+ } else {
+ p = item.$save();
+ }
+
+ p.then(function (res) {
+ if (isNew) {
+ _this.data.push(angular.copy(res));
+ }
delete _this.detailedItem;
_this.responseMsg = _this.config.resource + ' with id ' + item.id + ' successfully saved';
}).catch(function (err) {
@@ -198,7 +214,7 @@
var props = Object.keys(item);
_.remove(props, function (p) {
- return p == 'id' || p == 'password' || p == 'validators';
+ return p == 'id' || p == 'validators';
});
// TODO move out cb
@@ -562,145 +578,6 @@
/**
* @ngdoc directive
- * @name xos.uiComponents.directive:xosAlert
- * @restrict E
- * @description The xos-alert directive
- * @param {Object} config The configuration object
- * ```
- * {
- * type: 'danger', //info, success, warning
- * closeBtn: true, //default false
- * autoHide: 3000 //delay to automatically hide the alert
- * }
- * ```
- * @param {Boolean=} show Binding to show and hide the alert, default to true
- * @element ANY
- * @scope
- * @example
- <example module="sampleAlert1">
- <file name="index.html">
- <div ng-controller="SampleCtrl1 as vm">
- <xos-alert config="vm.config1">
- A sample alert message
- </xos-alert>
- <xos-alert config="vm.config2">
- A sample alert message (with close button)
- </xos-alert>
- <xos-alert config="vm.config3">
- A sample info message
- </xos-alert>
- <xos-alert config="vm.config4">
- A sample success message
- </xos-alert>
- <xos-alert config="vm.config5">
- A sample warning message
- </xos-alert>
- </div>
- </file>
- <file name="script.js">
- angular.module('sampleAlert1', ['xos.uiComponents'])
- .controller('SampleCtrl1', function(){
- this.config1 = {
- type: 'danger'
- };
- this.config2 = {
- type: 'danger',
- closeBtn: true
- };
- this.config3 = {
- type: 'info'
- };
- this.config4 = {
- type: 'success'
- };
- this.config5 = {
- type: 'warning'
- };
- });
- </file>
- </example>
- <example module="sampleAlert2" animations="true">
- <file name="index.html">
- <div ng-controller="SampleCtrl as vm" class="row">
- <div class="col-sm-4">
- <a class="btn btn-default btn-block" ng-show="!vm.show" ng-click="vm.show = true">Show Alert</a>
- <a class="btn btn-default btn-block" ng-show="vm.show" ng-click="vm.show = false">Hide Alert</a>
- </div>
- <div class="col-sm-8">
- <xos-alert config="vm.config1" show="vm.show">
- A sample alert message, not displayed by default.
- </xos-alert>
- </div>
- </div>
- </file>
- <file name="script.js">
- angular.module('sampleAlert2', ['xos.uiComponents', 'ngAnimate'])
- .controller('SampleCtrl', function(){
- this.config1 = {
- type: 'success'
- };
- this.show = false;
- });
- </file>
- </example>
- **/
-
- .directive('xosAlert', function () {
- return {
- restrict: 'E',
- scope: {
- config: '=',
- show: '=?'
- },
- template: '\n <div ng-cloak class="alert alert-{{vm.config.type}}" ng-hide="!vm.show">\n <button type="button" class="close" ng-if="vm.config.closeBtn" ng-click="vm.dismiss()">\n <span aria-hidden="true">×</span>\n </button>\n <p ng-transclude></p>\n </div>\n ',
- transclude: true,
- bindToController: true,
- controllerAs: 'vm',
- controller: ["$timeout", function controller($timeout) {
- var _this = this;
-
- if (!this.config) {
- throw new Error('[xosAlert] Please provide a configuration via the "config" attribute');
- }
-
- // default the value to true
- this.show = this.show !== false;
-
- this.dismiss = function () {
- _this.show = false;
- };
-
- if (this.config.autoHide) {
- (function () {
- var to = $timeout(function () {
- _this.dismiss();
- $timeout.cancel(to);
- }, _this.config.autoHide);
- })();
- }
- }]
- };
- });
-})();
-//# sourceMappingURL=../../../maps/ui_components/dumbComponents/alert/alert.component.js.map
-
-'use strict';
-
-/**
- * © OpenCORD
- *
- * Visit http://guide.xosproject.org/devguide/addview/ for more information
- *
- * Created by teone on 4/15/16.
- */
-
-(function () {
- 'use strict';
-
- angular.module('xos.uiComponents')
-
- /**
- * @ngdoc directive
* @name xos.uiComponents.directive:xosPagination
* @restrict E
* @description The xos-table directive
@@ -1058,6 +935,145 @@
'use strict';
+/**
+ * © OpenCORD
+ *
+ * Visit http://guide.xosproject.org/devguide/addview/ for more information
+ *
+ * Created by teone on 4/15/16.
+ */
+
+(function () {
+ 'use strict';
+
+ angular.module('xos.uiComponents')
+
+ /**
+ * @ngdoc directive
+ * @name xos.uiComponents.directive:xosAlert
+ * @restrict E
+ * @description The xos-alert directive
+ * @param {Object} config The configuration object
+ * ```
+ * {
+ * type: 'danger', //info, success, warning
+ * closeBtn: true, //default false
+ * autoHide: 3000 //delay to automatically hide the alert
+ * }
+ * ```
+ * @param {Boolean=} show Binding to show and hide the alert, default to true
+ * @element ANY
+ * @scope
+ * @example
+ <example module="sampleAlert1">
+ <file name="index.html">
+ <div ng-controller="SampleCtrl1 as vm">
+ <xos-alert config="vm.config1">
+ A sample alert message
+ </xos-alert>
+ <xos-alert config="vm.config2">
+ A sample alert message (with close button)
+ </xos-alert>
+ <xos-alert config="vm.config3">
+ A sample info message
+ </xos-alert>
+ <xos-alert config="vm.config4">
+ A sample success message
+ </xos-alert>
+ <xos-alert config="vm.config5">
+ A sample warning message
+ </xos-alert>
+ </div>
+ </file>
+ <file name="script.js">
+ angular.module('sampleAlert1', ['xos.uiComponents'])
+ .controller('SampleCtrl1', function(){
+ this.config1 = {
+ type: 'danger'
+ };
+ this.config2 = {
+ type: 'danger',
+ closeBtn: true
+ };
+ this.config3 = {
+ type: 'info'
+ };
+ this.config4 = {
+ type: 'success'
+ };
+ this.config5 = {
+ type: 'warning'
+ };
+ });
+ </file>
+ </example>
+ <example module="sampleAlert2" animations="true">
+ <file name="index.html">
+ <div ng-controller="SampleCtrl as vm" class="row">
+ <div class="col-sm-4">
+ <a class="btn btn-default btn-block" ng-show="!vm.show" ng-click="vm.show = true">Show Alert</a>
+ <a class="btn btn-default btn-block" ng-show="vm.show" ng-click="vm.show = false">Hide Alert</a>
+ </div>
+ <div class="col-sm-8">
+ <xos-alert config="vm.config1" show="vm.show">
+ A sample alert message, not displayed by default.
+ </xos-alert>
+ </div>
+ </div>
+ </file>
+ <file name="script.js">
+ angular.module('sampleAlert2', ['xos.uiComponents', 'ngAnimate'])
+ .controller('SampleCtrl', function(){
+ this.config1 = {
+ type: 'success'
+ };
+ this.show = false;
+ });
+ </file>
+ </example>
+ **/
+
+ .directive('xosAlert', function () {
+ return {
+ restrict: 'E',
+ scope: {
+ config: '=',
+ show: '=?'
+ },
+ template: '\n <div ng-cloak class="alert alert-{{vm.config.type}}" ng-hide="!vm.show">\n <button type="button" class="close" ng-if="vm.config.closeBtn" ng-click="vm.dismiss()">\n <span aria-hidden="true">×</span>\n </button>\n <p ng-transclude></p>\n </div>\n ',
+ transclude: true,
+ bindToController: true,
+ controllerAs: 'vm',
+ controller: ["$timeout", function controller($timeout) {
+ var _this = this;
+
+ if (!this.config) {
+ throw new Error('[xosAlert] Please provide a configuration via the "config" attribute');
+ }
+
+ // default the value to true
+ this.show = this.show !== false;
+
+ this.dismiss = function () {
+ _this.show = false;
+ };
+
+ if (this.config.autoHide) {
+ (function () {
+ var to = $timeout(function () {
+ _this.dismiss();
+ $timeout.cancel(to);
+ }, _this.config.autoHide);
+ })();
+ }
+ }]
+ };
+ });
+})();
+//# sourceMappingURL=../../../maps/ui_components/dumbComponents/alert/alert.component.js.map
+
+'use strict';
+
(function () {
'use strict';
@@ -1123,7 +1139,9 @@
* @description Angular resource to fetch /api/tenant/cord/volt/:volt_id/
**/
.service('vOLT-Collection', ["$resource", function ($resource) {
- return $resource('/api/tenant/cord/volt/:volt_id/', { volt_id: '@id' });
+ return $resource('/api/tenant/cord/volt/:volt_id/', { volt_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
}]);
})();
//# sourceMappingURL=../../maps/services/rest/vOLT.js.map
@@ -1137,10 +1155,12 @@
/**
* @ngdoc service
* @name xos.helpers.Users
- * @description Angular resource to fetch /api/core/users/:user_id/
+ * @description Angular resource to fetch /api/core/users/:id/
**/
.service('Users', ["$resource", function ($resource) {
- return $resource('/api/core/users/:user_id/', { user_id: '@id' });
+ return $resource('/api/core/users/:id/', { id: '@id' }, {
+ update: { method: 'PUT' }
+ });
}]);
})();
//# sourceMappingURL=../../maps/services/rest/Users.js.map
@@ -1157,7 +1177,9 @@
* @description Angular resource to fetch /api/tenant/truckroll/:truckroll_id/
**/
.service('Truckroll-Collection', ["$resource", function ($resource) {
- return $resource('/api/tenant/truckroll/:truckroll_id/', { truckroll_id: '@id' });
+ return $resource('/api/tenant/truckroll/:truckroll_id/', { truckroll_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
}]);
})();
//# sourceMappingURL=../../maps/services/rest/Truckroll.js.map
@@ -1174,7 +1196,9 @@
* @description Angular resource to fetch /api/tenant/cord/subscriber/:subscriber_id/
**/
.service('Subscribers', ["$resource", function ($resource) {
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/', { subscriber_id: '@id' });
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/', { subscriber_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
}])
/**
* @ngdoc service
@@ -1182,7 +1206,9 @@
* @description Angular resource to fetch /api/tenant/cord/subscriber/:subscriber_id/features/
**/
.service('Subscriber-features', ["$resource", function ($resource) {
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/', { subscriber_id: '@id' });
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/', { subscriber_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
}])
/**
* @ngdoc service
@@ -1190,7 +1216,9 @@
* @description Angular resource to fetch /api/tenant/cord/subscriber/:subscriber_id/features/uplink_speed/
**/
.service('Subscriber-features-uplink_speed', ["$resource", function ($resource) {
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/uplink_speed/', { subscriber_id: '@id' });
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/uplink_speed/', { subscriber_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
}])
/**
* @ngdoc service
@@ -1198,7 +1226,9 @@
* @description Angular resource to fetch /api/tenant/cord/subscriber/:subscriber_id/features/downlink_speed/
**/
.service('Subscriber-features-downlink_speed', ["$resource", function ($resource) {
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/downlink_speed/', { subscriber_id: '@id' });
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/downlink_speed/', { subscriber_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
}])
/**
* @ngdoc service
@@ -1206,7 +1236,9 @@
* @description Angular resource to fetch /api/tenant/cord/subscriber/:subscriber_id/features/cdn/
**/
.service('Subscriber-features-cdn', ["$resource", function ($resource) {
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/cdn/', { subscriber_id: '@id' });
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/cdn/', { subscriber_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
}])
/**
* @ngdoc service
@@ -1214,7 +1246,9 @@
* @description Angular resource to fetch /api/tenant/cord/subscriber/:subscriber_id/features/uverse/
**/
.service('Subscriber-features-uverse', ["$resource", function ($resource) {
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/uverse/', { subscriber_id: '@id' });
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/uverse/', { subscriber_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
}])
/**
* @ngdoc service
@@ -1222,7 +1256,9 @@
* @description Angular resource to fetch /api/tenant/cord/subscriber/:subscriber_id/features/status/
**/
.service('Subscriber-features-status', ["$resource", function ($resource) {
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/status/', { subscriber_id: '@id' });
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/status/', { subscriber_id: '@id' }, {
+ update: { method: 'PUT' }
+ });
}]);
})();
//# sourceMappingURL=../../maps/services/rest/Subscribers.js.map
@@ -1270,10 +1306,12 @@
/**
* @ngdoc service
* @name xos.helpers.Instances
- * @description Angular resource to fetch /api/core/instances/:instance_id/
+ * @description Angular resource to fetch /api/core/instances/:id/
**/
.service('Instances', ["$resource", function ($resource) {
- return $resource('/api/core/instances/:instance_id/', { instance_id: '@id' });
+ return $resource('/api/core/instances/:id/', { id: '@id' }, {
+ update: { method: 'PUT' }
+ });
}]);
})();
//# sourceMappingURL=../../maps/services/rest/Instances.js.map
@@ -1283,6 +1321,23 @@
(function () {
'use strict';
+ angular.module('xos.helpers')
+ /**
+ * @ngdoc service
+ * @name xos.helpers.Example-Services-Collection
+ * @description Angular resource to fetch /api/service/exampleservice/
+ **/
+ .service('Example-Services-Collection', ["$resource", function ($resource) {
+ return $resource('/api/service/exampleservice/');
+ }]);
+})();
+//# sourceMappingURL=../../maps/services/rest/Example.js.map
+
+'use strict';
+
+(function () {
+ 'use strict';
+
/**
* @ngdoc service
* @name xos.helpers.NoHyperlinks
diff --git a/xos/tests/api/helpers/flavors.py b/xos/tests/api/helpers/flavors.py
new file mode 100644
index 0000000..e16d41f
--- /dev/null
+++ b/xos/tests/api/helpers/flavors.py
@@ -0,0 +1,24 @@
+import dredd_hooks as hooks
+import sys
+
+# HELPERS
+# NOTE move in separated module
+import os
+import sys
+sys.path.append("/opt/xos")
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xos.settings")
+import django
+from core.models import *
+from services.cord.models import *
+from services.vtr.models import *
+import urllib2
+import json
+django.setup()
+
+def createFlavor():
+ fl = Flavor(id=1)
+ fl.name = 'm1.large'
+ fl.save()
+ print(fl, fl.id)
+
+createFlavor()
\ No newline at end of file
diff --git a/xos/tests/api/hooks.py b/xos/tests/api/hooks.py
index ccf0c6c..83354c7 100644
--- a/xos/tests/api/hooks.py
+++ b/xos/tests/api/hooks.py
@@ -174,6 +174,13 @@
tn.save()
+def createFlavor():
+ fl = Flavor(id=1)
+ fl.name = 'm1.large'
+ fl.save()
+ print(fl)
+
+
@hooks.before_all
def my_before_all_hook(transactions):
# print "-------------------------------- Before All Hook --------------------------------"
@@ -214,6 +221,11 @@
VOLTTenant.objects.get(kind='vOLT').delete()
+@hooks.before("Flavors > Flavors > View a Flavors Detail")
+def test5(transaction):
+ createFlavor()
+
+
@hooks.before("Example > Example Services Collection > List all Example Services")
def exampleTest(transaction):
transaction['skip'] = True
diff --git a/xos/tests/api/source/core/deployment.md b/xos/tests/api/source/core/deployment.md
new file mode 100644
index 0000000..bcd1e0e
--- /dev/null
+++ b/xos/tests/api/source/core/deployment.md
@@ -0,0 +1,40 @@
+# Group Deployments
+
+List of the XOS deployments
+
+## Deployments [/api/core/deployments/{id}/]
+
+### List all deployments [GET]
+
++ Response 200 (application/json)
+
+ {
+ "humanReadableName": "MyDeployment",
+ "id": 1,
+ "created": "2016-04-29T16:19:03.549901Z",
+ "updated": "2016-04-29T16:19:05.624151Z",
+ "enacted": null,
+ "policed": null,
+ "backend_register": "{}",
+ "backend_status": "0 - Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "lazy_blocked": false,
+ "no_sync": true,
+ "name": "MyDeployment",
+ "accessControl": "allow all",
+ "images": [
+ "1"
+ ],
+ "sites": [
+ "1"
+ ],
+ "flavors": [
+ "1",
+ "2",
+ "3"
+ ],
+ "dashboardviews": [
+ "1"
+ ]
+ }
\ No newline at end of file
diff --git a/xos/tests/api/source/core/flavors.md b/xos/tests/api/source/core/flavors.md
new file mode 100644
index 0000000..cb63a57
--- /dev/null
+++ b/xos/tests/api/source/core/flavors.md
@@ -0,0 +1,64 @@
+# Group Flavors
+
+List of the XOS flavors
+
+## Flavors [/api/core/flavors/{id}/]
+
+### List all flavors [GET]
+
++ Response 200 (application/json)
+
+ [
+ {
+ "humanReadableName": "m1.large",
+ "id": 1,
+ "created": "2016-04-29T16:19:01.979548Z",
+ "updated": "2016-04-29T16:19:03.568238Z",
+ "enacted": null,
+ "policed": null,
+ "backend_register": "{}",
+ "backend_status": "0 - Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "lazy_blocked": false,
+ "no_sync": true,
+ "name": "m1.large",
+ "description": null,
+ "flavor": "m1.large",
+ "order": 0,
+ "default": false,
+ "deployments": [
+ "1"
+ ]
+ }
+ ]
+
+### View a Flavors Detail [GET]
+
++ Parameters
+ + id: 1 (number) - ID of the Flavors in the form of an integer
+
++ Response 200 (application/json)
+
+ {
+ "humanReadableName": "m1.large",
+ "id": 1,
+ "created": "2016-04-29T16:19:01.979548Z",
+ "updated": "2016-04-29T16:19:03.568238Z",
+ "enacted": null,
+ "policed": null,
+ "backend_register": "{}",
+ "backend_status": "0 - Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "lazy_blocked": false,
+ "no_sync": true,
+ "name": "m1.large",
+ "description": null,
+ "flavor": "m1.large",
+ "order": 0,
+ "default": false,
+ "deployments": [
+ "1"
+ ]
+ }
\ No newline at end of file
diff --git a/xos/tests/api/source/core/instances.md b/xos/tests/api/source/core/instances.md
index d2ec059..4b95259 100644
--- a/xos/tests/api/source/core/instances.md
+++ b/xos/tests/api/source/core/instances.md
@@ -2,7 +2,7 @@
List of the XOS instances
-## Instances [/api/core/instances/{instance_id}/]
+## Instances [/api/core/instances/{id}/]
### List all Instances [GET]
@@ -27,19 +27,19 @@
"name": "mysite_vcpe",
"instance_name": null,
"ip": null,
- "image": "http://xos.dev:9999/api/core/images/1/",
- "creator": "http://xos.dev:9999/api/core/users/1/",
- "slice": "http://xos.dev:9999/api/core/slices/1/",
- "deployment": "http://xos.dev:9999/api/core/deployments/1/",
- "node": "http://xos.dev:9999/api/core/nodes/1/",
+ "image": "1",
+ "creator": "1",
+ "slice": "1",
+ "deployment": "1",
+ "node": "1",
"numberCores": 0,
- "flavor": "http://xos.dev:9999/api/core/flavors/1/",
+ "flavor": "1",
"userData": null,
"isolation": "vm",
"volumes": "/etc/dnsmasq.d,/etc/ufw",
"parent": null,
"networks": [
- "http://xos.dev:9999/api/core/networks/2/"
+ "1"
]
}
]
diff --git a/xos/tests/api/source/core/nodes.md b/xos/tests/api/source/core/nodes.md
new file mode 100644
index 0000000..d9931dc
--- /dev/null
+++ b/xos/tests/api/source/core/nodes.md
@@ -0,0 +1,30 @@
+# Group Nodes
+
+List of the XOS nodes
+
+## Nodes [/api/core/nodes/{id}/]
+
+### List all nodes [GET]
+
++ Response 200 (application/json)
+
+ [
+ {
+ "humanReadableName": "node2.opencloud.us",
+ "id": 1,
+ "created": "2016-04-29T16:19:05.661567Z",
+ "updated": "2016-04-29T16:19:05.661454Z",
+ "enacted": null,
+ "policed": null,
+ "backend_register": "{}",
+ "backend_status": "0 - Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "lazy_blocked": false,
+ "no_sync": true,
+ "name": "node2.opencloud.us",
+ "site_deployment": "1",
+ "site": "1",
+ "nodelabels": []
+ }
+ ]
diff --git a/xos/tests/api/source/core/sites.md b/xos/tests/api/source/core/sites.md
new file mode 100644
index 0000000..c3784db
--- /dev/null
+++ b/xos/tests/api/source/core/sites.md
@@ -0,0 +1,38 @@
+# Group Sites
+
+List of the XOS sites
+
+## Sites [/api/core/sites/{id}/]
+
+### List all sites [GET]
+
++ Response 200 (application/json)
+
+ {
+ "humanReadableName": "MySite",
+ "id": 1,
+ "created": "2016-04-29T16:19:03.587770Z",
+ "updated": "2016-04-29T16:19:05.651933Z",
+ "enacted": null,
+ "policed": null,
+ "backend_register": "{}",
+ "backend_status": "0 - Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "lazy_blocked": false,
+ "no_sync": false,
+ "name": "MySite",
+ "site_url": "http://opencord.us/",
+ "enabled": true,
+ "hosts_nodes": true,
+ "hosts_users": true,
+ "location": null,
+ "longitude": null,
+ "latitude": null,
+ "login_base": "mysite",
+ "is_public": true,
+ "abbreviated_name": "",
+ "deployments": [
+ "1"
+ ]
+ }
\ No newline at end of file
diff --git a/xos/tests/api/source/core/slices.md b/xos/tests/api/source/core/slices.md
new file mode 100644
index 0000000..6ec5c7e
--- /dev/null
+++ b/xos/tests/api/source/core/slices.md
@@ -0,0 +1,46 @@
+# Group Slices
+
+List of the XOS slices
+
+## Slices [/api/core/slices/{id}/]
+
+### List all slices [GET]
+
++ Response 200 (application/json)
+
+ [
+ {
+ "humanReadableName": "mysite_slice",
+ "id": 1,
+ "created": "2016-04-29T16:23:22.505072Z",
+ "updated": "2016-04-29T16:23:22.504691Z",
+ "enacted": null,
+ "policed": "2016-04-29T16:23:22.781298Z",
+ "backend_register": "{}",
+ "backend_status": "0 - Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "lazy_blocked": false,
+ "no_sync": false,
+ "name": "mysite_slice",
+ "enabled": true,
+ "omf_friendly": false,
+ "description": "",
+ "slice_url": "",
+ "site": "http://apt118.apt.emulab.net/api/core/sites/1/",
+ "max_instances": 10,
+ "service": null,
+ "network": null,
+ "exposed_ports": null,
+ "serviceClass": "http://apt118.apt.emulab.net/api/core/serviceclasses/1/",
+ "creator": "http://apt118.apt.emulab.net/api/core/users/1/",
+ "default_flavor": null,
+ "default_image": null,
+ "mount_data_sets": "GenBank",
+ "default_isolation": "vm",
+ "networks": [
+ "http://apt118.apt.emulab.net/api/core/networks/1/"
+ ]
+ }
+ ]
+
\ No newline at end of file
diff --git a/xos/tests/api/source/core/users.md b/xos/tests/api/source/core/users.md
index 6d37868..8ccabb5 100644
--- a/xos/tests/api/source/core/users.md
+++ b/xos/tests/api/source/core/users.md
@@ -2,7 +2,7 @@
List of the XOS users
-## Users [/api/core/users/{user_id}/]
+## Users [/api/core/users/{id}/]
### List all Users [GET]
diff --git a/xos/tools/apigen/api.template.py b/xos/tools/apigen/api.template.py
index de733e8..d0852db 100644
--- a/xos/tools/apigen/api.template.py
+++ b/xos/tools/apigen/api.template.py
@@ -68,7 +68,8 @@
# Based on serializers.py
class XOSModelSerializer(serializers.ModelSerializer):
- def save_object(self, obj, **kwargs):
+ # TODO: Rest Framework 3.x doesn't support save_object()
+ def NEED_TO_UPDATE_save_object(self, obj, **kwargs):
""" rest_framework can't deal with ManyToMany relations that have a
through table. In xos, most of the through tables we have
diff --git a/xos/xos/apibase.py b/xos/xos/apibase.py
index 03493ee..addbbe9 100644
--- a/xos/xos/apibase.py
+++ b/xos/xos/apibase.py
@@ -15,32 +15,27 @@
def update(self, request, *args, **kwargs):
partial = kwargs.pop('partial', False)
- self.object = self.get_object_or_none()
+ self.object = self.get_object()
if self.object is None:
raise XOSProgrammingError("Use the List API for creating objects")
- serializer = self.get_serializer(self.object, data=request.DATA,
- files=request.FILES, partial=partial)
-
- assert(serializer.object is not None)
-
- serializer.object.caller = request.user
+ serializer = self.get_serializer(self.object, data=request.data, partial=partial)
if not serializer.is_valid():
raise XOSValidationError(fields=serializer._errors)
- if not serializer.object.can_update(request.user):
+ # Do the XOS perm check
+
+ assert(serializer.instance is not None)
+ obj = serializer.instance
+ for attr, value in serializer.validated_data.items():
+ setattr(obj, attr, value)
+ obj.caller = request.user
+ if not obj.can_update(request.user):
raise XOSPermissionDenied()
- if (hasattr(self, "pre_save")):
- # rest_framework 2.x
- self.pre_save(serializer.object)
- self.object = serializer.save(force_update=True)
- self.post_save(self.object, created=False)
- else:
- # rest_framework 3.x
- self.perform_update(serializer)
+ self.perform_update(serializer)
return Response(serializer.data, status=status.HTTP_200_OK)
@@ -48,11 +43,7 @@
obj = self.get_object()
obj.caller = request.user
if obj.can_update(request.user):
- # this is the guts of DestroyModelMixin, copied here so that we
- # can use the obj with caller set in it,
- self.pre_delete(obj)
- obj.delete()
- self.post_delete(obj)
+ self.perform_destroy(obj)
return Response(status=status.HTTP_204_NO_CONTENT)
else:
return Response(status=status.HTTP_400_BAD_REQUEST)
@@ -69,7 +60,7 @@
class XOSListCreateAPIView(generics.ListCreateAPIView):
def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
+ serializer = self.get_serializer(data=request.data)
# In rest_framework 3.x: we can pass raise_exception=True instead of
# raising the exception ourselves
@@ -77,22 +68,12 @@
raise XOSValidationError(fields=serializer._errors)
# now do XOS can_update permission checking
-
- obj = serializer.object
+ obj = serializer.Meta.model(**serializer.validated_data)
obj.caller = request.user
if not obj.can_update(request.user):
raise XOSPermissionDenied()
- # stuff below is from generics.ListCreateAPIView
-
- if (hasattr(self, "pre_save")):
- # rest_framework 2.x
- self.pre_save(serializer.object)
- self.object = serializer.save(force_insert=True)
- self.post_save(self.object, created=True)
- else:
- # rest_framework 3.x
- self.perform_create(serializer)
+ self.perform_create(serializer)
headers = self.get_success_headers(serializer.data)
return Response(serializer.data, status=status.HTTP_201_CREATED,
diff --git a/xos/xos/hpcapi.py b/xos/xos/hpcapi.py
index d444684..5b97ab9 100644
--- a/xos/xos/hpcapi.py
+++ b/xos/xos/hpcapi.py
@@ -123,7 +123,8 @@
# Based on serializers.py
class XOSModelSerializer(serializers.ModelSerializer):
- def save_object(self, obj, **kwargs):
+ # TODO: Rest Framework 3.x doesn't support save_object()
+ def NEED_TO_UPDATE_save_object(self, obj, **kwargs):
""" rest_framework can't deal with ManyToMany relations that have a
through table. In xos, most of the through tables we have
diff --git a/xos/xos/xosapi.py b/xos/xos/xosapi.py
index d0a9646..7673f28 100644
--- a/xos/xos/xosapi.py
+++ b/xos/xos/xosapi.py
@@ -605,7 +605,8 @@
# Based on serializers.py
class XOSModelSerializer(serializers.ModelSerializer):
- def save_object(self, obj, **kwargs):
+ # TODO: Rest Framework 3.x doesn't support save_object()
+ def NEED_TO_UPDATE_save_object(self, obj, **kwargs):
""" rest_framework can't deal with ManyToMany relations that have a
through table. In xos, most of the through tables we have