Added changes to Routing
diff --git a/views/ngXosViews/tenant/src/js/main.js b/views/ngXosViews/tenant/src/js/main.js
index a08764e..e5f702e 100644
--- a/views/ngXosViews/tenant/src/js/main.js
+++ b/views/ngXosViews/tenant/src/js/main.js
@@ -110,6 +110,7 @@
controllerAs: 'sl',
templateUrl: 'templates/slicelist.html',
controller: function(SlicesPlus, $stateParams){
+ this.siteId = $stateParams.id;
this.tableConfig = {
columns: [
{
@@ -133,7 +134,7 @@
site: $stateParams.id
}).$promise
.then((users) => {
- this.users = users;
+ this.sliceList = users;
})
.catch((e) => {
throw new Error(e);
@@ -149,7 +150,7 @@
bindToController: true,
controllerAs: 'cs',
templateUrl: 'templates/createslice.html',
- controller: function(Slices, SlicesPlus, Sites, Images, $stateParams, $http, $state){
+ controller: function(Slices, SlicesPlus, Sites, Images, $stateParams, $http, $state, $q){
//var sites;
//console.log(this.users.name);
@@ -167,98 +168,26 @@
label: 'Save',
icon: 'ok', // refers to bootstraps glyphicon
cb: (model, form) => { // receive the model
- if (form.$valid )
- {
- if(model.id){
- var pr = Slices.update(model).$promise;
- }
- else{
- var pr = Slices.save(model).$promise;
- }
- pr.then((users) => {
- this.users = users;
- data = users;
- this.model = data;
- this.config.feedback.show = true;
- $state.go('site',{id : this.model.site});
- })
- .catch((e) => {
- this.config.feedback.show = true;
- this.config.feedback.type='danger';
- if(e.data)
- {
- console.log(e.data.detail);
- this.config.feedback.message = e.data.detail;
- }
- else {
- this.config.feedback.message=e.statusText;}
- });
- }
+ saveform(model, form).then(()=> {
+ $state.go('site', {id: this.model.site});
+ });
},
class: 'success'
}, {
label: 'Save and continue editing',
icon: 'ok', // refers to bootstraps glyphicon
cb: (model, form) => { // receive the model
- if (form.$valid )
- {
- if(model.id){
- var pr = Slices.update(model).$promise;
- }
- else{
- var pr = Slices.save(model).$promise;
- }
- pr.then((users) => {
- this.users = users;
- data = users;
- this.model = data;
- this.config.feedback.show = true;
- })
- .catch((e) => {
- this.config.feedback.show = true;
- this.config.feedback.type='danger';
- if(e.data)
- {
- console.log(e.data.detail);
- this.config.feedback.message = e.data.detail;
- }
- else {
- this.config.feedback.message=e.statusText;}
- });
- }
+ saveform(model,form);
},
class: 'primary'
},
{
label: 'Save and add another',
icon: 'ok', // refers to bootstraps glyphicon
- cb: (model, form) => { // receive the model
- if (form.$valid )
- {
- if(model.id){
- var pr = Slices.update(model).$promise;
- }
- else{
- var pr = Slices.save(model).$promise;
- }
- pr.then((users) => {
- this.users = users;
- data = users;
- this.model = data;
- this.config.feedback.show = true;
- })
- .catch((e) => {
- this.config.feedback.show = true;
- this.config.feedback.type='danger';
- if(e.data)
- {
- console.log(e.data.detail);
- this.config.feedback.message = e.data.detail;
- }
- else {
- this.config.feedback.message=e.statusText;}
- });
- }
+ cb: (model, form) => {
+ saveform(model,form).then(()=> {
+ $state.go('createslice',{site : this.model.site,id : ''});
+ });
},
class: 'primary'
}
@@ -327,7 +256,8 @@
}
},
max_instances: {
- type: 'Max Instances',
+ label: 'Max Instances',
+ type: 'number',
validators: {
required: false,
min: 0
@@ -423,7 +353,6 @@
.then((users) => {
this.users = users;
data = users;
- delete data.networks;
this.model = data;
})
@@ -464,6 +393,42 @@
});
}
+
+ var saveform = (model,form) =>
+ { // receive the model
+ var deferred = $q.defer();
+ delete model.networks;
+ if (form.$valid )
+ {
+ if(model.id){
+ var pr = Slices.update(model).$promise;
+ }
+ else{
+ var pr = Slices.save(model).$promise;
+ }
+ pr.then((users) => {
+ this.model = users;
+ //data = users;
+ //this.model = this.users;
+ this.config.feedback.show = true;
+ deferred.resolve(this.model);
+ })
+ .catch((e) => {
+ this.config.feedback.show = true;
+ this.config.feedback.type='danger';
+ if(e.data && e.data.detail )
+ {
+ this.config.feedback.message = e.data.detail;
+ }
+ else {
+ this.config.feedback.message=e.statusText;
+ }
+ deferred.reject(e);
+ });
+ }
+
+ return deferred.promise;
+ }
}
};
});
\ No newline at end of file
diff --git a/views/ngXosViews/tenant/src/templates/slicelist.html b/views/ngXosViews/tenant/src/templates/slicelist.html
index 37b8550..fb42315 100644
--- a/views/ngXosViews/tenant/src/templates/slicelist.html
+++ b/views/ngXosViews/tenant/src/templates/slicelist.html
@@ -1,6 +1,6 @@
<!--<span ng-bind="siteNameSe"></span>-->
<!--<xos-field></xos-field>-->
-<a class="addlink btn btn-info" ui-sref="createslice({site: sl.users[0].site})"><i class="glyphicon glyphicon-plus-sign"></i> Create Slice</a>
-<xos-table config="sl.tableConfig" data="sl.users"></xos-table>
+<a class="addlink btn btn-info" ui-sref="createslice({site: sl.siteId})"><i class="glyphicon glyphicon-plus-sign"></i> Create Slice</a>
+<xos-table config="sl.tableConfig" data="sl.sliceList"></xos-table>
<!--<div ui-view="sliceDetails"></div>-->
<!--<pre>{{sl.users[0].site}}</pre>-->