Browse Source

Added loading screen to runnow

Jeroen De Meerleer 3 years ago
parent
commit
67ce425338
3 changed files with 22 additions and 17 deletions
  1. BIN
      images/ajax-loader.gif
  2. 19 17
      js/site.js
  3. 3 0
      templates/overview.html.twig

BIN
images/ajax-loader.gif


+ 19 - 17
js/site.js

@@ -24,24 +24,26 @@
 
 
 $(document).ready(function() {
-   $("body").on("click", "#patternDropdown li", function() {
-       if(this.value != "custom") { $("input#delay").val($(this).data("val")); }
-   });
-   $('#nextrunselector').datetimepicker();
+    $("body").on("click", "#patternDropdown li", function() {
+        if(this.value != "custom") { $("input#delay").val($(this).data("val")); }
+    });
+    $('#nextrunselector').datetimepicker();
    
-   $("body").on("click", ".runcron", function() {
-       fullurl = "/runnow.php?jobID=" + $(this).data("id");
-       $.ajax(fullurl).done(function(data) {
-           results = JSON.parse(data);
+    $("body").on("click", ".runcron", function() {
+        $("#ajax_loader").show();
+        fullurl = "/runnow.php?jobID=" + $(this).data("id");
+        $.ajax(fullurl).done(function(data) {
+            results = JSON.parse(data);
            
-           if(results["error"] !== undefined) {
-               $("#resulttitle").html("Error");
-               $("#resultbody").text(results["error"]);
-           } else {
-               $("#resulttitle").html("Success");
-               $("#resultbody").text(results["message"]);
-           }
-           $('#resultmodal').modal('show');
-       })
+            if(results["error"] !== undefined) {
+                $("#resulttitle").html("Error");
+                $("#resultbody").text(results["error"]);
+            } else {
+                $("#resulttitle").html("Success");
+                $("#resultbody").text(results["message"]);
+            }
+            $("#ajax_loader").hide();
+            $('#resultmodal').modal('show');
+        });
    });
 });

+ 3 - 0
templates/overview.html.twig

@@ -48,4 +48,7 @@
 
   </div>
 </div>
+<div id='ajax_loader' style="position: fixed; left: 50%; top: 50%; display: none;">
+    <img src="/images/ajax-loader.gif">
+</div>
 {% endblock %}