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_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/table.html b/app/components/table/table.html index c3fcae7..136fcbb 100644 --- a/app/components/table/table.html +++ b/app/components/table/table.html @@ -12,7 +12,7 @@ - + diff --git a/app/components/table/table.js b/app/components/table/table.js index 449adcc..32488cd 100644 --- a/app/components/table/table.js +++ b/app/components/table/table.js @@ -42,50 +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 ($http, $compile, $templateCache) { return { - restrict:'A', - - compile: function() { - return function postCompile(scope, element, attrs) { - var template = 'components/table/cell_' + attrs.type + '/cell_' + attrs.type + '.html' - // TODO: Manage a true caching - var toto = $templateCache.get(template) - $http.get(template) - .success(function(data) { - $templateCache.put(template, data); - var titi = $compile(data)(scope) - // We do this HACK because we are in a "table" element - // Which accept only td element :( - // Don't do this anywhere else - element.replaceWith(titi) - }); - } + restrict: 'A', + compile: function () { + return function (scope, element, attrs) { + if (!attrs.cellName) { + throw new Error(' "cell-name" attribute must be defined'); } + + 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); + }); + }; + } }; }); 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}}">