Update the policyName send to Policy
[clamp.git] / src / main / resources / META-INF / resources / designer / scripts / app.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2017 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       'cldsTemplateService',
276       'extraUserInfoService',
277       function($scope, $rootScope, $timeout, dialogs,
278         $location, MenuService, Datafactory,
279         userPreferencesService, cldsModelService,
280         cldsTemplateService, extraUserInfoService) {
281         console.log("MenuCtrl");
282         $rootScope.screenName = "Universal Test Modeler";
283         $rootScope.testSet = null;
284         $rootScope.isNew = false;
285         var testingType = "";
286         $rootScope.contactUs = function() {
287           console.log("contactUs");
288           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.";
289           window.location.href = link;
290         };
291
292         extraUserInfoService
293           .getUserInfo()
294           .then(
295             function(pars) {
296               $scope.userInfo = pars;
297               if (!($scope.userInfo["permissionUpdateTemplate"])) {
298                 readTOnly = true;
299               };
300               if (!($scope.userInfo["permissionUpdateCl"])) {
301                 readMOnly = true;
302               };
303             });
304
305         $scope.emptyMenuClick = function(value, name) {
306           if ($rootScope.isNew &&
307             (name != "Save Template" &&
308               name != "Close Template" && name != "Template Properties")) {
309             saveConfirmationNotificationPopUp();
310           } else if ($rootScope.isNewClosed &&
311             name != "Save CL" &&
312             name != "Close Model" &&
313             name != "Properties CL") {
314             saveConfirmationNotificationPopUp();
315           } else {
316             isSaveCheck(name);
317           }
318
319           function saveConfirmationNotificationPopUp() {
320             $scope
321               .saveConfirmationNotificationPopUp(function(
322                 data) {
323                 if (data) {
324                   if ($rootScope.isNewClosed) {
325                     isSaveCheck("Save CL");
326                   } else {
327                     isSaveCheck("Save Template");
328                   }
329                   $rootScope.isNewClosed = false;
330                   $rootScope.isNew = false;
331                 } else {
332                   return false;
333                 }
334               });
335           }
336
337           function isSaveCheck(name) {
338             if (name == "User Info") {
339               $scope.extraUserInfo();
340             } else if (name == "Wiki") {
341               window.open(value);
342             } else if (name == "Contact Us") {
343               $rootScope.contactUs();
344             } else if (name == "Log Out") {
345               $scope.logout();
346             } else if (name == "Revert Template Changes") {
347               $scope.cldsRevertTemplate();
348             } else if (name == "Revert Model Changes") {
349               $scope.cldsRevertModel();
350             } else if (name == "Create Template") {
351               $rootScope.isNew = true;
352               $scope.cldsCreateTemplate();
353             } else if (name == "Open Template") {
354               $scope.cldsOpenTemplate();
355             } else if (name == "Save Template") {
356               $scope
357                 .cldsTemplatePerformAction("SAVE");
358               $rootScope.isNewClosed = false;
359               $rootScope.isNew = false;
360             } else if (name == "Template Properties") {
361               $scope.cldsOpenTemplateProperties();
362             } else if (name == "Close Model" ||
363               name == "Close Template") {
364               $scope.cldsClose();
365             } else if (name == "Refresh ASDC") {
366               $scope.cldsRefreshASDC();
367             } else if (name == "Create CL") {
368               $rootScope.isNewClosed = true;
369               $scope.cldsCreateModel();
370             } else if (name == "Open CL") {
371               $scope.cldsOpenModel();
372             } else if (name == "Save CL") {
373               $rootScope.isNewClosed = false;
374               $rootScope.isNew = false;
375               $scope.cldsPerformAction("SAVE");
376             } else if (name == "Validation Test") {
377               $scope.cldsPerformAction("TEST");
378             } else if (name == "Submit") {
379               $scope
380                 .cldsConfirmPerformAction("SUBMIT");
381             } else if (name == "Resubmit") {
382               $scope
383                 .cldsConfirmPerformAction("RESUBMIT");
384             } else if (name == "Update") {
385               $scope
386                 .cldsConfirmPerformAction("UPDATE");
387             } else if (name.toLowerCase() == "delete") {
388               $scope
389                 .manageConfirmPerformAction("DELETE");
390             } else if (name == "Stop") {
391               $scope.cldsConfirmPerformAction("STOP");
392             } else if (name == "Restart") {
393               $scope
394                 .cldsConfirmPerformAction("RESTART");
395             } else if (name == "Refresh Status") {
396               $scope.refreshStatus();
397             } else if (name == "Properties CL") {
398               $scope.cldsOpenModelProperties();
399             } else if (name == "Deploy") {
400               $scope
401                 .cldsConfirmToggleDeployPerformAction("Deploy");
402             } else if (name == "UnDeploy") {
403               $scope
404                 .cldsConfirmToggleDeployPerformAction("UnDeploy");
405             } else {
406               $rootScope.screenName = name;
407               $scope.updatebreadcrumb(value);
408               $location.path(value);
409             }
410           }
411         };
412
413         $rootScope.impAlerts = function() {
414
415         };
416
417         $scope.tabs = {
418           "Template": [{
419             link: "/cldsCreateTemplate",
420             name: "Create Template"
421           }, {
422             link: "/cldsOpenTemplate",
423             name: "Open Template"
424           }, {
425             link: "/cldsSaveTemplate",
426             name: "Save Template"
427           }, {
428             link: "/cldsOpenTemplateProperties",
429             name: "Template Properties"
430           }, {
431             link: "/RevertChanges",
432             name: "Revert Template Changes"
433           }, {
434             link: "/Close",
435             name: "Close Template"
436           }],
437
438           "Closed Loop": [{
439             link: "/cldsCreateModel",
440             name: "Create CL"
441           }, {
442             link: "/cldsOpenModel",
443             name: "Open CL"
444           }, {
445             link: "/cldsSaveModel",
446             name: "Save CL"
447           }, {
448             link: "/cldsOpenModelProperties",
449             name: "Properties CL"
450           }, {
451             link: "/RevertChanges",
452             name: "Revert Model Changes"
453           }, {
454             link: "/Close",
455             name: "Close Model"
456           }],
457           "Manage": [{
458             link: "/cldsTestActivate",
459             name: "Validation Test"
460           }, {
461             link: "/cldsSubmit",
462             name: "Submit"
463           }, {
464             link: "/cldsResubmit",
465             name: "Resubmit"
466           }, {
467             link: "/cldsUpdate",
468             name: "Update"
469           }, {
470             link: "/cldsStop",
471             name: "Stop"
472           }, {
473             link: "/cldsRestart",
474             name: "Restart"
475           }, {
476             link: "/cldsDelete",
477             name: "Delete"
478           }, {
479             link: "/cldsDeploy",
480             name: "Deploy"
481           }, {
482             link: "/cldsUnDeploy",
483             name: "UnDeploy"
484           }],
485           "View": [{
486             link: "/refreshStatus",
487             name: "Refresh Status"
488           }, {
489             link: "/refreshASDCProperties",
490             name: "Refresh ASDC"
491           }],
492           "Help": [{
493             link: "http://wiki.onap.org",
494             name: "Wiki"
495           }, {
496             link: "/contact_us",
497             name: "Contact Us"
498           }, {
499             link: "/extraUserInfo",
500             name: "User Info"
501           }],
502           "Log Out": [{
503             link: "/log_out.html",
504             name: "Log Out"
505           }]
506         };
507
508         if (!Object.keys) {
509           Object.keys = function(obj) {
510             var keys = [];
511
512             for (var i in obj) {
513               if (obj.hasOwnProperty(i)) {
514                 keys.push(i);
515               }
516             }
517
518             return keys;
519           };
520           $scope.keyList = Object.keys($scope.tabs);
521         } else {
522           $scope.keyList = Object.keys($scope.tabs);
523         }
524
525         $scope.updatebreadcrumb = function(path) {
526
527           var currentURL = $location.path();
528           if (path != undefined) {
529             currentURL = path;
530           }
531
532           if (currentURL == "/dashboard") {
533             $rootScope.screenName = "Universal Test Modeler";
534             $rootScope.parentMenu = "Home";
535             $rootScope.rightTabName = "UTM Build Configuration";
536           }
537           /*
538            * else if(currentURL=="/quicksearch") {
539            * $rootScope.screenName = "Quick Search";
540            * $rootScope.parentMenu = "Home"; }
541            */
542           else {
543             var found = false;
544
545             angular
546               .forEach(
547                 $scope.keyList,
548                 function(value, key) {
549
550                   if (!found) {
551                     $rootScope.parentMenu = value;
552
553                     angular
554                       .forEach(
555                         $scope.tabs[value],
556                         function(
557                           value,
558                           key) {
559
560                           if (currentURL == value.link) {
561                             $rootScope.screenName = value.name;
562                             found = true;
563                           }
564                         });
565                   }
566                 });
567           }
568         };
569
570         $scope.updatebreadcrumb();
571
572         $scope.createNewProject = function() {
573
574           if ($rootScope.projectName != null) {
575             var dlg = dialogs
576               .confirm('Message',
577                 'Do you want to over-write  the project ?');
578
579             dlg.result
580               .then(
581                 function(btn) {
582
583                   $scope.clearProject();
584                   var dlg1 = dialogs
585                     .create(
586                       'partials/portfolios/create_new_project.html',
587                       'CreateNewPrjCtrl', {}, {
588                         size: 'sm',
589                         keyboard: true,
590                         backdrop: false,
591                         windowClass: 'my-class'
592                       });
593                   dlg1.result.then(
594                     function(name) {
595
596                       // $scope.name
597                       // = name;
598                     },
599                     function() {
600
601                       // if(angular.equals($scope.name,''))
602                       // $scope.name
603                       // = 'You
604                       // did not
605                       // enter in
606                       // your
607                       // name!';
608                     });
609                 },
610                 function(btn) {
611
612                   // $modalInstance.close("closed");
613                 });
614
615           } else {
616             var dlg = dialogs
617               .create(
618                 'partials/portfolios/create_new_project.html',
619                 'CreateNewPrjCtrl', {}, {
620                   size: 'lg',
621                   keyboard: true,
622                   backdrop: false,
623                   windowClass: 'my-class'
624                 });
625             dlg.result.then(function(name) {
626
627               // $scope.name = name;
628             }, function() {
629
630               // if(angular.equals($scope.name,''))
631               // $scope.name = 'You did not enter in
632               // your name!';
633             });
634
635           }
636         };
637
638         $scope.clearProject = function() {
639
640           $rootScope.projectName = null;
641           $rootScope.revision = -1;
642           // $rootScope.models.length=0;
643           $rootScope.utmModels = $rootScope.$new(true);
644           $rootScope.serviceInfo = $rootScope.$new(true);
645           $rootScope.serviceInfo = null;
646           $rootScope.serviceInputPartInfo = $rootScope
647             .$new(true);
648           $rootScope.serviceOutputPartInfo = $rootScope
649             .$new(true);
650           $rootScope.servicefaultPartInfo = $rootScope
651             .$new(true);
652           $rootScope.isModel = false;
653           $("#paletteDiv").load(
654             './modeler/dist/index.html');
655           $rootScope.isPalette = false;
656           $rootScope.isTestset = false;
657           $rootScope.isRequirementCoverage = false;
658           $rootScope.ispropertyExplorer = false;
659           // $("#propertyDiv").load('./partials/portfolios/Property_Explorer.html');
660           $rootScope.modelName = "";
661           // document.getElementById('propertyExplorer').classList.remove('visible');
662           document.getElementById("modeler_name").textContent = "Activity Modeler";
663           // $( "#propertyExplorer" ).prev().css(
664           // "display", "block" );
665           $("#activity_modeler").prev().css("display",
666             "block");
667           $('div').find('.k-expand-next').click();
668
669           $rootScope.$apply();
670
671         };
672
673         $scope.homePage = function() {
674
675           $location.path('/dashboard');
676         };
677         $scope.propertyExplorerErrorMessage = function(msg) {
678
679           var dlg = dialogs.notify('Error', msg);
680         }
681
682         // $scope.fromTstMultipleFlag=false;
683         /* onclicking of review testset / generate testset */
684
685         $scope.reviewTestSet = function() {
686
687           $rootScope.modeltestset = list_model_test_sets[selected_model];
688
689           $rootScope.isPalette = false;
690           $rootScope.isTestset = true;
691           $rootScope.isRequirementCoverage = false;
692           document.getElementById("modeler_name").textContent = "UTM Test Set";
693           // document.getElementById('propertyExplorer').classList.add('visible');
694
695           // $( "#propertyExplorer" ).prev().css(
696           // "display", "none" );
697           $('div').find('.k-collapse-next').click();
698
699           // $rootScope.$apply();
700
701         };
702         $scope.requirementCoverage = function() {
703
704           $rootScope.testCaseRequirements = [];
705           $rootScope.validTestRequirementArray = [];
706           $rootScope.validTestRequirements = {};
707           $rootScope.modeltestset = list_model_test_sets[selected_model];
708           var allPathDetails = [];
709           $scope.currentSelectedModel = {};
710           // $scope.getPathDetails($rootScope.utmModels,selected_model);
711           // $scope.populatePathDetails(allPathDetails,$scope.currentSelectedModel);
712           $rootScope.pathDetailsList = list_model_path_details[selected_model];
713           /*
714            * for(var p=0;p<100;p++){
715            * $rootScope.testCaseRequirements.push("Requirement"+p); }
716            * for(var p=0;p<100;p++){
717            * $rootScope.testCaseValue.push("TestCase"+p); }
718            */
719           for (var x = 0; x < allPathDetails.length; x++) {
720             var tempPathDetails = allPathDetails[x];
721             if (tempPathDetails != null) {
722               for (var i = 0; i < tempPathDetails.length; i++) {
723                 var pathDetails = tempPathDetails[i];
724                 if (pathDetails.requirement !== '' &&
725                   pathDetails.requirement !== null) {
726                   $rootScope.testCaseRequirements
727                     .push(pathDetails.requirement);
728                 }
729
730                 /*
731                  * for (var j = 0; j <
732                  * pathDetails.decisionIdentifiers.length;
733                  * j++) {
734                  * if(pathDetails.decisionIdentifiers[j].requirement
735                  * !== '' &&
736                  * pathDetails.decisionIdentifiers[j].requirement
737                  * !== null){
738                  * $rootScope.testCaseRequirements.push(pathDetails.decisionIdentifiers[j].requirement); } }
739                  */
740               }
741             }
742
743           }
744           for (var p = 0; p < $rootScope.modeltestset.activityTestCases.length; p++) {
745             var activityTestCases = $rootScope.modeltestset.activityTestCases[p];
746             if (activityTestCases.mappedRequirements != null) {
747               for (var i = 0; i < activityTestCases.mappedRequirements.length; i++) {
748                 // $rootScope.testCaseRequirements
749                 // .push(activityTestCases.mappedRequirements[i]);
750                 var testCaseNames = $rootScope.validTestRequirements[activityTestCases.mappedRequirements[i]];
751                 if (testCaseNames == null) {
752                   testCaseNames = [];
753                 }
754                 if (activityTestCases.version != null)
755                   var testCase = activityTestCases.testCaseName +
756                     "_" +
757                     activityTestCases.version;
758                 else
759                   var testCase = activityTestCases.testCaseName;
760                 testCaseNames.push(testCase);
761                 $rootScope.validTestRequirements[activityTestCases.mappedRequirements[i]] = testCaseNames;
762               }
763             }
764           }
765
766           $rootScope.isPalette = false;
767           $rootScope.isTestset = false;
768           $rootScope.isRequirementCoverage = true;
769           document.getElementById("modeler_name").textContent = "Test Case / Requirement Coverage";
770           // document.getElementById('propertyExplorer').classList.add('visible');
771           // console.log("modeltestset"+JSON.stringify($rootScope.modeltestset));
772           // $( "#propertyExplorer" ).prev().css(
773           // "display", "none" );
774           $('div').find('.k-collapse-next').click();
775           // $rootScope.$apply();
776
777         };
778
779         $scope.activityModelling = function() {
780
781           // window.open("./bpmn-js-examples-master/modeler/dist/index.html",
782           // "_self");
783           // $location.path('/activity_modelling');
784         };
785         /*
786          * $scope.openProject = function(){
787          * $location.path('/dashboard_upload'); };
788          */
789         $rootScope.cldsOpenTemplateProperties = function() {
790
791           var dlg = dialogs
792             .create(
793               'partials/portfolios/global_template_properties.html',
794               'CldsOpenTemplateCtrl', {}, {
795                 size: 'lg',
796                 keyboard: true,
797                 backdrop: 'static',
798                 windowClass: 'my-class'
799               });
800
801           dlg.result.then(function(name) {
802
803             // $scope.modelName =modelName;
804             // $("#" +
805             // selected_model).addClass("selectedcolor");
806             // alert ("model name:"+$scope.modelName);
807           }, function() {
808
809             // if(angular.equals($scope.name,''))
810             // $scope.name = 'You did not enter in your
811             // name!';
812           });
813         }
814
815         $scope.cldsClose = function() {
816
817           var dlg = dialogs
818             .create(
819               'partials/portfolios/confirmation_window.html',
820               'CldsOpenTemplateCtrl', {
821                 closable: true,
822                 draggable: true
823               }, {
824                 size: 'lg',
825                 keyboard: true,
826                 backdrop: 'static',
827                 windowClass: 'my-class'
828               });
829
830           dlg.result.then(function(name) {
831
832             // $scope.name = name;
833           }, function() {
834
835             // if(angular.equals($scope.name,''))
836             // $scope.name = 'You did not enter in your
837             // name!';
838           });
839         };
840         $scope.cldsOpenTemplate = function() {
841
842           var dlg = dialogs
843             .create(
844               'partials/portfolios/clds_open_template.html',
845               'CldsOpenTemplateCtrl', {
846                 closable: true,
847                 draggable: true
848               }, {
849                 size: 'lg',
850                 keyboard: true,
851                 backdrop: 'static',
852                 windowClass: 'my-class'
853               });
854
855           dlg.result.then(function(name) {
856
857             // $scope.name = name;
858           }, function() {
859
860             // if(angular.equals($scope.name,''))
861             // $scope.name = 'You did not enter in your
862             // name!';
863           });
864         };
865         $scope.saveConfirmationNotificationPopUp = function(
866           callBack) {
867
868           var dlg = dialogs
869             .create(
870               'partials/portfolios/save_confirmation.html',
871               'saveConfirmationModalPopUpCtrl', {
872                 closable: true,
873                 draggable: true
874               }, {
875                 size: 'lg',
876                 keyboard: true,
877                 backdrop: 'static',
878                 windowClass: 'my-class'
879               });
880
881           dlg.result.then(function(name) {
882             callBack("OK");
883           }, function() {
884             callBack(null);
885           });
886
887         };
888         $scope.cldsCreateTemplate = function() {
889
890           var dlg = dialogs
891             .create(
892               'partials/portfolios/clds_create_template.html',
893               'CldsOpenTemplateCtrl', {
894                 closable: true,
895                 draggable: true
896               }, {
897                 size: 'lg',
898                 keyboard: true,
899                 backdrop: 'static',
900                 windowClass: 'my-class'
901               });
902
903           dlg.result.then(function(name) {
904
905             // $scope.name = name;
906           }, function() {
907
908             // if(angular.equals($scope.name,''))
909             // $scope.name = 'You did not enter in your
910             // name!';
911           });
912
913         };
914         $scope.cldsRefreshASDC = function() {
915
916           var dlg = dialogs
917             .create(
918               'partials/portfolios/refresh_asdc.html',
919               'CldsOpenModelCtrl', {
920                 closable: true,
921                 draggable: true
922               }, {
923                 size: 'lg',
924                 keyboard: true,
925                 backdrop: 'static',
926                 windowClass: 'my-class'
927               });
928           dlg.result.then(function(name) {
929
930             // $scope.name = name;
931           }, function() {
932
933             // if(angular.equals($scope.name,''))
934             // $scope.name = 'You did not enter in your
935             // name!';
936           });
937         }
938         $scope.cldsRevertModel = function() {
939
940           var dlg = dialogs
941             .create(
942               'partials/portfolios/ConfirmRevertChanges.html',
943               'CldsOpenModelCtrl', {
944                 closable: true,
945                 draggable: true
946               }, {
947                 size: 'lg',
948                 keyboard: true,
949                 backdrop: 'static',
950                 windowClass: 'my-class'
951               });
952
953           dlg.result.then(function(name) {
954
955             // $scope.name = name;
956           }, function() {
957
958             // if(angular.equals($scope.name,''))
959             // $scope.name = 'You did not enter in your
960             // name!';
961           });
962
963         };
964
965         $scope.cldsRevertTemplate = function() {
966
967           var dlg = dialogs
968             .create(
969               'partials/portfolios/ConfirmRevertChanges.html',
970               'CldsOpenTemplateCtrl', {
971                 closable: true,
972                 draggable: true
973               }, {
974                 size: 'lg',
975                 keyboard: true,
976                 backdrop: 'static',
977                 windowClass: 'my-class'
978               });
979
980           dlg.result.then(function(name) {
981
982             // $scope.name = name;
983           }, function() {
984
985             // if(angular.equals($scope.name,''))
986             // $scope.name = 'You did not enter in your
987             // name!';
988           });
989
990         };
991         $scope.cldsTemplatePerformAction = function(
992           uiAction) {
993
994           var modelName = selected_model;
995           var controlNamePrefix = "ClosedLoop-";
996           var bpmnText = modelXML;
997           // serialize model properties
998           var propText = JSON.stringify(elementMap);
999
1000           var svgXml = "";
1001           console.log(abootDiagram.saveSVG({
1002             format: true
1003           }, function(err, xml) {
1004
1005             if (err)
1006               console.log("error")
1007             else
1008               console.log(xml)
1009             svgXml = xml;
1010           }));
1011           console.log("cldsTemplatePerformAction: " +
1012             uiAction + " modelName=" + modelName);
1013           console.log("cldsTemplatePerformAction: " +
1014             uiAction + " controlNamePrefix=" +
1015             controlNamePrefix);
1016           console.log("cldsTemplatePerformAction: " +
1017             uiAction + " bpmnText=" + bpmnText);
1018           console.log("cldsTemplatePerformAction: " +
1019             uiAction + " propText=" + propText);
1020           cldsTemplateService
1021             .processAction(uiAction, modelName,
1022               controlNamePrefix, bpmnText,
1023               propText, svgXml)
1024             .then(
1025               function(pars) {
1026                 console
1027                   .log("processAction");
1028                 console
1029                   .log("cldsTemplatePerformAction: pars=" +
1030                     pars);
1031                 cldsTemplateService
1032                   .processActionResponse(
1033                     modelName,
1034                     pars);
1035               },
1036               function(data) {
1037
1038                 // alert("setModel failed: "
1039                 // + data);
1040               });
1041         };
1042
1043         $rootScope.cldsOpenModelProperties = function() {
1044
1045           var dlg = dialogs
1046             .create(
1047               'partials/portfolios/global_properties.html',
1048               'GlobalPropertiesCtrl', {}, {
1049                 size: 'lg',
1050                 keyboard: true,
1051                 backdrop: 'static',
1052                 windowClass: 'my-class'
1053               });
1054
1055           dlg.result.then(function(name) {}, function() {});
1056         };
1057
1058         $scope.cldsOpenModel = function() {
1059
1060           var dlg = dialogs
1061             .create(
1062               'partials/portfolios/clds_open_model.html',
1063               'CldsOpenModelCtrl', {
1064                 closable: true,
1065                 draggable: true
1066               }, {
1067                 size: 'lg',
1068                 keyboard: true,
1069                 backdrop: 'static',
1070                 windowClass: 'my-class'
1071               });
1072
1073           dlg.result.then(function(name) {
1074
1075             // $scope.name = name;
1076           }, function() {
1077
1078             // if(angular.equals($scope.name,''))
1079             // $scope.name = 'You did not enter in your
1080             // name!';
1081           });
1082         };
1083         $scope.cldsCreateModel = function() {
1084
1085           var dlg = dialogs
1086             .create(
1087               'partials/portfolios/clds_create_model_off_Template.html',
1088               'CldsOpenModelCtrl', {
1089                 closable: true,
1090                 draggable: true
1091               }, {
1092                 size: 'lg',
1093                 keyboard: true,
1094                 backdrop: 'static',
1095                 windowClass: 'my-class'
1096               });
1097
1098           dlg.result.then(function(name) {
1099
1100             // $scope.name = name;
1101           }, function() {
1102
1103             // if(angular.equals($scope.name,''))
1104             // $scope.name = 'You did not enter in your
1105             // name!';
1106           });
1107
1108         };
1109         $scope.extraUserInfo = function() {
1110
1111           var dlg = dialogs
1112             .create(
1113               'partials/portfolios/extra_user_info.html',
1114               'ExtraUserInfoCtrl', {
1115                 closable: true,
1116                 draggable: true
1117               }, {
1118                 size: 'lg',
1119                 keyboard: true,
1120                 backdrop: 'static',
1121                 windowClass: 'my-class'
1122               });
1123
1124           dlg.result.then(function(name) {}, function() {});
1125
1126         };
1127         $scope.cldsPerformAction = function(uiAction) {
1128
1129           var modelName = selected_model;
1130           var controlNamePrefix = "ClosedLoop-";
1131           var bpmnText = modelXML;
1132           // serialize model properties
1133           var propText = JSON.stringify(elementMap);
1134           var templateName = selected_template
1135
1136           var svgXml = "";
1137           console.log(abootDiagram.saveSVG({
1138             format: true
1139           }, function(err, xml) {
1140             if (err)
1141               console.log("error")
1142             else
1143               console.log(xml)
1144             svgXml = xml;
1145           }));
1146           console.log("cldsPerformAction: " + uiAction +
1147             " modelName=" + modelName);
1148           console.log("cldsPerformAction: " + uiAction +
1149             " controlNamePrefix=" +
1150             controlNamePrefix);
1151           console.log("cldsPerformAction: " + uiAction +
1152             " bpmnText=" + bpmnText);
1153           console.log("cldsPerformAction: " + uiAction +
1154             " propText=" + propText);
1155           console.log("cldsPerformAction: " + uiAction +
1156             " typeID=" + typeID);
1157           console.log("cldsPerformAction: " + uiAction +
1158             " deploymentId=" + deploymentId);
1159           cldsModelService
1160             .processAction(uiAction, modelName,
1161               controlNamePrefix, bpmnText,
1162               propText, svgXml, templateName,
1163               typeID, deploymentId)
1164             .then(
1165               function(pars) {
1166                 console
1167                   .log("cldsPerformAction: pars=" +
1168                     pars);
1169                 cldsModelService
1170                   .processRefresh(pars);
1171               },
1172               function(data) {
1173
1174                 // alert("setModel failed: "
1175                 // + data);
1176               });
1177         };
1178         $scope.refreshStatus = function() {
1179             var modelName = selected_model;
1180             var svgXml = "";
1181             console.log(abootDiagram.saveSVG({
1182               format: true
1183             }, function(err, xml) {
1184               if (err)
1185                 console.log("error")
1186               else
1187                 console.log(xml)
1188               svgXml = xml;
1189             }));
1190             console.log("refreStatus modelName=" + modelName);
1191             cldsModelService
1192               .getModel(modelName)
1193               .then(
1194                 function(pars) {
1195                   console
1196                     .log("refreStatus: pars=" +
1197                       pars);
1198                   cldsModelService
1199                     .processRefresh(pars);
1200                 },
1201                 function(data) {
1202                 });
1203           };
1204         $scope.cldsConfirmPerformAction = function(uiAction) {
1205           var dlg = dialogs.confirm('Message',
1206             'Do you want to ' +
1207             uiAction.toLowerCase() +
1208             ' the closed loop?');
1209           dlg.result.then(function(btn) {
1210
1211             $scope.cldsPerformAction(uiAction);
1212           }, function(btn) {
1213
1214             // $modalInstance.close("closed");
1215           });
1216         };
1217
1218         $scope.cldsConfirmToggleDeployPerformAction = function(
1219           uiAction) {
1220
1221           var dlg = dialogs.confirm('Message',
1222             'Do you want to ' +
1223             uiAction.toLowerCase() +
1224             ' the closed loop?');
1225           dlg.result.then(function(btn) {
1226             cldsToggleDeploy(uiAction.toLowerCase());
1227           }, function(btn) {
1228
1229             // $modalInstance.close("closed");
1230           });
1231         };
1232
1233         function cldsToggleDeploy(uiAction) {
1234           var modelName = selected_model;
1235           var controlNamePrefix = "ClosedLoop-";
1236           var bpmnText = modelXML;
1237           // serialize model properties
1238           var propText = JSON.stringify(elementMap);
1239           var templateName = selected_template;
1240           var svgXml = "";
1241
1242           console.log(abootDiagram.saveSVG({
1243             format: true
1244           }, function(err, xml) {
1245             if (err)
1246               console.log("error")
1247             else
1248               console.log(xml)
1249             svgXml = xml;
1250           }));
1251           console.log("cldsPerformAction: " + uiAction +
1252             " modelName=" + modelName);
1253           console.log("cldsPerformAction: " + uiAction +
1254             " controlNamePrefix=" +
1255             controlNamePrefix);
1256           console.log("cldsPerformAction: " + uiAction +
1257             " bpmnText=" + bpmnText);
1258           console.log("cldsPerformAction: " + uiAction +
1259             " propText=" + propText);
1260           console.log("cldsPerformAction: " + uiAction +
1261             " modelEventService=" +
1262             modelEventService);
1263           console.log("cldsPerformAction: " + uiAction +
1264             " typeID=" + typeID);
1265           console.log("cldsPerformAction: " + uiAction +
1266             " deploymentId=" + deploymentId);
1267           cldsModelService
1268             .toggleDeploy(uiAction, modelName,
1269               controlNamePrefix, bpmnText,
1270               propText, svgXml, templateName,
1271               typeID, controlNameUuid,
1272               modelEventService, deploymentId)
1273             .then(
1274               function(pars) {
1275                 typeID = pars.typeId;
1276                 controlNameUuid = pars.controlNameUuid;
1277                 selected_template = pars.templateName;
1278                 modelEventService = pars.event;
1279                 // actionCd =
1280                 // pars.event.actionCd;
1281                 actionStateCd = pars.event.actionStateCd;
1282                 deploymentId = pars.deploymentId;
1283                 cldsModelService
1284                   .processActionResponse(
1285                     modelName,
1286                     pars);
1287
1288               },
1289               function(data) {
1290
1291               });
1292         }
1293         $scope.managePerformAction = function(action) {
1294           if (action.toLowerCase() === "delete") {
1295             cldsModelService
1296               .manageAction(
1297                 selected_model,
1298                 "805b9f83-261f-48d9-98c7-8011fc2cc8e8",
1299                 "ClosedLoop-ABCD-0000.yml")
1300               .then(function(pars) {
1301
1302               }, function(data) {
1303
1304                 // alert("setModel failed: " +
1305                 // data);
1306               });
1307           }
1308         };
1309         $scope.manageConfirmPerformAction = function(
1310           uiAction) {
1311
1312           var dlg = dialogs.confirm('Message',
1313             'Do you want to ' +
1314             uiAction.toLowerCase() +
1315             ' the closed loop?');
1316           dlg.result.then(function(btn) {
1317
1318             $scope.managePerformAction(uiAction);
1319           }, function(btn) {
1320
1321             // $modalInstance.close("closed");
1322           });
1323         };
1324         $scope.VesCollectorWindow = function(vesCollector) {
1325
1326           if (isTemplate) {
1327             var dlg = dialogs
1328               .create(
1329                 'partials/portfolios/Template_model.html',
1330                 'ImportSchemaCtrl',
1331                 vesCollector, {
1332                   closable: true,
1333                   draggable: true
1334                 }, {
1335                   size: 'lg',
1336                   keyboard: true,
1337                   backdrop: 'static',
1338                   windowClass: 'my-class'
1339                 });
1340             dlg.result.then(function(name) {
1341
1342             }, function() {
1343
1344
1345             });
1346           } else { // if (isTemplate)
1347
1348             var dlg = dialogs
1349               .create(
1350                 'partials/portfolios/vesCollector_properties.html',
1351                 'ImportSchemaCtrl', {
1352                   closable: true,
1353                   draggable: true
1354                 }, {
1355                   size: 'lg',
1356                   keyboard: true,
1357                   backdrop: 'static',
1358                   windowClass: 'my-class'
1359                 });
1360
1361             dlg.result.then(function(name) {
1362
1363             }, function() {
1364
1365             });
1366
1367           }
1368         };
1369
1370         $scope.HolmesWindow = function(holmes) {
1371
1372           if (isTemplate) {
1373             var partial = 'partials/portfolios/Template_model.html'
1374           } else {
1375             var partial = 'partials/portfolios/holmes_properties.html'
1376           }
1377
1378           var dlg = dialogs
1379             .create(
1380               partial,
1381               'ImportSchemaCtrl',
1382               holmes, {
1383                 closable: true,
1384                 draggable: true
1385               }, {
1386                 size: 'lg',
1387                 keyboard: true,
1388                 backdrop: 'static',
1389                 windowClass: 'my-class'
1390               });
1391         };
1392
1393         $scope.TCAWindow = function(tca) {
1394           if (isTemplate) {
1395             var dlg = dialogs
1396               .create(
1397                 'partials/portfolios/Template_model.html',
1398                 'ImportSchemaCtrl',
1399                 tca, {
1400                   closable: true,
1401                   draggable: true
1402                 }, {
1403                   size: 'lg',
1404                   keyboard: true,
1405                   backdrop: 'static',
1406                   windowClass: 'my-class'
1407                 });
1408             dlg.result.then(function(name) {}, function() {
1409               // if(angular.equals($scope.name,''))
1410               // $scope.name = 'You did not enter in
1411               // your name!';
1412             });
1413           } else {
1414             var dlg = dialogs
1415               .create(
1416                 'partials/portfolios/tca_properties.html',
1417                 'ImportSchemaCtrl', {
1418                   closable: true,
1419                   draggable: true
1420                 }, {
1421                   size: 'lg',
1422                   keyboard: true,
1423                   backdrop: 'static',
1424                   windowClass: 'my-class'
1425                 });
1426
1427             dlg.result.then(function(name) {
1428               // $scope.name = name;
1429             }, function() {
1430               // if(angular.equals($scope.name,''))
1431               // $scope.name = 'You did not enter in
1432               // your name!';
1433             });
1434           }
1435         };
1436
1437         $scope.PolicyWindow = function(policy) {
1438
1439           if (isTemplate) {
1440             var dlg = dialogs
1441               .create(
1442                 'partials/portfolios/Template_model.html',
1443                 'ImportSchemaCtrl',
1444                 policy, {
1445                   closable: true,
1446                   draggable: true
1447                 }, {
1448                   size: 'lg',
1449                   keyboard: true,
1450                   backdrop: 'static',
1451                   windowClass: 'my-class'
1452                 });
1453             dlg.result.then(function(name) {
1454
1455             }, function() {
1456
1457               // if(angular.equals($scope.name,''))
1458               // $scope.name = 'You did not enter in
1459               // your name!';
1460             });
1461           } else {
1462             var dlg = dialogs
1463               .create(
1464                 'partials/portfolios/PolicyWindow_properties.html',
1465                 'ImportSchemaCtrl', {
1466                   closable: true,
1467                   draggable: true
1468                 }, {
1469                   size: 'lg',
1470                   keyboard: true,
1471                   backdrop: 'static',
1472                   windowClass: 'my-class'
1473                 });
1474
1475             dlg.result.then(function(name) {
1476
1477               // $scope.name = name;
1478             }, function() {
1479
1480               // if(angular.equals($scope.name,''))
1481               // $scope.name = 'You did not enter in
1482               // your name!';
1483             });
1484
1485           }
1486         };
1487
1488       }
1489     ]);
1490
1491 app.service('MenuService', ['$http', '$q', function($http, $q) {
1492
1493   /*
1494    * this.generateMDTTestSet = function(utmMDTRequest, generateTestSetMDTURL){
1495    *
1496    * console.log("generateMDTTestSet"); //alert("In generateMDTTestSet :: " +
1497    * JSON.stringify(utmMDTRequest)); var def = $q.defer(); var sets = [];
1498    *
1499    * $http.post(generateTestSetMDTURL, utmMDTRequest) .success(function(data){
1500    * console.log("success"); sets = data; def.resolve(data); })
1501    * .error(function(data){ console.log("error");
1502    * def.reject("GenerateMDTTestSet not successful"); });
1503    *
1504    * return def.promise; };
1505    */
1506 }]);
1507
1508 app.directive('focus', function($timeout) {
1509
1510   return {
1511     scope: {
1512       trigger: '@focus'
1513     },
1514     link: function(scope, element) {
1515       scope.$watch('trigger', function(value) {
1516
1517         if (value === "true") {
1518           $timeout(function() {
1519
1520             element[0].focus();
1521           });
1522         }
1523       });
1524     }
1525   };
1526 });
1527 app.directive('draggable', function($document) {
1528
1529   return function(scope, element, attr) {
1530
1531     var startX = 0,
1532       startY = 0,
1533       x = 0,
1534       y = 0;
1535     element.css({
1536       position: 'relative',
1537
1538       backgroundColor: 'white',
1539       cursor: 'move',
1540       display: 'block',
1541
1542     });
1543     element.on('mousedown', function(event) {
1544
1545       // Prevent default dragging of selected content
1546       // event.preventDefault();
1547       startX = event.screenX - x;
1548       startY = event.screenY - y;
1549       $document.on('mousemove', mousemove);
1550       $document.on('mouseup', mouseup);
1551     });
1552
1553     function mousemove(event) {
1554
1555       y = event.screenY - startY;
1556       x = event.screenX - startX;
1557       element.css({
1558         top: y + 'px',
1559         left: x + 'px'
1560       });
1561     }
1562
1563     function mouseup() {
1564
1565       $document.off('mousemove', mousemove);
1566       $document.off('mouseup', mouseup);
1567     }
1568   };
1569 });
1570
1571 app.factory('myHttpInterceptor', function($q, $window) {
1572
1573   return function(promise) {
1574
1575     return promise.then(function(response) {
1576
1577       return response;
1578     }, function(response) {
1579
1580       return $q.reject(response);
1581     });
1582   };
1583 });
1584
1585 app.run(['$route', function($route) {
1586
1587   $route.reload();
1588 }]);
1589
1590 function TestCtrl($scope) {
1591
1592   $scope.msg = "Hello from a controller method.";
1593   $scope.returnHello = function() {
1594
1595     return $scope.msg;
1596   }
1597 }
1598
1599 function importshema() {
1600
1601   angular.element(document.getElementById('navbar')).scope().importSchema();
1602
1603 }
1604
1605 function VesCollectorWindow(vesCollectorWin) {
1606   angular.element(document.getElementById('navbar')).scope()
1607     .VesCollectorWindow(vesCollectorWin);
1608 }
1609
1610 function HolmesWindow(holmesWin) {
1611   angular.element(document.getElementById('navbar')).scope()
1612     .HolmesWindow(holmesWin);
1613 }
1614
1615 function F5Window() {
1616
1617   angular.element(document.getElementById('navbar')).scope().F5Window();
1618
1619 }
1620
1621 function TCAWindow(tca) {
1622
1623   angular.element(document.getElementById('navbar')).scope().TCAWindow(tca);
1624
1625 }
1626
1627 function GOCWindow() {
1628
1629   angular.element(document.getElementById('navbar')).scope().GOCWindow();
1630
1631 }
1632
1633 function PolicyWindow(PolicyWin) {
1634
1635   angular.element(document.getElementById('navbar')).scope().PolicyWindow(
1636     PolicyWin);
1637
1638 }
1639
1640 function pathDetails(bpmnElementID, bpmnElementName, pathIdentifiers) {
1641
1642   angular.element(document.getElementById('navbar')).scope().pathDetails(
1643     bpmnElementID, bpmnElementName, pathIdentifiers);
1644
1645 }
1646
1647 function setdefaultvalue() {
1648
1649   angular.element(document.getElementById('navbar')).scope()
1650     .setDefaultValue();
1651
1652 }
1653
1654 function upgradeSchemaVersion() {
1655
1656   angular.element(document.getElementById('navbar')).scope()
1657     .upgradeSchemaVersion();
1658
1659 }
1660
1661 function saveProject() {
1662
1663   angular.element(document.getElementById('navbar')).scope().saveProject();
1664
1665 }
1666
1667 function modifySchema() {
1668
1669   angular.element(document.getElementById('navbar')).scope().modifySchema();
1670
1671 }
1672
1673 function definePID() {
1674
1675   angular.element(document.getElementById('navbar')).scope().definePID();
1676
1677 }
1678
1679 function defineServiceAcronym() {
1680
1681   angular.element(document.getElementById('navbar')).scope()
1682     .defineServiceAcronym();
1683
1684 }
1685
1686 function errorProperty(msg) {
1687
1688   angular.element(document.getElementById('navbar')).scope()
1689     .propertyExplorerErrorMessage(msg);
1690 }
1691
1692 function invisiblepropertyExplorer() {
1693
1694   angular.element(document.getElementById('navbar')).scope()
1695     .invisibleproperty();
1696 }
1697
1698 function updateDecisionLabel(originalLabel, newLabel) {
1699
1700   angular.element(document.getElementById('navbar')).scope()
1701     .updateDecisionLabels(originalLabel, newLabel);
1702 }
1703
1704 // Used to logout the session , when browser window was closed
1705 window.onunload = function() {
1706   window.localStorage.removeItem("isAuth");
1707   window.localStorage.removeItem("loginuser");
1708 };