mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-14 08:26:22 +00:00
Updated dashboard
Bulk deleting files and adding/removing selected files from album will no longer refresh the current view to the first page. It will now instead try to refresh the current page. There will be cases where the current page ends up empty (when bulk deleting or moving files from the current album), but I figured that isn't much of an issue when compared with the advantages.
This commit is contained in:
parent
4b7feb4c08
commit
c51365adb5
@ -444,6 +444,7 @@ uploadsController.processFilesForDisplay = async (req, res, files, existingFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
uploadsController.delete = async (req, res) => {
|
uploadsController.delete = async (req, res) => {
|
||||||
|
// TODO: Wrap utils.bulkDeleteFilesByIds() instead
|
||||||
const user = await utils.authorize(req, res)
|
const user = await utils.authorize(req, res)
|
||||||
if (!user) { return }
|
if (!user) { return }
|
||||||
const id = req.body.id
|
const id = req.body.id
|
||||||
|
@ -11,7 +11,11 @@ const panel = {
|
|||||||
selectAlbumContainer: undefined,
|
selectAlbumContainer: undefined,
|
||||||
checkboxes: undefined,
|
checkboxes: undefined,
|
||||||
lastSelected: undefined,
|
lastSelected: undefined,
|
||||||
albums: []
|
albums: [],
|
||||||
|
currentView: {
|
||||||
|
album: undefined,
|
||||||
|
page: undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
panel.preparePage = () => {
|
panel.preparePage = () => {
|
||||||
@ -135,12 +139,12 @@ panel.getUploads = (album, page, element) => {
|
|||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column is-hidden-mobile"></div>
|
<div class="column is-hidden-mobile"></div>
|
||||||
<div class="column" style="text-align: center">
|
<div class="column" style="text-align: center">
|
||||||
<a class="button is-small is-danger" title="List view" onclick="panel.setFilesView('list', ${album}, ${page}, this)">
|
<a class="button is-small is-danger" title="List view" onclick="panel.setFilesView('list', this)">
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<i class="icon-th-list"></i>
|
<i class="icon-th-list"></i>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<a class="button is-small is-danger" title="Thumbs view" onclick="panel.setFilesView('thumbs', ${album}, ${page}, this)">
|
<a class="button is-small is-danger" title="Thumbs view" onclick="panel.setFilesView('thumbs', this)">
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<i class="icon-th-large"></i>
|
<i class="icon-th-large"></i>
|
||||||
</span>
|
</span>
|
||||||
@ -152,12 +156,12 @@ panel.getUploads = (album, page, element) => {
|
|||||||
<i class="icon-cancel"></i>
|
<i class="icon-cancel"></i>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<a class="button is-small is-warning" title="Add selected files to album" onclick="panel.addSelectedFilesToAlbum(${album})">
|
<a class="button is-small is-warning" title="Add selected files to album" onclick="panel.addSelectedFilesToAlbum()">
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<i class="icon-plus"></i>
|
<i class="icon-plus"></i>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<a class="button is-small is-danger" title="Bulk delete" onclick="panel.deleteSelectedFiles(${album})">
|
<a class="button is-small is-danger" title="Bulk delete" onclick="panel.deleteSelectedFiles()">
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<i class="icon-trash"></i>
|
<i class="icon-trash"></i>
|
||||||
</span>
|
</span>
|
||||||
@ -207,12 +211,12 @@ panel.getUploads = (album, page, element) => {
|
|||||||
<i class="icon-clipboard-1"></i>
|
<i class="icon-clipboard-1"></i>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<a class="button is-small is-warning" title="Add to album" onclick="panel.addToAlbum([${file.id}], ${album})">
|
<a class="button is-small is-warning" title="Add to album" onclick="panel.addSingleFileToAlbum(${file.id})">
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<i class="icon-plus"></i>
|
<i class="icon-plus"></i>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<a class="button is-small is-danger" title="Delete file" onclick="panel.deleteFile(${file.id}, ${album}, ${page})">
|
<a class="button is-small is-danger" title="Delete file" onclick="panel.deleteFile(${file.id})">
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<i class="icon-trash"></i>
|
<i class="icon-trash"></i>
|
||||||
</span>
|
</span>
|
||||||
@ -286,12 +290,12 @@ panel.getUploads = (album, page, element) => {
|
|||||||
<i class="icon-clipboard-1"></i>
|
<i class="icon-clipboard-1"></i>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<a class="button is-small is-warning" title="Add to album" onclick="panel.addToAlbum([${file.id}])">
|
<a class="button is-small is-warning" title="Add to album" onclick="panel.addSingleFileToAlbum(${file.id})">
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<i class="icon-plus"></i>
|
<i class="icon-plus"></i>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<a class="button is-small is-danger" title="Delete file" onclick="panel.deleteFile(${file.id}, ${album}, ${page})">
|
<a class="button is-small is-danger" title="Delete file" onclick="panel.deleteFile(${file.id})">
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<i class="icon-trash"></i>
|
<i class="icon-trash"></i>
|
||||||
</span>
|
</span>
|
||||||
@ -309,16 +313,19 @@ panel.getUploads = (album, page, element) => {
|
|||||||
const selectAll = document.getElementById('selectAll')
|
const selectAll = document.getElementById('selectAll')
|
||||||
if (selectAll) { selectAll.checked = true }
|
if (selectAll) { selectAll.checked = true }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panel.currentView.album = album
|
||||||
|
panel.currentView.page = page
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
return swal('An error occurred!', 'There was an error with the request, please check the console for more information.', 'error')
|
return swal('An error occurred!', 'There was an error with the request, please check the console for more information.', 'error')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
panel.setFilesView = (view, album, page, element) => {
|
panel.setFilesView = (view, element) => {
|
||||||
localStorage.filesView = view
|
localStorage.filesView = view
|
||||||
panel.filesView = view
|
panel.filesView = view
|
||||||
panel.getUploads(album, page, element)
|
panel.getUploads(panel.currentView.album, panel.currentView.page, element)
|
||||||
}
|
}
|
||||||
|
|
||||||
panel.displayThumbnailModal = thumb => {
|
panel.displayThumbnailModal = thumb => {
|
||||||
@ -431,7 +438,8 @@ panel.clearSelection = async () => {
|
|||||||
return swal('Cleared selection!', `Unselected ${count} ${suffix}.`, 'success')
|
return swal('Cleared selection!', `Unselected ${count} ${suffix}.`, 'success')
|
||||||
}
|
}
|
||||||
|
|
||||||
panel.deleteFile = (id, album, page) => {
|
panel.deleteFile = id => {
|
||||||
|
// TODO: Share function with bulk delete, just like 'add selected files to album' and 'add single file to album'
|
||||||
swal({
|
swal({
|
||||||
title: 'Are you sure?',
|
title: 'Are you sure?',
|
||||||
text: 'You won\'t be able to recover the file!',
|
text: 'You won\'t be able to recover the file!',
|
||||||
@ -457,7 +465,7 @@ panel.deleteFile = (id, album, page) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
swal('Deleted!', 'The file has been deleted.', 'success')
|
swal('Deleted!', 'The file has been deleted.', 'success')
|
||||||
panel.getUploads(album, page)
|
panel.getUploads(panel.currentView.album, panel.currentView.page)
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
@ -466,7 +474,7 @@ panel.deleteFile = (id, album, page) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
panel.deleteSelectedFiles = async album => {
|
panel.deleteSelectedFiles = async () => {
|
||||||
const count = panel.selectedFiles.length
|
const count = panel.selectedFiles.length
|
||||||
if (!count) {
|
if (!count) {
|
||||||
return swal('An error occurred!', 'You have not selected any files.', 'error')
|
return swal('An error occurred!', 'You have not selected any files.', 'error')
|
||||||
@ -516,16 +524,16 @@ panel.deleteSelectedFiles = async album => {
|
|||||||
localStorage.selectedFiles = JSON.stringify(panel.selectedFiles)
|
localStorage.selectedFiles = JSON.stringify(panel.selectedFiles)
|
||||||
|
|
||||||
swal('Deleted!', `${deleted} file${deleted === 1 ? ' has' : 's have'} been deleted.`, 'success')
|
swal('Deleted!', `${deleted} file${deleted === 1 ? ' has' : 's have'} been deleted.`, 'success')
|
||||||
return panel.getUploads(album)
|
return panel.getUploads(panel.currentView.album, panel.currentView.page)
|
||||||
}
|
}
|
||||||
|
|
||||||
panel.addSelectedFilesToAlbum = async album => {
|
panel.addSelectedFilesToAlbum = async () => {
|
||||||
const count = panel.selectedFiles.length
|
const count = panel.selectedFiles.length
|
||||||
if (!count) {
|
if (!count) {
|
||||||
return swal('An error occurred!', 'You have not selected any files.', 'error')
|
return swal('An error occurred!', 'You have not selected any files.', 'error')
|
||||||
}
|
}
|
||||||
|
|
||||||
const failedids = await panel.addToAlbum(panel.selectedFiles, album)
|
const failedids = await panel.addFilesToAlbum(panel.selectedFiles)
|
||||||
if (!failedids) { return }
|
if (!failedids) { return }
|
||||||
if (failedids.length) {
|
if (failedids.length) {
|
||||||
panel.selectedFiles = panel.selectedFiles.filter(id => failedids.includes(id))
|
panel.selectedFiles = panel.selectedFiles.filter(id => failedids.includes(id))
|
||||||
@ -533,9 +541,16 @@ panel.addSelectedFilesToAlbum = async album => {
|
|||||||
panel.selectedFiles = []
|
panel.selectedFiles = []
|
||||||
}
|
}
|
||||||
localStorage.selectedFiles = JSON.stringify(panel.selectedFiles)
|
localStorage.selectedFiles = JSON.stringify(panel.selectedFiles)
|
||||||
|
panel.getUploads(panel.currentView.album, panel.currentView.page)
|
||||||
}
|
}
|
||||||
|
|
||||||
panel.addToAlbum = async (ids, album) => {
|
panel.addSingleFileToAlbum = async id => {
|
||||||
|
const failedids = await panel.addFilesToAlbum([id])
|
||||||
|
if (!failedids) { return }
|
||||||
|
panel.getUploads(panel.currentView.album, panel.currentView.page)
|
||||||
|
}
|
||||||
|
|
||||||
|
panel.addFilesToAlbum = async ids => {
|
||||||
const count = ids.length
|
const count = ids.length
|
||||||
const proceed = await swal({
|
const proceed = await swal({
|
||||||
title: 'Are you sure?',
|
title: 'Are you sure?',
|
||||||
@ -636,7 +651,6 @@ panel.addToAlbum = async (ids, album) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
swal('Woohoo!', `Successfully ${albumid < 0 ? 'removed' : 'added'} ${added} ${suffix} ${albumid < 0 ? 'from' : 'to'} the album.`, 'success')
|
swal('Woohoo!', `Successfully ${albumid < 0 ? 'removed' : 'added'} ${added} ${suffix} ${albumid < 0 ? 'from' : 'to'} the album.`, 'success')
|
||||||
panel.getUploads(album)
|
|
||||||
return add.data.failedids
|
return add.data.failedids
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
v1: CSS and JS files.
|
v1: CSS and JS files.
|
||||||
v2: Images and config files (manifest.json, browserconfig.xml, etcetera).
|
v2: Images and config files (manifest.json, browserconfig.xml, etcetera).
|
||||||
#}
|
#}
|
||||||
{% set v1 = "cDnmwkVVmk" %}
|
{% set v1 = "vixJhF5oKZ" %}
|
||||||
{% set v2 = "MSEpgpfFIQ" %}
|
{% set v2 = "MSEpgpfFIQ" %}
|
||||||
|
|
||||||
{#
|
{#
|
||||||
|
Loading…
Reference in New Issue
Block a user