mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 10:55:30 -04:00
Allow delete all missing items (#151)
This commit is contained in:
parent
b5db508005
commit
a389fa7178
@ -24,6 +24,20 @@ const component = () => {
|
|||||||
this.load();
|
this.load();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
rmAll() {
|
||||||
|
UIkit.modal.confirm('Are you sure? All metadata associated with these items, including their tags and thumbnails, will be deleted from the database.', {
|
||||||
|
labels: {
|
||||||
|
ok: 'Yes, delete them',
|
||||||
|
cancel: 'Cancel'
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
this.request('DELETE', `${base_url}api/admin/titles/missing`, () => {
|
||||||
|
this.request('DELETE', `${base_url}api/admin/entries/missing`, () => {
|
||||||
|
this.load();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
request(method, url, cb) {
|
request(method, url, cb) {
|
||||||
console.log(url);
|
console.log(url);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -828,7 +828,45 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Deletes a missing title with `tid`"
|
Koa.describe "Deletes all missing titles"
|
||||||
|
Koa.response 200, ref: "$result"
|
||||||
|
Koa.tag "admin"
|
||||||
|
delete "/api/admin/titles/missing" do |env|
|
||||||
|
begin
|
||||||
|
Storage.default.delete_missing_title
|
||||||
|
send_json env, {
|
||||||
|
"success" => true,
|
||||||
|
"error" => nil,
|
||||||
|
}.to_json
|
||||||
|
rescue e
|
||||||
|
send_json env, {
|
||||||
|
"success" => false,
|
||||||
|
"error" => e.message,
|
||||||
|
}.to_json
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Koa.describe "Deletes all missing entries"
|
||||||
|
Koa.response 200, ref: "$result"
|
||||||
|
Koa.tag "admin"
|
||||||
|
delete "/api/admin/entries/missing" do |env|
|
||||||
|
begin
|
||||||
|
Storage.default.delete_missing_entry
|
||||||
|
send_json env, {
|
||||||
|
"success" => true,
|
||||||
|
"error" => nil,
|
||||||
|
}.to_json
|
||||||
|
rescue e
|
||||||
|
send_json env, {
|
||||||
|
"success" => false,
|
||||||
|
"error" => e.message,
|
||||||
|
}.to_json
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Koa.describe "Deletes a missing title identified by `tid`", <<-MD
|
||||||
|
Does nothing if the given `tid` is not found or if the title is not missing.
|
||||||
|
MD
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, ref: "$result"
|
||||||
Koa.tag "admin"
|
Koa.tag "admin"
|
||||||
delete "/api/admin/titles/missing/:tid" do |env|
|
delete "/api/admin/titles/missing/:tid" do |env|
|
||||||
@ -847,7 +885,9 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Koa.describe "Deletes a missing entry with `eid`"
|
Koa.describe "Deletes a missing entry identified by `eid`", <<-MD
|
||||||
|
Does nothing if the given `eid` is not found or if the entry is not missing.
|
||||||
|
MD
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, ref: "$result"
|
||||||
Koa.tag "admin"
|
Koa.tag "admin"
|
||||||
delete "/api/admin/entries/missing/:eid" do |env|
|
delete "/api/admin/entries/missing/:eid" do |env|
|
||||||
|
@ -493,11 +493,15 @@ class Storage
|
|||||||
ary
|
ary
|
||||||
end
|
end
|
||||||
|
|
||||||
private def delete_missing(tablename, id)
|
private def delete_missing(tablename, id : String? = nil)
|
||||||
MainFiber.run do
|
MainFiber.run do
|
||||||
get_db do |db|
|
get_db do |db|
|
||||||
db.exec "delete from #{tablename} where id = (?) and unavailable = 1",
|
if id
|
||||||
id
|
db.exec "delete from #{tablename} where id = (?) " \
|
||||||
|
"and unavailable = 1", id
|
||||||
|
else
|
||||||
|
db.exec "delete from #{tablename} where unavailable = 1"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -510,11 +514,11 @@ class Storage
|
|||||||
get_missing "titles"
|
get_missing "titles"
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_missing_entry(id)
|
def delete_missing_entry(id = nil)
|
||||||
delete_missing "ids", id
|
delete_missing "ids", id
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_missing_title(id)
|
def delete_missing_title(id = nil)
|
||||||
delete_missing "titles", id
|
delete_missing "titles", id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<p x-show="empty" class="uk-text-lead uk-text-center">No missing items found.</p>
|
<p x-show="empty" class="uk-text-lead uk-text-center">No missing items found.</p>
|
||||||
<div x-show="!empty">
|
<div x-show="!empty">
|
||||||
<p>The following items were present in your library, but now we can't find them anymore. If you deleted them mistakenly, try to recover the files or folders, put them back to where they were, and rescan the library. Otherwise, you can safely delete them and the associated metadata using the buttons below to free up database space.</p>
|
<p>The following items were present in your library, but now we can't find them anymore. If you deleted them mistakenly, try to recover the files or folders, put them back to where they were, and rescan the library. Otherwise, you can safely delete them and the associated metadata using the buttons below to free up database space.</p>
|
||||||
|
<button class="uk-button uk-button-danger" @click="rmAll()">Delete All</button>
|
||||||
<table class="uk-table uk-table-striped uk-overflow-auto">
|
<table class="uk-table uk-table-striped uk-overflow-auto">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user