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;
|
this.loading = true;
|
||||||
const id = $(event.currentTarget).closest("tr").attr("sid");
|
const id = $(event.currentTarget).closest("tr").attr("sid");
|
||||||
fetch(
|
fetch(
|
||||||
`${base_url}api/admin/plugin/subscriptions?${new URLSearchParams(
|
`${base_url}api/admin/plugin/subscriptions${type === 'update' ? '/update' : ''}?${new URLSearchParams(
|
||||||
{
|
{
|
||||||
plugin: this.pid,
|
plugin: this.pid,
|
||||||
subscription: id,
|
subscription: id,
|
||||||
}
|
}
|
||||||
)}`,
|
)}`,
|
||||||
{
|
{
|
||||||
method: "DELETE",
|
method: type === 'delete' ? "DELETE" : 'POST'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (!data.success) throw new Error(data.error);
|
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) => {
|
.catch((e) => {
|
||||||
alert(
|
alert(
|
||||||
"danger",
|
"danger",
|
||||||
`Failed to delete subscription. Error: ${e}`
|
`Failed to ${type} subscription. Error: ${e}`
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
@ -61,7 +61,7 @@ class CLI < Clim
|
|||||||
Library.load_instance
|
Library.load_instance
|
||||||
Library.default
|
Library.default
|
||||||
Plugin::Downloader.default
|
Plugin::Downloader.default
|
||||||
Plugin::Updater.new
|
Plugin::Updater.default
|
||||||
|
|
||||||
spawn do
|
spawn do
|
||||||
begin
|
begin
|
||||||
|
@ -153,6 +153,11 @@ class Plugin
|
|||||||
list.save
|
list.save
|
||||||
end
|
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)
|
def initialize(id : String)
|
||||||
Plugin.build_info_ary
|
Plugin.build_info_ary
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require "../config"
|
|
||||||
|
|
||||||
class Plugin
|
class Plugin
|
||||||
class Updater
|
class Updater
|
||||||
|
use_default
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
interval = Config.current.plugin_update_interval_hours
|
interval = Config.current.plugin_update_interval_hours
|
||||||
return if interval <= 0
|
return if interval <= 0
|
||||||
|
@ -721,6 +721,23 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
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.describe "Lists the chapters in a title from a plugin"
|
||||||
Koa.tags ["admin", "downloader"]
|
Koa.tags ["admin", "downloader"]
|
||||||
Koa.query "plugin", schema: String
|
Koa.query "plugin", schema: String
|
||||||
|
Loading…
x
Reference in New Issue
Block a user