From c5a577a1cc00ace7964ff53dd2862a7dd2325411 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 8 Aug 2017 03:11:34 -0700 Subject: Rework javascripts for designer UI (part2) Rework javascripts for designer UI (part2) Change-Id: I72ffef0adc2559e8053203cee928eff5c4d9b0dc Issue-Id: CLAMP-1 Signed-off-by: Determe, Sebastien (sd378r) --- .../designer/scripts/AutosaveProjectCtrl.js | 98 ---- .../resources/designer/scripts/CldsModelService.js | 495 ++++++++++++--------- .../designer/scripts/CldsOpenModelCtrl.js | 96 ++-- .../designer/scripts/CldsOpenTemplateCtrl.js | 38 +- .../designer/scripts/CldsTemplateService.js | 97 ++-- .../resources/designer/scripts/DashboardCtrl.js | 67 +-- .../resources/designer/scripts/ExportFileCtrl.js | 94 ---- .../designer/scripts/ExportFileService.js | 26 -- .../resources/designer/scripts/FileUploadCtrl.js | 65 +-- 9 files changed, 406 insertions(+), 670 deletions(-) diff --git a/src/main/resources/META-INF/resources/designer/scripts/AutosaveProjectCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/AutosaveProjectCtrl.js index 02297d7a6..0c3fd2ed9 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/AutosaveProjectCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/AutosaveProjectCtrl.js @@ -24,102 +24,4 @@ function AutosaveProject($scope,$rootScope,$resource, $http, $timeout, $location, $interval, $q, Datafactory) { console.log("//////////Autosaveproject"); - $scope.saveProjectToUrl = function(UTMMDTProject,svnUploadURL){ - console.log("saveProjectURL"); - console.log('Autosaveproject Enter == ' + new Date().getTime()); - console.log(new Date()); - var def = $q.defer(); - - $http.post(svnUploadURL, UTMMDTProject) - .success(function(data){ - console.log("success"); - def.resolve(data); - }) - .error(function(data){ - console.log("error"); - def.reject("Autosave unsuccessful"); - }); - - return def.promise; - - }; - - $scope.autosave = function(){ - console.log("autosave"); - - var saveProjectURL = "/utm-service/project_administration/autoSaveProject"; - - var UTMProjectExplorer = {}; - UTMProjectExplorer.projectName = $rootScope.projectName; - UTMProjectExplorer.utmModels = $rootScope.utmModels; - UTMProjectExplorer.revision = autoSaveRevision; - UTMProjectExplorer.utmDepthValueMap = $rootScope.depthElementKeyMap; - UTMProjectExplorer.utmCountValueMap = $rootScope.countElementKeyMap; - - var utm_models = []; - $rootScope.populateUTMModelArray(utm_models,$rootScope.utmModels); - - var UTMMDTProject = {}; - UTMMDTProject.utmProjectExplorer = UTMProjectExplorer; - UTMMDTProject.utmModels = utm_models; - UTMMDTProject.almqcdata = $rootScope.almqcData; - UTMMDTProject.wsdlInfo = null; - UTMMDTProject.schemaLocation = null; - - if ($rootScope.wsdlInfo != null) { - UTMMDTProject.schemaLocation = $rootScope.wsdlInfo.schemaLocation; - UTMMDTProject.oldSchemaLocation = $rootScope.wsdlInfo.oldSchemaLocation; - UTMMDTProject.schemaUpgradedFlag = $rootScope.wsdlInfo.schemaUpgradedFlag; - } - - UTMMDTProject.revision=$rootScope.revision; - console.log(UTMMDTProject.revision); - - UTMMDTProject.checkOutPath=$rootScope.checkOutPath; - UTMMDTProject.oldNewModelNameMap = old_new_model_name; - UTMMDTProject.automationDetails={}; - - UTMMDTProject.automationDetails.projectPreferenceInfo = Datafactory.getProjectPreferenceInfo(); - UTMMDTProject.automationDetails.environmentData = $rootScope.environmentData; - UTMMDTProject.automationDetails.pythonScriptList = Datafactory.getCommonPythonScriptList(); - UTMMDTProject.automationDetails.dbToolRequestList = Datafactory.getDbToolProjectLevelList(); - UTMMDTProject.automationDetails.runtimePythonScriptList = Datafactory.getRuntimePythonScriptProjectLevelList(); - UTMMDTProject.automationDetails.xmlValidatorList = Datafactory.getXmlValidatorList(); - UTMMDTProject.automationDetails.fileWriterList = Datafactory.getWriteFileDataList(); - UTMMDTProject.automationDetails.fileStreamWriterList = Datafactory.getFileStreamWriterList(); - - - - if($rootScope.openedProject != null){ - console.log('opened project...') - var existingData = JSON.stringify($rootScope.openedProject); - var currentgData = JSON.stringify(UTMMDTProject); - if(angular.equals(existingData, currentgData)){ - //do nothing - console.log('No changes found.'); - }else{ - console.log('Changes found.'); - $scope.saveProjectToUrl(UTMMDTProject,saveProjectURL) - .then(function(pars) { - console.log(""); - }, - function(data) { - - }); - } - - }else{ - console.log('autosaving project...') - $scope.saveProjectToUrl(UTMMDTProject,saveProjectURL) - .then(function(pars) { - - }, - function(data) { - - }); - } - - } - - $scope.autosave(); } diff --git a/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js b/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js index c0d4f8a7a..c2b4f6733 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js +++ b/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js @@ -22,253 +22,282 @@ */ app.service('cldsModelService', ['alertService','$http', '$q', function (alertService,$http, $q) { - console.log("/////////////cldsModelService"); - function checkIfElementType(name){ + + function checkIfElementType(name){ - //This will open the methods located in the app.js - if(name.toLowerCase().indexOf("stringmatch")>=0) - StringMatchWindow(); - else if(name.toLowerCase().indexOf("tca")>=0) - TCAWindow(); - else if(name.toLowerCase().indexOf("collector")>=0) - CollectorsWindow(); - else if(name.toLowerCase().indexOf("policy")>=0) - PolicyWindow(); - - } - this.getASDCServices = function(){ - - console.log("getASDCServices"); - var def = $q.defer(); - var sets = []; - - var svcUrl = "/restservices/clds/v1/clds/asdc/services/"; - + //This will open the methods located in the app.js + if (name.toLowerCase().indexOf("stringmatch")>=0) + StringMatchWindow(); + else if (name.toLowerCase().indexOf("tca")>=0) + TCAWindow(); + else if(name.toLowerCase().indexOf("policy")>=0) + PolicyWindow(); + else if(name.toLowerCase().indexOf("collector")>=0) + CollectorsWindow(); + + } + + this.toggleDeploy = function (uiAction, modelName, controlNamePrefixIn, + bpmnTextIn, propTextIn, svgXmlIn, templateName, typeID, controlNameUuid, modelEventService, deploymentId) { + + var def = $q.defer(); + var sets = []; + var action = uiAction.toLowerCase(); + var deployUrl = "/restservices/clds/v1/clds/"+action+"/"+modelName; + var requestData = {name: modelName, + controlNamePrefix: controlNamePrefixIn, + bpmnText: bpmnTextIn, + propText: propTextIn, + imageText:svgXmlIn, + templateName:templateName, + typeId:typeID, + controlNameUuid: controlNameUuid, + event:modelEventService, + deploymentId:deploymentId}; + + $http.put(deployUrl,requestData) + .success(function(data){ + deploymentId = data.deploymentId; + def.resolve(data); + alertService.alertMessage("Action Successful:"+uiAction,1) + }) + .error(function(data){ + alertService.alertMessage("Action Failure:"+uiAction,2) + def.reject("Save Model not successful"); + }); + + return def.promise; + }; + + this.getASDCServices = function(){ + + + var def = $q.defer(); + var sets = []; + + var svcUrl = "/restservices/clds/v1/clds/sdc/services/"; + $http.get(svcUrl) - .success(function(data){ - def.resolve(data); - - + .success(function(data){ + def.resolve(data); + + }) - .error(function(data){ - def.reject("Asdc Services not found"); - + .error(function(data){ + def.reject("sdc Services not found"); + }); return def.promise; }; - this.getRunningInstances=function(resouseInput){ - console.log("getRunningInstances"); - var def = $q.defer(); - var sets = []; - - //Look in scripts/common_variables.html to get utmModel name - - // var svcUrl = "/restservices/clds/v1/clds/model/roncl003"; - var svcUrl = "/restservices/clds/v1/clds/model/" + resouseInput; - - $http.get(svcUrl) - .success(function(data){ - def.resolve(data); - - - }) - .error(function(data){ - def.reject("Asdc Services not found"); - - }); - - return def.promise; - - // return [{"name":"asbg0003vm001","location":"SNANTXCA","status":"Running","view":"KPI"},{"name":"asbg0003vm002","location":"SNANTXCA","status":"Running","view":"KPI"},{"name":"asbg0003vm003","location":"SNANTXCA","status":"Running","view":"KPI"},{"name":"asbg0003vm004","location":"SNANTXCA","status":"Stopped","view":"KPI"}] - } this.getASDCService = function(uuid){ - console.log("getASDCService"); - - var def = $q.defer(); - var sets = []; - - var svcUrl = "/restservices/clds/v1/clds/asdc/services/" + uuid; - + + + var def = $q.defer(); + var sets = []; + + var svcUrl = "/restservices/clds/v1/clds/sdc/services/" + uuid; + $http.get(svcUrl) .success(function(data){ - def.resolve(data); - + def.resolve(data); + }) - .error(function(data){ - def.reject("ASDC service not found"); + .error(function(data){ + def.reject("SDC service not found"); }); return def.promise; }; this.getModel = function(modelName){ - - console.log("getModel"); - var def = $q.defer(); - var sets = []; - - var svcUrl = "/restservices/clds/v1/clds/model/" + modelName; - + + + var def = $q.defer(); + var sets = []; + var svcUrl = "/restservices/clds/v1/clds/model/" + modelName; + $http.get(svcUrl) - .success(function(data){ - def.resolve(data); - + .success(function(data){ + def.resolve(data); + }) - .error(function(data){ - def.reject("Open Model not successful"); + .error(function(data){ + def.reject("Open Model not successful"); }); return def.promise; }; this.getSavedModel=function(){ - console.log("getSavedModel"); - var def = $q.defer(); - var sets = []; - - var svcUrl = "/restservices/clds/v1/clds/model-names"; - + + var def = $q.defer(); + var sets = []; + + var svcUrl = "/restservices/clds/v1/clds/model-names"; + $http.get(svcUrl) - .success(function(data){ - def.resolve(data); - + .success(function(data){ + def.resolve(data); + }) - .error(function(data){ - def.reject("Open Model not successful"); + .error(function(data){ + def.reject("Open Model not successful"); }); return def.promise; }; this.setModel = function(modelName, controlNamePrefixIn, bpmnTextIn, propTextIn){ - - console.log("setModel"); - var def = $q.defer(); - var sets = []; - - var svcUrl = "/restservices/clds/v1/clds/model/" + modelName; + + + var def = $q.defer(); + var sets = []; + var svcUrl = "/restservices/clds/v1/clds/model/" + modelName; var svcRequest = {name: modelName, controlNamePrefix: controlNamePrefixIn, bpmnText: bpmnTextIn, propText: propTextIn}; - + $http.put(svcUrl, svcRequest) - .success(function(data){ - def.resolve(data); - + .success(function(data){ + def.resolve(data); + }) - .error(function(data){ - def.reject("Save Model not successful"); + .error(function(data){ + def.reject("Save Model not successful"); }); return def.promise; }; - this.processAction = function(uiAction, modelName, controlNamePrefixIn, bpmnTextIn, propTextIn,svgXmlIn,templateName){ - - console.log("processAction"); - var def = $q.defer(); - var sets = []; - console.log("Generated SVG xml File..."); - //console.log(svgXmlIn); - var svcUrl = "/restservices/clds/v1/clds/"; - var svcAction = uiAction.toLowerCase(); - if ( svcAction == "save" || svcAction == "refresh" ) { - svcUrl = svcUrl + "model/" + modelName; - } else if ( svcAction == "test" ) { - svcUrl = svcUrl + "action/submit/" + modelName + "?test=true"; - } else { - svcUrl = svcUrl + "action/" + svcAction + "/" + modelName; - } - - var svcRequest = {name: modelName, controlNamePrefix: controlNamePrefixIn, bpmnText: bpmnTextIn, propText: propTextIn, imageText:svgXmlIn, templateName:templateName}; - console.log(svcRequest) + this.processAction = function(uiAction, modelName, controlNamePrefixIn, bpmnTextIn, propTextIn,svgXmlIn,templateName,typeID,deploymentId){ + + + var def = $q.defer(); + var sets = []; + + //console.log(svgXmlIn); + var svcUrl = "/restservices/clds/v1/clds/"; + var svcAction = uiAction.toLowerCase(); + if ( svcAction == "save" || svcAction == "refresh" ) { + svcUrl = svcUrl + "model/" + modelName; + } else if ( svcAction == "test" ) { + svcUrl = svcUrl + "action/submit/" + modelName + "?test=true"; + } else { + svcUrl = svcUrl + "action/" + svcAction + "/" + modelName; + } + + var svcRequest = {name: modelName, controlNamePrefix: controlNamePrefixIn, bpmnText: bpmnTextIn, propText: propTextIn, imageText:svgXmlIn, templateName:templateName, typeId:typeID, deploymentId:deploymentId}; + $http.put(svcUrl, svcRequest) .success(function(data){ - def.resolve(data); - alertService.alertMessage("Action Successful:"+uiAction,1) - + def.resolve(data); + alertService.alertMessage("Action Successful:"+uiAction,1) + }) .error(function(data){ - alertService.alertMessage("Action Failure:"+uiAction,2); - //def alertService.alertMessage("Action Successful:"+uiAction,1); - def.reject(svcAction + " not successful"); + alertService.alertMessage("Action Failure:"+uiAction,2); + //def alertService.alertMessage("Action Successful:"+uiAction,1); + def.reject(svcAction + " not successful"); + }); + + return def.promise; + }; + this.manageAction = function(modelName,typeId,typeName){ + var def = $q.defer(); + var sets = []; + + var config = { + url: "/restservices/clds/v1/clds/getDispatcherInfo", + method: "GET", + params:{model:modelName,typeId:typeId,typeName:typeName} + }; + $http(config) + .success(function(data){ + def.resolve(data); + + }) + .error(function(data){ + def.reject("manage action not successful"); }); return def.promise; + }; this.checkPermittedActionCd = function(permittedActionCd, menuText, actionCd){ - console.log("checkPermittedActionCd"); - if ( permittedActionCd.indexOf(actionCd) > -1 ) { - document.getElementById(menuText).classList.remove('ThisLink'); - } else { - document.getElementById(menuText).classList.add('ThisLink'); - } + if ( permittedActionCd.indexOf(actionCd) > -1 ) { + document.getElementById(menuText).classList.remove('ThisLink'); + } else { + document.getElementById(menuText).classList.add('ThisLink'); + } }; this.processActionResponse = function(modelName, pars){ - console.log("processActionResponse"); - // populate control name (prefix and uuid here) - var controlNamePrefix = pars.controlNamePrefix; - var controlNameUuid = pars.controlNameUuid; - - + + // populate control name (prefix and uuid here) + var controlNamePrefix = pars.controlNamePrefix; + var controlNameUuid = pars.controlNameUuid; + deploymentId = pars.deploymentId; + var modelEventService = pars.modelEventService; + typeID = pars.typeId; - var headerText = "Closed Loop Modeler - " + modelName; + var headerText = "Closed Loop Modeler - " + modelName; if ( controlNameUuid != null ) { - var actionCd = pars.event.actionCd; - var actionStateCd = pars.event.actionStateCd; - //headerText = headerText + " [" + controlNamePrefix + controlNameUuid + "] [" + actionCd + ":" + actionStateCd + "]"; - headerText = headerText + " [" + controlNamePrefix + controlNameUuid + "]"; - console.log("MINA PARS TEST " + headerText + " ----- " + controlNamePrefix + " ----- " + controlNameUuid + " ----- " + pars); + var actionCd = pars.event.actionCd; + var actionStateCd = pars.event.actionStateCd; + //headerText = headerText + " [" + controlNamePrefix + controlNameUuid + "] [" + actionCd + ":" + actionStateCd + "]"; + headerText = headerText + " [" + controlNamePrefix + controlNameUuid + "]"; } - - document.getElementById("modeler_name").textContent = headerText; - setStatus(pars) - disableBPMNAddSVG(pars); + + document.getElementById("modeler_name").textContent = headerText; + document.getElementById("templa_name").textContent = ("Template Used - " + selected_template); + setStatus(pars) + disableBPMNAddSVG(pars); this.enableDisableMenuOptions(pars); - - + + }; this.processRefresh=function(pars){ - console.log("processRefresh"); - setStatus(pars); + typeID = pars.typeId; + deploymentId = pars.deploymentId; + setStatus(pars); + this.enableDisableMenuOptions(pars); } function setStatus(pars){ - console.log("setStatus"); - var status = pars.status; - // apply color to status - var statusColor='white'; - if(status.trim()==="DESIGN"){ - statusColor='gray' - } else if(status.trim()==="DISTRIBUTED"){ - statusColor='blue' - } else if(status.trim()==="ACTIVE"){ - statusColor='green' - } else if(status.trim()==="STOPPED"){ - statusColor='red' - } else if(status.trim()==="DELETING"){ - statusColor='pink' - } else if(status.trim()==="ERROR"){ - statusColor='orange' - } else if(status.trim()==="UNKNOWN"){ - statusColor='blue' - } else{ - statusColor=null; - } - + + var status = pars.status; + // apply color to status + var statusColor='white'; + if(status.trim()==="DESIGN"){ + statusColor='gray' + } else if(status.trim()==="DISTRIBUTED"){ + statusColor='blue' + } else if(status.trim()==="ACTIVE"){ + statusColor='green' + } else if(status.trim()==="STOPPED"){ + statusColor='red' + } else if(status.trim()==="DELETING"){ + statusColor='pink' + } else if(status.trim()==="ERROR"){ + statusColor='orange' + } else if(status.trim()==="UNKNOWN"){ + statusColor='blue' + } else{ + statusColor=null; + } + - var statusMsg='   '+status+'   '; - // display status - if ($("#status_clds").length>=1) - $("#status_clds").remove(); - $("#activity_modeler").append('Status: '+statusMsg+''); + var statusMsg='   '+status+'   '; + // display status + if ($("#status_clds").length>=1) + $("#status_clds").remove(); + $("#activity_modeler").append('Status: '+statusMsg+''); - + } function disableBPMNAddSVG(pars){ - console.log("disableBPMNAddSVG"); - var svg=pars.imageText.substring(pars.imageText.indexOf("0) - $("#svgContainer").remove(); - $("#js-canvas").append(""+svg+""); + + var svg=pars.imageText.substring(pars.imageText.indexOf("0) + $("#svgContainer").remove(); + $("#js-canvas").append(""+svg+""); /* added code for height width viewBox */ $("#svgContainer svg").removeAttr("height"); $("#svgContainer svg").removeAttr('viewBox'); @@ -277,50 +306,74 @@ this.getASDCService = function(uuid){ $("#svgContainer svg").attr('width','100%'); $("#svgContainer svg").attr('height','100%'); - $("#svgContainer").click(function(event){ - console.log($(event.target).parent().html()) - console.log($($(event.target).parent()).attr("data-element-id")) - var name=$($(event.target).parent()).attr("data-element-id") - lastElementSelected=$($(event.target).parent()).attr("data-element-id") - checkIfElementType(name) - - }) + $("#svgContainer").click(function(event){ + //console.log($(event.target).parent().html()) + //console.log($($(event.target).parent()).attr("data-element-id")) + var name=$($(event.target).parent()).attr("data-element-id") + lastElementSelected=$($(event.target).parent()).attr("data-element-id") + checkIfElementType(name) + + }) $(".bjs-container").attr("hidden",""); } this.enableDisableMenuOptions=function(pars){ - console.log("enableDisableMenuOptions"); - var permittedActionCd = pars.permittedActionCd; - // enable menu options - document.getElementById('Save CL').classList.remove('ThisLink'); - document.getElementById('Test').classList.remove('ThisLink'); - document.getElementById('Properties CL').classList.remove('ThisLink'); - document.getElementById('Refresh Status').classList.remove('ThisLink'); - document.getElementById('Revert Model Changes').classList.remove('ThisLink'); - document.getElementById('Close Model').classList.remove('ThisLink'); - document.getElementById('Refresh ASDC').classList.remove('ThisLink'); - document.getElementById('Running Instances').classList.remove('ThisLink'); - - //disable template options for save/properties - document.getElementById('Save Template').classList.add('ThisLink'); - document.getElementById('Template Properties').classList.add('ThisLink'); - document.getElementById('Revert Template Changes').classList.add('ThisLink'); - document.getElementById('Close Template').classList.add('ThisLink'); - - - // enable/disable menu options based on permittedActionCd list - this.checkPermittedActionCd(permittedActionCd, 'Submit', 'SUBMIT'); - this.checkPermittedActionCd(permittedActionCd, 'Resubmit', 'RESUBMIT'); - this.checkPermittedActionCd(permittedActionCd, 'Update', 'UPDATE'); - this.checkPermittedActionCd(permittedActionCd, 'Delete', 'DELETE'); - this.checkPermittedActionCd(permittedActionCd, 'Stop', 'STOP'); - this.checkPermittedActionCd(permittedActionCd, 'Restart', 'RESTART'); - } + + var permittedActionCd = pars.permittedActionCd; + + //dropdown options - always true + document.getElementById('Open Template').classList.remove('ThisLink'); + document.getElementById('Open CL').classList.remove('ThisLink'); + document.getElementById('Save Template').classList.add('ThisLink'); + document.getElementById('Template Properties').classList.add('ThisLink'); + document.getElementById('Revert Template Changes').classList.add('ThisLink'); + document.getElementById('Close Template').classList.add('ThisLink'); + + if (readOnly||readMOnly){ + //enable model options + document.getElementById('Properties CL').classList.remove('ThisLink'); + document.getElementById('Close Model').classList.remove('ThisLink'); + + //disable models options + document.getElementById('Create CL').classList.add('ThisLink'); + document.getElementById('Save CL').classList.add('ThisLink'); + document.getElementById('Revert Model Changes').classList.add('ThisLink'); + } else { + // enable menu options + document.getElementById('Create CL').classList.remove('ThisLink'); + document.getElementById('Save CL').classList.remove('ThisLink'); + document.getElementById('Properties CL').classList.remove('ThisLink'); + document.getElementById('Revert Model Changes').classList.remove('ThisLink'); + document.getElementById('Close Model').classList.remove('ThisLink'); + + + document.getElementById('Validation Test').classList.remove('ThisLink'); + document.getElementById('Refresh Status').classList.remove('ThisLink'); + document.getElementById('Refresh ASDC').classList.remove('ThisLink'); + } + if (readTOnly){ + document.getElementById('Create Template').classList.add('ThisLink'); + } else { + document.getElementById('Create Template').classList.remove('ThisLink'); + } + + // enable/disable menu options based on permittedActionCd list + this.checkPermittedActionCd(permittedActionCd, 'Validation Test', 'TEST'); + this.checkPermittedActionCd(permittedActionCd, 'Submit', 'SUBMIT'); + this.checkPermittedActionCd(permittedActionCd, 'Resubmit', 'RESUBMIT'); + this.checkPermittedActionCd(permittedActionCd, 'Update', 'UPDATE'); + this.checkPermittedActionCd(permittedActionCd, 'Stop', 'STOP'); + this.checkPermittedActionCd(permittedActionCd, 'Restart', 'RESTART'); + this.checkPermittedActionCd(permittedActionCd, 'Delete', 'DELETE'); + this.checkPermittedActionCd(permittedActionCd, 'Deploy', 'DEPLOY'); + this.checkPermittedActionCd(permittedActionCd, 'UnDeploy', 'UNDEPLOY'); + + } this.getASDCServices().then(function(pars){ - console.log("getASDCServices"); - var services=pars.service; - asdc_Services=services + + var services=pars.service; + asdc_Services=services }); }]); diff --git a/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js index d58dcb923..f31d72e53 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js @@ -20,11 +20,10 @@ * =================================================================== * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - app.controller('CldsOpenModelCtrl', ['$scope', '$rootScope', '$modalInstance','cldsModelService', '$location', 'dialogs','cldsTemplateService', function($scope, $rootScope, $modalInstance, cldsModelService, $location,dialogs,cldsTemplateService) { - console.log("/////////CldsOpenModelCtrl"); + $scope.typeModel='template'; $scope.error = { flag : false, @@ -38,7 +37,6 @@ app.controller('CldsOpenModelCtrl', $scope.modelNamel.push(pars[i].value); } setTimeout(function(){ - console.log("setTimeout"); setMultiSelect(); }, 100); @@ -69,7 +67,6 @@ app.controller('CldsOpenModelCtrl', } } $scope.refreshASDC=function(){ - console.log("refreshASDC"); $("#ridinSpinners").css("display","") var bool=loadSharedPropertyByService(undefined,true,callBack); $("#ridinSpinners").css("display","none"); @@ -78,17 +75,15 @@ app.controller('CldsOpenModelCtrl', } cldsTemplateService.getSavedTemplate().then(function(pars) { - - $scope.templateNamel=[] for(var i=0;i0 ? a.length : 0; while (i--) { if (a[i].toLowerCase() === obj.toLowerCase()) { @@ -98,7 +93,6 @@ app.controller('CldsOpenModelCtrl', return false; } $scope.checkExisting=function(){ - console.log("checkExisting"); var name = $('#modelName').val(); if(contains($scope.modelNamel,name)){ $scope.nameinUse=true; @@ -108,7 +102,6 @@ app.controller('CldsOpenModelCtrl', specialCharacters(); } function specialCharacters (){ - console.log("specialCharacters"); $scope.spcl = false; if(angular.element("#modelName") && angular.element("#modelName").scope().model.$error.pattern && @@ -119,23 +112,18 @@ app.controller('CldsOpenModelCtrl', $scope.setTypeModel=function(_type){ $scope.error.flag = false; - console.log("setTypeModel"); $scope.typeModel=_type; } $scope.close = function(){ - console.log("close"); $rootScope.isNewClosed = false; $modalInstance.close("closed"); }; $scope.createNewModelOffTemplate=function(formModel){ - console.log("createNewModelOffTemplate"); - console.log(formModel); reloadDefaultVariables(false) var modelName = document.getElementById("modelName").value; var templateName=document.getElementById("templateName").value; - console.log("openModel: modelName=" + modelName); - console.log("Template: templateName=" + templateName); + if(!modelName){ $scope.error.flag =true; $scope.error.message = "Please enter any closed template name for proceeding"; @@ -155,20 +143,24 @@ app.controller('CldsOpenModelCtrl', cldsTemplateService.getTemplate( templateName ).then(function(pars) { - console.log("openModel: pars=" + pars); var tempImageText=pars.imageText var bpmnText=pars.bpmnText + var authorizedToUp = pars.userAuthorizedToUpdate; pars={} pars.imageText=tempImageText pars.status= "DESIGN"; - pars.permittedActionCd= ["SUBMIT"]; - cldsModelService.processActionResponse(modelName, pars); - + if (readOnly || readMOnly){ + pars.permittedActionCd=[""]; + } else { + pars.permittedActionCd=["TEST", "SUBMIT"]; + } selected_template= templateName selected_model = modelName; + + cldsModelService.processActionResponse(modelName, pars); // set model bpmn and open diagram $rootScope.isPalette = true; @@ -178,17 +170,16 @@ app.controller('CldsOpenModelCtrl', function(data) { //alert("getModel failed"); }); - + allPolicies = {}; + elementMap = {}; $modalInstance.close("closed"); } $scope.cloneModel=function(){ - console.log("cloneModel"); reloadDefaultVariables(false) var modelName = document.getElementById("modelName").value; var originalModel=document.getElementById("modelList").value; - console.log("openModel: modelName=" + modelName); if(!modelName){ $scope.error.flag =true; $scope.error.message = "Please enter any name for proceeding"; @@ -209,7 +200,6 @@ app.controller('CldsOpenModelCtrl', cldsModelService.getModel( originalModel ).then(function(pars) { - console.log("openModel: pars=" + pars); // process data returned var bpmnText = pars.bpmnText; @@ -218,15 +208,26 @@ app.controller('CldsOpenModelCtrl', var controlNamePrefix = pars.controlNamePrefix; var controlNameUuid = pars.controlNameUuid; selected_template=pars.templateName; + typeID = pars.typeId; pars.status="DESIGN"; + if (readOnly || readMOnly){ + pars.permittedActionCd=[""]; + } else { + pars.permittedActionCd=["TEST", "SUBMIT"]; + } pars.controlNameUuid=""; + modelEventService = pars.event; + //actionCd = pars.event.actionCd; + actionStateCd = pars.event.actionStateCd; + deploymentId = pars.deploymentId; + + var authorizedToUp = pars.userAuthorizedToUpdate; + cldsModelService.processActionResponse(modelName, pars); // deserialize model properties if ( propText == null ) { - console.log("openModel: propText is null"); } else { - console.log("openModel: propText=" + propText); elementMap = JSON.parse(propText); } @@ -244,10 +245,8 @@ app.controller('CldsOpenModelCtrl', $modalInstance.close("closed"); } $scope.createNewModel=function(){ - console.log("createNewModel"); reloadDefaultVariables(false) - var modelName = document.getElementById("modelName").value; - console.log("openModel: modelName=" + modelName); + var modelName = document.getElementById("modelName").value; // BEGIN env // init UTM items @@ -263,7 +262,7 @@ app.controller('CldsOpenModelCtrl', $rootScope.utmModels = utmModels; // enable appropriate menu options - var pars = {status: "DESIGN", permittedActionCd: ["SUBMIT"]}; + var pars = {status: "DESIGN"}; cldsModelService.processActionResponse(modelName, pars); @@ -297,21 +296,14 @@ app.controller('CldsOpenModelCtrl', $modalInstance.close("closed"); } $scope.revertChanges=function(){ - console.log("revertChanges"); $scope.openModel(); } $scope.openModel = function(){ - console.log("openModel"); reloadDefaultVariables(false) - var readonly; if(document.getElementById("readOnly")){ - readOnly=document.getElementById("readOnly").checked; + readOnly=document.getElementById("readOnly").checked; } - - console.log("readonly seen ") - console.log(readOnly) - var modelName = document.getElementById("modelName").value; - console.log("openModel: modelName=" + modelName); + var modelName = document.getElementById("modelName").value; // init UTM items $scope.utmModelsArray = []; @@ -325,24 +317,30 @@ app.controller('CldsOpenModelCtrl', utmModels.subModels = []; $rootScope.utmModels = utmModels; - cldsModelService.getModel( modelName ).then(function(pars) { - console.log("openModel: pars=" + pars); - console.log(pars) // process data returned var bpmnText = pars.bpmnText; var propText = pars.propText; var status = pars.status; - var controlNamePrefix = pars.controlNamePrefix; - var controlNameUuid = pars.controlNameUuid; - selected_template=pars.templateName + controlNamePrefix = pars.controlNamePrefix; + // var controlNameUuid = pars.controlNameUuid; + var authorizedToUp = pars.userAuthorizedToUpdate; + typeID = pars.typeId; + controlNameUuid = pars.controlNameUuid; + selected_template=pars.templateName; + modelEventService = pars.event; + //actionCd = pars.event.actionCd; + actionStateCd = pars.event.actionStateCd; + deploymentId = pars.deploymentId; + + if (readMOnly || readOnly){ + pars.permittedActionCd= [""]; + } cldsModelService.processActionResponse(modelName, pars); // deserialize model properties if ( propText == null ) { - console.log("openModel: propText is null"); } else { - console.log("openModel: propText=" + propText); elementMap = JSON.parse(propText); } @@ -363,4 +361,4 @@ app.controller('CldsOpenModelCtrl', setMultiSelect(); } ] -); +); \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/designer/scripts/CldsOpenTemplateCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/CldsOpenTemplateCtrl.js index bde63c912..32eb5c6aa 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/CldsOpenTemplateCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/CldsOpenTemplateCtrl.js @@ -20,11 +20,10 @@ * =================================================================== * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - app.controller('CldsOpenTemplateCtrl', ['$scope', '$rootScope', '$modalInstance','$window','cldsTemplateService', '$location', 'dialogs', function($scope, $rootScope, $modalInstance,$window, cldsTemplateService, $location,dialogs) { - console.log("////////////CldsOpenTemplateCtrl"); + $scope.error = { flag : false, message: "" @@ -39,14 +38,14 @@ app.controller('CldsOpenTemplateCtrl', //console.log($scope.modelNamel[i]) } setTimeout(function(){ - console.log("setTimeout"); + setMultiSelect(); }, 100); }); function contains(a, obj) { - console.log("contains"); + var i = a.length; while (i--) { if (a[i].toLowerCase() === obj.toLowerCase()) { @@ -56,7 +55,7 @@ app.controller('CldsOpenTemplateCtrl', return false; } $scope.checkExisting=function(){ - console.log("checkExisting"); + var name = $('#modelName').val(); //alert(name) //console.log($scope.modelNamel) @@ -69,14 +68,14 @@ app.controller('CldsOpenTemplateCtrl', } $scope.closeDiagram=function(){ - console.log("closeDiagram"); + $window.location.reload(); } $scope.createNewTemplate=function(){ - console.log("createNewTemplate"); + reloadDefaultVariables(true) if($(".bjs-container").is("[hidden]")){ $(".bjs-container").removeAttr("hidden"); @@ -87,9 +86,7 @@ app.controller('CldsOpenTemplateCtrl', $scope.error.flag =true; $scope.error.message = "Please enter any name for proceeding"; return false; - } - - console.log("openModel: modelName=" + modelName); + } // BEGIN env // init UTM items @@ -112,6 +109,7 @@ app.controller('CldsOpenTemplateCtrl', pars.event={} pars.event.actionStateCD="" pars.newTemplate = true + pars.permittedActionCd= [""]; cldsTemplateService.processActionResponse(modelName, pars); selected_model = modelName; @@ -145,23 +143,22 @@ app.controller('CldsOpenTemplateCtrl', } $scope.revertChanges=function(){ - console.log("revertChanges"); + $scope.openTemplate(); } $scope.close=function(){ - console.log("close"); + $rootScope.isNew = false; $modalInstance.close("closed"); } $scope.openTemplate = function() { - console.log("openTemplate"); + reloadDefaultVariables(true) if($(".bjs-container").is("[hidden]")){ $(".bjs-container").removeAttr("hidden"); $("#svgContainer").remove(); } var modelName = document.getElementById("modelName").value; - console.log("openModel: modelName=" + modelName); if($scope.modelNamel.includes(document.getElementById("modelName").value)){ } @@ -180,24 +177,19 @@ app.controller('CldsOpenTemplateCtrl', cldsTemplateService.getTemplate( modelName ).then(function(pars) { - console.log("openModel: pars="); - console.log(pars) // process data returned var bpmnText = pars.bpmnText; var propText = pars.propText; var status = pars.status; var controlNamePrefix = pars.controlNamePrefix; var controlNameUuid = pars.controlNameUuid; - + var authorizedToUp = pars.userAuthorizedToUpdate; + pars.permittedActionCd= [""]; cldsTemplateService.processActionResponse(modelName, pars); // deserialize model properties - console.log("prop text") - console.log(propText) if ( propText == null ) { - console.log("openModel: propText is null"); } else { - console.log("openModel: propText=" + propText); elementMap = JSON.parse(propText); } @@ -209,7 +201,7 @@ app.controller('CldsOpenTemplateCtrl', visibility_model(); }, function(data) { - console.log("data"); + //console.log("data"); //alert("getModel failed"); }); @@ -218,4 +210,4 @@ app.controller('CldsOpenTemplateCtrl', } ] -); +); \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/designer/scripts/CldsTemplateService.js b/src/main/resources/META-INF/resources/designer/scripts/CldsTemplateService.js index 3d4313864..a9ad8a3bb 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/CldsTemplateService.js +++ b/src/main/resources/META-INF/resources/designer/scripts/CldsTemplateService.js @@ -24,7 +24,7 @@ app.service('cldsTemplateService', ['alertService', '$http', '$q', function (alertService, $http, $q) { this.getTemplate = function(templateName){ - console.log("///////////////cldsTemplateService"); + var def = $q.defer(); var sets = []; @@ -32,19 +32,19 @@ app.service('cldsTemplateService', ['alertService', '$http', '$q', function (ale $http.get(svcUrl) .success(function(data){ - console.log("success"); + def.resolve(data); }) .error(function(data){ - console.log("error"); + def.reject("Open Model not successful"); }); return def.promise; }; this.getSavedTemplate=function(){ - console.log("getSavedTemplate"); + var def = $q.defer(); var sets = []; @@ -52,12 +52,12 @@ app.service('cldsTemplateService', ['alertService', '$http', '$q', function (ale $http.get(svcUrl) .success(function(data){ - console.log("success"); + def.resolve(data); }) .error(function(data){ - console.log("error"); + def.reject("Open Model not successful"); }); @@ -65,7 +65,7 @@ app.service('cldsTemplateService', ['alertService', '$http', '$q', function (ale }; this.setTemplate = function(templateName, controlNamePrefixIn, bpmnTextIn, propTextIn){ - console.log("setTemplate"); + var def = $q.defer(); var sets = []; @@ -75,12 +75,12 @@ app.service('cldsTemplateService', ['alertService', '$http', '$q', function (ale $http.put(svcUrl, svcRequest) .success(function(data){ - console.log("success"); + def.resolve(data); }) .error(function(data){ - console.log("error"); + def.reject("Save Model not successful"); }); @@ -88,23 +88,21 @@ app.service('cldsTemplateService', ['alertService', '$http', '$q', function (ale }; this.processAction = function(uiAction, templateName, controlNamePrefixIn, bpmnTextIn, propTextIn,svgXmlIn){ - console.log("processAction"); + var def = $q.defer(); var sets = []; - console.log("Generated SVG xml File..."); - console.log(propTextIn); var svcUrl = "/restservices/clds/v1/cldsTempate/template/"+templateName; var svcRequest = {name: templateName, controlNamePrefix: controlNamePrefixIn, bpmnText: bpmnTextIn, propText: propTextIn, imageText:svgXmlIn}; $http.put(svcUrl, svcRequest) .success(function(data){ - console.log("success"); + def.resolve(data); alertService.alertMessage("Action Successful:"+uiAction,1) }) .error(function(data){ - console.log("error"); + def.reject(" not successful"); alertService.alertMessage("Action Failure:"+uiAction,2) @@ -113,7 +111,7 @@ app.service('cldsTemplateService', ['alertService', '$http', '$q', function (ale return def.promise; }; this.checkPermittedActionCd = function(permittedActionCd, menuText, actionCd){ - console.log("checkPermittedActionCd"); + if ( permittedActionCd.indexOf(actionCd) > -1 ) { document.getElementById(menuText).classList.remove('ThisLink'); } else { @@ -121,10 +119,11 @@ app.service('cldsTemplateService', ['alertService', '$http', '$q', function (ale } }; this.processActionResponse = function(templateName, pars){ - console.log("processActionResponse"); + // populate control name (prefix and uuid here) var controlNamePrefix = pars.controlNamePrefix; var controlNameUuid = pars.controlNameUuid; + var permittedActionCd = pars.permittedActionCd; var headerText = "Closed Loop Modeler - " + templateName; if ( controlNameUuid != null ) { @@ -136,25 +135,61 @@ app.service('cldsTemplateService', ['alertService', '$http', '$q', function (ale document.getElementById("modeler_name").textContent = headerText; - - // enable menu options - document.getElementById('Save Template').classList.remove('ThisLink'); - document.getElementById('Template Properties').classList.remove('ThisLink'); - document.getElementById('Test').classList.remove('ThisLink'); - if(!pars.newTemplate){ - document.getElementById('Revert Template Changes').classList.remove('ThisLink'); - } - document.getElementById('Close Template').classList.remove('ThisLink'); - - document.getElementById('Refresh Status').classList.remove('ThisLink'); - //disable save/properties for model + //dropdown options -- always true + document.getElementById('Open Template').classList.remove('ThisLink'); + document.getElementById('Open CL').classList.remove('ThisLink'); document.getElementById('Save CL').classList.add('ThisLink'); document.getElementById('Properties CL').classList.add('ThisLink'); document.getElementById('Revert Model Changes').classList.add('ThisLink'); document.getElementById('Close Model').classList.add('ThisLink'); - document.getElementById('Refresh ASDC').classList.add('ThisLink'); - document.getElementById('Running Instances').classList.add('ThisLink'); + + // enable menu options + if (readTOnly){ + //enable temp options (read only, Open Template) + document.getElementById('Template Properties').classList.remove('ThisLink'); + document.getElementById('Close Template').classList.remove('ThisLink'); + + //disable temp menu options (read only, Open Template) + document.getElementById('Create Template').classList.add('ThisLink'); + document.getElementById('Save Template').classList.add('ThisLink'); + document.getElementById('Revert Template Changes').classList.add('ThisLink'); + + //disable save/properties for model + document.getElementById('Refresh ASDC').classList.add('ThisLink'); + } else { + //enable temp options + document.getElementById('Create Template').classList.remove('ThisLink'); + document.getElementById('Save Template').classList.remove('ThisLink'); + document.getElementById('Template Properties').classList.remove('ThisLink'); + document.getElementById('Validation Test').classList.remove('ThisLink'); + if(!pars.newTemplate){ + document.getElementById('Revert Template Changes').classList.remove('ThisLink'); + } + document.getElementById('Close Template').classList.remove('ThisLink'); + + document.getElementById('Refresh Status').classList.remove('ThisLink'); + + //disable model options + document.getElementById('Refresh ASDC').classList.add('ThisLink'); + + + } + if (readMOnly){ + document.getElementById('Create CL').classList.add('ThisLink'); + } else { + document.getElementById('Create CL').classList.remove('ThisLink'); + } + + // enable/disable menu options based on permittedActionCd list + this.checkPermittedActionCd(permittedActionCd, 'Validation Test', 'TEST'); + this.checkPermittedActionCd(permittedActionCd, 'Submit', 'SUBMIT'); + this.checkPermittedActionCd(permittedActionCd, 'Resubmit', 'RESUBMIT'); + this.checkPermittedActionCd(permittedActionCd, 'Update', 'UPDATE'); + this.checkPermittedActionCd(permittedActionCd, 'Stop', 'STOP'); + this.checkPermittedActionCd(permittedActionCd, 'Restart', 'RESTART'); + this.checkPermittedActionCd(permittedActionCd, 'Delete', 'DELETE'); + this.checkPermittedActionCd(permittedActionCd, 'Deploy', 'DEPLOY'); + this.checkPermittedActionCd(permittedActionCd, 'UnDeploy', 'UNDEPLOY'); - }; }]); diff --git a/src/main/resources/META-INF/resources/designer/scripts/DashboardCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/DashboardCtrl.js index 0fdf5db5c..9a0656a10 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/DashboardCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/DashboardCtrl.js @@ -46,8 +46,9 @@ function DashboardCtrl($scope,$rootScope,$resource, $http, $timeout, $location, $interval( function(){ - console.log("interval"); - AutosaveProject($scope,$rootScope,$resource, $http, $timeout, $location, $interval, $q, Datafactory); + console.log("interval"); + /*AutosaveProject($scope,$rootScope,$resource, $http, $timeout, $location, $interval, + $q, Datafactory);*/ }, $scope.autosaveInterval); @@ -605,68 +606,6 @@ function DashboardCtrl($scope,$rootScope,$resource, $http, $timeout, $location, }; - $rootScope.populateUTMModelArray= function(utm_models,utmModels){ - console.log("populateUTMModelArray"); - var modelName =utmModels.name; - if (utmModels != null && utmModels.name != null) { - if($rootScope.oldUTMModels != null && $rootScope.oldUTMModels.length > 0){ - for(var i=0 ;i<$rootScope.oldUTMModels.length;i++ ){ - var tempOldName = $rootScope.oldUTMModels[i]; - console.log("new model name from map:"+old_new_model_name[tempOldName]); - if( utmModels.name == old_new_model_name[tempOldName]){ - modelName = $rootScope.oldUTMModels[i]; - } - } - } - var utm_model = {}; - utm_model.modelName = utmModels.name; - utm_model.modelXML = list_models[modelName]; - utm_model.repeatableHeirachicalSchemaElements = {}; - utm_model.repeatableHeirachicalSchemaElements = list_model_repeatable_heirarchical_elements[modelName]; - - utm_model.testManagementDetails = {}; - utm_model.testManagementDetails = list_model_test_management_details[modelName]; - - var activitytestset={}; - activitytestset.invalidModelException=null; - activitytestset.serviceName=serviceName; - activitytestset.activityTestCases=[]; - if (list_model_test_sets[modelName] != null && list_model_test_sets[modelName].activityTestCases != null) { - activitytestset.activityTestCases=angular.copy(list_model_test_sets[modelName].activityTestCases); - } - utm_model.activityTestSet = activitytestset; - - utm_model.utmPropertyExplorer = {}; - utm_model.utmPropertyExplorer.pathDetailsList = []; - if (list_model_path_details[modelName] != null) { - utm_model.utmPropertyExplorer.pathDetailsList = angular.copy(list_model_path_details[modelName]); - } - - utm_model.utmModelSchemaExtention = {}; - utm_model.utmModelSchemaExtention.utmSchemaExtentionMap = {}; - if (list_model_schema_extensions[modelName] != null) { - utm_model.utmModelSchemaExtention = angular.copy(list_model_schema_extensions[modelName]); - } - - utm_models.push(utm_model); - if(utmModels.subModels != null && utmModels.subModels.length>0){ - for(var i=0 ; i