Single Table template
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"dashboardConfig": {
|
"dashboardConfig": {
|
||||||
"title": "Unhandled service problems",
|
"title": "Unhandled service problems",
|
||||||
"refreshInterval": "0",
|
"refreshInterval": "10000",
|
||||||
"template": "",
|
"template": "",
|
||||||
"components" : [
|
"components" : [
|
||||||
{
|
{
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
"hostsConfig": {
|
"hostsConfig": {
|
||||||
"title": "Hosts",
|
"title": "Hosts",
|
||||||
"refreshInterval": "10000",
|
"refreshInterval": "10000",
|
||||||
"template": "",
|
"template": "singleTable",
|
||||||
"components": [
|
"components": [
|
||||||
{
|
{
|
||||||
"type": "table",
|
"type": "table",
|
||||||
@@ -115,11 +115,11 @@
|
|||||||
"servicesConfig": {
|
"servicesConfig": {
|
||||||
"title": "Services",
|
"title": "Services",
|
||||||
"refreshInterval": "10000",
|
"refreshInterval": "10000",
|
||||||
"template": "",
|
"template": "singleTable",
|
||||||
"components": [{
|
"components": [{
|
||||||
|
"type": "table",
|
||||||
|
"config": {
|
||||||
"title": "Services",
|
"title": "Services",
|
||||||
"type": "table",
|
|
||||||
"config": {
|
|
||||||
"cells": {
|
"cells": {
|
||||||
"text": [
|
"text": [
|
||||||
"Host",
|
"Host",
|
||||||
@@ -140,67 +140,5 @@
|
|||||||
"noRepeatCell" : "host"
|
"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,10 +16,10 @@ angular.module('adagios.table', ['adagios.live',
|
|||||||
|
|
||||||
.controller('TableCtrl', ['$scope', '$interval', 'getServices', 'tableConfig', 'processColumnRepeat',
|
.controller('TableCtrl', ['$scope', '$interval', 'getServices', 'tableConfig', 'processColumnRepeat',
|
||||||
function ($scope, $interval, getServices, tableConfig, processColumnRepeat) {
|
function ($scope, $interval, getServices, tableConfig, processColumnRepeat) {
|
||||||
|
|
||||||
var requestFields = [],
|
var requestFields = [],
|
||||||
filters = JSON.parse(tableConfig[tableConfig.index].filters),
|
filters = JSON.parse(tableConfig[tableConfig.index].filters),
|
||||||
conf = tableConfig[tableConfig.index],
|
conf = tableConfig[tableConfig.index],
|
||||||
|
getData,
|
||||||
i;
|
i;
|
||||||
|
|
||||||
$scope.cellsName = conf.cells.name;
|
$scope.cellsName = conf.cells.name;
|
||||||
@@ -36,9 +36,8 @@ angular.module('adagios.table', ['adagios.live',
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.getData =
|
getData = function (requestFields, filters, apiName) {
|
||||||
function (requestFields, filters, apiName) {
|
getServices(requestFields, filters, apiName)
|
||||||
getServices(requestFields, filters, conf.apiName)
|
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
var fieldToWrap = tableConfig.cellWrappableField[conf.noRepeatCell],
|
var fieldToWrap = tableConfig.cellWrappableField[conf.noRepeatCell],
|
||||||
cellFields = tableConfig.cellToFieldsMap[conf.noRepeatCell];
|
cellFields = tableConfig.cellToFieldsMap[conf.noRepeatCell];
|
||||||
@@ -49,13 +48,13 @@ angular.module('adagios.table', ['adagios.live',
|
|||||||
|
|
||||||
$scope.entries = data;
|
$scope.entries = data;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
$scope.getData(requestFields, filters, conf.apiName);
|
getData(requestFields, filters, conf.apiName);
|
||||||
|
|
||||||
if (tableConfig.refreshInterval !== '0') {
|
if (tableConfig.refreshInterval !== '0') {
|
||||||
$interval(function() {
|
$interval(function () {
|
||||||
$scope.getData(requestFields, filters, conf.apiName);
|
getData(requestFields, filters, conf.apiName);
|
||||||
}, tableConfig.refreshInterval);
|
}, tableConfig.refreshInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,26 +73,26 @@ angular.module('adagios.table', ['adagios.live',
|
|||||||
+ ' and "is-wrappable" attributes must be defined');
|
+ ' and "is-wrappable" attributes must be defined');
|
||||||
}
|
}
|
||||||
|
|
||||||
tableConfig[attrs.tableIndex] = {};
|
tableConfig[attrs.tableId] = {};
|
||||||
tableConfig[attrs.tableIndex].filters = {};
|
tableConfig[attrs.tableId].filters = {};
|
||||||
|
|
||||||
tableConfig[attrs.tableIndex].cells = { 'text': [], 'name': [] };
|
tableConfig[attrs.tableId].cells = { 'text': [], 'name': [] };
|
||||||
tableConfig[attrs.tableIndex].cells.text = attrs.cellsText.split(',');
|
tableConfig[attrs.tableId].cells.text = attrs.cellsText.split(',');
|
||||||
tableConfig[attrs.tableIndex].cells.name = attrs.cellsName.split(',');
|
tableConfig[attrs.tableId].cells.name = attrs.cellsName.split(',');
|
||||||
|
|
||||||
tableConfig[attrs.tableIndex].apiName = attrs.apiName;
|
tableConfig[attrs.tableId].apiName = attrs.apiName;
|
||||||
|
|
||||||
tableConfig[attrs.tableIndex].isWrappable = false;
|
tableConfig[attrs.tableId].isWrappable = false;
|
||||||
tableConfig[attrs.tableIndex].isWrappable = attrs.isWrappable;
|
tableConfig[attrs.tableId].isWrappable = attrs.isWrappable;
|
||||||
tableConfig[attrs.tableIndex].noRepeatCell = attrs.noRepeatCell;
|
tableConfig[attrs.tableId].noRepeatCell = attrs.noRepeatCell;
|
||||||
tableConfig[attrs.tableIndex].tableIndex = attrs.tableIndex;
|
tableConfig[attrs.tableId].tableId = attrs.tableId;
|
||||||
|
|
||||||
if (!!attrs.refreshInterval) {
|
if (!!attrs.refreshInterval) {
|
||||||
tableConfig.refreshInterval = attrs.refreshInterval;
|
tableConfig.refreshInterval = attrs.refreshInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!!attrs.filters) {
|
if (!!attrs.filters) {
|
||||||
tableConfig[attrs.tableIndex].filters = attrs.filters;
|
tableConfig[attrs.tableId].filters = attrs.filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
var template = 'components/table/table.html';
|
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) {
|
function clearFields(entry, fields) {
|
||||||
angular.forEach(fields, function (value) {
|
angular.forEach(fields, function (value) {
|
||||||
entry[value] = '';
|
entry[value] = '';
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
// Erase subsequently repeated data of a given cell only keeping the first occurrence
|
// Erase subsequently repeated data of a given cell only keeping the first occurrence
|
||||||
// fieldToProcess is the field to watch for subsequent repetition
|
// fieldToProcess is the field to watch for subsequent repetition
|
||||||
@@ -145,12 +144,11 @@ angular.module('adagios.table', ['adagios.live',
|
|||||||
var last = '',
|
var last = '',
|
||||||
actual = '',
|
actual = '',
|
||||||
entry = {},
|
entry = {},
|
||||||
first_child = false,
|
|
||||||
parent_found = false,
|
parent_found = false,
|
||||||
class_name = ['', ''],
|
class_name = ['', ''],
|
||||||
i;
|
i;
|
||||||
|
|
||||||
if (isWrappable == "true") {
|
if (isWrappable === "true") {
|
||||||
class_name = ['state--hasChild', 'state--isChild'];
|
class_name = ['state--hasChild', 'state--isChild'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,9 +158,9 @@ angular.module('adagios.table', ['adagios.live',
|
|||||||
|
|
||||||
if (entry[fieldToProcess] === last) {
|
if (entry[fieldToProcess] === last) {
|
||||||
|
|
||||||
if (!data[i-1].has_child && !parent_found) {
|
if (!data[i - 1].has_child && !parent_found) {
|
||||||
data[i-1].has_child = 1;
|
data[i - 1].has_child = 1;
|
||||||
data[i-1].child_class = class_name[0];
|
data[i - 1].child_class = class_name[0];
|
||||||
entry.child_class = class_name[1];
|
entry.child_class = class_name[1];
|
||||||
parent_found = true;
|
parent_found = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -173,7 +171,6 @@ angular.module('adagios.table', ['adagios.live',
|
|||||||
clearFields(entry, fields);
|
clearFields(entry, fields);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
first_child = false;
|
|
||||||
parent_found = false;
|
parent_found = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,5 +178,5 @@ angular.module('adagios.table', ['adagios.live',
|
|||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,11 +27,12 @@ angular.module('adagios.tactical', ['adagios.tactical.status_overview',
|
|||||||
compile: function compile() {
|
compile: function compile() {
|
||||||
return {
|
return {
|
||||||
pre: function preLink(scope, iElement, iAttrs, controller) {
|
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.statusOverview = JSON.parse(iAttrs.statusOverview.toLowerCase());
|
||||||
tacticalConfig.currentHealth = JSON.parse(iAttrs.currentHealth.toLowerCase());
|
tacticalConfig.currentHealth = JSON.parse(iAttrs.currentHealth.toLowerCase());
|
||||||
tacticalConfig.topAlertProducers = JSON.parse(iAttrs.topAlertProducers.toLowerCase());
|
tacticalConfig.topAlertProducers = JSON.parse(iAttrs.topAlertProducers.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
@@ -5,18 +5,19 @@
|
|||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div role="tabpanel" class="problems tab-pane active" id="openProblems">
|
<div role="tabpanel" class="problems tab-pane active" id="openProblems">
|
||||||
<header class="main__content__header clearfix">
|
<header class="main__content__header clearfix">
|
||||||
<h2 class="main__content__title">{{customViewTitle}}</h2>
|
<h2 class="main__content__title">{{singleTableTitle}}</h2>
|
||||||
</header>
|
</header>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<adg-table cells-name="{{customViewCellsName}}"
|
<adg-table cells-name="{{tableConfig.CellsName}}"
|
||||||
cells-text="{{customViewCellsText}}"
|
cells-text="{{tableConfig.CellsText}}"
|
||||||
api-name="{{customViewApiName}}"
|
api-name="{{tableConfig.ApiName}}"
|
||||||
filters="{{customViewFilters}}"
|
filters="{{tableConfig.Filters}}"
|
||||||
is-wrappable="{{customViewIsWrappable}}"
|
is-wrappable="{{tableConfig.IsWrappable}}"
|
||||||
no-repeat-cell="{{customViewNoRepeatCell}}"
|
no-repeat-cell="{{tableConfig.NoRepeatCell}}"
|
||||||
refresh-interval="{{customViewRefreshInterval}}"></adg-table>
|
refresh-interval="{{singleTableRefreshInterval}}"
|
||||||
|
table-id="0"></adg-table>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
@@ -27,21 +27,28 @@ angular.module('adagios.view.custom', ['ngRoute',
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.customViewTitle = customViewsConfig[viewName].title;
|
function TableConfig(config) {
|
||||||
$scope.customViewCellsText = customViewsConfig[viewName].cells.text.join();
|
this.title = config.title;
|
||||||
$scope.customViewCellsName = customViewsConfig[viewName].cells.name.join();
|
this.CellsText = config.cells.text.join();
|
||||||
$scope.customViewApiName = customViewsConfig[viewName].apiName;
|
this.CellsName = config.cells.name.join();
|
||||||
$scope.customViewFilters = customViewsConfig[viewName].filters;
|
this.ApiName = config.apiName;
|
||||||
$scope.customViewIsWrappable = customViewsConfig[viewName].isWrappable;
|
this.Filters = config.filters;
|
||||||
$scope.customViewNoRepeatCell = customViewsConfig[viewName].noRepeatCell;
|
this.IsWrappable = config.isWrappable;
|
||||||
$scope.customViewRefreshInterval = customViewsConfig[viewName].refreshInterval;
|
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) {
|
.run(['readConfig', 'customViewsConfig', function (readConfig, customViewsConfig) {
|
||||||
var viewsConfig = readConfig.data.customViewsConfig;
|
var viewsConfig = readConfig.data;
|
||||||
|
|
||||||
angular.forEach(viewsConfig, function (config, view) {
|
angular.forEach(viewsConfig, function (config, view) {
|
||||||
|
if (config.template === "singleTable") {
|
||||||
customViewsConfig[view] = config;
|
customViewsConfig[view] = config;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
is-wrappable="{{dashboardTables[0].IsWrappable}}"
|
is-wrappable="{{dashboardTables[0].IsWrappable}}"
|
||||||
no-repeat-cell="{{dashboardTables[0].NoRepeatCell}}"
|
no-repeat-cell="{{dashboardTables[0].NoRepeatCell}}"
|
||||||
refresh-interval="{{dashboardRefreshInterval}}"
|
refresh-interval="{{dashboardRefreshInterval}}"
|
||||||
table-index="0"></adg-table>
|
table-id="0"></adg-table>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
is-wrappable="{{dashboardTables[1].IsWrappable}}"
|
is-wrappable="{{dashboardTables[1].IsWrappable}}"
|
||||||
no-repeat-cell="{{dashboardTables[1].NoRepeatCell}}"
|
no-repeat-cell="{{dashboardTables[1].NoRepeatCell}}"
|
||||||
refresh-interval="{{dashboardRefreshInterval}}"
|
refresh-interval="{{dashboardRefreshInterval}}"
|
||||||
table-index="1"></adg-table>
|
table-id="1"></adg-table>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</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'],
|
var fields = ['state'],
|
||||||
filters = {'isnot' : { 'state' : ['0'] }},
|
filters = {'isnot' : { 'state' : ['0'] }},
|
||||||
apiName = 'hosts',
|
apiName = 'hosts',
|
||||||
components = [],
|
components = [],
|
||||||
|
component,
|
||||||
|
config,
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
$scope.dashboardTitle = dashboardConfig.data.title;
|
$scope.dashboardTitle = dashboardConfig.data.title;
|
||||||
@@ -32,7 +34,7 @@ angular.module('adagios.view.dashboard', ['ngRoute',
|
|||||||
|
|
||||||
components = dashboardConfig.data.components;
|
components = dashboardConfig.data.components;
|
||||||
|
|
||||||
function tableConfig(config) {
|
function TableConfig(config) {
|
||||||
this.title = config.title;
|
this.title = config.title;
|
||||||
this.CellsText = config.cells.text.join();
|
this.CellsText = config.cells.text.join();
|
||||||
this.CellsName = config.cells.name.join();
|
this.CellsName = config.cells.name.join();
|
||||||
@@ -40,23 +42,23 @@ angular.module('adagios.view.dashboard', ['ngRoute',
|
|||||||
this.Filters = config.filters;
|
this.Filters = config.filters;
|
||||||
this.IsWrappable = config.isWrappable;
|
this.IsWrappable = config.isWrappable;
|
||||||
this.NoRepeatCell = config.noRepeatCell;
|
this.NoRepeatCell = config.noRepeatCell;
|
||||||
};
|
}
|
||||||
|
|
||||||
function tacticalConfig(config) {
|
function TacticalConfig(config) {
|
||||||
this.title = config.title;
|
this.title = config.title;
|
||||||
this.statusOverview = config.components.statusOverview;
|
this.statusOverview = config.components.statusOverview;
|
||||||
this.currentHealth = config.components.currentHealth;
|
this.currentHealth = config.components.currentHealth;
|
||||||
this.topAlertProducers = config.components.topAlertProducers;
|
this.topAlertProducers = config.components.topAlertProducers;
|
||||||
};
|
}
|
||||||
|
|
||||||
for (i = 0; i < components.length; i += 1) {
|
for (i = 0; i < components.length; i += 1) {
|
||||||
var component = components[i],
|
component = components[i];
|
||||||
config = component.config;
|
config = component.config;
|
||||||
|
|
||||||
if (component.type === 'table') {
|
if (component.type === 'table') {
|
||||||
$scope.dashboardTables.push(new tableConfig(config));
|
$scope.dashboardTables.push(new TableConfig(config));
|
||||||
} else if (component.type === 'tactical') {
|
} else if (component.type === 'tactical') {
|
||||||
$scope.dashboardTactical.push(new tacticalConfig(config));
|
$scope.dashboardTactical.push(new TacticalConfig(config));
|
||||||
console.log($scope.dashboardTactical[0].statusOverview);
|
console.log($scope.dashboardTactical[0].statusOverview);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user