Creating CDN Prefix
diff --git a/xos/core/xoslib/static/js/xosContentProvider.js b/xos/core/xoslib/static/js/xosContentProvider.js
index aebdbd6..aac629d 100644
--- a/xos/core/xoslib/static/js/xosContentProvider.js
+++ b/xos/core/xoslib/static/js/xosContentProvider.js
@@ -55,7 +55,7 @@
.service('ServiceProvider', function($resource) {
return $resource('/hpcapi/serviceproviders/:id/', {id: '@id'});
})
-.service('CdnPrefixed', function($resource) {
+.service('CdnPrefix', function($resource) {
return $resource('/hpcapi/cdnprefixs/:id/', {id: '@id'});
})
.directive('contentProviderList', function(ContentProvider) {
@@ -138,7 +138,7 @@
}
};
})
-.directive('contentProviderCdn', function($routeParams, CdnPrefixed, ContentProvider, lodash) {
+.directive('contentProviderCdn', function($routeParams, CdnPrefix, ContentProvider, lodash) {
return{
restrict: 'E',
controllerAs: 'vm',
@@ -161,7 +161,7 @@
}
// TODO filter on client
- CdnPrefixed.query({contentProvider: $routeParams.id}).$promise
+ CdnPrefix.query({contentProvider: $routeParams.id}).$promise
.then(function(cp_prf) {
_this.cp_prf = cp_prf;
}).catch(function(e) {
@@ -171,7 +171,7 @@
};
});
- CdnPrefixed.query().$promise
+ CdnPrefix.query().$promise
.then(function(prf) {
_this.prf = prf;
}).catch(function(e) {
@@ -181,8 +181,21 @@
};
});
- this.addPrefix = function(item) {
- console.log(item);
+ this.addPrefix = function(prf) {
+ prf.contentProvider = '/hpcapi/contentproviders/' + $routeParams.id + '/';
+
+ var item = new CdnPrefix(prf);
+
+ item.$save()
+ .then(function(res) {
+ _this.cp_prf.push(res);
+ })
+ .catch(function(e) {
+ _this.result = {
+ status: 0,
+ msg: e.data.detail
+ };
+ });
};
this.removePrefix = function(item) {
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 8179385..398f80d 100644
--- a/xos/core/xoslib/static/templates/contentProvider/cp_cdn_prefix.html
+++ b/xos/core/xoslib/static/templates/contentProvider/cp_cdn_prefix.html
@@ -32,12 +32,12 @@
<div class="row-fluid">
<div class="span4">
<label>Prefix</label>
- <input type="text" ng-model="vm.new_prf.humanReadableName" required style="max-width: 90%">
+ <input type="text" ng-model="vm.new_prf.prefix" required style="max-width: 90%">
</div>
<div class="span6">
<label>Default Origin Server</label>
- <select ng-model="vm.new_prf.boh" style="max-width: 100%">
- <option ng-repeat="prf in vm.prf" ng-value="prf.id.name">{$ prf.humanReadableName $}</option>
+ <select ng-model="vm.new_prf.defaultOriginServer" style="max-width: 100%">
+ <option ng-repeat="prf in vm.prf" ng-value="'/hpcapi/originservers/' + prf.id + '/'">{$ prf.humanReadableName $}</option>
</select>
</div>
<div class="span2">