diff --git a/app/components/live/get_services.js b/app/components/live/get_services.js index 3375a8d..8d4da49 100644 --- a/app/components/live/get_services.js +++ b/app/components/live/get_services.js @@ -37,7 +37,7 @@ angular.module('adagios.live') return $http.get('/rest/status/json/' + apiName + '/?fields=' + columns + filtersQuery) .error(function (data, status, headers, config) { - console.error('getServices : GET Request failed'); + throw new Error('getServices : GET Request failed'); }); }; }]); diff --git a/app/components/table/cell_duration/cell_duration.html b/app/components/table/cell_duration/cell_duration.html index ad877fa..9e0a6b4 100644 --- a/app/components/table/cell_duration/cell_duration.html +++ b/app/components/table/cell_duration/cell_duration.html @@ -1 +1 @@ -
{{entry.last_state_change | timeElapsed}}
+{{entry.last_state_change | timeElapsed}} diff --git a/app/components/table/cell_host/cell_host.html b/app/components/table/cell_host/cell_host.html index a63408f..9ffffe7 100644 --- a/app/components/table/cell_host/cell_host.html +++ b/app/components/table/cell_host/cell_host.html @@ -1,3 +1,3 @@ - + {{entry.host_name}} - + diff --git a/app/components/table/cell_host/cell_host.js b/app/components/table/cell_host/cell_host.js index 0497256..5ec23c2 100644 --- a/app/components/table/cell_host/cell_host.js +++ b/app/components/table/cell_host/cell_host.js @@ -14,4 +14,5 @@ angular.module('adagios.table.cell_host', ['adagios.table']) .run(['tableConfig', function (tableConfig) { tableConfig.cellToFieldsMap.host = [ 'host_state', 'host_name' ]; + }]); diff --git a/app/components/table/cell_host_address/cell_host_address.html b/app/components/table/cell_host_address/cell_host_address.html index 6c161f0..6e4bf83 100644 --- a/app/components/table/cell_host_address/cell_host_address.html +++ b/app/components/table/cell_host_address/cell_host_address.html @@ -1 +1 @@ -
{{entry.address}}
+{{entry.address}} diff --git a/app/components/table/cell_host_status/cell_host_status.html b/app/components/table/cell_host_status/cell_host_status.html index 8da8ea2..a7f2ed4 100644 --- a/app/components/table/cell_host_status/cell_host_status.html +++ b/app/components/table/cell_host_status/cell_host_status.html @@ -1 +1 @@ -
{{entry.host_status}}
+{{entry.host_status}} diff --git a/app/components/table/cell_hosts_host/cell_hosts_host.html b/app/components/table/cell_hosts_host/cell_hosts_host.html index c7f91ba..5820cae 100644 --- a/app/components/table/cell_hosts_host/cell_hosts_host.html +++ b/app/components/table/cell_hosts_host/cell_hosts_host.html @@ -1 +1 @@ -
{{entry.name}}
+{{entry.name}} diff --git a/app/components/table/cell_last_check/cell_last_check.html b/app/components/table/cell_last_check/cell_last_check.html index 55add3f..5436017 100644 --- a/app/components/table/cell_last_check/cell_last_check.html +++ b/app/components/table/cell_last_check/cell_last_check.html @@ -1 +1 @@ -
{{entry.last_check * 1000 | date: medium}}
+{{entry.last_check * 1000 | date: medium}} diff --git a/app/components/table/cell_service_check/cell_service_check.html b/app/components/table/cell_service_check/cell_service_check.html index a5f501c..793dc91 100644 --- a/app/components/table/cell_service_check/cell_service_check.html +++ b/app/components/table/cell_service_check/cell_service_check.html @@ -1,6 +1,6 @@ -
+
{{entry.description}}
{{entry.plugin_output}}
-
+ diff --git a/app/components/table/table.html b/app/components/table/table.html index 493421b..136fcbb 100644 --- a/app/components/table/table.html +++ b/app/components/table/table.html @@ -12,8 +12,7 @@ - - + diff --git a/app/components/table/table.js b/app/components/table/table.js index 440c14b..32488cd 100644 --- a/app/components/table/table.js +++ b/app/components/table/table.js @@ -42,41 +42,55 @@ angular.module('adagios.table', ['adagios.live', }); }]) - .directive('adgTable', ['tableConfig', function (tableConfig) { + .directive('adgTable', ['$http', '$compile', 'tableConfig', function ($http, $compile, tableConfig) { return { restrict: 'E', - link: function (scope, element, attrs) { - scope.generateTable = function () { + compile: function () { + return function (scope, element, attrs) { - if (!!attrs.cellsText && !!attrs.cellsName && !!attrs.apiName) { - tableConfig.cells.text = attrs.cellsText.split(','); - tableConfig.cells.name = attrs.cellsName.split(','); - tableConfig.apiName = attrs.apiName; - - if (!!attrs.filters) { - tableConfig.filters = attrs.filters; - } - - return 'components/table/table.html'; + if (!attrs.cellsText || !attrs.cellsName || !attrs.apiName) { + throw new Error(' "cells-text", "cells-name" and "api-name" attributes must be defined'); } - console.error(' "cells" and "api-name" attributes must be defined'); + + tableConfig.cells.text = attrs.cellsText.split(','); + tableConfig.cells.name = attrs.cellsName.split(','); + tableConfig.apiName = attrs.apiName; + + if (!!attrs.filters) { + tableConfig.filters = attrs.filters; + } + + var template = 'components/table/table.html'; + + $http.get(template, { cache: true }) + .success(function (data) { + var elem = $compile(data)(scope); + element.append(elem); + }); }; - }, - template: '
' + } }; }]) - .directive('adgCell', function () { + .directive('adgCell', function ($http, $compile, $templateCache) { + return { restrict: 'A', - link: function (scope, element, attrs) { - scope.getTemplateUrl = function () { - if (!!attrs.type) { - return 'components/table/cell_' + attrs.type + '/cell_' + attrs.type + '.html'; + compile: function () { + return function (scope, element, attrs) { + if (!attrs.cellName) { + throw new Error(' "cell-name" attribute must be defined'); } - console.error(' "type" attribute is undefined'); + + var template = 'components/table/cell_' + attrs.cellName + '/cell_' + attrs.cellName + '.html'; + + $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); + }); }; - }, - template: '
' + } }; }); diff --git a/app/dashboard/dashboard.html b/app/dashboard/dashboard.html index 01f7165..2727493 100644 --- a/app/dashboard/dashboard.html +++ b/app/dashboard/dashboard.html @@ -139,7 +139,7 @@ + filters="{{dashboardFilters}}"> diff --git a/app/hosts/hosts.html b/app/hosts/hosts.html index 9ca9bf3..5e38764 100644 --- a/app/hosts/hosts.html +++ b/app/hosts/hosts.html @@ -13,7 +13,7 @@ + filters="{{hostsFilters}}"> diff --git a/app/services/services.html b/app/services/services.html index c2061f5..6e26f0e 100644 --- a/app/services/services.html +++ b/app/services/services.html @@ -13,7 +13,7 @@ + filters="{{servicesFilters}}">