From 494de8228c70ce29e421826d17bff95bec551242 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Thu, 15 Oct 2015 16:24:27 +0200 Subject: [PATCH] Add alert view to UI --- ui/app/js/app.js | 67 ++++++++++++++++++++++++++++--------- ui/app/partials/alerts.html | 38 +++++++++++++++++++++ 2 files changed, 90 insertions(+), 15 deletions(-) create mode 100644 ui/app/partials/alerts.html diff --git a/ui/app/js/app.js b/ui/app/js/app.js index e0e49940..c6141b52 100644 --- a/ui/app/js/app.js +++ b/ui/app/js/app.js @@ -14,6 +14,14 @@ angular.module('am.services').factory('Silence', } ); +angular.module('am.services').factory('Alert', + function($resource){ + return $resource('', {}, { + 'query': {method: 'GET', url: '/api/v1/alerts'} + }); + } +); + angular.module('am.controllers', []); angular.module('am.controllers').controller('NavCtrl', @@ -30,6 +38,26 @@ angular.module('am.controllers').controller('NavCtrl', } ); +angular.module('am.controllers').controller('AlertsCtrl', + function($scope, Alert) { + $scope.alerts = []; + $scope.order = "startsAt"; + + $scope.refresh = function() { + Alert.query({}, + function(data) { + $scope.alerts = data.data || []; + }, + function(data) { + + } + ); + } + + $scope.refresh(); + } +); + angular.module('am.controllers').controller('SilencesCtrl', function($scope, Silence) { $scope.silences = []; @@ -57,21 +85,6 @@ angular.module('am.controllers').controller('SilencesCtrl', angular.module('am.controllers').controller('SilenceCreateCtrl', function($scope, Silence) { - var now = new Date(), - end = new Date(); - - now.setMilliseconds(0); - end.setMilliseconds(0); - now.setSeconds(0); - end.setSeconds(0); - - end.setHours(end.getHours() + 2) - - $scope.silence = { - startsAt: now, - endsAt: end, - matchers: [{}] - } $scope.create = function() { Silence.create($scope.silence, @@ -92,7 +105,27 @@ angular.module('am.controllers').controller('SilenceCreateCtrl', $scope.delMatcher = function(i) { $scope.silence.matchers.splice(i, 1); } + $scope.reset = function() { + var now = new Date(), + end = new Date(); + now.setMilliseconds(0); + end.setMilliseconds(0); + now.setSeconds(0); + end.setSeconds(0); + + end.setHours(end.getHours() + 2) + + $scope.silence = { + startsAt: now, + endsAt: end, + matchers: [{}], + comment: "", + createdBy: "" + } + } + + $scope.reset(); } ); @@ -106,6 +139,10 @@ angular.module('am', [ angular.module('am').config( function($routeProvider) { $routeProvider. + when('/alerts', { + templateUrl: '/app/partials/alerts.html', + controller: 'AlertsCtrl' + }). when('/silences', { templateUrl: '/app/partials/silences.html', controller: 'SilencesCtrl' diff --git a/ui/app/partials/alerts.html b/ui/app/partials/alerts.html new file mode 100644 index 00000000..f8c55d4e --- /dev/null +++ b/ui/app/partials/alerts.html @@ -0,0 +1,38 @@ +
+ + + + + + + + +
+ +
No alerts found
+ +
+ +
+
+
{{ a.startsAt | date:'medium' }} – {{ a.endsAt | date:'medium' }}
+ + {{ name }} = '{{ value }}' + +
+
+ + + + + + + +
{{ name }}{{ val }}
+
+
+ +
\ No newline at end of file