Skip to content

Commit 1fe7a72

Browse files
committed
onprem/frontend/gpu licenses: show info in text description and bugfixing
1 parent 46f6557 commit 1fe7a72

File tree

7 files changed

+25
-10
lines changed

7 files changed

+25
-10
lines changed

src/packages/frontend/project/settings/quota-editor/admin-quotas.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import { useEffect, useState } from "react";
77
import { Button, Card, Popconfirm, Popover } from "antd";
8+
import { isEqual } from "lodash";
9+
810
import { alert_message } from "@cocalc/frontend/alerts";
911
import { Icon, Loading } from "@cocalc/frontend/components";
1012
import { webapp_client } from "@cocalc/frontend/webapp-client";
@@ -13,16 +15,16 @@ import { PROJECT_UPGRADES } from "@cocalc/util/schema";
1315
import type { ProjectSettings } from "../types";
1416
import QuotaRow from "./quota-row";
1517
import type { QuotaParams } from "./types";
16-
import { isEqual } from "lodash";
17-
import { useRedux } from "@cocalc/frontend/app-framework";
18+
import { CSS, useRedux } from "@cocalc/frontend/app-framework";
1819

1920
const QUOTA_PARAMS = PROJECT_UPGRADES.params;
2021

2122
interface Props {
2223
project_id: string;
24+
style?: CSS;
2325
}
2426

25-
export default function AdminQuotas({ project_id }: Props) {
27+
export default function AdminQuotas({ project_id, style }: Props) {
2628
const projectSettings: ProjectSettings | undefined = useRedux([
2729
"projects",
2830
"project_map",
@@ -114,6 +116,7 @@ export default function AdminQuotas({ project_id }: Props) {
114116

115117
return (
116118
<Card
119+
style={style}
117120
title={
118121
<>
119122
<Icon name="user-plus" /> Admin Quota Editor

src/packages/frontend/project/settings/run-quota/hooks.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { fromPairs, isEqual } from "lodash";
88

99
import { ProjectStatus } from "@cocalc/comm/project-status/types";
1010
import {
11+
TypedMap,
1112
useEffect,
1213
useMemo,
1314
useState,
@@ -20,6 +21,7 @@ import {
2021
} from "@cocalc/util/db-schema/site-defaults";
2122
import { round1, seconds2hms, server_time } from "@cocalc/util/misc";
2223
import { PROJECT_UPGRADES } from "@cocalc/util/schema";
24+
import { GPU } from "@cocalc/util/types/site-licenses";
2325
import {
2426
Upgrades,
2527
quota2upgrade_key,
@@ -54,7 +56,12 @@ export function useRunQuota(
5456
return rq
5557
.map((val, key) => {
5658
if (key === "gpu") {
57-
return val?.get("num", 0);
59+
const v = val as boolean | TypedMap<GPU>;
60+
if (typeof v === "boolean") {
61+
return v ? 1 : null;
62+
} else {
63+
return v?.get("num", 0);
64+
}
5865
} else if (typeof val !== "number") {
5966
return val;
6067
} else if (key == "idle_timeout") {

src/packages/frontend/project/settings/run-quota/run-quota.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,6 @@ export const RunQuota: React.FC<Props> = React.memo(
246246
);
247247
}
248248

249-
console.log(record.key, val);
250-
251249
if (typeof val === "boolean") {
252250
return renderBoolean(val, projectIsRunning);
253251
} else if (record.key === "idle_timeout") {

src/packages/frontend/project/settings/upgrade-usage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ export const UpgradeUsage: React.FC<Props> = React.memo(
211211
return (
212212
<>
213213
{account_groups.includes("admin") && (
214-
<AdminQuotas project_id={project_id} />
214+
<AdminQuotas
215+
project_id={project_id}
216+
style={{ marginTop: "15px" }}
217+
/>
215218
)}
216219
{is_commercial && (
217220
<PayAsYouGoQuotaEditor

src/packages/util/licenses/describe-quota.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
44
*/
55

6-
76
/*
87
To avoid inconsistency, we are going to follow the style guide/table from
98
the "Microsoft Writing Style Guide" for things like "3 GB":
@@ -139,6 +138,11 @@ export function describe_quota(
139138
`${quota.dedicated_cpu} dedicated ${plural(quota.dedicated_cpu, "vCPU")}`,
140139
);
141140
}
141+
if (quota.gpu) {
142+
const { gpu } = quota;
143+
const num = gpu === true ? 1 : gpu.num ?? 1;
144+
v.push(`${num} GPU(s)`);
145+
}
142146

143147
if (
144148
typeof quota.dedicated_vm !== "boolean" &&

src/packages/util/types/site-licenses.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface SiteLicenseQuota {
3333
// JSON array of Array of JSON Patch Operations, e.g. "[{op: \"add\", path: \"/foo\", value: \"bar\"}]"
3434
// It's not an array of objects, because somewhere the array is converted to weird map of "0, 1, 2,..." indexed objects.
3535
patch?: string;
36-
gpu?: GPU;
36+
gpu?: GPU | boolean;
3737
}
3838

3939
// For typescript use of these from user side, we make this available:

src/packages/util/upgrades/quota.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ interface QuotaBase {
111111
interface QuotaOnPrem {
112112
ext_rw?: boolean;
113113
patch?: { [key: string]: string | object }[];
114-
gpu?: GPU | false;
114+
gpu?: GPU | boolean;
115115
}
116116

117117
// the resulting quota is a combination of the base quota and the onprem specific one

0 commit comments

Comments
 (0)