mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-16 02:24:06 -08:00
f0bb8129c3
* fix service-discovery view Signed-off-by: Harkishen-Singh <[email protected]> * updated localStorage logic Signed-off-by: Harkishen-Singh <[email protected]> * sign off Signed-off-by: Harkishen-Singh <[email protected]> * committed vfs unicodes Signed-off-by: Harkishen-Singh <[email protected]>
69 lines
2.2 KiB
JavaScript
69 lines
2.2 KiB
JavaScript
function toggleJobTable(button, shouldExpand){
|
|
if (button.length === 0) { return; }
|
|
|
|
if (shouldExpand) {
|
|
button.removeClass("collapsed-table").addClass("expanded-table").html("show less");
|
|
} else {
|
|
button.removeClass("expanded-table").addClass("collapsed-table").html("show more");
|
|
}
|
|
|
|
button.parents(".table-container").find("table").toggle(shouldExpand);
|
|
button.parents(".table-container").find(".collapsed-element").toggle(shouldExpand);
|
|
}
|
|
|
|
function showAll(_, container) {
|
|
$(container).show();
|
|
}
|
|
|
|
function showUnhealthy(_, container) {
|
|
const isHealthy = $(container).find("h2").attr("class").indexOf("danger") < 0;
|
|
if (isHealthy) { $(container).hide(); }
|
|
}
|
|
|
|
function init() {
|
|
if ($("#unhealthy-targets").length) {
|
|
if (!localStorage.selectedTab || localStorage.selectedTab == "all-targets") {
|
|
$("#all-targets").parent().addClass("active");
|
|
$(".table-container").each(showAll);
|
|
} else if (localStorage.selectedTab == "unhealthy-targets") {
|
|
$("#unhealthy-targets").parent().addClass("active");
|
|
$(".table-container").each(showUnhealthy);
|
|
}
|
|
} else {
|
|
$(".table-container").each(showAll);
|
|
}
|
|
|
|
$("button.targets").click(function() {
|
|
const tableTitle = $(this).closest("h2").find("a").attr("id");
|
|
|
|
if ($(this).hasClass("collapsed-table")) {
|
|
localStorage.setItem(tableTitle, "expanded");
|
|
toggleJobTable($(this), true);
|
|
} else if ($(this).hasClass("expanded-table")) {
|
|
localStorage.setItem(tableTitle, "collapsed");
|
|
toggleJobTable($(this), false);
|
|
}
|
|
});
|
|
|
|
$(".job_header a").each(function (_, link) {
|
|
const cachedTableState = localStorage.getItem($(link).attr("id"));
|
|
if (cachedTableState === "collapsed") {
|
|
toggleJobTable($(this).siblings("button"), false);
|
|
}
|
|
});
|
|
|
|
$("#showTargets :input").change(function() {
|
|
const target = $(this).attr("id");
|
|
|
|
if (target === "all-targets") {
|
|
$(".table-container").each(showAll);
|
|
localStorage.setItem("selectedTab", "all-targets");
|
|
} else if (target === "unhealthy-targets") {
|
|
$(".table-container").each(showUnhealthy);
|
|
localStorage.setItem("selectedTab", "unhealthy-targets");
|
|
}
|
|
});
|
|
}
|
|
|
|
$(init);
|