mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-31 15:21:33 +00:00
Updated
Better 'df' handling (check the TODO entry for more details). Simplified a few lines in dashboard.js. Bumped v1 version string.
This commit is contained in:
parent
d5cd5b7b5b
commit
3d09df501d
2
TODO.md
2
TODO.md
@ -6,7 +6,7 @@ Normal priority:
|
|||||||
* [x] Use [native lazy-load tag](https://web.dev/native-lazy-loading) on nojs album pages.
|
* [x] Use [native lazy-load tag](https://web.dev/native-lazy-loading) on nojs album pages.
|
||||||
* [x] Use incremental version numbering instead of randomized strings.
|
* [x] Use incremental version numbering instead of randomized strings.
|
||||||
* [ ] Use versioning in /api/check. To elaborate, make it so that when a version string reported by server is higher than expected, force user to reload the page (which should be all that is needed for users to be loading latest front-end assets). Possibly also use it in /api/tokens/verify, for dashboard page.
|
* [ ] Use versioning in /api/check. To elaborate, make it so that when a version string reported by server is higher than expected, force user to reload the page (which should be all that is needed for users to be loading latest front-end assets). Possibly also use it in /api/tokens/verify, for dashboard page.
|
||||||
* [ ] Better `df` handling (system disk stats). To elaborate, either properly show disk usages of directories that have sub-directories, or only show disk usages of whitelisted directories (thumbs, chunks, etc).
|
* [x] Better `df` handling (system disk stats). To elaborate, either properly show disk usages of directories that have sub-directories, or only show disk usages of whitelisted directories (thumbs, chunks, etc).
|
||||||
* [x] Use loading spinners on dashboard's sidebar menus.
|
* [x] Use loading spinners on dashboard's sidebar menus.
|
||||||
* [x] Disable all other sidebar menus when a menu is still loading.
|
* [x] Disable all other sidebar menus when a menu is still loading.
|
||||||
* [ ] Collapsible dashboard's sidebar albums menus.
|
* [ ] Collapsible dashboard's sidebar albums menus.
|
||||||
|
@ -579,20 +579,22 @@ self.stats = async (req, res, next) => {
|
|||||||
} else {
|
} else {
|
||||||
statsCache.disk.generating = true
|
statsCache.disk.generating = true
|
||||||
|
|
||||||
// We pre-assign the keys below to guarantee their order
|
|
||||||
stats.disk = {
|
stats.disk = {
|
||||||
_types: {
|
_types: {
|
||||||
byte: ['uploads', 'thumbs', 'zips', 'chunks'],
|
byte: ['uploads', 'thumbs', 'zips', 'chunks'],
|
||||||
byteUsage: ['drive']
|
byteUsage: ['drive']
|
||||||
},
|
},
|
||||||
drive: null,
|
drive: null,
|
||||||
|
// We pre-assign the keys below to fix their order
|
||||||
uploads: 0,
|
uploads: 0,
|
||||||
thumbs: 0,
|
thumbs: 0,
|
||||||
zips: 0,
|
zips: 0,
|
||||||
chunks: 0
|
chunks: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get size of directories in uploads path
|
const subdirs = []
|
||||||
|
|
||||||
|
// Get size of uploads path (excluding sub-directories)
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
const proc = spawn('du', [
|
const proc = spawn('du', [
|
||||||
'--apparent-size',
|
'--apparent-size',
|
||||||
@ -603,6 +605,42 @@ self.stats = async (req, res, next) => {
|
|||||||
paths.uploads
|
paths.uploads
|
||||||
])
|
])
|
||||||
|
|
||||||
|
proc.stdout.on('data', data => {
|
||||||
|
const formatted = String(data)
|
||||||
|
.trim()
|
||||||
|
.split(/\s+/)
|
||||||
|
for (let i = 0; i < formatted.length; i += 2) {
|
||||||
|
const path = formatted[i + 1]
|
||||||
|
if (!path) return
|
||||||
|
|
||||||
|
if (path !== paths.uploads) {
|
||||||
|
subdirs.push(path)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
stats.disk.uploads = parseInt(formatted[i])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const stderr = []
|
||||||
|
proc.stderr.on('data', data => stderr.push(data))
|
||||||
|
|
||||||
|
proc.on('exit', code => {
|
||||||
|
if (code !== 0) return reject(stderr)
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
await Promise.all(subdirs.map(subdir => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const proc = spawn('du', [
|
||||||
|
'--apparent-size',
|
||||||
|
'--block-size=1',
|
||||||
|
'--dereference',
|
||||||
|
'--summarize',
|
||||||
|
subdir
|
||||||
|
])
|
||||||
|
|
||||||
proc.stdout.on('data', data => {
|
proc.stdout.on('data', data => {
|
||||||
const formatted = String(data)
|
const formatted = String(data)
|
||||||
.trim()
|
.trim()
|
||||||
@ -625,6 +663,7 @@ self.stats = async (req, res, next) => {
|
|||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
}))
|
||||||
|
|
||||||
// Get disk usage of whichever disk uploads path resides on
|
// Get disk usage of whichever disk uploads path resides on
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
|
2
dist/js/dashboard.js
vendored
2
dist/js/dashboard.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/dashboard.js.map
vendored
2
dist/js/dashboard.js.map
vendored
File diff suppressed because one or more lines are too long
@ -353,8 +353,6 @@ page.fadeAndScroll = disableFading => {
|
|||||||
page.dom.classList.remove('fade-in')
|
page.dom.classList.remove('fade-in')
|
||||||
}
|
}
|
||||||
|
|
||||||
const behavior = disableFading ? 'auto' : 'smooth'
|
|
||||||
|
|
||||||
if (!disableFading) {
|
if (!disableFading) {
|
||||||
page.dom.classList.add('fade-in')
|
page.dom.classList.add('fade-in')
|
||||||
page.fadingIn = setTimeout(() => {
|
page.fadingIn = setTimeout(() => {
|
||||||
@ -363,7 +361,7 @@ page.fadeAndScroll = disableFading => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
page.dom.scrollIntoView({
|
page.dom.scrollIntoView({
|
||||||
behavior,
|
behavior: disableFading ? 'auto' : 'smooth',
|
||||||
block: 'start',
|
block: 'start',
|
||||||
inline: 'nearest'
|
inline: 'nearest'
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"1": "1573625966",
|
"1": "1573682741",
|
||||||
"2": "1568894058",
|
"2": "1568894058",
|
||||||
"3": "1568894058",
|
"3": "1568894058",
|
||||||
"4": "1568894058",
|
"4": "1568894058",
|
||||||
|
Loading…
Reference in New Issue
Block a user