Mega refactor of the task processing and rendering logic; Split filter into a separate task, and add support for running filter tasks individually; Change the format for sending model and filter data from the API, but maintain backwards compatibility for now with the old API

This commit is contained in:
cmdr2
2023-07-28 18:57:28 +05:30
parent b93c624efa
commit e61549e0cd
11 changed files with 626 additions and 300 deletions

View File

@@ -1047,17 +1047,22 @@
}
}
class FilterTask extends Task {
constructor(options = {}) {}
constructor(options = {}) {
super(options)
}
/** Send current task to server.
* @param {*} [timeout=-1] Optional timeout value in ms
* @returns the response from the render request.
* @memberof Task
*/
async post(timeout = -1) {
let jsonResponse = await super.post("/filter", timeout)
let res = await super.post("/filter", timeout)
//this._setId(jsonResponse.task)
this._setStatus(TaskStatus.waiting)
return res
}
checkReqBody() {}
enqueue(progressCallback) {
return Task.enqueueNew(this, FilterTask, progressCallback)
}
@@ -1068,6 +1073,20 @@
if (this.isStopped) {
return
}
this._setStatus(TaskStatus.pending)
progressCallback?.call(this, { reqBody: this._reqBody })
Object.freeze(this._reqBody)
// Post task request to backend
let renderRes = undefined
try {
renderRes = yield this.post()
yield progressCallback?.call(this, { renderResponse: renderRes })
} catch (e) {
yield progressCallback?.call(this, { detail: e.message })
throw e
}
}
static start(task, progressCallback) {
if (typeof task !== "object") {