Add single cell and modify config

Change-Id: I7c1349248dc64c73efe6b7aefb46e82d29a4cce7
This commit is contained in:
Vincent Fournier 2015-08-17 11:58:41 -04:00
parent 81484834dc
commit 68e3f89633
51 changed files with 719 additions and 663 deletions

View File

@ -333,7 +333,6 @@ time.data-table__data {
line-height: 40px; line-height: 40px;
} }
@include medium-and-up-screen { @include medium-and-up-screen {
width:percentage(368 / 1200); width:percentage(368 / 1200);
} }
@ -352,10 +351,6 @@ time.data-table__data {
line-height: 24px; line-height: 24px;
} }
@include medium-and-up-screen {
width:percentage(500 / 1200);
}
.data-table__service__summary { .data-table__service__summary {
font-style:italic; font-style:italic;
margin-left:0; margin-left:0;
@ -373,3 +368,33 @@ time.data-table__data {
color:$_color_light_delta; color:$_color_light_delta;
} }
} }
.data-table__ {
@include medium-and-up-screen {
width:auto;
}
}
.data-table__xsmall {
@include medium-and-up-screen {
width:percentage(100 / 1200);
}
}
.data-table__small {
@include medium-and-up-screen {
width:percentage(200 / 1200);
}
}
.data-table__medium {
@include medium-and-up-screen {
width:percentage(368 / 1200);
}
}
.data-table__large {
@include medium-and-up-screen {
width:percentage(500 / 1200);
}
}

View File

@ -2,7 +2,7 @@
"env": "production", "env": "production",
"username":"", "username":"",
"password":"", "password":"",
"useStoredConfig": false, "useStoredConfig": true,
"surveilApiUrl": "surveil/v2", "surveilApiUrl": "surveil/v2",
"surveilAuthUrl": "surveil/v2/auth", "surveilAuthUrl": "surveil/v2/auth",
"refreshInterval": -1 "refreshInterval": -1

View File

