5 * @name opnfvdashBoardAngularApp.controller:TableController
8 * Controller of the opnfvdashBoardAngularApp
10 angular.module('opnfvApp')
11 .controller('TableController', ['$scope', '$state', '$stateParams', '$http', 'TableFactory', '$timeout',
12 function($scope, $state, $stateParams, $http, TableFactory, $timeout) {
17 $scope.filterlist = [];
18 $scope.selection = [];
20 $scope.statusList = [];
21 $scope.projectList = [];
22 $scope.installerList = [];
23 $scope.versionlist = [];
27 $scope.selectStatus = [];
28 $scope.selectProjects = [];
29 $scope.selectInstallers = [];
30 $scope.selectVersion = null;
31 $scope.selectLoop = null;
32 $scope.selectTime = null;
34 $scope.statusClicked = false;
35 $scope.installerClicked = false;
36 $scope.projectClicked = false;
38 $scope.scenarios = {};
40 $scope.VersionConfig = {
46 placeholder: 'Version',
47 onChange: function(value) {
48 $scope.selectVersion = value;
62 onChange: function(value) {
63 $scope.selectLoop = value;
77 onChange: function(value) {
78 $scope.selectTime = value;
87 function getFilters() {
88 TableFactory.getFilter().get({
89 }).$promise.then(function(response) {
90 if (response != null) {
91 $scope.statusList = response.filters.status;
92 $scope.projectList = response.filters.projects;
93 $scope.installerList = response.filters.installers;
94 $scope.versionList = toSelectList(response.filters.version);
95 $scope.loopList = toSelectList(response.filters.loops);
96 $scope.timeList = toSelectList(response.filters.time);
98 $scope.selectStatus = copy($scope.statusList);
99 $scope.selectInstallers = copy($scope.installerList);
100 $scope.selectProjects = copy($scope.projectList);
101 $scope.selectVersion = response.filters.version[0];
102 $scope.selectLoop = response.filters.loops[0];
103 $scope.selectTime = response.filters.time[0];
112 function toSelectList(arr){
114 angular.forEach(arr, function(ele){
115 tempList.push({'title': ele});
122 angular.forEach(arr, function(ele){
128 function getScenarioData() {
131 'status': $scope.selectStatus,
132 'projects': $scope.selectProjects,
133 'installers': $scope.selectInstallers,
134 'version': $scope.selectVersion,
135 'loops': $scope.selectLoop,
136 'time': $scope.selectTime
139 TableFactory.getScenario(data).then(function(response) {
140 if (response.status == 200) {
141 $scope.scenarios = response.data.scenarios;
150 function getScenario(){
152 $scope.project_row = [];
153 angular.forEach($scope.selectInstallers, function(installer){
154 angular.forEach($scope.selectProjects, function(project){
156 'installer': installer,
159 $scope.project_row.push(temp);
165 $scope.scenario_rows = [];
166 angular.forEach($scope.scenarios, function(scenario, name){
170 'statusDisplay': null,
173 scenario_row.name = name;
174 scenario_row.status = scenario.status;
176 var scenarioStatusDisplay;
177 if (scenario.status == "success") {
178 scenarioStatusDisplay = "navy";
179 } else if (scenario.status == "danger") {
180 scenarioStatusDisplay = "danger";
181 } else if (scenario.status == "warning") {
182 scenarioStatusDisplay = "warning";
184 scenario_row.statusDisplay = scenarioStatusDisplay;
186 angular.forEach($scope.selectInstallers, function(installer){
187 angular.forEach($scope.selectProjects, function(project){
195 datadisplay.installer = installer;
196 datadisplay.project = project;
197 datadisplay.value = scenario.installers[installer][project].score;
199 var single_status = scenario.installers[installer][project].status;
200 if (single_status == "platinium") {
201 datadisplay.label = 'primary';
202 datadisplay.label_value = 'P';
203 } else if (single_status == "gold") {
204 datadisplay.label = 'danger';
205 datadisplay.label_value = 'G';
206 } else if (single_status == "silver") {
207 datadisplay.label = 'warning';
208 datadisplay.label_value = 'S';
209 } else if (single_status == null) {
211 scenario_row.datadisplay.push(datadisplay);
215 $scope.scenario_rows.push(scenario_row);
220 function clickBase(eleList, ele){
221 var idx = eleList.indexOf(ele);
223 eleList.splice(idx, 1);
229 $scope.clickStatus = function(status){
230 if($scope.selectStatus.length == $scope.statusList.length && $scope.statusClicked == false){
231 $scope.selectStatus = [];
232 $scope.statusClicked = true;
235 clickBase($scope.selectStatus, status);
237 if($scope.selectStatus.length == 0 && $scope.statusClicked == true){
238 $scope.selectStatus = copy($scope.statusList);
239 $scope.statusClicked = false;
245 $scope.clickInstaller = function(installer){
246 if($scope.selectInstallers.length == $scope.installerList.length && $scope.installerClicked == false){
247 $scope.selectInstallers = [];
248 $scope.installerClicked = true;
251 clickBase($scope.selectInstallers, installer);
253 if($scope.selectInstallers.length == 0 && $scope.installerClicked == true){
254 $scope.selectInstallers = copy($scope.installerList);
255 $scope.installerClicked = false;
261 $scope.clickProject = function(project){
262 if($scope.selectProjects.length == $scope.projectList.length && $scope.projectClicked == false){
263 $scope.selectProjects = [];
264 $scope.projectClicked = true;
267 clickBase($scope.selectProjects, project);
269 if($scope.selectProjects.length == 0 && $scope.projectClicked == true){
270 $scope.selectProjects = copy($scope.projectList);
271 $scope.projectClicked = false;