2017-11-26 04:49:24 +00:00
|
|
|
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);
|
2018-06-05 09:20:32 +00:00
|
|
|
button.parents(".table-container").find(".collapsed-element").toggle(shouldExpand);
|
2017-11-26 04:49:24 +00:00
|
|
|
}
|
|
|
|
|
2018-03-09 10:19:09 +00:00
|
|
|
function showAll(_, container) {
|
|
|
|
$(container).show();
|
|
|
|
}
|
|
|
|
|
|
|
|
function showUnhealthy(_, container) {
|
|
|
|
const isHealthy = $(container).find("h2").attr("class").indexOf("danger") < 0;
|
|
|
|
if (isHealthy) { $(container).hide(); }
|
|
|
|
}
|
|
|
|
|
2020-09-07 14:54:54 +00:00
|
|
|
var allCollapsed = false;
|
|
|
|
|
2017-11-26 04:49:24 +00:00
|
|
|
function init() {
|
2019-08-21 11:57:08 +00:00
|
|
|
if ($("#unhealthy-targets").length) {
|
2019-10-29 10:09:53 +00:00
|
|
|
if (!localStorage.selectedTargetsTab || localStorage.selectedTargetsTab == "all-targets") {
|
2019-08-21 11:57:08 +00:00
|
|
|
$("#all-targets").parent().addClass("active");
|
|
|
|
$(".table-container").each(showAll);
|
2019-10-29 10:09:53 +00:00
|
|
|
} else if (localStorage.selectedTargetsTab == "unhealthy-targets") {
|
2019-08-21 11:57:08 +00:00
|
|
|
$("#unhealthy-targets").parent().addClass("active");
|
|
|
|
$(".table-container").each(showUnhealthy);
|
|
|
|
}
|
|
|
|
} else {
|
2019-02-11 23:22:05 +00:00
|
|
|
$(".table-container").each(showAll);
|
|
|
|
}
|
|
|
|
|
2019-08-21 11:57:08 +00:00
|
|
|
$("button.targets").click(function() {
|
2017-11-26 04:49:24 +00:00
|
|
|
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);
|
2017-08-09 15:10:30 +00:00
|
|
|
}
|
2017-11-26 04:49:24 +00:00
|
|
|
});
|
2017-08-09 15:10:30 +00:00
|
|
|
|
2020-09-07 14:54:54 +00:00
|
|
|
$(".collapse-all").click(function() {
|
|
|
|
|
|
|
|
// locally store state of allCollapsed
|
|
|
|
previousAllCollapsed = allCollapsed;
|
|
|
|
|
|
|
|
// conditionally change the text of the button
|
|
|
|
if (allCollapsed == false) {
|
|
|
|
$(this).html("Expand All");
|
|
|
|
allCollapsed = true;
|
|
|
|
} else {
|
|
|
|
$(this).html("Collapse All");
|
|
|
|
allCollapsed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$("button.targets").each(function(_, thisButton) {
|
|
|
|
const tableTitle = $(thisButton).closest("h2").find("a").attr("id");
|
|
|
|
|
|
|
|
if (previousAllCollapsed == false) {
|
|
|
|
|
|
|
|
// collapse all the jobs
|
|
|
|
if ($(this).hasClass("expanded-table")) {
|
|
|
|
localStorage.setItem(tableTitle, "collapsed");
|
|
|
|
toggleJobTable($(thisButton), false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// expand all the jobs
|
|
|
|
if ($(this).hasClass("collapsed-table")) {
|
|
|
|
localStorage.setItem(tableTitle, "expanded");
|
|
|
|
toggleJobTable($(this), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-11-26 04:49:24 +00:00
|
|
|
$(".job_header a").each(function (_, link) {
|
|
|
|
const cachedTableState = localStorage.getItem($(link).attr("id"));
|
|
|
|
if (cachedTableState === "collapsed") {
|
|
|
|
toggleJobTable($(this).siblings("button"), false);
|
2017-08-09 15:10:30 +00:00
|
|
|
}
|
2017-11-26 04:49:24 +00:00
|
|
|
});
|
|
|
|
|
2018-03-09 10:19:09 +00:00
|
|
|
$("#showTargets :input").change(function() {
|
|
|
|
const target = $(this).attr("id");
|
2017-11-26 04:49:24 +00:00
|
|
|
|
2018-03-09 10:19:09 +00:00
|
|
|
if (target === "all-targets") {
|
2017-11-26 04:49:24 +00:00
|
|
|
$(".table-container").each(showAll);
|
2019-10-29 10:09:53 +00:00
|
|
|
localStorage.setItem("selectedTargetsTab", "all-targets");
|
2018-03-09 10:19:09 +00:00
|
|
|
} else if (target === "unhealthy-targets") {
|
|
|
|
$(".table-container").each(showUnhealthy);
|
2019-10-29 10:09:53 +00:00
|
|
|
localStorage.setItem("selectedTargetsTab", "unhealthy-targets");
|
2017-11-26 04:49:24 +00:00
|
|
|
}
|
|
|
|
});
|
2017-08-09 15:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-11-26 04:49:24 +00:00
|
|
|
$(init);
|