mirror of
https://github.com/goharbor/harbor
synced 2025-05-10 09:24:12 +00:00
Change quota unit to Mebibyte (#15220)
Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
parent
ff11cbafa1
commit
f902db9d85
@ -87,23 +87,23 @@ export const QuotaUnits = [
|
||||
UNIT: "Byte",
|
||||
},
|
||||
{
|
||||
UNIT: "KB",
|
||||
UNIT: "KiB",
|
||||
},
|
||||
{
|
||||
UNIT: "MB",
|
||||
UNIT: "MiB",
|
||||
},
|
||||
{
|
||||
UNIT: "GB",
|
||||
UNIT: "GiB",
|
||||
},
|
||||
{
|
||||
UNIT: "TB",
|
||||
UNIT: "TiB",
|
||||
},
|
||||
];
|
||||
export const QuotaUnlimited = -1;
|
||||
export const StorageMultipleConstant = 1024;
|
||||
export const LimitCount = 100000000;
|
||||
export enum QuotaUnit {
|
||||
TB = "TB", GB = "GB", MB = "MB", KB = "KB", BIT = "Byte"
|
||||
TB = "TiB", GB = "GiB", MB = "MiB", KB = "KiB", BIT = "Byte"
|
||||
}
|
||||
export enum QuotaProgress {
|
||||
COUNT_USED = "COUNT_USED", COUNT_HARD = "COUNT_HARD", STROAGE_USED = "STORAGE_USED", STORAGE_HARD = "STORAGE_HARD"
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { delUrlParam, getQueryString, getSizeNumber, getSizeUnit, getSortingString, isSameArrayValue, isSameObject } from "./utils";
|
||||
import { ClrDatagridStateInterface } from "@clr/angular";
|
||||
import {QuotaUnit} from "../entities/shared.const";
|
||||
|
||||
describe('functions in utils.ts should work', () => {
|
||||
it('function isSameArrayValue() should work', () => {
|
||||
@ -60,15 +61,15 @@ describe('functions in utils.ts should work', () => {
|
||||
expect(getSizeNumber(10)).toEqual(10);
|
||||
expect(getSizeNumber(456400)).toEqual('445.70');
|
||||
expect(getSizeNumber(45640000)).toEqual('43.53');
|
||||
expect(getSizeNumber(4564000000000)).toEqual('4.15');
|
||||
expect(getSizeNumber(4564000000000)).toEqual('4.15');
|
||||
});
|
||||
|
||||
it('function getSizeUnit() should work', () => {
|
||||
expect(getSizeUnit).toBeTruthy();
|
||||
expect(getSizeUnit(4564)).toEqual('KiB');
|
||||
expect(getSizeUnit(10)).toEqual('Byte');
|
||||
expect(getSizeUnit(4564000)).toEqual('MiB');
|
||||
expect(getSizeUnit(4564000000)).toEqual('GiB');
|
||||
expect(getSizeUnit(4564000000000)).toEqual('TiB');
|
||||
expect(getSizeUnit(4564)).toEqual(QuotaUnit.KB);
|
||||
expect(getSizeUnit(10)).toEqual(QuotaUnit.BIT);
|
||||
expect(getSizeUnit(4564000)).toEqual(QuotaUnit.MB);
|
||||
expect(getSizeUnit(4564000000)).toEqual(QuotaUnit.GB);
|
||||
expect(getSizeUnit(4564000000000)).toEqual(QuotaUnit.TB);
|
||||
});
|
||||
});
|
||||
|
@ -3,7 +3,7 @@ import { HttpHeaders } from '@angular/common/http';
|
||||
import { RequestQueryParams } from '../services';
|
||||
import { DebugElement } from '@angular/core';
|
||||
import { Comparator, State, HttpOptionInterface, HttpOptionTextInterface, QuotaUnitInterface } from '../services';
|
||||
import { QuotaUnits, StorageMultipleConstant } from '../entities/shared.const';
|
||||
import {QuotaUnit, QuotaUnits, StorageMultipleConstant} from '../entities/shared.const';
|
||||
import { AbstractControl } from "@angular/forms";
|
||||
import { isValidCron } from 'cron-validator';
|
||||
import { ClrDatagridStateInterface } from "@clr/angular";
|
||||
@ -567,14 +567,14 @@ export const validateLimit = unitContrl => {
|
||||
};
|
||||
|
||||
export function formatSize(tagSize: string): string {
|
||||
let size: number = Number.parseInt(tagSize);
|
||||
const size: number = Number.parseInt(tagSize);
|
||||
if (Math.pow(1024, 1) <= size && size < Math.pow(1024, 2)) {
|
||||
return (size / Math.pow(1024, 1)).toFixed(2) + "KiB";
|
||||
} else if (Math.pow(1024, 2) <= size && size < Math.pow(1024, 3)) {
|
||||
return (size / Math.pow(1024, 2)).toFixed(2) + "MiB";
|
||||
} else if (Math.pow(1024, 3) <= size && size < Math.pow(1024, 4)) {
|
||||
return (size / Math.pow(1024, 3)).toFixed(2) + "GiB";
|
||||
} else if (Math.pow(1024, 4) <= size && size < Math.pow(1024, 5)) {
|
||||
} else if (Math.pow(1024, 4) <= size) {
|
||||
return (size / Math.pow(1024, 4)).toFixed(2) + "TiB";
|
||||
} else {
|
||||
return size + "B";
|
||||
@ -592,7 +592,7 @@ export function getSizeNumber(size: number): string | number {
|
||||
return (size / Math.pow(1024, 2)).toFixed(2);
|
||||
} else if (Math.pow(1024, 3) <= size && size < Math.pow(1024, 4)) {
|
||||
return (size / Math.pow(1024, 3)).toFixed(2);
|
||||
} else if (Math.pow(1024, 4) <= size && size < Math.pow(1024, 5)) {
|
||||
} else if (Math.pow(1024, 4) <= size) {
|
||||
return (size / Math.pow(1024, 4)).toFixed(2);
|
||||
} else {
|
||||
return size;
|
||||
@ -605,15 +605,15 @@ export function getSizeNumber(size: number): string | number {
|
||||
*/
|
||||
export function getSizeUnit(size: number): string {
|
||||
if (Math.pow(1024, 1) <= size && size < Math.pow(1024, 2)) {
|
||||
return "KiB";
|
||||
return QuotaUnit.KB;
|
||||
} else if (Math.pow(1024, 2) <= size && size < Math.pow(1024, 3)) {
|
||||
return "MiB";
|
||||
return QuotaUnit.MB;
|
||||
} else if (Math.pow(1024, 3) <= size && size < Math.pow(1024, 4)) {
|
||||
return "GiB";
|
||||
} else if (Math.pow(1024, 4) <= size && size < Math.pow(1024, 5)) {
|
||||
return "TiB";
|
||||
return QuotaUnit.GB;
|
||||
} else if (Math.pow(1024, 4) <= size) {
|
||||
return QuotaUnit.TB;
|
||||
} else {
|
||||
return "Byte";
|
||||
return QuotaUnit.BIT;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user