Changeset 6581


Ignore:
Timestamp:
Oct 29, 2014, 10:49:23 AM (7 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1875: Abort multiple jobs

Location:
branches/3.3-stable/www/views/jobs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-stable/www/views/jobs/index.jsp

    r6447 r6581  
    5858  import="java.util.List"
    5959  import="java.util.ArrayList"
     60  import="java.util.Collection"
    6061  import="java.util.Collections"
    6162%>
     
    278279    redirect = viewPage;
    279280  }
     281  else if ("AbortJobs".equals(cmd))
     282  {
     283    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     284    dc = sc.newDbControl();
     285    int numAborted = 0;
     286    int numSelected = 0;
     287    for (int jobId : cc.getSelected())
     288    {
     289      numSelected++;
     290      Job job = Job.getById(dc, jobId);
     291      SignalTransporter signalTransporter = job.getSignalTransporter();
     292      if (signalTransporter == null)
     293      {
     294        if (job.getStatus() == Job.Status.WAITING)
     295        {
     296          job.doneError("Aborted by user");
     297          numAborted++;
     298        }
     299      }
     300      else
     301      {
     302        Collection<Signal> supportedSignals = signalTransporter.getSupportedSignals();
     303        if (supportedSignals == null || supportedSignals.contains(Signal.ABORT))
     304        {
     305          signalTransporter.send(Signal.ABORT);
     306          numAborted++;
     307        }
     308      }
     309    }
     310    dc.commit();
     311   
     312    message = numAborted + " of " + numSelected + " jobs have been aborted ";
     313    Thread.sleep(500);
     314    redirect = listPage;
     315  }
    280316  else if ("AbortJob".equals(cmd))
    281317  {
  • branches/3.3-stable/www/views/jobs/jobs.js

    r6342 r6581  
    6262      Buttons.addClickHandler('btnDeleteItems', Buttons.deleteItems, tableAttributes);
    6363      Buttons.addClickHandler('btnRestoreItems', Buttons.restoreItems, tableAttributes);
     64      Buttons.addClickHandler('btnAbort', jobs.abortJobs, tableAttributes);
    6465      Buttons.addClickHandler('btnShareItems', Buttons.shareItems, tableAttributes);
    6566      Buttons.addClickHandler('btnSetOwner', Buttons.setOwnerOfItems, tableAttributes);
     
    8081  }
    8182
     83 
     84  jobs.abortJobs = function()
     85  {
     86    var frm = document.forms['jobs'];
     87    var numSelected = Table.checkIfSelected('jobs');
     88    if (numSelected == 0) return;
     89    if (!confirm('You are about to abort '+numSelected+' jobs. This can\'t be undone. Continue?'))
     90    {
     91      return;
     92    }
     93    frm.cmd.value = 'AbortJobs';
     94    frm.submit();
     95  }
    8296 
    8397  jobs.abortJob = function()
  • branches/3.3-stable/www/views/jobs/list_jobs.jsp

    r6447 r6581  
    413413            title="Restore"
    414414            tooltip="Restore the selected (deleted) items"
     415          />
     416          <tbl:button
     417            id="btnAbort"
     418            image="abort.png"
     419            title="Abort&hellip;"
     420            tooltip="Abort the selected items"
    415421          />
    416422          <tbl:button
Note: See TracChangeset for help on using the changeset viewer.