Browse Source

Fix race conditions in preview code.

pull/109/head
Pēteris Caune 8 years ago
parent
commit
b29400710f
1 changed files with 3 additions and 7 deletions
  1. +3
    -7
      static/js/checks.js

+ 3
- 7
static/js/checks.js View File

@ -97,21 +97,17 @@ $(function () {
}); });
function showSimple() { function showSimple() {
console.log("show simple");
$("#update-timeout-form").show(); $("#update-timeout-form").show();
$("#update-cron-form").hide(); $("#update-cron-form").hide();
} }
function showCron() { function showCron() {
console.log("show cron");
$("#update-timeout-form").hide(); $("#update-timeout-form").hide();
$("#update-cron-form").show(); $("#update-cron-form").show();
} }
var currentPreviewHash = ""; var currentPreviewHash = "";
function updateCronPreview() { function updateCronPreview() {
console.log("requested to update 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;
@ -145,11 +141,13 @@ $(function () {
graceSlider.noUiSlider.set(this.dataset.grace); graceSlider.noUiSlider.set(this.dataset.grace);
// Cron // Cron
currentPreviewHash = "";
$("#cron-preview").html("<p>Updating...</p>"); $("#cron-preview").html("<p>Updating...</p>");
$("#schedule").val(this.dataset.schedule); $("#schedule").val(this.dataset.schedule);
document.getElementById("tz").selectize.setValue(this.dataset.tz); document.getElementById("tz").selectize.setValue(this.dataset.tz);
var minutes = parseInt(this.dataset.grace / 60); var minutes = parseInt(this.dataset.grace / 60);
$("#update-timeout-grace-cron").val(minutes); $("#update-timeout-grace-cron").val(minutes);
updateCronPreview();
this.dataset.kind == "simple" ? showSimple() : showCron(); this.dataset.kind == "simple" ? showSimple() : showCron();
$('#update-timeout-modal').modal({"show":true, "backdrop":"static"}); $('#update-timeout-modal').modal({"show":true, "backdrop":"static"});
@ -161,8 +159,7 @@ $(function () {
$(".kind-cron").click(showCron); $(".kind-cron").click(showCron);
$("#schedule").on("keyup", updateCronPreview); $("#schedule").on("keyup", updateCronPreview);
$("#tz").on("change", updateCronPreview);
$("#tz").selectize({onChange: updateCronPreview});
$(".check-menu-remove").click(function() { $(".check-menu-remove").click(function() {
$("#remove-check-form").attr("action", this.dataset.url); $("#remove-check-form").attr("action", this.dataset.url);
@ -217,7 +214,6 @@ $(function () {
}); });
$('[data-toggle="tooltip"]').tooltip(); $('[data-toggle="tooltip"]').tooltip();
$("#tz").selectize();
$(".usage-examples").click(function(e) { $(".usage-examples").click(function(e) {
var a = e.target; var a = e.target;


Loading…
Cancel
Save