You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2018/08/13 17:11:25 UTC
[trafficcontrol] 06/12: delete sde
This is an automated email from the ASF dual-hosted git repository.
mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit e2b8d023cd1fce6bad18c9966f5a84f489f8ad7a
Author: Jesse Rivas <je...@comcast.com>
AuthorDate: Tue Jul 31 14:02:48 2018 -0600
delete sde
update sde
---
.../app/src/common/api/StaticDnsEntryService.js | 33 ++++++++++-
...mEditDeliveryServiceStaticDnsEntryController.js | 68 +++++++++++-----------
.../form.deliveryServiceStaticDnsEntry.tpl.html | 2 +-
3 files changed, 66 insertions(+), 37 deletions(-)
diff --git a/traffic_portal/app/src/common/api/StaticDnsEntryService.js b/traffic_portal/app/src/common/api/StaticDnsEntryService.js
index 3021beb..4382538 100644
--- a/traffic_portal/app/src/common/api/StaticDnsEntryService.js
+++ b/traffic_portal/app/src/common/api/StaticDnsEntryService.js
@@ -17,7 +17,7 @@
* under the License.
*/
-var StaticDnsEntryService = function(Restangular, locationUtils, messageModel) {
+var StaticDnsEntryService = function($http, $q, Restangular, locationUtils, messageModel, ENV) {
this.getStaticDnsEntries = function(queryParams) {
return Restangular.all('staticdnsentries').getList(queryParams);
@@ -35,7 +35,36 @@ var StaticDnsEntryService = function(Restangular, locationUtils, messageModel) {
}
);
};
+
+ this.deleteDeliveryServiceStaticDnsEntry = function(queryParams) {
+ return Restangular.all('staticdnsentries').remove(queryParams)
+ .then(
+ function() {
+ messageModel.setMessages([ { level: 'success', text: 'Static DNS Entry deleted' } ], true);
+ },
+ function(fault) {
+ messageModel.setMessages(fault.data.alerts, true);
+ }
+ );
+ };
+
+ this.updateDeliveryServiceStaticDnsEntry = function(id, staticDnsEntry) {
+ var request = $q.defer();
+
+ $http.put(ENV.api['root'] + "staticdnsentries?id=" + id, staticDnsEntry)
+ .then(
+ function(response) {
+ messageModel.setMessages(response.data.alerts, false);
+ request.resolve();
+ },
+ function(fault) {
+ messageModel.setMessages(fault.data.alerts, false);
+ request.reject();
+ }
+ );
+ return request.promise;
+ };
};
-StaticDnsEntryService.$inject = ['Restangular', 'locationUtils', 'messageModel'];
+StaticDnsEntryService.$inject = ['$http', '$q', 'Restangular', 'locationUtils', 'messageModel', 'ENV'];
module.exports = StaticDnsEntryService;
diff --git a/traffic_portal/app/src/common/modules/form/deliveryServiceStaticDnsEntry/edit/FormEditDeliveryServiceStaticDnsEntryController.js b/traffic_portal/app/src/common/modules/form/deliveryServiceStaticDnsEntry/edit/FormEditDeliveryServiceStaticDnsEntryController.js
index 71ce9de..5a5a4d1 100644
--- a/traffic_portal/app/src/common/modules/form/deliveryServiceStaticDnsEntry/edit/FormEditDeliveryServiceStaticDnsEntryController.js
+++ b/traffic_portal/app/src/common/modules/form/deliveryServiceStaticDnsEntry/edit/FormEditDeliveryServiceStaticDnsEntryController.js
@@ -22,12 +22,12 @@ var FormEditDeliveryServiceStaticDnsEntryController = function(deliveryService,
// extends the FormDeliveryServiceController to inherit common methods
angular.extend(this, $controller('FormDeliveryServiceStaticDnsEntryController', { deliveryService: deliveryService, staticDnsEntry: staticDnsEntry, $scope: $scope }));
- // var deleteDeliveryServiceRegex = function(dsId, regexId) {
- // deliveryServiceRegexService.deleteDeliveryServiceRegex(dsId, regexId)
- // .then(function() {
- // locationUtils.navigateToPath('/delivery-services/' + dsId + '/regexes');
- // });
- // };
+ var deleteDeliveryServiceStaticDnsEntry = function(dsId, staticDnsEntryId) {
+ staticDnsEntryService.deleteDeliveryServiceStaticDnsEntry({ id: staticDnsEntryId })
+ .then(function() {
+ locationUtils.navigateToPath('/delivery-services/' + dsId + '/static-dns-entries');
+ });
+ };
$scope.staticDnsEntry = staticDnsEntry[0];
$scope.host = angular.copy($scope.staticDnsEntry.host);
@@ -37,35 +37,35 @@ var FormEditDeliveryServiceStaticDnsEntryController = function(deliveryService,
saveLabel: 'Update'
};
- // $scope.save = function(dsId, regex) {
- // deliveryServiceRegexService.updateDeliveryServiceRegex(regex).
- // then(function() {
- // $scope.regexPattern = angular.copy(regex.pattern);
- // $anchorScroll(); // scrolls window to top
- // });
- // };
+ $scope.save = function(dsId, staticDnsEntry) {
+ staticDnsEntryService.updateDeliveryServiceStaticDnsEntry(staticDnsEntry.id, staticDnsEntry).
+ then(function() {
+ $scope.host = angular.copy(staticDnsEntry.host);
+ $anchorScroll(); // scrolls window to top
+ });
+ };
- // $scope.confirmDelete = function(regex) {
- // var params = {
- // title: 'Delete Delivery Service Regex: ' + regex.pattern,
- // key: regex.pattern
- // };
- // var modalInstance = $uibModal.open({
- // templateUrl: 'common/modules/dialog/delete/dialog.delete.tpl.html',
- // controller: 'DialogDeleteController',
- // size: 'md',
- // resolve: {
- // params: function () {
- // return params;
- // }
- // }
- // });
- // modalInstance.result.then(function() {
- // deleteDeliveryServiceRegex(deliveryService.id, regex.id);
- // }, function () {
- // // do nothing
- // });
- // };
+ $scope.confirmDelete = function(staticDnsEntry) {
+ var params = {
+ title: 'Delete Delivery Service StaticDnsEntry on host: ' + staticDnsEntry.host + ' with address: ' + staticDnsEntry.address,
+ key: staticDnsEntry.host
+ };
+ var modalInstance = $uibModal.open({
+ templateUrl: 'common/modules/dialog/delete/dialog.delete.tpl.html',
+ controller: 'DialogDeleteController',
+ size: 'md',
+ resolve: {
+ params: function () {
+ return params;
+ }
+ }
+ });
+ modalInstance.result.then(function() {
+ deleteDeliveryServiceStaticDnsEntry(deliveryService.id, staticDnsEntry.id);
+ }, function () {
+ // do nothing
+ });
+ };
};
diff --git a/traffic_portal/app/src/common/modules/form/deliveryServiceStaticDnsEntry/form.deliveryServiceStaticDnsEntry.tpl.html b/traffic_portal/app/src/common/modules/form/deliveryServiceStaticDnsEntry/form.deliveryServiceStaticDnsEntry.tpl.html
index e9486a3..0f980a8 100644
--- a/traffic_portal/app/src/common/modules/form/deliveryServiceStaticDnsEntry/form.deliveryServiceStaticDnsEntry.tpl.html
+++ b/traffic_portal/app/src/common/modules/form/deliveryServiceStaticDnsEntry/form.deliveryServiceStaticDnsEntry.tpl.html
@@ -75,7 +75,7 @@ under the License.
</div>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-danger" ng-show="!settings.isNew" ng-click="confirmDelete(regex)">Delete</button>
+ <button type="button" class="btn btn-danger" ng-show="!settings.isNew" ng-click="confirmDelete(staticDnsEntry)">Delete</button>
<button type="button" class="btn btn-success" ng-disabled="dsStaticDnsEntryForm.$pristine || dsStaticDnsEntryForm.$invalid" ng-click="save(deliveryService.id, staticDnsEntry)">{{settings.saveLabel}}</button>
</div>
</form>