@ -24,7 +24,7 @@
{ {
"type": "panel", "type": "panel",
"attributes": { "attributes": {
"panelId": "openProblems" "panelId": "allProblems"
}, },
"components": [ "components": [
{ {
@ -94,7 +94,7 @@
{ {
"type": "actionbar", "type": "actionbar",
"attributes": { "attributes": {
"tableId": [ "datasourceId": [
0, 0,
1 1
] ]
@ -152,30 +152,56 @@
{ {
"type": "table", "type": "table",
"attributes": { "attributes": {
"tableId": 0, "datasourceId": 0,
"cells": {
"text": [
"Host",
"Address",
"Duration",
"Last check",
"Host status"
],
"name": [
"status_host",
"status_host_address",
"status_duration",
"status_last_check",
"status_host_status"
]
},
"headerFollow": false,
"inputSource": "hostOpenProblems", "inputSource": "hostOpenProblems",
"headerFollow": false,
"isWrappable": false, "isWrappable": false,
"checkColumn": true, "checkColumn": true,
"noRepeatCell": "", "noRepeatCell": "",
"pagingbar": false "pagingbar": false
} },
"components": [
{
"type": "cell-status-host",
"attributes": {
"title": "Hosts",
"url": {
"view": "host",
"params": [
{
"urlParam": "host_name",
"entryKey": "host_host_name"
}
]
}
}
},
{
"type": "cell-single",
"attributes": {
"entryKey": "host_address",
"title": "Address"
}
},
{
"type": "cell-status-duration",
"attributes": {
"title": "Duration"
}
},
{
"type": "cell-status-last-check",
"attributes": {
"title": "Last check"
}
},
{
"type": "cell-status-host-status",
"attributes": {
"title": "Host status"
}
}
]
}, },
{ {
"type": "title", "type": "title",
@ -188,28 +214,49 @@
{ {
"type": "table", "type": "table",
"attributes": { "attributes": {
"tableId": 1, "datasourceId": 1,
"cells": {
"text": [
"Host",
"Service check",
"Duration",
"Last check"
],
"name": [
"status_host",
"status_service_check",
"status_duration",
"status_last_check"
]
},
"headerFollow": false,
"inputSource": "serviceOpenProblemsOnly", "inputSource": "serviceOpenProblemsOnly",
"headerFollow": false,
"isWrappable": true, "isWrappable": true,
"checkColumn": true, "checkColumn": true,
"noRepeatCell": "host", "noRepeatCell": "host",
"pagingbar": false "pagingbar": false
} },
"components": [
{
"type": "cell-status-host",
"attributes": {
"title": "Hosts",
"url": {
"view": "host",
"params": [
{
"urlParam": "host_name",
"entryKey": "host_host_name"
}
]
}
}
},
{
"type": "cell-status-service-check",
"attributes": {
"title": "Service check"
}
},
{
"type": "cell-status-duration",
"attributes": {
"title": "Duration"
}
},
{
"type": "cell-status-last-check",
"attributes": {
"title": "Last check"
}
}
]
} }
] ]
}, },
@ -223,7 +270,7 @@
{ {
"type": "actionbar", "type": "actionbar",
"attributes": { "attributes": {
"tableId": [ "datasourceId": [
2, 2,
3 3
] ]
@ -281,30 +328,56 @@
{ {
"type": "table", "type": "table",
"attributes": { "attributes": {
"tableId": 2, "datasourceId": 2,
"cells": {
"text": [
"Host",
"Address",
"Duration",
"Lastcheck",
"Hoststatus"
],
"name": [
"status_host",
"status_host_address",
"status_duration",
"status_last_check",
"status_host_status"
]
},
"headerFollow": false,
"inputSource": "hostsProblems", "inputSource": "hostsProblems",
"headerFollow": false,
"isWrappable": false, "isWrappable": false,
"checkColumn": true, "checkColumn": true,
"noRepeatCell": "", "noRepeatCell": "",
"pagingbar": false "pagingbar": false
} },
"components": [
{
"type": "cell-status-host",
"attributes": {
"title": "Hosts",
"url": {
"view": "host",
"params": [
{
"urlParam": "host_name",
"entryKey": "host_host_name"
}
]
}
}
},
{
"type": "cell-single",
"attributes": {
"entryKey": "host_address",
"title": "Address"
}
},
{
"type": "cell-status-duration",
"attributes": {
"title": "Duration"
}
},
{
"type": "cell-status-last-check",
"attributes": {
"title": "Last check"
}
},
{
"type": "cell-status-host-status",
"attributes": {
"title": "Host status"
}
}
]
}, },
{ {
"type": "title", "type": "title",
@ -317,28 +390,49 @@
{ {
"type": "table", "type": "table",
"attributes": { "attributes": {
"tableId": 3, "datasourceId": 3,
"cells": {
"text": [
"Host",
"Service check",
"Duration",
"Last check"
],
"name": [
"status_host",
"status_service_check",
"status_duration",
"status_last_check"
]
},
"headerFollow": false,
"inputSource": "servicesProblems", "inputSource": "servicesProblems",
"headerFollow": false,
"isWrappable": true, "isWrappable": true,
"checkColumn": true, "checkColumn": true,
"noRepeatCell": "host", "noRepeatCell": "host",
"pagingbar": false "pagingbar": false
} },
"components": [
{
"type": "cell-status-host",
"attributes": {
"title": "Hosts",
"url": {
"view": "host",
"params": [
{
"urlParam": "host_name",
"entryKey": "host_host_name"
}
]
}
}
},
{
"type": "cell-status-service-check",
"attributes": {
"title": "Service check"
}
},
{
"type": "cell-status-duration",
"attributes": {
"title": "Duration"
}
},
{
"type": "cell-status-last-check",
"attributes": {
"title": "Last check"
}
}
]
} }
] ]
} }
@ -355,13 +449,13 @@
{ {
"type": "title", "type": "title",
"attributes": { "attributes": {
"title": "Hosts" "title": "Hosts status"
} }
}, },
{ {
"type": "actionbar", "type": "actionbar",
"attributes": { "attributes": {
"tableId": [ "datasourceId": [
0 0
] ]
}, },
@ -410,30 +504,59 @@
{ {
"type": "table", "type": "table",
"attributes": { "attributes": {
"tableId": 0, "datasourceId": 0,
"cells": {
"text": [
"Host",
"Address",
"Duration",
"Last check",
"Host status"
],
"name": [
"status_host",
"status_host_address",
"status_duration",
"status_last_check",
"status_host_status"
]
},
"headerFollow": true,
"inputSource": "hosts", "inputSource": "hosts",
"headerFollow": true,
"isWrappable": false, "isWrappable": false,
"noRepeatCell": "", "noRepeatCell": "",
"checkColumn": true, "checkColumn": true,
"pagingbar": true "pagingbar": true
} },
"components": [
{
"type": "cell-status-host",
"attributes": {
"title": "Hosts",
"url": {
"view": "host",
"params": [
{
"urlParam": "host_name",
"entryKey": "host_host_name"
}
]
},
"class": "host"
}
},
{
"type": "cell-single",
"attributes": {
"entryKey": "host_address",
"title": "Address"
}
},
{
"type": "cell-status-duration",
"attributes": {
"title": "Duration"
}
},
{
"type": "cell-status-last-check",
"attributes": {
"title": "Last check",
"class": "small"
}
},
{
"type": "cell-status-host-status",
"attributes": {
"title": "Host status",
"class": "small"
}
}
]
} }
] ]
} }
@ -454,7 +577,7 @@
{ {
"type": "actionbar", "type": "actionbar",
"attributes": { "attributes": {
"tableId": [ "datasourceId": [
0 0
] ]
}, },
@ -503,28 +626,62 @@
{ {
"type": "table", "type": "table",
"attributes": { "attributes": {
"tableId": 0, "datasourceId": 0,
"cells": {
"text": [
"Host",
"Service check",
"Duration",
"Last check"
],
"name": [
"status_host",
"status_service_check",
"status_duration",
"status_last_check"
]
},
"headerFollow": true,
"inputSource": "services", "inputSource": "services",
"headerFollow": true,
"isWrappable": false, "isWrappable": false,
"checkColumn": true, "checkColumn": true,
"noRepeatCell": "host", "noRepeatCell": "host",
"pagingbar": true "pagingbar": true
} },
"components": [
{
"type": "cell-status-host",
"attributes": {
"title": "Hosts",
"url": {
"view": "host",
"params": [
{
"urlParam": "host_name",
"entryKey": "host_host_name"
}
]
}
}
},
{
"type": "cell-status-service-check",
"attributes": {
"title": "Service check",
"url": {
"view": "service",
"params": [
{
"urlParam": "host_name",
"entryKey": "host_host_name"
},
{
"urlParam": "service_description",
"entryKey": "service_service_description"
}
]
}
}
},
{
"type": "cell-status-duration",
"attributes": {
"title": "Duration"
}
},
{
"type": "cell-status-last-check",
"attributes": {
"title": "Last check"
}
}
]
} }
] ]
} }
@ -545,7 +702,7 @@
{ {
"type": "actionbar", "type": "actionbar",
"attributes": { "attributes": {
"tableId": [ "datasourceId": [
0 0
] ]
}, },
@ -582,32 +739,64 @@
{ {
"type": "table", "type": "table",
"attributes": { "attributes": {
"tableId": 0, "datasourceId": 0,
"cells": {
"text": [
"Event type",
"Output",
"Hostname",
"Service",
"Time",
"Complete data"
],
"name": [
"status_event_event_type",
"status_event_output",
"status_event_host_name",
"status_event_service",
"status_event_time",
"status_event"
]
},
"headerFollow": true,
"inputSource": "events", "inputSource": "events",
"headerFollow": true,
"isWrappable": false, "isWrappable": false,
"checkColumn": false, "checkColumn": false,
"noRepeatCell": "", "noRepeatCell": "",
"pagingbar": true "pagingbar": true
} },
"components": [
{
"type": "cell-single",
"attributes": {
"entryKey": "event_event_type",
"title": "Type"
}
},
{
"type": "cell-single",
"attributes": {
"entryKey": "event_output",
"title": "Output"
}
},
{
"type": "cell-single",
"attributes": {
"entryKey": "event_host_name",
"title": "Hostname"
}
},
{
"type": "cell-single",
"attributes": {
"entryKey": "event_service_description",
"title": "Service description"
}
},
{
"type": "cell-single",
"attributes": {
"entryKey": "event_time",
"title": "Time"
}
},
{
"type": "cell-other-fields",
"attributes": {
"title": "Other fields",
"skipFields": [
"event_time",
"event_host_name",
"event_output",
"event_event_type",
"event_service_description"
]
}
}
]
} }
] ]
} }
@ -727,13 +916,13 @@
{ {
"type": "title", "type": "title",
"attributes": { "attributes": {
"title": "ConfigHosts" "title": "Hosts configuration"
} }
}, },
{ {
"type": "actionbar", "type": "actionbar",
"attributes": { "attributes": {
"tableId": [ "datasourceId": [
0 0
] ]
}, },
@ -770,29 +959,53 @@
{ {
"type": "table", "type": "table",
"attributes": { "attributes": {
"tableId": 0, "datasourceId": 0,
"refreshInterval": 30,
"cells": {
"text": [
"Host",
"Address",
"Use",
"Enable"
],
"name": [
"config_host",
"config_host_address",
"config_host_use",
"config_host_register"
]
},
"headerFollow": false,
"inputSource": "hostsConfig", "inputSource": "hostsConfig",
"headerFollow": false,
"isWrappable": false, "isWrappable": false,
"noRepeatCell": "", "noRepeatCell": "",
"checkColumn": false, "checkColumn": false,
"pagingbar": true "pagingbar": true
} },
"components": [
{
"type": "cell-single",
"attributes": {
"entryKey": "host_name",
"title": "Hosts",
"url": {
"view": "host",
"params": [
{
"urlParam": "host_name",
"entryKey": "host_name"
}
]
}
}
},
{
"type": "cell-single",
"attributes": {
"entryKey": "address",
"title": "Address"
}
},
{
"type": "cell-single",
"attributes": {
"entryKey": "use",
"title": "Use"
}
},
{
"type": "cell-config-host-register",
"attributes": {
"title": "Register",
"class": "xsmall"
}
}
]
} }
] ]
} }
@ -813,7 +1026,7 @@
{ {
"type": "actionbar", "type": "actionbar",
"attributes": { "attributes": {
"tableId": [ "datasourceId": [
0 0
] ]
}, },
@ -850,24 +1063,40 @@
{ {
"type": "table", "type": "table",
"attributes": { "attributes": {
"tableId": 0, "datasourceId": 0,
"cells": {
"text": [
"Template",
"Use"
],
"name": [
"config_host_name",
"config_host_use"
]
},
"headerFollow": false,
"inputSource": "hostsConfigTemplate", "inputSource": "hostsConfigTemplate",
"headerFollow": false,
"isWrappable": false, "isWrappable": false,
"noRepeatCell": "", "noRepeatCell": "",
"checkColumn": false, "checkColumn": false,
"pagingbar": true "pagingbar": true
} },
"components": [
{
"type": "cell-single",
"attributes": {
"entryKey": "name",
"title": "Name"
}
},
{
"type": "cell-single",
"attributes": {
"entryKey": "use",
"title": "Use"
}
},
{
"type": "cell-other-fields",
"attributes": {
"title": "Other fields",
"skipFields": [
"use",
"name"
]
}
}
]
} }
] ]
} }
@ -888,7 +1117,7 @@
{ {
"type": "actionbar", "type": "actionbar",
"attributes": { "attributes": {
"tableId": [ "datasourceId": [
0 0
] ]
}, },
@ -910,9 +1139,9 @@
{ {
"type": "table", "type": "table",
"attributes": { "attributes": {
"tableId": 0, "datasourceId": 0,
"headerFollow": true,
"inputSource": "commands", "inputSource": "commands",
"headerFollow": true,
"isWrappable": false, "isWrappable": false,
"noRepeatCell": "", "noRepeatCell": "",
"checkColumn": false, "checkColumn": false,
@ -925,7 +1154,30 @@
] ]
} }
} }
} },
"components": [
{
"type": "cell-single",
"attributes": {
"entryKey": "command_name",
"title": "Name"
}
},
{
"type": "cell-single",
"attributes": {
"entryKey": "command_line",
"title": "Line"
}
},
{
"type": "cell-single",
"attributes": {
"entryKey": "module_type",
"title": "Module Type"
}
}
]
} }
] ]
} }
@ -953,6 +1205,5 @@
] ]
} }
] ]
} }
} }

