First step for no-repeat support
This commit is contained in:
parent
80934ea2e9
commit
5251c7acce
|
@ -117,8 +117,11 @@ module.exports = function (grunt) {
|
||||||
'!<%= project.app %>/bower_components/**',
|
'!<%= project.app %>/bower_components/**',
|
||||||
'!<%= project.app %>/build/**',
|
'!<%= project.app %>/build/**',
|
||||||
'!<%= project.app %>/**/*_test.js'
|
'!<%= project.app %>/**/*_test.js'
|
||||||
]
|
],
|
||||||
}]
|
}],
|
||||||
|
options: {
|
||||||
|
mangle: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,7 +22,9 @@
|
||||||
"0"
|
"0"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"wrap" : ["host"],
|
||||||
|
"noRepeat" : ["host"]
|
||||||
},
|
},
|
||||||
"hostsConfig": {
|
"hostsConfig": {
|
||||||
"title": "Hosts",
|
"title": "Hosts",
|
||||||
|
|
|
@ -15,9 +15,12 @@ angular.module('adagios.table', ['adagios.live',
|
||||||
.value('tableConfig', { cells: { 'text': [], 'name': [] },
|
.value('tableConfig', { cells: { 'text': [], 'name': [] },
|
||||||
apiName: '',
|
apiName: '',
|
||||||
filters: {},
|
filters: {},
|
||||||
cellToFieldsMap: {} })
|
cellToFieldsMap: {},
|
||||||
|
toWrap: [],
|
||||||
|
noRepeat: []})
|
||||||
|
|
||||||
.controller('TableCtrl', ['$scope', 'getServices', 'tableConfig', function ($scope, getServices, tableConfig) {
|
.controller('TableCtrl', ['$scope', 'getServices', 'tableConfig', 'processColumnRepeat',
|
||||||
|
function ($scope, getServices, tableConfig, processColumnRepeat) {
|
||||||
|
|
||||||
var requestFields = [],
|
var requestFields = [],
|
||||||
filters = JSON.parse(tableConfig.filters),
|
filters = JSON.parse(tableConfig.filters),
|
||||||
|
@ -37,53 +40,14 @@ angular.module('adagios.table', ['adagios.live',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function processMultipleServicesPerHost(data) {
|
|
||||||
var last_host = "",
|
|
||||||
actual_host = "",
|
|
||||||
entry = {},
|
|
||||||
first_child = false,
|
|
||||||
parent_found = false,
|
|
||||||
i;
|
|
||||||
|
|
||||||
for (i = 0; i < data.length; i += 1) {
|
|
||||||
entry = data[i];
|
|
||||||
if (entry.host_name === undefined) return data;
|
|
||||||
actual_host = entry.host_name;
|
|
||||||
|
|
||||||
if (entry.host_name === last_host) {
|
|
||||||
|
|
||||||
if (!data[i-1].has_child && !parent_found) {
|
|
||||||
data[i-1].has_child = 1;
|
|
||||||
data[i-1].child_class='state--hasChild';
|
|
||||||
entry.child_class='state--isChild';
|
|
||||||
entry.host_state = "";
|
|
||||||
parent_found = true;
|
|
||||||
} else {
|
|
||||||
entry.is_child = 1;
|
|
||||||
entry.child_class='state--isChild';
|
|
||||||
entry.host_state = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
entry.host_name = "";
|
|
||||||
|
|
||||||
} else {
|
|
||||||
first_child = false;
|
|
||||||
parent_found = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
last_host = actual_host;
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
getServices(requestFields, filters, tableConfig.apiName)
|
getServices(requestFields, filters, tableConfig.apiName)
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
$scope.entries = processMultipleServicesPerHost(data);
|
console.log(tableConfig.toWrap[0]);
|
||||||
|
$scope.entries = processColumnRepeat(data, tableConfig.cellToFieldsMap[tableConfig.toWrap[0]][1], tableConfig.cellToFieldsMap[tableConfig.toWrap[0]]);
|
||||||
});
|
});
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.directive('adgTable', ['$http', '$compile', 'tableConfig', function ($http, $compile, tableConfig) {
|
.directive('adgTable', ['$http', '$compile', 'tableConfig', function ($http, $compile, tableConfig) {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
compile: function () {
|
compile: function () {
|
||||||
|
@ -96,6 +60,8 @@ angular.module('adagios.table', ['adagios.live',
|
||||||
tableConfig.cells.text = attrs.cellsText.split(',');
|
tableConfig.cells.text = attrs.cellsText.split(',');
|
||||||
tableConfig.cells.name = attrs.cellsName.split(',');
|
tableConfig.cells.name = attrs.cellsName.split(',');
|
||||||
tableConfig.apiName = attrs.apiName;
|
tableConfig.apiName = attrs.apiName;
|
||||||
|
tableConfig.toWrap = attrs.toWrap.split(',');
|
||||||
|
tableConfig.noRepeat = attrs.noRepeat.split(',');
|
||||||
|
|
||||||
if (!!attrs.filters) {
|
if (!!attrs.filters) {
|
||||||
tableConfig.filters = attrs.filters;
|
tableConfig.filters = attrs.filters;
|
||||||
|
@ -134,4 +100,52 @@ angular.module('adagios.table', ['adagios.live',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}]);
|
}])
|
||||||
|
|
||||||
|
.service('processColumnRepeat', function() {
|
||||||
|
|
||||||
|
function clearFields(entry, fields) {
|
||||||
|
angular.forEach(fields, function (value) {
|
||||||
|
entry[value] = '';
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return function (data, fieldToProcess, fields) {
|
||||||
|
var last = '',
|
||||||
|
actual = '',
|
||||||
|
entry = {},
|
||||||
|
first_child = false,
|
||||||
|
parent_found = false,
|
||||||
|
i;
|
||||||
|
|
||||||
|
console.log(fieldToProcess);
|
||||||
|
for (i = 0; i < data.length; i += 1) {
|
||||||
|
entry = data[i];
|
||||||
|
actual = entry[fieldToProcess];
|
||||||
|
|
||||||
|
console.log(entry.host_name + " " + entry[fieldToProcess] + " === " + last);
|
||||||
|
if (entry[fieldToProcess] === last) {
|
||||||
|
|
||||||
|
if (!data[i-1].has_child && !parent_found) {
|
||||||
|
data[i-1].has_child = 1;
|
||||||
|
data[i-1].child_class='state--hasChild';
|
||||||
|
entry.child_class='state--isChild';
|
||||||
|
parent_found = true;
|
||||||
|
} else {
|
||||||
|
entry.is_child = 1;
|
||||||
|
entry.child_class='state--isChild';
|
||||||
|
}
|
||||||
|
|
||||||
|
clearFields(entry, fields);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
first_child = false;
|
||||||
|
parent_found = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
last = actual;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -44,7 +44,9 @@
|
||||||
<adg-table cells-text="{{dashboardCellsText}}"
|
<adg-table cells-text="{{dashboardCellsText}}"
|
||||||
cells-name="{{dashboardCellsName}}"
|
cells-name="{{dashboardCellsName}}"
|
||||||
api-name="{{dashboardApiName}}"
|
api-name="{{dashboardApiName}}"
|
||||||
filters="{{dashboardFilters}}"></adg-table>
|
filters="{{dashboardFilters}}"
|
||||||
|
to-wrap="{{dashboardToWrap}}"
|
||||||
|
no-repeat="{{dashboardNoRepeat}}"></adg-table>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,6 +26,8 @@ angular.module('adagios.view.dashboard', ['ngRoute',
|
||||||
$scope.dashboardCellsName = dashboardConfig.cellsName.join();
|
$scope.dashboardCellsName = dashboardConfig.cellsName.join();
|
||||||
$scope.dashboardApiName = dashboardConfig.apiName;
|
$scope.dashboardApiName = dashboardConfig.apiName;
|
||||||
$scope.dashboardFilters = dashboardConfig.filters;
|
$scope.dashboardFilters = dashboardConfig.filters;
|
||||||
|
$scope.dashboardToWrap = dashboardConfig.toWrap.join();
|
||||||
|
$scope.dashboardNoRepeat = dashboardConfig.noRepeat.join();
|
||||||
|
|
||||||
getServices(fields, filters, apiName)
|
getServices(fields, filters, apiName)
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
|
@ -40,4 +42,6 @@ angular.module('adagios.view.dashboard', ['ngRoute',
|
||||||
dashboardConfig.cellsName = readConfig.data.dashboardConfig.cells.name;
|
dashboardConfig.cellsName = readConfig.data.dashboardConfig.cells.name;
|
||||||
dashboardConfig.apiName = readConfig.data.dashboardConfig.apiName;
|
dashboardConfig.apiName = readConfig.data.dashboardConfig.apiName;
|
||||||
dashboardConfig.filters = readConfig.data.dashboardConfig.filters;
|
dashboardConfig.filters = readConfig.data.dashboardConfig.filters;
|
||||||
|
dashboardConfig.toWrap = readConfig.data.dashboardConfig.wrap;
|
||||||
|
dashboardConfig.noRepeat = readConfig.data.dashboardConfig.noRepeat;
|
||||||
}]);
|
}]);
|
||||||
|
|
Loading…
Reference in New Issue