mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-14 17:08:29 +00:00
Clean up JS for the "Update Timeout" modal
+ fix a bug where the preview doesn't update after closing and re-opening the dialog.
This commit is contained in:
parent
7ad01c4692
commit
b82274d827
1 changed files with 11 additions and 25 deletions
|
@ -32,7 +32,7 @@ $(function () {
|
||||||
$("#update-timeout-grace").val(this.dataset.grace);
|
$("#update-timeout-grace").val(this.dataset.grace);
|
||||||
|
|
||||||
// Cron
|
// Cron
|
||||||
currentPreviewHash = "";
|
cronPreviewHash = "";
|
||||||
$("#cron-preview").html("<p>Updating...</p>");
|
$("#cron-preview").html("<p>Updating...</p>");
|
||||||
$("#schedule").val(this.dataset.kind == "cron" ? this.dataset.schedule: "* * * * *");
|
$("#schedule").val(this.dataset.kind == "cron" ? this.dataset.schedule: "* * * * *");
|
||||||
$("#tz")[0].selectize.setValue(this.dataset.tz, true);
|
$("#tz")[0].selectize.setValue(this.dataset.tz, true);
|
||||||
|
@ -42,16 +42,15 @@ $(function () {
|
||||||
updateCronPreview();
|
updateCronPreview();
|
||||||
|
|
||||||
// OnCalendar
|
// OnCalendar
|
||||||
$("#cron-preview").html("<p>Updating...</p>");
|
onCalendarPreviewHash = "";
|
||||||
|
$("#oncalendar-preview").html("<p>Updating...</p>");
|
||||||
$("#schedule-oncalendar").val(this.dataset.kind == "oncalendar" ? this.dataset.schedule: "*-*-* *:*:*");
|
$("#schedule-oncalendar").val(this.dataset.kind == "oncalendar" ? this.dataset.schedule: "*-*-* *:*:*");
|
||||||
$("#tz-oncalendar")[0].selectize.setValue(this.dataset.tz, true);
|
$("#tz-oncalendar")[0].selectize.setValue(this.dataset.tz, true);
|
||||||
var minutes = parseInt(this.dataset.grace / 60);
|
var minutes = parseInt(this.dataset.grace / 60);
|
||||||
$("#update-timeout-grace-oncalendar").val(minutes);
|
$("#update-timeout-grace-oncalendar").val(minutes);
|
||||||
updateOnCalendarPreview();
|
updateOnCalendarPreview();
|
||||||
|
|
||||||
if (this.dataset.kind == "simple") showSimple();
|
showPanel(this.dataset.kind);
|
||||||
if (this.dataset.kind == "cron") showCron();
|
|
||||||
if (this.dataset.kind == "oncalendar") showOnCalendar();
|
|
||||||
$('#update-timeout-modal').modal({"show":true, "backdrop":"static"});
|
$('#update-timeout-modal').modal({"show":true, "backdrop":"static"});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@ -166,27 +165,14 @@ $(function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function showSimple() {
|
function showPanel(kind) {
|
||||||
$("#update-timeout-form").show();
|
$("#update-timeout-form").toggle(kind == "simple");
|
||||||
$("#update-cron-form").hide();
|
$("#update-cron-form").toggle(kind == "cron");
|
||||||
$("#update-oncalendar-form").hide();
|
$("#update-oncalendar-form").toggle(kind == "oncalendar");
|
||||||
}
|
|
||||||
|
|
||||||
function showCron() {
|
|
||||||
$("#update-timeout-form").hide();
|
|
||||||
$("#update-cron-form").show();
|
|
||||||
$("#update-oncalendar-form").hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
function showOnCalendar() {
|
|
||||||
$("#update-timeout-form").hide();
|
|
||||||
$("#update-cron-form").hide();
|
|
||||||
$("#update-oncalendar-form").show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var cronPreviewHash = "";
|
var cronPreviewHash = "";
|
||||||
function updateCronPreview() {
|
function updateCronPreview() {
|
||||||
console.log("updating cron preview");
|
|
||||||
var schedule = $("#schedule").val();
|
var schedule = $("#schedule").val();
|
||||||
var tz = $("#tz").val();
|
var tz = $("#tz").val();
|
||||||
var hash = schedule + tz;
|
var hash = schedule + tz;
|
||||||
|
@ -250,9 +236,9 @@ $(function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wire up events for Timeout/Cron forms
|
// Wire up events for Timeout/Cron forms
|
||||||
$(".kind-simple").click(showSimple);
|
$(".kind-simple").click(() => showPanel("simple"));
|
||||||
$(".kind-cron").click(showCron);
|
$(".kind-cron").click(() => showPanel("cron"));
|
||||||
$(".kind-oncalendar").click(showOnCalendar);
|
$(".kind-oncalendar").click(() => showPanel("oncalendar"));
|
||||||
|
|
||||||
$("#schedule").on("keyup", updateCronPreview);
|
$("#schedule").on("keyup", updateCronPreview);
|
||||||
$("#schedule-oncalendar").on("keyup", updateOnCalendarPreview);
|
$("#schedule-oncalendar").on("keyup", updateOnCalendarPreview);
|
||||||
|
|
Loading…
Add table
Reference in a new issue