diff --git a/public/dashboard.js b/public/dashboard.js index da589ab2..6375c9f2 100644 --- a/public/dashboard.js +++ b/public/dashboard.js @@ -256,8 +256,9 @@ $(document).ready(() => { const job = localStorage.getItem('arena:savedJob'); if (job) { - const {name, data} = JSON.parse(job); + const {name, data, opts} = JSON.parse(job); window.jsonEditor.set(data); + if (window.jsonEditorOpts) window.jsonEditorOpts.set(opts); $('input.js-add-job-name').val(name); } else { window.jsonEditor.set({id: ''}); @@ -291,7 +292,8 @@ $(document).ready(() => { $('.js-add-job').on('click', function () { const name = $('input.js-add-job-name').val() || null; const data = window.jsonEditor.get(); - const job = JSON.stringify({name, data}); + const opts = window.jsonEditorOpts ? window.jsonEditorOpts.get() : {}; + const job = JSON.stringify({name, data, opts}); localStorage.setItem('arena:savedJob', job); const {queueHost, queueName} = window.arenaInitialPayload; $.ajax({ diff --git a/src/server/queue/index.js b/src/server/queue/index.js index 34b75cf2..ff3cdb53 100644 --- a/src/server/queue/index.js +++ b/src/server/queue/index.js @@ -140,14 +140,16 @@ class Queues { * @param {Object} queue A bee or bull queue class * @param {Object} data The data to be used within the job * @param {String} name The name of the Bull job (optional) + * @param {Object} opts The opts to be used within the job */ - async set(queue, data, name) { + async set(queue, data, name, opts) { if (queue.IS_BEE) { return queue.createJob(data).save(); } else { const args = [ data, { + ...opts, removeOnComplete: false, removeOnFail: false, }, diff --git a/src/server/views/api/jobAdd.js b/src/server/views/api/jobAdd.js index 38d68669..fdd54963 100644 --- a/src/server/views/api/jobAdd.js +++ b/src/server/views/api/jobAdd.js @@ -1,6 +1,6 @@ async function handler(req, res) { const {queueName, queueHost} = req.params; - const {name, data} = req.body; + const {name, data, opts} = req.body; const {Queues} = req.app.locals; @@ -8,7 +8,7 @@ async function handler(req, res) { if (!queue) return res.status(404).json({error: 'queue not found'}); try { - await Queues.set(queue, data, name); + await Queues.set(queue, data, name, opts); } catch (err) { return res.status(500).json({error: err.message}); } diff --git a/src/server/views/dashboard/queueDetails.js b/src/server/views/dashboard/queueDetails.js index 079eb4ad..5eb577e9 100644 --- a/src/server/views/dashboard/queueDetails.js +++ b/src/server/views/dashboard/queueDetails.js @@ -35,6 +35,7 @@ async function handler(req, res) { queueName, queueHost, queueIsBee: !!queue.IS_BEE, + queueIsBullMQ: !!queue.IS_BULLMQ, hasFlows: Flows.hasFlows(), jobCounts, stats, diff --git a/src/server/views/dashboard/templates/queueDetails.hbs b/src/server/views/dashboard/templates/queueDetails.hbs index 8075e15e..396baadb 100644 --- a/src/server/views/dashboard/templates/queueDetails.hbs +++ b/src/server/views/dashboard/templates/queueDetails.hbs @@ -18,17 +18,41 @@