Table DOM cleaning
This commit is contained in:
parent
956c349923
commit
b4390253ad
@ -37,7 +37,7 @@ angular.module('adagios.live')
|
|||||||
|
|
||||||
return $http.get('/rest/status/json/' + apiName + '/?fields=' + columns + filtersQuery)
|
return $http.get('/rest/status/json/' + apiName + '/?fields=' + columns + filtersQuery)
|
||||||
.error(function (data, status, headers, config) {
|
.error(function (data, status, headers, config) {
|
||||||
console.error('getServices : GET Request failed');
|
throw new Error('getServices : GET Request failed');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
@ -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>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<tbody class="" ng-repeat="entry in entries">
|
<tbody class="" ng-repeat="entry in entries">
|
||||||
<tr>
|
<tr>
|
||||||
<td><input type="checkbox"></td>
|
<td><input type="checkbox"></td>
|
||||||
<td adg-cell type="{{cell}}" ng-repeat="cell in cellsName"> </td >
|
<td adg-cell cell-name="{{cell}}" ng-repeat="cell in cellsName"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</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 {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
link: function (scope, element, attrs) {
|
compile: function () {
|
||||||
scope.generateTable = 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.text = attrs.cellsText.split(',');
|
||||||
tableConfig.cells.name = attrs.cellsName.split(',');
|
tableConfig.cells.name = attrs.cellsName.split(',');
|
||||||
tableConfig.apiName = attrs.apiName;
|
tableConfig.apiName = attrs.apiName;
|
||||||
@ -57,35 +60,37 @@ angular.module('adagios.table', ['adagios.live',
|
|||||||
tableConfig.filters = attrs.filters;
|
tableConfig.filters = attrs.filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'components/table/table.html';
|
var template = 'components/table/table.html';
|
||||||
}
|
|
||||||
console.error('<adg-table> "cells" and "api-name" attributes must be defined');
|
$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 ($http, $compile, $templateCache) {
|
.directive('adgCell', function ($http, $compile, $templateCache) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
restrict:'A',
|
restrict: 'A',
|
||||||
|
compile: function () {
|
||||||
compile: function() {
|
return function (scope, element, attrs) {
|
||||||
return function postCompile(scope, element, attrs) {
|
if (!attrs.cellName) {
|
||||||
var template = 'components/table/cell_' + attrs.type + '/cell_' + attrs.type + '.html'
|
throw new Error('<adg-cell> "cell-name" attribute must be defined');
|
||||||
// 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)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -139,7 +139,7 @@
|
|||||||
<adg-table cells-text="{{dashboardCellsText}}"
|
<adg-table cells-text="{{dashboardCellsText}}"
|
||||||
cells-name="{{dashboardCellsName}}"
|
cells-name="{{dashboardCellsName}}"
|
||||||
api-name="{{dashboardApiName}}"
|
api-name="{{dashboardApiName}}"
|
||||||
filters="{{dashboardFilters}}">
|
filters="{{dashboardFilters}}"></adg-table>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<adg-table cells-name="{{hostsCellsName}}"
|
<adg-table cells-name="{{hostsCellsName}}"
|
||||||
cells-text="{{hostsCellsText}}"
|
cells-text="{{hostsCellsText}}"
|
||||||
api-name="{{hostsApiName}}"
|
api-name="{{hostsApiName}}"
|
||||||
filters="{{hostsFilters}}">
|
filters="{{hostsFilters}}"></adg-table>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
</article>
|
</article>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<adg-table cells-name="{{servicesCellsName}}"
|
<adg-table cells-name="{{servicesCellsName}}"
|
||||||
cells-text="{{servicesCellsText}}"
|
cells-text="{{servicesCellsText}}"
|
||||||
api-name="{{servicesApiName}}"
|
api-name="{{servicesApiName}}"
|
||||||
filters="{{servicesFilters}}">
|
filters="{{servicesFilters}}"></adg-table>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
</article>
|
</article>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user