mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 19:05:32 -04:00
Use the correct verbs in the API
This commit is contained in:
parent
4f6df5b9a3
commit
d33b45233a
@ -33,14 +33,13 @@ const search = () => {
|
|||||||
if (searching)
|
if (searching)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const query = $('#search-input').val();
|
const query = $.param({
|
||||||
|
query: $('#search-input').val(),
|
||||||
|
plugin: pid
|
||||||
|
});
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'GET',
|
||||||
url: base_url + 'api/admin/plugin/list',
|
url: `${base_url}api/admin/plugin/list?${query}`,
|
||||||
data: JSON.stringify({
|
|
||||||
query: query,
|
|
||||||
plugin: pid
|
|
||||||
}),
|
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
})
|
})
|
||||||
|
@ -220,14 +220,18 @@ const saveProgress = (idx, cb) => {
|
|||||||
console.log('saving progress', idx);
|
console.log('saving progress', idx);
|
||||||
|
|
||||||
const url = `${base_url}api/progress/${tid}/${idx}?${$.param({eid: eid})}`;
|
const url = `${base_url}api/progress/${tid}/${idx}?${$.param({eid: eid})}`;
|
||||||
$.post(url)
|
$.ajax({
|
||||||
.then(data => {
|
method: 'PUT',
|
||||||
if (data.error) throw new Error(data.error);
|
url: url,
|
||||||
|
dataType: 'json'
|
||||||
|
})
|
||||||
|
.done(data => {
|
||||||
|
if (data.error)
|
||||||
|
alert('danger', data.error);
|
||||||
if (cb) cb();
|
if (cb) cb();
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.fail((jqXHR, status) => {
|
||||||
console.error(e);
|
alert('danger', `Error: [${jqXHR.status}] ${jqXHR.statusText}`);
|
||||||
alert('danger', e);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -67,14 +67,23 @@ const updateProgress = (tid, eid, page) => {
|
|||||||
});
|
});
|
||||||
if (eid)
|
if (eid)
|
||||||
url += `?${query}`;
|
url += `?${query}`;
|
||||||
$.post(url, (data) => {
|
|
||||||
if (data.success) {
|
$.ajax({
|
||||||
location.reload();
|
method: 'PUT',
|
||||||
} else {
|
url: url,
|
||||||
error = data.error;
|
dataType: 'json'
|
||||||
alert('danger', error);
|
})
|
||||||
}
|
.done(data => {
|
||||||
});
|
if (data.success) {
|
||||||
|
location.reload();
|
||||||
|
} else {
|
||||||
|
error = data.error;
|
||||||
|
alert('danger', error);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.fail((jqXHR, status) => {
|
||||||
|
alert('danger', `Error: [${jqXHR.status}] ${jqXHR.statusText}`);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const renameSubmit = (name, eid) => {
|
const renameSubmit = (name, eid) => {
|
||||||
@ -96,7 +105,7 @@ const renameSubmit = (name, eid) => {
|
|||||||
url += `?${query}`;
|
url += `?${query}`;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'PUT',
|
||||||
url: url,
|
url: url,
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
@ -131,6 +140,7 @@ const edit = (eid) => {
|
|||||||
|
|
||||||
const displayNameField = $('#display-name-field');
|
const displayNameField = $('#display-name-field');
|
||||||
displayNameField.attr('value', displayName);
|
displayNameField.attr('value', displayName);
|
||||||
|
console.log(displayNameField);
|
||||||
displayNameField.keyup(event => {
|
displayNameField.keyup(event => {
|
||||||
if (event.keyCode === 13) {
|
if (event.keyCode === 13) {
|
||||||
renameSubmit(displayNameField.val(), eid);
|
renameSubmit(displayNameField.val(), eid);
|
||||||
@ -220,7 +230,7 @@ const bulkProgress = (action, el) => {
|
|||||||
const ids = selectedIDs();
|
const ids = selectedIDs();
|
||||||
const url = `${base_url}api/bulk_progress/${action}/${tid}`;
|
const url = `${base_url}api/bulk_progress/${action}/${tid}`;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'PUT',
|
||||||
url: url,
|
url: url,
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
function remove(username) {
|
const remove = (username) => {
|
||||||
$.post(base_url + 'api/admin/user/delete/' + username, function(data) {
|
$.ajax({
|
||||||
if (data.success) {
|
url: `${base_url}api/admin/user/delete/${username}`,
|
||||||
location.reload();
|
type: 'DELETE',
|
||||||
}
|
dataType: 'json'
|
||||||
else {
|
})
|
||||||
error = data.error;
|
.done(data => {
|
||||||
alert('danger', error);
|
if (data.success)
|
||||||
}
|
location.reload();
|
||||||
});
|
else
|
||||||
}
|
alert('danger', data.error);
|
||||||
|
})
|
||||||
|
.fail((jqXHR, status) => {
|
||||||
|
alert('danger', `Failed to delete the user. Error: [${jqXHR.status}] ${jqXHR.statusText}`);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
@ -140,6 +140,10 @@ class APIRouter < Router
|
|||||||
"error" => "string?",
|
"error" => "string?",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Koa.object "ids", {
|
||||||
|
"ids" => "$strAry",
|
||||||
|
}
|
||||||
|
|
||||||
Koa.describe "Returns a page in a manga entry"
|
Koa.describe "Returns a page in a manga entry"
|
||||||
Koa.path "tid", desc: "Title ID"
|
Koa.path "tid", desc: "Title ID"
|
||||||
Koa.path "eid", desc: "Entry ID"
|
Koa.path "eid", desc: "Entry ID"
|
||||||
@ -252,7 +256,7 @@ class APIRouter < Router
|
|||||||
Koa.describe "Deletes a user with `username`"
|
Koa.describe "Deletes a user with `username`"
|
||||||
Koa.tag "admin"
|
Koa.tag "admin"
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, ref: "$result"
|
||||||
post "/api/admin/user/delete/:username" do |env|
|
delete "/api/admin/user/delete/:username" do |env|
|
||||||
begin
|
begin
|
||||||
username = env.params.url["username"]
|
username = env.params.url["username"]
|
||||||
@context.storage.delete_user username
|
@context.storage.delete_user username
|
||||||
@ -279,7 +283,7 @@ class APIRouter < Router
|
|||||||
Koa.query "eid", desc: "Entry ID", required: false
|
Koa.query "eid", desc: "Entry ID", required: false
|
||||||
Koa.path "page", desc: "The new page number indicating the progress"
|
Koa.path "page", desc: "The new page number indicating the progress"
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, ref: "$result"
|
||||||
post "/api/progress/:tid/:page" do |env|
|
put "/api/progress/:tid/:page" do |env|
|
||||||
begin
|
begin
|
||||||
username = get_username env
|
username = get_username env
|
||||||
title = (@context.library.get_title env.params.url["tid"]).not_nil!
|
title = (@context.library.get_title env.params.url["tid"]).not_nil!
|
||||||
@ -309,9 +313,9 @@ class APIRouter < Router
|
|||||||
Koa.describe "Updates the reading progress of multiple entries in a title"
|
Koa.describe "Updates the reading progress of multiple entries in a title"
|
||||||
Koa.path "action", desc: "The action to perform. Can be either `read` or `unread`"
|
Koa.path "action", desc: "The action to perform. Can be either `read` or `unread`"
|
||||||
Koa.path "tid", desc: "Title ID"
|
Koa.path "tid", desc: "Title ID"
|
||||||
Koa.body ref: "$strAry", desc: "An array of entry IDs"
|
Koa.body ref: "$ids", desc: "An array of entry IDs"
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, ref: "$result"
|
||||||
post "/api/bulk_progress/:action/:tid" do |env|
|
put "/api/bulk_progress/:action/:tid" do |env|
|
||||||
begin
|
begin
|
||||||
username = get_username env
|
username = get_username env
|
||||||
title = (@context.library.get_title env.params.url["tid"]).not_nil!
|
title = (@context.library.get_title env.params.url["tid"]).not_nil!
|
||||||
@ -341,7 +345,7 @@ class APIRouter < Router
|
|||||||
Koa.query "eid", desc: "Entry ID", required: false
|
Koa.query "eid", desc: "Entry ID", required: false
|
||||||
Koa.path "name", desc: "The new display name"
|
Koa.path "name", desc: "The new display name"
|
||||||
Koa.response 200, ref: "$result"
|
Koa.response 200, ref: "$result"
|
||||||
post "/api/admin/display_name/:tid/:name" do |env|
|
put "/api/admin/display_name/:tid/:name" do |env|
|
||||||
begin
|
begin
|
||||||
title = (@context.library.get_title env.params.url["tid"])
|
title = (@context.library.get_title env.params.url["tid"])
|
||||||
.not_nil!
|
.not_nil!
|
||||||
@ -566,10 +570,10 @@ class APIRouter < Router
|
|||||||
Koa.tag "admin"
|
Koa.tag "admin"
|
||||||
Koa.body ref: "$pluginListBody"
|
Koa.body ref: "$pluginListBody"
|
||||||
Koa.response 200, ref: "$pluginList"
|
Koa.response 200, ref: "$pluginList"
|
||||||
post "/api/admin/plugin/list" do |env|
|
get "/api/admin/plugin/list" do |env|
|
||||||
begin
|
begin
|
||||||
query = env.params.json["query"].as String
|
query = env.params.query["query"].as String
|
||||||
plugin = Plugin.new env.params.json["plugin"].as String
|
plugin = Plugin.new env.params.query["plugin"].as String
|
||||||
|
|
||||||
json = plugin.list_chapters query
|
json = plugin.list_chapters query
|
||||||
chapters = json["chapters"]
|
chapters = json["chapters"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user