1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-02 12:25:22 +02:00

refactor(docker): migrate dashboard to react [EE-2191] (#11574)
Some checks are pending
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run

This commit is contained in:
Chaim Lev-Ari 2024-05-20 09:34:51 +03:00 committed by GitHub
parent 2669a44d79
commit 014a590704
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
54 changed files with 1297 additions and 507 deletions

View file

@ -0,0 +1,61 @@
import { DetailsTable } from '@@/DetailsTable';
import { DockerSnapshot } from '../snapshots/types';
export function GpuInfo({
gpus,
snapshot,
}: {
gpus: Array<{ name: string }>;
snapshot?: DockerSnapshot;
}) {
if (!snapshot) {
return null;
}
const gpuUseAll = snapshot.GpuUseAll;
const gpuUseList = snapshot.GpuUseList;
let gpuFreeStr = '';
if (gpuUseAll) {
gpuFreeStr = 'none';
} else {
gpuFreeStr = buildGpusStr(gpuUseList, gpus);
}
return (
<DetailsTable.Row label={gpus.length <= 1 ? 'GPU' : 'GPUs'}>
{gpuFreeStr}
</DetailsTable.Row>
);
function buildGpusStr(
gpuUseList: Array<string>,
gpus: Array<{ name: string }> = []
) {
if (!gpus.length) {
return 'none';
}
const gpuUseSet = new Set(gpuUseList);
const gpusAvailable: Record<string, number> = {};
for (let i = 0; i < gpus.length; i++) {
if (!gpuUseSet.has(gpus[i].name)) {
if (gpusAvailable[gpus[i].name]) {
gpusAvailable[gpus[i].name] += 1;
} else {
gpusAvailable[gpus[i].name] = 1;
}
}
}
const gpusKeys = Object.keys(gpusAvailable);
if (!gpusKeys.length) {
return 'none';
}
return Object.keys(gpusAvailable)
.map((gpuAvailable) => `${gpusAvailable[gpuAvailable]} x ${gpuAvailable}`)
.join(' + ');
}
}