Upgrade JQuery to latest
[clamp.git] / src / main / resources / META-INF / resources / designer / scripts / app.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
6  *                             reserved.
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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  * ===================================================================
21  * 
22  */
23
24 'use strict';
25
26 /* App Module */
27
28 var app = angular.module('clds-app', ['ngRoute',
29     'ngResource',
30     'angularjs-dropdown-multiselect',
31     'angularjs-dropdown-multiselect-new',
32     'hljs',
33     'ui.bootstrap',
34     'angular-loading-bar',
35     'ngAnimate',
36     'dialogs.main',
37     'ui.grid',
38     'ui.grid.resizeColumns',
39     'ui.grid.paging',
40     'ui.grid.selection',
41     'ui.grid.cellNav',
42     'ui.grid.pinning',
43     'ngSanitize',
44     'ngCookies',
45     'ui.bootstrap.modal',
46     'ui.grid.exporter',
47     'angucomplete'
48   ])
49   .config(['cfpLoadingBarProvider', function(cfpLoadingBarProvider) {
50
51     cfpLoadingBarProvider.includeBar = true;
52     cfpLoadingBarProvider.includeSpinner = true;
53   }])
54   .config(
55     function($httpProvider) {
56
57       $httpProvider.responseInterceptors
58         .push('myHttpInterceptor');
59
60       var spinnerFunction = function spinnerFunction(data,
61         headersGetter) {
62
63         return data;
64       };
65
66       $httpProvider.defaults.transformRequest
67         .push(spinnerFunction);
68     })
69   .config(
70     [
71       '$routeProvider',
72       '$locationProvider',
73       '$compileProvider',
74       'cfpLoadingBarProvider',
75       function($routeProvider, $locationProvider,
76         cfpLoadingBarProvider, $timeout, dialogs,
77         $cookies) {
78         $locationProvider.html5Mode(false);
79         // alert("App.js");
80
81         $routeProvider
82           .when('/otherwise', {
83             templateUrl: 'please_wait.html',
84             controller: QueryParamsHandlerCtrl
85           })
86           .
87         // when('/dashboard_submit', { templateUrl:
88         // 'partials/portfolios/dashboard_submit.html',
89         // controller: CreateNewPrjCtrl }).
90         when(
91             '/dashboard', {
92               templateUrl: 'partials/portfolios/clds_modelling.html',
93               controller: DashboardCtrl
94             })
95           .
96         // when('/dashboard_upload', { templateUrl:
97         // 'partials/portfolios/dashboard_upload.html',
98         // controller: DashboardCtrl }).
99         when(
100           '/activity_modelling', {
101             templateUrl: 'partials/portfolios/clds_modelling.html',
102             controller: DashboardCtrl
103           }).when('/authenticate', {
104           templateUrl: 'authenticate.html',
105           controller: AuthenticateCtrl
106         }).when('/invalidlogin', {
107           templateUrl: 'invalid_login.html',
108           controller: PageUnderConstructionCtrl
109         }).otherwise({
110           redirectTo: '/otherwise'
111         });
112
113       }
114     ])
115   .controller(
116     'dialogCtrl',
117     function($scope, $rootScope, $timeout, dialogs) {
118
119       // -- Variables --//
120
121       $scope.lang = 'en-US';
122       $scope.language = 'English';
123
124       var _progress = 100;
125
126       $scope.name = '';
127       $scope.confirmed = 'No confirmation yet!';
128
129       $scope.custom = {
130         val: 'Initial Value'
131       };
132
133       // -- Listeners & Watchers --//
134
135       $scope.$watch('lang', function(val, old) {
136
137         switch (val) {
138           case 'en-US':
139             $scope.language = 'English';
140             break;
141           case 'es':
142             $scope.language = 'Spanish';
143             break;
144         }
145       });
146
147       // -- Methods --//
148       $rootScope.testCaseRequirements = [];
149       $rootScope.validTestRequirements = [];
150       /* $rootScope.testCaseValue=[]; */
151       $scope.setLanguage = function(lang) {
152
153         $scope.lang = lang;
154         $translate.use(lang);
155       };
156
157       $rootScope.launch = function(which) {
158
159         switch (which) {
160           case 'error':
161             dialogs.error();
162             break;
163           case 'wait':
164             // var dlg =
165             // dialogs.wait(undefined,undefined,_progress);
166             // _fakeWaitProgress();
167             break;
168           case 'customwait':
169             // var dlg = dialogs.wait('Custom Wait
170             // Header','Custom Wait Message',_progress);
171             // _fakeWaitProgress();
172             break;
173           case 'notify':
174             dialogs.notify();
175             break;
176           case 'confirm':
177             var dlg = dialogs.confirm();
178             dlg.result.then(function(btn) {
179
180               $scope.confirmed = 'You confirmed "Yes."';
181             }, function(btn) {
182
183               $scope.confirmed = 'You confirmed "No."';
184             });
185             break;
186           case 'custom':
187             var dlg = dialogs.create('/dialogs/custom.html',
188               'customDialogCtrl', {}, {
189                 size: 'lg',
190                 keyboard: true,
191                 backdrop: 'static',
192                 windowClass: 'my-class'
193               });
194             dlg.result
195               .then(
196                 function(name) {
197
198                   $scope.name = name;
199                 },
200                 function() {
201
202                   if (angular.equals($scope.name,
203                       ''))
204                     $scope.name = 'You did not enter in your name!';
205                 });
206             break;
207           case 'custom2':
208             var dlg = dialogs.create('/dialogs/custom2.html',
209               'customDialogCtrl2', $scope.custom, {
210                 size: 'lg'
211               });
212             break;
213           case 'custom3':
214             var dlg = dialogs
215               .notify(
216                 'Message',
217                 'All is not supported, Please select interface(s)/version(s) to fetch real time federated coverage report.');
218             break;
219           case 'custom4':
220             var dlg = dialogs
221               .confirm(
222                 'Message',
223                 'You are about to fetch real time federated coverage report.This may take sometime!!!.');
224             dlg.result.then(function(btn) {
225
226               $scope.confirmed = 'You confirmed "Yes."';
227             }, function(btn) {
228
229               $scope.confirmed = 'You confirmed "No."';
230             });
231             break;
232           case 'custom5':
233             var dlg = dialogs.notify('Success',
234               'Request has been successfully processed.');
235             break;
236           case 'custom6':
237             var dlg = dialogs.notify('Message',
238               'Please type Testscenario Name');
239             break;
240         }
241       }; // end launch
242
243       var _fakeWaitProgress = function() {
244
245         $timeout(function() {
246
247           if (_progress < 100) {
248             _progress += 33;
249             $rootScope.$broadcast('dialogs.wait.progress', {
250               'progress': _progress
251             });
252             _fakeWaitProgress();
253           } else {
254             $rootScope.$broadcast('dialogs.wait.complete');
255             _progress = 0;
256           }
257         }, 1000);
258       };
259     })
260   .controller(
261     'MenuCtrl', [
262       '$scope',
263       '$rootScope',
264       '$timeout',
265       'dialogs',
266       '$location',
267       'MenuService',
268       'Datafactory',
269       'userPreferencesService',
270       'cldsModelService',
271       'extraUserInfoService',
272       function($scope, $rootScope, $timeout, dialogs,
273         $location, MenuService, Datafactory,
274         userPreferencesService, cldsModelService, extraUserInfoService) {
275         console.log("MenuCtrl");
276         $rootScope.screenName = "Universal Test Modeler";
277         $rootScope.testSet = null;
278         var testingType = "";
279         $rootScope.contactUs = function() {
280           console.log("contactUs");
281           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.";
282           window.location.href = link;
283         };
284
285         extraUserInfoService
286           .getUserInfo()
287           .then(
288             function(pars) {
289               $scope.userInfo = pars;
290               if (!($scope.userInfo["permissionUpdateCl"])) {
291                 readMOnly = true;
292               };
293             });
294
295         $scope.emptyMenuClick = function(value, name) {
296           if ($rootScope.isNewClosed &&
297             name != "Save CL" &&
298             name != "Close Model" &&
299             name != "Properties CL") {
300             saveConfirmationNotificationPopUp();
301           } else {
302             isSaveCheck(name);
303           }
304
305           function saveConfirmationNotificationPopUp() {
306             $scope
307               .saveConfirmationNotificationPopUp(function(
308                 data) {
309                 if (data) {
310                   if ($rootScope.isNewClosed) {
311                     isSaveCheck("Save CL");
312                   } 
313                   $rootScope.isNewClosed = false;
314                 } else {
315                   return false;
316                 }
317               });
318           }
319
320           function isSaveCheck(name) {
321             if (name == "User Info") {
322               $scope.extraUserInfo();
323             } else if (name == "Wiki") {
324               window.open(value);
325             } else if (name == "Contact Us") {
326               $rootScope.contactUs();
327             } else if (name == "Revert Model Changes") {
328               $scope.cldsRevertModel();
329             } else if (name == "Close Model") {
330               $scope.cldsClose();
331             } else if (name == "Refresh ASDC") {
332               $scope.cldsRefreshASDC();
333             } else if (name == "Create CL") {
334               $rootScope.isNewClosed = true;
335               $scope.cldsCreateModel();
336             } else if (name == "Open CL") {
337               $scope.cldsOpenModel();
338             } else if (name == "Save CL") {
339               $rootScope.isNewClosed = false;
340               $scope.cldsPerformAction("SAVE");
341             } else if (name == "Validation Test") {
342               $scope.cldsPerformAction("TEST");
343             } else if (name == "Submit") {
344               $scope
345                 .cldsConfirmPerformAction("SUBMIT");
346             } else if (name == "Resubmit") {
347               $scope
348                 .cldsConfirmPerformAction("RESUBMIT");
349             } else if (name == "Update") {
350               $scope
351                 .cldsConfirmPerformAction("UPDATE");
352             } else if (name.toLowerCase() == "delete") {
353               $scope
354                 .manageConfirmPerformAction("DELETE");
355             } else if (name == "Stop") {
356               $scope.cldsConfirmPerformAction("STOP");
357             } else if (name == "Restart") {
358               $scope
359                 .cldsConfirmPerformAction("RESTART");
360             } else if (name == "Refresh Status") {
361               $scope.refreshStatus();
362             } else if (name == "Properties CL") {
363               $scope.cldsOpenModelProperties();
364             } else if (name == "Deploy") {
365               $scope
366                 .cldsAskDeployParametersPerformAction();
367             } else if (name == "UnDeploy") {
368               $scope
369                 .cldsConfirmToggleDeployPerformAction("UnDeploy");
370             } else {
371               $rootScope.screenName = name;
372               $scope.updatebreadcrumb(value);
373               $location.path(value);
374             }
375           }
376         };
377
378         $rootScope.impAlerts = function() {
379
380         };
381
382         $scope.tabs = {
383           "Closed Loop": [{
384             link: "/cldsCreateModel",
385             name: "Create CL"
386           }, {
387             link: "/cldsOpenModel",
388             name: "Open CL"
389           }, {
390             link: "/cldsSaveModel",
391             name: "Save CL"
392           }, {
393             link: "/cldsOpenModelProperties",
394             name: "Properties CL"
395           }, {
396             link: "/RevertChanges",
397             name: "Revert Model Changes"
398           }, {
399             link: "/Close",
400             name: "Close Model"
401           }],
402           "Manage": [{
403             link: "/cldsTestActivate",
404             name: "Validation Test"
405           }, {
406             link: "/cldsSubmit",
407             name: "Submit"
408           }, {
409             link: "/cldsResubmit",
410             name: "Resubmit"
411           }, {
412             link: "/cldsUpdate",
413             name: "Update"
414           }, {
415             link: "/cldsStop",
416             name: "Stop"
417           }, {
418             link: "/cldsRestart",
419             name: "Restart"
420           }, {
421             link: "/cldsDelete",
422             name: "Delete"
423           }, {
424             link: "/cldsDeploy",
425             name: "Deploy"
426           }, {
427             link: "/cldsUnDeploy",
428             name: "UnDeploy"
429           }],
430           "View": [{
431             link: "/refreshStatus",
432             name: "Refresh Status"
433           }, {
434             link: "/cldsRefreshASDC",
435             name: "Refresh ASDC"
436           }],
437           "Help": [{
438             link: "http://wiki.onap.org",
439             name: "Wiki"
440           }, {
441             link: "/contact_us",
442             name: "Contact Us"
443           }, {
444             link: "/extraUserInfo",
445             name: "User Info"
446           }]
447         };
448
449         if (!Object.keys) {
450           Object.keys = function(obj) {
451             var keys = [];
452
453             for (var i in obj) {
454               if (obj.hasOwnProperty(i)) {
455                 keys.push(i);
456               }
457             }
458
459             return keys;
460           };
461           $scope.keyList = Object.keys($scope.tabs);
462         } else {
463           $scope.keyList = Object.keys($scope.tabs);
464         }
465
466         $scope.updatebreadcrumb = function(path) {
467
468           var currentURL = $location.path();
469           if (path != undefined) {
470             currentURL = path;
471           }
472
473           if (currentURL == "/dashboard") {
474             $rootScope.screenName = "Universal Test Modeler";
475             $rootScope.parentMenu = "Home";
476             $rootScope.rightTabName = "UTM Build Configuration";
477           }
478           /*
479            * else if(currentURL=="/quicksearch") {
480            * $rootScope.screenName = "Quick Search";
481            * $rootScope.parentMenu = "Home"; }
482            */
483           else {
484             var found = false;
485
486             angular
487               .forEach(
488                 $scope.keyList,
489                 function(value, key) {
490
491                   if (!found) {
492                     $rootScope.parentMenu = value;
493
494                     angular
495                       .forEach(
496                         $scope.tabs[value],
497                         function(
498                           value,
499                           key) {
500
501                           if (currentURL == value.link) {
502                             $rootScope.screenName = value.name;
503                             found = true;
504                           }
505                         });
506                   }
507                 });
508           }
509         };
510
511         $scope.updatebreadcrumb();
512
513         $scope.homePage = function() {
514
515           $location.path('/dashboard');
516         };
517         $scope.propertyExplorerErrorMessage = function(msg) {
518
519           var dlg = dialogs.notify('Error', msg);
520         }
521
522         // $scope.fromTstMultipleFlag=false;
523         /* onclicking of review testset / generate testset */
524
525         $scope.reviewTestSet = function() {
526
527           $rootScope.modeltestset = list_model_test_sets[selected_model];
528
529           $rootScope.isPalette = false;
530           $rootScope.isTestset = true;
531           $rootScope.isRequirementCoverage = false;
532           document.getElementById("modeler_name").textContent = "UTM Test Set";
533           // document.getElementById('propertyExplorer').classList.add('visible');
534
535           // $( "#propertyExplorer" ).prev().css(
536           // "display", "none" );
537           $('div').find('.k-collapse-next').click();
538
539           // $rootScope.$apply();
540
541         };
542         $scope.requirementCoverage = function() {
543
544           $rootScope.testCaseRequirements = [];
545           $rootScope.validTestRequirementArray = [];
546           $rootScope.validTestRequirements = {};
547           $rootScope.modeltestset = list_model_test_sets[selected_model];
548           var allPathDetails = [];
549           $scope.currentSelectedModel = {};
550           // $scope.getPathDetails($rootScope.utmModels,selected_model);
551           // $scope.populatePathDetails(allPathDetails,$scope.currentSelectedModel);
552           $rootScope.pathDetailsList = list_model_path_details[selected_model];
553           /*
554            * for(var p=0;p<100;p++){
555            * $rootScope.testCaseRequirements.push("Requirement"+p); }
556            * for(var p=0;p<100;p++){
557            * $rootScope.testCaseValue.push("TestCase"+p); }
558            */
559           for (var x = 0; x < allPathDetails.length; x++) {
560             var tempPathDetails = allPathDetails[x];
561             if (tempPathDetails != null) {
562               for (var i = 0; i < tempPathDetails.length; i++) {
563                 var pathDetails = tempPathDetails[i];
564                 if (pathDetails.requirement !== '' &&
565                   pathDetails.requirement !== null) {
566                   $rootScope.testCaseRequirements
567                     .push(pathDetails.requirement);
568                 }
569
570                 /*
571                  * for (var j = 0; j <
572                  * pathDetails.decisionIdentifiers.length;
573                  * j++) {
574                  * if(pathDetails.decisionIdentifiers[j].requirement
575                  * !== '' &&
576                  * pathDetails.decisionIdentifiers[j].requirement
577                  * !== null){
578                  * $rootScope.testCaseRequirements.push(pathDetails.decisionIdentifiers[j].requirement); } }
579                  */
580               }
581             }
582
583           }
584           for (var p = 0; p < $rootScope.modeltestset.activityTestCases.length; p++) {
585             var activityTestCases = $rootScope.modeltestset.activityTestCases[p];
586             if (activityTestCases.mappedRequirements != null) {
587               for (var i = 0; i < activityTestCases.mappedRequirements.length; i++) {
588                 // $rootScope.testCaseRequirements
589                 // .push(activityTestCases.mappedRequirements[i]);
590                 var testCaseNames = $rootScope.validTestRequirements[activityTestCases.mappedRequirements[i]];
591                 if (testCaseNames == null) {
592                   testCaseNames = [];
593                 }
594                 if (activityTestCases.version != null)
595                   var testCase = activityTestCases.testCaseName +
596                     "_" +
597                     activityTestCases.version;
598                 else
599                   var testCase = activityTestCases.testCaseName;
600                 testCaseNames.push(testCase);
601                 $rootScope.validTestRequirements[activityTestCases.mappedRequirements[i]] = testCaseNames;
602               }
603             }
604           }
605
606           $rootScope.isPalette = false;
607           $rootScope.isTestset = false;
608           $rootScope.isRequirementCoverage = true;
609           document.getElementById("modeler_name").textContent = "Test Case / Requirement Coverage";
610
611           $('div').find('.k-collapse-next').click();
612
613
614         };
615
616         $scope.activityModelling = function() {
617         };
618
619
620         $scope.cldsClose = function() {
621
622           var dlg = dialogs
623             .create(
624               'partials/portfolios/confirmation_window.html',
625               'CldsOpenModelCtrl', {
626                 closable: true,
627                 draggable: true
628               }, {
629                 size: 'lg',
630                 keyboard: true,
631                 backdrop: 'static',
632                 windowClass: 'my-class'
633               });
634
635           dlg.result.then(function(name) {
636
637             // $scope.name = name;
638           }, function() {
639
640             // if(angular.equals($scope.name,''))
641             // $scope.name = 'You did not enter in your
642             // name!';
643           });
644         };
645         $scope.saveConfirmationNotificationPopUp = function(
646           callBack) {
647
648           var dlg = dialogs
649             .create(
650               'partials/portfolios/save_confirmation.html',
651               'saveConfirmationModalPopUpCtrl', {
652                 closable: true,
653                 draggable: true
654               }, {
655                 size: 'lg',
656                 keyboard: true,
657                 backdrop: 'static',
658                 windowClass: 'my-class'
659               });
660
661           dlg.result.then(function(name) {
662             callBack("OK");
663           }, function() {
664             callBack(null);
665           });
666
667         };
668
669         $scope.cldsRefreshASDC = function() {
670
671           var dlg = dialogs
672             .create(
673               'partials/portfolios/refresh_asdc.html',
674               'CldsOpenModelCtrl', {
675                 closable: true,
676                 draggable: true
677               }, {
678                 size: 'lg',
679                 keyboard: true,
680                 backdrop: 'static',
681                 windowClass: 'my-class'
682               });
683           dlg.result.then(function(name) {
684
685             // $scope.name = name;
686           }, function() {
687
688             // if(angular.equals($scope.name,''))
689             // $scope.name = 'You did not enter in your
690             // name!';
691           });
692         }
693         $scope.cldsRevertModel = function() {
694
695           var dlg = dialogs
696             .create(
697               'partials/portfolios/ConfirmRevertChanges.html',
698               'CldsOpenModelCtrl', {
699                 closable: true,
700                 draggable: true
701               }, {
702                 size: 'lg',
703                 keyboard: true,
704                 backdrop: 'static',
705                 windowClass: 'my-class'
706               });
707
708           dlg.result.then(function(name) {
709
710             // $scope.name = name;
711           }, function() {
712
713             // if(angular.equals($scope.name,''))
714             // $scope.name = 'You did not enter in your
715             // name!';
716           });
717
718         };
719
720         $rootScope.cldsOpenModelProperties = function() {
721
722           var dlg = dialogs
723             .create(
724               'partials/portfolios/global_properties.html',
725               'GlobalPropertiesCtrl', {}, {
726                 size: 'lg',
727                 keyboard: true,
728                 backdrop: 'static',
729                 windowClass: 'my-class'
730               });
731
732           dlg.result.then(function(name) {}, function() {});
733         };
734
735         $scope.cldsOpenModel = function() {
736
737           var dlg = dialogs
738             .create(
739               'partials/portfolios/clds_open_model.html',
740               'CldsOpenModelCtrl', {
741                 closable: true,
742                 draggable: true
743               }, {
744                 size: 'lg',
745                 keyboard: true,
746                 backdrop: 'static',
747                 windowClass: 'my-class'
748               });
749
750           dlg.result.then(function(name) {
751
752             // $scope.name = name;
753           }, function() {
754
755             // if(angular.equals($scope.name,''))
756             // $scope.name = 'You did not enter in your
757             // name!';
758           });
759         };
760         $scope.cldsCreateModel = function() {
761
762           var dlg = dialogs
763             .create(
764               'partials/portfolios/clds_create_model_off_Template.html',
765               'CldsOpenModelCtrl', {
766                 closable: true,
767                 draggable: true
768               }, {
769                 size: 'lg',
770                 keyboard: true,
771                 backdrop: 'static',
772                 windowClass: 'my-class'
773               });
774
775           dlg.result.then(function(name) {
776
777             // $scope.name = name;
778           }, function() {
779
780             // if(angular.equals($scope.name,''))
781             // $scope.name = 'You did not enter in your
782             // name!';
783           });
784
785         };
786         $scope.extraUserInfo = function() {
787
788           var dlg = dialogs
789             .create(
790               'partials/portfolios/extra_user_info.html',
791               'ExtraUserInfoCtrl', {
792                 closable: true,
793                 draggable: true
794               }, {
795                 size: 'lg',
796                 keyboard: true,
797                 backdrop: 'static',
798                 windowClass: 'my-class'
799               });
800
801           dlg.result.then(function(name) {}, function() {});
802
803         };
804         $scope.cldsPerformAction = function(uiAction) {
805
806           var modelName = selected_model;
807           var controlNamePrefix = "ClosedLoop-";
808           var bpmnText = modelXML;
809           // serialize model properties
810           var propText = JSON.stringify(elementMap);
811           var templateName = selected_template
812
813           var svgXml = $("#svgContainer").html(); 
814
815           console.log("cldsPerformAction: " + uiAction +
816             " modelName=" + modelName);
817           console.log("cldsPerformAction: " + uiAction +
818             " controlNamePrefix=" +
819             controlNamePrefix);
820           console.log("cldsPerformAction: " + uiAction +
821             " bpmnText=" + bpmnText);
822           console.log("cldsPerformAction: " + uiAction +
823             " propText=" + propText);
824           console.log("cldsPerformAction: " + uiAction +
825             " typeID=" + typeID);
826           console.log("cldsPerformAction: " + uiAction +
827             " deploymentId=" + deploymentId);
828           cldsModelService
829             .processAction(uiAction, modelName,
830               controlNamePrefix, bpmnText,
831               propText, svgXml, templateName,
832               typeID, deploymentId)
833             .then(
834               function(pars) {
835                 console
836                   .log("cldsPerformAction: pars=" +
837                     pars);
838                 cldsModelService
839                   .processRefresh(pars);
840               },
841               function(data) {
842
843                 // alert("setModel failed: "
844                 // + data);
845               });
846         };
847         $scope.refreshStatus = function() {
848             var modelName = selected_model;
849             var svgXml = $("#svgContainer").html(); 
850             console.log("refreStatus modelName=" + modelName);
851             cldsModelService
852               .getModel(modelName)
853               .then(
854                 function(pars) {
855                   console
856                     .log("refreStatus: pars=" +
857                       pars);
858                   cldsModelService
859                     .processRefresh(pars);
860                 },
861                 function(data) {
862                 });
863           };
864         $scope.cldsConfirmPerformAction = function(uiAction) {
865           var dlg = dialogs.confirm('Message',
866             'Do you want to ' +
867             uiAction.toLowerCase() +
868             ' the closed loop?');
869           dlg.result.then(function(btn) {
870
871             $scope.cldsPerformAction(uiAction);
872           }, function(btn) {
873
874             // $modalInstance.close("closed");
875           });
876         };
877
878         $scope.cldsAskDeployParametersPerformAction = function() {
879             var dlg = dialogs.create('partials/portfolios/deploy_parameters.html',
880                                      'DeploymentCtrl',
881                                      {}, {keyboard: true, backdrop: true, windowClass: 'deploy-parameters'});
882             dlg.result.then(function() {
883                 var confirm = dialogs.confirm('Deploy', 'Are you sure you want to deploy the closed loop?');
884                 confirm.result.then(function() {
885                     cldsToggleDeploy("deploy");
886                 });
887             });
888         };
889
890         $scope.cldsConfirmToggleDeployPerformAction = function(
891           uiAction) {
892
893           var dlg = dialogs.confirm('Message',
894             'Do you want to ' +
895             uiAction.toLowerCase() +
896             ' the closed loop?');
897           dlg.result.then(function(btn) {
898             cldsToggleDeploy(uiAction.toLowerCase());
899           }, function(btn) {
900
901             // $modalInstance.close("closed");
902           });
903         };
904
905         function cldsToggleDeploy(uiAction) {
906           var modelName = selected_model;
907           var controlNamePrefix = "ClosedLoop-";
908           var bpmnText = modelXML;
909           // serialize model properties
910           var propText = JSON.stringify(elementMap);
911           var templateName = selected_template;
912           var svgXml = $("#svgContainer").html();
913
914           console.log("cldsPerformAction: " + uiAction +
915             " modelName=" + modelName);
916           console.log("cldsPerformAction: " + uiAction +
917             " controlNamePrefix=" +
918             controlNamePrefix);
919           console.log("cldsPerformAction: " + uiAction +
920             " bpmnText=" + bpmnText);
921           console.log("cldsPerformAction: " + uiAction +
922             " propText=" + propText);
923           console.log("cldsPerformAction: " + uiAction +
924             " modelEventService=" +
925             modelEventService);
926           console.log("cldsPerformAction: " + uiAction +
927             " typeID=" + typeID);
928           console.log("cldsPerformAction: " + uiAction +
929             " deploymentId=" + deploymentId);
930           cldsModelService
931             .toggleDeploy(uiAction, modelName,
932               controlNamePrefix, bpmnText,
933               propText, svgXml, templateName,
934               typeID, controlNameUuid,
935               modelEventService, deploymentId)
936             .then(
937               function(pars) {
938                 typeID = pars.typeId;
939                 controlNameUuid = pars.controlNameUuid;
940                 selected_template = pars.templateName;
941                 modelEventService = pars.event;
942                 // actionCd =
943                 // pars.event.actionCd;
944                 actionStateCd = pars.event.actionStateCd;
945                 deploymentId = pars.deploymentId;
946                 cldsModelService
947                   .processActionResponse(
948                     modelName,
949                     pars);
950
951               },
952               function(data) {
953
954               });
955         }
956         $scope.managePerformAction = function(action) {
957           if (action.toLowerCase() === "delete") {
958             cldsModelService
959               .manageAction(
960                 selected_model,
961                 "805b9f83-261f-48d9-98c7-8011fc2cc8e8",
962                 "ClosedLoop-ABCD-0000.yml")
963               .then(function(pars) {
964
965               }, function(data) {
966
967                 // alert("setModel failed: " +
968                 // data);
969               });
970           }
971         };
972         $scope.manageConfirmPerformAction = function(
973           uiAction) {
974
975           var dlg = dialogs.confirm('Message',
976             'Do you want to ' +
977             uiAction.toLowerCase() +
978             ' the closed loop?');
979           dlg.result.then(function(btn) {
980
981             $scope.managePerformAction(uiAction);
982           }, function(btn) {
983
984             // $modalInstance.close("closed");
985           });
986         };
987         $scope.VesCollectorWindow = function(vesCollector) {
988
989             var dlg = dialogs
990               .create(
991                 'partials/portfolios/vesCollector_properties.html',
992                 'ImportSchemaCtrl', {
993                   closable: true,
994                   draggable: true
995                 }, {
996                   size: 'lg',
997                   keyboard: true,
998                   backdrop: 'static',
999                   windowClass: 'my-class'
1000                 });
1001
1002             dlg.result.then(function(name) {
1003
1004             }, function() {
1005
1006             });
1007
1008
1009         };
1010
1011         $scope.HolmesWindow = function(holmes) {
1012
1013           var partial = 'partials/portfolios/holmes_properties.html'
1014
1015           var dlg = dialogs
1016             .create(
1017               partial,
1018               'ImportSchemaCtrl',
1019               holmes, {
1020                 closable: true,
1021                 draggable: true
1022               }, {
1023                 size: 'lg',
1024                 keyboard: true,
1025                 backdrop: 'static',
1026                 windowClass: 'my-class'
1027               });
1028         };
1029
1030         $scope.TCAWindow = function(tca) {
1031
1032             var dlg = dialogs
1033               .create(
1034                 'partials/portfolios/tca_properties.html',
1035                 'ImportSchemaCtrl', {
1036                   closable: true,
1037                   draggable: true
1038                 }, {
1039                   size: 'lg',
1040                   keyboard: true,
1041                   backdrop: 'static',
1042                   windowClass: 'my-class'
1043                 });
1044
1045             dlg.result.then(function(name) {
1046               // $scope.name = name;
1047             }, function() {
1048               // if(angular.equals($scope.name,''))
1049               // $scope.name = 'You did not enter in
1050               // your name!';
1051             });
1052
1053         };
1054
1055         $scope.PolicyWindow = function(policy) {
1056             var dlg = dialogs
1057               .create(
1058                 'partials/portfolios/PolicyWindow_properties.html',
1059                 'ImportSchemaCtrl', {
1060                   closable: true,
1061                   draggable: true
1062                 }, {
1063                   size: 'lg',
1064                   keyboard: true,
1065                   backdrop: 'static',
1066                   windowClass: 'my-class'
1067                 });
1068
1069             dlg.result.then(function(name) {
1070
1071               // $scope.name = name;
1072             }, function() {
1073
1074               // if(angular.equals($scope.name,''))
1075               // $scope.name = 'You did not enter in
1076               // your name!';
1077             });
1078
1079         };
1080
1081       }
1082     ]);
1083
1084 app.service('MenuService', ['$http', '$q', function($http, $q) {
1085
1086   /*
1087    * this.generateMDTTestSet = function(utmMDTRequest, generateTestSetMDTURL){
1088    *
1089    * console.log("generateMDTTestSet"); //alert("In generateMDTTestSet :: " +
1090    * JSON.stringify(utmMDTRequest)); var def = $q.defer(); var sets = [];
1091    *
1092    * $http.post(generateTestSetMDTURL, utmMDTRequest) .success(function(data){
1093    * console.log("success"); sets = data; def.resolve(data); })
1094    * .error(function(data){ console.log("error");
1095    * def.reject("GenerateMDTTestSet not successful"); });
1096    *
1097    * return def.promise; };
1098    */
1099 }]);
1100
1101 app.directive('focus', function($timeout) {
1102
1103   return {
1104     scope: {
1105       trigger: '@focus'
1106     },
1107     link: function(scope, element) {
1108       scope.$watch('trigger', function(value) {
1109
1110         if (value === "true") {
1111           $timeout(function() {
1112
1113             element[0].focus();
1114           });
1115         }
1116       });
1117     }
1118   };
1119 });
1120 app.directive('draggable', function($document) {
1121
1122   return function(scope, element, attr) {
1123
1124     var startX = 0,
1125       startY = 0,
1126       x = 0,
1127       y = 0;
1128     element.css({
1129       position: 'relative',
1130
1131       backgroundColor: 'white',
1132       cursor: 'move',
1133       display: 'block',
1134
1135     });
1136     element.on('mousedown', function(event) {
1137
1138       // Prevent default dragging of selected content
1139       // event.preventDefault();
1140       startX = event.screenX - x;
1141       startY = event.screenY - y;
1142       $document.on('mousemove', mousemove);
1143       $document.on('mouseup', mouseup);
1144     });
1145
1146     function mousemove(event) {
1147
1148       y = event.screenY - startY;
1149       x = event.screenX - startX;
1150       element.css({
1151         top: y + 'px',
1152         left: x + 'px'
1153       });
1154     }
1155
1156     function mouseup() {
1157
1158       $document.off('mousemove', mousemove);
1159       $document.off('mouseup', mouseup);
1160     }
1161   };
1162 });
1163
1164 app.factory('myHttpInterceptor', function($q, $window) {
1165
1166   return function(promise) {
1167
1168     return promise.then(function(response) {
1169
1170       return response;
1171     }, function(response) {
1172
1173       return $q.reject(response);
1174     });
1175   };
1176 });
1177
1178 app.run(['$route', function($route) {
1179
1180   $route.reload();
1181 }]);
1182
1183 function TestCtrl($scope) {
1184
1185   $scope.msg = "Hello from a controller method.";
1186   $scope.returnHello = function() {
1187
1188     return $scope.msg;
1189   }
1190 }
1191
1192 function importshema() {
1193
1194   angular.element(document.getElementById('navbar')).scope().importSchema();
1195
1196 }
1197
1198 function VesCollectorWindow(vesCollectorWin) {
1199   angular.element(document.getElementById('navbar')).scope()
1200     .VesCollectorWindow(vesCollectorWin);
1201 }
1202
1203 function HolmesWindow(holmesWin) {
1204   angular.element(document.getElementById('navbar')).scope()
1205     .HolmesWindow(holmesWin);
1206 }
1207
1208 function F5Window() {
1209
1210   angular.element(document.getElementById('navbar')).scope().F5Window();
1211
1212 }
1213
1214 function TCAWindow(tca) {
1215
1216   angular.element(document.getElementById('navbar')).scope().TCAWindow(tca);
1217
1218 }
1219
1220 function GOCWindow() {
1221
1222   angular.element(document.getElementById('navbar')).scope().GOCWindow();
1223
1224 }
1225
1226 function PolicyWindow(PolicyWin) {
1227
1228   angular.element(document.getElementById('navbar')).scope().PolicyWindow(
1229     PolicyWin);
1230
1231 }
1232
1233 function pathDetails(bpmnElementID, bpmnElementName, pathIdentifiers) {
1234
1235   angular.element(document.getElementById('navbar')).scope().pathDetails(
1236     bpmnElementID, bpmnElementName, pathIdentifiers);
1237
1238 }
1239
1240 function setdefaultvalue() {
1241
1242   angular.element(document.getElementById('navbar')).scope()
1243     .setDefaultValue();
1244
1245 }
1246
1247 function upgradeSchemaVersion() {
1248
1249   angular.element(document.getElementById('navbar')).scope()
1250     .upgradeSchemaVersion();
1251
1252 }
1253
1254 function saveProject() {
1255
1256   angular.element(document.getElementById('navbar')).scope().saveProject();
1257
1258 }
1259
1260 function modifySchema() {
1261
1262   angular.element(document.getElementById('navbar')).scope().modifySchema();
1263
1264 }
1265
1266 function definePID() {
1267
1268   angular.element(document.getElementById('navbar')).scope().definePID();
1269
1270 }
1271
1272 function defineServiceAcronym() {
1273
1274   angular.element(document.getElementById('navbar')).scope()
1275     .defineServiceAcronym();
1276
1277 }
1278
1279 function errorProperty(msg) {
1280
1281   angular.element(document.getElementById('navbar')).scope()
1282     .propertyExplorerErrorMessage(msg);
1283 }
1284
1285 function invisiblepropertyExplorer() {
1286
1287   angular.element(document.getElementById('navbar')).scope()
1288     .invisibleproperty();
1289 }
1290
1291 function updateDecisionLabel(originalLabel, newLabel) {
1292
1293   angular.element(document.getElementById('navbar')).scope()
1294     .updateDecisionLabels(originalLabel, newLabel);
1295 }
1296
1297 // Used to logout the session , when browser window was closed
1298 window.onunload = function() {
1299   window.localStorage.removeItem("isAuth");
1300   window.localStorage.removeItem("loginuser");
1301   window.localStorage.removeItem("invalidUser");
1302 };