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