View File

@ -14,33 +14,33 @@ angular.module('bansho.datasource', ['bansho.surveil'])
filteredData = [], filteredData = [],
listeners = []; listeners = [];
function notifyDataChanged(tableId) { function notifyDataChanged(datasourceId) {
angular.forEach(listeners[tableId], function (callback) { angular.forEach(listeners[datasourceId], function (callback) {
callback(filteredData[tableId], config[tableId].isCheckAll); callback(filteredData[datasourceId], config[datasourceId].isCheckAll);
}); });
} }
function filterData(tableId) { function filterData(datasourceId) {
filteredData[tableId] = $filter('filter')(data[tableId], config[tableId].searchFilter); filteredData[datasourceId] = $filter('filter')(data[datasourceId], config[datasourceId].searchFilter);
notifyDataChanged(tableId); notifyDataChanged(datasourceId);
} }
function refreshTableData(tableId) { function refreshTableData(datasourceId) {
var conf = config[tableId], var conf = config[datasourceId],
inputSource = componentsConfig.getInputSource(conf.inputSource), inputSource = componentsConfig.getInputSource(conf.inputSource),
filter = componentsConfig.getFilter(inputSource.filter).filter, filter = componentsConfig.getFilter(inputSource.filter).filter,
promise; promise;
if (config[tableId].queryFilter) { if (config[datasourceId].queryFilter) {
filter = componentsConfig.mergeFilters([config[tableId].queryFilter, filter]); filter = componentsConfig.mergeFilters([config[datasourceId].queryFilter, filter]);
} }
promise = providerServices[inputSource.provider].getData([], filter, inputSource.endpoint, conf.queryPaging); promise = providerServices[inputSource.provider].getData([], filter, inputSource.endpoint, conf.queryPaging);
promise.then(function (newData) { promise.then(function (newData) {
data[tableId] = newData; data[datasourceId] = newData;
config[tableId].isCheckAll = false; config[datasourceId].isCheckAll = false;
filterData(tableId); filterData(datasourceId);
}, function (error) { }, function (error) {
throw new Error('getTableData : Query failed' + error); throw new Error('getTableData : Query failed' + error);
}); });
@ -48,76 +48,76 @@ angular.module('bansho.datasource', ['bansho.surveil'])
return { return {
refreshTableData: refreshTableData, refreshTableData: refreshTableData,
addTable: function (tableId, conf) { addTable: function (datasourceId, conf) {
config[tableId] = conf; config[datasourceId] = conf;
config[tableId].requestFields = []; config[datasourceId].requestFields = [];
angular.forEach(config[tableId].cells.name, function (cell) { angular.forEach(config[datasourceId].columns, function (cell) {
angular.forEach(tableGlobalConfig.cellToFieldsMap[cell], function (_value) { angular.forEach(tableGlobalConfig.cellToFieldsMap[cell], function (_value) {
config[tableId].requestFields.push(_value); config[datasourceId].requestFields.push(_value);
}); });
}); });
if (config[tableId].pagingbar) { if (config[datasourceId].pagingbar) {
config[tableId].queryPaging = { config[datasourceId].queryPaging = {
page: 0, page: 0,
size: configManager.getPagingSize() size: configManager.getPagingSize()
}; };
} }
}, },
getConfig: function (tableId) { getConfig: function (datasourceId) {
return config[tableId]; return config[datasourceId];
}, },
forEachCheckedEntry: function (tableId, callbackIsChecked) { forEachCheckedEntry: function (datasourceId, callbackIsChecked) {
angular.forEach(filteredData[tableId], function (entry) { angular.forEach(filteredData[datasourceId], function (entry) {
if (entry.is_checked) { if (entry.is_checked) {
callbackIsChecked(entry); callbackIsChecked(entry);
} }
}); });
notifyDataChanged(tableId); notifyDataChanged(datasourceId);
}, },
registerDataChanged: function (tableId, callback) { registerDataChanged: function (datasourceId, callback) {
if (!listeners[tableId]) { if (!listeners[datasourceId]) {
listeners[tableId] = []; listeners[datasourceId] = [];
} }
listeners[tableId].push(callback); listeners[datasourceId].push(callback);
}, },
setAllCheckTable: function (tableId, isChecked) { setAllCheckTable: function (datasourceId, isChecked) {
config[tableId].isCheckAll = isChecked; config[datasourceId].isCheckAll = isChecked;
angular.forEach(filteredData[tableId], function (entry) { angular.forEach(filteredData[datasourceId], function (entry) {
entry.is_checked = isChecked; entry.is_checked = isChecked;
}); });
notifyDataChanged(tableId, isChecked); notifyDataChanged(datasourceId, isChecked);
}, },
setSearchFilter: function (tableId, searchFilter) { setSearchFilter: function (datasourceId, searchFilter) {
config[tableId].searchFilter = searchFilter; config[datasourceId].searchFilter = searchFilter;
filterData(tableId); filterData(datasourceId);
}, },
setQueryFilter: function (tableId, queryFilter) { setQueryFilter: function (datasourceId, queryFilter) {
config[tableId].queryFilter = queryFilter; config[datasourceId].queryFilter = queryFilter;
refreshTableData(tableId); refreshTableData(datasourceId);
}, },
nextPage: function (tableId) { nextPage: function (datasourceId) {
config[tableId].queryPaging.page += 1; config[datasourceId].queryPaging.page += 1;
refreshTableData(tableId); refreshTableData(datasourceId);
}, },
previousPage: function (tableId) { previousPage: function (datasourceId) {
if (config[tableId].queryPaging.page > 0) { if (config[datasourceId].queryPaging.page > 0) {
config[tableId].queryPaging.page -= 1; config[datasourceId].queryPaging.page -= 1;
refreshTableData(tableId); refreshTableData(datasourceId);
} }
}, },
getPage: function (tableId) { getPage: function (datasourceId) {
return config[tableId].queryPaging.page; return config[datasourceId].queryPaging.page;
}, },
setPageSize: function (tableId, pageSize) { setPageSize: function (datasourceId, pageSize) {
config[tableId].queryPaging.size = pageSize; config[datasourceId].queryPaging.size = pageSize;
refreshTableData(tableId); refreshTableData(datasourceId);
}, },
getPageSize: function (tableId) { getPageSize: function (datasourceId) {
return config[tableId].queryPaging.size; return config[datasourceId].queryPaging.size;
} }
}; };
}]) }])

