Merge pull request #26 from titilambert/tcohen2
Clean table HTML generated structure
This commit is contained in:
commit
a838a6779a
@ -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');
|
||||
});
|
||||
};
|
||||
}]);
|
||||
|
@ -1 +1 @@
|
||||
<div class="data-table__duration">{{entry.last_state_change | timeElapsed}}</div>
|
||||
<td class="data-table__duration">{{entry.last_state_change | timeElapsed}}</td>
|
||||
|
@ -1,3 +1,3 @@
|
||||
<span class="data-table__host {{state}}" ng-controller="CellHostCtrl">
|
||||
<td class="data-table__{{ cell }} {{state}}" ng-controller="CellHostCtrl">
|
||||
<a class="data-table__data" href="#">{{entry.host_name}}</a>
|
||||
</span>
|
||||
</td>
|
||||
|
@ -14,4 +14,5 @@ angular.module('adagios.table.cell_host', ['adagios.table'])
|
||||
|
||||
.run(['tableConfig', function (tableConfig) {
|
||||
tableConfig.cellToFieldsMap.host = [ 'host_state', 'host_name' ];
|
||||
|
||||
}]);
|
||||
|
@ -1 +1 @@
|
||||
<div ng-controller="CellHostAddressCtrl">{{entry.address}}</div>
|
||||
<td ng-controller="CellHostAddressCtrl">{{entry.address}}</td>
|
||||
|
@ -1 +1 @@
|
||||
<div class="{{alert_level}}" ng-controller="CellHostStatusCtrl">{{entry.host_status}}</div>
|
||||
<td class="{{alert_level}}" ng-controller="CellHostStatusCtrl">{{entry.host_status}}</td>
|
||||
|
@ -1 +1 @@
|
||||
<div ng-controller="CellHostsHostCtrl">{{entry.name}}</div>
|
||||
<td ng-controller="CellHostsHostCtrl">{{entry.name}}</td>
|
||||
|
@ -1 +1 @@
|
||||
<div class="data-table__lastcheck">{{entry.last_check * 1000 | date: medium}}</div>
|
||||
<td class="data-table__lastcheck">{{entry.last_check * 1000 | date: medium}}</td>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div class="data-table__service {{state}}" ng-controller="CellServiceCheckCtrl">
|
||||
<td class="data-table__service {{state}}" ng-controller="CellServiceCheckCtrl">
|
||||
<dl class="data-table__data">
|
||||
<dt class="data-table__service__name">{{entry.description}}</dt>
|
||||
<dd class="data-table__service__summary">{{entry.plugin_output}}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -12,8 +12,7 @@
|
||||
<tbody class="" ng-repeat="entry in entries">
|
||||
<tr>
|
||||
<td><input type="checkbox"></td>
|
||||
<td class="data-table__{{ cell }}" adg-cell type="{{cell}}" ng-repeat="cell in cellsName">
|
||||
</td>
|
||||
<td adg-cell cell-name="{{cell}}" ng-repeat="cell in cellsName"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
|
@ -42,13 +42,16 @@ 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) {
|
||||
throw new Error('<adg-table> "cells-text", "cells-name" and "api-name" attributes must be defined');
|
||||
}
|
||||
|
||||
if (!!attrs.cellsText && !!attrs.cellsName && !!attrs.apiName) {
|
||||
tableConfig.cells.text = attrs.cellsText.split(',');
|
||||
tableConfig.cells.name = attrs.cellsName.split(',');
|
||||
tableConfig.apiName = attrs.apiName;
|
||||
@ -57,26 +60,37 @@ angular.module('adagios.table', ['adagios.live',
|
||||
tableConfig.filters = attrs.filters;
|
||||
}
|
||||
|
||||
return 'components/table/table.html';
|
||||
}
|
||||
console.error('<adg-table> "cells" and "api-name" attributes must be defined');
|
||||
var template = 'components/table/table.html';
|
||||
|
||||
$http.get(template, { cache: true })
|
||||
.success(function (data) {
|
||||
var elem = $compile(data)(scope);
|
||||
element.append(elem);
|
||||
});
|
||||
};
|
||||
},
|
||||
template: '<div ng-include="generateTable()"></div>'
|
||||
}
|
||||
};
|
||||
}])
|
||||
|
||||
.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('<adg-cell> "cell-name" attribute must be defined');
|
||||
}
|
||||
console.error('<adg-cell> "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 <tr> only accepts <td> as a child
|
||||
element.replaceWith(td);
|
||||
});
|
||||
};
|
||||
},
|
||||
template: '<div ng-include="getTemplateUrl()"></div>'
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -139,7 +139,7 @@
|
||||
<adg-table cells-text="{{dashboardCellsText}}"
|
||||
cells-name="{{dashboardCellsName}}"
|
||||
api-name="{{dashboardApiName}}"
|
||||
filters="{{dashboardFilters}}">
|
||||
filters="{{dashboardFilters}}"></adg-table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -13,7 +13,7 @@
|
||||
<adg-table cells-name="{{hostsCellsName}}"
|
||||
cells-text="{{hostsCellsText}}"
|
||||
api-name="{{hostsApiName}}"
|
||||
filters="{{hostsFilters}}">
|
||||
filters="{{hostsFilters}}"></adg-table>
|
||||
|
||||
</section>
|
||||
</article>
|
||||
|
@ -13,7 +13,7 @@
|
||||
<adg-table cells-name="{{servicesCellsName}}"
|
||||
cells-text="{{servicesCellsText}}"
|
||||
api-name="{{servicesApiName}}"
|
||||
filters="{{servicesFilters}}">
|
||||
filters="{{servicesFilters}}"></adg-table>
|
||||
|
||||
</section>
|
||||
</article>
|
||||
|
Loading…
Reference in New Issue
Block a user