Merge changes Ib3c339b2,I47888da8,Ifdc5a4d9,I2f7b7417,If10e2dff, ...
[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     '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                 .cldsAskDeployParametersPerformAction();
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.cldsAskDeployParametersPerformAction = function() {
997             var dlg = dialogs.create('partials/portfolios/deploy_parameters.html',
998                                      'DeploymentCtrl',
999                                      {}, {keyboard: true, backdrop: true, windowClass: 'deploy-parameters'});
1000             dlg.result.then(function() {
1001                 var confirm = dialogs.confirm('Deploy', 'Are you sure you want to deploy the closed loop?');
1002                 confirm.result.then(function() {
1003                     cldsToggleDeploy("deploy");
1004                 });
1005             });
1006         };
1007
1008         $scope.cldsConfirmToggleDeployPerformAction = function(
1009           uiAction) {
1010
1011           var dlg = dialogs.confirm('Message',
1012             'Do you want to ' +
1013             uiAction.toLowerCase() +
1014             ' the closed loop?');
1015           dlg.result.then(function(btn) {
1016             cldsToggleDeploy(uiAction.toLowerCase());
1017           }, function(btn) {
1018
1019             // $modalInstance.close("closed");
1020           });
1021         };
1022
1023         function cldsToggleDeploy(uiAction) {
1024           var modelName = selected_model;
1025           var controlNamePrefix = "ClosedLoop-";
1026           var bpmnText = modelXML;
1027           // serialize model properties
1028           var propText = JSON.stringify(elementMap);
1029           var templateName = selected_template;
1030           var svgXml = $("#svgContainer").html();
1031
1032           console.log("cldsPerformAction: " + uiAction +
1033             " modelName=" + modelName);
1034           console.log("cldsPerformAction: " + uiAction +
1035             " controlNamePrefix=" +
1036             controlNamePrefix);
1037           console.log("cldsPerformAction: " + uiAction +
1038             " bpmnText=" + bpmnText);
1039           console.log("cldsPerformAction: " + uiAction +
1040             " propText=" + propText);
1041           console.log("cldsPerformAction: " + uiAction +
1042             " modelEventService=" +
1043             modelEventService);
1044           console.log("cldsPerformAction: " + uiAction +
1045             " typeID=" + typeID);
1046           console.log("cldsPerformAction: " + uiAction +
1047             " deploymentId=" + deploymentId);
1048           cldsModelService
1049             .toggleDeploy(uiAction, modelName,
1050               controlNamePrefix, bpmnText,
1051               propText, svgXml, templateName,
1052               typeID, controlNameUuid,
1053               modelEventService, deploymentId)
1054             .then(
1055               function(pars) {
1056                 typeID = pars.typeId;
1057                 controlNameUuid = pars.controlNameUuid;
1058                 selected_template = pars.templateName;
1059                 modelEventService = pars.event;
1060                 // actionCd =
1061                 // pars.event.actionCd;
1062                 actionStateCd = pars.event.actionStateCd;
1063                 deploymentId = pars.deploymentId;
1064                 cldsModelService
1065                   .processActionResponse(
1066                     modelName,
1067                     pars);
1068
1069               },
1070               function(data) {
1071
1072               });
1073         }
1074         $scope.managePerformAction = function(action) {
1075           if (action.toLowerCase() === "delete") {
1076             cldsModelService
1077               .manageAction(
1078                 selected_model,
1079                 "805b9f83-261f-48d9-98c7-8011fc2cc8e8",
1080                 "ClosedLoop-ABCD-0000.yml")
1081               .then(function(pars) {
1082
1083               }, function(data) {
1084
1085                 // alert("setModel failed: " +
1086                 // data);
1087               });
1088           }
1089         };
1090         $scope.manageConfirmPerformAction = function(
1091           uiAction) {
1092
1093           var dlg = dialogs.confirm('Message',
1094             'Do you want to ' +
1095             uiAction.toLowerCase() +
1096             ' the closed loop?');
1097           dlg.result.then(function(btn) {
1098
1099             $scope.managePerformAction(uiAction);
1100           }, function(btn) {
1101
1102             // $modalInstance.close("closed");
1103           });
1104         };
1105         $scope.VesCollectorWindow = function(vesCollector) {
1106
1107             var dlg = dialogs
1108               .create(
1109                 'partials/portfolios/vesCollector_properties.html',
1110                 'ImportSchemaCtrl', {
1111                   closable: true,
1112                   draggable: true
1113                 }, {
1114                   size: 'lg',
1115                   keyboard: true,
1116                   backdrop: 'static',
1117                   windowClass: 'my-class'
1118                 });
1119
1120             dlg.result.then(function(name) {
1121
1122             }, function() {
1123
1124             });
1125
1126
1127         };
1128
1129         $scope.HolmesWindow = function(holmes) {
1130
1131           var partial = 'partials/portfolios/holmes_properties.html'
1132
1133           var dlg = dialogs
1134             .create(
1135               partial,
1136               'ImportSchemaCtrl',
1137               holmes, {
1138                 closable: true,
1139                 draggable: true
1140               }, {
1141                 size: 'lg',
1142                 keyboard: true,
1143                 backdrop: 'static',
1144                 windowClass: 'my-class'
1145               });
1146         };
1147
1148         $scope.TCAWindow = function(tca) {
1149
1150             var dlg = dialogs
1151               .create(
1152                 'partials/portfolios/tca_properties.html',
1153                 'ImportSchemaCtrl', {
1154                   closable: true,
1155                   draggable: true
1156                 }, {
1157                   size: 'lg',
1158                   keyboard: true,
1159                   backdrop: 'static',
1160                   windowClass: 'my-class'
1161                 });
1162
1163             dlg.result.then(function(name) {
1164               // $scope.name = name;
1165             }, function() {
1166               // if(angular.equals($scope.name,''))
1167               // $scope.name = 'You did not enter in
1168               // your name!';
1169             });
1170
1171         };
1172
1173         $scope.PolicyWindow = function(policy) {
1174             var dlg = dialogs
1175               .create(
1176                 'partials/portfolios/PolicyWindow_properties.html',
1177                 'ImportSchemaCtrl', {
1178                   closable: true,
1179                   draggable: true
1180                 }, {
1181                   size: 'lg',
1182                   keyboard: true,
1183                   backdrop: 'static',
1184                   windowClass: 'my-class'
1185                 });
1186
1187             dlg.result.then(function(name) {
1188
1189               // $scope.name = name;
1190             }, function() {
1191
1192               // if(angular.equals($scope.name,''))
1193               // $scope.name = 'You did not enter in
1194               // your name!';
1195             });
1196
1197         };
1198
1199       }
1200     ]);
1201
1202 app.service('MenuService', ['$http', '$q', function($http, $q) {
1203
1204   /*
1205    * this.generateMDTTestSet = function(utmMDTRequest, generateTestSetMDTURL){
1206    *
1207    * console.log("generateMDTTestSet"); //alert("In generateMDTTestSet :: " +
1208    * JSON.stringify(utmMDTRequest)); var def = $q.defer(); var sets = [];
1209    *
1210    * $http.post(generateTestSetMDTURL, utmMDTRequest) .success(function(data){
1211    * console.log("success"); sets = data; def.resolve(data); })
1212    * .error(function(data){ console.log("error");
1213    * def.reject("GenerateMDTTestSet not successful"); });
1214    *
1215    * return def.promise; };
1216    */
1217 }]);
1218
1219 app.directive('focus', function($timeout) {
1220
1221   return {
1222     scope: {
1223       trigger: '@focus'
1224     },
1225     link: function(scope, element) {
1226       scope.$watch('trigger', function(value) {
1227
1228         if (value === "true") {
1229           $timeout(function() {
1230
1231             element[0].focus();
1232           });
1233         }
1234       });
1235     }
1236   };
1237 });
1238 app.directive('draggable', function($document) {
1239
1240   return function(scope, element, attr) {
1241
1242     var startX = 0,
1243       startY = 0,
1244       x = 0,
1245       y = 0;
1246     element.css({
1247       position: 'relative',
1248
1249       backgroundColor: 'white',
1250       cursor: 'move',
1251       display: 'block',
1252
1253     });
1254     element.on('mousedown', function(event) {
1255
1256       // Prevent default dragging of selected content
1257       // event.preventDefault();
1258       startX = event.screenX - x;
1259       startY = event.screenY - y;
1260       $document.on('mousemove', mousemove);
1261       $document.on('mouseup', mouseup);
1262     });
1263
1264     function mousemove(event) {
1265
1266       y = event.screenY - startY;
1267       x = event.screenX - startX;
1268       element.css({
1269         top: y + 'px',
1270         left: x + 'px'
1271       });
1272     }
1273
1274     function mouseup() {
1275
1276       $document.off('mousemove', mousemove);
1277       $document.off('mouseup', mouseup);
1278     }
1279   };
1280 });
1281
1282 app.factory('myHttpInterceptor', function($q, $window) {
1283
1284   return function(promise) {
1285
1286     return promise.then(function(response) {
1287
1288       return response;
1289     }, function(response) {
1290
1291       return $q.reject(response);
1292     });
1293   };
1294 });
1295
1296 app.run(['$route', function($route) {
1297
1298   $route.reload();
1299 }]);
1300
1301 function TestCtrl($scope) {
1302
1303   $scope.msg = "Hello from a controller method.";
1304   $scope.returnHello = function() {
1305
1306     return $scope.msg;
1307   }
1308 }
1309
1310 function importshema() {
1311
1312   angular.element(document.getElementById('navbar')).scope().importSchema();
1313
1314 }
1315
1316 function VesCollectorWindow(vesCollectorWin) {
1317   angular.element(document.getElementById('navbar')).scope()
1318     .VesCollectorWindow(vesCollectorWin);
1319 }
1320
1321 function HolmesWindow(holmesWin) {
1322   angular.element(document.getElementById('navbar')).scope()
1323     .HolmesWindow(holmesWin);
1324 }
1325
1326 function F5Window() {
1327
1328   angular.element(document.getElementById('navbar')).scope().F5Window();
1329
1330 }
1331
1332 function TCAWindow(tca) {
1333
1334   angular.element(document.getElementById('navbar')).scope().TCAWindow(tca);
1335
1336 }
1337
1338 function GOCWindow() {
1339
1340   angular.element(document.getElementById('navbar')).scope().GOCWindow();
1341
1342 }
1343
1344 function PolicyWindow(PolicyWin) {
1345
1346   angular.element(document.getElementById('navbar')).scope().PolicyWindow(
1347     PolicyWin);
1348
1349 }
1350
1351 function pathDetails(bpmnElementID, bpmnElementName, pathIdentifiers) {
1352
1353   angular.element(document.getElementById('navbar')).scope().pathDetails(
1354     bpmnElementID, bpmnElementName, pathIdentifiers);
1355
1356 }
1357
1358 function setdefaultvalue() {
1359
1360   angular.element(document.getElementById('navbar')).scope()
1361     .setDefaultValue();
1362
1363 }
1364
1365 function upgradeSchemaVersion() {
1366
1367   angular.element(document.getElementById('navbar')).scope()
1368     .upgradeSchemaVersion();
1369
1370 }
1371
1372 function saveProject() {
1373
1374   angular.element(document.getElementById('navbar')).scope().saveProject();
1375
1376 }
1377
1378 function modifySchema() {
1379
1380   angular.element(document.getElementById('navbar')).scope().modifySchema();
1381
1382 }
1383
1384 function definePID() {
1385
1386   angular.element(document.getElementById('navbar')).scope().definePID();
1387
1388 }
1389
1390 function defineServiceAcronym() {
1391
1392   angular.element(document.getElementById('navbar')).scope()
1393     .defineServiceAcronym();
1394
1395 }
1396
1397 function errorProperty(msg) {
1398
1399   angular.element(document.getElementById('navbar')).scope()
1400     .propertyExplorerErrorMessage(msg);
1401 }
1402
1403 function invisiblepropertyExplorer() {
1404
1405   angular.element(document.getElementById('navbar')).scope()
1406     .invisibleproperty();
1407 }
1408
1409 function updateDecisionLabel(originalLabel, newLabel) {
1410
1411   angular.element(document.getElementById('navbar')).scope()
1412     .updateDecisionLabels(originalLabel, newLabel);
1413 }
1414
1415 // Used to logout the session , when browser window was closed
1416 window.onunload = function() {
1417   window.localStorage.removeItem("isAuth");
1418   window.localStorage.removeItem("loginuser");
1419 };