2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
28 [ 'ngRoute', 'ngResource', 'ui.bootstrap', 'angular-loading-bar', 'ngAnimate',
29 'dialogs.main', 'ngSanitize', 'ngCookies', 'ui.bootstrap.modal' ])
30 .config([ 'cfpLoadingBarProvider', function(cfpLoadingBarProvider) {
32 cfpLoadingBarProvider.includeBar = true;
33 cfpLoadingBarProvider.includeSpinner = true;
35 .config(function($httpProvider) {
37 $httpProvider.interceptors.push('myHttpInterceptor');
38 var spinnerFunction = function spinnerFunction(data, headersGetter) {
42 $httpProvider.defaults.transformRequest.push(spinnerFunction);
49 'cfpLoadingBarProvider',
50 function($routeProvider, $locationProvider, cfpLoadingBarProvider,
51 $timeout, dialogs, $cookies) {
53 $locationProvider.html5Mode(false);
54 $routeProvider.when('/otherwise', {
55 templateUrl : 'please_wait.html',
56 controller : 'QueryParamsHandlerCtrl'
57 }).when('/dashboard', {
58 templateUrl : 'partials/portfolios/clds_modelling.html',
59 controller : 'DashboardCtrl'
60 }).when('/activity_modelling', {
61 templateUrl : 'partials/portfolios/clds_modelling.html',
62 controller : 'DashboardCtrl'
63 }).when('/authenticate', {
64 templateUrl : 'authenticate.html',
65 controller : 'AuthenticateCtrl'
66 }).when('/invalidlogin', {
67 templateUrl : 'invalid_login.html',
68 controller : 'PageUnderConstructionCtrl'
70 redirectTo : '/otherwise'
75 function($scope, $rootScope, $timeout, dialogs) {
78 $scope.lang = 'en-US';
79 $scope.language = 'English';
82 $scope.confirmed = 'No confirmation yet!';
86 // -- Listeners & Watchers --//
87 $scope.$watch('lang', function(val, old) {
91 $scope.language = 'English';
94 $scope.language = 'Spanish';
99 $rootScope.testCaseRequirements = [];
100 $rootScope.validTestRequirements = [];
101 $scope.setLanguage = function(lang) {
104 $translate.use(lang);
106 $rootScope.launch = function(which) {
120 var dlg = dialogs.confirm();
121 dlg.result.then(function(btn) {
123 $scope.confirmed = 'You confirmed "Yes."';
126 $scope.confirmed = 'You confirmed "No."';
130 var dlg = dialogs.create('/dialogs/custom.html',
131 'customDialogCtrl', {}, {
135 windowClass : 'my-class'
137 dlg.result.then(function(name) {
142 if (angular.equals($scope.name, ''))
143 $scope.name = 'You did not enter in your name!';
147 var dlg = dialogs.create('/dialogs/custom2.html',
148 'customDialogCtrl2', $scope.custom, {
156 'All is not supported, Please select interface(s)/version(s) to fetch real time federated coverage report.');
162 'You are about to fetch real time federated coverage report.This may take sometime!!!.');
163 dlg.result.then(function(btn) {
165 $scope.confirmed = 'You confirmed "Yes."';
168 $scope.confirmed = 'You confirmed "No."';
172 var dlg = dialogs.notify('Success',
173 'Request has been successfully processed.');
176 var dlg = dialogs.notify('Message',
177 'Please type Testscenario Name');
181 var _fakeWaitProgress = function() {
183 $timeout(function() {
185 if (_progress < 100) {
187 $rootScope.$broadcast('dialogs.wait.progress', {
188 'progress' : _progress
192 $rootScope.$broadcast('dialogs.wait.complete');
208 'userPreferencesService',
210 'extraUserInfoService',
211 function($scope, $rootScope, $timeout, dialogs, $location, MenuService,
212 Datafactory, userPreferencesService, cldsModelService,
213 extraUserInfoService) {
215 console.log("MenuCtrl");
216 $rootScope.screenName = "Universal Test Modeler";
217 $rootScope.testSet = null;
218 var testingType = "";
219 $rootScope.contactUs = function() {
221 console.log("contactUs");
222 var link = "mailto:onap-discuss@lists.onap.org?subject=CLAMP&body=Please send us suggestions or feature enhancements or defect. If possible, please send us the steps to replicate any defect.";
223 window.location.href = link;
225 extraUserInfoService.getUserInfo().then(function(pars) {
227 $scope.userInfo = pars;
228 if (!($scope.userInfo["permissionUpdateCl"])) {
233 $scope.emptyMenuClick = function(value, name) {
235 if ($rootScope.isNewClosed
236 && name != "Close Model" && name != "Properties CL") {
237 saveConfirmationNotificationPopUp();
241 function saveConfirmationNotificationPopUp() {
243 $scope.saveConfirmationNotificationPopUp(function(data) {
246 $rootScope.isNewClosed = false;
252 function isSaveCheck(name) {
254 if (name == "User Info") {
255 $scope.extraUserInfo();
256 } else if (name == "Wiki") {
258 } else if (name == "Contact Us") {
259 $rootScope.contactUs();
260 } else if (name == "Close Model") {
262 } else if (name == "Open CL") {
263 $scope.cldsOpenModel();
264 } else if (name == "Submit") {
265 $scope.cldsConfirmPerformAction("SUBMIT");
266 } else if (name == "Update") {
267 $scope.cldsConfirmPerformAction("UPDATE");
268 } else if (name == "Delete") {
269 $scope.cldsConfirmPerformAction("DELETE");
270 } else if (name == "Stop") {
271 $scope.cldsConfirmPerformAction("STOP");
272 } else if (name == "Restart") {
273 $scope.cldsConfirmPerformAction("RESTART");
274 } else if (name == "Refresh Status") {
275 $scope.refreshStatus();
276 } else if (name == "Properties CL") {
277 $scope.cldsOpenModelProperties();
278 } else if (name == "Deploy") {
279 $scope.cldsAskDeployParametersPerformAction();
280 } else if (name == "UnDeploy") {
281 $scope.cldsConfirmToggleDeployPerformAction("UnDeploy");
283 $rootScope.screenName = name;
284 $scope.updatebreadcrumb(value);
285 $location.path(value);
289 $rootScope.impAlerts = function() {
294 link : "/cldsOpenModel",
297 link : "/cldsOpenModelProperties",
298 name : "Properties CL"
304 link : "/cldsSubmit",
307 // disabled for Dublin since Policy doesn't support updating in this release
308 // link : "/cldsUpdate",
314 link : "/cldsRestart",
317 link : "/cldsDelete",
320 link : "/cldsDeploy",
323 link : "/cldsUnDeploy",
327 link : "/refreshStatus",
328 name : "Refresh Status"
331 link : "http://wiki.onap.org",
334 link : "/contact_us",
337 link : "/extraUserInfo",
342 Object.keys = function(obj) {
345 for ( var i in obj) {
346 if (obj.hasOwnProperty(i)) {
352 $scope.keyList = Object.keys($scope.tabs);
354 $scope.keyList = Object.keys($scope.tabs);
356 $scope.updatebreadcrumb = function(path) {
358 var currentURL = $location.path();
359 if (path != undefined) {
362 if (currentURL == "/dashboard") {
363 $rootScope.screenName = "Universal Test Modeler";
364 $rootScope.parentMenu = "Home";
365 $rootScope.rightTabName = "UTM Build Configuration";
368 angular.forEach($scope.keyList, function(value, key) {
371 $rootScope.parentMenu = value;
372 angular.forEach($scope.tabs[value],
373 function(value, key) {
375 if (currentURL == value.link) {
376 $rootScope.screenName = value.name;
384 $scope.updatebreadcrumb();
385 $scope.homePage = function() {
387 $location.path('/dashboard');
389 $scope.propertyExplorerErrorMessage = function(msg) {
391 var dlg = dialogs.notify('Error', msg);
393 $scope.reviewTestSet = function() {
395 $rootScope.modeltestset = list_model_test_sets[selected_model];
396 $rootScope.isPalette = false;
397 $rootScope.isTestset = true;
398 $rootScope.isRequirementCoverage = false;
399 document.getElementById("modeler_name").textContent = "UTM Test Set";
400 $('div').find('.k-collapse-next').click();
402 $scope.requirementCoverage = function() {
404 $rootScope.testCaseRequirements = [];
405 $rootScope.validTestRequirementArray = [];
406 $rootScope.validTestRequirements = {};
407 $rootScope.modeltestset = list_model_test_sets[selected_model];
408 var allPathDetails = [];
409 $scope.currentSelectedModel = {};
410 $rootScope.pathDetailsList = list_model_path_details[selected_model];
411 for (var x = 0; x < allPathDetails.length; x++) {
412 var tempPathDetails = allPathDetails[x];
413 if (tempPathDetails != null) {
414 for (var i = 0; i < tempPathDetails.length; i++) {
415 var pathDetails = tempPathDetails[i];
416 if (pathDetails.requirement !== ''
417 && pathDetails.requirement !== null) {
418 $rootScope.testCaseRequirements
419 .push(pathDetails.requirement);
424 for (var p = 0; p < $rootScope.modeltestset.activityTestCases.length; p++) {
425 var activityTestCases = $rootScope.modeltestset.activityTestCases[p];
426 if (activityTestCases.mappedRequirements != null) {
427 for (var i = 0; i < activityTestCases.mappedRequirements.length; i++) {
428 var testCaseNames = $rootScope.validTestRequirements[activityTestCases.mappedRequirements[i]];
429 if (testCaseNames == null) {
432 if (activityTestCases.version != null)
433 var testCase = activityTestCases.testCaseName + "_"
434 + activityTestCases.version;
436 var testCase = activityTestCases.testCaseName;
437 testCaseNames.push(testCase);
438 $rootScope.validTestRequirements[activityTestCases.mappedRequirements[i]] = testCaseNames;
442 $rootScope.isPalette = false;
443 $rootScope.isTestset = false;
444 $rootScope.isRequirementCoverage = true;
445 document.getElementById("modeler_name").textContent = "Test Case / Requirement Coverage";
446 $('div').find('.k-collapse-next').click();
448 $scope.activityModelling = function() {
451 $scope.cldsClose = function() {
453 var dlg = dialogs.create(
454 'partials/portfolios/confirmation_window.html',
455 'CldsOpenModelCtrl', {
462 windowClass : 'my-class'
464 dlg.result.then(function(name) {
466 // $scope.name = name;
469 // if(angular.equals($scope.name,''))
470 // $scope.name = 'You did not enter in your
474 $scope.saveConfirmationNotificationPopUp = function(callBack) {
476 var dlg = dialogs.create(
477 'partials/portfolios/save_confirmation.html',
478 'saveConfirmationModalPopUpCtrl', {
485 windowClass : 'my-class'
487 dlg.result.then(function(name) {
495 $rootScope.cldsOpenModelProperties = function() {
497 var dlg = dialogs.create(
498 'partials/portfolios/global_properties.html',
499 'GlobalPropertiesCtrl', {}, {
503 windowClass : 'my-class'
505 dlg.result.then(function(name) {
511 $scope.cldsOpenModel = function() {
513 var dlg = dialogs.create(
514 'partials/portfolios/clds_open_model.html', 'CldsOpenModelCtrl', {
521 windowClass : 'my-class'
523 dlg.result.then(function(name) {
529 $scope.extraUserInfo = function() {
531 var dlg = dialogs.create(
532 'partials/portfolios/extra_user_info.html', 'ExtraUserInfoCtrl', {
539 windowClass : 'my-class'
541 dlg.result.then(function(name) {
547 $scope.cldsPerformAction = function(uiAction) {
549 var modelName = selected_model;
550 var controlNamePrefix = "ClosedLoop-";
551 var bpmnText = modelXML;
552 // serialize model properties
553 var propText = JSON.stringify(elementMap);
554 var templateName = selected_template
555 var svgXml = $("#svgContainer").html();
556 console.log("cldsPerformAction: " + uiAction + " modelName="
558 console.log("cldsPerformAction: " + uiAction
559 + " controlNamePrefix=" + controlNamePrefix);
560 console.log("cldsPerformAction: " + uiAction + " bpmnText="
562 console.log("cldsPerformAction: " + uiAction + " propText="
564 console.log("cldsPerformAction: " + uiAction + " typeID=" + typeID);
565 console.log("cldsPerformAction: " + uiAction + " deploymentId="
567 cldsModelService.processAction(uiAction, modelName,
568 controlNamePrefix, bpmnText, propText, svgXml, templateName,
569 typeID, deploymentId).then(function(pars) {
571 console.log("cldsPerformAction: pars=" + pars);
572 cldsModelService.processRefresh(pars);
577 $scope.refreshStatus = function() {
579 var modelName = selected_model;
580 var svgXml = $("#svgContainer").html();
581 console.log("refreStatus modelName=" + modelName);
582 cldsModelService.getModel(modelName).then(function(pars) {
584 console.log("refreStatus: pars=" + pars);
585 cldsModelService.processRefresh(pars);
590 $scope.cldsConfirmPerformAction = function(uiAction) {
592 var dlg = dialogs.confirm('Message', 'Do you want to '
593 + uiAction.toLowerCase() + ' the closed loop?');
594 dlg.result.then(function(btn) {
596 $scope.cldsPerformAction(uiAction);
601 $scope.cldsAskDeployParametersPerformAction = function() {
603 var dlg = dialogs.create(
604 'partials/portfolios/deploy_parameters.html', 'DeploymentCtrl', {},
608 windowClass : 'deploy-parameters'
610 dlg.result.then(function() {
612 var confirm = dialogs.confirm('Deploy',
613 'Are you sure you want to deploy the closed loop?');
614 confirm.result.then(function() {
616 cldsToggleDeploy("deploy");
620 $scope.cldsConfirmToggleDeployPerformAction = function(uiAction) {
622 var dlg = dialogs.confirm('Message', 'Do you want to '
623 + uiAction.toLowerCase() + ' the closed loop?');
624 dlg.result.then(function(btn) {
626 cldsToggleDeploy(uiAction.toLowerCase());
631 function cldsToggleDeploy(uiAction) {
633 var modelName = selected_model;
634 var controlNamePrefix = "ClosedLoop-";
635 var bpmnText = modelXML;
636 // serialize model properties
637 var propText = JSON.stringify(elementMap);
638 var templateName = selected_template;
639 var svgXml = $("#svgContainer").html();
640 console.log("cldsPerformAction: " + uiAction + " modelName="
642 console.log("cldsPerformAction: " + uiAction
643 + " controlNamePrefix=" + controlNamePrefix);
644 console.log("cldsPerformAction: " + uiAction + " bpmnText="
646 console.log("cldsPerformAction: " + uiAction + " propText="
648 console.log("cldsPerformAction: " + uiAction
649 + " modelEventService=" + modelEventService);
650 console.log("cldsPerformAction: " + uiAction + " typeID=" + typeID);
651 console.log("cldsPerformAction: " + uiAction + " deploymentId="
653 cldsModelService.toggleDeploy(uiAction, modelName,
654 controlNamePrefix, bpmnText, propText, svgXml, templateName,
655 typeID, controlNameUuid, modelEventService, deploymentId).then(
658 var cldsObject = pars.body;
659 typeID = cldsObject.typeId;
660 controlNameUuid = cldsObject.controlNameUuid;
661 selected_template = cldsObject.templateName;
662 modelEventService = cldsObject.event;
663 actionStateCd = cldsObject.event.actionStateCd;
664 deploymentId = cldsObject.deploymentId;
665 cldsModelService.processActionResponse(modelName, cldsObject);
670 $scope.ToscaModelWindow = function (tosca_model) {
672 var dlg = dialogs.create('partials/portfolios/tosca_model_properties.html','ToscaModelCtrl',{closable:true,draggable:true},{size:'lg',keyboard: true,backdrop: 'static',windowClass: 'my-class'});
673 dlg.result.then(function(name){
677 $scope.PolicyWindow = function(policy) {
679 var dlg = dialogs.create(
680 'partials/portfolios/PolicyWindow_properties.html',
681 'operationalPolicyCtrl', {
688 windowClass : 'my-class'
690 dlg.result.then(function(name) {
697 app.service('MenuService', [ '$http', '$q', function($http, $q) {
700 app.directive('focus', function($timeout) {
706 link : function(scope, element) {
708 scope.$watch('trigger', function(value) {
710 if (value === "true") {
711 $timeout(function() {
720 app.directive('draggable', function($document) {
722 return function(scope, element, attr) {
724 var startX = 0, startY = 0, x = 0, y = 0;
726 position : 'relative',
727 backgroundColor : 'white',
731 element.on('mousedown', function(event) {
733 startX = event.screenX - x;
734 startY = event.screenY - y;
735 $document.on('mousemove', mousemove);
736 $document.on('mouseup', mouseup);
738 function mousemove(event) {
740 y = event.screenY - startY;
741 x = event.screenX - startX;
749 $document.off('mousemove', mousemove);
750 $document.off('mouseup', mouseup);
754 app.factory('myHttpInterceptor', function($q, $window) {
756 return function(promise) {
758 return promise.then(function(response) {
761 }, function(response) {
763 return $q.reject(response);
767 app.run([ '$route', function($route) {
772 function F5Window() {
774 angular.element(document.getElementById('navbar')).scope().F5Window();
776 function GOCWindow() {
778 angular.element(document.getElementById('navbar')).scope().GOCWindow();
780 function ToscaModelWindow() {
781 angular.element(document.getElementById('navbar')).scope().ToscaModelWindow();
783 function PolicyWindow(PolicyWin) {
785 angular.element(document.getElementById('navbar')).scope().PolicyWindow(
788 function pathDetails(bpmnElementID, bpmnElementName, pathIdentifiers) {
790 angular.element(document.getElementById('navbar')).scope().pathDetails(
791 bpmnElementID, bpmnElementName, pathIdentifiers);
793 function setdefaultvalue() {
795 angular.element(document.getElementById('navbar')).scope()
798 function saveProject() {
800 angular.element(document.getElementById('navbar')).scope().saveProject();
803 function defineServiceAcronym() {
805 angular.element(document.getElementById('navbar')).scope()
806 .defineServiceAcronym();
808 function errorProperty(msg) {
810 angular.element(document.getElementById('navbar')).scope()
811 .propertyExplorerErrorMessage(msg);
813 function invisiblepropertyExplorer() {
815 angular.element(document.getElementById('navbar')).scope()
816 .invisibleproperty();
818 function updateDecisionLabel(originalLabel, newLabel) {
820 angular.element(document.getElementById('navbar')).scope()
821 .updateDecisionLabels(originalLabel, newLabel);
823 // Used to logout the session , when browser window was closed
824 window.onunload = function() {
826 window.localStorage.removeItem("isAuth");
827 window.localStorage.removeItem("loginuser");
828 window.localStorage.removeItem("invalidUser");