2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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 * ===================================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
27 function DashboardCtrl($scope,$rootScope,$resource, $http, $timeout, $location, $interval, $q, Datafactory)
29 console.log("//////////////DashboardCtrl");
30 $scope.autosaveInterval = 1800000;
31 $scope.testsetgendashboard = false;
32 $rootScope.isModel = false;
33 $rootScope.isPalette = false;
34 $rootScope.isTestSet = false;
35 $rootScope.isRequirementCoverage = false;
36 $rootScope.ispropertyExplorer = false;
37 $rootScope.parameters;
38 $scope.orientation ="horizontal";
39 $rootScope.ispropertyExplorer = false;
40 $rootScope.isActive =true;
42 $scope.selectedParent={};
43 $rootScope.utmModels={};
44 $rootScope.selectedModelName;
45 $rootScope.dialogName="";
48 $interval( function(){
49 console.log("interval");
50 AutosaveProject($scope,$rootScope,$resource, $http, $timeout, $location, $interval, $q, Datafactory);
51 }, $scope.autosaveInterval);
54 $rootScope.onSelectActivityModel =function(obj)
56 console.log("onSelectActivityModel");
58 $rootScope.isPalette = true;
59 $rootScope.isTestSet = false;
60 $rootScope.isRequirementCoverage = false;
61 $rootScope.ispropertyExplorer = false;
62 //document.getElementById('propertyExplorer').classList.remove('visible');
64 //$( "#propertyExplorer" ).prev().css( "display" ,"block");
65 $( "#activity_modeler" ).prev().css( "display", "block" );
66 $( 'div' ).find('.k-expand-next').click();
69 document.getElementById("modeler_name").textContent="Activity Modeler" ;
72 document.getElementById("modeler_name").textContent="Activity Modeler"+" - "+ selected_model ;
75 $rootScope.modelName = selected_model;
77 $rootScope.modeltestset = list_model_test_sets[selected_model];
78 if(list_model_schema_extensions[selected_model] == null){
79 if(list_model_schema_extensions[$rootScope.utmModels.name] != null) {
80 list_model_schema_extensions[selected_model] = jQuery.extend(true, {}, list_model_schema_extensions[$rootScope.utmModels.name]);
82 list_model_schema_extensions[selected_model] = {};
86 $rootScope.initProjectExplorer();
89 changecolor(selected_model);
93 $scope.selectActivityTestSet =function()
95 console.log("selectActivityTestSet");
96 $rootScope.isPalette = false;
97 $rootScope.isRequirementCoverage = false;
98 $rootScope.isTestset = true;
99 document.getElementById("modeler_name").textContent="UTM Test Set";
100 //document.getElementById('propertyExplorer').classList.add('visible');
101 //$( "#propertyExplorer" ).prev().css( "display" ,"none");
102 $( 'div' ).find('.k-collapse-next').click();
103 $rootScope.modeltestset = list_model_test_sets[selected_model];
107 $scope.showPalette= function(){
108 console.log("showPalette");
109 //alert("showPalette()");
110 $rootScope.isModel = true;
111 // $rootScope.isPalette = true;
115 //$scope.initialShow=false;
117 if("/testsetgendashboard"==$location.url())
119 $scope.testsetgendashboard = true;
122 $rootScope.total_users = 0;
123 $scope.showUserView = true;
124 $scope.showTestExecution = true;
125 //$rootScope.total_accounts = 606;
126 $scope.showAccountView = true;
128 $rootScope.total_creation_times = 0;
129 $rootScope.success_rate_percent = 0;//(((data.data[0].value*1.0)/(data.data[0].value+data.data[1].value))*100).toFixed();
130 $rootScope.total_accounts = 0;
131 $scope.showCreation_timeView = true;
132 $scope.showSuccess_ratePercent = true;
135 //$scope.generalMessages= "This section will show general messages/alerts.";
136 $scope.gridHeaderMessages= "TestData Self-Service: Select TestCase and Click on Run button!!!";
140 $scope.dt = new Date();
141 $scope.clear = function () {
142 console.log("clear");
146 // Disable weekend selection
147 $scope.disabled = function(date, mode) {
148 console.log("disabled");
149 return ( mode === 'day' && ( date.getDay() === 0 || date.getDay() === 6 ) );
152 $scope.toggleMin = function() {
153 console.log("toggleMin");
154 $scope.minDate = $scope.minDate ? null : new Date();
158 $scope.open2 = function($event) {
159 console.log("open2");
160 $event.preventDefault();
161 $event.stopPropagation();
162 console.log(' herro: is the value of opened');
163 $scope.opened = true;
164 console.log($scope.opened + ' is the value of opened');
167 $scope.dateOptions = {
172 $scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
173 $scope.format = $scope.formats[0];
175 $scope.disabled = function(date, mode)
177 console.log("disabled");
178 return ( mode === 'day' && ( date.getDay() === -1 || date.getDay() === 7 ) );
181 $scope.maxDate = new Date();
184 $scope.open = function($event,opened) {
186 $event.preventDefault();
187 $event.stopPropagation();
189 $scope[opened] = true;
193 $scope.dateOptions = {
194 'year-format': "'yy'",
198 $scope.date = "29-December-2014";
199 $scope.date2 = new Date();
201 $scope.printDate = function()
203 console.log("printDate");
212 $scope.returnObjectArray = function(arrayObj)
214 console.log("returnObjectArray");
215 var newArrayObj = [];
217 angular.forEach(arrayObj, function(value, key)
219 console.log("arrayObj");
220 newArrayObj.push({"data":value});
227 $scope.returnTestScenarioTstObjectArray = function(arrayObj)
229 console.log("returnTestScenarioTstObjectArray");
230 var newArrayObj = [];
232 angular.forEach(arrayObj, function(value, key)
234 console.log("arrayObj");
235 if( value.testScenarioInstances !=undefined && value.testScenarioInstances.length !=0){
236 var tempLabel = value.testScenarioInstances[0].label.split(":");
237 newArrayObj.push({"data":tempLabel[0]});
248 $scope.returnOverRiddenObjectArray = function(arrayObj)
250 console.log("returnOverRiddenObjectArray");
251 var newArrayObj = [];
253 angular.forEach(arrayObj, function(value, key)
255 console.log("arrayObj");
256 newArrayObj.push({"data":value.name});
265 $rootScope.filterRouter = 'partials/DashboardFilters.html';
266 $scope.isActivePROD = true;
267 $scope.isActiveQC = false;
268 $rootScope.reload = function(env)
270 console.log("reload");
273 $scope.showTDSSView = true;
275 $scope.ReLoadDashboardFromViewResetComboBox = function(type, amount)//('Users','All') ('Accounts','All') ('Creation_times','All')
277 console.log("ReLoadDashboardFromViewResetComboBox");
282 //////////////////////////////////
284 $scope.total_tdr_team_selected_model = [];
285 $scope.total_tdr_users_selected_model = [];
286 $scope.total_tdr_requests_selected_model = [];
287 $scope.total_tdr_entities_selected_model = [];
289 $scope.reloadTDRDashboard = function(name)
291 console.log("reloadTDRDashboard");
292 var url = "/testdata-service/test-data-request/dashboard/counts.json?";
294 $http.get(url+params).success(function(data)
296 console.log("success");
297 $scope.total_tdr_team_count = data.result.dashboardCountModel.teams;
298 $scope.total_tdr_users_count = data.result.dashboardCountModel.users;
299 $scope.total_tdr_requests_count = data.result.dashboardCountModel.requests;
300 $scope.total_tdr_entities_count = data.result.dashboardCountModel.entities;
305 $scope.total_tdr_team_array = $scope.returnObjectArray(data.result.tdrDashboardModel.teams);
306 $scope.TDRTeamGridId.api().clear().draw();
307 $scope.TDRTeamGridId.fnAddData($scope.total_tdr_team_array);
313 $scope.total_tdr_users_array = $scope.returnObjectArray(data.result.tdrDashboardModel.users);
314 $scope.TDRUserGridId.api().clear().draw();
315 $scope.TDRUserGridId.fnAddData($scope.total_tdr_users_array);
320 $scope.total_tdr_entities_array = $scope.returnObjectArray(data.result.tdrDashboardModel.entities);
321 $scope.TDREntitiesGridId.api().clear().draw();
322 $scope.TDREntitiesGridId.fnAddData($scope.total_tdr_entities_array);
327 $scope.total_tdr_requests_array = $scope.returnObjectArray(data.result.tdrDashboardModel.requests);
328 $scope.TDRNumberGridId.api().clear().draw();
329 $scope.TDRNumberGridId.fnAddData($scope.total_tdr_requests_array);
336 $scope.loadTDRDashboard = function()
338 console.log("loadTDRDashboard");
339 $rootScope.launch('wait');
342 var apiJobUrl = "/utm-service/em/jobs?timezoneOffset=420";
344 $http.get(apiJobUrl).success(function(data)
346 console.log("success");
347 $scope.total_test_scenario_count = data.length;
350 $scope.TDRNumberGridId = $('#TDRNumberGridId').dataTable( {
354 { "sTitle": "","mDataProp": null, "sWidth": "20px", "bSortable": false},
355 { "sTitle":"Total TestScenarios","mDataProp": "data","bSortable": true}
357 //"columns": [{"data": "data"}],
358 "order": [[ 1, "asc" ]],
363 "bScrollCollapse": false,
364 "bLengthChange":false,
366 "search": {"caseInsensitive": true},
369 "sScrollXInner": "100%",
370 "fnCreatedRow": function( nRow, aData, iDataIndex )
372 console.log("fnCreatedRow");
373 $(nRow).children("td").css("overflow", "hidden");
374 $(nRow).children("td").css("white-space", "nowrap");
375 $(nRow).children("td").css("text-overflow", "ellipsis");
379 angular.forEach($scope.total_tdr_requests_selected_model, function (value)
381 console.log("total_tdr_requests_selected_model");
382 if(aData.data==value.id)
390 $('td:eq(0)', nRow).html( '<span class="tdr_checkbox tdr_checkbox_glyphicon_glyphicon_ok glyphicon glyphicon-ok" id="'+aData.data+'"></span>');
394 $('td:eq(0)', nRow).html( '<span class="tdr_checkbox tdr_checkbox_glyphicon_glyphicon_unchecked glyphicon glyphicon-unchecked" id="'+aData.data+'"></span>');
401 $scope.total_tdr_requests_array = $scope.returnOverRiddenObjectArray(data);
403 if($scope.total_tdr_requests_array.length > 0)
405 $scope.TDRNumberGridId.fnAddData($scope.total_tdr_requests_array);
412 $('#TDRNumberGridId tbody').on( 'click', 'td', function ()
414 console.log("click");
415 var position = $scope.TDRNumberGridId.fnGetPosition(this); // getting the clicked row position
420 var valueX = this.innerHTML;
422 $('.tdr_checkbox').each(function(i, obj)
424 console.log("tdr_checkbox");
425 var uncheck = $(obj).hasClass( "glyphicon-unchecked");
427 if(valueX==obj.id && uncheck)
429 $(obj).attr('class','tdr_checkbox tdr_checkbox_glyphicon_glyphicon_ok glyphicon glyphicon-ok');
431 else if(valueX==obj.id && !uncheck)
433 $(obj).attr('class','tdr_checkbox tdr_checkbox_glyphicon_glyphicon_unchecked glyphicon glyphicon-unchecked');
438 if($('.tdr_checkbox_glyphicon_glyphicon_ok').length <= 0)
440 $scope.total_tdr_requests_selected_model = [];
441 $scope.total_tdr_requests_selected_model.push({'id':'All'});
445 $scope.total_tdr_requests_selected_model = [];
447 $('.tdr_checkbox_glyphicon_glyphicon_ok').each(function(i, obj)
449 console.log("tdr_checkbox_glyphicon_glyphicon_ok");
450 $scope.total_tdr_requests_selected_model.push({'id':obj.id});
457 var valueX = this.innerHTML.substring(this.innerHTML.indexOf("id=\"")+4,this.innerHTML.length-9);
459 $('.tdr_checkbox').each(function(i, obj)
461 console.log("tdr_checkbox");
462 var uncheck = $(obj).hasClass( "glyphicon-unchecked");
464 if(valueX==obj.id && uncheck)
466 $(obj).attr('class','tdr_checkbox tdr_checkbox_glyphicon_glyphicon_ok glyphicon glyphicon-ok');
468 else if(valueX==obj.id && !uncheck)
470 $(obj).attr('class','tdr_checkbox tdr_checkbox_glyphicon_glyphicon_unchecked glyphicon glyphicon-unchecked');
476 if($('.tdr_checkbox_glyphicon_glyphicon_ok').length <= 0)
478 $scope.total_tdr_requests_selected_model = [];
479 $scope.total_tdr_requests_selected_model.push({'id':'All'});
483 $scope.total_tdr_requests_selected_model = [];
484 $('.tdr_checkbox_glyphicon_glyphicon_ok').each(function(i, obj)
486 console.log("tdr_checkbox_glyphicon_glyphicon_ok");
487 $scope.total_tdr_requests_selected_model.push({'id':obj.id});
492 $scope.reloadTDRDashboard('request');
494 //$scope.initialShow=true;
495 $rootScope.$broadcast('dialogs.wait.complete');
504 $scope.getCommaSeparatedString = function(json)
506 console.log("getCommaSeparatedString");
507 if(json==undefined || json==null)
515 for (var dString in json)
517 result += json[dString].id + ",";
521 var res = result.match(/All,/g);
523 if(res!=null && result.split(",").length > 1)
525 result = result.replace("All,", "");
528 if(!found || result=="")
533 return result.replace(/,(\s+)?$/, '');
537 /*if("/dashboard"==$location.url())
539 $scope.loadTDRDashboard();
544 $scope.reloadTDRDashboardFromReset = function(name)
546 console.log("reloadTDRDashboardFromReset");
547 var url = "/testdata-service/test-data-request/dashboard/counts.json?";
548 var params = "teams="+$scope.getCommaSeparatedString($scope.total_tdr_team_selected_model);
549 params = params + "&users="+$scope.getCommaSeparatedString($scope.total_tdr_users_selected_model);
550 params = params + "&requests="+$scope.getCommaSeparatedString($scope.total_tdr_requests_selected_model);
551 params = params + "&status="+$scope.getCommaSeparatedString($scope.total_tdr_entities_selected_model);
553 $http.get(url+params).success(function(data)
555 console.log("success");
556 $scope.total_tdr_team_count = data.result.dashboardCountModel.teams;
557 $scope.total_tdr_users_count = data.result.dashboardCountModel.users;
558 $scope.total_tdr_requests_count = data.result.dashboardCountModel.requests;
559 $scope.total_tdr_entities_count = data.result.dashboardCountModel.entities;
561 $scope.total_tdr_team_array = $scope.returnObjectArray(data.result.tdrDashboardModel.teams);
562 $scope.TDRTeamGridId.api().clear().draw();
563 $scope.TDRTeamGridId.fnAddData($scope.total_tdr_team_array);
565 $scope.total_tdr_users_array = $scope.returnObjectArray(data.result.tdrDashboardModel.users);
566 $scope.TDRUserGridId.api().clear().draw();
567 $scope.TDRUserGridId.fnAddData($scope.total_tdr_users_array);
569 $scope.total_tdr_entities_array = $scope.returnObjectArray(data.result.tdrDashboardModel.entities);
570 $scope.TDREntitiesGridId.api().clear().draw();
571 $scope.TDREntitiesGridId.fnAddData($scope.total_tdr_entities_array);
573 $scope.total_tdr_requests_array = $scope.returnObjectArray(data.result.tdrDashboardModel.requests);
574 $scope.TDRNumberGridId.api().clear().draw();
575 $scope.TDRNumberGridId.fnAddData($scope.total_tdr_requests_array);
581 $scope.ReLoadTDRDashboard = function(name)
583 console.log("ReLoadTDRDashboard");
586 $scope.total_tdr_team_selected_model = [];
591 $scope.total_tdr_users_selected_model = [];
596 $scope.total_tdr_entities_selected_model = [];
601 $scope.total_tdr_requests_selected_model = [];
604 $scope.reloadTDRDashboardFromReset(name);
608 $rootScope.populateUTMModelArray= function(utm_models,utmModels){
609 console.log("populateUTMModelArray");
610 var modelName =utmModels.name;
611 if (utmModels != null && utmModels.name != null) {
612 if($rootScope.oldUTMModels != null && $rootScope.oldUTMModels.length > 0){
613 for(var i=0 ;i<$rootScope.oldUTMModels.length;i++ ){
614 var tempOldName = $rootScope.oldUTMModels[i];
615 console.log("new model name from map:"+old_new_model_name[tempOldName]);
616 if( utmModels.name == old_new_model_name[tempOldName]){
617 modelName = $rootScope.oldUTMModels[i];
622 utm_model.modelName = utmModels.name;
623 utm_model.modelXML = list_models[modelName];
624 utm_model.repeatableHeirachicalSchemaElements = {};
625 utm_model.repeatableHeirachicalSchemaElements = list_model_repeatable_heirarchical_elements[modelName];
627 utm_model.testManagementDetails = {};
628 utm_model.testManagementDetails = list_model_test_management_details[modelName];
630 var activitytestset={};
631 activitytestset.invalidModelException=null;
632 activitytestset.serviceName=serviceName;
633 activitytestset.activityTestCases=[];
634 if (list_model_test_sets[modelName] != null && list_model_test_sets[modelName].activityTestCases != null) {
635 activitytestset.activityTestCases=angular.copy(list_model_test_sets[modelName].activityTestCases);
637 utm_model.activityTestSet = activitytestset;
639 utm_model.utmPropertyExplorer = {};
640 utm_model.utmPropertyExplorer.pathDetailsList = [];
641 if (list_model_path_details[modelName] != null) {
642 utm_model.utmPropertyExplorer.pathDetailsList = angular.copy(list_model_path_details[modelName]);
645 utm_model.utmModelSchemaExtention = {};
646 utm_model.utmModelSchemaExtention.utmSchemaExtentionMap = {};
647 if (list_model_schema_extensions[modelName] != null) {
648 utm_model.utmModelSchemaExtention = angular.copy(list_model_schema_extensions[modelName]);
651 utm_models.push(utm_model);
652 if(utmModels.subModels != null && utmModels.subModels.length>0){
653 for(var i=0 ; i<utmModels.subModels.length;i++) {
655 subModel = utmModels.subModels[i];
656 $scope.populateUTMModelArray(utm_models,subModel);
663 /*$scope.getPallette = function(){
671 function changecolor(selected_model)
673 console.log("changecolor");
676 //var modelNames =[];
678 $(".models").each(function(i){
680 var model_value = $(this).text().trim();
681 //modelName.push(model_value);
682 if(model_value == selected_model || model_value == "")
684 $(this).addClass("selectedcolor");
688 $(this).removeClass("selectedcolor");