diff --git a/app/components/config/config.json b/app/components/config/config.json index d978453..a109953 100644 --- a/app/components/config/config.json +++ b/app/components/config/config.json @@ -1,7 +1,7 @@ { "dashboardConfig": { "title": "Unhandled service problems", - "refreshInterval": "0", + "refreshInterval": "10000", "template": "", "components" : [ { @@ -82,7 +82,7 @@ "hostsConfig": { "title": "Hosts", "refreshInterval": "10000", - "template": "", + "template": "singleTable", "components": [ { "type": "table", @@ -115,11 +115,11 @@ "servicesConfig": { "title": "Services", "refreshInterval": "10000", - "template": "", + "template": "singleTable", "components": [{ - "title": "Services", "type": "table", "config": { + "title": "Services", "cells": { "text": [ "Host", @@ -140,67 +140,5 @@ "noRepeatCell" : "host" } }] - }, - "customViewsConfig": { - "customView1": { - "title": "Custom View 1", - "refreshInterval": "10000", - "template": "", - "components": [{ - "type": "table", - "config": { - "title": "Custom View 1", - "cells": { - "text": [ - "Host", - "Address", - "Duration", - "Last check", - "Host status" - ], - "name": [ - "hosts_host", - "host_address", - "duration", - "last_check", - "host_status" - ] - }, - "apiName": "hosts", - "filters": {}, - "isWrappable" : false, - "noRepeatCell" : "" - } - }] - }, - "customView2": { - "title": "Custom View 2", - "refreshInterval": "10000", - "template": "", - "components": [{ - "type": "table", - "config": { - "title": "Custom View 2", - "cells": { - "text": [ - "Host", - "Service check", - "Duration", - "Last check" - ], - "name": [ - "host", - "service_check", - "duration", - "last_check" - ] - }, - "apiName": "services", - "filters": {}, - "isWrappable" : false, - "noRepeatCell" : "host" - } - }] - } } } diff --git a/app/components/table/table.js b/app/components/table/table.js index 71b4fe6..015ad6e 100644 --- a/app/components/table/table.js +++ b/app/components/table/table.js @@ -16,29 +16,28 @@ angular.module('adagios.table', ['adagios.live', .controller('TableCtrl', ['$scope', '$interval', 'getServices', 'tableConfig', 'processColumnRepeat', function ($scope, $interval, getServices, tableConfig, processColumnRepeat) { + var requestFields = [], + filters = JSON.parse(tableConfig[tableConfig.index].filters), + conf = tableConfig[tableConfig.index], + getData, + i; - var requestFields = [], - filters = JSON.parse(tableConfig[tableConfig.index].filters), - conf = tableConfig[tableConfig.index], - i; + $scope.cellsName = conf.cells.name; + $scope.cellsText = conf.cells.text; + $scope.cellIndexes = []; - $scope.cellsName = conf.cells.name; - $scope.cellsText = conf.cells.text; - $scope.cellIndexes = []; + for (i = 0; i < $scope.cellsName.length; i += 1) { + $scope.cellIndexes.push(i); + } - for (i = 0; i < $scope.cellsName.length; i += 1) { - $scope.cellIndexes.push(i); - } - - angular.forEach($scope.cellsName, function (key) { - angular.forEach(tableConfig.cellToFieldsMap[key], function (_value) { - requestFields.push(_value); + angular.forEach($scope.cellsName, function (key) { + angular.forEach(tableConfig.cellToFieldsMap[key], function (_value) { + requestFields.push(_value); + }); }); - }); - - $scope.getData = - function (requestFields, filters, apiName) { - getServices(requestFields, filters, conf.apiName) + + getData = function (requestFields, filters, apiName) { + getServices(requestFields, filters, apiName) .success(function (data) { var fieldToWrap = tableConfig.cellWrappableField[conf.noRepeatCell], cellFields = tableConfig.cellToFieldsMap[conf.noRepeatCell]; @@ -49,19 +48,19 @@ angular.module('adagios.table', ['adagios.live', $scope.entries = data; }); + }; + + getData(requestFields, filters, conf.apiName); + + if (tableConfig.refreshInterval !== '0') { + $interval(function () { + getData(requestFields, filters, conf.apiName); + }, tableConfig.refreshInterval); } - $scope.getData(requestFields, filters, conf.apiName); - - if (tableConfig.refreshInterval !== '0') { - $interval(function() { - $scope.getData(requestFields, filters, conf.apiName); - }, tableConfig.refreshInterval); - } - - // Used if there's more than one table in a view - tableConfig.index += 1; - }]) + // Used if there's more than one table in a view + tableConfig.index += 1; + }]) .directive('adgTable', ['$http', '$compile', 'tableConfig', function ($http, $compile, tableConfig) { return { @@ -74,26 +73,26 @@ angular.module('adagios.table', ['adagios.live', + ' and "is-wrappable" attributes must be defined'); } - tableConfig[attrs.tableIndex] = {}; - tableConfig[attrs.tableIndex].filters = {}; + tableConfig[attrs.tableId] = {}; + tableConfig[attrs.tableId].filters = {}; - tableConfig[attrs.tableIndex].cells = { 'text': [], 'name': [] }; - tableConfig[attrs.tableIndex].cells.text = attrs.cellsText.split(','); - tableConfig[attrs.tableIndex].cells.name = attrs.cellsName.split(','); + tableConfig[attrs.tableId].cells = { 'text': [], 'name': [] }; + tableConfig[attrs.tableId].cells.text = attrs.cellsText.split(','); + tableConfig[attrs.tableId].cells.name = attrs.cellsName.split(','); - tableConfig[attrs.tableIndex].apiName = attrs.apiName; + tableConfig[attrs.tableId].apiName = attrs.apiName; + + tableConfig[attrs.tableId].isWrappable = false; + tableConfig[attrs.tableId].isWrappable = attrs.isWrappable; + tableConfig[attrs.tableId].noRepeatCell = attrs.noRepeatCell; + tableConfig[attrs.tableId].tableId = attrs.tableId; - tableConfig[attrs.tableIndex].isWrappable = false; - tableConfig[attrs.tableIndex].isWrappable = attrs.isWrappable; - tableConfig[attrs.tableIndex].noRepeatCell = attrs.noRepeatCell; - tableConfig[attrs.tableIndex].tableIndex = attrs.tableIndex; - if (!!attrs.refreshInterval) { tableConfig.refreshInterval = attrs.refreshInterval; } if (!!attrs.filters) { - tableConfig[attrs.tableIndex].filters = attrs.filters; + tableConfig[attrs.tableId].filters = attrs.filters; } var template = 'components/table/table.html'; @@ -130,13 +129,13 @@ angular.module('adagios.table', ['adagios.live', }; }]) - .service('processColumnRepeat', function() { - + .service('processColumnRepeat', function () { + function clearFields(entry, fields) { angular.forEach(fields, function (value) { - entry[value] = ''; + entry[value] = ''; }); - }; + } // Erase subsequently repeated data of a given cell only keeping the first occurrence // fieldToProcess is the field to watch for subsequent repetition @@ -145,24 +144,23 @@ angular.module('adagios.table', ['adagios.live', var last = '', actual = '', entry = {}, - first_child = false, parent_found = false, class_name = ['', ''], i; - if (isWrappable == "true") { + if (isWrappable === "true") { class_name = ['state--hasChild', 'state--isChild']; } - + for (i = 0; i < data.length; i += 1) { entry = data[i]; actual = entry[fieldToProcess]; if (entry[fieldToProcess] === last) { - if (!data[i-1].has_child && !parent_found) { - data[i-1].has_child = 1; - data[i-1].child_class = class_name[0]; + if (!data[i - 1].has_child && !parent_found) { + data[i - 1].has_child = 1; + data[i - 1].child_class = class_name[0]; entry.child_class = class_name[1]; parent_found = true; } else { @@ -173,7 +171,6 @@ angular.module('adagios.table', ['adagios.live', clearFields(entry, fields); } else { - first_child = false; parent_found = false; } @@ -181,5 +178,5 @@ angular.module('adagios.table', ['adagios.live', } return data; - } + }; }); diff --git a/app/components/tactical/tactical.js b/app/components/tactical/tactical.js index 2119883..c428874 100644 --- a/app/components/tactical/tactical.js +++ b/app/components/tactical/tactical.js @@ -27,11 +27,12 @@ angular.module('adagios.tactical', ['adagios.tactical.status_overview', compile: function compile() { return { pre: function preLink(scope, iElement, iAttrs, controller) { + // This is the earliest phase during which attributes are evaluated tacticalConfig.statusOverview = JSON.parse(iAttrs.statusOverview.toLowerCase()); tacticalConfig.currentHealth = JSON.parse(iAttrs.currentHealth.toLowerCase()); tacticalConfig.topAlertProducers = JSON.parse(iAttrs.topAlertProducers.toLowerCase()); } - } + }; } }; }]); diff --git a/app/custom_views/custom_views.html b/app/custom_views/custom_views.html index 2b49c70..770d831 100644 --- a/app/custom_views/custom_views.html +++ b/app/custom_views/custom_views.html @@ -5,18 +5,19 @@