mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 11:25:29 -04:00
Trigger subscription update from manager page
This commit is contained in:
parent
968f6246de
commit
2c7c29fef9
@ -104,24 +104,26 @@ const component = () => {
|
||||
this.loading = true;
|
||||
const id = $(event.currentTarget).closest("tr").attr("sid");
|
||||
fetch(
|
||||
`${base_url}api/admin/plugin/subscriptions?${new URLSearchParams(
|
||||
`${base_url}api/admin/plugin/subscriptions${type === 'update' ? '/update' : ''}?${new URLSearchParams(
|
||||
{
|
||||
plugin: this.pid,
|
||||
subscription: id,
|
||||
}
|
||||
)}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
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 delete subscription. Error: ${e}`
|
||||
`Failed to ${type} subscription. Error: ${e}`
|
||||
);
|
||||
})
|
||||
.finally(() => {
|
||||
|
@ -61,7 +61,7 @@ class CLI < Clim
|
||||
Library.load_instance
|
||||
Library.default
|
||||
Plugin::Downloader.default
|
||||
Plugin::Updater.new
|
||||
Plugin::Updater.default
|
||||
|
||||
spawn do
|
||||
begin
|
||||
|
@ -153,6 +153,11 @@ class Plugin
|
||||
list.save
|
||||
end
|
||||
|
||||
def check_subscription(id : String)
|
||||
sub = list_subscriptions_raw.find &.id.== id
|
||||
Plugin::Updater.default.check_subscription self, sub.not_nil!
|
||||
end
|
||||
|
||||
def initialize(id : String)
|
||||
Plugin.build_info_ary
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
require "../config"
|
||||
|
||||
class Plugin
|
||||
class Updater
|
||||
use_default
|
||||
|
||||
def initialize
|
||||
interval = Config.current.plugin_update_interval_hours
|
||||
return if interval <= 0
|
||||
|
@ -721,6 +721,23 @@ struct APIRouter
|
||||
end
|
||||
end
|
||||
|
||||
post "/api/admin/plugin/subscriptions/update" do |env|
|
||||
pid = env.params.query["plugin"].as String
|
||||
sid = env.params.query["subscription"].as String
|
||||
|
||||
Plugin.new(pid).check_subscription sid
|
||||
|
||||
send_json env, {
|
||||
"success" => true,
|
||||
}.to_json
|
||||
rescue e
|
||||
Logger.error e
|
||||
send_json env, {
|
||||
"success" => false,
|
||||
"error" => e.message,
|
||||
}.to_json
|
||||
end
|
||||
|
||||
Koa.describe "Lists the chapters in a title from a plugin"
|
||||
Koa.tags ["admin", "downloader"]
|
||||
Koa.query "plugin", schema: String
|
||||
|
Loading…
x
Reference in New Issue
Block a user