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