From 8b42fc48bde4726ef077e053efe3677d94f187ee Mon Sep 17 00:00:00 2001 From: Lubomir Balogh Date: Tue, 16 Aug 2016 15:04:08 +0200 Subject: [PATCH] Yangman - changed event strings to constants - Bug 6394 - Review for YangMan - events (broadcast, on, emit) are holded inside constants Change-Id: Id520a16f11a8f073b0f4135f6f528802a2906fc9 Signed-off-by: Lubomir Balogh --- .../src/main/resources/yangutils/constants.js | 37 +++++++++++++ .../controllers/form/list.controller.js | 4 +- .../controllers/module-detail.controller.js | 6 +-- .../controllers/modules-list.controller.js | 14 ++--- .../controllers/request-data.controller.js | 4 +- .../controllers/request-header.controller.js | 52 +++++++++---------- .../controllers/requests-list.controller.js | 51 +++++++++--------- .../controllers/yang-form.controller.js | 4 +- .../yangman/controllers/yangman.controller.js | 14 ++--- .../yangman/directives/abn-tree.directive.js | 4 +- .../services/plugins-unsetter.services.js | 10 ++-- .../plugins/ymDisplayMountPoints.services.js | 14 ++--- 12 files changed, 126 insertions(+), 88 deletions(-) diff --git a/modules/common-yangutils-resources/src/main/resources/yangutils/constants.js b/modules/common-yangutils-resources/src/main/resources/yangutils/constants.js index b707c50f..6c03f89d 100644 --- a/modules/common-yangutils-resources/src/main/resources/yangutils/constants.js +++ b/modules/common-yangutils-resources/src/main/resources/yangutils/constants.js @@ -37,6 +37,43 @@ function () { ICON_COLLAPSE_REMOVE: 'remove', ICON_KEYBOARD_ARROW_RIGHT: 'keyboard_arrow_right', EXPAND_LEVEL_THREE: '3', + COLLECTION_CHECK_ARRAY: ['sentData', 'receivedData', 'path', 'collection', 'method', 'status', 'name'], + EV_REFRESH_LIST_INDEX: 'EV_REFRESH_LIST_INDEX', + YANGMAN_DISABLE_ADDING_LIST_ELEMENT: 'YANGMAN_DISABLE_ADDING_LIST_ELEMENT', + YANGMAN_MODULE_D_INIT: 'YANGMAN_MODULE_D_INIT', + YANGMAN_GET_API_TREE_DATA: 'YANGMAN_GET_API_TREE_DATA', + YANGMAN_SET_API_TREE_DATA: 'YANGMAN_SET_API_TREE_DATA', + YANGMAN_SET_LOADING_BOX: 'YANGMAN_SET_LOADING_BOX', + YANGMAN_SHOW_TOAST: 'YANGMAN_SHOW_TOAST', + YANGMAN_SET_MODULE_LIST_TITLE: 'YANGMAN_SET_MODULE_LIST_TITLE', + YANGMAN_SET_CODEMIRROR_DATA: 'YANGMAN_SET_CODEMIRROR_DATA_', + YANGMAN_GET_CODEMIRROR_DATA: 'YANGMAN_GET_CODEMIRROR_DATA_', + SET_SEL_OPERATIONS: 'SET_SEL_OPERATIONS', + YANGMAN_HEADER_INIT: 'YANGMAN_HEADER_INIT', + YANGMAN_FILL_NODE_FROM_REQ: 'YANGMAN_FILL_NODE_FROM_REQ', + YANGMAN_EXECUTE_WITH_DATA: 'YANGMAN_EXECUTE_WITH_DATA', + YANGMAN_DESELECT_REQUESTS: 'YANGMAN_DESELECT_REQUESTS', + YANGMAN_REFRESH_COLLECTIONS: 'YANGMAN_REFRESH_COLLECTIONS', + YANGMAN_REFRESH_HISTORY: 'YANGMAN_REFRESH_HISTORY', + YANGMAN_SAVE_EXECUTED_REQUEST: 'YANGMAN_SAVE_EXECUTED_REQUEST', + YANGMAN_SELECT_THE_NEWEST_REQUEST: 'YANGMAN_SELECT_THE_NEWEST_REQUEST', + YANGMAN_SAVE_REQUEST_TO_COLLECTION: 'YANGMAN_SAVE_REQUEST_TO_COLLECTION', + YANGMAN_REFRESH_AND_EXPAND_COLLECTIONS: 'YANGMAN_REFRESH_AND_EXPAND_COLLECTIONS', + YANGMAN_SET_ERROR_DATA: 'YANGMAN_SET_ERROR_DATA', + YANGMAN_SET_ERROR_MESSAGE: 'YANGMAN_SET_ERROR_MESSAGE', + YANGMAN_EXECUTING_REQUEST_PROGRESS_START: 'YANGMAN_EXECUTING_REQUEST_PROGRESS_START', + YANGMAN_EXECUTING_REQUEST_PROGRESS_STOP: 'YANGMAN_EXECUTING_REQUEST_PROGRESS_STOP', + YANGMAN_GET_CODEMIRROR_DATA_RECEIVED: 'YANGMAN_GET_CODEMIRROR_DATA_RECEIVED', + YANGMAN_GET_CODEMIRROR_DATA_SENT: 'YANGMAN_GET_CODEMIRROR_DATA_SENT', + YANGMAN_SET_CODEMIRROR_DATA_RECEIVED: 'YANGMAN_SET_CODEMIRROR_DATA_RECEIVED', + YANGMAN_SET_CODEMIRROR_DATA_SENT: 'YANGMAN_SET_CODEMIRROR_DATA_SENT', + YANGMAN_ERROR_EMPTY_IDENTIFIERS: 'YANGMAN_ERROR_EMPTY_IDENTIFIERS', + YANGMAN_NO_MOUNT_POINT: 'YANGMAN_NO_MOUNT_POINT', + YANGMAN_CUST_MOUNT_POINTS: 'YANGMAN_CUST_MOUNT_POINTS', + YANGMAN_CANCEL_MP: 'YANGMAN_CANCEL_MP', + YANGMAN_MOUNT_POINT: 'YANGMAN_MOUNT_POINT', + SET_SCOPE_TREE_ROWS: 'SET_SCOPE_TREE_ROWS', + TREE_ROWS: 'tree_rows', }; }); diff --git a/modules/yangman-resources/src/main/resources/yangman/controllers/form/list.controller.js b/modules/yangman-resources/src/main/resources/yangman/controllers/form/list.controller.js index a5bf8d37..86c72001 100644 --- a/modules/yangman-resources/src/main/resources/yangman/controllers/form/list.controller.js +++ b/modules/yangman-resources/src/main/resources/yangman/controllers/form/list.controller.js @@ -37,11 +37,11 @@ define([], function () { yangList.toggleExpanded = toggleExpanded; // WATCHERS - $scope.$on('EV_REFRESH_LIST_INDEX', function () { + $scope.$on(constants.EV_REFRESH_LIST_INDEX, function () { yangList.currentDisplayIndex = 1; }); - $scope.$on('YANGMAN_DISABLE_ADDING_LIST_ELEMENT', function() { + $scope.$on(constants.YANGMAN_DISABLE_ADDING_LIST_ELEMENT, function() { yangList.init(); }); diff --git a/modules/yangman-resources/src/main/resources/yangman/controllers/module-detail.controller.js b/modules/yangman-resources/src/main/resources/yangman/controllers/module-detail.controller.js index 7d7bddc3..5c2168c5 100644 --- a/modules/yangman-resources/src/main/resources/yangman/controllers/module-detail.controller.js +++ b/modules/yangman-resources/src/main/resources/yangman/controllers/module-detail.controller.js @@ -5,9 +5,9 @@ define([ angular.module('app.yangman').controller('ModuleDetailCtrl', ModuleDetailCtrl); - ModuleDetailCtrl.$inject = ['$scope', '$rootScope', '$timeout', 'YangmanService']; + ModuleDetailCtrl.$inject = ['$scope', '$rootScope', '$timeout', 'YangmanService', 'constants']; - function ModuleDetailCtrl($scope, $rootScope, $timeout, YangmanService) { + function ModuleDetailCtrl($scope, $rootScope, $timeout, YangmanService, constants) { var moduleDetail = this; moduleDetail.treeApis = []; @@ -18,7 +18,7 @@ define([ moduleDetail.setDataDetailStore = setDataDetailStore; // WATCHERS - $scope.$on('YANGMAN_MODULE_D_INIT', function (){ + $scope.$on(constants.YANGMAN_MODULE_D_INIT, function (){ init(); }); diff --git a/modules/yangman-resources/src/main/resources/yangman/controllers/modules-list.controller.js b/modules/yangman-resources/src/main/resources/yangman/controllers/modules-list.controller.js index 470c5c93..c686d345 100644 --- a/modules/yangman-resources/src/main/resources/yangman/controllers/modules-list.controller.js +++ b/modules/yangman-resources/src/main/resources/yangman/controllers/modules-list.controller.js @@ -6,9 +6,9 @@ define([ angular.module('app.yangman').controller('ModulesListCtrl', ModulesListCtrl); ModulesListCtrl.$inject = ['$scope', '$rootScope', '$mdToast', 'YangUtilsService', 'PluginsHandlerService', - '$filter', '$timeout']; + '$filter', '$timeout', 'constants']; - function ModulesListCtrl($scope, $rootScope, $mdToast, YangUtilsService, PluginsHandlerService, $filter, $timeout) { + function ModulesListCtrl($scope, $rootScope, $mdToast, YangUtilsService, PluginsHandlerService, $filter, $timeout, constants) { var modulesList = this; modulesList.treeApis = []; @@ -24,29 +24,29 @@ define([ modulesList.setModule = setModule; // watchers - $scope.$on('YANGMAN_GET_API_TREE_DATA', function (event, args) { + $scope.$on(constants.YANGMAN_GET_API_TREE_DATA, function (event, args) { (args.cbk || angular.noop)(modulesList.treeApis); }); // set tree apis data - $scope.$on('YANGMAN_SET_API_TREE_DATA', function (event, args) { + $scope.$on(constants.YANGMAN_SET_API_TREE_DATA, function (event, args) { modulesList.treeApis = args.params; modulesList.showLoadingBox = false; showToastInfoBox('YANGMAN_LOADED_MODULES'); }); // show hide loading box - $scope.$on('YANGMAN_SET_LOADING_BOX', function (event, args){ + $scope.$on(constants.YANGMAN_SET_LOADING_BOX, function (event, args){ modulesList.showLoadingBox = args.params; (args.cbk || angular.noop)(); }); // show info box with custom title - $scope.$on('YANGMAN_SHOW_TOAST', function (event, args) { + $scope.$on(constants.YANGMAN_SHOW_TOAST, function (event, args) { showToastInfoBox(args.params); }); - $scope.$on('YANGMAN_SET_MODULE_LIST_TITLE', function (event, args) { + $scope.$on(constants.YANGMAN_SET_MODULE_LIST_TITLE, function (event, args) { modulesList.moduleListTitle = args.params; }); diff --git a/modules/yangman-resources/src/main/resources/yangman/controllers/request-data.controller.js b/modules/yangman-resources/src/main/resources/yangman/controllers/request-data.controller.js index 2b21d7a1..2064d377 100644 --- a/modules/yangman-resources/src/main/resources/yangman/controllers/request-data.controller.js +++ b/modules/yangman-resources/src/main/resources/yangman/controllers/request-data.controller.js @@ -127,11 +127,11 @@ define([], function () { requestData.type = type; initEditorOptions(); - $scope.$on('YANGMAN_SET_CODEMIRROR_DATA_' + type, function (event, args){ + $scope.$on(constants.YANGMAN_SET_CODEMIRROR_DATA + type, function (event, args){ requestData.data = args.params.data; }); - $scope.$on('YANGMAN_GET_CODEMIRROR_DATA_' + type, function (event, args){ + $scope.$on(constants.YANGMAN_GET_CODEMIRROR_DATA + type, function (event, args){ args.params.reqData = requestData.data; }); } diff --git a/modules/yangman-resources/src/main/resources/yangman/controllers/request-header.controller.js b/modules/yangman-resources/src/main/resources/yangman/controllers/request-header.controller.js index ce0e1702..ff241578 100644 --- a/modules/yangman-resources/src/main/resources/yangman/controllers/request-header.controller.js +++ b/modules/yangman-resources/src/main/resources/yangman/controllers/request-header.controller.js @@ -42,7 +42,7 @@ define([ /** * Set selected operations based on data store */ - $scope.$on('SET_SEL_OPERATIONS', function (event, operations, setUrl) { + $scope.$on(constants.SET_SEL_OPERATIONS, function (event, operations, setUrl) { setAllowedMethods(operations); if ( setUrl ) { @@ -53,7 +53,7 @@ define([ /** * Watching for changes in shown detail data type (radio button) */ - $scope.$on('YANGMAN_HEADER_INIT', function (event, args) { + $scope.$on(constants.YANGMAN_HEADER_INIT, function (event, args) { init(); setRequestUrl(args.params.path); setRequestMethod(args.params.method); @@ -62,12 +62,12 @@ define([ (args.cbk || angular.noop)(); }); - $scope.$on('YANGMAN_FILL_NODE_FROM_REQ', function (event, args) { + $scope.$on(constants.YANGMAN_FILL_NODE_FROM_REQ, function (event, args) { setNodeDataFromRequestData(args.params.requestUrl, args.params.leftpanel); (args.cbk || angular.noop)(); }); - $scope.$on('YANGMAN_EXECUTE_WITH_DATA', function (event, args) { + $scope.$on(constants.YANGMAN_EXECUTE_WITH_DATA, function (event, args) { executeOperation(args.params.data ? angular.fromJson(args.params.data) : {}, args.cbk); }); @@ -168,8 +168,8 @@ define([ var sentData = { reqData: null }, allData = { sent: null, received: null }; - $scope.rootBroadcast('YANGMAN_GET_CODEMIRROR_DATA_RECEIVED', params); - $scope.rootBroadcast('YANGMAN_GET_CODEMIRROR_DATA_SENT', sentData); + $scope.rootBroadcast(constants.YANGMAN_GET_CODEMIRROR_DATA_RECEIVED, params); + $scope.rootBroadcast(constants.YANGMAN_GET_CODEMIRROR_DATA_SENT, sentData); allData.sent = sentData.reqData ? angular.fromJson(sentData.reqData) : {}; allData.received = params.reqData ? angular.fromJson(params.reqData) : {}; @@ -191,7 +191,7 @@ define([ dataType = requestHeader.selectedOperation === constants.OPERATION_GET ? constants.REQUEST_DATA_TYPE_RECEIVED : 'SENT'; } - $scope.rootBroadcast('YANGMAN_GET_CODEMIRROR_DATA_' + dataType, params); + $scope.rootBroadcast(constants.YANGMAN_GET_CODEMIRROR_DATA + dataType, params); return params.reqData ? angular.fromJson(params.reqData) : {}; }, }; @@ -205,13 +205,13 @@ define([ */ function sendRequestData(data, type){ $scope.rootBroadcast( - 'YANGMAN_SET_CODEMIRROR_DATA_' + type, + constants.YANGMAN_SET_CODEMIRROR_DATA + type, { data: data instanceof Object ? JSON.stringify(data, null, 4) : data } ); } function sendErrorData(response) { - $scope.rootBroadcast('YANGMAN_SET_ERROR_DATA', response); + $scope.rootBroadcast(constants.YANGMAN_SET_ERROR_DATA, response); } /** @@ -281,7 +281,7 @@ define([ } function setApiByUrl(url, cbk, fill){ - $scope.rootBroadcast('YANGMAN_GET_API_TREE_DATA', null, function (treeApis) { + $scope.rootBroadcast(constants.YANGMAN_GET_API_TREE_DATA, null, function (treeApis) { var apisIndexes = PathUtilsService.searchNodeByPath(url, treeApis, null, true, true); @@ -317,24 +317,24 @@ define([ null, null, requestHeader.requestUrl, requestHeader.selectedOperation, '', '', '' ); - $scope.rootBroadcast('YANGMAN_GET_CODEMIRROR_DATA_SENT', sentData); - $scope.rootBroadcast('YANGMAN_GET_CODEMIRROR_DATA_RECEIVED', receivedData); + $scope.rootBroadcast(constants.YANGMAN_GET_CODEMIRROR_DATA_SENT, sentData); + $scope.rootBroadcast(constants.YANGMAN_GET_CODEMIRROR_DATA_RECEIVED, receivedData); RequestService.fillRequestByMethod( historyReq, sentData, receivedData, requestHeader.selectedOperation, $scope.node, requestHeader.selectedShownDataType ); - $scope.rootBroadcast('YANGMAN_SAVE_REQUEST_TO_COLLECTION', { event: event, reqObj: historyReq }); + $scope.rootBroadcast(constants.YANGMAN_SAVE_REQUEST_TO_COLLECTION, { event: event, reqObj: historyReq }); } function showRequestProgress(){ - $scope.rootBroadcast('YANGMAN_EXECUTING_REQUEST_PROGRESS_START'); + $scope.rootBroadcast(constants.YANGMAN_EXECUTING_REQUEST_PROGRESS_START); } function finishRequestProgress(message){ - $scope.rootBroadcast('YANGMAN_EXECUTING_REQUEST_PROGRESS_STOP'); + $scope.rootBroadcast(constants.YANGMAN_EXECUTING_REQUEST_PROGRESS_STOP); } /** @@ -349,7 +349,7 @@ define([ showRequestProgress(); setRequestUrl(requestHeader.selectedShownDataType === constants.DISPLAY_TYPE_REQ_DATA ? requestHeader.requestUrl : null); - $scope.rootBroadcast('YANGMAN_SET_ERROR_MESSAGE', ''); + $scope.rootBroadcast(constants.YANGMAN_SET_ERROR_MESSAGE, ''); if ( requestHeader.selectedShownDataType !== constants.DISPLAY_TYPE_FORM ){ setApiByUrl(requestHeader.requestUrl, null, true); @@ -373,8 +373,8 @@ define([ requestHeader.executedOperation = requestHeader.selectedOperation; } else { $scope.rootBroadcast( - 'YANGMAN_SET_ERROR_MESSAGE', - $filter('translate')('YANGMAN_ERROR_EMPTY_IDENTIFIERS') + constants.YANGMAN_SET_ERROR_MESSAGE, + $filter('translate')(constants.YANGMAN_ERROR_EMPTY_IDENTIFIERS) ); } @@ -413,7 +413,7 @@ define([ ); $scope.node.expanded = true; - $scope.rootBroadcast('YANGMAN_DISABLE_ADDING_LIST_ELEMENT'); + $scope.rootBroadcast(constants.YANGMAN_DISABLE_ADDING_LIST_ELEMENT); preparedReceivedData = YangmanService.checkRpcReceivedData(preparedReceivedData, $scope.node); sendRequestData(preparedReceivedData, constants.REQUEST_DATA_TYPE_RECEIVED); } @@ -429,8 +429,8 @@ define([ reqInfo.time ); - $scope.rootBroadcast('YANGMAN_SAVE_EXECUTED_REQUEST', historyReq, function (){ - $scope.rootBroadcast('YANGMAN_SELECT_THE_NEWEST_REQUEST'); + $scope.rootBroadcast(constants.YANGMAN_SAVE_EXECUTED_REQUEST, historyReq, function (){ + $scope.rootBroadcast(constants.YANGMAN_SELECT_THE_NEWEST_REQUEST); }); (executeCbk || angular.noop)(historyReq); @@ -456,8 +456,8 @@ define([ reqInfo.statusText, reqInfo.time ); - $scope.rootBroadcast('YANGMAN_SAVE_EXECUTED_REQUEST', historyReq, function (){ - $scope.rootBroadcast('YANGMAN_SELECT_THE_NEWEST_REQUEST'); + $scope.rootBroadcast(constants.YANGMAN_SAVE_EXECUTED_REQUEST, historyReq, function (){ + $scope.rootBroadcast(constants.YANGMAN_SELECT_THE_NEWEST_REQUEST); }); if (response.data) { @@ -496,7 +496,7 @@ define([ if ( requestHeader.selectedShownDataType === constants.DISPLAY_TYPE_REQ_DATA ) { // get json data var params = { reqData: null }; - $scope.rootBroadcast('YANGMAN_GET_CODEMIRROR_DATA_SENT', params); + $scope.rootBroadcast(constants.YANGMAN_GET_CODEMIRROR_DATA_SENT, params); executeOperation(params.reqData ? angular.fromJson(params.reqData) : {}, cbk); } else { executeOperation({}, cbk); @@ -521,7 +521,7 @@ define([ 'MAIN_SCOPE' ); - $scope.rootBroadcast('YANGMAN_GET_API_TREE_DATA', null, function (treeApis) { + $scope.rootBroadcast(constants.YANGMAN_GET_API_TREE_DATA, null, function (treeApis) { DataBackupService.storeFromScope( ['treeApis'], { treeApis: treeApis }, @@ -534,7 +534,7 @@ define([ $scope.setGlobalParams(mountPointApis, augmentations); $scope.setDataStore(null); requestHeader.statusObj = reqObj; - $scope.rootBroadcast('YANGMAN_SET_API_TREE_DATA', mountPointTreeApis); + $scope.rootBroadcast(constants.YANGMAN_SET_API_TREE_DATA, mountPointTreeApis); } /** diff --git a/modules/yangman-resources/src/main/resources/yangman/controllers/requests-list.controller.js b/modules/yangman-resources/src/main/resources/yangman/controllers/requests-list.controller.js index 62a35f89..047525a4 100644 --- a/modules/yangman-resources/src/main/resources/yangman/controllers/requests-list.controller.js +++ b/modules/yangman-resources/src/main/resources/yangman/controllers/requests-list.controller.js @@ -123,7 +123,7 @@ define([ $mdDialog.show(confirm).then(function (){ vm.collectionList.clear(); vm.collectionList.saveToStorage(); - $scope.rootBroadcast('YANGMAN_REFRESH_COLLECTIONS'); + $scope.rootBroadcast(constants.YANGMAN_REFRESH_COLLECTIONS); YangmanDesignService.enableMdMenuItem(event); }, function () { YangmanDesignService.enableMdMenuItem(event); @@ -156,14 +156,13 @@ define([ * @param $fileContent */ function readCollectionFromFile($fileContent) { - var data = $fileContent, - checkArray = ['sentData', 'receivedData', 'path', 'collection', 'method', 'status', 'name']; + var data = $fileContent; - if (data && YangmanService.validateFile(data, checkArray)){ + if (data && YangmanService.validateFile(data, constants.COLLECTION_CHECK_ARRAY)){ try { vm.collectionList.loadListFromFile(data); vm.collectionList.saveToStorage(); - $scope.rootBroadcast('YANGMAN_REFRESH_COLLECTIONS'); + $scope.rootBroadcast(constants.YANGMAN_REFRESH_COLLECTIONS); clearFileInputValue(); } catch (e) { @@ -214,19 +213,19 @@ define([ } $scope.rootBroadcast( - 'YANGMAN_SET_CODEMIRROR_DATA_RECEIVED', { data: reqObj.setDataForView(reqObj.receivedData) } + constants.YANGMAN_SET_CODEMIRROR_DATA_RECEIVED, { data: reqObj.setDataForView(reqObj.receivedData) } ); $scope.rootBroadcast( - 'YANGMAN_SET_CODEMIRROR_DATA_SENT', { data: reqObj.setDataForView(reqObj.sentData) } + constants.YANGMAN_SET_CODEMIRROR_DATA_SENT, { data: reqObj.setDataForView(reqObj.sentData) } ); - $scope.rootBroadcast('YANGMAN_SET_ERROR_DATA', + $scope.rootBroadcast(constants.YANGMAN_SET_ERROR_DATA, reqObj.receivedData && reqObj.receivedData.hasOwnProperty('errors') ? reqObj.receivedData : {}); - $scope.rootBroadcast('YANGMAN_FILL_NODE_FROM_REQ', { requestUrl: reqObj.path, requestData: data }, + $scope.rootBroadcast(constants.YANGMAN_FILL_NODE_FROM_REQ, { requestUrl: reqObj.path, requestData: data }, function (){ $scope.setRightPanelSection(constants.DISPLAY_TYPE_FORM); - $scope.rootBroadcast('YANGMAN_HEADER_INIT', { + $scope.rootBroadcast(constants.YANGMAN_HEADER_INIT, { path: reqObj.path, method: reqObj.method, statusObj: { @@ -263,7 +262,7 @@ define([ */ function executeRequest(reqObj) { showData(reqObj); - $scope.rootBroadcast('YANGMAN_EXECUTE_WITH_DATA',{ data: reqObj.sentData }); + $scope.rootBroadcast(constants.YANGMAN_EXECUTE_WITH_DATA,{ data: reqObj.sentData }); } /** @@ -286,7 +285,7 @@ define([ }; $scope.rootBroadcast( - 'YANGMAN_SET_ERROR_DATA', + constants.YANGMAN_SET_ERROR_DATA, reqObj.receivedData && reqObj.receivedData.hasOwnProperty('errors') ? reqObj.receivedData : {} ); } @@ -294,16 +293,16 @@ define([ $scope.setRightPanelSection(constants.DISPLAY_TYPE_REQ_DATA); $scope.setJsonView(true, reqObj.method !== constants.OPERATION_GET); - $scope.rootBroadcast('YANGMAN_HEADER_INIT', headerObj); - $scope.rootBroadcast('YANGMAN_FILL_NODE_FROM_REQ', { requestUrl: reqObj.path }); + $scope.rootBroadcast(constants.YANGMAN_HEADER_INIT, headerObj); + $scope.rootBroadcast(constants.YANGMAN_FILL_NODE_FROM_REQ, { requestUrl: reqObj.path }); $scope.rootBroadcast( - 'YANGMAN_SET_CODEMIRROR_DATA_RECEIVED', + constants.YANGMAN_SET_CODEMIRROR_DATA_RECEIVED, { data: reqObj.setDataForView(reqObj.receivedData) } ); $scope.rootBroadcast( - 'YANGMAN_SET_CODEMIRROR_DATA_SENT', + constants.YANGMAN_SET_CODEMIRROR_DATA_SENT, { data: reqObj.setDataForView(reqObj.sentData) } ); } @@ -537,13 +536,13 @@ define([ // if request was selected, deselect requests in all other instances of RequestsListCtrl - $scope.$on('YANGMAN_DESELECT_REQUESTS', function (event, params) { + $scope.$on(constants.YANGMAN_DESELECT_REQUESTS, function (event, params) { if (params.params.broadcastingCtrl !== vm) { deselectAllRequests(); } }); - $scope.$on('YANGMAN_REFRESH_COLLECTIONS', function (event, params){ + $scope.$on(constants.YANGMAN_REFRESH_COLLECTIONS, function (event, params){ loadCollectionsList(); (params.cbk || angular.noop)(); }); @@ -554,20 +553,20 @@ define([ vm.mainList = vm.requestList; loadHistoryList(); - $scope.$on('YANGMAN_REFRESH_HISTORY', loadHistoryList); + $scope.$on(constants.YANGMAN_REFRESH_HISTORY, loadHistoryList); // saving from request header after execution - $scope.$on('YANGMAN_SAVE_EXECUTED_REQUEST', saveBcstedHistoryRequest); + $scope.$on(constants.YANGMAN_SAVE_EXECUTED_REQUEST, saveBcstedHistoryRequest); // select newest request - $scope.$on('YANGMAN_SELECT_THE_NEWEST_REQUEST', selectNewestRequest); + $scope.$on(constants.YANGMAN_SELECT_THE_NEWEST_REQUEST, selectNewestRequest); } else { vm.mainList = vm.collectionList; // saving from request header - $scope.$on('YANGMAN_SAVE_REQUEST_TO_COLLECTION', saveRequestFromExt); + $scope.$on(constants.YANGMAN_SAVE_REQUEST_TO_COLLECTION, saveRequestFromExt); // saving collections expanded status on refresh - $scope.$on('YANGMAN_REFRESH_AND_EXPAND_COLLECTIONS', function(){ + $scope.$on(constants.YANGMAN_REFRESH_AND_EXPAND_COLLECTIONS, function(){ var expandedColNames = vm.collectionList.getExpandedCollectionNames(); - $scope.rootBroadcast('YANGMAN_REFRESH_COLLECTIONS', {}, function (){ + $scope.rootBroadcast(constants.YANGMAN_REFRESH_COLLECTIONS, {}, function (){ vm.collectionList.expandCollectionByNames(expandedColNames); }); }); @@ -583,7 +582,7 @@ define([ * @param requestObj */ function selectRequest(event, requestObj){ - $scope.rootBroadcast('YANGMAN_DESELECT_REQUESTS', { broadcastingCtrl: vm }); + $scope.rootBroadcast(constants.YANGMAN_DESELECT_REQUESTS, { broadcastingCtrl: vm }); vm.mainList.toggleReqSelection(!event.ctrlKey, requestObj); if (!event.ctrlKey){ vm.showData(requestObj, true); @@ -631,7 +630,7 @@ define([ * Refresh and expand collections */ function refreshCollectionsWithExpansion(){ - $scope.rootBroadcast('YANGMAN_REFRESH_AND_EXPAND_COLLECTIONS'); + $scope.rootBroadcast(constants.YANGMAN_REFRESH_AND_EXPAND_COLLECTIONS); } } diff --git a/modules/yangman-resources/src/main/resources/yangman/controllers/yang-form.controller.js b/modules/yangman-resources/src/main/resources/yangman/controllers/yang-form.controller.js index 22f3c249..f05fbaf6 100644 --- a/modules/yangman-resources/src/main/resources/yangman/controllers/yang-form.controller.js +++ b/modules/yangman-resources/src/main/resources/yangman/controllers/yang-form.controller.js @@ -34,9 +34,9 @@ define([ yangForm.getNodeName = getNodeName; // watchers - $scope.$on('YANGMAN_SET_ERROR_DATA', setRcvdErrorData); + $scope.$on(constants.YANGMAN_SET_ERROR_DATA, setRcvdErrorData); - $scope.$on('YANGMAN_SET_ERROR_MESSAGE', setErrorMessage); + $scope.$on(constants.YANGMAN_SET_ERROR_MESSAGE, setErrorMessage); /** * Method for set error message in form diff --git a/modules/yangman-resources/src/main/resources/yangman/controllers/yangman.controller.js b/modules/yangman-resources/src/main/resources/yangman/controllers/yangman.controller.js index 7c4a3727..907b6e33 100644 --- a/modules/yangman-resources/src/main/resources/yangman/controllers/yangman.controller.js +++ b/modules/yangman-resources/src/main/resources/yangman/controllers/yangman.controller.js @@ -119,8 +119,8 @@ define([ * Initialization */ function init(){ - $scope.$on('YANGMAN_EXECUTING_REQUEST_PROGRESS_START', startExecutingRequestProgress); - $scope.$on('YANGMAN_EXECUTING_REQUEST_PROGRESS_STOP', stopExecutingRequestProgress); + $scope.$on(constants.YANGMAN_EXECUTING_REQUEST_PROGRESS_START, startExecutingRequestProgress); + $scope.$on(constants.YANGMAN_EXECUTING_REQUEST_PROGRESS_STOP, stopExecutingRequestProgress); YangmanDesignService.hideMainMenu(); YangmanDesignService.setDraggableLeftPanel(); @@ -211,8 +211,8 @@ define([ * Genereal method for clearing code mirror - sent and received data too */ function clearCM(){ - $scope.rootBroadcast('YANGMAN_SET_CODEMIRROR_DATA_RECEIVED', { data: JSON.stringify({}) }); - $scope.rootBroadcast('YANGMAN_SET_CODEMIRROR_DATA_SENT', { data: JSON.stringify({}) }); + $scope.rootBroadcast(constants.YANGMAN_SET_CODEMIRROR_DATA_RECEIVED, { data: JSON.stringify({}) }); + $scope.rootBroadcast(constants.YANGMAN_SET_CODEMIRROR_DATA_SENT, { data: JSON.stringify({}) }); } @@ -246,7 +246,7 @@ define([ if ( $scope.node ) { $scope.node.clear(); - $scope.$broadcast('YANGMAN_DISABLE_ADDING_LIST_ELEMENT'); + $scope.$broadcast(constants.YANGMAN_DISABLE_ADDING_LIST_ELEMENT); } } @@ -269,7 +269,7 @@ define([ if ( expand ) { $scope.node = null; setLeftPanel(leftPanel); - $scope.$broadcast('YANGMAN_MODULE_D_INIT'); + $scope.$broadcast(constants.YANGMAN_MODULE_D_INIT); } else { if ( $scope.node ) { @@ -300,7 +300,7 @@ define([ PathUtilsService.clearPath($scope.selectedSubApi.pathArray); } - $scope.$broadcast('SET_SEL_OPERATIONS', subApi ? $scope.selectedSubApi.operations : [], setUrl); + $scope.$broadcast(constants.SET_SEL_OPERATIONS, subApi ? $scope.selectedSubApi.operations : [], setUrl); } /** diff --git a/modules/yangman-resources/src/main/resources/yangman/directives/abn-tree.directive.js b/modules/yangman-resources/src/main/resources/yangman/directives/abn-tree.directive.js index 138edb46..06358536 100644 --- a/modules/yangman-resources/src/main/resources/yangman/directives/abn-tree.directive.js +++ b/modules/yangman-resources/src/main/resources/yangman/directives/abn-tree.directive.js @@ -194,9 +194,9 @@ define(['angular'], function (angular) { }; - scope.$watch('tree_rows', function () { + scope.$watch(constants.TREE_ROWS, function () { scope.treeRows = scope.tree_rows; - scope.$emit('SET_SCOPE_TREE_ROWS', scope.treeRows); + scope.$emit(constants.SET_SCOPE_TREE_ROWS, scope.treeRows); }); scope.tree_rows = []; diff --git a/modules/yangman-resources/src/main/resources/yangman/services/plugins-unsetter.services.js b/modules/yangman-resources/src/main/resources/yangman/services/plugins-unsetter.services.js index 3a518bdb..347ae538 100644 --- a/modules/yangman-resources/src/main/resources/yangman/services/plugins-unsetter.services.js +++ b/modules/yangman-resources/src/main/resources/yangman/services/plugins-unsetter.services.js @@ -4,7 +4,9 @@ define(['angular'], function (angular) { angular.module('app.yangman').service('PluginsUnsetterService', ['PathUtilsService', 'DataBackupService', PluginsUnsetterService]); - function PluginsUnsetterService(PathUtilsService, DataBackupService){ + PluginsUnsetterService.$inject = ['constants']; + + function PluginsUnsetterService(PathUtilsService, DataBackupService, constants){ var service = { 'YANGMAN_CUST_MOUNT_POINTS': unsetMountPoint, unset: unset, @@ -29,11 +31,11 @@ define(['angular'], function (angular) { ); DataBackupService.getToScope(['treeApis'], modulesListObj, 'MODULES_LIST'); - scope.$broadcast('YANGMAN_SET_API_TREE_DATA', { params: modulesListObj.treeApis }); - scope.$broadcast('YANGMAN_SET_MODULE_LIST_TITLE', { params: '' }); + scope.$broadcast(constants.YANGMAN_SET_API_TREE_DATA, { params: modulesListObj.treeApis }); + scope.$broadcast(constants.YANGMAN_SET_MODULE_LIST_TITLE, { params: '' }); if ( scope.selectedDatastore ){ - scope.$broadcast('YANGMAN_MODULE_D_INIT'); + scope.$broadcast(constants.YANGMAN_MODULE_D_INIT); } } diff --git a/modules/yangman-resources/src/main/resources/yangman/services/plugins/ymDisplayMountPoints.services.js b/modules/yangman-resources/src/main/resources/yangman/services/plugins/ymDisplayMountPoints.services.js index 048ea70f..07cafd47 100644 --- a/modules/yangman-resources/src/main/resources/yangman/services/plugins/ymDisplayMountPoints.services.js +++ b/modules/yangman-resources/src/main/resources/yangman/services/plugins/ymDisplayMountPoints.services.js @@ -29,7 +29,7 @@ define([ scope = args.scope, path = scope.selectedSubApi.buildApiRequestString(); - scope.rootBroadcast('YANGMAN_SET_LOADING_BOX', true, function () { + scope.rootBroadcast(constants.YANGMAN_SET_LOADING_BOX, true, function () { scope.setLeftPanel(0); $timeout(function () { MountPointsConnectorService.discoverMountPoints(path, getNodesMPData, createMPStructure); @@ -107,13 +107,13 @@ define([ controller.initMountPoint(mountPointTreeApis, mountPointApis, mpAugments, reqObj); scope.rootBroadcast( - 'YANGMAN_SET_MODULE_LIST_TITLE', - pathItems[pathItems.length - 1] + ' [ ' + $filter('translate')('YANGMAN_MOUNT_POINT') + ' ]' + constants.YANGMAN_SET_MODULE_LIST_TITLE, + pathItems[pathItems.length - 1] + ' [ ' + $filter('translate')(constants.YANGMAN_MOUNT_POINT) + ' ]' ); controller.selectedPluginsButtons.push( - MountPointsConnectorService.createCustomButton('YANGMAN_CANCEL_MP', function (){ - return controller.selectedPlugin.label === 'YANGMAN_CUST_MOUNT_POINTS'; + MountPointsConnectorService.createCustomButton(constants.YANGMAN_CANCEL_MP, function (){ + return controller.selectedPlugin.label === constants.YANGMAN_CUST_MOUNT_POINTS; }, function (){ controller.unsetPluginFunctionality(); @@ -123,8 +123,8 @@ define([ } else { $timeout(function (){ controller.selectedPlugin = null; - scope.rootBroadcast('YANGMAN_SET_LOADING_BOX', false); - scope.rootBroadcast('YANGMAN_SHOW_TOAST', 'YANGMAN_NO_MOUNT_POINT'); + scope.rootBroadcast(constants.YANGMAN_SET_LOADING_BOX, false); + scope.rootBroadcast(constants.YANGMAN_SHOW_TOAST, constants.YANGMAN_NO_MOUNT_POINT); }, 100); } } -- 2.36.6