prometheus/web/ui/static/js/alerts.js
James Turnbull 4486ef013b Make show annotations checkbox match query history checkbox (#3936)
After removing the checkbox in #3913 the only remaining element that
looked like it was the new Show Annotations checkbox on the Alerts page.
Which in turn didn't look like the Enable query history checkout on the
graph page. So:

1. This takes the Enable query history button as canonical.
2. Updates the show annotations button code to match it.
3. Simplifies the JS for the checkbox.
2018-03-09 14:39:28 +01:00

32 lines
1.1 KiB
JavaScript

function init() {
$(".alert_header").click(function() {
var expanderIcon = $(this).find("i.icon-chevron-down");
if (expanderIcon.length !== 0) {
expanderIcon.removeClass("icon-chevron-down").addClass("icon-chevron-up");
} else {
var collapserIcon = $(this).find("i.icon-chevron-up");
collapserIcon.removeClass("icon-chevron-up").addClass("icon-chevron-down");
}
$(this).next().toggle();
});
$("div.show-annotations").click(function() {
const targetEl = $('div.show-annotations');
const icon = $(targetEl).children('i');
if (icon.hasClass('glyphicon-unchecked')) {
$(".alert_annotations").show();
$(".alert_annotations_header").show();
$(targetEl).children('i').removeClass('glyphicon-unchecked').addClass('glyphicon-check');
targetEl.addClass('is-checked');
} else if (icon.hasClass('glyphicon-check')) {
$(".alert_annotations").hide();
$(".alert_annotations_header").hide();
$(targetEl).children('i').removeClass('glyphicon-check').addClass('glyphicon-unchecked');
targetEl.removeClass('is-checked');
}
});
}
$(init);