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)
|
||||
return;
|
||||
|
||||
const query = $('#search-input').val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: base_url + 'api/admin/plugin/list',
|
||||
data: JSON.stringify({
|
||||
query: query,
|
||||
const query = $.param({
|
||||
query: $('#search-input').val(),
|
||||
plugin: pid
|
||||
}),
|
||||
});
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: `${base_url}api/admin/plugin/list?${query}`,
|
||||
contentType: "application/json",
|
||||
dataType: 'json'
|
||||
})
|
||||
|
@ -220,14 +220,18 @@ const saveProgress = (idx, cb) => {
|
||||
console.log('saving progress', idx);
|
||||
|
||||
const url = `${base_url}api/progress/${tid}/${idx}?${$.param({eid: eid})}`;
|
||||
$.post(url)
|
||||
.then(data => {
|
||||
if (data.error) throw new Error(data.error);
|
||||
$.ajax({
|
||||
method: 'PUT',
|
||||
url: url,
|
||||
dataType: 'json'
|
||||
})
|
||||
.done(data => {
|
||||
if (data.error)
|
||||
alert('danger', data.error);
|
||||
if (cb) cb();
|
||||
})
|
||||
.catch(e => {
|
||||
console.error(e);
|
||||
alert('danger', e);
|
||||
.fail((jqXHR, status) => {
|
||||
alert('danger', `Error: [${jqXHR.status}] ${jqXHR.statusText}`);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -67,13 +67,22 @@ const updateProgress = (tid, eid, page) => {
|
||||
});
|
||||
if (eid)
|
||||
url += `?${query}`;
|
||||
$.post(url, (data) => {
|
||||
|
||||
$.ajax({
|
||||
method: 'PUT',
|
||||
url: url,
|
||||
dataType: 'json'
|
||||
})
|
||||
.done(data => {
|
||||
if (data.success) {
|
||||
location.reload();
|
||||
} else {
|
||||
error = data.error;
|
||||
alert('danger', error);
|
||||
}
|
||||
})
|
||||
.fail((jqXHR, status) => {
|
||||
alert('danger', `Error: [${jqXHR.status}] ${jqXHR.statusText}`);
|
||||
});
|
||||
};
|
||||
|
||||
@ -96,7 +105,7 @@ const renameSubmit = (name, eid) => {
|
||||
url += `?${query}`;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
type: 'PUT',
|
||||
url: url,
|
||||
contentType: "application/json",
|
||||
dataType: 'json'
|
||||
@ -131,6 +140,7 @@ const edit = (eid) => {
|
||||
|
||||
const displayNameField = $('#display-name-field');
|
||||
displayNameField.attr('value', displayName);
|
||||
console.log(displayNameField);
|
||||
displayNameField.keyup(event => {
|
||||
if (event.keyCode === 13) {
|
||||
renameSubmit(displayNameField.val(), eid);
|
||||
@ -220,7 +230,7 @@ const bulkProgress = (action, el) => {
|
||||
const ids = selectedIDs();
|
||||
const url = `${base_url}api/bulk_progress/${action}/${tid}`;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
type: 'PUT',
|
||||
url: url,
|
||||
contentType: "application/json",
|
||||
dataType: 'json',
|
||||
|
@ -1,11 +1,16 @@
|
||||
function remove(username) {
|
||||
$.post(base_url + 'api/admin/user/delete/' + username, function(data) {
|
||||
if (data.success) {
|
||||
const remove = (username) => {
|
||||
$.ajax({
|
||||
url: `${base_url}api/admin/user/delete/${username}`,
|
||||
type: 'DELETE',
|
||||
dataType: 'json'
|
||||
})
|
||||
.done(data => {
|
||||
if (data.success)
|
||||
location.reload();
|
||||
}
|
||||
else {
|
||||
error = data.error;
|
||||
alert('danger', error);
|
||||
}
|
||||
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?",
|
||||
}
|
||||
|
||||
Koa.object "ids", {
|
||||
"ids" => "$strAry",
|
||||
}
|
||||
|
||||
Koa.describe "Returns a page in a manga entry"
|
||||
Koa.path "tid", desc: "Title ID"
|
||||
Koa.path "eid", desc: "Entry ID"
|
||||
@ -252,7 +256,7 @@ class APIRouter < Router
|
||||
Koa.describe "Deletes a user with `username`"
|
||||
Koa.tag "admin"
|
||||
Koa.response 200, ref: "$result"
|
||||
post "/api/admin/user/delete/:username" do |env|
|
||||
delete "/api/admin/user/delete/:username" do |env|
|
||||
begin
|
||||
username = env.params.url["username"]
|
||||
@context.storage.delete_user username
|
||||
@ -279,7 +283,7 @@ class APIRouter < Router
|
||||
Koa.query "eid", desc: "Entry ID", required: false
|
||||
Koa.path "page", desc: "The new page number indicating the progress"
|
||||
Koa.response 200, ref: "$result"
|
||||
post "/api/progress/:tid/:page" do |env|
|
||||
put "/api/progress/:tid/:page" do |env|
|
||||
begin
|
||||
username = get_username env
|
||||
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.path "action", desc: "The action to perform. Can be either `read` or `unread`"
|
||||
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"
|
||||
post "/api/bulk_progress/:action/:tid" do |env|
|
||||
put "/api/bulk_progress/:action/:tid" do |env|
|
||||
begin
|
||||
username = get_username env
|
||||
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.path "name", desc: "The new display name"
|
||||
Koa.response 200, ref: "$result"
|
||||
post "/api/admin/display_name/:tid/:name" do |env|
|
||||
put "/api/admin/display_name/:tid/:name" do |env|
|
||||
begin
|
||||
title = (@context.library.get_title env.params.url["tid"])
|
||||
.not_nil!
|
||||
@ -566,10 +570,10 @@ class APIRouter < Router
|
||||
Koa.tag "admin"
|
||||
Koa.body ref: "$pluginListBody"
|
||||
Koa.response 200, ref: "$pluginList"
|
||||
post "/api/admin/plugin/list" do |env|
|
||||
get "/api/admin/plugin/list" do |env|
|
||||
begin
|
||||
query = env.params.json["query"].as String
|
||||
plugin = Plugin.new env.params.json["plugin"].as String
|
||||
query = env.params.query["query"].as String
|
||||
plugin = Plugin.new env.params.query["plugin"].as String
|
||||
|
||||
json = plugin.list_chapters query
|
||||
chapters = json["chapters"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user