Parameterizable table

This commit is contained in:
Frédéric Vachon 2015-02-03 12:23:26 -05:00
parent 7b7bddcb12
commit de6f9b0689
2 changed files with 15 additions and 10 deletions

View File

@ -33,19 +33,28 @@ angular.module('adagios.table', ['ngRoute',
});
}])
.directive('adgTable', function () {
.directive('adgTable', ['tableConfig', function (tableConfig) {
return {
restrict: 'E',
templateUrl: 'table/table.html'
link: function (scope, element, attrs) {
scope.generateTable = function () {
if (!!attrs.cells) {
tableConfig.dashboardCells = attrs.cells.split(',');
return 'table/table.html';
}
console.log('<adg-table> "cells" attribute is undefined');
};
},
template: '<div ng-include="generateTable()"></div>'
};
})
}])
.directive('adgCell', function () {
return {
restrict: 'E',
link: function (scope, element, attrs) {
scope.getTemplateUrl = function () {
if (attrs.type) {
if (!!attrs.type) {
return 'table/cell_' + attrs.type + '/cell_' + attrs.type + '.html';
}
console.error('<adg-cell> "type" attribute is undefined');
@ -53,8 +62,4 @@ angular.module('adagios.table', ['ngRoute',
},
template: '<div ng-include="getTemplateUrl()"></div>'
};
})
.run(['readConfig', 'tableConfig', function (readConfig, tableConfig) {
tableConfig.dashboardCells = readConfig.dashboardCells;
}]);
});

View File

@ -19,6 +19,6 @@
</div>
<adg-table></adg-table>
<adg-table cells="host,service_check,duration,last_check"></adg-table>
</div>