-
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add "title_title" to slim JSON * WIP * WIP * WIP * WIP * Add plugin subscription types * Revert "Subscription manager" This reverts commit a612500. * Use auto overflow tables cherry-picked from a612500 * Add endpoint for plugin subscription * WIP * WIP * Simplify subscription JSON parsing * Remove MangaDex files that are no longer needed * Fix linter * Refactor date filtering and use native date picker * Delete unnecessary raise for debugging * Subscription management API endpoints * Store manga ID with subscriptions * Add subscription manager page (WIP) * Finish subscription manager page * WIP * Finish plugin updater * Base64 encode chapter IDs * Fix actions on download manager * Trigger subscription update from manager page * Fix timestamp precision issue in plugin * Show target API version * Update last checked from manager page * Update last checked even when no chapters found * Fix null pid * Clean up * Document the subscription endpoints * Fix BigFloat conversion issue * Confirmation before deleting subscriptions * Reset table sort options * Show manga title on subscription manager
- Loading branch information
1 parent
1817efe
commit 461398d
Showing
19 changed files
with
1,469 additions
and
564 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
const component = () => { | ||
return { | ||
subscriptions: [], | ||
plugins: [], | ||
pid: undefined, | ||
subscription: undefined, // selected subscription | ||
loading: false, | ||
|
||
init() { | ||
fetch(`${base_url}api/admin/plugin`) | ||
.then((res) => res.json()) | ||
.then((data) => { | ||
if (!data.success) throw new Error(data.error); | ||
this.plugins = data.plugins; | ||
|
||
const pid = localStorage.getItem("plugin"); | ||
if (pid && this.plugins.map((p) => p.id).includes(pid)) | ||
this.pid = pid; | ||
else if (this.plugins.length > 0) | ||
this.pid = this.plugins[0].id; | ||
|
||
this.list(pid); | ||
}) | ||
.catch((e) => { | ||
alert( | ||
"danger", | ||
`Failed to list the available plugins. Error: ${e}` | ||
); | ||
}); | ||
}, | ||
pluginChanged() { | ||
localStorage.setItem("plugin", this.pid); | ||
this.list(this.pid); | ||
}, | ||
list(pid) { | ||
if (!pid) return; | ||
fetch( | ||
`${base_url}api/admin/plugin/subscriptions?${new URLSearchParams( | ||
{ | ||
plugin: pid, | ||
} | ||
)}`, | ||
{ | ||
method: "GET", | ||
} | ||
) | ||
.then((response) => response.json()) | ||
.then((data) => { | ||
if (!data.success) throw new Error(data.error); | ||
this.subscriptions = data.subscriptions; | ||
}) | ||
.catch((e) => { | ||
alert( | ||
"danger", | ||
`Failed to list subscriptions. Error: ${e}` | ||
); | ||
}); | ||
}, | ||
renderStrCell(str) { | ||
const maxLength = 40; | ||
if (str.length > maxLength) | ||
return `<td><span>${str.substring( | ||
0, | ||
maxLength | ||
)}...</span><div uk-dropdown>${str}</div></td>`; | ||
return `<td>${str}</td>`; | ||
}, | ||
renderDateCell(timestamp) { | ||
return `<td>${moment | ||
.duration(moment.unix(timestamp).diff(moment())) | ||
.humanize(true)}</td>`; | ||
}, | ||
selected(event, modal) { | ||
const id = event.currentTarget.getAttribute("sid"); | ||
this.subscription = this.subscriptions.find((s) => s.id === id); | ||
UIkit.modal(modal).show(); | ||
}, | ||
renderFilterRow(ft) { | ||
const key = ft.key; | ||
let type = ft.type; | ||
switch (type) { | ||
case "number-min": | ||
type = "number (minimum value)"; | ||
break; | ||
case "number-max": | ||
type = "number (maximum value)"; | ||
break; | ||
case "date-min": | ||
type = "minimum date"; | ||
break; | ||
case "date-max": | ||
type = "maximum date"; | ||
break; | ||
} | ||
let value = ft.value; | ||
|
||
if (ft.type.startsWith("number") && isNaN(value)) value = ""; | ||
else if (ft.type.startsWith("date") && value) | ||
value = moment(Number(value)).format("MMM D, YYYY"); | ||
|
||
return `<td>${key}</td><td>${type}</td><td>${value}</td>`; | ||
}, | ||
actionHandler(event, type) { | ||
const id = $(event.currentTarget).closest("tr").attr("sid"); | ||
if (type !== 'delete') return this.action(id, type); | ||
UIkit.modal.confirm('Are you sure you want to delete the subscription? This cannot be undone.', { | ||
labels: { | ||
ok: 'Yes, delete it', | ||
cancel: 'Cancel' | ||
} | ||
}).then(() => { | ||
this.action(id, type); | ||
}); | ||
}, | ||
action(id, type) { | ||
if (this.loading) return; | ||
this.loading = true; | ||
fetch( | ||
`${base_url}api/admin/plugin/subscriptions${type === 'update' ? '/update' : ''}?${new URLSearchParams( | ||
{ | ||
plugin: this.pid, | ||
subscription: id, | ||
} | ||
)}`, | ||
{ | ||
method: type === 'delete' ? "DELETE" : 'POST' | ||
} | ||
) | ||
.then((response) => response.json()) | ||
.then((data) => { | ||
if (!data.success) throw new Error(data.error); | ||
if (type === 'update') | ||
alert("success", `Checking updates for subscription ${id}. Check the log for the progress or come back to this page later.`); | ||
}) | ||
.catch((e) => { | ||
alert( | ||
"danger", | ||
`Failed to ${type} subscription. Error: ${e}` | ||
); | ||
}) | ||
.finally(() => { | ||
this.loading = false; | ||
this.list(this.pid); | ||
}); | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.