CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/compute/configuration.tsx
Views: 687
1
import type {
2
Configuration as ConfigurationType,
3
ComputeServerTemplate,
4
State,
5
} from "@cocalc/util/db-schema/compute-servers";
6
import GoogleCloudConfiguration from "./google-cloud-config";
7
import OnPremConfiguration from "./onprem-config";
8
import HyperstackConfiguration from "./cloud/hyperstack/config";
9
10
interface Props {
11
configuration: ConfigurationType;
12
data?;
13
editable?: boolean;
14
id?: number;
15
project_id?: string;
16
onChange?: (configuration: ConfigurationType) => void;
17
state?: State;
18
setCloud?;
19
template?: ComputeServerTemplate;
20
}
21
22
export default function Configuration({
23
configuration,
24
data,
25
editable,
26
id,
27
project_id,
28
onChange,
29
state,
30
setCloud,
31
template,
32
}: Props) {
33
const disabled =
34
(state ?? "deprovisioned") != "deprovisioned" && state != "off";
35
return (
36
<>
37
{editable && disabled && (
38
<div
39
style={{
40
fontWeight: 250,
41
textAlign: "center",
42
maxWidth: "600px",
43
margin: "15px auto",
44
borderBottom: "1px solid #aaa",
45
marginBottom: "15px",
46
paddingBottom: "15px",
47
}}
48
>
49
Most configuration can only be changed when the server is off, and
50
some things can only be changed if you deprevision the server (which
51
deletes the disk).
52
{configuration?.cloud == "google-cloud" ? (
53
<b>
54
<br />
55
The disk can be instantly enlarged at any time without a reboot.
56
</b>
57
) : (
58
""
59
)}
60
</div>
61
)}
62
<Config
63
editable={editable}
64
id={id}
65
project_id={project_id}
66
configuration={configuration}
67
data={data}
68
onChange={onChange}
69
disabled={disabled}
70
state={state}
71
setCloud={setCloud}
72
template={template}
73
/>
74
</>
75
);
76
}
77
78
function Config({
79
configuration,
80
data,
81
editable,
82
id,
83
project_id,
84
onChange,
85
disabled,
86
state,
87
setCloud,
88
template,
89
}) {
90
if (configuration?.cloud == "google-cloud") {
91
return (
92
<GoogleCloudConfiguration
93
configuration={configuration}
94
data={data}
95
editable={editable}
96
id={id}
97
project_id={project_id}
98
onChange={onChange}
99
disabled={disabled}
100
state={state}
101
setCloud={setCloud}
102
template={template}
103
/>
104
);
105
} else if (configuration?.cloud == "onprem") {
106
return (
107
<OnPremConfiguration
108
configuration={configuration}
109
data={data}
110
editable={editable}
111
id={id}
112
project_id={project_id}
113
onChange={onChange}
114
disabled={disabled}
115
state={state}
116
template={template}
117
/>
118
);
119
} else if (configuration?.cloud == "hyperstack") {
120
return (
121
<HyperstackConfiguration
122
configuration={configuration}
123
data={data}
124
editable={editable}
125
id={id}
126
project_id={project_id}
127
onChange={onChange}
128
disabled={disabled}
129
state={state}
130
setCloud={setCloud}
131
template={template}
132
/>
133
);
134
} else {
135
return (
136
<span>
137
Configuration not implemented: {JSON.stringify(configuration)}
138
</span>
139
);
140
}
141
}
142
143