mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 22:39:41 +02:00
refactor(app): backport technical changes (#4679)
* refactor(app): backport technical changes * refactor(app): remove EE only features * feat(app): small review changes to match EE codebase layout on some files Co-authored-by: xAt0mZ <baron_l@epitech.eu>
This commit is contained in:
parent
158bdae10e
commit
ccf6babc02
40 changed files with 951 additions and 976 deletions
|
@ -4,6 +4,28 @@ class KubernetesResourceQuotaHelper {
|
|||
static generateResourceQuotaName(name) {
|
||||
return KubernetesPortainerResourceQuotaPrefix + name;
|
||||
}
|
||||
|
||||
static formatBytes(bytes, decimals = 0, base10 = true) {
|
||||
const res = {
|
||||
Size: 0,
|
||||
SizeUnit: 'B',
|
||||
};
|
||||
|
||||
if (bytes === 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
const k = base10 ? 1000 : 1024;
|
||||
const dm = decimals < 0 ? 0 : decimals;
|
||||
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
|
||||
return {
|
||||
Size: parseFloat((bytes / Math.pow(k, i)).toFixed(dm)),
|
||||
SizeUnit: sizes[i],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default KubernetesResourceQuotaHelper;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue