2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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 * ===================================================================
28 [ 'ngRoute', 'ngResource', 'ui.bootstrap', 'angular-loading-bar', 'ngAnimate',
29 'dialogs.main', 'ngSanitize', 'ngCookies', 'ui.bootstrap.modal' ])
30 .config([ 'cfpLoadingBarProvider', function(cfpLoadingBarProvider) {
32 cfpLoadingBarProvider.includeBar = true;
33 cfpLoadingBarProvider.includeSpinner = true;
35 .config(function($httpProvider) {
37 $httpProvider.interceptors.push('myHttpInterceptor');
38 var spinnerFunction = function spinnerFunction(data, headersGetter) {
42 $httpProvider.defaults.transformRequest.push(spinnerFunction);
49 'cfpLoadingBarProvider',
50 function($routeProvider, $locationProvider, cfpLoadingBarProvider,
51 $timeout, dialogs, $cookies) {
53 $locationProvider.html5Mode(false);
54 $routeProvider.when('/otherwise', {
55 templateUrl : 'please_wait.html',
56 controller : 'QueryParamsHandlerCtrl'
57 }).when('/dashboard', {
58 templateUrl : 'partials/portfolios/clds_modelling.html',
59 controller : 'DashboardCtrl'
60 }).when('/activity_modelling', {
61 templateUrl : 'partials/portfolios/clds_modelling.html',
62 controller : 'DashboardCtrl'
63 }).when('/authenticate', {
64 templateUrl : 'authenticate.html',
65 controller : 'AuthenticateCtrl'
66 }).when('/invalidlogin', {
67 templateUrl : 'invalid_login.html',
68 controller : 'PageUnderConstructionCtrl'
70 redirectTo : '/otherwise'
75 function($scope, $rootScope, $timeout, dialogs) {
78 $scope.lang = 'en-US';
79 $scope.language = 'English';
82 $scope.confirmed = 'No confirmation yet!';
86 // -- Listeners & Watchers --//
87 $scope.$watch('lang', function(val, old) {
91 $scope.language = 'English';
94 $scope.language = 'Spanish';
99 $rootScope.testCaseRequirements = [];
100 $rootScope.validTestRequirements = [];
101 $scope.setLanguage = function(lang) {
104 $translate.use(lang);
106 $rootScope.launch = function(which) {
120 var dlg = dialogs.confirm();
121 dlg.result.then(function(btn) {
123 $scope.confirmed = 'You confirmed "Yes."';
126 $scope.confirmed = 'You confirmed "No."';
130 var dlg = dialogs.create('/dialogs/custom.html',
131 'customDialogCtrl', {}, {
135 windowClass : 'my-class'
137 dlg.result.then(function(name) {
142 if (angular.equals($scope.name, ''))
143 $scope.name = 'You did not enter in your name!';
147 var dlg = dialogs.create('/dialogs/custom2.html',
148 'customDialogCtrl2', $scope.custom, {
156 'All is not supported, Please select interface(s)/version(s) to fetch real time federated coverage report.');
162 'You are about to fetch real time federated coverage report.This may take sometime!!!.');
163 dlg.result.then(function(btn) {
165 $scope.confirmed = 'You confirmed "Yes."';
168 $scope.confirmed = 'You confirmed "No."';
172 var dlg = dialogs.notify('Success',
173 'Request has been successfully processed.');
176 var dlg = dialogs.notify('Message',
177 'Please type Testscenario Name');
181 var _fakeWaitProgress = function() {
183 $timeout(function() {
185 if (_progress < 100) {
187 $rootScope.$broadcast('dialogs.wait.progress', {
188 'progress' : _progress
192 $rootScope.$broadcast('dialogs.wait.complete');
208 'userPreferencesService',
210 'extraUserInfoService',
211 function($scope, $rootScope, $timeout, dialogs, $location, MenuService,
212 Datafactory, userPreferencesService, cldsModelService,
213 extraUserInfoService) {
215 console.log("MenuCtrl");
216 $rootScope.screenName = "Universal Test Modeler";
217 $rootScope.loop_logs = [];
218 $rootScope.testSet = null;
219 $rootScope.contactUs = function() {
221 console.log("contactUs");
222 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.";
223 window.location.href = link;
225 extraUserInfoService.getUserInfo().then(function(pars) {
227 $scope.userInfo = pars;
228 if (!($scope.userInfo["permissionUpdateCl"])) {
233 $scope.emptyMenuClick = function(value, name) {
235 if ($rootScope.isNewClosed
236 && name != "Close Model" && name != "Properties CL") {
237 saveConfirmationNotificationPopUp();
241 function saveConfirmationNotificationPopUp() {
243 $scope.saveConfirmationNotificationPopUp(function(data) {
246 $rootScope.isNewClosed = false;
252 function isSaveCheck(name) {
254 if (name == "User Info") {
255 $scope.extraUserInfo();
256 } else if (name == "Wiki") {
258 } else if (name == "Contact Us") {
259 $rootScope.contactUs();
260 } else if (name == "Close Model") {
262 } else if (name == "Open CL") {
263 $scope.cldsOpenModel();
264 } else if (name == "Submit") {
265 $scope.cldsConfirmPerformAction("SUBMIT");
266 } else if (name == "Update") {
267 $scope.cldsConfirmPerformAction("UPDATE");
268 } else if (name == "Delete") {
269 $scope.cldsConfirmPerformAction("DELETE");
270 } else if (name == "Stop") {
271 $scope.cldsConfirmPerformAction("STOP");
272 } else if (name == "Restart") {
273 $scope.cldsConfirmPerformAction("RESTART");
274 } else if (name == "Refresh Status") {
275 $scope.refreshStatus();
276 } else if (name == "Properties CL") {
277 $scope.cldsOpenModelProperties();
278 } else if (name == "Deploy") {
279 $scope.cldsAskDeployParametersPerformAction();
280 } else if (name == "UnDeploy") {
281 $scope.cldsConfirmToggleDeployPerformAction("UnDeploy");
283 $rootScope.screenName = name;
284 $scope.updatebreadcrumb(value);
285 $location.path(value);
289 $rootScope.impAlerts = function() {
294 link : "/cldsOpenModel",
297 link : "/cldsOpenModelProperties",
298 name : "Properties CL"
304 link : "/cldsSubmit",
307 // disabled for Dublin since Policy doesn't support updating in this release
308 // link : "/cldsUpdate",
314 link : "/cldsRestart",
317 link : "/cldsDelete",
320 link : "/cldsDeploy",
323 link : "/cldsUnDeploy",
327 link : "/refreshStatus",
328 name : "Refresh Status"
331 link : "http://wiki.onap.org",
334 link : "/contact_us",
337 link : "/extraUserInfo",
342 Object.keys = function(obj) {
345 for ( var i in obj) {
346 if (obj.hasOwnProperty(i)) {
352 $scope.keyList = Object.keys($scope.tabs);
354 $scope.keyList = Object.keys($scope.tabs);
356 $scope.updatebreadcrumb = function(path) {
358 var currentURL = $location.path();
359 if (path != undefined) {
362 if (currentURL == "/dashboard") {
363 $rootScope.screenName = "Universal Test Modeler";
364 $rootScope.parentMenu = "Home";
365 $rootScope.rightTabName = "UTM Build Configuration";
368 angular.forEach($scope.keyList, function(value, key) {
371 $rootScope.parentMenu = value;
372 angular.forEach($scope.tabs[value],
373 function(value, key) {
375 if (currentURL == value.link) {
376 $rootScope.screenName = value.name;
384 $scope.updatebreadcrumb();
385 $scope.homePage = function() {
387 $location.path('/dashboard');
389 $scope.propertyExplorerErrorMessage = function(msg) {
391 var dlg = dialogs.notify('Error', msg);
393 $scope.activityModelling = function() {
396 $scope.cldsClose = function() {
398 var dlg = dialogs.create(
399 'partials/portfolios/confirmation_window.html',
400 'CldsOpenModelCtrl', {
407 windowClass : 'my-class'
409 dlg.result.then(function(name) {
411 // $scope.name = name;
414 // if(angular.equals($scope.name,''))
415 // $scope.name = 'You did not enter in your
419 $scope.saveConfirmationNotificationPopUp = function(callBack) {
421 var dlg = dialogs.create(
422 'partials/portfolios/save_confirmation.html',
423 'saveConfirmationModalPopUpCtrl', {
430 windowClass : 'my-class'
432 dlg.result.then(function(name) {
440 $rootScope.cldsOpenModelProperties = function() {
442 var dlg = dialogs.create(
443 'partials/portfolios/global_properties.html',
444 'GlobalPropertiesCtrl', {}, {
448 windowClass : 'my-class'
450 dlg.result.then(function(name) {
456 $scope.cldsOpenModel = function() {
458 var dlg = dialogs.create(
459 'partials/portfolios/clds_open_model.html', 'CldsOpenModelCtrl', {
466 windowClass : 'my-class'
468 dlg.result.then(function(name) {
473 $rootScope.refreshLoopLog = function() {
474 var newLogArray = [];
475 if (getLoopLogsArray() != undefined) {
476 newLogArray=getLoopLogsArray();
478 $rootScope.loop_logs.splice(0, $rootScope.loop_logs.length);
479 for (var i=0;i<newLogArray.length;i++) {
480 $rootScope.loop_logs.push(newLogArray[i]);
483 $scope.extraUserInfo = function() {
485 var dlg = dialogs.create(
486 'partials/portfolios/extra_user_info.html', 'ExtraUserInfoCtrl', {
493 windowClass : 'my-class'
495 dlg.result.then(function(name) {
501 $scope.cldsPerformAction = function(uiAction) {
502 var modelName = selected_model;
503 console.log("cldsPerformAction: " + uiAction + " modelName="
506 cldsModelService.processAction(uiAction, modelName).then(function(pars) {
507 console.log("cldsPerformAction: pars=" + pars);
508 $rootScope.refreshLoopLog();
513 $scope.refreshStatus = function() {
514 var modelName = selected_model;
515 console.log("refreStatus modelName=" + modelName);
516 cldsModelService.getModel(modelName).then(function(pars) {
517 console.log("refreStatus: pars=" + pars);
518 cldsModelService.processRefresh();
523 $scope.cldsConfirmPerformAction = function(uiAction) {
525 var dlg = dialogs.confirm('Message', 'Do you want to '
526 + uiAction.toLowerCase() + ' the closed loop?');
527 dlg.result.then(function(btn) {
529 $scope.cldsPerformAction(uiAction);
534 $scope.cldsAskDeployParametersPerformAction = function() {
536 var dlg = dialogs.create(
537 'partials/portfolios/deploy_parameters.html', 'DeploymentCtrl', {},
541 windowClass : 'deploy-parameters'
543 dlg.result.then(function() {
545 var confirm = dialogs.confirm('Deploy',
546 'Are you sure you want to deploy the closed loop?');
547 confirm.result.then(function() {
549 cldsToggleDeploy("deploy");
553 $scope.cldsConfirmToggleDeployPerformAction = function(uiAction) {
555 var dlg = dialogs.confirm('Message', 'Do you want to '
556 + uiAction.toLowerCase() + ' the closed loop?');
557 dlg.result.then(function(btn) {
559 cldsToggleDeploy(uiAction.toLowerCase());
564 function cldsToggleDeploy(uiAction) {
565 console.log("cldsPerformAction: " + uiAction + " modelName="
567 cldsModelService.toggleDeploy(uiAction, selected_model).then(
573 $scope.ToscaModelWindow = function (tosca_model) {
575 var dlg = dialogs.create('partials/portfolios/tosca_model_properties.html','ToscaModelCtrl',{closable:true,draggable:true},{size:'lg',keyboard: true,backdrop: 'static',windowClass: 'my-class'});
576 dlg.result.then(function(name){
580 $scope.PolicyWindow = function(policy) {
582 var dlg = dialogs.create(
583 'partials/portfolios/operational_policy_window.html',
584 'operationalPolicyCtrl', {
591 windowClass : 'my-class'
593 dlg.result.then(function(name) {
600 app.service('MenuService', [ '$http', '$q', function($http, $q) {
603 app.directive('focus', function($timeout) {
609 link : function(scope, element) {
611 scope.$watch('trigger', function(value) {
613 if (value === "true") {
614 $timeout(function() {
623 app.directive('draggable', function($document) {
625 return function(scope, element, attr) {
627 var startX = 0, startY = 0, x = 0, y = 0;
629 position : 'relative',
630 backgroundColor : 'white',
634 element.on('mousedown', function(event) {
636 startX = event.screenX - x;
637 startY = event.screenY - y;
638 $document.on('mousemove', mousemove);
639 $document.on('mouseup', mouseup);
641 function mousemove(event) {
643 y = event.screenY - startY;
644 x = event.screenX - startX;
652 $document.off('mousemove', mousemove);
653 $document.off('mouseup', mouseup);
657 app.factory('myHttpInterceptor', function($q, $window) {
659 return function(promise) {
661 return promise.then(function(response) {
664 }, function(response) {
666 return $q.reject(response);
670 app.run([ '$route', function($route) {
675 function F5Window() {
677 angular.element(document.getElementById('navbar')).scope().F5Window();
679 function GOCWindow() {
681 angular.element(document.getElementById('navbar')).scope().GOCWindow();
683 function ToscaModelWindow() {
684 angular.element(document.getElementById('navbar')).scope().ToscaModelWindow();
686 function PolicyWindow(PolicyWin) {
688 angular.element(document.getElementById('navbar')).scope().PolicyWindow(
691 function pathDetails(bpmnElementID, bpmnElementName, pathIdentifiers) {
693 angular.element(document.getElementById('navbar')).scope().pathDetails(
694 bpmnElementID, bpmnElementName, pathIdentifiers);
696 function setdefaultvalue() {
698 angular.element(document.getElementById('navbar')).scope()
701 function saveProject() {
703 angular.element(document.getElementById('navbar')).scope().saveProject();
706 function defineServiceAcronym() {
708 angular.element(document.getElementById('navbar')).scope()
709 .defineServiceAcronym();
711 function errorProperty(msg) {
713 angular.element(document.getElementById('navbar')).scope()
714 .propertyExplorerErrorMessage(msg);
716 function invisiblepropertyExplorer() {
718 angular.element(document.getElementById('navbar')).scope()
719 .invisibleproperty();
721 function updateDecisionLabel(originalLabel, newLabel) {
723 angular.element(document.getElementById('navbar')).scope()
724 .updateDecisionLabels(originalLabel, newLabel);
726 // Used to logout the session , when browser window was closed
727 window.onunload = function() {
729 window.localStorage.removeItem("isAuth");
730 window.localStorage.removeItem("loginuser");
731 window.localStorage.removeItem("invalidUser");