Added dynamically generated table

This commit is contained in:
Frédéric Vachon 2015-01-22 17:11:28 -05:00
parent c913bd7547
commit ef0deb12f9
14 changed files with 34 additions and 104 deletions

View File

@ -69,4 +69,4 @@
<script src="bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js"></script>
<script src="assets/js/scripts.js"></script>
</body>
</html>
</html>

View File

@ -1,3 +1 @@
<div ng-app="adagios.table.cell_duration" ng-controller="CellDurationCtrl">
Cell duration
</div>
<div>{{entry.duration}}</div>

View File

@ -1,22 +0,0 @@
'use strict';
angular.module('adagios.table.cell_duration', ['ngSanitize'])
.controller('CellDurationCtrl', ['$scope', '$sce', function ($scope, $sce) {
$scope.balise = 'salut';
}])
.directive('cellDuration', function () {
return {
restrict: 'E',
replace: true,
scope: false,
templateUrl: 'table/cell_duration/cell_duration.html',
link: function(scope, element, attrs) {
var factory = angular.element('<div></div>');
factory.html('<p>{{balise}}</p>');
console.log(scope);
$compile(factory)(scope);
}
};
});

View File

@ -1,3 +1 @@
<div ng-app="adagios.table.cell_host" ng-controller="cellHostCtrl">
Cell host
</div>
<div>{{entry.host_name}}</div>

View File

@ -1,15 +0,0 @@
'use strict';
angular.module('adagios.table.cell_host', [])
.controller('CellHostCtrl', ['$scope', function ($scope) {
return;
}])
.directive('cellHost', function () {
return {
restrict: 'E',
replace: true,
templateUrl: "table/cell_host/cell_host.html"
};
});

View File

@ -1,3 +1 @@
<div ng-app="adagios.table.cell_last_check" ng-controller="cellLastCheckCtrl">
Cell last check
</div>
<div>{{entry.last_check}}</div>

View File

@ -1,15 +0,0 @@
'use strict';
angular.module('adagios.table.cell_last_check', [])
.controller('CellLastCheckCtrl', ['$scope', function ($scope) {
return;
}])
.directive('cellLastCheck', function () {
return {
restrict: 'E',
replace: true,
templateUrl: "table/cell_last_check/cell_last_check.html"
};
});

View File

@ -1,3 +1 @@
<div ng-app="adagios.table.cell_service_check" ng-controller="cellServiceCheckCtrl">
Cell service check
</div>
<div>{{entry.service_check}</div>

View File

@ -1,14 +0,0 @@
'use strict';
angular.module('adagios.table.cell_service_check', [])
.controller('CellServiceCheck', ['$scope', function ($scope) {
return;
}])
.directive('cellServiceCheck', function () {
return {
restrict: 'E',
templateUrl: "table/cell_service_check/cell_service_check.html"
};
});

View File

@ -1,17 +1,17 @@
<div ng-app="adagios.table" ng-controller="TableCtrl" id="table">
<table class="table table-bordered table-hover">
<table class="table table-bordered">
<thead>
<tr>
<th></th>
<th ng-repeat="thead in columns">
<th ng-repeat="thead in cells">
{{thead}}
</th>
</tr>
</thead>
<tr ng-repeat="entry in entries">
<td><input type="checkbox"></td>
<td ng-repeat="cell in columns">
{{cell}}
<td ng-repeat="cell in cells">
<custom-cell type="{{cell}}"></custom-cell>
</td>
</tr>
</table>

View File

@ -1,30 +1,27 @@
'use strict';
angular.module('adagios.table', ['ngRoute',
'ngSanitize',
'adagios.live',
'adagios.table.cell_duration',
'adagios.table.cell_host',
'adagios.table.cell_last_check',
'adagios.table.cell_service_check'
'adagios.live'
])
.controller('TableCtrl', ['$scope', '$sce', 'GetServices', function ($scope, $sce, GetServices) {
$scope.cellTagMapping = {
duration: $sce.trustAsHtml('<cell-duration></cell-duration>'),
host_name: $sce.trustAsHtml('<cell-host></cell-host>'),
last_check: $sce.trustAsHtml('<cell-last-check></cell-last-check>'),
service_check: $sce.trustAsHtml('<service-check></service-check>')
};
$scope.columns = ['host_name', 'last_check'];
.controller('TableCtrl', ['$scope', 'GetServices', function ($scope, GetServices) {
console.log(new GetServices($scope.columns)
$scope.cellPathMapping = {
duration: 'duration',
host_name: 'host',
last_check: 'last_check',
service_check: 'service_check'
};
$scope.cells = ['host_name', 'duration', 'last_check'];
console.log(new GetServices($scope.cells)
.success(function (data) {
$scope.entries = data;
}));
}])
.directive('servicesTable', function () {
.directive('customTable', function () {
return {
restrict: 'E',
replace: true,
@ -32,10 +29,18 @@ angular.module('adagios.table', ['ngRoute',
};
})
.directive('servicesEntry', function () {
.directive('customCell', function () {
return {
restrict: 'E',
replace: true,
templateUrl: 'table/table.html'
link: function (scope, element, attrs) {
var path = scope.cellPathMapping[attrs.type];
scope.getTemplateUrl = function () {
if (path) {
return 'table/cell_' + path + '/cell_' + path + '.html';
}
};
},
template: '<div ng-include="getTemplateUrl()"></div>'
};
});

View File

@ -19,6 +19,6 @@
</div>
<services-table></services-table>
<custom-table></custom-table>
</div>

View File

@ -10,7 +10,6 @@
"angular-route": "1.2.x",
"angular-loader": "1.2.x",
"angular-mocks": "~1.2.x",
"angular-sanitize": "~1.2.x",
"html5-boilerplate": "~4.3.0",
"bootstrap-sass-official": "3.3.1",
"fontawesome": "4.2.0",