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/course/configuration/parallel.tsx
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { Card, InputNumber } from "antd";
7
import { useEffect, useState } from "react";
8
import { useRedux, useActions } from "../../app-framework";
9
import { Icon } from "../../components";
10
import { CourseActions } from "../actions";
11
import { MAX_COPY_PARALLEL } from "../store";
12
13
interface Props {
14
name: string;
15
}
16
export function Parallel({ name }: Props) {
17
const settings = useRedux([name, "settings"]);
18
const actions: CourseActions = useActions({ name });
19
20
const parallel =
21
settings.get("copy_parallel") ?? actions.get_store().get_copy_parallel();
22
const [value, setValue] = useState<number | null>(parallel);
23
useEffect(() => {
24
setValue(parallel);
25
}, [parallel]);
26
27
function render_parallel() {
28
return (
29
<div>
30
<i>Max number of students</i> to copy and collect files from in
31
parallel. What is optimal depends on available compute resources
32
(upgrades) and the size of the content you are copying.
33
<br />
34
<div style={{ textAlign: "center", marginTop: "15px" }}>
35
<InputNumber
36
style={{ width: "200px" }}
37
onChange={(n) => setValue(n)}
38
min={1}
39
max={MAX_COPY_PARALLEL}
40
value={value}
41
onBlur={() => {
42
if (!value) {
43
setValue(1);
44
actions.configuration.set_copy_parallel(1);
45
return;
46
}
47
if (value != parallel) {
48
actions.configuration.set_copy_parallel(value);
49
}
50
}}
51
/>
52
</div>
53
</div>
54
);
55
}
56
57
return (
58
<Card
59
title={
60
<>
61
{" "}
62
<Icon name="users" /> Parallel Limit: Copy {parallel} assignments at a
63
time
64
</>
65
}
66
>
67
{render_parallel()}
68
</Card>
69
);
70
}
71
72