This is an automated email from the ASF dual-hosted git repository.

shamrick pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new dc19574735 Add Delete button to SSL Keys page (#7646)
dc19574735 is described below

commit dc195747356bfac9ded4cf1dbc23b37931ac824e
Author: Eric Holguin <[email protected]>
AuthorDate: Tue Jul 18 07:23:16 2023 -0600

    Add Delete button to SSL Keys page (#7646)
    
    * add delete cert button
    
    * handle cert deletion
    
    * add delete button
    
    * Include change
    
    * add new line to end of file
---
 CHANGELOG.md                                       |  1 +
 .../common/api/DeliveryServiceSslKeysService.js    | 15 ++++++++++++++
 .../FormDeliveryServiceSslKeysController.js        | 24 ++++++++++++++++++++++
 .../form.deliveryServiceSslKeys.tpl.html           |  5 ++---
 4 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6d366dae38..51cc40ac2c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -44,6 +44,7 @@ The format is based on [Keep a 
Changelog](http://keepachangelog.com/en/1.0.0/).
 - [#7618](https://github.com/apache/trafficcontrol/pull/7618) *Traffic Portal* 
Add the ability to inspect a user provider cert, or the cert chain on DS SSL 
keys.
 - [#7619](https://github.com/apache/trafficcontrol/pull/7619) Traffic Ops* 
added optional field `oauth_user_attribute` for OAuth login credentials
 - [#7641](https://github.com/apache/trafficcontrol/pull/7641) *Traffic Router* 
Added further optimization to TR's algorithm of figuring out the zone for an 
incoming request.
+- [#7646](https://github.com/apache/trafficcontrol/pull/7646) *Traffic Portal* 
Add the ability to delete a cert.
 
 ### Changed
 - [#7584](https://github.com/apache/trafficcontrol/pull/7584) *Documentation* 
Upgrade Traffic Control Sphinx documentation Makefile OS intelligent.
diff --git a/traffic_portal/app/src/common/api/DeliveryServiceSslKeysService.js 
b/traffic_portal/app/src/common/api/DeliveryServiceSslKeysService.js
index 997eb40254..bdec97a1d8 100644
--- a/traffic_portal/app/src/common/api/DeliveryServiceSslKeysService.js
+++ b/traffic_portal/app/src/common/api/DeliveryServiceSslKeysService.js
@@ -100,6 +100,21 @@ var DeliveryServiceSslKeysService = function($http, 
messageModel, ENV) {
         );
     };
 
+    this.deleteCert = function(deliveryService) {
+        return $http.delete(ENV.api.unstable + "deliveryservices/xmlId/" + 
deliveryService.xmlId + "/sslkeys").then(
+            function(result) {
+                messageModel.setMessages(result.data.alerts, false);
+                return result;
+            },
+            function(err) {
+                if (err.data && err.data.alerts) {
+                    messageModel.setMessages(err.data.alerts, false);
+                    throw err;
+                }
+            }
+        );
+    };
+
     this.getSslKeys = function(deliveryService) {
         return $http.get(ENV.api.unstable + "deliveryservices/xmlId/" + 
deliveryService.xmlId + "/sslkeys", {params: {decode: "true"}}).then(
             function(result) {
diff --git 
a/traffic_portal/app/src/common/modules/form/deliveryServiceSslKeys/FormDeliveryServiceSslKeysController.js
 
b/traffic_portal/app/src/common/modules/form/deliveryServiceSslKeys/FormDeliveryServiceSslKeysController.js
index 4037e35dc9..496ded8b63 100644
--- 
a/traffic_portal/app/src/common/modules/form/deliveryServiceSslKeys/FormDeliveryServiceSslKeysController.js
+++ 
b/traffic_portal/app/src/common/modules/form/deliveryServiceSslKeys/FormDeliveryServiceSslKeysController.js
@@ -140,6 +140,30 @@ var FormDeliveryServiceSslKeysController = 
function(deliveryService, sslKeys, $s
                });
        };
 
+       $scope.confirmDelete = function() {
+               var params = {
+                       title: 'Delete latest SSL Keys for Delivery Service: ' 
+ deliveryService.xmlId,
+                       key: deliveryService.xmlId + '-keys'
+               };
+               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() {
+                       
deliveryServiceSslKeysService.deleteCert(deliveryService).then(
+                               function() {
+                                       $anchorScroll();
+                                       $scope.refresh();
+                               });
+               });
+       };
+
        $scope.updateProvider = function() {
                sslKeys.authType = $scope.acmeProvider;
        };
diff --git 
a/traffic_portal/app/src/common/modules/form/deliveryServiceSslKeys/form.deliveryServiceSslKeys.tpl.html
 
b/traffic_portal/app/src/common/modules/form/deliveryServiceSslKeys/form.deliveryServiceSslKeys.tpl.html
index fd59128b30..fba753806f 100644
--- 
a/traffic_portal/app/src/common/modules/form/deliveryServiceSslKeys/form.deliveryServiceSslKeys.tpl.html
+++ 
b/traffic_portal/app/src/common/modules/form/deliveryServiceSslKeys/form.deliveryServiceSslKeys.tpl.html
@@ -139,9 +139,8 @@ under the License.
                         </div>
                     </div>
                     <div class="modal-footer">
-                        <button type="button" class="btn btn-success"
-                                ng-disabled="dsSslKeyForm.$pristine || 
dsSslKeyForm.$invalid" ng-click="save()">Update Keys
-                        </button>
+                        <button type="button" class="btn btn-danger" 
ng-show="sslKeys.version" ng-click="confirmDelete()">Delete</button>
+                        <button type="button" class="btn btn-success" 
ng-disabled="dsSslKeyForm.$pristine || dsSslKeyForm.$invalid" 
ng-click="save()">Update</button>
                     </div>
                 </form>
             </div>

Reply via email to