diff OrthancExplorer/explorer.js @ 2582:b3da733d984c jobs

job actions in Orthanc Explorer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 11 May 2018 17:58:06 +0200
parents 3372c5255333
children 1b6a6d80b6f2
line wrap: on
line diff
--- a/OrthancExplorer/explorer.js	Fri May 11 17:33:19 2018 +0200
+++ b/OrthancExplorer/explorer.js	Fri May 11 17:58:06 2018 +0200
@@ -1218,7 +1218,7 @@
         
         target.listview('refresh');
 
-        $('#job-delete').closest('.ui-btn').show();
+        $('#job-cancel').closest('.ui-btn').hide();
         $('#job-retry').closest('.ui-btn').hide();
         $('#job-resubmit').closest('.ui-btn').hide();
         $('#job-pause').closest('.ui-btn').hide();
@@ -1227,6 +1227,7 @@
         if (job.State == 'Running' ||
             job.State == 'Pending' ||
             job.State == 'Retry') {
+          $('#job-cancel').closest('.ui-btn').show();
           $('#job-pause').closest('.ui-btn').show();
         }
         else if (job.State == 'Success') {
@@ -1241,3 +1242,33 @@
     });
   }
 });
+
+
+
+function TriggerJobAction(action)
+{
+  $.ajax({
+    url: '../jobs/' + $.mobile.pageData.uuid + '/' + action,
+    type: 'POST',
+    async: false,
+    complete: function(s) {
+      window.location.reload();
+    }
+  });
+}
+
+$('#job-cancel').live('click', function() {
+  TriggerJobAction('cancel');
+});
+
+$('#job-resubmit').live('click', function() {
+  TriggerJobAction('resubmit');
+});
+
+$('#job-pause').live('click', function() {
+  TriggerJobAction('pause');
+});
+
+$('#job-resume').live('click', function() {
+  TriggerJobAction('resume');
+});