View File

@ -9,11 +9,11 @@ angular.module('bansho.actionbar', ['bansho.datasource', 'bansho.surveil', 'bans
}, },
templateUrl: 'components/directive/actionbar/actionbar.html', templateUrl: 'components/directive/actionbar/actionbar.html',
link: function (scope, element) { link: function (scope, element) {
scope.tableId = scope.options.attributes.tableId; scope.datasourceId = scope.options.attributes.datasourceId;
scope.components = scope.options.components; scope.components = scope.options.components;
angular.forEach(scope.components, function (component) { angular.forEach(scope.components, function (component) {
component.attributes.tableId = scope.tableId; component.attributes.datasourceId = scope.datasourceId;
}); });
$compile(element.contents())(scope); $compile(element.contents())(scope);

View File

@ -16,8 +16,8 @@ angular.module('bansho.actionbar')
}; };
$scope.acknowledgeProblems = function () { $scope.acknowledgeProblems = function () {
angular.forEach($scope.options.attributes.tableId, function (tableId) { angular.forEach($scope.options.attributes.datasourceId, function (datasourceId) {
datasource.forEachCheckedEntry(tableId, function (entry) { datasource.forEachCheckedEntry(datasourceId, function (entry) {
surveilActions.acknowledge(entry.host_host_name, entry.service_service_description, $scope.attrs).then(function (data) { surveilActions.acknowledge(entry.host_host_name, entry.service_service_description, $scope.attrs).then(function (data) {
notifications.push('success', 'Acknowledgement', 'Acknowledged ' + entry.host_host_name + ' ' + entry.service_service_description); notifications.push('success', 'Acknowledgement', 'Acknowledged ' + entry.host_host_name + ' ' + entry.service_service_description);
}, },
@ -26,7 +26,7 @@ angular.module('bansho.actionbar')
}); });
}); });
datasource.setAllCheckTable(tableId, false); datasource.setAllCheckTable(datasourceId, false);
}); });
$scope.isAcknowledgeFormShown = false; $scope.isAcknowledgeFormShown = false;

View File

