diff --git a/agent/app/dto/container.go b/agent/app/dto/container.go index ca19cca86c06..196cd51801e7 100644 --- a/agent/app/dto/container.go +++ b/agent/app/dto/container.go @@ -31,6 +31,9 @@ type ContainerInfo struct { Network []string `json:"network"` Ports []string `json:"ports"` + SizeRw int64 `json:"sizeRw"` + SizeRootFs int64 `json:"sizeRootFs"` + IsFromApp bool `json:"isFromApp"` IsFromCompose bool `json:"isFromCompose"` @@ -45,14 +48,13 @@ type ContainerOptions struct { } type ContainerStatus struct { - All uint `json:"all"` - Created uint `json:"created"` - Running uint `json:"running"` - Paused uint `json:"paused"` - Restarting uint `json:"restarting"` - Removing uint `json:"removing"` - Exited uint `json:"exited"` - Dead uint `json:"dead"` + Created int `json:"created"` + Running int `json:"running"` + Paused int `json:"paused"` + Restarting int `json:"restarting"` + Removing int `json:"removing"` + Exited int `json:"exited"` + Dead int `json:"dead"` ContainerCount int `json:"containerCount"` ComposeCount int `json:"composeCount"` @@ -62,7 +64,14 @@ type ContainerStatus struct { VolumeCount int `json:"volumeCount"` RepoCount int `json:"repoCount"` - ImageSize uint64 `json:"imageSize"` + ContainerUsage int64 `json:"containerUsage"` + ContainerReclaimable int64 `json:"containerReclaimable"` + ImageUsage int64 `json:"imageUsage"` + ImageReclaimable int64 `json:"imageReclaimable"` + VolumeUsage int64 `json:"volumeUsage"` + VolumeReclaimable int64 `json:"volumeReclaimable"` + BuildCacheUsage int64 `json:"buildCacheUsage"` + BuildCacheReclaimable int64 `json:"buildCacheReclaimable"` } type ResourceLimit struct { CPU int `json:"cpu"` diff --git a/agent/app/service/container.go b/agent/app/service/container.go index f3dec08803c1..8c1e2897f831 100644 --- a/agent/app/service/container.go +++ b/agent/app/service/container.go @@ -34,6 +34,7 @@ import ( "github.com/1Panel-dev/1Panel/agent/utils/cmd" "github.com/1Panel-dev/1Panel/agent/utils/common" "github.com/1Panel-dev/1Panel/agent/utils/docker" + "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/build" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" @@ -105,7 +106,8 @@ func (u *ContainerService) Page(req dto.PageContainer) (int64, interface{}, erro } defer client.Close() options := container.ListOptions{ - All: true, + All: true, + Size: true, } if len(req.Filters) != 0 { options.Filters = filters.NewArgs() @@ -199,6 +201,8 @@ func (u *ContainerService) Page(req dto.PageContainer) (int64, interface{}, erro Ports: exposePorts, IsFromApp: IsFromApp, IsFromCompose: IsFromCompose, + SizeRw: item.SizeRw, + SizeRootFs: item.SizeRootFs, } install, _ := appInstallRepo.GetFirst(appInstallRepo.WithContainerName(info.Name)) if install.ID > 0 { @@ -282,11 +286,35 @@ func (u *ContainerService) LoadStatus() (dto.ContainerStatus, error) { } defer client.Close() c := context.Background() - images, _ := client.ImageList(c, image.ListOptions{}) - for _, image := range images { - data.ImageSize += uint64(image.Size) + + usage, err := client.DiskUsage(c, types.DiskUsageOptions{}) + if err != nil { + return data, err + } + + data.ImageCount = len(usage.Images) + data.VolumeCount = len(usage.Volumes) + for _, item := range usage.Images { + data.ImageUsage += item.Size + if item.Containers < 1 { + data.ImageReclaimable += item.Size + } + } + for _, item := range usage.Containers { + data.ContainerUsage += item.SizeRw + if item.State != "running" { + data.ContainerReclaimable += item.SizeRw + } + } + for _, item := range usage.Volumes { + data.VolumeUsage += item.UsageData.Size + if item.UsageData.RefCount == 0 { + data.VolumeReclaimable += item.UsageData.Size + } + } + for _, item := range usage.BuildCache { + data.BuildCacheUsage += item.Size } - data.ImageCount = len(images) repo, _ := imageRepoRepo.List() data.RepoCount = len(repo) templates, _ := composeRepo.List() @@ -296,12 +324,8 @@ func (u *ContainerService) LoadStatus() (dto.ContainerStatus, error) { volumes, _ := client.VolumeList(c, volume.ListOptions{}) data.VolumeCount = len(volumes.Volumes) data.ComposeCount = loadComposeCount(client) - containers, err := client.ContainerList(c, container.ListOptions{All: true}) - if err != nil { - return data, err - } - data.All = uint(len(containers)) - for _, item := range containers { + data.ContainerCount = len(usage.Containers) + for _, item := range usage.Containers { switch item.State { case "created": data.Created++ @@ -319,7 +343,6 @@ func (u *ContainerService) LoadStatus() (dto.ContainerStatus, error) { data.Removing++ } } - data.ContainerCount = int(data.All) return data, nil } func (u *ContainerService) ContainerListStats() ([]dto.ContainerListStats, error) { diff --git a/core/app/api/v2/auth.go b/core/app/api/v2/auth.go index ef686ffd801b..c2b60d9a9112 100644 --- a/core/app/api/v2/auth.go +++ b/core/app/api/v2/auth.go @@ -135,7 +135,7 @@ func (b *BaseApi) GetWelcomePage(c *gin.Context) { } file, err := os.ReadFile(path.Join(global.CONF.Base.InstallDir, "1panel/welcome/index.html")) if err != nil { - helper.InternalServer(c, err) + helper.Success(c) return } helper.SuccessWithData(c, string(file)) diff --git a/frontend/src/api/interface/container.ts b/frontend/src/api/interface/container.ts index 461902dd31e8..9072d9187bc3 100644 --- a/frontend/src/api/interface/container.ts +++ b/frontend/src/api/interface/container.ts @@ -27,7 +27,6 @@ export namespace Container { order: string; } export interface ContainerStatus { - all: number; created: number; running: number; paused: number; @@ -44,7 +43,14 @@ export namespace Container { volumeCount: number; repoCount: number; - imageSize: number; + containerUsage: number; + containerReclaimable: number; + imageUsage: number; + imageReclaimable: number; + volumeUsage: number; + volumeReclaimable: number; + buildCacheUsage: number; + buildCacheReclaimable: number; } export interface ContainerOption { name: string; diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 305ca9628800..9676d9c13a9c 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -822,6 +822,19 @@ const message = { inputIpv4: 'Example: 192.168.1.1', inputIpv6: 'Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334', + diskUsage: 'Disk Usage', + localVolume: 'Local Storage Volume', + buildCache: 'Build Cache', + usage: 'Used: {0}, Releasable: {1}', + clean: 'Release', + imageClean: 'Clean up images will delete all unused images. This operation cannot be rolled back. Continue?', + containerClean: + 'Clean up containers will delete all stopped containers (including stopped apps from App Store). This operation cannot be rolled back. Continue?', + sizeRw: 'Layer Size', + sizeRwHelper: 'Size of the writable layer unique to the container', + sizeRootFs: 'Virtual Size', + sizeRootFsHelper: 'Total size of all image layers the container depends on + container layer', + containerFromAppHelper: 'Detected that this container originates from the app store. App operations may cause current edits to be invalidated.', containerFromAppHelper1: diff --git a/frontend/src/lang/modules/es-es.ts b/frontend/src/lang/modules/es-es.ts index 439ee4b67c3d..94aa67f644c3 100644 --- a/frontend/src/lang/modules/es-es.ts +++ b/frontend/src/lang/modules/es-es.ts @@ -824,6 +824,22 @@ const message = { 'El motor de contenedores usa un valor base de 1024 para la proporción de CPU. Puede aumentarlo para darle al contenedor más tiempo de CPU.', inputIpv4: 'Ejemplo: 192.168.1.1', inputIpv6: 'Ejemplo: 2001:0db8:85a3:0000:0000:8a2e:0370:7334', + + diskUsage: 'Uso del Disco', + localVolume: 'Volumen de Almacenamiento Local', + buildCache: 'Caché de Construcción', + usage: 'Usado: {0}, Liberable: {1}', + clean: 'Liberar', + imageClean: + 'Limpiar imágenes eliminará todas las imágenes no utilizadas. Esta operación no se puede deshacer. ¿Continuar?', + containerClean: + 'Limpiar contenedores eliminará todos los contenedores detenidos (incluidas las aplicaciones detenidas de la Tienda de Aplicaciones). Esta operación no se puede deshacer. ¿Continuar?', + sizeRw: 'Tamaño de Capa de Contenedor', + sizeRwHelper: 'Tamaño de la capa escribible exclusiva del contenedor', + sizeRootFs: 'Tamaño Virtual', + sizeRootFsHelper: + 'Tamaño total de todas las capas de imagen de las que depende el contenedor + capa del contenedor', + containerFromAppHelper: 'Se detectó que este contenedor proviene de la tienda de aplicaciones. Las operaciones sobre la app pueden invalidar los cambios actuales.', containerFromAppHelper1: diff --git a/frontend/src/lang/modules/ja.ts b/frontend/src/lang/modules/ja.ts index 2fa84ebab4e4..1a3560e866e6 100644 --- a/frontend/src/lang/modules/ja.ts +++ b/frontend/src/lang/modules/ja.ts @@ -803,6 +803,20 @@ const message = { inputIpv4: '例:192.168.1.1', inputIpv6: '例:2001:0DB8:85A3:0000:0000:8A2E:0370:7334', + diskUsage: 'ディスク使用量', + localVolume: 'ローカルストレージボリューム', + buildCache: 'ビルドキャッシュ', + usage: '使用済み: {0}, 解放可能: {1}', + clean: '解放', + imageClean: + 'イメージをクリーンアップすると、すべての未使用イメージが削除されます。この操作は元に戻せません。続行しますか?', + containerClean: + 'コンテナをクリーンアップすると、停止中のすべてのコンテナ(アプリストアの停止アプリを含む)が削除されます。この操作は元に戻せません。続行しますか?', + sizeRw: 'コンテナレイヤーサイズ', + sizeRwHelper: 'コンテナ固有の書き込み可能レイヤーのサイズ', + sizeRootFs: '仮想サイズ', + sizeRootFsHelper: 'コンテナが依存するすべてのイメージレイヤー + コンテナレイヤーの合計サイズ', + containerFromAppHelper: 'このコンテナがアプリストアから取得されたことが検出されました。アプリの操作により、現在の編集が無効になる可能性があります。', containerFromAppHelper1: diff --git a/frontend/src/lang/modules/ko.ts b/frontend/src/lang/modules/ko.ts index 48c0f4924001..63bebf55091f 100644 --- a/frontend/src/lang/modules/ko.ts +++ b/frontend/src/lang/modules/ko.ts @@ -796,6 +796,21 @@ const message = { '컨테이너 엔진은 기본값으로 1024를 사용합니다. 이를 늘리면 컨테이너에 더 많은 CPU 시간을 할당할 수 있습니다.', inputIpv4: '예시: 192.168.1.1', inputIpv6: '예시: 2001:0db8:85a3:0000:0000:8a2e:0370:7334', + + diskUsage: '디스크 사용량', + localVolume: '로컬 스토리지 볼륨', + buildCache: '빌드 캐시', + usage: '사용됨: {0}, 해제 가능: {1}', + clean: '해제', + imageClean: + '이미지 정리를 수행하면 사용되지 않은 모든 이미지가 삭제됩니다. 이 작업은 되돌릴 수 없습니다. 계속하시겠습니까?', + containerClean: + '컨테이너 정리를 수행하면 중지된 모든 컨테이너(앱 스토어의 중지된 앱 포함)가 삭제됩니다. 이 작업은 되돌릴 수 없습니다. 계속하시겠습니까?', + sizeRw: '컨테이너 레이어 크기', + sizeRwHelper: '컨테이너에 고유한 쓰기 가능 레이어 크기', + sizeRootFs: '가상 크기', + sizeRootFsHelper: '컨테이너가 의존하는 모든 이미지 레이어 + 컨테이너 레이어의 총 크기', + containerFromAppHelper: '이 컨테이너가 앱 스토어에서 왔음을 감지했습니다. 앱 작업으로 현재 편집이 무효화될 수 있습니다.', containerFromAppHelper1: diff --git a/frontend/src/lang/modules/ms.ts b/frontend/src/lang/modules/ms.ts index 41239eb2635b..03ace5e1f5f8 100644 --- a/frontend/src/lang/modules/ms.ts +++ b/frontend/src/lang/modules/ms.ts @@ -817,6 +817,20 @@ const message = { inputIpv4: 'Contoh: 192.168.1.1', inputIpv6: 'Contoh: 2001:0db8:85a3:0000:0000:8a2e:0370:7334', + diskUsage: 'Penggunaan Cakera', + localVolume: 'Isipadu Storan Tempatan', + buildCache: 'Cache Binaan', + usage: 'Digunakan: {0}, Boleh Dibebaskan: {1}', + clean: 'Bebaskan', + imageClean: + 'Membersihkan imej akan memadam semua imej yang tidak digunakan. Operasi ini tidak boleh dikembalikan. Teruskan?', + containerClean: + 'Membersihkan bekas akan memadam semua bekas yang dihentikan (termasuk aplikasi berhenti dari Kedai Apl). Operasi ini tidak boleh dikembalikan. Teruskan?', + sizeRw: 'Saiz Lapisan Bekas', + sizeRwHelper: 'Saiz lapisan boleh tulis yang unik untuk bekas', + sizeRootFs: 'Saiz Maya', + sizeRootFsHelper: 'Jumlah saiz semua lapisan imej yang disandarkan oleh bekas + lapisan bekas', + containerFromAppHelper: 'Dikesan bahawa kontena ini berasal dari gedung aplikasi. Operasi aplikasi boleh menyebabkan suntingan semasa menjadi tidak sah.', containerFromAppHelper1: diff --git a/frontend/src/lang/modules/pt-br.ts b/frontend/src/lang/modules/pt-br.ts index 56fe4de5ec0b..ef6a71828015 100644 --- a/frontend/src/lang/modules/pt-br.ts +++ b/frontend/src/lang/modules/pt-br.ts @@ -814,6 +814,21 @@ const message = { inputIpv4: 'Exemplo: 192.168.1.1', inputIpv6: 'Exemplo: 2001:0db8:85a3:0000:0000:8a2e:0370:7334', + diskUsage: 'Uso do Disco', + localVolume: 'Volume de Armazenamento Local', + buildCache: 'Cache de Build', + usage: 'Usado: {0}, Liberável: {1}', + clean: 'Liberar', + imageClean: + 'Limpar imagens excluirá todas as imagens não utilizadas. Esta operação não pode ser desfeita. Continuar?', + containerClean: + 'Limpar contêineres excluirá todos os contêineres parados (incluindo aplicativos parados da Loja de Aplicativos). Esta operação não pode ser desfeita. Continuar?', + sizeRw: 'Tamanho da Camada do Contêiner', + sizeRwHelper: 'Tamanho da camada gravável exclusiva do contêiner', + sizeRootFs: 'Tamanho Virtual', + sizeRootFsHelper: + 'Tamanho total de todas as camadas de imagem das quais o contêiner depende + camada do contêiner', + containerFromAppHelper: 'Detectamos que este contêiner vem da loja de aplicativos. As operações no aplicativo podem fazer com que as edições atuais sejam invalidadas.', containerFromAppHelper1: diff --git a/frontend/src/lang/modules/ru.ts b/frontend/src/lang/modules/ru.ts index 8524d2e20ffb..6d586ecea96c 100644 --- a/frontend/src/lang/modules/ru.ts +++ b/frontend/src/lang/modules/ru.ts @@ -813,6 +813,19 @@ const message = { inputIpv4: 'Пример: 192.168.1.1', inputIpv6: 'Пример: 2001:0db8:85a3:0000:0000:8a2e:0370:7334', + diskUsage: 'Использование Диска', + localVolume: 'Локальный Том Хранилища', + buildCache: 'Кэш Сборки', + usage: 'Использовано: {0}, Можно освободить: {1}', + clean: 'Освободить', + imageClean: 'Очистка образов удалит все неиспользуемые образы. Это действие нельзя отменить. Продолжить?', + containerClean: + 'Очистка контейнеров удалит все остановленные контейнеры (включая остановленные приложения из Магазина приложений). Это действие нельзя отменить. Продолжить?', + sizeRw: 'Размер Слоя Контейнера', + sizeRwHelper: 'Размер записываемого слоя, уникального для контейнера', + sizeRootFs: 'Виртуальный Размер', + sizeRootFsHelper: 'Общий размер всех слоев образа, от которых зависит контейнер + слой контейнера', + containerFromAppHelper: 'Обнаружено, что этот контейнер происходит из магазина приложений. Операции с приложением могут привести к недействительности текущих изменений.', containerFromAppHelper1: diff --git a/frontend/src/lang/modules/tr.ts b/frontend/src/lang/modules/tr.ts index 54cfb252c13a..da0cf1ebcaa2 100644 --- a/frontend/src/lang/modules/tr.ts +++ b/frontend/src/lang/modules/tr.ts @@ -831,6 +831,20 @@ const message = { inputIpv4: 'Örnek: 192.168.1.1', inputIpv6: 'Örnek: 2001:0db8:85a3:0000:0000:8a2e:0370:7334', + diskUsage: 'Disk Kullanımı', + localVolume: 'Yerel Depolama Birimi', + buildCache: 'Derleme Önbelleği', + usage: 'Kullanılan: {0}, Serbest Bırakılabilir: {1}', + clean: 'Serbest Bırak', + imageClean: + 'Görüntüleri temizlemek, kullanılmayan tüm görüntüleri silecektir. Bu işlem geri alınamaz. Devam etmek istiyor musunuz?', + containerClean: + 'Konteynerleri temizlemek, durdurulmuş tüm konteynerleri (Uygulama Mağazası ndaki durdurulmuş uygulamalar dahil) silecektir. Bu işlem geri alınamaz. Devam etmek istiyor musunuz?', + sizeRw: 'Konteyner Katman Boyutu', + sizeRwHelper: 'Konteynere özel yazılabilir katman boyutu', + sizeRootFs: 'Sanal Boyut', + sizeRootFsHelper: 'Konteynerin bağımlı olduğu tüm görüntü katmanları + konteyner katmanının toplam boyutu', + containerFromAppHelper: 'Bu konteynerin uygulama mağazasından geldiği tespit edildi. Uygulama işlemleri mevcut düzenlemelerin geçersiz hale gelmesine neden olabilir.', containerFromAppHelper1: diff --git a/frontend/src/lang/modules/zh-Hant.ts b/frontend/src/lang/modules/zh-Hant.ts index 66dca3f25f18..a8378850597b 100644 --- a/frontend/src/lang/modules/zh-Hant.ts +++ b/frontend/src/lang/modules/zh-Hant.ts @@ -787,6 +787,18 @@ const message = { inputIpv4: '請輸入 IPv4 位址', inputIpv6: '請輸入 IPv6 位址', + diskUsage: '磁碟佔用', + localVolume: '本機儲存卷', + buildCache: '建置快取', + usage: '已佔用:{0}, 可釋放:{1}', + clean: '釋放', + imageClean: '清理映像將刪除所有未被使用的映像,該操作無法復原,是否繼續?', + containerClean: '清理容器將刪除所有處於停止中狀態的容器(包括應用商店停止應用),該操作無法復原,是否繼續?', + sizeRw: '容器層大小', + sizeRwHelper: '容器獨有的可寫層大小', + sizeRootFs: '虛擬大小', + sizeRootFsHelper: '容器依賴的所有映像層 + 容器層的總大小', + containerFromAppHelper: '檢測到該容器來源於應用商店,應用操作可能會導致目前編輯失效', containerFromAppHelper1: '在已安裝應用程式列表點擊 [參數] 按鈕,進入編輯頁面即可修改容器名稱。', command: '指令', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 78eb635b9097..ce5bb178ebda 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -787,6 +787,18 @@ const message = { inputIpv4: '请输入 IPv4 地址', inputIpv6: '请输入 IPv6 地址', + diskUsage: '磁盘占用', + localVolume: '本地存储卷', + buildCache: '构建缓存', + usage: '已占用:{0}, 可释放:{1}', + clean: '释放', + imageClean: '清理镜像 将删除所有未被使用的镜像,该操作无法回滚,是否继续?', + containerClean: '清理容器 将删除所有处于停止中状态的容器(包括应用商店停止应用),该操作无法回滚,是否继续?', + sizeRw: '容器层大小', + sizeRwHelper: '容器独有的可写层大小', + sizeRootFs: '虚拟大小', + sizeRootFsHelper: ' 容器依赖的所有镜像层 + 容器层的总大小', + containerFromAppHelper: '检测到该容器来源于应用商店,应用操作可能会导致当前编辑失效', containerFromAppHelper1: '在应用商店的已安装页面,点击 [参数] 按钮,进入编辑页面修改容器名称。', command: '命令', diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.ts index bc876e6c4e60..7e8c241385b5 100644 --- a/frontend/src/utils/util.ts +++ b/frontend/src/utils/util.ts @@ -217,6 +217,32 @@ export function computeSize(size: number): string { return formattedNumber((size / Math.pow(num, 4)).toFixed(2)) + ' TB'; } +export function computeSizeForDocker(size: number): string { + const num = 1024.0; + if (size < num) return size + ' B'; + if (size < Math.pow(num, 2)) return formattedNumber((size / num).toFixed(2)) + ' KiB'; + if (size < Math.pow(num, 3)) return formattedNumber((size / Math.pow(num, 2)).toFixed(2)) + ' MiB'; + if (size < Math.pow(num, 4)) return formattedNumber((size / Math.pow(num, 3)).toFixed(2)) + ' GiB'; + return formattedNumber((size / Math.pow(num, 4)).toFixed(2)) + ' TiB'; +} + +export function computeSize2(size: number): string { + const num = 1000.0; + if (size < num) return size + ' B'; + if (size < Math.pow(num, 2)) return formattedNumber((size / num).toFixed(2)) + ' KB'; + if (size < Math.pow(num, 3)) return formattedNumber((size / Math.pow(num, 2)).toFixed(2)) + ' MB'; + if (size < Math.pow(num, 4)) return formattedNumber((size / Math.pow(num, 3)).toFixed(2)) + ' GB'; + return formattedNumber((size / Math.pow(num, 4)).toFixed(2)) + ' TB'; +} + +export function computeCPU(size: number): string { + const num = 1000; + if (size < num) return size + ' ns'; + if (size < Math.pow(num, 2)) return formattedNumber((size / num).toFixed(2)) + ' μs'; + if (size < Math.pow(num, 3)) return formattedNumber((size / Math.pow(num, 2)).toFixed(2)) + ' ms'; + return formattedNumber((size / Math.pow(num, 3)).toFixed(2)) + ' s'; +} + export function splitSize(size: number): any { const num = 1024.0; if (size < num) return { size: Number(size), unit: 'B' }; diff --git a/frontend/src/views/container/container/index.vue b/frontend/src/views/container/container/index.vue index 04b2a15e227c..0555420393d7 100644 --- a/frontend/src/views/container/container/index.vue +++ b/frontend/src/views/container/container/index.vue @@ -173,59 +173,46 @@ @@ -379,7 +366,7 @@ import { MsgSuccess, MsgWarning } from '@/utils/message'; import { GlobalStore } from '@/store'; import { routerToName, routerToNameWithQuery } from '@/utils/router'; import router from '@/routers'; -import { newUUID } from '@/utils/util'; +import { computeSize2, computeSizeForDocker, computeCPU, newUUID } from '@/utils/util'; const globalStore = GlobalStore(); const mobile = computed(() => { @@ -490,28 +477,28 @@ const searchWithAppShow = (item: any) => { const loadContainerCount = async () => { await loadContainerStatus().then((res) => { tags.value = []; - if (res.data.all) { - tags.value.push({ key: 'all', count: res.data.all }); + if (res.data.containerCount) { + tags.value.push({ key: 'all', count: res.data.containerCount }); } - if (res.data.all) { + if (res.data.running) { tags.value.push({ key: 'running', count: res.data.running }); } - if (res.data.all) { + if (res.data.paused) { tags.value.push({ key: 'paused', count: res.data.paused }); } - if (res.data.all) { + if (res.data.restarting) { tags.value.push({ key: 'restarting', count: res.data.restarting }); } - if (res.data.all) { + if (res.data.removing) { tags.value.push({ key: 'removing', count: res.data.removing }); } - if (res.data.all) { + if (res.data.created) { tags.value.push({ key: 'created', count: res.data.created }); } - if (res.data.all) { + if (res.data.dead) { tags.value.push({ key: 'dead', count: res.data.dead }); } - if (res.data.all) { + if (res.data.exited) { tags.value.push({ key: 'exited', count: res.data.exited }); } }); @@ -569,38 +556,6 @@ const loadStats = async () => { } }; -const loadCPUUnit = (t: number) => { - const num = 1000; - if (t < num) return ' ns'; - if (t < Math.pow(num, 2)) return ' μs'; - if (t < Math.pow(num, 3)) return ' ms'; - return ' s'; -}; -function loadCPUValue(t: number) { - const num = 1000; - if (t < num) return t; - if (t < Math.pow(num, 2)) return Number((t / num).toFixed(2)); - if (t < Math.pow(num, 3)) return Number((t / Math.pow(num, 2)).toFixed(2)); - return Number((t / Math.pow(num, 3)).toFixed(2)); -} -const loadMemUnit = (t: number) => { - if (t == 0) { - return ''; - } - const num = 1024; - if (t < num) return ' B'; - if (t < Math.pow(num, 2)) return ' KiB'; - if (t < Math.pow(num, 3)) return ' MiB'; - return ' GiB'; -}; -function loadMemValue(t: number) { - const num = 1024; - if (t < num) return t; - if (t < Math.pow(num, 2)) return Number((t / num).toFixed(2)); - if (t < Math.pow(num, 3)) return Number((t / Math.pow(num, 2)).toFixed(2)); - return Number((t / Math.pow(num, 3)).toFixed(2)); -} - const onContainerOperate = async (container: string) => { routerToNameWithQuery('ContainerCreate', { name: container }); }; diff --git a/frontend/src/views/container/dashboard/index.vue b/frontend/src/views/container/dashboard/index.vue index e9319ea4833b..19423b08a829 100644 --- a/frontend/src/views/container/dashboard/index.vue +++ b/frontend/src/views/container/dashboard/index.vue @@ -13,8 +13,8 @@ {{ countItem.containerCount }}