changes to model
diff --git a/views/ngXosViews/tenant/.eslintrc b/views/ngXosViews/tenant/.eslintrc
index c852748..f9a952f 100644
--- a/views/ngXosViews/tenant/.eslintrc
+++ b/views/ngXosViews/tenant/.eslintrc
@@ -16,7 +16,7 @@
],
"rules": {
"quotes": [2, "single"],
- "camelcase": [1, {"properties": "always"}],
+ "camelcase": [0, {"properties": "always"}],
"no-underscore-dangle": 1,
"eqeqeq": [2, "smart"],
"no-alert": 1,
diff --git a/views/ngXosViews/tenant/src/js/main.js b/views/ngXosViews/tenant/src/js/main.js
index 468d4d6..20cf2f0 100644
--- a/views/ngXosViews/tenant/src/js/main.js
+++ b/views/ngXosViews/tenant/src/js/main.js
@@ -13,21 +13,15 @@
template: '<users-list></users-list>'
})
.state('site', {
- url:'/site/:id',
- template:'<site-detail></site-detail>'
+ url: '/site/:id',
+ template: '<site-detail></site-detail>'
})
.state('createslice', {
- url:'/site/:site/slice/',
- template:'<create-slice></create-slice>'
+ url: '/site/:site/slice/:id?',
+ template: '<create-slice></create-slice>'
- })
- .state('editslice', {
- url:'/site/:site/slice/:id?',
- template:'<edit-slice></edit-slice>'
-
- });;
-
+ });
})
.config(function($httpProvider){
$httpProvider.interceptors.push('NoHyperlinks');
@@ -40,7 +34,7 @@
bindToController: true,
controllerAs: 'vm',
templateUrl: 'templates/users-list.tpl.html',
- controller: function(Sites,SlicesPlus){
+ controller: function(Sites, SlicesPlus){
@@ -62,7 +56,6 @@
]
};
- var sites;
// retrieving user list
Sites.query().$promise
.then((users) => {
@@ -72,41 +65,38 @@
.then((users) => {
this.slices = users;
//console.log(this.sites,this.slices);
- this.site_list = this.returnData(this.sites,this.slices);
+ this.site_list = this.returnData(this.sites, this.slices);
})
.catch((e) => {
throw new Error(e);
});
- //console.log(sites);
- this.returnData = (sites,slices) => {
+ this.returnData = (sites, slices) => {
//console.log(sites,slices);
//console.log(sites.length)
- var i,j=0;
+ var i, j=0;
var site_list=[];
- var slice_list = [];
for(i = 0; i<sites.length; i++){
var instance_t = 0;
var instance_t_r = 0;
for(j=0;j<slices.length;j++){
- if (sites[i].id != null && slices[j].site !=null && sites[i].id == slices[j].site){
- console.log(sites[i].id,slices[j].id);
- instance_t = instance_t + slices[j].instance_total;
- instance_t_r = instance_t_r + slices[j].instance_total_ready;
- }
+ if (sites[i].id != null && slices[j].site !=null && sites[i].id === slices[j].site){
+ instance_t = instance_t + slices[j].instance_total;
+ instance_t_r = instance_t_r + slices[j].instance_total_ready;
+ }
}
var data_sites = {
- 'id': sites[i].id,
- 'name': sites[i].name,
- 'instance_total' :instance_t,
- 'instance_total_ready' : instance_t_r
+ 'id': sites[i].id,
+ 'name': sites[i].name,
+ 'instance_total': instance_t,
+ 'instance_total_ready': instance_t_r
};
//console.log(sites[i].id);
site_list.push(data_sites);
}
- return site_list
+ return site_list;
//this.site_list = site_list;
}
}
@@ -119,9 +109,7 @@
bindToController: true,
controllerAs: 'sl',
templateUrl: 'templates/slicelist.html',
- controller: function(SlicesPlus,$stateParams){
- console.log($stateParams);
- this.siteId = $stateParams.id;
+ controller: function(SlicesPlus, $stateParams){
this.tableConfig = {
columns: [
{
@@ -142,7 +130,7 @@
// retrieving user list
SlicesPlus.query({
- site:$stateParams.id
+ site: $stateParams.id
}).$promise
.then((users) => {
this.users = users;
@@ -161,104 +149,105 @@
bindToController: true,
controllerAs: 'cs',
templateUrl: 'templates/createslice.html',
- controller: function(Slices,SlicesPlus,$stateParams){
+ controller: function(Slices, SlicesPlus, $stateParams){
//var sites;
//console.log(this.users.name);
//console.log(this.config);
this.config = {
- exclude: ['password', 'last_login'],
- formName: 'SliceDetails',
- actions: [
- {
- label: 'Save',
- icon: 'ok', // refers to bootstraps glyphicon
- cb: (user) => { // receive the model
- console.log(user);
- },
- class: 'success'
- },{
- label: 'Save and continue editing',
- icon: 'ok', // refers to bootstraps glyphicon
- cb: (user) => { // receive the model
- console.log(user);
- },
- class: 'primary'
- },{
- label: 'Save and add another',
- icon: 'ok', // refers to bootstraps glyphicon
- cb: (user) => { // receive the model
- console.log(user);
- },
- class: 'primary'
- }
- ],
- fields:
- {
- site_select : {
- label:'Site',
- type:'select',
- validators:{ required: true,},
- hint : 'The Site this Slice belongs to',
- options:[
- {
- id:0,
- label:"---Site---"
- },
- {
- id:1,
- label:"---Site1---"
- }],
-
+ exclude: ['password', 'last_login'],
+ formName: 'SliceDetails',
+ actions: [
+ {
+ label: 'Save',
+ icon: 'ok', // refers to bootstraps glyphicon
+ cb: (user) => { // receive the model
+ console.log(user);
},
+ class: 'success'
+ }, {
+ label: 'Save and continue editing',
+ icon: 'ok', // refers to bootstraps glyphicon
+ cb: (user) => { // receive the model
+ console.log(user);
+ },
+ class: 'primary'
+ },
+ {
+ label: 'Save and add another',
+ icon: 'ok', // refers to bootstraps glyphicon
+ cb: (user) => { // receive the model
+ console.log(user);
+ },
+ class: 'primary'
+ }
+ ],
+ fields:
+ {
+ site_select: {
+ label: 'Site',
+ type: 'select',
+ validators: { required: true},
+ hint: 'The Site this Slice belongs to',
+ options: [
+ {
+ id: 0,
+ label: '---Site---'
+ },
+ {
+ id: 1,
+ label: '---Site1---'
+ }]
+
+ },
first_name: {
- label:'Name',
+ label: 'Name',
type: 'string',
- hint: 'The Name of the Slice',
+ hint: 'The Name of the Slice',
validators: {
required: true
}
},
- service_class : {
- label:'ServiceClass',
- type:'select',
- validators:{ required: true,},
- hint : 'The Site this Slice belongs to',
- options:[
- {
- id:0,
- label:"Best effort"
- },
- ],
- },
+ service_class: {
+ label: 'ServiceClass',
+ type: 'select',
+ validators: {required: true},
+ hint: 'The Site this Slice belongs to',
+ options: [
+ {
+ id: 1,
+ label: 'Best effort'
+ }
+ ]
+ },
enabled: {
label: 'Enabled',
- type : 'boolean',
- hint:'Status for this Slice'
+ type: 'boolean',
+ hint: 'Status for this Slice'
},
description: {
label: 'Description',
- type : 'string',
- hint:'High level description of the slice and expected activities',
+ type: 'string',
+ hint: 'High level description of the slice and expected activities',
validators: {
required: false,
minlength: 10
}
},
- service : {
- label:'Service',
- type:'select',
- validators:{ required: false,},
- options:[
- {
- id:0,
- label:"--------"
- },
- ],
- },
+ service: {
+ label: 'Service',
+ type: 'select',
+ validators: { required: false},
+ options: [
+ {
+ id: 0,
+ label: '--------'
+ }
+ ]
+ },
slice_url: {
label: 'Slice url',
- type : 'string',
+ type: 'string',
validators: {
required: false,
minlength: 10
@@ -271,279 +260,92 @@
min: 0
}
},
- default_isolation : {
- label:'Default Isolation',
- type:'select',
- validators:{ required: false,},
- options:[
- {
- id:0,
- label:"Virtual Machine"
- },{
- id:1,
- label:"Container"
- },{
- id:2,
- label:"Container in VM"
- },
- ],
+ default_isolation: {
+ label: 'Default Isolation',
+ type: 'select',
+ validators: { required: false},
+ options: [
+ {
+ id: 'vm',
+ label: 'Virtual Machine'
+ },
+ {
+ id: 'container',
+ label: 'Container'
+ },
+ {
+ id: 'container_vm',
+ label: 'Container in VM'
+ }
+ ]
},
- default_image : {
- label:'Default image',
- type:'select',
- validators:{ required: false,},
- options:[
- {
- id:0,
- label:"trusty-server-multi-nic"
- },
- ],
+ default_image: {
+ label: 'Default image',
+ type: 'select',
+ validators: { required: false},
+ options: [
+ {
+ id: 0,
+ label: 'trusty-server-multi-nic'
+ }
+ ]
},
- network : {
- label:'Network',
- type:'select',
- validators:{ required: false,},
- options:[
- {
- id:0,
- label:"Default"
- },
- {
- id:1,
- label:"Host"
- },
- {
- id:2,
- label:"Bridged"
- },
- {
- id:3,
- label:"No Automatic Networks"
- },
- ],
- },
+ network: {
+ label: 'Network',
+ type: 'select',
+ validators: { required: false},
+ options: [
+ {
+ id: 'default',
+ label: 'Default'
+ },
+ {
+ id: 'host',
+ label: 'Host'
+ },
+ {
+ id: 'bridged',
+ label: 'Bridged'
+ },
+ {
+ id: 'noauto',
+ label: 'No Automatic Networks'
+ }
+ ]
+ }
- }
- };
-
- var data;
- // retrieving user list
-
-
- //Slices.get({id :$stateParams.id}).$promise
- //.then((users) => {
- // this.users = users;
- // //console.log(users.name);
- // data = users;
- //})
- //.catch((e) => {
- // throw new Error(e);
- //});
-
- //console.log(this.users);
-//console.log(this.config.fields.site_select.options);
- this.model = {
+ }
};
- }
- };
-})
-.directive('editSlice', function(){
- return {
- //sites : {},
- restrict: 'E',
- scope: {},
- bindToController: true,
- controllerAs: 'cs',
- templateUrl: 'templates/createslice.html',
- controller: function(Slices,SlicesPlus,$stateParams){
- //var sites;
- //console.log(this.users.name);
-
- //console.log(this.config);
- this.config = {
- exclude: ['password', 'last_login'],
- formName: 'SliceDetails',
- actions: [
- {
- label: 'Save',
- icon: 'ok', // refers to bootstraps glyphicon
- cb: (user) => { // receive the model
- console.log(user);
- },
- class: 'success'
- },{
- label: 'Save and continue editing',
- icon: 'ok', // refers to bootstraps glyphicon
- cb: (user) => { // receive the model
- console.log(user);
- },
- class: 'primary'
- },{
- label: 'Save and add another',
- icon: 'ok', // refers to bootstraps glyphicon
- cb: (user) => { // receive the model
- console.log(user);
- },
- class: 'primary'
- }
- ],
- fields:
- {
- site_select : {
- label:'Site',
- type:'select',
- validators:{ required: true,},
- hint : 'The Site this Slice belongs to',
- options:[
- {
- id:0,
- label:"---Site---"
- },
- {
- id:1,
- label:"---Site1---"
- }],
-
- },
- first_name: {
- label:'Name',
- type: 'string',
- hint: 'The Name of the Slice',
- validators: {
- required: true
- }
- },
- service_class : {
- label:'ServiceClass',
- type:'select',
- validators:{ required: true,},
- hint : 'The Site this Slice belongs to',
- options:[
- {
- id:0,
- label:"Best effort"
- },
- ],
- },
- enabled: {
- label: 'Enabled',
- type : 'boolean',
- hint:'Status for this Slice'
- },
- description: {
- label: 'Description',
- type : 'string',
- hint:'High level description of the slice and expected activities',
- validators: {
- required: false,
- minlength: 10
- }
- },
- service : {
- label:'Service',
- type:'select',
- validators:{ required: false,},
- options:[
- {
- id:0,
- label:"--------"
- },
- ],
- },
- slice_url: {
- label: 'Slice url',
- type : 'string',
- validators: {
- required: false,
- minlength: 10
- }
- },
- max_instances: {
- type: 'Max Instances',
- validators: {
- required: false,
- min: 0
- }
- },
- default_isolation : {
- label:'Default Isolation',
- type:'select',
- validators:{ required: false,},
- options:[
- {
- id:0,
- label:"Virtual Machine"
- },{
- id:1,
- label:"Container"
- },{
- id:2,
- label:"Container in VM"
- },
- ],
- },
- default_image : {
- label:'Default image',
- type:'select',
- validators:{ required: false,},
- options:[
- {
- id:0,
- label:"trusty-server-multi-nic"
- },
- ],
- },
- network : {
- label:'Network',
- type:'select',
- validators:{ required: false,},
- options:[
- {
- id:0,
- label:"Default"
- },
- {
- id:1,
- label:"Host"
- },
- {
- id:2,
- label:"Bridged"
- },
- {
- id:3,
- label:"No Automatic Networks"
- },
- ],
- },
-
- }
- };
var data;
// retrieving user list
-
-
- Slices.get({id :$stateParams.id}).$promise
- .then((users) => {
- this.users = users;
- //console.log(users.name);
- data = users;
+ if ($stateParams.id)
+ {
+ Slices.get({id: $stateParams.id}).$promise
+ .then((users) => {
+ this.users = users;
+ data = users;
this.model = {
- first_name : users.firstname;
-
- };
- })
- .catch((e) => {
- throw new Error(e);
- });
-
- //console.log(this.users);
-//console.log(this.config.fields.site_select.options);
-
+ first_name: data.name,
+ service_class: data.serviceClass,
+ enabled: data.enabled,
+ description: data.description,
+ service: data.service,
+ slice_url: data.slice_url,
+ max_instances: data.max_instances,
+ default_isolation: data.default_isolation,
+ default_image: data.default_image,
+ network: data.network
+ };
+ })
+ .catch((e) => {
+ throw new Error(e);
+ });
+ }
+ else
+ {
+ this.model = {};
+ }
}
};
-});
-
-
-
+});
\ No newline at end of file