saving a new CP
diff --git a/xos/core/xoslib/static/js/xosContentProvider.js b/xos/core/xoslib/static/js/xosContentProvider.js
index a36a3b7..3e9d772 100644
--- a/xos/core/xoslib/static/js/xosContentProvider.js
+++ b/xos/core/xoslib/static/js/xosContentProvider.js
@@ -17,7 +17,7 @@
.when('/', {
template: '<content-provider-list></content-provider-list>',
})
- .when('/contentProvider/:id', {
+ .when('/contentProvider/:id?', {
template: '<content-provider-detail></content-provider-detail>'
})
.when('/contentProvider/:id/cdn_prefix', {
@@ -81,10 +81,12 @@
this.pageName = 'detail';
var _this = this;
- ContentProvider.get({id: $routeParams.id}).$promise
- .then(function(cp) {
- _this.cp = cp;
- });
+ if($routeParams.id) {
+ ContentProvider.get({id: $routeParams.id}).$promise
+ .then(function(cp) {
+ _this.cp = cp;
+ });
+ }
ServiceProvider.query().$promise
.then(function(sp) {
@@ -101,9 +103,17 @@
};
this.saveContentProvider = function(cp) {
- // NOTE remember the creation
- cp.$update()
- .then(function() {
+ var p;
+
+ if(cp.id) {
+ p = cp.$update();
+ }
+ else {
+ cp.name = cp.humanReadableName;
+ p = new ContentProvider(cp).$save();
+ }
+
+ p.then(function() {
_this.result = {
status: 1,
msg: 'Content Provider Saved'
diff --git a/xos/core/xoslib/static/templates/contentProvider/cp_detail.html b/xos/core/xoslib/static/templates/contentProvider/cp_detail.html
index 0d5bf0a..3456449 100644
--- a/xos/core/xoslib/static/templates/contentProvider/cp_detail.html
+++ b/xos/core/xoslib/static/templates/contentProvider/cp_detail.html
@@ -34,14 +34,17 @@
<div class="row-fluid">
<div class="span12">
<label>Service provider</label>
- <select ng-model="vm.cp.serviceProvider">
- <option ng-repeat="sp in vm.sp" ng-value="sp.id" ng-selected="vm.activeServiceProvide(sp.id, vm.cp.serviceProvider)">{$ sp.humanReadableName $}</option>
+ <select ng-model="vm.cp.serviceProvider" required>
+ <option ng-repeat="sp in vm.sp" ng-value="'/hpcapi/serviceproviders/' + sp.id + '/'" ng-selected="vm.activeServiceProvide(sp.id, vm.cp.serviceProvider)">{$ sp.humanReadableName $}</option>
</select>
</div>
</div>
<div class="row-fluid">
<div class="span12">
- <button class="btn btn-success">Save</button>
+ <button class="btn btn-success">
+ <span ng-show="vm.cp.id">Save</span>
+ <span ng-show="!vm.cp.id">Create</span>
+ </button>
<div class="alert" ng-show="vm.result" ng-class="{'alert-success': vm.result.status === 1,'alert-error': vm.result.status === 0}">
{$ vm.result.msg $}
</div>
diff --git a/xos/core/xoslib/static/templates/contentProvider/cp_list.html b/xos/core/xoslib/static/templates/contentProvider/cp_list.html
index 9d205fd..16db7b5 100644
--- a/xos/core/xoslib/static/templates/contentProvider/cp_list.html
+++ b/xos/core/xoslib/static/templates/contentProvider/cp_list.html
@@ -1,4 +1,4 @@
-<table class="table table-striped">
+<table class="table table-striped" ng-show="vm.contentProviderList.length > 0">
<thead>
<tr>
<th>
@@ -19,4 +19,13 @@
{$ item.enabled $}
</td>
</tr>
-</table>
\ No newline at end of file
+</table>
+<div class="alert alert-error" ng-show="vm.contentProviderList.length == 0">
+ No Content Provider defined
+</div>
+
+<div class="row">
+ <div class="span12 text-right">
+ <a class="btn btn-success"href="#/contentProvider/">Create</a>
+ </div>
+</div>
\ No newline at end of file