@@ -162,8 +162,7 @@ export default {
162162 await this .refreshElement (job, updatedJob => this .broadcast (' editProcess' , updatedJob));
163163 },
164164 async startAndQueueProcess (options ) {
165- const job = await this .createJob (this .process , options);
166- await this .queueJob (job);
165+ await this .createJob (this .process , options, true );
167166 },
168167 async executeProcessWithOptions () {
169168 const fields = [
@@ -201,20 +200,34 @@ export default {
201200 }
202201 }
203202 },
204- jobCreated (job ) {
203+ jobAfterCreation (job , queueing = false ) {
205204 const buttons = [];
206- if (this .supports (' estimateJob' )) {
207- buttons .push ({text: ' Estimate' , action : () => this .estimateJob (job)});
208- }
209- if (this .supports (' startJob' )) {
210- buttons .push ({text: ' Start processing' , action : () => this .queueJob (job)});
205+ if (job .status === ' created' && ! queueing) {
206+ if (this .supports (' estimateJob' ) && job .status === ' created' ) {
207+ buttons .push ({text: ' Estimate' , action : () => this .estimateJob (job)});
208+ }
209+ if (this .supports (' startJob' ) && job .status === ' created' ) {
210+ buttons .push ({text: ' Start processing' , action : () => this .queueJob (job)});
211+ }
212+ } else if (! queueing) {
213+ if (this .supportsRead ) {
214+ buttons .push ({ text: ' Details' , action : () => this .showJobInfo (job) });
215+ }
216+ if (job .status !== ' queued' && this .supportsDebug ) { // not when created or queued
217+ buttons .push ({text: ' Logs' , action : () => this .showLogs (job)});
218+ }
211219 }
212- if (this .supports (' deleteJob' )) {
220+ if (this .supports (' deleteJob' )) { // always
213221 buttons .push ({text: ' Delete' , action : () => this .deleteJob (job)});
214222 }
215- Utils .confirm (this , ' Job "' + Utils .getResourceTitle (job) + ' " created!' , buttons);
223+ const title = Utils .getResourceTitle (job);
224+ let message = ` Job "${ title} " ${ job .status || ' created' } !` ;
225+ if (queueing) {
226+ message += ` Queuing for execution...` ;
227+ }
228+ Utils .confirm (this , message, buttons);
216229 },
217- async createJob (process , data ) {
230+ async createJob (process , data , queue = false ) {
218231 try {
219232 let job = await this .create ([
220233 process ,
@@ -224,7 +237,10 @@ export default {
224237 data .budget ,
225238 data
226239 ]);
227- this .jobCreated (job);
240+ this .jobAfterCreation (job, queue);
241+ if (queue) {
242+ job = await this .queueJob (job);
243+ }
228244 return job;
229245 } catch (error) {
230246 Utils .exception (this , error, ' Create Job Error: ' + (data .title || ' ' ));
@@ -357,15 +373,15 @@ export default {
357373 },
358374 async queueJob (job ) {
359375 await this .refreshElement (job, async (updatedJob ) => {
360- if (updatedJob .status === ' finished' && ! confirm (` The batch job "${ Utils .getResourceTitle (updatedJob)} " has already finished with results. Queueing the job again may discard all previous results! Do you really want to queue it again?` )) {
376+ if (updatedJob .status === ' finished' && ! confirm (` The batch job "${ Utils .getResourceTitle (updatedJob)} " has already finished with results. Queuing the job again may discard all previous results! Do you really want to queue it again?` )) {
361377 return ;
362378 }
363379
364380 try {
365- let updatedJob = await this .queue ({data: job });
366- Utils . ok ( this , ' Job " ' + Utils . getResourceTitle (updatedJob) + ' " successfully queued. ' );
381+ let updatedJob = await this .queue ({data: updatedJob });
382+ this . jobAfterCreation (updatedJob);
367383 } catch (error) {
368- Utils .exception (this , error, ' Queue Job Error: ' + Utils .getResourceTitle (job ));
384+ Utils .exception (this , error, ' Queue Job Error: ' + Utils .getResourceTitle (updatedJob ));
369385 }
370386 });
371387 },
0 commit comments