mirror of
https://github.com/prometheus/alertmanager
synced 2025-02-16 10:37:09 +00:00
Add silence-form directive, enable silence button for alerts
This commit is contained in:
parent
a765ef9534
commit
f4a31855cc
@ -31,6 +31,18 @@ angular.module('am.directives').directive('alert',
|
||||
}
|
||||
);
|
||||
|
||||
angular.module('am.directives').directive('silenceForm',
|
||||
function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
silence: '='
|
||||
},
|
||||
templateUrl: '/app/partials/silence-form.html'
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
angular.module('am.services', ['ngResource']);
|
||||
|
||||
angular.module('am.services').factory('RecursionHelper',
|
||||
@ -165,7 +177,25 @@ angular.module('am.controllers').controller('NavCtrl',
|
||||
);
|
||||
|
||||
angular.module('am.controllers').controller('AlertCtrl',
|
||||
function() {}
|
||||
function($scope) {
|
||||
$scope.showSilenceForm = false;
|
||||
|
||||
$scope.toggleSilenceForm = function() {
|
||||
$scope.showSilenceForm = !$scope.showSilenceForm
|
||||
}
|
||||
|
||||
$scope.silence = {
|
||||
matchers: []
|
||||
}
|
||||
angular.forEach($scope.a.labels, function(value, key) {
|
||||
this.push({
|
||||
name: key,
|
||||
value: value,
|
||||
isRegex: false,
|
||||
});
|
||||
}, $scope.silence.matchers);
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
angular.module('am.controllers').controller('AlertsCtrl',
|
||||
@ -190,27 +220,6 @@ angular.module('am.controllers').controller('AlertsCtrl',
|
||||
}
|
||||
);
|
||||
|
||||
// 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 || [];
|
||||
// console.log($scope.alerts)
|
||||
// },
|
||||
// function(data) {
|
||||
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
|
||||
// $scope.refresh();
|
||||
// }
|
||||
// );
|
||||
|
||||
angular.module('am.controllers').controller('SilencesCtrl',
|
||||
function($scope, Silence) {
|
||||
$scope.silences = [];
|
||||
@ -261,8 +270,10 @@ angular.module('am.controllers').controller('SilenceCreateCtrl',
|
||||
$scope.silence.matchers.splice(i, 1);
|
||||
}
|
||||
$scope.reset = function() {
|
||||
var now = new Date(),
|
||||
end = new Date();
|
||||
var now = new Date();
|
||||
var end = new Date();
|
||||
|
||||
$scope.silence = $scope.silence || {};
|
||||
|
||||
now.setMilliseconds(0);
|
||||
end.setMilliseconds(0);
|
||||
@ -271,12 +282,11 @@ angular.module('am.controllers').controller('SilenceCreateCtrl',
|
||||
|
||||
end.setHours(end.getHours() + 2)
|
||||
|
||||
$scope.silence = {
|
||||
startsAt: now,
|
||||
endsAt: end,
|
||||
matchers: [{}],
|
||||
comment: "",
|
||||
createdBy: ""
|
||||
$scope.silence.startsAt = now;
|
||||
$scope.silence.endsAt = end;
|
||||
|
||||
if (!$scope.silence.matchers) {
|
||||
$scope.silence.matchers = [{}];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,8 @@
|
||||
</div>
|
||||
|
||||
<div class="right">
|
||||
<button type="secondary" ng-click="silence(a)" small>Silence</button>
|
||||
<button type="secondary" ng-click="toggleSilenceForm()" small>Silence</button>
|
||||
<silence-form ng-show="showSilenceForm" silence="silence"></silence-form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,55 +1,4 @@
|
||||
<div ng-controller="SilenceCreateCtrl">
|
||||
<form novalidate class="forms">
|
||||
<fieldset id="silence-create">
|
||||
<legend>Create <span class="desc">Define a new silence.</span></legend>
|
||||
|
||||
<row>
|
||||
<column cols="2">
|
||||
<label>Start</label>
|
||||
<input ng-model="silence.startsAt" type="datetime-local">
|
||||
</column>
|
||||
<column cols="3">
|
||||
<label>End</label>
|
||||
<input ng-model="silence.endsAt" type="datetime-local">
|
||||
</column>
|
||||
<column cols="2">
|
||||
<label>Creator</label>
|
||||
<input ng-model="silence.createdBy" type="email">
|
||||
</column>
|
||||
<column cols="3">
|
||||
<label>Comment</label>
|
||||
<input ng-model="silence.comment" type="text">
|
||||
</column>
|
||||
</row>
|
||||
|
||||
<label>Matchers <span class="desc">Alerts affected by this silence.</span></label>
|
||||
<row class="silence-matchers" ng-repeat="m in silence.matchers">
|
||||
<column cols="2">
|
||||
<input class="input-small" type="text" placeholder="name" ng-model="m.name">
|
||||
</column>
|
||||
<column cols="2">
|
||||
<input class="input-small" type="text" placeholder="value" ng-model="m.value">
|
||||
</column>
|
||||
<column>
|
||||
<label class="checkbox is-regex"><input type="checkbox" ng-model="m.isRegex"> /re/</label>
|
||||
</column>
|
||||
|
||||
<column cols="1">
|
||||
<button type="secondary" ng-hide="$first" ng-click="delMatcher($index)" small>-</button>
|
||||
<button type="secondary" ng-show="$last" ng-click="newMatcher()" small>+</button>
|
||||
</column>
|
||||
</row>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<div ng-show="error != null"><span class="error">{{ error }}</span></div>
|
||||
|
||||
<div class="btn-group">
|
||||
<button type="primary" ng-disabled="silence.matchers.length == 0" ng-click="create()" small>Create</button>
|
||||
<button type="seconday" ng-click="reset()" small>Reset</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<silence-form sil="silence"></silence-form>
|
||||
|
||||
<hr>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user