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