Single Table template
This commit is contained in:
parent
bae160e75c
commit
2f4c1e04c4
@ -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"
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
@ -5,18 +5,19 @@
|
||||
<div class="tab-content">
|
||||
<div role="tabpanel" class="problems tab-pane active" id="openProblems">
|
||||
<header class="main__content__header clearfix">
|
||||
<h2 class="main__content__title">{{customViewTitle}}</h2>
|
||||
<h2 class="main__content__title">{{singleTableTitle}}</h2>
|
||||
</header>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<adg-table cells-name="{{customViewCellsName}}"
|
||||
cells-text="{{customViewCellsText}}"
|
||||
api-name="{{customViewApiName}}"
|
||||
filters="{{customViewFilters}}"
|
||||
is-wrappable="{{customViewIsWrappable}}"
|
||||
no-repeat-cell="{{customViewNoRepeatCell}}"
|
||||
refresh-interval="{{customViewRefreshInterval}}"></adg-table>
|
||||
<adg-table cells-name="{{tableConfig.CellsName}}"
|
||||
cells-text="{{tableConfig.CellsText}}"
|
||||
api-name="{{tableConfig.ApiName}}"
|
||||
filters="{{tableConfig.Filters}}"
|
||||
is-wrappable="{{tableConfig.IsWrappable}}"
|
||||
no-repeat-cell="{{tableConfig.NoRepeatCell}}"
|
||||
refresh-interval="{{singleTableRefreshInterval}}"
|
||||
table-id="0"></adg-table>
|
||||
|
||||
</section>
|
||||
</article>
|
||||
|
@ -27,21 +27,28 @@ angular.module('adagios.view.custom', ['ngRoute',
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.customViewTitle = customViewsConfig[viewName].title;
|
||||
$scope.customViewCellsText = customViewsConfig[viewName].cells.text.join();
|
||||
$scope.customViewCellsName = customViewsConfig[viewName].cells.name.join();
|
||||
$scope.customViewApiName = customViewsConfig[viewName].apiName;
|
||||
$scope.customViewFilters = customViewsConfig[viewName].filters;
|
||||
$scope.customViewIsWrappable = customViewsConfig[viewName].isWrappable;
|
||||
$scope.customViewNoRepeatCell = customViewsConfig[viewName].noRepeatCell;
|
||||
$scope.customViewRefreshInterval = customViewsConfig[viewName].refreshInterval;
|
||||
function TableConfig(config) {
|
||||
this.title = config.title;
|
||||
this.CellsText = config.cells.text.join();
|
||||
this.CellsName = config.cells.name.join();
|
||||
this.ApiName = config.apiName;
|
||||
this.Filters = config.filters;
|
||||
this.IsWrappable = config.isWrappable;
|
||||
this.NoRepeatCell = config.noRepeatCell;
|
||||
}
|
||||
|
||||
$scope.tableConfig = new TableConfig(customViewsConfig[viewName].components[0].config);
|
||||
|
||||
$scope.singleTableTitle = customViewsConfig[viewName].title;
|
||||
$scope.singleTableRefreshInterval = customViewsConfig[viewName].refreshInterval;
|
||||
}])
|
||||
|
||||
.run(['readConfig', 'customViewsConfig', function (readConfig, customViewsConfig) {
|
||||
var viewsConfig = readConfig.data.customViewsConfig;
|
||||
var viewsConfig = readConfig.data;
|
||||
|
||||
angular.forEach(viewsConfig, function (config, view) {
|
||||
customViewsConfig[view] = config;
|
||||
if (config.template === "singleTable") {
|
||||
customViewsConfig[view] = config;
|
||||
}
|
||||
});
|
||||
|
||||
}]);
|
||||
|
@ -50,7 +50,7 @@
|
||||
is-wrappable="{{dashboardTables[0].IsWrappable}}"
|
||||
no-repeat-cell="{{dashboardTables[0].NoRepeatCell}}"
|
||||
refresh-interval="{{dashboardRefreshInterval}}"
|
||||
table-index="0"></adg-table>
|
||||
table-id="0"></adg-table>
|
||||
|
||||
</div>
|
||||
|
||||
@ -67,7 +67,7 @@
|
||||
is-wrappable="{{dashboardTables[1].IsWrappable}}"
|
||||
no-repeat-cell="{{dashboardTables[1].NoRepeatCell}}"
|
||||
refresh-interval="{{dashboardRefreshInterval}}"
|
||||
table-index="1"></adg-table>
|
||||
table-id="1"></adg-table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -15,12 +15,14 @@ angular.module('adagios.view.dashboard', ['ngRoute',
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('DashboardCtrl', ['$scope', '$timeout', 'dashboardConfig', 'getServices', function ($scope, $timeout, dashboardConfig, getServices) {
|
||||
.controller('DashboardCtrl', ['$scope', 'dashboardConfig', 'getServices', function ($scope, dashboardConfig, getServices) {
|
||||
|
||||
var fields = ['state'],
|
||||
filters = {'isnot' : { 'state' : ['0'] }},
|
||||
apiName = 'hosts',
|
||||
components = [],
|
||||
component,
|
||||
config,
|
||||
i = 0;
|
||||
|
||||
$scope.dashboardTitle = dashboardConfig.data.title;
|
||||
@ -32,7 +34,7 @@ angular.module('adagios.view.dashboard', ['ngRoute',
|
||||
|
||||
components = dashboardConfig.data.components;
|
||||
|
||||
function tableConfig(config) {
|
||||
function TableConfig(config) {
|
||||
this.title = config.title;
|
||||
this.CellsText = config.cells.text.join();
|
||||
this.CellsName = config.cells.name.join();
|
||||
@ -40,23 +42,23 @@ angular.module('adagios.view.dashboard', ['ngRoute',
|
||||
this.Filters = config.filters;
|
||||
this.IsWrappable = config.isWrappable;
|
||||
this.NoRepeatCell = config.noRepeatCell;
|
||||
};
|
||||
}
|
||||
|
||||
function tacticalConfig(config) {
|
||||
function TacticalConfig(config) {
|
||||
this.title = config.title;
|
||||
this.statusOverview = config.components.statusOverview;
|
||||
this.currentHealth = config.components.currentHealth;
|
||||
this.topAlertProducers = config.components.topAlertProducers;
|
||||
};
|
||||
}
|
||||
|
||||
for (i = 0; i < components.length; i += 1) {
|
||||
var component = components[i],
|
||||
config = component.config;
|
||||
component = components[i];
|
||||
config = component.config;
|
||||
|
||||
if (component.type === 'table') {
|
||||
$scope.dashboardTables.push(new tableConfig(config));
|
||||
$scope.dashboardTables.push(new TableConfig(config));
|
||||
} else if (component.type === 'tactical') {
|
||||
$scope.dashboardTactical.push(new tacticalConfig(config));
|
||||
$scope.dashboardTactical.push(new TacticalConfig(config));
|
||||
console.log($scope.dashboardTactical[0].statusOverview);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user