From 15b687bb0134f9d69c66d171c1fe856ddaa54a6e Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Thu, 29 Apr 2021 15:04:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9TB=E3=80=81PB=E3=80=81EB?= =?UTF-8?q?=E7=9A=84=E6=9C=89=E4=BA=9B=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/utils/numberutils/utils.go | 12 ++++++++++-- .../web/actions/default/clusters/regions/prices.go | 4 +++- .../@default/clusters/regions/items/createPopup.js | 4 ++++ .../@default/clusters/regions/items/updatePopup.js | 4 ++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/internal/utils/numberutils/utils.go b/internal/utils/numberutils/utils.go index 1454a180..71bfd4ed 100644 --- a/internal/utils/numberutils/utils.go +++ b/internal/utils/numberutils/utils.go @@ -22,8 +22,12 @@ func FormatBytes(bytes int64) string { return fmt.Sprintf("%.2fMB", float64(bytes)/1024/1024) } else if bytes < 1024*1024*1024*1024 { return fmt.Sprintf("%.2fGB", float64(bytes)/1024/1024/1024) + } else if bytes < 1024*1024*1024*1024*1024 { + return fmt.Sprintf("%.2fTB", float64(bytes)/1024/1024/1024/1024) + } else if bytes < 1024*1024*1024*1024*1024*1024 { + return fmt.Sprintf("%.2fPB", float64(bytes)/1024/1024/1024/1024/1024) } else { - return fmt.Sprintf("%.2fPB", float64(bytes)/1024/1024/1024/1024) + return fmt.Sprintf("%.2fEB", float64(bytes)/1024/1024/1024/1024/1024/1024) } } @@ -36,7 +40,11 @@ func FormatBits(bits int64) string { return fmt.Sprintf("%.2fMB", float64(bits)/1000/1000) } else if bits < 1000*1000*1000*1000 { return fmt.Sprintf("%.2fGB", float64(bits)/1000/1000/1000) + } else if bits < 1000*1000*1000*1000*1000 { + return fmt.Sprintf("%.2fTB", float64(bits)/1000/1000/1000/1000) + } else if bits < 1000*1000*1000*1000*1000*1000 { + return fmt.Sprintf("%.2fPB", float64(bits)/1000/1000/1000/1000/1000) } else { - return fmt.Sprintf("%.2fPB", float64(bits)/1000/1000/1000/1000) + return fmt.Sprintf("%.2fEB", float64(bits)/1000/1000/1000/1000/1000/1000) } } diff --git a/internal/web/actions/default/clusters/regions/prices.go b/internal/web/actions/default/clusters/regions/prices.go index 9c87f09b..ea8e8c93 100644 --- a/internal/web/actions/default/clusters/regions/prices.go +++ b/internal/web/actions/default/clusters/regions/prices.go @@ -77,8 +77,10 @@ func (this *PricesAction) formatBits(bits int64) string { sizeHuman = fmt.Sprintf("%.2fGBPS", float64(bits)/1000/1000/1000) } else if bits < 1_000_000_000_000_000 { sizeHuman = fmt.Sprintf("%.2fTBPS", float64(bits)/1000/1000/1000/1000) - } else { + } else if bits < 1_000_000_000_000_000_000 { sizeHuman = fmt.Sprintf("%.2fPBPS", float64(bits)/1000/1000/1000/1000/1000) + } else { + sizeHuman = fmt.Sprintf("%.2fEBPS", float64(bits)/1000/1000/1000/1000/1000/1000) } return sizeHuman } diff --git a/web/views/@default/clusters/regions/items/createPopup.js b/web/views/@default/clusters/regions/items/createPopup.js index 1b7c285d..e2eae1b2 100644 --- a/web/views/@default/clusters/regions/items/createPopup.js +++ b/web/views/@default/clusters/regions/items/createPopup.js @@ -37,6 +37,10 @@ Tea.context(function () { return (bits / 1000 / 1000 / 1000) + "PB" } + if (bits < 1000 * 1000 * 1000 * 1000 * 1000) { + return (bits / 1000 / 1000 / 1000 / 1000) + "EB" + } + return "" } }) \ No newline at end of file diff --git a/web/views/@default/clusters/regions/items/updatePopup.js b/web/views/@default/clusters/regions/items/updatePopup.js index 93454062..792f378b 100644 --- a/web/views/@default/clusters/regions/items/updatePopup.js +++ b/web/views/@default/clusters/regions/items/updatePopup.js @@ -40,6 +40,10 @@ Tea.context(function () { return (bits / 1000 / 1000 / 1000) + "PB" } + if (bits < 1000 * 1000 * 1000 * 1000 * 1000) { + return (bits / 1000 / 1000 / 1000 / 1000) + "EB" + } + return "" } }) \ No newline at end of file