Post selected chapter JSON object to API, instead of just posting the

IDs
This commit is contained in:
Alex Ling 2020-02-26 17:45:37 +00:00
parent c33884ea29
commit d9d1dbc26f
2 changed files with 11 additions and 4 deletions

View File

@ -27,11 +27,17 @@ const download = () => {
const ids = selected.map((i, e) => { const ids = selected.map((i, e) => {
return $(e).find('td').first().text(); return $(e).find('td').first().text();
}).get(); }).get();
const chapters = globalChapters.filter(c => ids.indexOf(c.id));
console.log(ids); console.log(ids);
$.post('/api/admin/download', { $.ajax({
chapters: ids type: 'POST',
url: '/api/admin/mangadex/download',
data: JSON.stringify({chapters: chapters}),
contentType: "application/json",
dataType: 'json'
}) })
.done(() => { .done(data => {
console.log(data);
console.log('post succeed'); console.log('post succeed');
}) })
.fail((jqXHR, status) => { .fail((jqXHR, status) => {

View File

@ -53,7 +53,8 @@
<div class="uk-margin"> <div class="uk-margin">
<button class="uk-button uk-button-default" onclick="selectAll()">Select All</button> <button class="uk-button uk-button-default" onclick="selectAll()">Select All</button>
<button class="uk-button uk-button-default" onclick="unselect()">Clear Selections</button> <button class="uk-button uk-button-default" onclick="unselect()">Clear Selections</button>
<button class="uk-button uk-button-primary" onclick="download()">Download Selected</button> <button class="uk-button uk-button-primary" id="download-btn" onclick="download()">Download Selected</button>
<div id="download-spinner" uk-spinner class="uk-margin-left" hidden></div>
</div> </div>
<p class="uk-text-meta">Click on a table row to select the chapter. Drag your mouse over multiple rows to select them all. Hold Ctrl to make multiple non-adjacent selections.</p> <p class="uk-text-meta">Click on a table row to select the chapter. Drag your mouse over multiple rows to select them all. Hold Ctrl to make multiple non-adjacent selections.</p>
</div> </div>