-
Notifications
You must be signed in to change notification settings - Fork 878
Update Disk.js - add used/total GB info #9131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Add used / total GB disk space used info to Disk widget
|
I like it :) |
| const totalBytes = usedBytes + freeBytes; | ||
| const usedGB = this._formatGB(usedBytes); | ||
| const totalGB = this._formatGB(totalBytes); | ||
| return `(${usedGB}/${totalGB}) GB`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The () looks misplaced before the GB, may be better to just omit and free the space used by it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks the same as the memory widget, but I agree the parenthesis aren't useful. Then the memory widget would have to be adjusted (easily done).
| */ | ||
|
|
||
| _formatGB(bytes) { | ||
| return (bytes / (1000 * 1000 * 1000)).toFixed(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is too simplistic as it should adapt to k M G T...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of formatter could be added to the BaseWidget I think.
E.g. here is one the UI uses in multiple places.
core/src/opnsense/www/js/opnsense_ui.js
Line 37 in 5875c18
| function byteFormat(bytes, decimals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would make more sense. My reasoning was that storage for such a device would be within XX GB and XXX GB - but we know how that ends up :)

Add used / total GB disk space used info to Disk widget