2017-11-25 20:49:24 -08: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 02:20:32 -07:00
|
|
|
button.parents(".table-container").find(".collapsed-element").toggle(shouldExpand);
|
2017-11-25 20:49:24 -08:00
|
|
|
}
|
|
|
|
|
2018-03-09 02:19:09 -08: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 07:54:54 -07:00
|
|
|
var allCollapsed = false;
|
|
|
|
|
2017-11-25 20:49:24 -08:00
|
|
|
function init() {
|
2019-08-21 04:57:08 -07:00
|
|
|
if ($("#unhealthy-targets").length) {
|
2019-10-29 03:09:53 -07:00
|
|
|
if (!localStorage.selectedTargetsTab || localStorage.selectedTargetsTab == "all-targets") {
|
2019-08-21 04:57:08 -07:00
|
|
|
$("#all-targets").parent().addClass("active");
|
|
|
|
$(".table-container").each(showAll);
|
2019-10-29 03:09:53 -07:00
|
|
|
} else if (localStorage.selectedTargetsTab == "unhealthy-targets") {
|
2019-08-21 04:57:08 -07:00
|
|
|
$("#unhealthy-targets").parent().addClass("active");
|
|
|
|
$(".table-container").each(showUnhealthy);
|
|
|
|
}
|
|
|
|
} else {
|
2019-02-11 15:22:05 -08:00
|
|
|
$(".table-container").each(showAll);
|
|
|
|
}
|
|
|
|
|
2019-08-21 04:57:08 -07:00
|
|
|
$("button.targets").click(function() {
|
2017-11-25 20:49:24 -08: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 08:10:30 -07:00
|
|
|
}
|
2017-11-25 20:49:24 -08:00
|
|
|
});
|
2017-08-09 08:10:30 -07:00
|
|
|
|
2020-09-07 07:54:54 -07: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-25 20:49:24 -08: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 08:10:30 -07:00
|
|
|
}
|
2017-11-25 20:49:24 -08:00
|
|
|
});
|
|
|
|
|
2018-03-09 02:19:09 -08:00
|
|
|
$("#showTargets :input").change(function() {
|
|
|
|
const target = $(this).attr("id");
|
2017-11-25 20:49:24 -08:00
|
|
|
|
2018-03-09 02:19:09 -08:00
|
|
|
if (target === "all-targets") {
|
2017-11-25 20:49:24 -08:00
|
|
|
$(".table-container").each(showAll);
|
2019-10-29 03:09:53 -07:00
|
|
|
localStorage.setItem("selectedTargetsTab", "all-targets");
|
2018-03-09 02:19:09 -08:00
|
|
|
} else if (target === "unhealthy-targets") {
|
|
|
|
$(".table-container").each(showUnhealthy);
|
2019-10-29 03:09:53 -07:00
|
|
|
localStorage.setItem("selectedTargetsTab", "unhealthy-targets");
|
2017-11-25 20:49:24 -08:00
|
|
|
}
|
|
|
|
});
|
2017-08-09 08:10:30 -07:00
|
|
|
}
|
|
|
|
|
2017-11-25 20:49:24 -08:00
|
|
|
$(init);
|