Test2 html replace

This commit is contained in:
Thibault Cohen 2015-02-18 19:51:21 -05:00 committed by Frédéric Vachon
parent aa43f1a7cb
commit 0e92ad2e5d
7 changed files with 9 additions and 25 deletions

View File

@ -9,7 +9,10 @@
"Last check"
],
"name": [
"host"
"host",
"service_check",
"duration",
"last_check"
]
},
"apiName": "services",

View File

@ -1 +1 @@
<div class="data-table__duration">{{entry.last_state_change | timeElapsed}}</div>
<td class="data-table__duration">{{entry.last_state_change | timeElapsed}}</td>

View File

@ -1,3 +1,3 @@
<td class="data-table__{{ cell }} {{entry.state}}">
<td class="data-table__{{ cell }} {{state}}" ng-controller="CellHostCtrl">
<a class="data-table__data" href="#">{{entry.host_name}}</a>
</td>

View File

@ -15,14 +15,4 @@ angular.module('adagios.table.cell_host', ['adagios.table'])
.run(['tableConfig', function (tableConfig) {
tableConfig.cellToFieldsMap.host = [ 'host_state', 'host_name' ];
tableConfig.cellToFunctionsMap.host = function(data) {
if (data.host_state === 0) {
data.state = 'state--ok';
} else if (data.host_state === 1) {
data.state = 'state--warning';
} else {
data.state = 'state--error';
}
return data
};
}]);

View File

@ -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>

View File

@ -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>

View File

@ -14,7 +14,6 @@ angular.module('adagios.table', ['adagios.live',
.value('tableConfig', { cells: { 'text': [], 'name': [] },
apiName: '',
filters: {},
cellToFunctionsMap: {},
cellToFieldsMap: {} })
.controller('TableCtrl', ['$scope', 'getServices', 'readConfig', 'tableConfig', function ($scope, getServices, readConfig, tableConfig) {
@ -39,11 +38,6 @@ angular.module('adagios.table', ['adagios.live',
getServices(requestFields, filters, tableConfig.apiName)
.success(function (data) {
angular.forEach(data, function (d) {
angular.forEach($scope.cellsName, function (key, value) {
d = tableConfig.cellToFunctionsMap[key](d)
})
})
$scope.entries = data;
});
}])
@ -77,7 +71,6 @@ angular.module('adagios.table', ['adagios.live',
return {
restrict:'A',
transclude: 'element',
compile: function() {
return function postCompile(scope, element, attrs) {
var template = 'components/table/cell_' + attrs.type + '/cell_' + attrs.type + '.html'
@ -86,11 +79,9 @@ angular.module('adagios.table', ['adagios.live',
.success(function(data) {
$templateCache.put(template, data);
var titi = $compile(data)(scope)
console.log(titi)
element.replaceWith(titi)
});
}
}
// template: '<span ></span>'
};
});