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