@dytsou/intern-corner-scheduler 1.2.13 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -42
- package/index.html +6 -1
- package/package.json +23 -20
- package/scripts/create-nojekyll.js +2 -2
- package/src/App.css +846 -233
- package/src/App.jsx +113 -17
- package/src/components/ErrorMessage.jsx +3 -2
- package/src/components/GenerationLoadingScreen.jsx +48 -0
- package/src/components/Header.jsx +23 -5
- package/src/components/LoadingSpinner.jsx +11 -0
- package/src/components/PairInput.jsx +21 -7
- package/src/components/PairStatus.jsx +8 -2
- package/src/components/ScheduleForm.jsx +182 -113
- package/src/components/TableAssignments.jsx +7 -1
- package/src/index.css +153 -26
- package/src/services/cpSatScheduler.js +551 -0
- package/src/services/schedulerClient.js +96 -0
- package/vite.config.js +18 -0
- package/src/config.js +0 -21
- package/src/services/api.js +0 -31
package/src/App.jsx
CHANGED
|
@@ -3,51 +3,147 @@ import ScheduleForm from './components/ScheduleForm';
|
|
|
3
3
|
import ResultsDisplay from './components/ResultsDisplay';
|
|
4
4
|
import ErrorMessage from './components/ErrorMessage';
|
|
5
5
|
import Header from './components/Header';
|
|
6
|
+
import GenerationLoadingScreen from './components/GenerationLoadingScreen';
|
|
6
7
|
import Footer from './components/Footer';
|
|
8
|
+
import {
|
|
9
|
+
cancelScheduleSolve,
|
|
10
|
+
solveScheduleLocally,
|
|
11
|
+
} from './services/schedulerClient';
|
|
7
12
|
import './App.css';
|
|
8
13
|
|
|
9
14
|
function App() {
|
|
10
15
|
const [schedule, setSchedule] = useState(null);
|
|
11
16
|
const [error, setError] = useState(null);
|
|
12
17
|
const [loading, setLoading] = useState(false);
|
|
18
|
+
const [cancelling, setCancelling] = useState(false);
|
|
19
|
+
const [statusMessage, setStatusMessage] = useState('');
|
|
13
20
|
|
|
14
21
|
const handleScheduleSubmit = async (formData) => {
|
|
15
22
|
setError(null);
|
|
16
23
|
setLoading(true);
|
|
24
|
+
setStatusMessage('Generating schedule in your browser…');
|
|
17
25
|
|
|
18
26
|
try {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
const result = await solveScheduleLocally(formData, {
|
|
28
|
+
onStatus(stage) {
|
|
29
|
+
if (stage === 'solving') {
|
|
30
|
+
setStatusMessage('Solving in a browser worker…');
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const solverStatus = String(result.solver_status).toUpperCase();
|
|
35
|
+
|
|
36
|
+
if (solverStatus === 'OPTIMAL' || solverStatus === 'FEASIBLE') {
|
|
37
|
+
setSchedule(result);
|
|
38
|
+
setStatusMessage(
|
|
39
|
+
`Schedule generated locally. Solver status: ${solverStatus}.`
|
|
40
|
+
);
|
|
41
|
+
} else if (solverStatus === 'INFEASIBLE') {
|
|
42
|
+
setStatusMessage('');
|
|
43
|
+
setError(
|
|
44
|
+
'No schedule satisfies these constraints. Try changing the pair restrictions and submit again.'
|
|
45
|
+
);
|
|
46
|
+
} else if (solverStatus === 'UNKNOWN') {
|
|
47
|
+
setStatusMessage('');
|
|
48
|
+
setError(
|
|
49
|
+
'The browser solver reached the time limit before finding a schedule. Increase the time limit or simplify the inputs and try again.'
|
|
50
|
+
);
|
|
51
|
+
} else if (solverStatus === 'MODEL_INVALID') {
|
|
52
|
+
setStatusMessage('');
|
|
53
|
+
setError(
|
|
54
|
+
'The browser solver rejected this schedule model. Check the inputs and try again.'
|
|
55
|
+
);
|
|
56
|
+
} else {
|
|
57
|
+
setStatusMessage('');
|
|
58
|
+
setError(
|
|
59
|
+
`The browser solver stopped with status ${solverStatus || 'unknown'}. You can review the inputs and try again.`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
22
62
|
} catch (err) {
|
|
63
|
+
if (err?.name === 'AbortError') {
|
|
64
|
+
setStatusMessage(
|
|
65
|
+
'Schedule generation was cancelled. The browser worker has stopped.'
|
|
66
|
+
);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
70
|
+
setStatusMessage('');
|
|
23
71
|
setError(
|
|
24
|
-
`
|
|
72
|
+
`The browser solver could not start or finish. ${detail || 'Please try again.'}`
|
|
25
73
|
);
|
|
26
74
|
} finally {
|
|
27
75
|
setLoading(false);
|
|
28
76
|
}
|
|
29
77
|
};
|
|
30
78
|
|
|
79
|
+
const handleCancelSchedule = async () => {
|
|
80
|
+
if (cancelling) return;
|
|
81
|
+
|
|
82
|
+
setCancelling(true);
|
|
83
|
+
setStatusMessage('Stopping the browser worker…');
|
|
84
|
+
setError(null);
|
|
85
|
+
try {
|
|
86
|
+
await cancelScheduleSolve();
|
|
87
|
+
} catch (err) {
|
|
88
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
89
|
+
setStatusMessage('The browser worker could not be stopped.');
|
|
90
|
+
setError(detail || 'Try again after the current solve finishes.');
|
|
91
|
+
} finally {
|
|
92
|
+
setCancelling(false);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
31
96
|
const handleReset = () => {
|
|
32
97
|
setSchedule(null);
|
|
33
98
|
setError(null);
|
|
99
|
+
setStatusMessage('');
|
|
34
100
|
};
|
|
35
101
|
|
|
36
102
|
return (
|
|
37
|
-
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
103
|
+
<>
|
|
104
|
+
<div
|
|
105
|
+
className="container"
|
|
106
|
+
aria-hidden={loading || undefined}
|
|
107
|
+
inert={loading || undefined}
|
|
108
|
+
>
|
|
109
|
+
<Header />
|
|
110
|
+
<div className="main-content">
|
|
111
|
+
{statusMessage && (
|
|
112
|
+
<p
|
|
113
|
+
className="solver-status"
|
|
114
|
+
role="status"
|
|
115
|
+
aria-live="polite"
|
|
116
|
+
aria-atomic="true"
|
|
117
|
+
>
|
|
118
|
+
{statusMessage}
|
|
119
|
+
</p>
|
|
120
|
+
)}
|
|
121
|
+
{!schedule ? (
|
|
122
|
+
<ScheduleForm
|
|
123
|
+
onSubmit={handleScheduleSubmit}
|
|
124
|
+
onCancel={handleCancelSchedule}
|
|
125
|
+
loading={loading}
|
|
126
|
+
cancelling={cancelling}
|
|
127
|
+
/>
|
|
128
|
+
) : (
|
|
129
|
+
<ResultsDisplay schedule={schedule} onReset={handleReset} />
|
|
130
|
+
)}
|
|
131
|
+
{error && (
|
|
132
|
+
<ErrorMessage message={error} onDismiss={() => setError(null)} />
|
|
133
|
+
)}
|
|
134
|
+
</div>
|
|
135
|
+
<Footer />
|
|
48
136
|
</div>
|
|
49
|
-
|
|
50
|
-
|
|
137
|
+
{loading && (
|
|
138
|
+
<GenerationLoadingScreen
|
|
139
|
+
statusMessage={statusMessage}
|
|
140
|
+
cancelling={cancelling}
|
|
141
|
+
error={error}
|
|
142
|
+
onCancel={handleCancelSchedule}
|
|
143
|
+
onDismissError={() => setError(null)}
|
|
144
|
+
/>
|
|
145
|
+
)}
|
|
146
|
+
</>
|
|
51
147
|
);
|
|
52
148
|
}
|
|
53
149
|
|
|
@@ -2,10 +2,11 @@ function ErrorMessage({ message, onDismiss }) {
|
|
|
2
2
|
if (!message) return null;
|
|
3
3
|
|
|
4
4
|
return (
|
|
5
|
-
<div className="error-message"
|
|
6
|
-
{message}
|
|
5
|
+
<div className="error-message" role="alert" aria-atomic="true">
|
|
6
|
+
<span>{message}</span>
|
|
7
7
|
{onDismiss && (
|
|
8
8
|
<button
|
|
9
|
+
type="button"
|
|
9
10
|
onClick={onDismiss}
|
|
10
11
|
className="error-dismiss"
|
|
11
12
|
aria-label="Dismiss error"
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import ErrorMessage from './ErrorMessage';
|
|
2
|
+
import LoadingSpinner from './LoadingSpinner';
|
|
3
|
+
|
|
4
|
+
function GenerationLoadingScreen({
|
|
5
|
+
statusMessage,
|
|
6
|
+
cancelling,
|
|
7
|
+
error,
|
|
8
|
+
onCancel,
|
|
9
|
+
onDismissError,
|
|
10
|
+
}) {
|
|
11
|
+
return (
|
|
12
|
+
<div className="generation-screen">
|
|
13
|
+
<dialog
|
|
14
|
+
open
|
|
15
|
+
className="generation-loader"
|
|
16
|
+
aria-modal="true"
|
|
17
|
+
aria-labelledby="generation-title"
|
|
18
|
+
>
|
|
19
|
+
<h1 id="generation-title" className="visually-hidden">
|
|
20
|
+
Generating schedule
|
|
21
|
+
</h1>
|
|
22
|
+
<div
|
|
23
|
+
className="generation-spinner"
|
|
24
|
+
role="status"
|
|
25
|
+
aria-live="polite"
|
|
26
|
+
aria-atomic="true"
|
|
27
|
+
>
|
|
28
|
+
<LoadingSpinner />
|
|
29
|
+
<span className="visually-hidden">
|
|
30
|
+
{statusMessage || 'Finding a good mix for every round…'}
|
|
31
|
+
</span>
|
|
32
|
+
</div>
|
|
33
|
+
<ErrorMessage message={error} onDismiss={onDismissError} />
|
|
34
|
+
<button
|
|
35
|
+
type="button"
|
|
36
|
+
className="btn-secondary generation-cancel"
|
|
37
|
+
onClick={onCancel}
|
|
38
|
+
disabled={cancelling}
|
|
39
|
+
autoFocus
|
|
40
|
+
>
|
|
41
|
+
{cancelling ? 'Stopping…' : 'Cancel generation'}
|
|
42
|
+
</button>
|
|
43
|
+
</dialog>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default GenerationLoadingScreen;
|
|
@@ -1,10 +1,28 @@
|
|
|
1
|
+
import LoadingSpinner from './LoadingSpinner';
|
|
2
|
+
|
|
1
3
|
function Header() {
|
|
2
4
|
return (
|
|
3
|
-
<header>
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
<header className="site-header">
|
|
6
|
+
<div className="hero-panel">
|
|
7
|
+
<div className="hero-copy">
|
|
8
|
+
<p className="eyebrow">
|
|
9
|
+
<span className="eyebrow-dot" aria-hidden="true" />A BETTER MIX,
|
|
10
|
+
EVERY ROUND
|
|
11
|
+
</p>
|
|
12
|
+
<h1>
|
|
13
|
+
Round-Table <span>Scheduler</span>
|
|
14
|
+
</h1>
|
|
15
|
+
<p className="subtitle">
|
|
16
|
+
Plan your tables in a couple of minutes. We’ll find a good mix for
|
|
17
|
+
every round.
|
|
18
|
+
</p>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<div className="hero-loading" aria-hidden="true">
|
|
22
|
+
<LoadingSpinner />
|
|
23
|
+
<span className="hero-loading-label">MIXING TABLES</span>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
8
26
|
</header>
|
|
9
27
|
);
|
|
10
28
|
}
|
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
function PairInput({ pair, onChange, onRemove }) {
|
|
1
|
+
function PairInput({ pair, pairLabel, helpId, onChange, onRemove }) {
|
|
2
2
|
const handleUChange = (e) => {
|
|
3
3
|
const value = e.target.value;
|
|
4
|
-
onChange('u', value === '' ? '' : parseInt(value) || '');
|
|
4
|
+
onChange('u', value === '' ? '' : Number.parseInt(value, 10) || '');
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
const handleVChange = (e) => {
|
|
8
8
|
const value = e.target.value;
|
|
9
|
-
onChange('v', value === '' ? '' : parseInt(value) || '');
|
|
9
|
+
onChange('v', value === '' ? '' : Number.parseInt(value, 10) || '');
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
|
-
<
|
|
14
|
-
<
|
|
13
|
+
<fieldset className="pair-item">
|
|
14
|
+
<legend className="visually-hidden">{pairLabel}</legend>
|
|
15
|
+
<span className="pair-label" aria-hidden="true">
|
|
16
|
+
PAIR
|
|
17
|
+
</span>
|
|
15
18
|
<input
|
|
16
19
|
type="number"
|
|
17
20
|
className="pair-u"
|
|
18
21
|
placeholder="Participant 1"
|
|
22
|
+
aria-label="Participant 1"
|
|
19
23
|
min="1"
|
|
24
|
+
inputMode="numeric"
|
|
25
|
+
aria-describedby={helpId}
|
|
20
26
|
value={pair.u === '' || pair.u === undefined ? '' : pair.u}
|
|
21
27
|
onChange={handleUChange}
|
|
22
28
|
/>
|
|
@@ -25,14 +31,22 @@ function PairInput({ pair, onChange, onRemove }) {
|
|
|
25
31
|
type="number"
|
|
26
32
|
className="pair-v"
|
|
27
33
|
placeholder="Participant 2"
|
|
34
|
+
aria-label="Participant 2"
|
|
28
35
|
min="1"
|
|
36
|
+
inputMode="numeric"
|
|
37
|
+
aria-describedby={helpId}
|
|
29
38
|
value={pair.v === '' || pair.v === undefined ? '' : pair.v}
|
|
30
39
|
onChange={handleVChange}
|
|
31
40
|
/>
|
|
32
|
-
<button
|
|
41
|
+
<button
|
|
42
|
+
type="button"
|
|
43
|
+
className="remove-pair"
|
|
44
|
+
onClick={onRemove}
|
|
45
|
+
aria-label={`Remove ${pairLabel}`}
|
|
46
|
+
>
|
|
33
47
|
Remove
|
|
34
48
|
</button>
|
|
35
|
-
</
|
|
49
|
+
</fieldset>
|
|
36
50
|
);
|
|
37
51
|
}
|
|
38
52
|
|
|
@@ -6,8 +6,14 @@ function PairStatus({ schedule }) {
|
|
|
6
6
|
<div className="pair-status-section">
|
|
7
7
|
<h3>{title}</h3>
|
|
8
8
|
<div className="pair-list">
|
|
9
|
-
{pairs.map((pair
|
|
10
|
-
<span
|
|
9
|
+
{pairs.map((pair) => (
|
|
10
|
+
<span
|
|
11
|
+
key={pair
|
|
12
|
+
.slice()
|
|
13
|
+
.sort((left, right) => left - right)
|
|
14
|
+
.join('-')}
|
|
15
|
+
className={`pair-badge ${className}`}
|
|
16
|
+
>
|
|
11
17
|
{pair[0]} × {pair[1]}
|
|
12
18
|
</span>
|
|
13
19
|
))}
|