mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-19 01:31:34 +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 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.
|
||||
* [ ] 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] Disable all other sidebar menus when a menu is still loading.
|
||||
* [ ] Collapsible dashboard's sidebar albums menus.
|
||||
|
@ -579,20 +579,22 @@ self.stats = async (req, res, next) => {
|
||||
} else {
|
||||
statsCache.disk.generating = true
|
||||
|
||||
// We pre-assign the keys below to guarantee their order
|
||||
stats.disk = {
|
||||
_types: {
|
||||
byte: ['uploads', 'thumbs', 'zips', 'chunks'],
|
||||
byteUsage: ['drive']
|
||||
},
|
||||
drive: null,
|
||||
// We pre-assign the keys below to fix their order
|
||||
uploads: 0,
|
||||
thumbs: 0,
|
||||
zips: 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) => {
|
||||
const proc = spawn('du', [
|
||||
'--apparent-size',
|
||||
@ -607,14 +609,17 @@ self.stats = async (req, res, next) => {
|
||||
const formatted = String(data)
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
if (formatted.length !== 2) return
|
||||
for (let i = 0; i < formatted.length; i += 2) {
|
||||
const path = formatted[i + 1]
|
||||
if (!path) return
|
||||
|
||||
const basename = path.basename(formatted[1])
|
||||
stats.disk[basename] = parseInt(formatted[0])
|
||||
if (path !== paths.uploads) {
|
||||
subdirs.push(path)
|
||||
continue
|
||||
}
|
||||
|
||||
// Add to types if necessary
|
||||
if (!stats.disk._types.byte.includes(basename))
|
||||
stats.disk._types.byte.push(basename)
|
||||
stats.disk.uploads = parseInt(formatted[i])
|
||||
}
|
||||
})
|
||||
|
||||
const stderr = []
|
||||
@ -626,6 +631,40 @@ self.stats = async (req, res, next) => {
|
||||
})
|
||||
})
|
||||
|
||||
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 => {
|
||||
const formatted = String(data)
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
if (formatted.length !== 2) return
|
||||
|
||||
const basename = path.basename(formatted[1])
|
||||
stats.disk[basename] = parseInt(formatted[0])
|
||||
|
||||
// Add to types if necessary
|
||||
if (!stats.disk._types.byte.includes(basename))
|
||||
stats.disk._types.byte.push(basename)
|
||||
})
|
||||
|
||||
const stderr = []
|
||||
proc.stderr.on('data', data => stderr.push(data))
|
||||
|
||||
proc.on('exit', code => {
|
||||
if (code !== 0) return reject(stderr)
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}))
|
||||
|
||||
// Get disk usage of whichever disk uploads path resides on
|
||||
await new Promise((resolve, reject) => {
|
||||
const proc = spawn('df', [
|
||||
|
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')
|
||||
}
|
||||
|
||||
const behavior = disableFading ? 'auto' : 'smooth'
|
||||
|
||||
if (!disableFading) {
|
||||
page.dom.classList.add('fade-in')
|
||||
page.fadingIn = setTimeout(() => {
|
||||
@ -363,7 +361,7 @@ page.fadeAndScroll = disableFading => {
|
||||
}
|
||||
|
||||
page.dom.scrollIntoView({
|
||||
behavior,
|
||||
behavior: disableFading ? 'auto' : 'smooth',
|
||||
block: 'start',
|
||||
inline: 'nearest'
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"1": "1573625966",
|
||||
"1": "1573682741",
|
||||
"2": "1568894058",
|
||||
"3": "1568894058",
|
||||
"4": "1568894058",
|
||||
|
Loading…
Reference in New Issue
Block a user