diff options
Diffstat (limited to 'dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter')
12 files changed, 1358 insertions, 0 deletions
diff --git a/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-client-list-controller.js b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-client-list-controller.js new file mode 100644 index 0000000..e6b11f8 --- /dev/null +++ b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-client-list-controller.js @@ -0,0 +1,154 @@ +/*- + * ================================================================================ + * DCAE DMaaP Bus Controller Web Application + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed 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. + * ================================================================================ + */ +app.controller('mrClientListCtrl', function($scope, $log, $modal, modalService, MRClientService){ + + // populates the table of Message Router clients + 'use strict'; + + // this object holds all app data and functions + $scope.dbcapp = {}; + // models for controls on screen + $scope.dbcapp.tableData=[]; + $scope.dbcapp.currentPageNum=1; + $scope.dbcapp.totalPages=1; + $scope.dbcapp.viewPerPage = 100; + $scope.dbcapp.viewPerPageOptions = [ + { index : 0, value : 100 }, + { index : 1, value : 500 }, + { index : 2, value : 1000 }, + { index : 3, value : 2500 } + ]; + // other + $scope.dbcapp.errMsg=null; + $scope.dbcapp.isDataLoading=true; + $scope.dbcapp.isRequestFailed=false; + + /** + * Answers an array of the specified size - makes Angular iteration easy. + */ + $scope.dbcapp.buildArraySizeN = function(num) { + // $log.debug("buildArraySizeN: invoked with " + num); + return new Array(num); + } + + /** + * Loads the table of message router clients. + */ + $scope.dbcapp.loadTable = function() { + $scope.dbcapp.isDataLoading = true; + MRClientService.getClientsByPage($scope.dbcapp.currentPageNum,$scope.dbcapp.viewPerPage) + .then(function(jsonObj){ + if (jsonObj.error) { + $scope.dbcapp.isRequestFailed = true; + $scope.dbcapp.errMsg = jsonObj.error; + $scope.dbcapp.tableData = []; + } + else { + $scope.dbcapp.isRequestFailed = false; + $scope.dbcapp.errMsg = null; + $scope.dbcapp.profileName = jsonObj.profileName; + $scope.dbcapp.dmaapName = jsonObj.dmaapName; + $scope.dbcapp.dcaeLocations = jsonObj.dcaeLocations; + $scope.dbcapp.totalPages = jsonObj.totalPages; + $scope.dbcapp.tableData = jsonObj.data; + } + $scope.dbcapp.isDataLoading=false; + },function(error){ + $log.error("mrClientListCtrl.loadTable failed: " + error); + $scope.dbcapp.isRequestFailed = true; + $scope.dbcapp.errMsg = error; + $scope.dbcapp.tableData = []; + $scope.dbcapp.isDataLoading = false; + }); + }; + + /** + * Shows a modal pop-up to edit a client. + * Passes data in via an object named "message". + * Always updates the table, even on failure, to discard + * user-entered changes that were not persisted. + */ + $scope.dbcapp.editClientModalPopup = function(client) { + $scope.dbcapp.editClient = client; + var modalInstance = $modal.open({ + templateUrl : 'edit_client_popup.html', + controller : 'clientPopupCtrl', + resolve : { + message : function() { + var dataForPopup = { + client : $scope.dbcapp.editClient, + clientList : $scope.dbcapp.tableData, + dcaeList : $scope.dbcapp.dcaeLocations + }; + return dataForPopup; + } + } + }); + modalInstance.result.then(function(response) { + if (response == null) { + // $log.debug('editClientModalPopup: user closed dialog'); + } + else { + // $log.debug('editClientModalPopup: response: ' + JSON.stringify(response)); + if (response.error != null) + modalService.showFailure('Edit Failed', + 'Failed to edit client:\n' + response.error); + // refresh in all cases + $scope.dbcapp.loadTable(); + } + }); + }; + + /** + * Shows a modal pop-up to confirm deletion of a client. + * On successful completion, updates the table. + */ + $scope.dbcapp.deleteClientModalPopup = function(client) { + modalService.popupConfirmWin("Confirm", + "Delete the client:\n" + client.mrClientId + "\nContinue?", + function() { + // $log.debug('deleteClientModalPopup: ' + topic.fqtn); + MRClientService.deleteClient(client.mrClientId) + .then( + function(response) { + // $log.debug('deleteClientModalPopup: response: ' + JSON.stringify(response)); + if (response.error != null) { + modalService.showFailure('Delete Failed', + 'Failed to delete client ' + client.mrClientId + + '\n' + response.error); + } + else { + // success, get the updated list. + $scope.dbcapp.loadTable() + } + }, + function(error) { + modalService.showFailure('Delete Failed', + 'Request failed to delete client ' + client.mrClientId + '\n' + + JSON.stringify(error)); + } + ); + }) + }; + + // Populate the table on load. + $scope.dbcapp.loadTable(); + +}); diff --git a/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-client-popup-controller.js b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-client-popup-controller.js new file mode 100644 index 0000000..d4bb40b --- /dev/null +++ b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-client-popup-controller.js @@ -0,0 +1,127 @@ +/*- + * ================================================================================ + * DCAE DMaaP Bus Controller Web Application + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed 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. + * ================================================================================ + */ +app.controller('clientPopupCtrl', function($scope, $log, $modalInstance, modalService, message, MRClientService) { + + 'use strict'; + + // this object holds all app data and functions + $scope.dbcapp = {}; + + // Set the label variable for the template + if (message.client == null || message.client.mrClientId == null) + $scope.dbcapp.label = 'Add Client'; + else + $scope.dbcapp.label = 'Edit Client'; + + // client object brings fqtn + $scope.dbcapp.editClient = message.client; + $scope.dbcapp.dcaeList = message.dcaeList; + + // Models for checkboxes + var PUB = 0; + var SUB = 1; + var VIEW = 2; + $scope.dbcapp.clientactionbox = []; + $scope.dbcapp.clientactionbox[PUB] = false; + $scope.dbcapp.clientactionbox[SUB] = false; + $scope.dbcapp.clientactionbox[VIEW] = false; + + // Morph the list of action strings into checks in boxes + for (var aidx in $scope.dbcapp.editClient.action) { + var action = $scope.dbcapp.editClient.action[aidx]; + // $log.debug('clientPopupCtrl: action idx ' + aidx + ', action ' + action); + if ("pub" == action) + $scope.dbcapp.clientactionbox[PUB] = true; + else if ("sub" == action) + $scope.dbcapp.clientactionbox[SUB] = true; + else if ("view" == action) + $scope.dbcapp.clientactionbox[VIEW] = true; + } + + /** + * Validates content of user-editable fields. + * Returns null if all is well, + * a descriptive error message otherwise. + */ + $scope.dbcapp.validateClient = function(client) { + if (client == null) + return "No data found.\nPlease enter some values."; + if (client.dcaeLocationName == null) + return "DCAE Location is required.\nPlease select a value."; + if (client.clientRole == null || client.clientRole.trim() == '') + return "Client role is required.\nPlease enter a value."; + // I don't like hardcoded strings, but what to do? + // IE does not support startsWith method + // $log.debug('validateClient: ' + client.clientRole.indexOf('com.openecomp.')); + if (client.clientRole.toLowerCase().indexOf('com.openecomp.') != 0) + return "Unexpected client role prefix.\nPlease enter a value starting with 'com.openecomp.'"; + if (client.action.length == 0) + return "An action is required.\nPlease select one or more actions."; + return null; + } + + $scope.dbcapp.saveClient = function(client) { + // Store list of action strings (if any) + var action_list = []; + for (var aidx in $scope.dbcapp.clientactionbox) { + if (aidx == PUB && $scope.dbcapp.clientactionbox[aidx]) + action_list.push('pub'); + else if (aidx == SUB && $scope.dbcapp.clientactionbox[aidx]) + action_list.push('sub'); + else if (aidx == VIEW && $scope.dbcapp.clientactionbox[aidx]) + action_list.push('view'); + } + $scope.dbcapp.editClient.action = action_list; + + var validateMsg = $scope.dbcapp.validateClient(client); + if (validateMsg != null) { + modalService.showFailure("Invalid Content", validateMsg); + return; + } + + if (client.mrClientId == null) { + // No id, so create a new one + MRClientService.addClient(client) + .then(function(response) { + $modalInstance.close(response); + }, + function (error) { + $log.error('clientPopupCtrl.saveClient: error while adding: ' + error); + } + ); + } + else { + // Has ID, so update an existing one + MRClientService.updateClient(client) + .then(function(response) { + $modalInstance.close(response); + }, + function (error) { + $log.error('clientPopupCtrl.saveClient: error while updating: ' + error); + } + ); + } + + }; // saveClient + + $scope.dbcapp.close = function() { + $modalInstance.close(); + }; +}); diff --git a/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-client-service.js b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-client-service.js new file mode 100644 index 0000000..f5f8167 --- /dev/null +++ b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-client-service.js @@ -0,0 +1,105 @@ +/*- + * ================================================================================ + * DCAE DMaaP Bus Controller Web Application + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed 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. + * ================================================================================ + */ +app.factory('MRClientService', function ($http, $q, $log) { + return { + /** + * Gets one page of message router client objects. + * @param {Number} pageNum - page number; e.g., 1 + * @param {Number} viewPerPage - number of items per page; e.g., 25 + * @return {JSON} Response object from remote side + */ + getClientsByPage: function(pageNum,viewPerPage) { + // cache control for IE + var cc = "&cc=" + new Date().getTime().toString(); + return $http({ + method: 'GET', + url: 'mr_client?pageNum=' + pageNum + '&viewPerPage=' + viewPerPage + cc, + cache: false, + responseType: 'json' }) + .then(function(response) { + if (response.data == null || typeof response.data != 'object') + return $q.reject('MRClientService.getClientsByPage: response.data null or not object'); + else + return response.data; + }, + function(error) { + $log.error('MRClientService.getClientsByPage failed: ' + error); + return $q.reject(error.data); + }); + }, + + // Creates a new client. + addClient: function(client) { + return $http({ + method: 'POST', + url: 'mr_client', + data: client, + responseType: 'json' }) + .then(function(response) { + if (response.data == null || typeof response.data != 'object') + return $q.reject('MRClientService.addClient: response.data null or not object'); + else + return response.data; + }, + function(error) { + $log.error('MRClientService.addClient failed: ' + error); + return $q.reject(error.data); + }); + }, + + // Updates an existing client. + updateClient: function(client) { + return $http({ + method: 'PUT', + url: 'mr_client/' + client.mrClientId, + data: client, + responseType: 'json' }) + .then(function(response) { + if (response.data == null || typeof response.data != 'object') + return $q.reject('MRClientService.updateClient: response.data null or not object'); + else + return response.data; + }, + function(error) { + $log.error('MRClientService.updateClient failed: ' + JSON.stringify(error)); + return $q.reject(error.data); + }); + }, + + // Deletes the client with the specified ID + deleteClient: function(mrClientId) { + return $http({ + method: 'DELETE', + url: 'mr_client/' + mrClientId, + responseType: 'json' }) + .then(function(response) { + if (response.data == null || typeof response.data != 'object') + return $q.reject('MRClientService.deleteClient: response.data null or not object'); + else + return response.data; + }, + function(error) { + $log.error('MRClientService.deleteClient failed: ' + error); + return $q.reject(error.data); + }); + }, + + }; +}); diff --git a/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-topic-client-list-popup-controller.js b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-topic-client-list-popup-controller.js new file mode 100644 index 0000000..4546ac9 --- /dev/null +++ b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-topic-client-list-popup-controller.js @@ -0,0 +1,36 @@ +/*- + * ================================================================================ + * DCAE DMaaP Bus Controller Web Application + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed 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. + * ================================================================================ + */ +app.controller('topicClientListPopupCtrl', function($scope, $log, $modalInstance, modalService, message) { + + 'use strict'; + + // this object holds all app data and functions + $scope.dbcapp = {}; + + // Set the label variable for the template + $scope.dbcapp.label = 'Clients of Topic ' + message.topic.topicName; + + // Source of data table + $scope.dbcapp.showTopic = message.topic; + + $scope.dbcapp.close = function() { + $modalInstance.close(); + }; +}); diff --git a/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-topic-list-controller.js b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-topic-list-controller.js new file mode 100644 index 0000000..46e1951 --- /dev/null +++ b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-topic-list-controller.js @@ -0,0 +1,248 @@ +/*- + * ================================================================================ + * DCAE DMaaP Bus Controller Web Application + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed 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. + * ================================================================================ + */ +app.controller('mrTopicListCtrl', function($scope, $log, $modal, modalService, MRTopicService){ + + // populates the table of Message Router topics + 'use strict'; + + // this object holds all app data and functions + $scope.dbcapp = {}; + // models for controls on screen + $scope.dbcapp.tableData=[]; + $scope.dbcapp.currentPageNum=1; + $scope.dbcapp.totalPages=1; + $scope.dbcapp.viewPerPage = 100; + $scope.dbcapp.viewPerPageOptions = [ + { index : 0, value : 100 }, + { index : 1, value : 500 }, + { index : 2, value : 1000 }, + { index : 3, value : 2500 } + ]; + // other + $scope.dbcapp.errMsg=null; + $scope.dbcapp.isDataLoading=true; + $scope.dbcapp.isRequestFailed=false; + + /** + * Answers an array of the specified size - makes Angular iteration easy. + */ + $scope.dbcapp.buildArraySizeN = function(num) { + // $log.debug("buildArraySizeN: invoked with " + num); + return new Array(num); + } + + /** + * Loads the table of message router topics. + */ + $scope.dbcapp.loadTable = function() { + $scope.dbcapp.isDataLoading = true; + MRTopicService.getTopicsByPage($scope.dbcapp.currentPageNum, $scope.dbcapp.viewPerPage) + .then(function(jsonObj){ + // must match keys in java controller's method + if (jsonObj.error) { + $scope.dbcapp.isRequestFailed = true; + $scope.dbcapp.errMsg = jsonObj.error; + $scope.dbcapp.tableData = []; + } + else { + $scope.dbcapp.isRequestFailed = false; + $scope.dbcapp.errMsg = null; + $scope.dbcapp.profileName = jsonObj.profileName; + $scope.dbcapp.dmaapName = jsonObj.dmaapName; + $scope.dbcapp.dcaeLocations = jsonObj.dcaeLocations; + $scope.dbcapp.totalPages = jsonObj.totalPages; + $scope.dbcapp.tableData = jsonObj.data; + } + $scope.dbcapp.isDataLoading=false; + },function(error){ + $log.error("mrTopicListCtrl.loadTable failed: " + error); + $scope.dbcapp.isRequestFailed = true; + $scope.dbcapp.errMsg = error; + $scope.dbcapp.tableData = []; + $scope.dbcapp.isDataLoading = false; + }); + }; + + /** + * Shows a modal pop-up to add a topic. Passes data in via an object named + * "message". On successful completion, updates the table. + */ + $scope.dbcapp.addTopicModalPopup = function() { + $scope.dbcapp.editTopic = null; + var modalInstance = $modal.open({ + templateUrl : 'edit_topic_popup.html', + controller : 'topicPopupCtrl', + resolve : { + message : function() { + var dataForPopup = { + topic : $scope.dbcapp.editTopic, + topicList : $scope.dbcapp.tableData + }; + return dataForPopup; + } + } + }); + modalInstance.result.then(function(response) { + if (response == null) { + // $log.debug('addFeedModalPopup: user closed dialog'); + } + else { + if (response.error != null) + modalService.showFailure('Add Failed', + 'Failed to add topic:\n' + response.error); + else + // success, get the updated list. + $scope.dbcapp.loadTable(); + } + }); + }; + + /** + * Shows a modal pop-up to edit a topic. + * Passes data in via an object named "message". + * Always updates the table, even on failure, to discard + * user-entered changes that were not persisted. + */ + $scope.dbcapp.editTopicModalPopup = function(topic) { + $scope.dbcapp.editTopic = topic; + var modalInstance = $modal.open({ + templateUrl : 'edit_topic_popup.html', + controller : 'topicPopupCtrl', + resolve : { + message : function() { + var dataForPopup = { + topic : $scope.dbcapp.editTopic, + topicList : $scope.dbcapp.tableData + }; + return dataForPopup; + } + } + }); + modalInstance.result.then(function(response) { + if (response == null) { + // $log.debug('editTopicModalPopup: user closed dialog'); + } + else { + // $log.debug('editTopicModalPopup: response: ' + JSON.stringify(response)); + if (response.error != null) + modalService.showFailure('Edit Failed', + 'Failed to edit topic ' + topic.fqtn + + '\n' + response.error); + // refresh in all cases + $scope.dbcapp.loadTable(); + } + }); + }; + + /** + * Shows a modal pop-up to confirm deletion of a topic. On successful + * completion, updates the table. + */ + $scope.dbcapp.deleteTopicModalPopup = function(topic) { + modalService.popupConfirmWin("Confirm", + "Delete the topic:\n" + topic.fqtn + "\nContinue?", + function() { + // $log.debug('deleteTopicModalPopup: ' + topic.fqtn); + MRTopicService.deleteTopic(topic.fqtn) + .then( + function(response) { + // $log.debug('deleteTopicModalPopup: response: ' + JSON.stringify(response)); + if (response.error != null) { + $log.error('deleteTopicModalPopup: failed to delete: ' + response.error); + modalService.showFailure('Delete Failed', + 'Failed to delete topic ' + topic.fqtn + + '\n' + response.error); + } + else { + // success, get the updated list. + $scope.dbcapp.loadTable() + } + }, + function(error) { + modalService.showFailure('Delete Failed', + 'Request failed to delete topic ' + topic.fqtn + '\n' + + JSON.stringify(error)); + } + ); + }) + }; + + /** + * Shows a modal pop-up with all clients of a topic. + * Passes data in via an object named "message". + */ + $scope.dbcapp.showTopicClientsModalPopup = function(topic) { + var modalInstance = $modal.open({ + templateUrl : 'topic_client_list_popup.html', + controller : 'topicClientListPopupCtrl', + resolve : { + message : function() { + var dataForPopup = { + topic : topic + }; + return dataForPopup; + } + } + }); + modalInstance.result.then(function(response) { + // No response expected. + }); + }; + + /** + * Shows a modal pop-up to add a client to a topic + * Passes data in via an object named "message". + * On successful completion, updates the table. + */ + $scope.dbcapp.addTopicClientModalPopup = function(topic) { + $scope.dbcapp.editClient = { fqtn : topic.fqtn } + var modalInstance = $modal.open({ + templateUrl : 'edit_client_popup.html', + controller : 'clientPopupCtrl', + resolve : { + message : function() { + var dataForPopup = { + client : $scope.dbcapp.editClient, + clientList : [], // empty list + dcaeList : $scope.dbcapp.dcaeLocations + }; + return dataForPopup; + } + } + }); + modalInstance.result.then(function(response) { + if (response == null) { + // $log.debug('addTopicClientModalPopup: user closed dialog'); + } + else { + if (response.error != null) + modalService.showFailure('Add Client Failed', + 'Failed to add client to topic:\n' + response.error); + else + // success, get the updated list. + $scope.dbcapp.loadTable(); + } + }); + }; + + // Populate the table on load. + $scope.dbcapp.loadTable(); + +}); diff --git a/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-topic-popup-controller.js b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-topic-popup-controller.js new file mode 100644 index 0000000..4d885c5 --- /dev/null +++ b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-topic-popup-controller.js @@ -0,0 +1,83 @@ +/*- + * ================================================================================ + * DCAE DMaaP Bus Controller Web Application + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed 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. + * ================================================================================ + */ +app.controller('topicPopupCtrl', function($scope, $log, $modalInstance, modalService, message, MRTopicService) { + 'use strict'; + + // this object holds all app data and functions + $scope.dbcapp = {}; + + // Set the label variable for the template + if (message.topic == null) + $scope.dbcapp.label = 'Add Topic'; + else + $scope.dbcapp.label = 'Edit Topic'; + $scope.dbcapp.editTopic = message.topic; + + /** + * Validates content of user-editable fields. + * Returns null if all is well, + * a descriptive error message otherwise. + */ + $scope.dbcapp.validateTopic = function(topic) { + if (topic == null) + return "No data found.\nPlease enter some values."; + if (topic.topicName == null || topic.topicName.trim() == '') + return "Name is required.\nPlease enter a value."; + if (topic.topicDescription == null || topic.topicDescription.trim() == '') + return "Description is required.\nPlease enter a value."; + return null; + } + + $scope.dbcapp.saveTopic = function(topic) { + var validateMsg = $scope.dbcapp.validateTopic(topic); + if (validateMsg != null) { + modalService.showFailure("Invalid Content", validateMsg); + return; + } + + if (topic.fqtn == null) { + // No fqtn, so create a new one + MRTopicService.addTopic(topic) + .then(function(response) { + $modalInstance.close(response); + }, + function (error) { + $log.error('topicPopupCtrl.saveTopic: error while adding: ' + error); + } + ); + } + else { + // Has fqtn, so update an existing one + MRTopicService.updateTopic(topic) + .then(function(response) { + $modalInstance.close(response); + }, + function (error) { + $log.error('topicPopupCtrl.saveTopic: error while updating: ' + error); + } + ); + } + + }; // saveTopic + + $scope.dbcapp.close = function() { + $modalInstance.close(); + }; +}); diff --git a/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-topic-service.js b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-topic-service.js new file mode 100644 index 0000000..49642f7 --- /dev/null +++ b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr-topic-service.js @@ -0,0 +1,105 @@ +/*- + * ================================================================================ + * DCAE DMaaP Bus Controller Web Application + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed 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. + * ================================================================================ + */ +app.factory('MRTopicService', function ($http, $q, $log) { + return { + /** + * Gets one page of message router topic objects. + * @param {Number} pageNum - page number; e.g., 1 + * @param {Number} viewPerPage - number of items per page; e.g., 25 + * @return {JSON} Response object from remote side + */ + getTopicsByPage: function(pageNum,viewPerPage) { + // cache control for IE + var cc = "&cc=" + new Date().getTime().toString(); + return $http({ + method: 'GET', + url: 'mr_topic?pageNum=' + pageNum + '&viewPerPage=' + viewPerPage + cc, + cache: false, + responseType: 'json' }) + .then(function(response) { + if (response.data == null || typeof response.data != 'object') + return $q.reject('MRTopicService.getTopicsByPage: response.data null or not object'); + else + return response.data; + }, + function(error) { + $log.error('MRTopicService.getTopicsByPage failed: ' + JSON.stringify(error)); + return $q.reject(error.data); + }); + }, + + // Creates a new topic. + addTopic: function(topic) { + return $http({ + method: 'POST', + url: 'mr_topic', + data: topic, + responseType: 'json' }) + .then(function(response) { + if (response.data == null || typeof response.data != 'object') + return $q.reject('MRTopicService.addTopic: response.data null or not object'); + else + return response.data; + }, + function(error) { + $log.error('MRTopicService.addTopic failed: ' + JSON.stringify(error)); + return $q.reject(error.data); + }); + }, + + // Updates an existing topic. + updateTopic: function(topic) { + return $http({ + method: 'PUT', + url: 'mr_topic/' + topic.fqtn, + data: topic, + responseType: 'json' }) + .then(function(response) { + if (response.data == null || typeof response.data != 'object') + return $q.reject('MRTopicService.updateTopic: response.data null or not object'); + else + return response.data; + }, + function(error) { + $log.error('MRTopicService.updateTopic failed: ' + JSON.stringify(error)); + return $q.reject(error.data); + }); + }, + + // Deletes the topic with the specified FQTN. + deleteTopic: function(fqtn) { + return $http({ + method: 'DELETE', + url: 'mr_topic/' + fqtn, + responseType: 'json' }) + .then(function(response) { + if (response.data == null || typeof response.data != 'object') + return $q.reject('MRTopicService.deleteTopic: response.data null or not object'); + else + return response.data; + }, + function(error) { + $log.error('MRTopicService.deleteTopic failed: ' + JSON.stringify(error)); + return $q.reject(error.data); + }); + }, + + }; +}); diff --git a/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr_client_list.html b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr_client_list.html new file mode 100644 index 0000000..1dac153 --- /dev/null +++ b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr_client_list.html @@ -0,0 +1,142 @@ +<!-- + ================================================================================ + DCAE DMaaP Bus Controller Web Application + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property + ================================================================================ + Licensed 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. + ================================================================================ + --> +<!-- controller is specified by route provider --> + +<div class="pageTitle"> + <h3 class="heading3" style="margin-top: 10px; margin-bottom: 10px;">Topic Clients</h3> +</div> + +<div id="button-search-row"> + <!-- NO "add" button on this page --> + <div style="float:right;"> + <div class="form-field form-field__small"> + <input class="fn-ebz-text.search" + type="text" + placeholder="Search clients" + ng-model="dbcapp.searchString"/> + <i class="ion-search" style="position:relative;line-height:10px;top:-25px;right:-190px"></i> + </div> + </div> + </div> + +<!-- show progress indicator --> +<div ng-show="dbcapp.isDataLoading"> + <div att-loading></div> +</div> + +<div ng-hide="dbcapp.isDataLoading"> + + <div ng-show="dbcapp.isRequestFailed"> + <span class="errorMessageText">{{dbcapp.errMsg}}</span> + </div> + + <div ng-hide="dbcapp.isRequestFailed"> + Access Profile <strong>{{dbcapp.profileName}}</strong>, DMaaP Name <strong>{{dbcapp.dmaapName}}</strong> + </div> + + <table att-table + id="clients-table" + table-data="dbcapp.tableData" + search-string="dbcapp.searchString" + view-per-page="dbcapp.viewPerPageIgnored" + current-page="dbcapp.currentPageIgnored" + total-page="dbcapp.totalPageIgnored"> + + <thead att-table-row type="header"> + <tr> + <th att-table-header sortable="true" key="mrClientId">MR Client ID</th> + <th att-table-header sortable="true" key="dcaeLocationName">DCAE Location Name</th> + <th att-table-header sortable="true" key="fqtn">Qualified Topic Name</th> + <th att-table-header sortable="true" key="action">Action</th> + <th att-table-header sortable="true" key="clientRole">Client Role</th> + <th att-table-header sortable="true" key="lastMod">Last Modified</th> + <th att-table-header sortable="true" key="status">Status</th> + <th att-table-header sortable="true" key="topicURL">Topic URL</th> + <th att-table-header sortable="false">Delete</th> + </tr> + </thead> + <tbody att-table-row type="body" row-repeat="rowData in dbcapp.tableData"> + <tr> + <td att-table-body + ng-bind="rowData.mrClientId" + ng-click="dbcapp.editClientModalPopup(rowData)"/> + <td att-table-body + ng-bind="rowData.dcaeLocationName" + ng-click="dbcapp.editClientModalPopup(rowData)"/> + <td att-table-body + ng-bind="rowData.fqtn" + ng-click="dbcapp.editClientModalPopup(rowData)"/> + <td att-table-body + ng-bind="rowData.action" + ng-click="dbcapp.editClientModalPopup(rowData)"/> + <td att-table-body + ng-bind="rowData.clientRole" + ng-click="dbcapp.editClientModalPopup(rowData)"/> + <td att-table-body + ng-bind="rowData.lastMod" + ng-click="dbcapp.editClientModalPopup(rowData)"/> + <td att-table-body + ng-bind="rowData.status" + ng-click="dbcapp.editClientModalPopup(rowData)"/> + <td att-table-body + ng-bind="rowData.topicURL" + ng-click="dbcapp.editClientModalPopup(rowData)"/> + <td att-table-body> + <div ng-click="dbcapp.deleteClientModalPopup(rowData);" style="font-size:20px;"> + <a href="" class="ion-trash-b"></a> + </div> + </td> + </tr> + </tbody> + </table> + + <div class="fn-ebz-container" > + Page Number: + <select class="fn-ebz-select dbcpageselect" + name="currentPageNumSelector" + ng-model="dbcapp.currentPageNum" + ng-change="dbcapp.loadTable()"> + <option ng-repeat="p in dbcapp.buildArraySizeN(dbcapp.totalPages) track by $index" + value="{{$index+1}}" + ng-selected="{{$index+1}}=={{dbcapp.currentPageNum}}"> + {{$index+1}} + </option> + </select> + Page Count: + <input class="fn-ebz-text dbcpagenum" + type="text" + ng-model="dbcapp.totalPages" + readonly="true"> + Rows per Page: + <select class="fn-ebz-select dbcpageselect" + name="viewPerPageSelector" + ng-model="dbcapp.viewPerPage" + ng-change="dbcapp.loadTable()" + style="height: 30px;"> + <option ng-repeat="v in dbcapp.viewPerPageOptions" + value="{{v.value}}" + ng-selected="{{v.value}}=={{dbcapp.viewPerPage}}"> + {{v.value}} + </option> + </select> + </div> + +</div> +<!-- loading --> diff --git a/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr_client_popup_template.html b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr_client_popup_template.html new file mode 100644 index 0000000..8f45073 --- /dev/null +++ b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr_client_popup_template.html @@ -0,0 +1,68 @@ +<!-- + ================================================================================ + DCAE DMaaP Bus Controller Web Application + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property + ================================================================================ + Licensed 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. + ================================================================================ + --> +<script type="text/ng-template" id="edit_client_popup.html"> + <div class="modal__informative font-showcase" style="width:400px;"> + <div class="modal__header"> + <h2 class="font-showcase-font-name" style="width: 500px;">{{dbcapp.label}}</h2> + </div> + <div class="divider-container"> + <hr> + </div> + <div class="modal__content"> + <div class="fn-ebz-container"> + DCAE Location:<sup><b>*</b></sup> + <br/> + <select class="fn-ebz-select dbcselect" ng-model="dbcapp.editClient.dcaeLocationName" ng-options="d for d in dbcapp.dcaeList"></select> + </div> + <br/> + <div class="fn-ebz-container" > + Client Role:<sup><b>*</b></sup> + <br/> + <input type="text" class="fn-ebz-text" ng-model="dbcapp.editClient.clientRole" /> + </div> + <br/> + <div class="fn-ebz-container" > + Action:<sup><b>*</b></sup> + <br/> + <span style="padding-left: 15px;"> Pub</span> + <input name="pub" type="checkbox" att-checkbox ng-model="dbcapp.clientactionbox[0]" /> + + <span style="padding-left: 15px;"> Sub</span> + <input name="sub" type="checkbox" att-checkbox ng-model="dbcapp.clientactionbox[1]" /> + + <span style="padding-left: 15px;"> View</span> + <input name="view" type="checkbox" att-checkbox ng-model="dbcapp.clientactionbox[2]" /> + </div> + </div> + + <div class="modal__footer"> + <button class="button button--primary button--small" + href="javascript:void(0)" + ng-click="dbcapp.saveClient(dbcapp.editClient);"> + Save + </button> + <button class="button button--primary button--small" + href="javascript:void(0)" + ng-click="dbcapp.close()"> + Close + </button> + </div> + </div> +</script> diff --git a/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr_topic_client_list_popup_template.html b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr_topic_client_list_popup_template.html new file mode 100644 index 0000000..4976138 --- /dev/null +++ b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr_topic_client_list_popup_template.html @@ -0,0 +1,74 @@ +<!-- + ================================================================================ + DCAE DMaaP Bus Controller Web Application + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property + ================================================================================ + Licensed 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. + ================================================================================ + --> +<script type="text/ng-template" id="topic_client_list_popup.html"> + <div class="modal__informative font-showcase" style="width:900px;"> + + <div class="modal__header"> + <h2 class="font-showcase-font-name" style="width: 900px;">{{dbcapp.label}}</h2> + </div> + <div class="divider-container"> + <hr> + </div> + <div class="modal__content"> + <div class="fn-ebz-container"> + + <table att-table + id="clients-table" + table-data="dbcapp.showTopic.clients" + search-string="dbcapp.searchString" + view-per-page="dbcapp.viewPerPageIgnored" + current-page="dbcapp.currentPageIgnored" + total-page="dbcapp.totalPageIgnored"> + + <thead att-table-row type="header"> + <tr> + <th att-table-header sortable="false">MR Client ID</th> + <th att-table-header sortable="false">DCAE Location Name</th> + <th att-table-header sortable="false">Action</th> + <th att-table-header sortable="false">Client Role</th> + <th att-table-header sortable="false">Last Modified</th> + <th att-table-header sortable="false">Status</th> + </tr> + </thead> + <tbody att-table-row type="body" row-repeat="rowData in dbcapp.showTopic.clients"> + <tr> + <td att-table-body ng-bind="rowData.mrClientId" /> + <td att-table-body ng-bind="rowData.dcaeLocationName" /> + <td att-table-body ng-bind="rowData.action"/> + <td att-table-body ng-bind="rowData.clientRole"/> + <td att-table-body ng-bind="rowData.lastMod" /> + <td att-table-body ng-bind="rowData.status" /> + </tr> + </tbody> + </table> + + </div> + + <div class="modal__footer"> + <button class="button button--primary button--small" + href="javascript:void(0)" + ng-click="dbcapp.close()"> + Close + </button> + </div> + + </div> + +</script> diff --git a/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr_topic_list.html b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr_topic_list.html new file mode 100644 index 0000000..4ed4726 --- /dev/null +++ b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr_topic_list.html @@ -0,0 +1,154 @@ +<!-- + ================================================================================ + DCAE DMaaP Bus Controller Web Application + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property + ================================================================================ + Licensed 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. + ================================================================================ + --> +<!-- controller is specified by route provider --> + +<div class="pageTitle"> + <h3 class="heading3" style="margin-top: 10px; margin-bottom: 10px;">Message Router Topics</h3> +</div> + +<div id="button-search-row"> + <button att-button + type="submit" + ng-click="dbcapp.addTopicModalPopup();" + btn-type="primary" + size="small"> + Add Topic... + </button> + <div style="float:right;"> + <div class="form-field form-field__small"> + <input class="fn-ebz-text.search" + type="text" + placeholder="Search topics" + ng-model="dbcapp.searchString"/> + <i class="ion-search" style="position:relative;line-height:10px;top:-25px;right:-190px"></i> + </div> + </div> + </div> + +<!-- show progress indicator --> +<div ng-show="dbcapp.isDataLoading"> + <div att-loading></div> +</div> + +<div ng-hide="dbcapp.isDataLoading"> + + <div ng-show="dbcapp.isRequestFailed"> + <span class="errorMessageText">{{dbcapp.errMsg}}</span> + </div> + + <div ng-hide="dbcapp.isRequestFailed"> + Access Profile <strong>{{dbcapp.profileName}}</strong>, DMaaP Name <strong>{{dbcapp.dmaapName}}</strong> + </div> + + <table att-table + id="topics-table" + table-data="dbcapp.tableData" + search-string="dbcapp.searchString" + view-per-page="dbcapp.viewPerPageIgnored" + current-page="dbcapp.currentPageIgnored" + total-page="dbcapp.totalPageIgnored"> + + <thead att-table-row type="header"> + <tr> + <th att-table-header sortable="true" key="fqtn">Qualified Name</th> + <th att-table-header sortable="true" key="topicName">Name</th> + <th att-table-header sortable="true" key="topicDescription">Description</th> + <!-- model differs from swagger + <th att-table-header sortable="true" key="tnxEnabled">Tnx</th> + --> + <th att-table-header sortable="true" key="owner">Owner</th> + <th att-table-header sortable="true" key="status">Status</th> + <th att-table-header sortable="false">Cl</th> + <th att-table-header sortable="false">Add</th> + <th att-table-header sortable="false">Delete</th> + </tr> + </thead> + <tbody att-table-row type="body" row-repeat="rowData in dbcapp.tableData"> + <tr> + <td att-table-body + ng-bind="rowData.fqtn"/> + <td att-table-body + ng-bind="rowData.topicName"/> + <td att-table-body + ng-bind="rowData.topicDescription"/> + <!-- model differs from swagger + <td att-table-body + ng-click="dbcapp.editTopicModalPopup(rowData)"/> + <input type="checkbox" att-checkbox + disabled="true" + ng-model="rowData.tnxEnabled" + ng-checked="rowData.tnxEnabled" + value="rowData.tnxEnabled"/> + --> + <td att-table-body + ng-bind="rowData.owner"/> + <td att-table-body + ng-bind="rowData.status"/> + <td att-table-body + ng-bind="rowData.clients.length" + ng-click="dbcapp.showTopicClientsModalPopup(rowData)"> + </td> + <td att-table-body> + <div ng-click="dbcapp.addTopicClientModalPopup(rowData);" style="font-size:20px;"> + <a href="" class="ion-plus"></a> + </div> + </td> + <td att-table-body> + <div ng-click="dbcapp.deleteTopicModalPopup(rowData);" style="font-size:20px;"> + <a href="" class="ion-trash-b"></a> + </div> + </td> + </tr> + </tbody> + </table> + + <div class="fn-ebz-container" > + Page Number: + <select class="fn-ebz-select dbcpageselect" + name="currentPageNumSelector" + ng-model="dbcapp.currentPageNum" + ng-change="dbcapp.loadTable()"> + <option ng-repeat="p in dbcapp.buildArraySizeN(dbcapp.totalPages) track by $index" + value="{{$index+1}}" + ng-selected="{{$index+1}}=={{dbcapp.currentPageNum}}"> + {{$index+1}} + </option> + </select> + Page Count: + <input class="fn-ebz-text dbcpagenum" + type="text" + ng-model="dbcapp.totalPages" + readonly="true"> + Rows per Page: + <select class="fn-ebz-select dbcpageselect" + name="viewPerPageSelector" + ng-model="dbcapp.viewPerPage" + ng-change="dbcapp.loadTable()" + style="height: 30px;"> + <option ng-repeat="v in dbcapp.viewPerPageOptions" + value="{{v.value}}" + ng-selected="{{v.value}}=={{dbcapp.viewPerPage}}"> + {{v.value}} + </option> + </select> + </div> + +</div> +<!-- loading --> diff --git a/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr_topic_popup_template.html b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr_topic_popup_template.html new file mode 100644 index 0000000..b83c698 --- /dev/null +++ b/dcae_dmaapbc_webapp/src/main/webapp/app/dbcapp/messagerouter/mr_topic_popup_template.html @@ -0,0 +1,62 @@ +<!-- + ================================================================================ + DCAE DMaaP Bus Controller Web Application + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property + ================================================================================ + Licensed 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. + ================================================================================ + --> +<script type="text/ng-template" id="edit_topic_popup.html"> + <div class="modal__informative font-showcase" style="width:400px;"> + <div class="modal__header"> + <h2 class="font-showcase-font-name" style="width: 500px;">{{dbcapp.label}}</h2> + </div> + <div class="divider-container"> + <hr> + </div> + <div class="modal__content"> + <div class="fn-ebz-container" > + Name:<sup><b>*</b></sup> + <br/> + <input type="text" class="fn-ebz-text" ng-model="dbcapp.editTopic.topicName" /> + </div> + <br/> + <div class="fn-ebz-container" > + Description:<sup><b>*</b></sup> + <br/> + <input type="text" class="fn-ebz-text" ng-model="dbcapp.editTopic.topicDescription" /> + </div> + <!-- model differs from swagger + <br/> + <div class="fn-ebz-container" > + Tnx Enabled: + <br/> + <input type="checkbox" att-checkbox ng-model="dbcapp.editTopic.tnxEnabled" /> + </div> + --> + </div> + <div class="modal__footer"> + <button class="button button--primary button--small" + href="javascript:void(0)" + ng-click="dbcapp.saveTopic(dbcapp.editTopic);"> + Save + </button> + <button class="button button--primary button--small" + href="javascript:void(0)" + ng-click="dbcapp.close()"> + Close + </button> + </div> + </div> +</script> |