Browse Source

HUE-1161 [oozie] Suspend a job directly from the dashboard lists

Introduced 'suspend' and 'resume' in the dashboard running lists
Enrico Berti 12 years ago
parent
commit
577c931

+ 33 - 12
apps/oozie/src/oozie/templates/dashboard/list_oozie_bundles.mako

@@ -127,6 +127,8 @@ ${layout.menubar(section='dashboard')}
       absoluteUrl: bundle.absoluteUrl,
       canEdit: bundle.canEdit,
       killUrl: bundle.killUrl,
+      suspendUrl: bundle.suspendUrl,
+      resumeUrl: bundle.resumeUrl,
       created: bundle.created
     }
   }
@@ -330,18 +332,36 @@ ${layout.menubar(section='dashboard')}
                 foundRow = node;
               }
             });
+            var killCell = "";
+            var suspendCell = "";
+            var resumeCell = "";
+            if (bundle.canEdit) {
+              killCell = '<a class="btn btn-small confirmationModal" ' +
+                      'href="javascript:void(0)" ' +
+                      'data-url="' + bundle.killUrl + '" ' +
+                      'title="${ _('Kill') } ' + bundle.id + '"' +
+                      'alt="${ _('Are you sure you want to kill bundle ')}' + bundle.id + '?" ' +
+                      'data-message="${ _('The bundle was killed!') }" ' +
+                      'data-confirmation-message="${ _('Are you sure you\'d like to kill this job?') }"' +
+                      '>${ _('Kill') }</a>';
+              suspendCell = '<a class="btn btn-small confirmationModal" ' +
+                      'href="javascript:void(0)" ' +
+                      'data-url="' + bundle.suspendUrl + '" ' +
+                      'title="${ _('Suspend') } ' + bundle.id + '"' +
+                      'alt="${ _('Are you sure you want to suspend bundle ')}' + bundle.id + '?" ' +
+                      'data-message="${ _('The bundle was suspended!') }" ' +
+                      'data-confirmation-message="${ _('Are you sure you\'d like to suspend this job?') }"' +
+                      '>${ _('Suspend') }</a>';
+              resumeCell = '<a class="btn btn-small confirmationModal" ' +
+                      'href="javascript:void(0)" ' +
+                      'data-url="' + bundle.resumeUrl + '" ' +
+                      'title="${ _('Resume') } ' + bundle.id + '"' +
+                      'alt="${ _('Are you sure you want to resume bundle ')}' + bundle.id + '?" ' +
+                      'data-message="${ _('The bundle was resumed!') }" ' +
+                      'data-confirmation-message="${ _('Are you sure you\'d like to resume this job?') }"' +
+                      '>${ _('Resume') }</a>';
+            }
             if (foundRow == null) {
-              var killCell = "";
-              if (bundle.canEdit) {
-                killCell = '<a class="btn btn-small confirmationModal" ' +
-                        'href="javascript:void(0)" ' +
-                        'data-url="' + bundle.killUrl + '" ' +
-                        'title="${ _('Kill') } ' + bundle.id + '"' +
-                        'alt="${ _('Are you sure you want to kill bundle ')}' + bundle.id + '?" ' +
-                        'data-message="${ _('The bundle was killed!') }" ' +
-                        'data-confirmation-message="${ _('Are you sure you\'d like to kill this job?') }"' +
-                        '>${ _('Kill') }</a>';
-              }
               if (['RUNNING', 'PREP', 'WAITING', 'SUSPENDED', 'PREPSUSPENDED', 'PREPPAUSED', 'PAUSED'].indexOf(bundle.status) > -1) {
                 try {
                   runningTable.fnAddData([
@@ -352,7 +372,7 @@ ${layout.menubar(section='dashboard')}
                     bundle.user,
                     emptyStringIfNull(bundle.created),
                     '<a href="' + bundle.absoluteUrl + '" data-row-selector="true">' + bundle.id + '</a>',
-                    killCell
+                    killCell + " " + (['RUNNING', 'PREP', 'WAITING'].indexOf(bundle.status) > -1?suspendCell:resumeCell)
                   ]);
                 }
                 catch (error) {
@@ -364,6 +384,7 @@ ${layout.menubar(section='dashboard')}
             else {
               runningTable.fnUpdate('<span class="' + bundle.statusClass + '">' + bundle.status + '</span>', foundRow, 1, false);
               runningTable.fnUpdate('<div class="progress"><div class="' + bundle.progressClass + '" style="width:' + bundle.progress + '%">' + bundle.progress + '%</div></div>', foundRow, 3, false);
+              runningTable.fnUpdate(killCell + " " + (['RUNNING', 'PREP', 'WAITING'].indexOf(bundle.status) > -1?suspendCell:resumeCell), foundRow, 7, false);
             }
           });
         }

+ 33 - 12
apps/oozie/src/oozie/templates/dashboard/list_oozie_coordinators.mako

