Actions directive and delete CP
diff --git a/xos/core/xoslib/static/js/xosContentProvider.js b/xos/core/xoslib/static/js/xosContentProvider.js
index c404420..f001730 100644
--- a/xos/core/xoslib/static/js/xosContentProvider.js
+++ b/xos/core/xoslib/static/js/xosContentProvider.js
@@ -71,6 +71,25 @@
.service('User', function($resource) {
return $resource('/xos/users/:id/', {id: '@id'});
})
+.directive('cpActions', function(ContentProvider, $location) {
+ return {
+ restrict: 'E',
+ scope: {
+ id: '=id',
+ },
+ bindToController: true,
+ controllerAs: 'vm',
+ templateUrl: '../../static/templates/contentProvider/cp_actions.html',
+ controller: function() {
+ this.deleteCp = function(id) {
+ ContentProvider.delete({id: id}).$promise
+ .then(function() {
+ $location.url('/');
+ });
+ };
+ }
+ };
+})
.directive('contentProviderList', function(ContentProvider) {
return {
restrict: 'E',
@@ -89,7 +108,7 @@
}
};
})
-.directive('contentProviderDetail', function(ContentProvider, ServiceProvider, $routeParams) {
+.directive('contentProviderDetail', function(ContentProvider, ServiceProvider, $routeParams, $location) {
return {
restrict: 'E',
controllerAs: 'vm',
@@ -125,21 +144,25 @@
};
this.saveContentProvider = function(cp) {
- var p;
+ var p, isNew = false;
if(cp.id) {
p = cp.$update();
}
else {
+ isNew = true;
cp.name = cp.humanReadableName;
p = new ContentProvider(cp).$save();
}
- p.then(function() {
+ p.then(function(res) {
_this.result = {
status: 1,
msg: 'Content Provider Saved'
};
+ if(isNew) {
+ $location.url('contentProvider/' + res.id + '/');
+ }
})
.catch(function(e) {
_this.result = {
diff --git a/xos/core/xoslib/static/templates/contentProvider/cp_actions.html b/xos/core/xoslib/static/templates/contentProvider/cp_actions.html
new file mode 100644
index 0000000..8c6ae97
--- /dev/null
+++ b/xos/core/xoslib/static/templates/contentProvider/cp_actions.html
@@ -0,0 +1,9 @@
+<a href="#/" class="btn btn-default">
+ <i class="icon icon-arrow-left"></i>Back
+</a>
+<a href="#/contentProvider/" class="btn btn-success">
+ <i class="icon icon-plus"></i>Create
+</a>
+<a ng-click="vm.deleteCp(vm.id)" class="btn btn-danger">
+ <i class="icon icon-remove"></i>Remove
+</a>
\ No newline at end of file
diff --git a/xos/core/xoslib/static/templates/contentProvider/cp_cdn_prefix.html b/xos/core/xoslib/static/templates/contentProvider/cp_cdn_prefix.html
index a941881..d989f90 100644
--- a/xos/core/xoslib/static/templates/contentProvider/cp_cdn_prefix.html
+++ b/xos/core/xoslib/static/templates/contentProvider/cp_cdn_prefix.html
@@ -1,9 +1,9 @@
<div class="row-fluid">
- <div class="span8">
+ <div class="span6">
<h1>{$ vm.cp.humanReadableName $}</h1>
</div>
- <div class="span4">
- <a href="#/" class="btn btn-default">Back</a>
+ <div class="span6 text-right">
+ <cp-actions id="vm.cp.id"></cp-actions>
</div>
</div>
<hr>
diff --git a/xos/core/xoslib/static/templates/contentProvider/cp_detail.html b/xos/core/xoslib/static/templates/contentProvider/cp_detail.html
index 88b68ea..7fab7f2 100644
--- a/xos/core/xoslib/static/templates/contentProvider/cp_detail.html
+++ b/xos/core/xoslib/static/templates/contentProvider/cp_detail.html
@@ -1,9 +1,9 @@
<div class="row-fluid">
- <div class="span8">
+ <div class="span6">
<h1>{$ vm.cp.humanReadableName $}</h1>
</div>
- <div class="span4">
- <a href="#/" class="btn btn-default">Back</a>
+ <div class="span6 text-right">
+ <cp-actions id="vm.cp.id"></cp-actions>
</div>
</div>
<hr>
diff --git a/xos/core/xoslib/static/templates/contentProvider/cp_origin_server.html b/xos/core/xoslib/static/templates/contentProvider/cp_origin_server.html
index fca7855..b2e1881 100644
--- a/xos/core/xoslib/static/templates/contentProvider/cp_origin_server.html
+++ b/xos/core/xoslib/static/templates/contentProvider/cp_origin_server.html
@@ -1,9 +1,9 @@
<div class="row-fluid">
- <div class="span8">
+ <div class="span6">
<h1>{$ vm.cp.humanReadableName $}</h1>
</div>
- <div class="span4">
- <a href="#/" class="btn btn-default">Back</a>
+ <div class="span6 text-right">
+ <cp-actions id="vm.cp.id"></cp-actions>
</div>
</div>
<hr>
diff --git a/xos/core/xoslib/static/templates/contentProvider/cp_user.html b/xos/core/xoslib/static/templates/contentProvider/cp_user.html
index 2ed8a0c..435e656 100644
--- a/xos/core/xoslib/static/templates/contentProvider/cp_user.html
+++ b/xos/core/xoslib/static/templates/contentProvider/cp_user.html
@@ -1,9 +1,9 @@
<div class="row-fluid">
- <div class="span8">
+ <div class="span6">
<h1>{$ vm.cp.humanReadableName $}</h1>
</div>
- <div class="span4">
- <a href="#/" class="btn btn-default">Back</a>
+ <div class="span6 text-right">
+ <cp-actions id="vm.cp.id"></cp-actions>
</div>
</div>
<hr>