mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 03:15:31 -04:00
Make the selection and download buttons on the download page functional
This commit is contained in:
parent
d782995bac
commit
9f6261e02d
@ -10,6 +10,35 @@ $(() => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
const selectAll = () => {
|
||||||
|
$('tbody > tr').each((i, e) => {
|
||||||
|
$(e).addClass('ui-selected');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const unselect = () => {
|
||||||
|
$('tbody > tr').each((i, e) => {
|
||||||
|
$(e).removeClass('ui-selected');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const download = () => {
|
||||||
|
const selected = $('tbody > tr.ui-selected');
|
||||||
|
if (selected.length === 0) return;
|
||||||
|
UIkit.modal.confirm(`Download ${selected.length} selected chapters?`).then(() => {
|
||||||
|
const ids = selected.map((i, e) => {
|
||||||
|
return $(e).find('td').first().text();
|
||||||
|
}).get();
|
||||||
|
console.log(ids);
|
||||||
|
$.post('/api/admin/download', {
|
||||||
|
chapters: ids
|
||||||
|
})
|
||||||
|
.done(() => {
|
||||||
|
console.log('post succeed');
|
||||||
|
})
|
||||||
|
.fail((jqXHR, status) => {
|
||||||
|
alert('danger', `Failed to add chapters to the download queue. Error: [${jqXHR.status}] ${jqXHR.statusText}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
const toggleSpinner = () => {
|
const toggleSpinner = () => {
|
||||||
var attr = $('#spinner').attr('hidden');
|
var attr = $('#spinner').attr('hidden');
|
||||||
if (attr) {
|
if (attr) {
|
||||||
@ -111,7 +140,7 @@ const search = () => {
|
|||||||
buildTable();
|
buildTable();
|
||||||
})
|
})
|
||||||
.fail((jqXHR, status) => {
|
.fail((jqXHR, status) => {
|
||||||
alert('danger', 'Failed to get manga info. Error: ' + status);
|
alert('danger', `Failed to get manga info. Error: [${jqXHR.status}] ${jqXHR.statusText}`);
|
||||||
})
|
})
|
||||||
.always(() => {
|
.always(() => {
|
||||||
toggleSpinner();
|
toggleSpinner();
|
||||||
@ -241,8 +270,7 @@ const buildTable = () => {
|
|||||||
$('table').append(tbody);
|
$('table').append(tbody);
|
||||||
$('table').removeAttr('hidden');
|
$('table').removeAttr('hidden');
|
||||||
$("#selectable").selectable({
|
$("#selectable").selectable({
|
||||||
filter: 'tr',
|
filter: 'tr'
|
||||||
autoRefresh: false
|
|
||||||
});
|
});
|
||||||
$('#selection-controls').removeAttr('hidden');
|
$('#selection-controls').removeAttr('hidden');
|
||||||
};
|
};
|
||||||
|
@ -51,9 +51,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="selection-controls" class="uk-margin" hidden>
|
<div id="selection-controls" class="uk-margin" hidden>
|
||||||
<div class="uk-margin">
|
<div class="uk-margin">
|
||||||
<button class="uk-button uk-button-default">Select All</button>
|
<button class="uk-button uk-button-default" onclick="selectAll()">Select All</button>
|
||||||
<button class="uk-button uk-button-default">Clear Selections</button>
|
<button class="uk-button uk-button-default" onclick="unselect()">Clear Selections</button>
|
||||||
<button class="uk-button uk-button-primary">Download Selected</button>
|
<button class="uk-button uk-button-primary" onclick="download()">Download Selected</button>
|
||||||
</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>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user