From ef0deb12f91686cbc2886a569104110d8a938d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Thu, 22 Jan 2015 17:11:28 -0500 Subject: [PATCH] Added dynamically generated table --- app/index.html | 2 +- app/table/cell_duration/cell_duration.css | 0 app/table/cell_duration/cell_duration.html | 4 +- app/table/cell_duration/cell_duration.js | 22 ---------- app/table/cell_host/cell_host.html | 4 +- app/table/cell_host/cell_host.js | 15 ------- .../cell_last_check/cell_last_check.html | 4 +- app/table/cell_last_check/cell_last_check.js | 15 ------- .../cell_service_check.html | 4 +- .../cell_service_check/cell_service_check.js | 14 ------ app/table/table.html | 8 ++-- app/table/table.js | 43 +++++++++++-------- app/tactical/tactical.html | 2 +- bower.json | 1 - 14 files changed, 34 insertions(+), 104 deletions(-) create mode 100644 app/table/cell_duration/cell_duration.css delete mode 100644 app/table/cell_duration/cell_duration.js delete mode 100644 app/table/cell_host/cell_host.js delete mode 100644 app/table/cell_last_check/cell_last_check.js delete mode 100644 app/table/cell_service_check/cell_service_check.js diff --git a/app/index.html b/app/index.html index ddb7d51..d1e9a95 100644 --- a/app/index.html +++ b/app/index.html @@ -69,4 +69,4 @@ - + \ No newline at end of file diff --git a/app/table/cell_duration/cell_duration.css b/app/table/cell_duration/cell_duration.css new file mode 100644 index 0000000..e69de29 diff --git a/app/table/cell_duration/cell_duration.html b/app/table/cell_duration/cell_duration.html index 123717d..f77abdf 100644 --- a/app/table/cell_duration/cell_duration.html +++ b/app/table/cell_duration/cell_duration.html @@ -1,3 +1 @@ -
- Cell duration -
+
{{entry.duration}}
diff --git a/app/table/cell_duration/cell_duration.js b/app/table/cell_duration/cell_duration.js deleted file mode 100644 index 126e5b6..0000000 --- a/app/table/cell_duration/cell_duration.js +++ /dev/null @@ -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('
'); - factory.html('

{{balise}}

'); - console.log(scope); - $compile(factory)(scope); - } - }; - }); diff --git a/app/table/cell_host/cell_host.html b/app/table/cell_host/cell_host.html index 6e66e62..f859443 100644 --- a/app/table/cell_host/cell_host.html +++ b/app/table/cell_host/cell_host.html @@ -1,3 +1 @@ -
- Cell host -
+
{{entry.host_name}}
diff --git a/app/table/cell_host/cell_host.js b/app/table/cell_host/cell_host.js deleted file mode 100644 index 4a766ea..0000000 --- a/app/table/cell_host/cell_host.js +++ /dev/null @@ -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" - }; - }); diff --git a/app/table/cell_last_check/cell_last_check.html b/app/table/cell_last_check/cell_last_check.html index 11bfcf2..bae530c 100644 --- a/app/table/cell_last_check/cell_last_check.html +++ b/app/table/cell_last_check/cell_last_check.html @@ -1,3 +1 @@ -
- Cell last check -
+
{{entry.last_check}}
diff --git a/app/table/cell_last_check/cell_last_check.js b/app/table/cell_last_check/cell_last_check.js deleted file mode 100644 index a464186..0000000 --- a/app/table/cell_last_check/cell_last_check.js +++ /dev/null @@ -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" - }; - }); diff --git a/app/table/cell_service_check/cell_service_check.html b/app/table/cell_service_check/cell_service_check.html index 752b0c7..a3fa3e2 100644 --- a/app/table/cell_service_check/cell_service_check.html +++ b/app/table/cell_service_check/cell_service_check.html @@ -1,3 +1 @@ -
- Cell service check -
+
{{entry.service_check}
diff --git a/app/table/cell_service_check/cell_service_check.js b/app/table/cell_service_check/cell_service_check.js deleted file mode 100644 index b5f846c..0000000 --- a/app/table/cell_service_check/cell_service_check.js +++ /dev/null @@ -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" - }; - }); diff --git a/app/table/table.html b/app/table/table.html index d138464..816e075 100644 --- a/app/table/table.html +++ b/app/table/table.html @@ -1,17 +1,17 @@
- +
- -
+ {{thead}}
- {{cell}} + +
diff --git a/app/table/table.js b/app/table/table.js index 284ad0e..53e10af 100644 --- a/app/table/table.js +++ b/app/table/table.js @@ -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(''), - host_name: $sce.trustAsHtml(''), - last_check: $sce.trustAsHtml(''), - service_check: $sce.trustAsHtml('') - }; - $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: '
' }; }); diff --git a/app/tactical/tactical.html b/app/tactical/tactical.html index ac48822..4411261 100644 --- a/app/tactical/tactical.html +++ b/app/tactical/tactical.html @@ -19,6 +19,6 @@
- + diff --git a/bower.json b/bower.json index ad84921..c0ca983 100644 --- a/bower.json +++ b/bower.json @@ -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",