diff options
Diffstat (limited to 'glances/outputs/static/js/directives.js')
-rw-r--r-- | glances/outputs/static/js/directives.js | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/glances/outputs/static/js/directives.js b/glances/outputs/static/js/directives.js new file mode 100644 index 00000000..d0f48d35 --- /dev/null +++ b/glances/outputs/static/js/directives.js @@ -0,0 +1,78 @@ +glancesApp.directive("sortableTh", function() { + return { + restrict: 'A', + scope: { + sorter: '=' + }, + link: function (scope, element, attrs) { + + scope.$watch(function() { + return scope.sorter.column; + }, function(newValue, oldValue) { + + if (angular.isArray(newValue)) { + if (newValue.indexOf(attrs.column) !== -1) { + element.addClass('sort'); + } else { + element.removeClass('sort'); + } + } else { + if (attrs.column === newValue) { + element.addClass('sort'); + } else { + element.removeClass('sort'); + } + } + + }); + + element.on('click', function() { + + scope.sorter.column = attrs.column; + + scope.$apply(); + }); + } + }; +}); + +glancesApp.directive("glMonitorList", function() { + return { + restrict: 'AE', + scope: { + processes: '=' + }, + templateUrl: 'plugins/monitor.html', + controller: function() { + + } + } +}) + +glancesApp.directive("glMonitorProcess", function() { + return { + restrict: 'AE', + require: "^glMonitorList", + templateUrl: 'components/monitor_process.html', + scope: { + process: '=' + }, + link: function(scope, element, attrs) { + + count = scope.process.count; + countMin = scope.process.countmin; + countMax = scope.process.countmax; + + if (count > 0) { + if ((countMin == null || count >= countMin) && (countMax == null || count <= countMax)) { + scope.descriptionClass = 'ok'; + } else { + scope.descriptionClass = 'careful'; + } + } else { + scope.descriptionClass = countMin == null ? 'ok' : 'critical'; + } + + } + } +}); |