From 68e3f89633daa81bc7f91365ae0e2dc547ff8a94 Mon Sep 17 00:00:00 2001 From: Vincent Fournier Date: Mon, 17 Aug 2015 11:58:41 -0400 Subject: [PATCH] Add single cell and modify config Change-Id: I7c1349248dc64c73efe6b7aefb46e82d29a4cce7 --- .../sass/modules-objects/_data-table.scss | 35 +- app/components/config/config.json | 2 +- .../config/defaultLayoutConfig.json | 601 +++++++++++++----- app/components/datasource/datasource.js | 106 +-- .../directive/actionbar/actionbar.js | 4 +- .../component_acknowledge/acknowledge.js | 6 +- .../actionbar/component_downtime/downtime.js | 8 +- .../actionbar/component_filter/filter.js | 6 +- .../actionbar/component_recheck/recheck.js | 6 +- .../component_search_filter/search_filter.js | 4 +- .../cell_config_host/cell_config_host.html | 3 - .../cell_config_host/cell_config_host.js | 12 - .../cell_config_host_address.html | 3 - .../cell_config_host_address.js | 11 - .../cell_config_host_name.html | 3 - .../cell_config_host_name.js | 11 - .../cell_config_host_register.html | 6 +- .../cell_config_host_register.js | 2 +- .../cell_config_host_use.html | 3 - .../cell_config_host_use.js | 11 - .../cell_other_fields.html} | 4 +- .../cell_other_fields/cell_other_fields.js | 29 + .../table/cell_single/cell_single.html | 3 + .../table/cell_single/cell_single.js | 6 + .../cell_status_duration.html | 4 +- .../cell_status_duration.js | 2 +- .../cell_status_event/cell_status_event.js | 40 -- .../cell_status_event_event_type.html | 3 - .../cell_status_event_event_type.js | 11 - .../cell_status_event_host_name.html | 3 - .../cell_status_event_host_name.js | 11 - .../cell_status_event_output.html | 3 - .../cell_status_event_output.js | 11 - .../cell_status_event_service.html | 3 - .../cell_status_event_service.js | 11 - .../cell_status_event_time.html | 3 - .../cell_status_event_time.js | 11 - .../cell_status_host/cell_status_host.html | 6 +- .../cell_status_host/cell_status_host.js | 2 +- .../cell_status_host_address.html | 3 - .../cell_status_host_address.js | 11 - .../cell_status_host_status.html | 4 +- .../cell_status_host_status.js | 6 +- .../cell_status_last_check.html | 4 +- .../cell_status_last_check.js | 2 +- .../cell_status_service_check.html | 6 +- .../cell_status_service_check.js | 2 +- .../directive/table/pagingbar/pagingbar.js | 16 +- app/components/directive/table/table.html | 92 +-- app/components/directive/table/table.js | 213 +++---- app/index.html | 14 +- 51 files changed, 719 insertions(+), 663 deletions(-) delete mode 100644 app/components/directive/table/cell_config_host/cell_config_host.html delete mode 100644 app/components/directive/table/cell_config_host/cell_config_host.js delete mode 100644 app/components/directive/table/cell_config_host_address/cell_config_host_address.html delete mode 100644 app/components/directive/table/cell_config_host_address/cell_config_host_address.js delete mode 100644 app/components/directive/table/cell_config_host_name/cell_config_host_name.html delete mode 100644 app/components/directive/table/cell_config_host_name/cell_config_host_name.js delete mode 100644 app/components/directive/table/cell_config_host_use/cell_config_host_use.html delete mode 100644 app/components/directive/table/cell_config_host_use/cell_config_host_use.js rename app/components/directive/table/{cell_status_event/cell_status_event.html => cell_other_fields/cell_other_fields.html} (71%) create mode 100644 app/components/directive/table/cell_other_fields/cell_other_fields.js create mode 100644 app/components/directive/table/cell_single/cell_single.html create mode 100644 app/components/directive/table/cell_single/cell_single.js delete mode 100644 app/components/directive/table/cell_status_event/cell_status_event.js delete mode 100644 app/components/directive/table/cell_status_event_event_type/cell_status_event_event_type.html delete mode 100644 app/components/directive/table/cell_status_event_event_type/cell_status_event_event_type.js delete mode 100644 app/components/directive/table/cell_status_event_host_name/cell_status_event_host_name.html delete mode 100644 app/components/directive/table/cell_status_event_host_name/cell_status_event_host_name.js delete mode 100644 app/components/directive/table/cell_status_event_output/cell_status_event_output.html delete mode 100644 app/components/directive/table/cell_status_event_output/cell_status_event_output.js delete mode 100644 app/components/directive/table/cell_status_event_service/cell_status_event_service.html delete mode 100644 app/components/directive/table/cell_status_event_service/cell_status_event_service.js delete mode 100644 app/components/directive/table/cell_status_event_time/cell_status_event_time.html delete mode 100644 app/components/directive/table/cell_status_event_time/cell_status_event_time.js delete mode 100644 app/components/directive/table/cell_status_host_address/cell_status_host_address.html delete mode 100644 app/components/directive/table/cell_status_host_address/cell_status_host_address.js diff --git a/app/assets/sass/modules-objects/_data-table.scss b/app/assets/sass/modules-objects/_data-table.scss index e0a55b5..ef82c8a 100644 --- a/app/assets/sass/modules-objects/_data-table.scss +++ b/app/assets/sass/modules-objects/_data-table.scss @@ -333,7 +333,6 @@ time.data-table__data { line-height: 40px; } - @include medium-and-up-screen { width:percentage(368 / 1200); } @@ -352,10 +351,6 @@ time.data-table__data { line-height: 24px; } - @include medium-and-up-screen { - width:percentage(500 / 1200); - } - .data-table__service__summary { font-style:italic; margin-left:0; @@ -373,3 +368,33 @@ time.data-table__data { 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); + } +} diff --git a/app/components/config/config.json b/app/components/config/config.json index 643c7bd..afe0de0 100644 --- a/app/components/config/config.json +++ b/app/components/config/config.json @@ -2,7 +2,7 @@ "env": "production", "username":"", "password":"", - "useStoredConfig": false, + "useStoredConfig": true, "surveilApiUrl": "surveil/v2", "surveilAuthUrl": "surveil/v2/auth", "refreshInterval": -1 diff --git a/app/components/config/defaultLayoutConfig.json b/app/components/config/defaultLayoutConfig.json index 86000b0..7265e5b 100644 --- a/app/components/config/defaultLayoutConfig.json +++ b/app/components/config/defaultLayoutConfig.json @@ -24,7 +24,7 @@ { "type": "panel", "attributes": { - "panelId": "openProblems" + "panelId": "allProblems" }, "components": [ { @@ -94,7 +94,7 @@ { "type": "actionbar", "attributes": { - "tableId": [ + "datasourceId": [ 0, 1 ] @@ -152,30 +152,56 @@ { "type": "table", "attributes": { - "tableId": 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, + "datasourceId": 0, "inputSource": "hostOpenProblems", + "headerFollow": false, "isWrappable": false, "checkColumn": true, "noRepeatCell": "", "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", @@ -188,28 +214,49 @@ { "type": "table", "attributes": { - "tableId": 1, - "cells": { - "text": [ - "Host", - "Service check", - "Duration", - "Last check" - ], - "name": [ - "status_host", - "status_service_check", - "status_duration", - "status_last_check" - ] - }, - "headerFollow": false, + "datasourceId": 1, "inputSource": "serviceOpenProblemsOnly", + "headerFollow": false, "isWrappable": true, "checkColumn": true, "noRepeatCell": "host", "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", "attributes": { - "tableId": [ + "datasourceId": [ 2, 3 ] @@ -281,30 +328,56 @@ { "type": "table", "attributes": { - "tableId": 2, - "cells": { - "text": [ - "Host", - "Address", - "Duration", - "Lastcheck", - "Hoststatus" - ], - "name": [ - "status_host", - "status_host_address", - "status_duration", - "status_last_check", - "status_host_status" - ] - }, - "headerFollow": false, + "datasourceId": 2, "inputSource": "hostsProblems", + "headerFollow": false, "isWrappable": false, "checkColumn": true, "noRepeatCell": "", "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", @@ -317,28 +390,49 @@ { "type": "table", "attributes": { - "tableId": 3, - "cells": { - "text": [ - "Host", - "Service check", - "Duration", - "Last check" - ], - "name": [ - "status_host", - "status_service_check", - "status_duration", - "status_last_check" - ] - }, - "headerFollow": false, + "datasourceId": 3, "inputSource": "servicesProblems", + "headerFollow": false, "isWrappable": true, "checkColumn": true, "noRepeatCell": "host", "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", "attributes": { - "title": "Hosts" + "title": "Hosts status" } }, { "type": "actionbar", "attributes": { - "tableId": [ + "datasourceId": [ 0 ] }, @@ -410,30 +504,59 @@ { "type": "table", "attributes": { - "tableId": 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, + "datasourceId": 0, "inputSource": "hosts", + "headerFollow": true, "isWrappable": false, "noRepeatCell": "", "checkColumn": 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", "attributes": { - "tableId": [ + "datasourceId": [ 0 ] }, @@ -503,28 +626,62 @@ { "type": "table", "attributes": { - "tableId": 0, - "cells": { - "text": [ - "Host", - "Service check", - "Duration", - "Last check" - ], - "name": [ - "status_host", - "status_service_check", - "status_duration", - "status_last_check" - ] - }, - "headerFollow": true, + "datasourceId": 0, "inputSource": "services", + "headerFollow": true, "isWrappable": false, "checkColumn": true, "noRepeatCell": "host", "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", "attributes": { - "tableId": [ + "datasourceId": [ 0 ] }, @@ -582,32 +739,64 @@ { "type": "table", "attributes": { - "tableId": 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, + "datasourceId": 0, "inputSource": "events", + "headerFollow": true, "isWrappable": false, "checkColumn": false, "noRepeatCell": "", "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", "attributes": { - "title": "ConfigHosts" + "title": "Hosts configuration" } }, { "type": "actionbar", "attributes": { - "tableId": [ + "datasourceId": [ 0 ] }, @@ -770,29 +959,53 @@ { "type": "table", "attributes": { - "tableId": 0, - "refreshInterval": 30, - "cells": { - "text": [ - "Host", - "Address", - "Use", - "Enable" - ], - "name": [ - "config_host", - "config_host_address", - "config_host_use", - "config_host_register" - ] - }, - "headerFollow": false, + "datasourceId": 0, "inputSource": "hostsConfig", + "headerFollow": false, "isWrappable": false, "noRepeatCell": "", "checkColumn": false, "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", "attributes": { - "tableId": [ + "datasourceId": [ 0 ] }, @@ -850,24 +1063,40 @@ { "type": "table", "attributes": { - "tableId": 0, - "cells": { - "text": [ - "Template", - "Use" - ], - "name": [ - "config_host_name", - "config_host_use" - ] - }, - "headerFollow": false, + "datasourceId": 0, "inputSource": "hostsConfigTemplate", + "headerFollow": false, "isWrappable": false, "noRepeatCell": "", "checkColumn": false, "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", "attributes": { - "tableId": [ + "datasourceId": [ 0 ] }, @@ -910,9 +1139,9 @@ { "type": "table", "attributes": { - "tableId": 0, - "headerFollow": true, + "datasourceId": 0, "inputSource": "commands", + "headerFollow": true, "isWrappable": false, "noRepeatCell": "", "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 @@ ] } ] - } } diff --git a/app/components/datasource/datasource.js b/app/components/datasource/datasource.js index cabf5f7..2acbb2b 100644 --- a/app/components/datasource/datasource.js +++ b/app/components/datasource/datasource.js @@ -14,33 +14,33 @@ angular.module('bansho.datasource', ['bansho.surveil']) filteredData = [], listeners = []; - function notifyDataChanged(tableId) { - angular.forEach(listeners[tableId], function (callback) { - callback(filteredData[tableId], config[tableId].isCheckAll); + function notifyDataChanged(datasourceId) { + angular.forEach(listeners[datasourceId], function (callback) { + callback(filteredData[datasourceId], config[datasourceId].isCheckAll); }); } - function filterData(tableId) { - filteredData[tableId] = $filter('filter')(data[tableId], config[tableId].searchFilter); - notifyDataChanged(tableId); + function filterData(datasourceId) { + filteredData[datasourceId] = $filter('filter')(data[datasourceId], config[datasourceId].searchFilter); + notifyDataChanged(datasourceId); } - function refreshTableData(tableId) { - var conf = config[tableId], + function refreshTableData(datasourceId) { + var conf = config[datasourceId], inputSource = componentsConfig.getInputSource(conf.inputSource), filter = componentsConfig.getFilter(inputSource.filter).filter, promise; - if (config[tableId].queryFilter) { - filter = componentsConfig.mergeFilters([config[tableId].queryFilter, filter]); + if (config[datasourceId].queryFilter) { + filter = componentsConfig.mergeFilters([config[datasourceId].queryFilter, filter]); } promise = providerServices[inputSource.provider].getData([], filter, inputSource.endpoint, conf.queryPaging); promise.then(function (newData) { - data[tableId] = newData; - config[tableId].isCheckAll = false; - filterData(tableId); + data[datasourceId] = newData; + config[datasourceId].isCheckAll = false; + filterData(datasourceId); }, function (error) { throw new Error('getTableData : Query failed' + error); }); @@ -48,76 +48,76 @@ angular.module('bansho.datasource', ['bansho.surveil']) return { refreshTableData: refreshTableData, - addTable: function (tableId, conf) { - config[tableId] = conf; - config[tableId].requestFields = []; - angular.forEach(config[tableId].cells.name, function (cell) { + addTable: function (datasourceId, conf) { + config[datasourceId] = conf; + config[datasourceId].requestFields = []; + angular.forEach(config[datasourceId].columns, function (cell) { angular.forEach(tableGlobalConfig.cellToFieldsMap[cell], function (_value) { - config[tableId].requestFields.push(_value); + config[datasourceId].requestFields.push(_value); }); }); - if (config[tableId].pagingbar) { - config[tableId].queryPaging = { + if (config[datasourceId].pagingbar) { + config[datasourceId].queryPaging = { page: 0, size: configManager.getPagingSize() }; } }, - getConfig: function (tableId) { - return config[tableId]; + getConfig: function (datasourceId) { + return config[datasourceId]; }, - forEachCheckedEntry: function (tableId, callbackIsChecked) { - angular.forEach(filteredData[tableId], function (entry) { + forEachCheckedEntry: function (datasourceId, callbackIsChecked) { + angular.forEach(filteredData[datasourceId], function (entry) { if (entry.is_checked) { callbackIsChecked(entry); } }); - notifyDataChanged(tableId); + notifyDataChanged(datasourceId); }, - registerDataChanged: function (tableId, callback) { - if (!listeners[tableId]) { - listeners[tableId] = []; + registerDataChanged: function (datasourceId, callback) { + if (!listeners[datasourceId]) { + listeners[datasourceId] = []; } - listeners[tableId].push(callback); + listeners[datasourceId].push(callback); }, - setAllCheckTable: function (tableId, isChecked) { - config[tableId].isCheckAll = isChecked; - angular.forEach(filteredData[tableId], function (entry) { + setAllCheckTable: function (datasourceId, isChecked) { + config[datasourceId].isCheckAll = isChecked; + angular.forEach(filteredData[datasourceId], function (entry) { entry.is_checked = isChecked; }); - notifyDataChanged(tableId, isChecked); + notifyDataChanged(datasourceId, isChecked); }, - setSearchFilter: function (tableId, searchFilter) { - config[tableId].searchFilter = searchFilter; - filterData(tableId); + setSearchFilter: function (datasourceId, searchFilter) { + config[datasourceId].searchFilter = searchFilter; + filterData(datasourceId); }, - setQueryFilter: function (tableId, queryFilter) { - config[tableId].queryFilter = queryFilter; - refreshTableData(tableId); + setQueryFilter: function (datasourceId, queryFilter) { + config[datasourceId].queryFilter = queryFilter; + refreshTableData(datasourceId); }, - nextPage: function (tableId) { - config[tableId].queryPaging.page += 1; - refreshTableData(tableId); + nextPage: function (datasourceId) { + config[datasourceId].queryPaging.page += 1; + refreshTableData(datasourceId); }, - previousPage: function (tableId) { - if (config[tableId].queryPaging.page > 0) { - config[tableId].queryPaging.page -= 1; - refreshTableData(tableId); + previousPage: function (datasourceId) { + if (config[datasourceId].queryPaging.page > 0) { + config[datasourceId].queryPaging.page -= 1; + refreshTableData(datasourceId); } }, - getPage: function (tableId) { - return config[tableId].queryPaging.page; + getPage: function (datasourceId) { + return config[datasourceId].queryPaging.page; }, - setPageSize: function (tableId, pageSize) { - config[tableId].queryPaging.size = pageSize; - refreshTableData(tableId); + setPageSize: function (datasourceId, pageSize) { + config[datasourceId].queryPaging.size = pageSize; + refreshTableData(datasourceId); }, - getPageSize: function (tableId) { - return config[tableId].queryPaging.size; + getPageSize: function (datasourceId) { + return config[datasourceId].queryPaging.size; } }; }]) diff --git a/app/components/directive/actionbar/actionbar.js b/app/components/directive/actionbar/actionbar.js index d238582..5591881 100644 --- a/app/components/directive/actionbar/actionbar.js +++ b/app/components/directive/actionbar/actionbar.js @@ -9,11 +9,11 @@ angular.module('bansho.actionbar', ['bansho.datasource', 'bansho.surveil', 'bans }, templateUrl: 'components/directive/actionbar/actionbar.html', link: function (scope, element) { - scope.tableId = scope.options.attributes.tableId; + scope.datasourceId = scope.options.attributes.datasourceId; scope.components = scope.options.components; angular.forEach(scope.components, function (component) { - component.attributes.tableId = scope.tableId; + component.attributes.datasourceId = scope.datasourceId; }); $compile(element.contents())(scope); diff --git a/app/components/directive/actionbar/component_acknowledge/acknowledge.js b/app/components/directive/actionbar/component_acknowledge/acknowledge.js index 9348409..5a2447c 100644 --- a/app/components/directive/actionbar/component_acknowledge/acknowledge.js +++ b/app/components/directive/actionbar/component_acknowledge/acknowledge.js @@ -16,8 +16,8 @@ angular.module('bansho.actionbar') }; $scope.acknowledgeProblems = function () { - angular.forEach($scope.options.attributes.tableId, function (tableId) { - datasource.forEachCheckedEntry(tableId, function (entry) { + angular.forEach($scope.options.attributes.datasourceId, function (datasourceId) { + datasource.forEachCheckedEntry(datasourceId, function (entry) { 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); }, @@ -26,7 +26,7 @@ angular.module('bansho.actionbar') }); }); - datasource.setAllCheckTable(tableId, false); + datasource.setAllCheckTable(datasourceId, false); }); $scope.isAcknowledgeFormShown = false; diff --git a/app/components/directive/actionbar/component_downtime/downtime.js b/app/components/directive/actionbar/component_downtime/downtime.js index 2865a93..1809214 100644 --- a/app/components/directive/actionbar/component_downtime/downtime.js +++ b/app/components/directive/actionbar/component_downtime/downtime.js @@ -10,7 +10,7 @@ angular.module('bansho.actionbar') }, controller: ['$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.switchDowntimeFormShown = function () { @@ -18,8 +18,8 @@ angular.module('bansho.actionbar') }; $scope.sendDowntime = function () { - angular.forEach($scope.options.attributes.tableId, function (tableId) { - datasource.forEachCheckedEntry(tableId, function (entry) { + angular.forEach($scope.options.attributes.datasourceId, function (datasourceId) { + datasource.forEachCheckedEntry(datasourceId, function (entry) { 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); }, @@ -28,7 +28,7 @@ angular.module('bansho.actionbar') }); }); - datasource.setAllCheckTable(tableId, false); + datasource.setAllCheckTable(datasourceId, false); }); $scope.isDowntimeFormShown = false; diff --git a/app/components/directive/actionbar/component_filter/filter.js b/app/components/directive/actionbar/component_filter/filter.js index 30e020f..441ec02 100644 --- a/app/components/directive/actionbar/component_filter/filter.js +++ b/app/components/directive/actionbar/component_filter/filter.js @@ -9,7 +9,7 @@ angular.module('bansho.actionbar') }, templateUrl: 'components/directive/actionbar/component_filter/filter.html', controller: ['$scope', 'datasource', function ($scope, datasource) { - $scope.tableId = $scope.options.attributes.tableId; + $scope.datasourceId = $scope.options.attributes.datasourceId; $scope.filters = []; angular.forEach($scope.options.attributes.filters, function (filter) { @@ -39,8 +39,8 @@ angular.module('bansho.actionbar') $scope.activateFilter = function (item) { $scope.activeFilter = $scope.filters[item]; - angular.forEach($scope.tableId, function (tableId) { - datasource.setQueryFilter(tableId, $scope.activeFilter.filter); + angular.forEach($scope.datasourceId, function (datasourceId) { + datasource.setQueryFilter(datasourceId, $scope.activeFilter.filter); }); $scope.isShown = false; }; diff --git a/app/components/directive/actionbar/component_recheck/recheck.js b/app/components/directive/actionbar/component_recheck/recheck.js index 182128c..bcb7803 100644 --- a/app/components/directive/actionbar/component_recheck/recheck.js +++ b/app/components/directive/actionbar/component_recheck/recheck.js @@ -11,8 +11,8 @@ angular.module('bansho.actionbar') controller: ['$scope', 'datasource', 'surveilActions', 'notifications', function ($scope, datasource, surveilActions, notifications) { $scope.sendRecheck = function () { - angular.forEach($scope.options.attributes.tableId, function (tableId) { - datasource.forEachCheckedEntry(tableId, function (entry) { + angular.forEach($scope.options.attributes.datasourceId, function (datasourceId) { + datasource.forEachCheckedEntry(datasourceId, function (entry) { 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); }, @@ -21,7 +21,7 @@ angular.module('bansho.actionbar') }); }); - datasource.setAllCheckTable(tableId, false); + datasource.setAllCheckTable(datasourceId, false); }); }; } diff --git a/app/components/directive/actionbar/component_search_filter/search_filter.js b/app/components/directive/actionbar/component_search_filter/search_filter.js index e5f3ee8..3f60423 100644 --- a/app/components/directive/actionbar/component_search_filter/search_filter.js +++ b/app/components/directive/actionbar/component_search_filter/search_filter.js @@ -10,8 +10,8 @@ angular.module('bansho.actionbar') templateUrl: 'components/directive/actionbar/component_search_filter/search_filter.html', controller: ['$scope', 'datasource', function ($scope, datasource) { $scope.searchFilterChange = function () { - angular.forEach($scope.options.attributes.tableId, function (tableId) { - datasource.setSearchFilter(tableId, $scope.searchFilter); + angular.forEach($scope.options.attributes.datasourceId, function (datasourceId) { + datasource.setSearchFilter(datasourceId, $scope.searchFilter); }); }; }] diff --git a/app/components/directive/table/cell_config_host/cell_config_host.html b/app/components/directive/table/cell_config_host/cell_config_host.html deleted file mode 100644 index 455deae..0000000 --- a/app/components/directive/table/cell_config_host/cell_config_host.html +++ /dev/null @@ -1,3 +0,0 @@ - - {{entry.host_name}} - diff --git a/app/components/directive/table/cell_config_host/cell_config_host.js b/app/components/directive/table/cell_config_host/cell_config_host.js deleted file mode 100644 index d4004f1..0000000 --- a/app/components/directive/table/cell_config_host/cell_config_host.js +++ /dev/null @@ -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'; - }]); diff --git a/app/components/directive/table/cell_config_host_address/cell_config_host_address.html b/app/components/directive/table/cell_config_host_address/cell_config_host_address.html deleted file mode 100644 index c883bdc..0000000 --- a/app/components/directive/table/cell_config_host_address/cell_config_host_address.html +++ /dev/null @@ -1,3 +0,0 @@ - - {{entry.address}} - diff --git a/app/components/directive/table/cell_config_host_address/cell_config_host_address.js b/app/components/directive/table/cell_config_host_address/cell_config_host_address.js deleted file mode 100644 index 70feecc..0000000 --- a/app/components/directive/table/cell_config_host_address/cell_config_host_address.js +++ /dev/null @@ -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']; - }]); diff --git a/app/components/directive/table/cell_config_host_name/cell_config_host_name.html b/app/components/directive/table/cell_config_host_name/cell_config_host_name.html deleted file mode 100644 index 6eb392e..0000000 --- a/app/components/directive/table/cell_config_host_name/cell_config_host_name.html +++ /dev/null @@ -1,3 +0,0 @@ - - {{entry.name}} - diff --git a/app/components/directive/table/cell_config_host_name/cell_config_host_name.js b/app/components/directive/table/cell_config_host_name/cell_config_host_name.js deleted file mode 100644 index 6d58901..0000000 --- a/app/components/directive/table/cell_config_host_name/cell_config_host_name.js +++ /dev/null @@ -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']; - }]); diff --git a/app/components/directive/table/cell_config_host_register/cell_config_host_register.html b/app/components/directive/table/cell_config_host_register/cell_config_host_register.html index ff22217..f436b27 100644 --- a/app/components/directive/table/cell_config_host_register/cell_config_host_register.html +++ b/app/components/directive/table/cell_config_host_register/cell_config_host_register.html @@ -1,3 +1,3 @@ - - - + + + diff --git a/app/components/directive/table/cell_config_host_register/cell_config_host_register.js b/app/components/directive/table/cell_config_host_register/cell_config_host_register.js index 73462bf..445a36a 100644 --- a/app/components/directive/table/cell_config_host_register/cell_config_host_register.js +++ b/app/components/directive/table/cell_config_host_register/cell_config_host_register.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('bansho.table.cell_config_host_register', ['bansho.table']) +angular.module('bansho.table') .controller('CellConfigHostRegisterCtrl', ['$scope', function ($scope) { if ($scope.register === 0) { diff --git a/app/components/directive/table/cell_config_host_use/cell_config_host_use.html b/app/components/directive/table/cell_config_host_use/cell_config_host_use.html deleted file mode 100644 index f9589b4..0000000 --- a/app/components/directive/table/cell_config_host_use/cell_config_host_use.html +++ /dev/null @@ -1,3 +0,0 @@ - - {{entry.use}} - diff --git a/app/components/directive/table/cell_config_host_use/cell_config_host_use.js b/app/components/directive/table/cell_config_host_use/cell_config_host_use.js deleted file mode 100644 index 3c28ec6..0000000 --- a/app/components/directive/table/cell_config_host_use/cell_config_host_use.js +++ /dev/null @@ -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']; - }]); diff --git a/app/components/directive/table/cell_status_event/cell_status_event.html b/app/components/directive/table/cell_other_fields/cell_other_fields.html similarity index 71% rename from app/components/directive/table/cell_status_event/cell_status_event.html rename to app/components/directive/table/cell_other_fields/cell_other_fields.html index 0342446..59ed282 100644 --- a/app/components/directive/table/cell_status_event/cell_status_event.html +++ b/app/components/directive/table/cell_other_fields/cell_other_fields.html @@ -1,4 +1,4 @@ - +

@@ -6,4 +6,4 @@

- +
diff --git a/app/components/directive/table/cell_other_fields/cell_other_fields.js b/app/components/directive/table/cell_other_fields/cell_other_fields.js new file mode 100644 index 0000000..2687500 --- /dev/null +++ b/app/components/directive/table/cell_other_fields/cell_other_fields.js @@ -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; + }; + }]); diff --git a/app/components/directive/table/cell_single/cell_single.html b/app/components/directive/table/cell_single/cell_single.html new file mode 100644 index 0000000..2b98a67 --- /dev/null +++ b/app/components/directive/table/cell_single/cell_single.html @@ -0,0 +1,3 @@ + + {{entry[attributes.entryKey]}} + diff --git a/app/components/directive/table/cell_single/cell_single.js b/app/components/directive/table/cell_single/cell_single.js new file mode 100644 index 0000000..33836b5 --- /dev/null +++ b/app/components/directive/table/cell_single/cell_single.js @@ -0,0 +1,6 @@ +'use strict'; + +angular.module('bansho.table') + .controller('CellSingleCtrl', ['$scope', function ($scope) { + $scope.attributes = JSON.parse($scope.attributes); + }]); diff --git a/app/components/directive/table/cell_status_duration/cell_status_duration.html b/app/components/directive/table/cell_status_duration/cell_status_duration.html index eaa2e18..ee8aaa5 100644 --- a/app/components/directive/table/cell_status_duration/cell_status_duration.html +++ b/app/components/directive/table/cell_status_duration/cell_status_duration.html @@ -1,3 +1 @@ - - - + diff --git a/app/components/directive/table/cell_status_duration/cell_status_duration.js b/app/components/directive/table/cell_status_duration/cell_status_duration.js index 8f4755f..7649052 100644 --- a/app/components/directive/table/cell_status_duration/cell_status_duration.js +++ b/app/components/directive/table/cell_status_duration/cell_status_duration.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('bansho.table.cell_status_duration', ['bansho.table']) +angular.module('bansho.table') .controller('CellStatusDurationCtrl', [function () { angular.noop(); diff --git a/app/components/directive/table/cell_status_event/cell_status_event.js b/app/components/directive/table/cell_status_event/cell_status_event.js deleted file mode 100644 index c605c61..0000000 --- a/app/components/directive/table/cell_status_event/cell_status_event.js +++ /dev/null @@ -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' - ]; - }]); diff --git a/app/components/directive/table/cell_status_event_event_type/cell_status_event_event_type.html b/app/components/directive/table/cell_status_event_event_type/cell_status_event_event_type.html deleted file mode 100644 index 32730f1..0000000 --- a/app/components/directive/table/cell_status_event_event_type/cell_status_event_event_type.html +++ /dev/null @@ -1,3 +0,0 @@ - -

{{entry.event_event_type}}

- diff --git a/app/components/directive/table/cell_status_event_event_type/cell_status_event_event_type.js b/app/components/directive/table/cell_status_event_event_type/cell_status_event_event_type.js deleted file mode 100644 index a8baad5..0000000 --- a/app/components/directive/table/cell_status_event_event_type/cell_status_event_event_type.js +++ /dev/null @@ -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']; - }]); diff --git a/app/components/directive/table/cell_status_event_host_name/cell_status_event_host_name.html b/app/components/directive/table/cell_status_event_host_name/cell_status_event_host_name.html deleted file mode 100644 index d7f7007..0000000 --- a/app/components/directive/table/cell_status_event_host_name/cell_status_event_host_name.html +++ /dev/null @@ -1,3 +0,0 @@ - -

{{entry.event_host_name}}

- diff --git a/app/components/directive/table/cell_status_event_host_name/cell_status_event_host_name.js b/app/components/directive/table/cell_status_event_host_name/cell_status_event_host_name.js deleted file mode 100644 index db1693c..0000000 --- a/app/components/directive/table/cell_status_event_host_name/cell_status_event_host_name.js +++ /dev/null @@ -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']; - }]); diff --git a/app/components/directive/table/cell_status_event_output/cell_status_event_output.html b/app/components/directive/table/cell_status_event_output/cell_status_event_output.html deleted file mode 100644 index d136026..0000000 --- a/app/components/directive/table/cell_status_event_output/cell_status_event_output.html +++ /dev/null @@ -1,3 +0,0 @@ - -

{{entry.event_output}}

- diff --git a/app/components/directive/table/cell_status_event_output/cell_status_event_output.js b/app/components/directive/table/cell_status_event_output/cell_status_event_output.js deleted file mode 100644 index 2982b8b..0000000 --- a/app/components/directive/table/cell_status_event_output/cell_status_event_output.js +++ /dev/null @@ -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']; - }]); diff --git a/app/components/directive/table/cell_status_event_service/cell_status_event_service.html b/app/components/directive/table/cell_status_event_service/cell_status_event_service.html deleted file mode 100644 index 3c02f4e..0000000 --- a/app/components/directive/table/cell_status_event_service/cell_status_event_service.html +++ /dev/null @@ -1,3 +0,0 @@ - -

{{entry.event_service_description}}

- diff --git a/app/components/directive/table/cell_status_event_service/cell_status_event_service.js b/app/components/directive/table/cell_status_event_service/cell_status_event_service.js deleted file mode 100644 index 26ed897..0000000 --- a/app/components/directive/table/cell_status_event_service/cell_status_event_service.js +++ /dev/null @@ -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']; - }]); diff --git a/app/components/directive/table/cell_status_event_time/cell_status_event_time.html b/app/components/directive/table/cell_status_event_time/cell_status_event_time.html deleted file mode 100644 index 9c4cc03..0000000 --- a/app/components/directive/table/cell_status_event_time/cell_status_event_time.html +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/app/components/directive/table/cell_status_event_time/cell_status_event_time.js b/app/components/directive/table/cell_status_event_time/cell_status_event_time.js deleted file mode 100644 index ecc4bec..0000000 --- a/app/components/directive/table/cell_status_event_time/cell_status_event_time.js +++ /dev/null @@ -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']; - }]); diff --git a/app/components/directive/table/cell_status_host/cell_status_host.html b/app/components/directive/table/cell_status_host/cell_status_host.html index 58fd5b4..b862afa 100644 --- a/app/components/directive/table/cell_status_host/cell_status_host.html +++ b/app/components/directive/table/cell_status_host/cell_status_host.html @@ -1,3 +1,3 @@ - - {{entry.host_host_name}} - + + {{entry.host_host_name}} + diff --git a/app/components/directive/table/cell_status_host/cell_status_host.js b/app/components/directive/table/cell_status_host/cell_status_host.js index ddf779c..cccf936 100644 --- a/app/components/directive/table/cell_status_host/cell_status_host.js +++ b/app/components/directive/table/cell_status_host/cell_status_host.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('bansho.table.cell_status_host', ['bansho.table']) +angular.module('bansho.table') .controller('CellStatusHostCtrl', ['$scope', function ($scope) { $scope.cell_name = 'host'; diff --git a/app/components/directive/table/cell_status_host_address/cell_status_host_address.html b/app/components/directive/table/cell_status_host_address/cell_status_host_address.html deleted file mode 100644 index ee275b3..0000000 --- a/app/components/directive/table/cell_status_host_address/cell_status_host_address.html +++ /dev/null @@ -1,3 +0,0 @@ - - {{entry.host_address}} - diff --git a/app/components/directive/table/cell_status_host_address/cell_status_host_address.js b/app/components/directive/table/cell_status_host_address/cell_status_host_address.js deleted file mode 100644 index 415e93e..0000000 --- a/app/components/directive/table/cell_status_host_address/cell_status_host_address.js +++ /dev/null @@ -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']; - }]); diff --git a/app/components/directive/table/cell_status_host_status/cell_status_host_status.html b/app/components/directive/table/cell_status_host_status/cell_status_host_status.html index 5aa753f..5ea7c50 100644 --- a/app/components/directive/table/cell_status_host_status/cell_status_host_status.html +++ b/app/components/directive/table/cell_status_host_status/cell_status_host_status.html @@ -1,3 +1 @@ - - {{entry.host_state}} - +{{entry.host_state}} diff --git a/app/components/directive/table/cell_status_host_status/cell_status_host_status.js b/app/components/directive/table/cell_status_host_status/cell_status_host_status.js index a52a057..8415178 100644 --- a/app/components/directive/table/cell_status_host_status/cell_status_host_status.js +++ b/app/components/directive/table/cell_status_host_status/cell_status_host_status.js @@ -1,10 +1,6 @@ 'use strict'; -angular.module('bansho.table.cell_status_host_status', ['bansho.table']) - - .controller('CellStatusHostStatusCtrl', ['$scope', function ($scope) { - angular.noop(); - }]) +angular.module('bansho.table') .run(['tableGlobalConfig', function (tableGlobalConfig) { tableGlobalConfig.cellToFieldsMap.status_host_status = ['state', 'last_check', 'parents']; diff --git a/app/components/directive/table/cell_status_last_check/cell_status_last_check.html b/app/components/directive/table/cell_status_last_check/cell_status_last_check.html index ec5b9a9..fce474f 100644 --- a/app/components/directive/table/cell_status_last_check/cell_status_last_check.html +++ b/app/components/directive/table/cell_status_last_check/cell_status_last_check.html @@ -1,3 +1 @@ - - - + diff --git a/app/components/directive/table/cell_status_last_check/cell_status_last_check.js b/app/components/directive/table/cell_status_last_check/cell_status_last_check.js index f2abe11..0717757 100644 --- a/app/components/directive/table/cell_status_last_check/cell_status_last_check.js +++ b/app/components/directive/table/cell_status_last_check/cell_status_last_check.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('bansho.table.cell_status_last_check', ['bansho.table']) +angular.module('bansho.table') .controller('CellStatusLastCheckCtrl', [function () { angular.noop(); diff --git a/app/components/directive/table/cell_status_service_check/cell_status_service_check.html b/app/components/directive/table/cell_status_service_check/cell_status_service_check.html index 9b2c225..fa3eff8 100644 --- a/app/components/directive/table/cell_status_service_check/cell_status_service_check.html +++ b/app/components/directive/table/cell_status_service_check/cell_status_service_check.html @@ -1,8 +1,8 @@ - +
- {{entry.service_service_description}} + {{entry.service_service_description}}
{{entry.service_plugin_output}}
- +
diff --git a/app/components/directive/table/cell_status_service_check/cell_status_service_check.js b/app/components/directive/table/cell_status_service_check/cell_status_service_check.js index c39598f..59d024b 100644 --- a/app/components/directive/table/cell_status_service_check/cell_status_service_check.js +++ b/app/components/directive/table/cell_status_service_check/cell_status_service_check.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('bansho.table.cell_status_service_check', ['bansho.table']) +angular.module('bansho.table') .controller('CellStatusServiceCheckCtrl', ['$scope', function ($scope) { if ($scope.entry.service_state === 'OK') { diff --git a/app/components/directive/table/pagingbar/pagingbar.js b/app/components/directive/table/pagingbar/pagingbar.js index 4a81714..11cc4a7 100644 --- a/app/components/directive/table/pagingbar/pagingbar.js +++ b/app/components/directive/table/pagingbar/pagingbar.js @@ -10,20 +10,20 @@ angular.module('bansho.table.pagingbar', ['bansho.datasource', 'bansho.surveil', templateUrl: 'components/directive/table/pagingbar/pagingbar.html', controller: ['$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.page = datasource.getPage($scope.tableId); - $scope.size = datasource.getPageSize($scope.tableId); + $scope.page = datasource.getPage($scope.datasourceId); + $scope.size = datasource.getPageSize($scope.datasourceId); $scope.previousPage = function () { - datasource.previousPage($scope.tableId); - $scope.page = datasource.getPage($scope.tableId); + datasource.previousPage($scope.datasourceId); + $scope.page = datasource.getPage($scope.datasourceId); }; $scope.nextPage = function () { - datasource.nextPage($scope.tableId); - $scope.page = datasource.getPage($scope.tableId); + datasource.nextPage($scope.datasourceId); + $scope.page = datasource.getPage($scope.datasourceId); }; $scope.setPageSize = function (pageSize) { @@ -32,7 +32,7 @@ angular.module('bansho.table.pagingbar', ['bansho.datasource', 'bansho.surveil', $scope.$watch('size', function (newValue) { if (newValue !== "") { - datasource.setPageSize($scope.tableId, newValue); + datasource.setPageSize($scope.datasourceId, newValue); } }); }] diff --git a/app/components/directive/table/table.html b/app/components/directive/table/table.html index d9ec901..cf1f3e4 100644 --- a/app/components/directive/table/table.html +++ b/app/components/directive/table/table.html @@ -1,70 +1,26 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - {{cellsText[i]}} - - - {{key}} - -
- - - {{cellsText[i]}} - - - {{key}} - -
- -
- - - - {{entry[key]}} - - - {{entry[key]}} - -
- + + + + + + + + + + + + + +
+ + + {{column.title}} +
+ + + +
+
diff --git a/app/components/directive/table/table.js b/app/components/directive/table/table.js index 47073f8..b5bbf1e 100644 --- a/app/components/directive/table/table.js +++ b/app/components/directive/table/table.js @@ -3,125 +3,112 @@ angular.module('bansho.table', ['bansho.datasource', 'bansho.actionbar', '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', 'ngMaterial' ]) - .directive('banshoTable', ['datasource', - 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) { + .directive('banshoTable', function () { return { - restrict: 'A', - compile: function () { - return function (scope, element, attrs) { - if (!attrs.cellName) { - throw new Error(' "cell-name" attribute must be defined'); + restrict: 'E', + scope: { + options: '=' + }, + 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 }) - .success(function (data) { - var td = $compile(data)(scope); - // HACK : replaceWith is a necessary hack because only accepts as a child - element.replaceWith(td); + // Handle components. + $scope.columns = []; + angular.forEach($scope.options.components, function (cell) { + $scope.columns.push({ + 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) { return function (input, scope) { @@ -130,13 +117,13 @@ angular.module('bansho.table', ['bansho.datasource', parent_found = false, class_name = ['', ''], i, - fieldToWrap = tableGlobalConfig.cellWrappableField[datasource.getConfig(scope.tableId).noRepeatCell]; + fieldToWrap = tableGlobalConfig.cellWrappableField[datasource.getConfig(scope.datasourceId).noRepeatCell]; if (fieldToWrap === undefined) { return input; } - if (datasource.getConfig(scope.tableId).isWrappable) { + if (datasource.getConfig(scope.datasourceId).isWrappable) { class_name = ['state--hasChild', 'state--isChild']; } @@ -169,8 +156,8 @@ angular.module('bansho.table', ['bansho.datasource', return function (items, scope) { var newItems = [], previous, - fieldToCompare = tableGlobalConfig.cellWrappableField[datasource.getConfig(scope.tableId).noRepeatCell], - newAttr = datasource.getConfig(scope.tableId).noRepeatCell + "_additionnalClass"; + fieldToCompare = tableGlobalConfig.cellWrappableField[datasource.getConfig(scope.datasourceId).noRepeatCell], + newAttr = datasource.getConfig(scope.datasourceId).noRepeatCell + "_additionnalClass"; angular.forEach(items, function (item) { diff --git a/app/index.html b/app/index.html index 8afe175..862add4 100644 --- a/app/index.html +++ b/app/index.html @@ -86,23 +86,13 @@ - - - + - - - - - - - - + -