From f46cbade3147fd41e59e11c21b29aa21a230dc78 Mon Sep 17 00:00:00 2001 From: Jeremy Mitchell Date: Thu, 26 Dec 2019 15:04:35 -0700 Subject: [PATCH] removes the ability to create, update or delete an api endpoint from the api_capability table. Doing this depends on endpoints that are to be deprecated. --- traffic_portal/app/src/app.js | 5 -- .../app/src/common/api/EndpointService.js | 58 +-------------- .../form/endpoint/FormEndpointController.js | 53 -------------- .../edit/FormEditEndpointController.js | 72 ------------------- .../modules/form/endpoint/edit/index.js | 21 ------ .../form/endpoint/form.endpoint.tpl.html | 67 ----------------- .../src/common/modules/form/endpoint/index.js | 21 ------ .../endpoint/new/FormNewEndpointController.js | 39 ---------- .../common/modules/form/endpoint/new/index.js | 21 ------ .../endpoints/TableEndpointsController.js | 12 +--- .../table/endpoints/table.endpoints.tpl.html | 5 +- .../modules/private/endpoints/edit/index.js | 39 ---------- .../modules/private/endpoints/new/index.js | 39 ---------- 13 files changed, 6 insertions(+), 446 deletions(-) delete mode 100644 traffic_portal/app/src/common/modules/form/endpoint/FormEndpointController.js delete mode 100644 traffic_portal/app/src/common/modules/form/endpoint/edit/FormEditEndpointController.js delete mode 100644 traffic_portal/app/src/common/modules/form/endpoint/edit/index.js delete mode 100644 traffic_portal/app/src/common/modules/form/endpoint/form.endpoint.tpl.html delete mode 100644 traffic_portal/app/src/common/modules/form/endpoint/index.js delete mode 100644 traffic_portal/app/src/common/modules/form/endpoint/new/FormNewEndpointController.js delete mode 100644 traffic_portal/app/src/common/modules/form/endpoint/new/index.js delete mode 100644 traffic_portal/app/src/modules/private/endpoints/edit/index.js delete mode 100644 traffic_portal/app/src/modules/private/endpoints/new/index.js diff --git a/traffic_portal/app/src/app.js b/traffic_portal/app/src/app.js index faaa69c12e..b48674d70d 100644 --- a/traffic_portal/app/src/app.js +++ b/traffic_portal/app/src/app.js @@ -139,9 +139,7 @@ var trafficPortal = angular.module('trafficPortal', [ require('./modules/private/divisions/new').name, require('./modules/private/divisions/regions').name, require('./modules/private/endpoints').name, - require('./modules/private/endpoints/edit').name, require('./modules/private/endpoints/list').name, - require('./modules/private/endpoints/new').name, require('./modules/private/iso').name, require('./modules/private/jobs').name, require('./modules/private/jobs/list').name, @@ -289,9 +287,6 @@ var trafficPortal = angular.module('trafficPortal', [ require('./common/modules/form/division').name, require('./common/modules/form/division/edit').name, require('./common/modules/form/division/new').name, - require('./common/modules/form/endpoint').name, - require('./common/modules/form/endpoint/edit').name, - require('./common/modules/form/endpoint/new').name, require('./common/modules/form/federation').name, require('./common/modules/form/federation/edit').name, require('./common/modules/form/federation/new').name, diff --git a/traffic_portal/app/src/common/api/EndpointService.js b/traffic_portal/app/src/common/api/EndpointService.js index 73587dba22..27e3827be7 100644 --- a/traffic_portal/app/src/common/api/EndpointService.js +++ b/traffic_portal/app/src/common/api/EndpointService.js @@ -17,7 +17,7 @@ * under the License. */ -var EndpointService = function($http, ENV, locationUtils, messageModel) { +var EndpointService = function($http, ENV) { this.getEndpoints = function(queryParams) { return $http.get(ENV.api['root'] + 'api_capabilities', {params: queryParams}).then( @@ -30,61 +30,7 @@ var EndpointService = function($http, ENV, locationUtils, messageModel) { ); }; - this.getEndpoint = function(id) { - return $http.get(ENV.api['root'] + 'api_capabilities', {params: {id: id}}).then( - function (result) { - return result.data.response[0]; - }, - function (err) { - throw err; - } - ); - }; - - // todo: this functionality needs to be removed as the endpoint will be deprecated - this.createEndpoint = function(endpoint) { - return $http.post(ENV.api['root'] + 'api_capabilities', endpoint).then( - function(result) { - messageModel.setMessages([{level: 'success', text: 'Endpoint created'}], true); - locationUtils.navigateToPath('/endpoints'); - return result; - }, - function(err) { - messageModel.setMessages(err.data.alerts, false); - throw err; - } - ); - }; - - // todo: this functionality needs to be removed as the endpoint will be deprecated - this.updateEndpoint = function(endpoint) { - return $http.put(ENV.api['root'] + 'api_capabilities/' + endpoint.id, endpoint).then( - function(result) { - messageModel.setMessages([{level: 'success', text: 'Endpoint updated'}], false); - return result; - }, - function(err) { - messageModel.setMessages(err.data.alerts, false); - throw err; - } - ); - }; - - // todo: this functionality needs to be removed as the endpoint will be deprecated - this.deleteEndpoint = function(id) { - return $http.delete(ENV.api['root'] + 'api_capabilities/' + id).then( - function(result) { - messageModel.setMessages([{level: 'success', text: 'Endpoint deleted'}], true); - return result; - }, - function(err) { - messageModel.setMessages(err.data.alerts, true); - throw err; - } - ); - }; - }; -EndpointService.$inject = ['$http', 'ENV', 'locationUtils', 'messageModel']; +EndpointService.$inject = ['$http', 'ENV']; module.exports = EndpointService; diff --git a/traffic_portal/app/src/common/modules/form/endpoint/FormEndpointController.js b/traffic_portal/app/src/common/modules/form/endpoint/FormEndpointController.js deleted file mode 100644 index 11dcebb6ce..0000000000 --- a/traffic_portal/app/src/common/modules/form/endpoint/FormEndpointController.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var FormEndpointController = function(endpoint, $scope, formUtils, locationUtils, capabilityService) { - - var getCapabilities = function() { - capabilityService.getCapabilities({ orderby: 'name' }) - .then(function(result) { - $scope.capabilities = result; - }); - }; - - $scope.endpoint = endpoint; - - $scope.methods = [ - { value: 'GET', label: 'GET' }, - { value: 'POST', label: 'POST' }, - { value: 'PUT', label: 'PUT' }, - { value: 'PATCH', label: 'PATCH' }, - { value: 'DELETE', label: 'DELETE' } - ]; - - $scope.navigateToPath = locationUtils.navigateToPath; - - $scope.hasError = formUtils.hasError; - - $scope.hasPropertyError = formUtils.hasPropertyError; - - var init = function () { - getCapabilities(); - }; - init(); - -}; - -FormEndpointController.$inject = ['endpoint', '$scope', 'formUtils', 'locationUtils', 'capabilityService']; -module.exports = FormEndpointController; diff --git a/traffic_portal/app/src/common/modules/form/endpoint/edit/FormEditEndpointController.js b/traffic_portal/app/src/common/modules/form/endpoint/edit/FormEditEndpointController.js deleted file mode 100644 index 62bed82bfd..0000000000 --- a/traffic_portal/app/src/common/modules/form/endpoint/edit/FormEditEndpointController.js +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var FormEditEndpointController = function(endpoint, $scope, $controller, $uibModal, $anchorScroll, locationUtils, endpointService) { - - // extends the FormEndpointController to inherit common methods - angular.extend(this, $controller('FormEndpointController', { endpoint: endpoint, $scope: $scope })); - - var deleteEndpoint = function(endpoint) { - endpointService.deleteEndpoint(endpoint.id) - .then(function() { - locationUtils.navigateToPath('/endpoints'); - }); - }; - - $scope.endpointName = angular.copy(endpoint.httpMethod) + ' /api/*/' + angular.copy(endpoint.httpRoute); - - $scope.settings = { - isNew: false, - saveLabel: 'Update' - }; - - $scope.save = function(endpoint) { - endpointService.updateEndpoint(endpoint). - then(function() { - $scope.endpointName = angular.copy(endpoint.httpMethod) + ' ' + angular.copy(endpoint.httpRoute); - $anchorScroll(); // scrolls window to top - }); - }; - - $scope.confirmDelete = function(endpoint) { - var params = { - title: 'Delete Endpoint: ' + endpoint.httpMethod + ' ' + endpoint.httpRoute, - key: endpoint.httpMethod + ' ' + endpoint.httpRoute - }; - 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() { - deleteEndpoint(endpoint); - }, function () { - // do nothing - }); - }; - -}; - -FormEditEndpointController.$inject = ['endpoint', '$scope', '$controller', '$uibModal', '$anchorScroll', 'locationUtils', 'endpointService']; -module.exports = FormEditEndpointController; diff --git a/traffic_portal/app/src/common/modules/form/endpoint/edit/index.js b/traffic_portal/app/src/common/modules/form/endpoint/edit/index.js deleted file mode 100644 index 591cd41351..0000000000 --- a/traffic_portal/app/src/common/modules/form/endpoint/edit/index.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -module.exports = angular.module('trafficPortal.form.endpoint.edit', []) - .controller('FormEditEndpointController', require('./FormEditEndpointController')); diff --git a/traffic_portal/app/src/common/modules/form/endpoint/form.endpoint.tpl.html b/traffic_portal/app/src/common/modules/form/endpoint/form.endpoint.tpl.html deleted file mode 100644 index 78faab1aa6..0000000000 --- a/traffic_portal/app/src/common/modules/form/endpoint/form.endpoint.tpl.html +++ /dev/null @@ -1,67 +0,0 @@ - - -
-
- -
-
-
-
-
-
- -
- - Required -
-
-
- -
-
- /api/*/ - -
- Required - No spaces - -
-
-
- -
- - Required -
-
- -
-
-
diff --git a/traffic_portal/app/src/common/modules/form/endpoint/index.js b/traffic_portal/app/src/common/modules/form/endpoint/index.js deleted file mode 100644 index b35959088c..0000000000 --- a/traffic_portal/app/src/common/modules/form/endpoint/index.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -module.exports = angular.module('trafficPortal.form.endpoint', []) - .controller('FormEndpointController', require('./FormEndpointController')); diff --git a/traffic_portal/app/src/common/modules/form/endpoint/new/FormNewEndpointController.js b/traffic_portal/app/src/common/modules/form/endpoint/new/FormNewEndpointController.js deleted file mode 100644 index 8a7d56e89a..0000000000 --- a/traffic_portal/app/src/common/modules/form/endpoint/new/FormNewEndpointController.js +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var FormNewEndpointController = function(endpoint, $scope, $controller, endpointService) { - - // extends the FormEndpointController to inherit common methods - angular.extend(this, $controller('FormEndpointController', { endpoint: endpoint, $scope: $scope })); - - $scope.endpointName = 'New'; - - $scope.settings = { - isNew: true, - saveLabel: 'Create' - }; - - $scope.save = function(endpoint) { - endpointService.createEndpoint(endpoint); - }; - -}; - -FormNewEndpointController.$inject = ['endpoint', '$scope', '$controller', 'endpointService']; -module.exports = FormNewEndpointController; diff --git a/traffic_portal/app/src/common/modules/form/endpoint/new/index.js b/traffic_portal/app/src/common/modules/form/endpoint/new/index.js deleted file mode 100644 index 7d168d902f..0000000000 --- a/traffic_portal/app/src/common/modules/form/endpoint/new/index.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -module.exports = angular.module('trafficPortal.form.endpoint.new', []) - .controller('FormNewEndpointController', require('./FormNewEndpointController')); diff --git a/traffic_portal/app/src/common/modules/table/endpoints/TableEndpointsController.js b/traffic_portal/app/src/common/modules/table/endpoints/TableEndpointsController.js index 2f10760a4f..1a64074f1d 100644 --- a/traffic_portal/app/src/common/modules/table/endpoints/TableEndpointsController.js +++ b/traffic_portal/app/src/common/modules/table/endpoints/TableEndpointsController.js @@ -17,18 +17,10 @@ * under the License. */ -var TableEndpointsController = function(endpoints, $scope, $state, locationUtils) { +var TableEndpointsController = function(endpoints, $scope, $state) { $scope.endpoints = endpoints; - $scope.editEndpoint = function(id) { - locationUtils.navigateToPath('/endpoints/' + id); - }; - - $scope.createEndpoint = function() { - locationUtils.navigateToPath('/endpoints/new'); - }; - $scope.refresh = function() { $state.reload(); // reloads all the resolves for the view }; @@ -43,5 +35,5 @@ var TableEndpointsController = function(endpoints, $scope, $state, locationUtils }; -TableEndpointsController.$inject = ['endpoints', '$scope', '$state', 'locationUtils']; +TableEndpointsController.$inject = ['endpoints', '$scope', '$state']; module.exports = TableEndpointsController; diff --git a/traffic_portal/app/src/common/modules/table/endpoints/table.endpoints.tpl.html b/traffic_portal/app/src/common/modules/table/endpoints/table.endpoints.tpl.html index aa4b091a7c..a4f2ec07a4 100644 --- a/traffic_portal/app/src/common/modules/table/endpoints/table.endpoints.tpl.html +++ b/traffic_portal/app/src/common/modules/table/endpoints/table.endpoints.tpl.html @@ -22,8 +22,7 @@ -
- +
@@ -39,7 +38,7 @@ - + {{::e.httpMethod}} /api/*/{{::e.httpRoute}} {{::e.capability}} diff --git a/traffic_portal/app/src/modules/private/endpoints/edit/index.js b/traffic_portal/app/src/modules/private/endpoints/edit/index.js deleted file mode 100644 index 868dfab977..0000000000 --- a/traffic_portal/app/src/modules/private/endpoints/edit/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -module.exports = angular.module('trafficPortal.private.endpoints.edit', []) - .config(function($stateProvider, $urlRouterProvider) { - $stateProvider - .state('trafficPortal.private.endpoints.edit', { - url: '/{endpointId:[0-9]{1,8}}', - views: { - endpointsContent: { - templateUrl: 'common/modules/form/endpoint/form.endpoint.tpl.html', - controller: 'FormEditEndpointController', - resolve: { - endpoint: function($stateParams, endpointService) { - return endpointService.getEndpoint($stateParams.endpointId); - } - } - } - } - }) - ; - $urlRouterProvider.otherwise('/'); - }); diff --git a/traffic_portal/app/src/modules/private/endpoints/new/index.js b/traffic_portal/app/src/modules/private/endpoints/new/index.js deleted file mode 100644 index 89cf783fd4..0000000000 --- a/traffic_portal/app/src/modules/private/endpoints/new/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -module.exports = angular.module('trafficPortal.private.endpoints.new', []) - .config(function($stateProvider, $urlRouterProvider) { - $stateProvider - .state('trafficPortal.private.endpoints.new', { - url: '/new', - views: { - endpointsContent: { - templateUrl: 'common/modules/form/endpoint/form.endpoint.tpl.html', - controller: 'FormNewEndpointController', - resolve: { - endpoint: function() { - return {}; - } - } - } - } - }) - ; - $urlRouterProvider.otherwise('/'); - });