mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-15 20:04:56 +02:00
Add:Tasks widget in appbar for merging m4bs & remove old m4b merge routes
This commit is contained in:
parent
441b8c5bb7
commit
39979ff8a3
16 changed files with 285 additions and 457 deletions
56
server/objects/Task.js
Normal file
56
server/objects/Task.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
const { getId } = require('../utils/index')
|
||||
|
||||
class Task {
|
||||
constructor() {
|
||||
this.id = null
|
||||
this.action = null // e.g. embed-metadata, encode-m4b, etc
|
||||
this.data = null // additional info for the action like libraryItemId
|
||||
|
||||
this.title = null
|
||||
this.description = null
|
||||
this.error = null
|
||||
|
||||
this.isFailed = false
|
||||
this.isFinished = false
|
||||
|
||||
this.startedAt = null
|
||||
this.finishedAt = null
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
id: this.id,
|
||||
action: this.action,
|
||||
data: this.data ? { ...this.data } : {},
|
||||
title: this.title,
|
||||
description: this.description,
|
||||
error: this.error,
|
||||
isFailed: this.isFailed,
|
||||
isFinished: this.isFinished,
|
||||
startedAt: this.startedAt,
|
||||
finishedAt: this.finishedAt
|
||||
}
|
||||
}
|
||||
|
||||
setData(action, title, description, data = {}) {
|
||||
this.id = getId(action)
|
||||
this.action = action
|
||||
this.data = { ...data }
|
||||
this.title = title
|
||||
this.description = description
|
||||
this.startedAt = Date.now()
|
||||
}
|
||||
|
||||
setFailed(message) {
|
||||
this.error = message
|
||||
this.isFailed = true
|
||||
this.failedAt = Date.now()
|
||||
this.setFinished()
|
||||
}
|
||||
|
||||
setFinished() {
|
||||
this.isFinished = true
|
||||
this.finishedAt = Date.now()
|
||||
}
|
||||
}
|
||||
module.exports = Task
|
Loading…
Add table
Add a link
Reference in a new issue