@ -10,7 +10,7 @@ angular.module('bansho.actionbar')
}, },
controller: ['$scope', 'datasource', 'surveilActions', 'notifications', controller: ['$scope', 'datasource', 'surveilActions', 'notifications',
function ($scope, datasource, surveilActions, notifications) { function ($scope, datasource, surveilActions, notifications) {
$scope.tableId = $scope.options.attributes.tableId; $scope.datasourceId = $scope.options.attributes.datasourceId;
$scope.isDowntimeFormShown = false; $scope.isDowntimeFormShown = false;
$scope.switchDowntimeFormShown = function () { $scope.switchDowntimeFormShown = function () {
@ -18,8 +18,8 @@ angular.module('bansho.actionbar')
}; };
$scope.sendDowntime = function () { $scope.sendDowntime = function () {
angular.forEach($scope.options.attributes.tableId, function (tableId) { angular.forEach($scope.options.attributes.datasourceId, function (datasourceId) {
datasource.forEachCheckedEntry(tableId, function (entry) { datasource.forEachCheckedEntry(datasourceId, function (entry) {
surveilActions.downtime(entry.host_host_name, entry.service_service_description, $scope.attrs).then(function (data) { surveilActions.downtime(entry.host_host_name, entry.service_service_description, $scope.attrs).then(function (data) {
notifications.push('success', 'Downtime', 'Added downtime for ' + entry.host_host_name + ' ' + entry.service_service_description); notifications.push('success', 'Downtime', 'Added downtime for ' + entry.host_host_name + ' ' + entry.service_service_description);
}, },
@ -28,7 +28,7 @@ angular.module('bansho.actionbar')
}); });
}); });
datasource.setAllCheckTable(tableId, false); datasource.setAllCheckTable(datasourceId, false);
}); });
$scope.isDowntimeFormShown = false; $scope.isDowntimeFormShown = false;

View File

@ -9,7 +9,7 @@ angular.module('bansho.actionbar')
}, },
templateUrl: 'components/directive/actionbar/component_filter/filter.html', templateUrl: 'components/directive/actionbar/component_filter/filter.html',
controller: ['$scope', 'datasource', function ($scope, datasource) { controller: ['$scope', 'datasource', function ($scope, datasource) {
$scope.tableId = $scope.options.attributes.tableId; $scope.datasourceId = $scope.options.attributes.datasourceId;
$scope.filters = []; $scope.filters = [];
angular.forEach($scope.options.attributes.filters, function (filter) { angular.forEach($scope.options.attributes.filters, function (filter) {
@ -39,8 +39,8 @@ angular.module('bansho.actionbar')
$scope.activateFilter = function (item) { $scope.activateFilter = function (item) {
$scope.activeFilter = $scope.filters[item]; $scope.activeFilter = $scope.filters[item];
angular.forEach($scope.tableId, function (tableId) { angular.forEach($scope.datasourceId, function (datasourceId) {
datasource.setQueryFilter(tableId, $scope.activeFilter.filter); datasource.setQueryFilter(datasourceId, $scope.activeFilter.filter);
}); });
$scope.isShown = false; $scope.isShown = false;
}; };

View File

@ -11,8 +11,8 @@ angular.module('bansho.actionbar')
controller: ['$scope', 'datasource', 'surveilActions', 'notifications', controller: ['$scope', 'datasource', 'surveilActions', 'notifications',
function ($scope, datasource, surveilActions, notifications) { function ($scope, datasource, surveilActions, notifications) {
$scope.sendRecheck = function () { $scope.sendRecheck = function () {
angular.forEach($scope.options.attributes.tableId, function (tableId) { angular.forEach($scope.options.attributes.datasourceId, function (datasourceId) {
datasource.forEachCheckedEntry(tableId, function (entry) { datasource.forEachCheckedEntry(datasourceId, function (entry) {
surveilActions.recheck(entry.host_host_name, entry.service_service_description).then(function (data) { surveilActions.recheck(entry.host_host_name, entry.service_service_description).then(function (data) {
notifications.push('success', 'Recheck', 'Scheduled recheck for ' + entry.host_host_name + ' ' + entry.service_service_description); notifications.push('success', 'Recheck', 'Scheduled recheck for ' + entry.host_host_name + ' ' + entry.service_service_description);
}, },
@ -21,7 +21,7 @@ angular.module('bansho.actionbar')
}); });
}); });
datasource.setAllCheckTable(tableId, false); datasource.setAllCheckTable(datasourceId, false);
}); });
}; };
} }

View File

@ -10,8 +10,8 @@ angular.module('bansho.actionbar')
templateUrl: 'components/directive/actionbar/component_search_filter/search_filter.html', templateUrl: 'components/directive/actionbar/component_search_filter/search_filter.html',
controller: ['$scope', 'datasource', function ($scope, datasource) { controller: ['$scope', 'datasource', function ($scope, datasource) {
$scope.searchFilterChange = function () { $scope.searchFilterChange = function () {
angular.forEach($scope.options.attributes.tableId, function (tableId) { angular.forEach($scope.options.attributes.datasourceId, function (datasourceId) {
datasource.setSearchFilter(tableId, $scope.searchFilter); datasource.setSearchFilter(datasourceId, $scope.searchFilter);
}); });
}; };
}] }]

View File

@ -1,3 +0,0 @@
<td class="data-table__host {{entry[cell_name + '_additionnalClass']}}" ng-controller="CellConfigHostCtrl">
<a class="data-table__data" href="#/view?view=host&host_name={{entry.host_name}}">{{entry.host_name}}</a>
</td>

View File

@ -1,12 +0,0 @@
'use strict';
angular.module('bansho.table.cell_config_host', ['bansho.table'])
.controller('CellConfigHostCtrl', ['$scope', function ($scope) {
$scope.cell_name = 'host';
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.config_host = ['host_name'];
tableGlobalConfig.cellWrappableField.config_host = 'host_name';
}]);

View File

@ -1,3 +0,0 @@
<td class="data-table__hostaddress">
<span class="data-table__data">{{entry.address}}</span>
</td>

View File

@ -1,11 +0,0 @@
'use strict';
angular.module('bansho.table.cell_config_host_address', ['bansho.table'])
.controller('CellConfigHostAddressCtrl', [function () {
angular.noop();
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.config_host_address = ['address'];
}]);

View File

@ -1,3 +0,0 @@
<td class="data-table__hostname">
<span class="data-table__data">{{entry.name}}</span>
</td>

View File

@ -1,11 +0,0 @@
'use strict';
angular.module('bansho.table.cell_config_host_name', ['bansho.table'])
.controller('CellConfigHostNameCtrl', [function () {
angular.noop();
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.config_host_use = ['name'];
}]);

View File

@ -1,3 +1,3 @@
<td class="data-table__hostregister" data-ng-controller="CellConfigHostRegisterCtrl"> <span data-ng-controller="CellConfigHostRegisterCtrl">
<span class="data-table__data fa {{activityClass}}"></span> <i class="data-table__data fa {{activityClass}}" />
</td> </span>

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('bansho.table.cell_config_host_register', ['bansho.table']) angular.module('bansho.table')
.controller('CellConfigHostRegisterCtrl', ['$scope', function ($scope) { .controller('CellConfigHostRegisterCtrl', ['$scope', function ($scope) {
if ($scope.register === 0) { if ($scope.register === 0) {

View File

@ -1,3 +0,0 @@
<td class="data-table__hostuse">
<span class="data-table__data">{{entry.use}}</span>
</td>

View File

@ -1,11 +0,0 @@
'use strict';
angular.module('bansho.table.cell_config_host_use', ['bansho.table'])
.controller('CellConfigHostUseCtrl', [function () {
angular.noop();
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.config_host_use = ['use'];
}]);

View File

@ -1,4 +1,4 @@
<td data-ng-click="toggleExpansion()" class="data-table__event" data-ng-controller="CellStatusEventCtrl"> <span data-ng-click="toggleExpansion()" data-ng-controller="CellOtherFieldsCtrl">
<p class="data-table__data"> <p class="data-table__data">
<i data-ng-class="{'ico-down-dir': isExpanded, 'ico-right-dir': !isExpanded}"></i> <i data-ng-class="{'ico-down-dir': isExpanded, 'ico-right-dir': !isExpanded}"></i>
<span data-ng-repeat="(k, e) in filter(entry)"> <span data-ng-repeat="(k, e) in filter(entry)">
@ -6,4 +6,4 @@
<span data-ng-show="isExpanded"><br></span> <span data-ng-show="isExpanded"><br></span>
</span> </span>
</p> </p>
</td> </span>

View File

@ -0,0 +1,29 @@
'use strict';
angular.module('bansho.table')
.controller('CellOtherFieldsCtrl', ['$scope', function ($scope) {
$scope.attributes = JSON.parse($scope.attributes);
$scope.isExpanded = false;
$scope.toggleExpansion = function () {
$scope.isExpanded = !$scope.isExpanded;
};
$scope.skipFields = {
"undefined_additionnalClass": true
};
angular.forEach($scope.attributes.skipFields, function (value) {
$scope.skipFields[value] = true;
});
$scope.filter = function (entry) {
var result = {};
angular.forEach(entry, function(value, key) {
if (!$scope.skipFields[key]) {
result[key] = entry[key];
}
});
return result;
};
}]);

View File

@ -0,0 +1,3 @@
<span data-ng-controller="CellSingleCtrl" class="data-table__data">
{{entry[attributes.entryKey]}}
</span>

View File

@ -0,0 +1,6 @@
'use strict';
angular.module('bansho.table')
.controller('CellSingleCtrl', ['$scope', function ($scope) {
$scope.attributes = JSON.parse($scope.attributes);
}]);

View File

@ -1,3 +1 @@
<td class="data-table__duration"> <time class="data-table__data">{{entry.service_last_state_change | timeElapsed}}</time>
<time class="data-table__data">{{entry.service_last_state_change | timeElapsed}}</time>
</td>

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('bansho.table.cell_status_duration', ['bansho.table']) angular.module('bansho.table')
.controller('CellStatusDurationCtrl', [function () { .controller('CellStatusDurationCtrl', [function () {
angular.noop(); angular.noop();

View File

@ -1,40 +0,0 @@
'use strict';
angular.module('bansho.table.cell_status_event', ['bansho.table'])
.controller('CellStatusEventCtrl', ['$scope', function ($scope) {
$scope.isExpanded = false;
$scope.toggleExpansion = function () {
$scope.isExpanded = !$scope.isExpanded;
};
var shownOutput = {
'event_attempts': true,
'event_contact': true,
'event_notification_method': true,
'event_notification_type': true,
'event_state': true,
'event_state_type': true
};
$scope.filter = function (entry) {
var result = {};
angular.forEach(entry, function(value, key) {
if (shownOutput[key]) {
result[key.substring(6)] = value;
}
});
return result;
};
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.status_output = [
'attempts',
'contact',
'notification_method',
'notification_type',
'state',
'state_type'
];
}]);

View File

@ -1,3 +0,0 @@
<td class="data-table__event_type">
<p class="data-table__data">{{entry.event_event_type}}</p>
</td>

View File

@ -1,11 +0,0 @@
'use strict';
angular.module('bansho.table.cell_status_event_event_type', ['bansho.table'])
.controller('CellStatusEventEventTypeCtrl', [function () {
angular.noop();
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.event_type = ['event_type'];
}]);

View File

@ -1,3 +0,0 @@
<td class="data-table__event_host_name">
<p class="data-table__data">{{entry.event_host_name}}</p>
</td>

View File

@ -1,11 +0,0 @@
'use strict';
angular.module('bansho.table.cell_status_event_host_name', ['bansho.table'])
.controller('CellStatusEventTypeCtrl', [function () {
angular.noop();
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.host_name = ['host_name'];
}]);

View File

@ -1,3 +0,0 @@
<td class="data-table__event_output">
<p class="data-table__data">{{entry.event_output}}</p>
</td>

View File

@ -1,11 +0,0 @@
'use strict';
angular.module('bansho.table.cell_status_event_output', ['bansho.table'])
.controller('CellStatusEventOutputCtrl', ['$scope', function ($scope) {
angular.noop();
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.status_output = ['output'];
}]);

View File

@ -1,3 +0,0 @@
<td class="data-table__event_service_description">
<p class="data-table__data">{{entry.event_service_description}}</p>
</td>

View File

@ -1,11 +0,0 @@
'use strict';
angular.module('bansho.table.cell_status_event_service', ['bansho.table'])
.controller('CellStatusEventServiceCtrl', [function () {
angular.noop();
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.service_description = ['service_description'];
}]);

View File

@ -1,3 +0,0 @@
<td class="data-table__time">
<time class="data-table__data">{{entry.event_time}}</time>
</td>

View File

@ -1,11 +0,0 @@
'use strict';
angular.module('bansho.table.cell_status_event_time', ['bansho.table'])
.controller('CellStatusEventTime', [function () {
angular.noop();
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.status_time = ['time'];
}]);

View File

@ -1,3 +1,3 @@
<td class="data-table__host {{entry[cell_name + '_additionnalClass']}} {{state}}" ng-controller="CellStatusHostCtrl"> <span class="{{state}}" data-ng-controller="CellStatusHostCtrl">
<a class="data-table__data" href="#/view?view=host&host_name={{entry.host_host_name}}">{{entry.host_host_name}}</a> <a class="data-table__data">{{entry.host_host_name}}</a>
</td> </span>

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('bansho.table.cell_status_host', ['bansho.table']) angular.module('bansho.table')
.controller('CellStatusHostCtrl', ['$scope', function ($scope) { .controller('CellStatusHostCtrl', ['$scope', function ($scope) {
$scope.cell_name = 'host'; $scope.cell_name = 'host';

View File

@ -1,3 +0,0 @@
<td class="data-table__hostaddress" ng-controller="CellStatusHostAddressCtrl">
<span class="data-table__data">{{entry.host_address}}</span>
</td>

View File

@ -1,11 +0,0 @@
'use strict';
angular.module('bansho.table.cell_status_host_address', ['bansho.table'])
.controller('CellStatusHostAddressCtrl', [function () {
angular.noop();
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.status_host_address = ['address'];
}]);

View File

@ -1,3 +1 @@
<td ng-controller="CellStatusHostStatusCtrl"> <span class="data-table__data {{entry.host_state}}">{{entry.host_state}}</span>
<span class="data-table__data {{entry.host_state}}">{{entry.host_state}}</span>
</td>

View File

@ -1,10 +1,6 @@
'use strict'; 'use strict';
angular.module('bansho.table.cell_status_host_status', ['bansho.table']) angular.module('bansho.table')
.controller('CellStatusHostStatusCtrl', ['$scope', function ($scope) {
angular.noop();
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) { .run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.status_host_status = ['state', 'last_check', 'parents']; tableGlobalConfig.cellToFieldsMap.status_host_status = ['state', 'last_check', 'parents'];

View File

@ -1,3 +1 @@
<td class="data-table__lastcheck"> <time class="data-table__data">{{entry.host_last_check * 1000 | date: "medium"}}</time>
<time class="data-table__data">{{entry.host_last_check * 1000 | date: "medium"}}</time>
</td>

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('bansho.table.cell_status_last_check', ['bansho.table']) angular.module('bansho.table')
.controller('CellStatusLastCheckCtrl', [function () { .controller('CellStatusLastCheckCtrl', [function () {
angular.noop(); angular.noop();

View File

@ -1,8 +1,8 @@
<td class="data-table__service {{state}}" ng-controller="CellStatusServiceCheckCtrl"> <span class="data-table__service {{state}}" ng-controller="CellStatusServiceCheckCtrl">
<dl class="data-table__data"> <dl class="data-table__data">
<dt class="data-table__service__name"> <dt class="data-table__service__name">
<a href="#/view?view=service&host_name={{entry.host_host_name}}&service_description={{entry.service_service_description}}">{{entry.service_service_description}}</a> <span>{{entry.service_service_description}}</span>
</dt> </dt>
<dd class="data-table__service__summary">{{entry.service_plugin_output}}</dd> <dd class="data-table__service__summary">{{entry.service_plugin_output}}</dd>
</dl> </dl>
</td> </span>

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('bansho.table.cell_status_service_check', ['bansho.table']) angular.module('bansho.table')
.controller('CellStatusServiceCheckCtrl', ['$scope', function ($scope) { .controller('CellStatusServiceCheckCtrl', ['$scope', function ($scope) {
if ($scope.entry.service_state === 'OK') { if ($scope.entry.service_state === 'OK') {

View File

@ -10,20 +10,20 @@ angular.module('bansho.table.pagingbar', ['bansho.datasource', 'bansho.surveil',
templateUrl: 'components/directive/table/pagingbar/pagingbar.html', templateUrl: 'components/directive/table/pagingbar/pagingbar.html',
controller: ['$scope', 'datasource', controller: ['$scope', 'datasource',
function ($scope, datasource) { function ($scope, datasource) {
$scope.tableId = $scope.options.attributes.tableId; $scope.datasourceId = $scope.options.attributes.datasourceId;
$scope.pageSizes = [5, 25, 50, 75, 100]; $scope.pageSizes = [5, 25, 50, 75, 100];
$scope.page = datasource.getPage($scope.tableId); $scope.page = datasource.getPage($scope.datasourceId);
$scope.size = datasource.getPageSize($scope.tableId); $scope.size = datasource.getPageSize($scope.datasourceId);
$scope.previousPage = function () { $scope.previousPage = function () {
datasource.previousPage($scope.tableId); datasource.previousPage($scope.datasourceId);
$scope.page = datasource.getPage($scope.tableId); $scope.page = datasource.getPage($scope.datasourceId);
}; };
$scope.nextPage = function () { $scope.nextPage = function () {
datasource.nextPage($scope.tableId); datasource.nextPage($scope.datasourceId);
$scope.page = datasource.getPage($scope.tableId); $scope.page = datasource.getPage($scope.datasourceId);
}; };
$scope.setPageSize = function (pageSize) { $scope.setPageSize = function (pageSize) {
@ -32,7 +32,7 @@ angular.module('bansho.table.pagingbar', ['bansho.datasource', 'bansho.surveil',
$scope.$watch('size', function (newValue) { $scope.$watch('size', function (newValue) {
if (newValue !== "") { if (newValue !== "") {
datasource.setPageSize($scope.tableId, newValue); datasource.setPageSize($scope.datasourceId, newValue);
} }
}); });
}] }]

View File

@ -1,70 +1,26 @@
<div> <div>
<table class="data-table"> <table class="data-table">
<thead class="moving-thead"> <thead data-ng-repeat="head in ['moving-thead', 'static-thead']" data-ng-class="head">
<tr> <tr>
<th data-ng-show="checkColumn" class="data-table__checkbox"> <th data-ng-show="checkColumn" class="data-table__checkbox">
<md-checkbox aria-label='Check all' ng-model="isCheckAll" ng-change="onCheckChange()"></md-checkbox> <md-checkbox aria-label='Check all' data-ng-model="isCheckAll" data-ng-change="onCheckChange()"></md-checkbox>
</th> </th>
<span data-ng-hide="allCells"> <th ng-repeat="column in columns" class="data-table__{{column.attributes.class}}">
<th ng-repeat="i in cellIndexes" class="data-table__{{cellsName[i]}}"> {{column.title}} <i class="ico-up-dir"></i>
{{cellsText[i]}} </th>
<i class="ico-up-dir"></i> </tr>
</th> </thead>
</span> <tbody data-ng-repeat="(groupByKey, groupByItems) in entries | groupBy:'host_host_name'">
<span data-ng-show="allCells"> <tr data-ng-repeat="entry in groupByItems | noRepeat:this | wrappableStyle:this">
<th ng-repeat="(key, value) in columns" class="data-table__host"> <td data-ng-show="checkColumn">
{{key}} <md-checkbox aria-label='Check' data-ng-model="entry.is_checked"></md-checkbox>
<i class="ico-up-dir"></i> </td>
</th> <td data-ng-repeat="cell in columns"
</span> data-ng-click="createUrl(entry, cell.attributes)">
</tr> <bansho-cell type="{{cell.type}}" attributes="{{cell.attributes}}"></bansho-cell>
</thead> </td>
</tr>
<thead class="static-thead"> </tbody>
<tr> </table>
<th data-ng-show="checkColumn" class="data-table__checkbox"> <bansho-pagingbar data-ng-if="pagingbar" options="options"></bansho-pagingbar>
<md-checkbox aria-label='Check all' ng-model="isCheckAll" ng-change="onCheckChange()"></md-checkbox>
</th>
<span data-ng-hide="allCells">
<th ng-repeat="i in cellIndexes" class="data-table__{{cellsName[i]}}">
{{cellsText[i]}}
<i class="ico-up-dir"></i>
</th>
</span>
<span data-ng-show="allCells">
<th ng-repeat="(key, value) in columns" class="data-table__host">
{{key}}
<i class="ico-up-dir"></i>
</th>
</span>
</tr>
</thead>
<tbody data-ng-if="!allCells" class="{{entry.child_class}}"
ng-repeat="(groupByKey, groupByItems) in entries | groupBy:'host_name'">
<tr ng-repeat="entry in groupByItems | noRepeat:this | wrappableStyle:this">
<td data-ng-show="checkColumn">
<md-checkbox aria-label='Check' ng-model="entry.is_checked"></md-checkbox>
</td>
<td bansho-cell cell-name="{{cell}}" ng-repeat="cell in cellsName"></td>
</tr>
</tbody>
<tbody data-ng-if="allCells" class="{{entry.child_class}}">
<tr ng-repeat="(key, entry) in entries">
<td data-ng-show="checkColumn">
<md-checkbox aria-label='Check' ng-model="entry.is_checked"></md-checkbox>
</td>
<td ng-repeat="(key, value) in columns">
<a data-ng-show="cellUrls[key]"
ng-click="createUrl(entry, cellUrls[key])">
{{entry[key]}}
</a>
<span data-ng-hide="cellUrls[key]">
{{entry[key]}}
</span>
</td>
</tr>
</tbody>
</table>
<bansho-pagingbar data-ng-if="pagingbar" options="options"></bansho-pagingbar>
</div> </div>

View File

@ -3,125 +3,112 @@
angular.module('bansho.table', ['bansho.datasource', angular.module('bansho.table', ['bansho.datasource',
'bansho.actionbar', 'bansho.actionbar',
'bansho.filters', 'bansho.filters',
'bansho.table.cell_status_host',
'bansho.table.cell_status_event',
'bansho.table.cell_status_service_check',
'bansho.table.cell_status_last_check',
'bansho.table.cell_status_host_address',
'bansho.table.cell_status_host_status',
'bansho.table.cell_config_host',
'bansho.table.cell_config_host_register',
'bansho.table.pagingbar', 'bansho.table.pagingbar',
'ngMaterial' 'ngMaterial'
]) ])
.directive('banshoTable', ['datasource', .directive('banshoTable', function () {
function (datasource) {
return {
restrict: 'E',
scope: {
options: '='
},
templateUrl: 'components/directive/table/table.html',
controller: ['$scope', '$window', 'headerFollow', 'datasource', 'templateManager',
function ($scope, $window, headerFollow, datasource, templateManager) {
var conf = {},
i;
$scope.tableId = $scope.options.attributes.tableId;
// Create table configuration
conf.title = $scope.options.attributes.title;
conf.cells = {'text': [], 'name': []};
if ($scope.options.attributes.cells) {
$scope.allCells = false;
conf.cells.text = $scope.options.attributes.cells.text;
conf.cells.name = $scope.options.attributes.cells.name;
} else {
$scope.allCells = true;
}
$scope.cellUrls = $scope.options.attributes.cellUrls;
$scope.createUrl = function (entry, urlParam) {
var url = "/#/view?view=" + urlParam.view;
angular.forEach(urlParam.params, function (paramName) {
url += '&' + paramName + '=' + entry[paramName];
});
$window.location = url;
};
conf.inputSource = $scope.options.attributes.inputSource;
conf.isWrappable = $scope.options.attributes.isWrappable;
conf.pagingbar = $scope.options.attributes.pagingbar;
conf.noRepeatCell = $scope.options.attributes.noRepeatCell;
datasource.addTable($scope.tableId, conf);
// Handle table layout
$scope.checkColumn = $scope.options.attributes.checkColumn;
$scope.pagingbar = conf.pagingbar;
if ($scope.options.attributes.headerFollow) {
headerFollow.activate();
} else {
headerFollow.deactivate();
}
$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);
}
$scope.onCheckChange = function () {
datasource.setAllCheckTable($scope.tableId, $scope.isCheckAll);
};
datasource.registerDataChanged($scope.tableId, function (data, isCheckAll) {
$scope.isCheckAll = isCheckAll;
$scope.entries = data;
if ($scope.allCells) {
$scope.columns = {};
angular.forEach($scope.entries, function (entry) {
angular.forEach(entry, function (value, key) {
$scope.columns[key] = true;
});
});
}
});
datasource.refreshTableData($scope.tableId);
templateManager.addInterval(function refreshTable () {
datasource.refreshTableData($scope.tableId);
});
}]
};
}
])
.directive('banshoCell', ['$http', '$compile', function ($http, $compile) {
return { return {
restrict: 'A', restrict: 'E',
compile: function () { scope: {
return function (scope, element, attrs) { options: '='
if (!attrs.cellName) { },
throw new Error('<bansho-cell> "cell-name" attribute must be defined'); templateUrl: 'components/directive/table/table.html',
controller: ['$scope', '$window', 'headerFollow', 'datasource', 'templateManager',
function ($scope, $window, headerFollow, datasource, templateManager) {
// Manage attributes.
$scope.datasourceId = $scope.options.attributes.datasourceId;
$scope.checkColumn = $scope.options.attributes.checkColumn;
$scope.pagingbar = $scope.options.attributes.pagingbar;
if ($scope.options.attributes.headerFollow) {
headerFollow.activate();
} else {
headerFollow.deactivate();
} }
var template = 'components/directive/table/cell_' + attrs.cellName + '/cell_' + attrs.cellName + '.html'; $scope.cellUrls = $scope.options.attributes.cellUrls;
$http.get(template, { cache: true }) // Handle components.
.success(function (data) { $scope.columns = [];
var td = $compile(data)(scope); angular.forEach($scope.options.components, function (cell) {
// HACK : replaceWith is a necessary hack because <tr> only accepts <td> as a child $scope.columns.push({
element.replaceWith(td); type: cell.type,
title: cell.attributes.title,
attributes: cell.attributes
}); });
}; });
}
// Add table configuration.
datasource.addTable($scope.datasourceId, {
columns: $scope.columns,
inputSource: $scope.options.attributes.inputSource,
pagingbar: $scope.options.attributes.pagingbar
});
datasource.registerDataChanged($scope.datasourceId, function (data, isCheckAll) {
$scope.isCheckAll = isCheckAll;
$scope.entries = data;
});
datasource.refreshTableData($scope.datasourceId);
templateManager.addInterval(function refreshTable () {
datasource.refreshTableData($scope.datasourceId);
});
// Table functions.
$scope.createUrl = function (entry, attributes) {
if (attributes.url) {
var url = "/#/view?view=" + attributes.url.view;
angular.forEach(attributes.url.params, function (value) {
url += '&' + value.urlParam + '=' + entry[value.entryKey];
});
$window.location = url;
}
};
$scope.onCheckChange = function () {
datasource.setAllCheckTable($scope.datasourceId, $scope.isCheckAll);
};
}]
}; };
}]) })
.directive('banshoCell', ['$http', '$compile', 'tableGlobalConfig',
function ($http, $compile, tableGlobalConfig) {
return {
restrict: 'E',
compile: function () {
return function (scope, element, attrs) {
var attributes = attrs.attributes,
template = 'components/directive/table/';
if (!attrs.type) {
throw new Error('Directive bansho-cell "type" attribute must be defined');
}
if (!attributes) {
throw new Error('Directive bansho-cell "attributes" attribute must be defined');
}
if (attrs.type == 'cell-single') {
template += 'cell_single/cell_single.html';
scope.attributes = attributes;
tableGlobalConfig[attrs.title] = scope.entryKey;
} else if (attrs.type == 'cell-other-fields') {
template += 'cell_other_fields/cell_other_fields.html';
scope.attributes = attributes;
} else {
var templateName = "cell_" + attrs.type.substring(5).replace(/-/g, "_");
template += templateName + '/' + templateName + '.html';
}
$http.get(template, { cache: true })
.success(function (data) {
element.replaceWith($compile(data)(scope));
});
};
}
};
}])
.filter('wrappableStyle', ['datasource', 'tableGlobalConfig', function (datasource, tableGlobalConfig) { .filter('wrappableStyle', ['datasource', 'tableGlobalConfig', function (datasource, tableGlobalConfig) {
return function (input, scope) { return function (input, scope) {
@ -130,13 +117,13 @@ angular.module('bansho.table', ['bansho.datasource',
parent_found = false, parent_found = false,
class_name = ['', ''], class_name = ['', ''],
i, i,
fieldToWrap = tableGlobalConfig.cellWrappableField[datasource.getConfig(scope.tableId).noRepeatCell]; fieldToWrap = tableGlobalConfig.cellWrappableField[datasource.getConfig(scope.datasourceId).noRepeatCell];
if (fieldToWrap === undefined) { if (fieldToWrap === undefined) {
return input; return input;
} }
if (datasource.getConfig(scope.tableId).isWrappable) { if (datasource.getConfig(scope.datasourceId).isWrappable) {
class_name = ['state--hasChild', 'state--isChild']; class_name = ['state--hasChild', 'state--isChild'];
} }
@ -169,8 +156,8 @@ angular.module('bansho.table', ['bansho.datasource',
return function (items, scope) { return function (items, scope) {
var newItems = [], var newItems = [],
previous, previous,
fieldToCompare = tableGlobalConfig.cellWrappableField[datasource.getConfig(scope.tableId).noRepeatCell], fieldToCompare = tableGlobalConfig.cellWrappableField[datasource.getConfig(scope.datasourceId).noRepeatCell],
newAttr = datasource.getConfig(scope.tableId).noRepeatCell + "_additionnalClass"; newAttr = datasource.getConfig(scope.datasourceId).noRepeatCell + "_additionnalClass";
angular.forEach(items, function (item) { angular.forEach(items, function (item) {

View File

@ -86,23 +86,13 @@
<script src="components/directive/table/pagingbar/pagingbar.js"></script> <script src="components/directive/table/pagingbar/pagingbar.js"></script>
<script src="components/directive/table/cell_status_duration/cell_status_duration.js"></script> <script src="components/directive/table/cell_status_duration/cell_status_duration.js"></script>
<script src="components/directive/table/cell_config_host/cell_config_host.js"></script> <script src="components/directive/table/cell_single/cell_single.js"></script>
<script src="components/directive/table/cell_config_host_address/cell_config_host_address.js"></script>
<script src="components/directive/table/cell_config_host_name/cell_config_host_name.js"></script>
<script src="components/directive/table/cell_config_host_register/cell_config_host_register.js"></script> <script src="components/directive/table/cell_config_host_register/cell_config_host_register.js"></script>
<script src="components/directive/table/cell_config_host_use/cell_config_host_use.js"></script>
<script src="components/directive/table/cell_status_event/cell_status_event.js"></script>
<script src="components/directive/table/cell_status_event_event_type/cell_status_event_event_type.js"></script>
<script src="components/directive/table/cell_status_event_output/cell_status_event_output.js"></script>
<script src="components/directive/table/cell_status_event_host_name/cell_status_event_host_name.js"></script>
<script src="components/directive/table/cell_status_event_service/cell_status_event_service.js"></script>
<script src="components/directive/table/cell_status_event_time/cell_status_event_time.js"></script>
<script src="components/directive/table/cell_other_fields/cell_other_fields.js"></script>
<script src="components/directive/table/cell_status_host/cell_status_host.js"></script> <script src="components/directive/table/cell_status_host/cell_status_host.js"></script>
<script src="components/directive/table/cell_status_last_check/cell_status_last_check.js"></script> <script src="components/directive/table/cell_status_last_check/cell_status_last_check.js"></script>
<script src="components/directive/table/cell_status_service_check/cell_status_service_check.js"></script> <script src="components/directive/table/cell_status_service_check/cell_status_service_check.js"></script>
<script src="components/directive/table/cell_status_host_address/cell_status_host_address.js"></script>
<script src="components/directive/table/cell_status_host_status/cell_status_host_status.js"></script> <script src="components/directive/table/cell_status_host_status/cell_status_host_status.js"></script>
<script src="components/directive/state_icon/state_icon.js"></script> <script src="components/directive/state_icon/state_icon.js"></script>
<script src="components/grafana/grafana.js"></script> <script src="components/grafana/grafana.js"></script>