fix(gpu): EE-3743 gpus null error (#7342)

pull/7385/head
congs 2022-07-29 16:08:17 +12:00 committed by GitHub
parent ce22544c60
commit 44737029a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -84,12 +84,12 @@ function Option(props: OptionProps<GpuOption, true>) {
export function Gpu({
values,
onChange,
gpus,
gpus = [],
usedGpus = [],
usedAllGpus,
}: Props) {
const options = useMemo(() => {
const options = gpus.map((gpu) => ({
const options = (gpus || []).map((gpu) => ({
value: gpu.value,
label:
usedGpus.includes(gpu.value) || usedAllGpus

View File

@ -46,7 +46,7 @@ angular.module('portainer.docker').controller('DashboardController', [
$scope.buildGpusStr = function (gpuUseSet) {
var gpusAvailable = new Object();
for (let i = 0; i < $scope.endpoint.Gpus.length; i++) {
for (let i = 0; i < ($scope.endpoint.Gpus || []).length; i++) {
if (!gpuUseSet.has($scope.endpoint.Gpus[i].name)) {
var exist = false;
for (let gpuAvailable in gpusAvailable) {

View File

@ -175,7 +175,7 @@ function EndpointController(
}
function verifyGpus() {
var i = $scope.endpoint.Gpus.length;
var i = ($scope.endpoint.Gpus || []).length;
while (i--) {
if ($scope.endpoint.Gpus[i].name === '' || $scope.endpoint.Gpus[i].name === null) {
$scope.endpoint.Gpus.splice(i, 1);