diff --git a/Gruntfile.js b/Gruntfile.js index cb63a7c..6555a27 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -117,8 +117,11 @@ module.exports = function (grunt) { '!<%= project.app %>/bower_components/**', '!<%= project.app %>/build/**', '!<%= project.app %>/**/*_test.js' - ] - }] + ], + }], + options: { + mangle: false + } } } }); diff --git a/app/components/config/config.json b/app/components/config/config.json index ff46119..8654393 100644 --- a/app/components/config/config.json +++ b/app/components/config/config.json @@ -22,7 +22,9 @@ "0" ] } - } + }, + "wrap" : ["host"], + "noRepeat" : ["host"] }, "hostsConfig": { "title": "Hosts", diff --git a/app/components/table/table.js b/app/components/table/table.js index 44d220f..761adcc 100644 --- a/app/components/table/table.js +++ b/app/components/table/table.js @@ -15,9 +15,12 @@ angular.module('adagios.table', ['adagios.live', .value('tableConfig', { cells: { 'text': [], 'name': [] }, apiName: '', 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 = [], 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) .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 { restrict: 'E', compile: function () { @@ -96,6 +60,8 @@ angular.module('adagios.table', ['adagios.live', tableConfig.cells.text = attrs.cellsText.split(','); tableConfig.cells.name = attrs.cellsName.split(','); tableConfig.apiName = attrs.apiName; + tableConfig.toWrap = attrs.toWrap.split(','); + tableConfig.noRepeat = attrs.noRepeat.split(','); if (!!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; + } + }); diff --git a/app/dashboard/dashboard.html b/app/dashboard/dashboard.html index f51dbd5..d058959 100644 --- a/app/dashboard/dashboard.html +++ b/app/dashboard/dashboard.html @@ -44,7 +44,9 @@ + filters="{{dashboardFilters}}" + to-wrap="{{dashboardToWrap}}" + no-repeat="{{dashboardNoRepeat}}"> diff --git a/app/dashboard/dashboard.js b/app/dashboard/dashboard.js index 54e028a..c0f7557 100644 --- a/app/dashboard/dashboard.js +++ b/app/dashboard/dashboard.js @@ -26,6 +26,8 @@ angular.module('adagios.view.dashboard', ['ngRoute', $scope.dashboardCellsName = dashboardConfig.cellsName.join(); $scope.dashboardApiName = dashboardConfig.apiName; $scope.dashboardFilters = dashboardConfig.filters; + $scope.dashboardToWrap = dashboardConfig.toWrap.join(); + $scope.dashboardNoRepeat = dashboardConfig.noRepeat.join(); getServices(fields, filters, apiName) .success(function (data) { @@ -40,4 +42,6 @@ angular.module('adagios.view.dashboard', ['ngRoute', dashboardConfig.cellsName = readConfig.data.dashboardConfig.cells.name; dashboardConfig.apiName = readConfig.data.dashboardConfig.apiName; dashboardConfig.filters = readConfig.data.dashboardConfig.filters; + dashboardConfig.toWrap = readConfig.data.dashboardConfig.wrap; + dashboardConfig.noRepeat = readConfig.data.dashboardConfig.noRepeat; }]);