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/ephemeral.tsx
Views: 687
1
import { Alert, Checkbox, Switch } from "antd";
2
import { useState } from "react";
3
import { Icon } from "@cocalc/frontend/components/icon";
4
5
export default function Ephemeral({ setConfig, configuration, loading }) {
6
const [ephemeral, setEphemeral] = useState<boolean>(configuration.ephemeral);
7
const [help, setHelp] = useState<boolean>(false);
8
return (
9
<div>
10
<div style={{ color: "#666", marginBottom: "5px" }}>
11
<div>
12
<b>
13
<Switch
14
size="small"
15
checkedChildren={"Help"}
16
unCheckedChildren={"Help"}
17
style={{ float: "right" }}
18
checked={help}
19
onChange={(val) => setHelp(val)}
20
/>
21
<Icon name="disk-snapshot" /> Ephemeral Compute Server
22
</b>
23
</div>
24
{help && (
25
<Alert
26
showIcon
27
style={{ margin: "15px 0" }}
28
type="info"
29
message={"Treat Compute Server as Ephemeral"}
30
description={
31
<div>
32
<p>
33
Use this setting if you will use this server only for{" "}
34
<i>temporary computations</i> and want{" "}
35
<i>maximum flexibility and minimal cost</i>.{" "}
36
<b>This setting only modifies the user interface</b>; in
37
particular, the default way to "turn off" the server will
38
delete its disk.
39
</p>
40
<p>
41
Do you plan to use data on this compute server that you want
42
to preserve only on the compute server? The HOME directory is
43
sync'd, except hidden folders and directories explicitly
44
excluded above. Other files, e.g., in /tmp and systemwide
45
changes, exist only on the compute server's local disk{" "}
46
<i>without any automatic backups</i>. (Backup functionality
47
for local data will be implementd in the future.)
48
</p>
49
<p>
50
If you don't need to preserve data that is not sync'd, this
51
setting is likely to be convenient.
52
</p>
53
</div>
54
}
55
/>
56
)}
57
<Checkbox
58
style={{ marginTop: "5px" }}
59
disabled={loading}
60
checked={ephemeral}
61
onChange={() => {
62
setConfig({ ephemeral: !ephemeral });
63
setEphemeral(!ephemeral);
64
}}
65
>
66
Ephemeral: I do not need to store data on this compute server between
67
sessions
68
</Checkbox>
69
</div>
70
</div>
71
);
72
}
73
74