@@ -131,6 +131,8 @@ ${layout.menubar(section='dashboard')}
       absoluteUrl: c.absoluteUrl,
       canEdit: c.canEdit,
       killUrl: c.killUrl,
+      suspendUrl: c.suspendUrl,
+      resumeUrl: c.resumeUrl,
       frequency: c.frequency,
       timeUnit: c.timeUnit,
       startTime: c.startTime
@@ -341,18 +343,36 @@ ${layout.menubar(section='dashboard')}
                 foundRow = node;
               }
             });
+            var killCell = "";
+            var suspendCell = "";
+            var resumeCell = "";
+            if (coord.canEdit) {
+              killCell = '<a class="btn btn-small confirmationModal" ' +
+                      'href="javascript:void(0)" ' +
+                      'data-url="' + coord.killUrl + '" ' +
+                      'title="${ _('Kill') } ' + coord.id + '"' +
+                      'alt="${ _('Are you sure you want to kill coordinator ')}' + coord.id + '?" ' +
+                      'data-message="${ _('The coordinator was killed!') }" ' +
+                      'data-confirmation-message="${ _('Are you sure you\'d like to kill this job?') }"' +
+                      '>${ _('Kill') }</a>';
+              suspendCell = '<a class="btn btn-small confirmationModal" ' +
+                      'href="javascript:void(0)" ' +
+                      'data-url="' + coord.suspendUrl + '" ' +
+                      'title="${ _('Suspend') } ' + coord.id + '"' +
+                      'alt="${ _('Are you sure you want to suspend coordinator ')}' + coord.id + '?" ' +
+                      'data-message="${ _('The coordinator was suspended!') }" ' +
+                      'data-confirmation-message="${ _('Are you sure you\'d like to suspend this job?') }"' +
+                      '>${ _('Suspend') }</a>';
+              resumeCell = '<a class="btn btn-small confirmationModal" ' +
+                      'href="javascript:void(0)" ' +
+                      'data-url="' + coord.resumeUrl + '" ' +
+                      'title="${ _('Resume') } ' + coord.id + '"' +
+                      'alt="${ _('Are you sure you want to resume coordinator ')}' + coord.id + '?" ' +
+                      'data-message="${ _('The coordinator was resumed!') }" ' +
+                      'data-confirmation-message="${ _('Are you sure you\'d like to resume this job?') }"' +
+                      '>${ _('Resume') }</a>';
+            }
             if (foundRow == null) {
-              var killCell = "";
-              if (coord.canEdit) {
-                killCell = '<a class="btn btn-small confirmationModal" ' +
-                        'href="javascript:void(0)" ' +
-                        'data-url="' + coord.killUrl + '" ' +
-                        'title="${ _('Kill') } ' + coord.id + '"' +
-                        'alt="${ _('Are you sure you want to kill coordinator ')}' + coord.id + '?" ' +
-                        'data-message="${ _('The coordinator was killed!') }" ' +
-                        'data-confirmation-message="${ _('Are you sure you\'d like to kill this job?') }"' +
-                        '>${ _('Kill') }</a>';
-              }
               if (['RUNNING', 'PREP', 'WAITING', 'SUSPENDED', 'PREPSUSPENDED', 'PREPPAUSED', 'PAUSED'].indexOf(coord.status) > -1) {
                 try {
                   runningTable.fnAddData([
@@ -365,7 +385,7 @@ ${layout.menubar(section='dashboard')}
                     emptyStringIfNull(coord.timeUnit),
                     emptyStringIfNull(coord.startTime),
                     '<a href="' + coord.absoluteUrl + '" data-row-selector="true">' + coord.id + '</a>',
-                    killCell
+                    killCell + " " + (['RUNNING', 'PREP', 'WAITING'].indexOf(coord.status) > -1?suspendCell:resumeCell)
                   ]);
                 }
                 catch (error) {
@@ -376,6 +396,7 @@ ${layout.menubar(section='dashboard')}
             else {
               runningTable.fnUpdate('<span class="' + coord.statusClass + '">' + coord.status + '</span>', foundRow, 1, false);
               runningTable.fnUpdate('<div class="progress"><div class="' + coord.progressClass + '" style="width:' + coord.progress + '%">' + coord.progress + '%</div></div>', foundRow, 3, false);
+              runningTable.fnUpdate(killCell + " " + (['RUNNING', 'PREP', 'WAITING'].indexOf(coord.status) > -1?suspendCell:resumeCell), foundRow, 9, false);
             }
           });
         }

+ 33 - 12
apps/oozie/src/oozie/templates/dashboard/list_oozie_workflows.mako

@@ -133,6 +133,8 @@ ${ layout.menubar(section='dashboard') }
       absoluteUrl: wf.absoluteUrl,
       canEdit: wf.canEdit,
       killUrl: wf.killUrl,
+      suspendUrl: wf.suspendUrl,
+      resumeUrl: wf.resumeUrl,
       created: wf.created,
       run: wf.run
     }
@@ -337,18 +339,36 @@ ${ layout.menubar(section='dashboard') }
                 foundRow = node;
               }
             });
+            var killCell = "";
+            var suspendCell = "";
+            var resumeCell = "";
+            if (wf.canEdit) {
+              killCell = '<a class="btn btn-small confirmationModal" ' +
+                      'href="javascript:void(0)" ' +
+                      'data-url="' + wf.killUrl + '" ' +
+                      'title="${ _('Kill') } ' + wf.id + '"' +
+                      'alt="${ _('Are you sure you want to kill workflow ')}' + wf.id + '?" ' +
+                      'data-message="${ _('The workflow was killed!') }" ' +
+                      'data-confirmation-message="${ _('Are you sure you\'d like to kill this job?') }"' +
+                      '>${ _('Kill') }</a>';
+              suspendCell = '<a class="btn btn-small confirmationModal" ' +
+                      'href="javascript:void(0)" ' +
+                      'data-url="' + wf.suspendUrl + '" ' +
+                      'title="${ _('Suspend') } ' + wf.id + '"' +
+                      'alt="${ _('Are you sure you want to suspend workflow ')}' + wf.id + '?" ' +
+                      'data-message="${ _('The workflow was suspended!') }" ' +
+                      'data-confirmation-message="${ _('Are you sure you\'d like to suspend this job?') }"' +
+                      '>${ _('Suspend') }</a>';
+              resumeCell = '<a class="btn btn-small confirmationModal" ' +
+                      'href="javascript:void(0)" ' +
+                      'data-url="' + wf.resumeUrl + '" ' +
+                      'title="${ _('Resume') } ' + wf.id + '"' +
+                      'alt="${ _('Are you sure you want to resume workflow ')}' + wf.id + '?" ' +
+                      'data-message="${ _('The workflow was resumed!') }" ' +
+                      'data-confirmation-message="${ _('Are you sure you\'d like to resume this job?') }"' +
+                      '>${ _('Resume') }</a>';
+            }
             if (foundRow == null) {
-              var killCell = "";
-              if (wf.canEdit) {
-                killCell = '<a class="btn btn-small confirmationModal" ' +
-                        'href="javascript:void(0)" ' +
-                        'data-url="' + wf.killUrl + '" ' +
-                        'title="${ _('Kill') } ' + wf.id + '"' +
-                        'alt="${ _('Are you sure you want to kill workflow ')}' + wf.id + '?" ' +
-                        'data-message="${ _('The workflow was killed!') }" ' +
-                        'data-confirmation-message="${ _('Are you sure you\'d like to kill this job?') }"' +
-                        '>${ _('Kill') }</a>';
-              }
               if (['RUNNING', 'PREP', 'WAITING', 'SUSPENDED', 'PREPSUSPENDED', 'PREPPAUSED', 'PAUSED'].indexOf(wf.status) > -1) {
                 try {
                   runningTable.fnAddData([
@@ -361,7 +381,7 @@ ${ layout.menubar(section='dashboard') }
                     emptyStringIfNull(wf.lastModTime),
                     wf.run,
                     '<a href="' + wf.absoluteUrl + '" data-row-selector="true">' + wf.id + '</a>',
-                    killCell
+                    killCell + " " + (['RUNNING', 'PREP', 'WAITING'].indexOf(wf.status) > -1?suspendCell:resumeCell)
                   ]);
                 }
                 catch (error) {
@@ -372,6 +392,7 @@ ${ layout.menubar(section='dashboard') }
             else {
               runningTable.fnUpdate('<span class="' + wf.statusClass + '">' + wf.status + '</span>', foundRow, 1, false);
               runningTable.fnUpdate('<div class="progress"><div class="' + wf.progressClass + '" style="width:' + wf.progress + '%">' + wf.progress + '%</div></div>', foundRow, 3, false);
+              runningTable.fnUpdate(killCell + " " + (['RUNNING', 'PREP', 'WAITING'].indexOf(wf.status) > -1?suspendCell:resumeCell), foundRow, 9, false);
             }
           });
         }

+ 2 - 0
apps/oozie/src/oozie/views/dashboard.py

@@ -621,6 +621,8 @@ def massaged_oozie_jobs_for_json(oozie_jobs, user):
       'absoluteUrl': job.get_absolute_url(),
       'canEdit': has_job_edition_permission(job, user),
       'killUrl': reverse('oozie:manage_oozie_jobs', kwargs={'job_id':job.id, 'action':'kill'}),
+      'suspendUrl': reverse('oozie:manage_oozie_jobs', kwargs={'job_id':job.id, 'action':'suspend'}),
+      'resumeUrl': reverse('oozie:manage_oozie_jobs', kwargs={'job_id':job.id, 'action':'resume'}),
       'created': hasattr(job, 'createdTime') and job.createdTime and job.createdTime and ((job.type == 'Bundle' and job.createdTime) or format_time(job.createdTime)),
       'startTime': hasattr(job, 'startTime') and format_time(job.startTime) or None,
       'run': hasattr(job, 'run') and job.run or 0,