@elice/material-runbox 1.260908.0 → 1.260910.0
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/cjs/_virtual/_rollupPluginBabelHelpers.js +16 -0
- package/cjs/assets/runbox-loading.svg.js +7 -0
- package/cjs/components/material-runbox/MaterialRunbox.js +16 -11
- package/cjs/components/material-runbox/MaterialRunboxContent.d.ts +2 -0
- package/cjs/components/material-runbox/MaterialRunboxContent.js +93 -65
- package/cjs/components/material-runbox/MaterialRunboxHeader.js +55 -69
- package/cjs/components/material-runbox/actions/MaterialRunboxActionDisconnect.d.ts +1 -4
- package/cjs/components/material-runbox/actions/MaterialRunboxActionDisconnect.js +29 -2
- package/cjs/components/material-runbox/actions/MaterialRunboxActionDisconnectMenuItem.d.ts +3 -0
- package/cjs/components/material-runbox/actions/MaterialRunboxActionDisconnectMenuItem.js +90 -0
- package/cjs/components/material-runbox/actions/MaterialRunboxActionMenu.d.ts +3 -1
- package/cjs/components/material-runbox/actions/MaterialRunboxActionMenu.js +26 -7
- package/cjs/components/material-runbox/actions/MaterialRunboxActionRestart.d.ts +1 -2
- package/cjs/components/material-runbox/actions/MaterialRunboxActionRestart.js +9 -26
- package/cjs/components/material-runbox/contexts/MaterialRunboxControlContext.d.ts +14 -0
- package/cjs/components/material-runbox/contexts/MaterialRunboxControlContext.js +56 -0
- package/cjs/components/material-runbox/contexts/index.d.ts +2 -0
- package/cjs/components/material-runbox/contexts/index.js +4 -0
- package/cjs/components/material-runbox/disk/MaterialRunboxDiskUsageAlert.d.ts +13 -0
- package/cjs/components/material-runbox/disk/MaterialRunboxDiskUsageAlert.js +71 -0
- package/cjs/components/material-runbox/disk/MaterialRunboxDiskUsageDialog.d.ts +10 -0
- package/cjs/components/material-runbox/disk/MaterialRunboxDiskUsageDialog.js +98 -0
- package/cjs/components/material-runbox/disk/MaterialRunboxEnvResetButton.d.ts +10 -0
- package/cjs/components/material-runbox/disk/MaterialRunboxEnvResetButton.js +151 -0
- package/cjs/components/material-runbox/disk/MaterialRunboxEnvResetDialog.d.ts +13 -0
- package/cjs/components/material-runbox/disk/MaterialRunboxEnvResetDialog.js +98 -0
- package/cjs/components/material-runbox/disk/index.d.ts +8 -1
- package/cjs/components/material-runbox/disk/index.js +8 -2
- package/cjs/components/material-runbox/hooks/index.d.ts +3 -0
- package/cjs/components/material-runbox/hooks/index.js +14 -0
- package/cjs/components/material-runbox/hooks/useRunboxControl.d.ts +4 -3
- package/cjs/components/material-runbox/hooks/useRunboxControl.js +43 -14
- package/cjs/components/material-runbox/hooks/useRunboxDiskUsage.d.ts +16 -0
- package/cjs/components/material-runbox/hooks/useRunboxDiskUsage.js +50 -0
- package/cjs/components/material-runbox/hooks/useRunboxNetworkStatus.d.ts +14 -0
- package/cjs/components/material-runbox/hooks/useRunboxNetworkStatus.js +65 -0
- package/cjs/components/material-runbox/hooks/useRunboxSessionEndWarning.d.ts +18 -0
- package/cjs/components/material-runbox/hooks/useRunboxSessionEndWarning.js +67 -0
- package/cjs/components/material-runbox/locales/en.json.js +1 -1
- package/cjs/components/material-runbox/locales/ja.json.js +1 -1
- package/cjs/components/material-runbox/locales/ko.json.js +1 -1
- package/cjs/components/material-runbox/locales/th.json.js +1 -1
- package/cjs/components/material-runbox/runtime/Runtime.js +21 -18
- package/cjs/components/material-runbox/runtime/RuntimeChangeMaterialDialog.d.ts +0 -1
- package/cjs/components/material-runbox/runtime/RuntimeChangeMaterialDialog.js +9 -3
- package/cjs/components/material-runbox/runtime/RuntimeOverlayAssigned.d.ts +5 -3
- package/cjs/components/material-runbox/runtime/RuntimeOverlayAssigned.js +6 -54
- package/cjs/components/material-runbox/runtime/RuntimeOverlayConflicted.d.ts +0 -1
- package/cjs/components/material-runbox/runtime/RuntimeOverlayConflicted.js +68 -64
- package/cjs/components/material-runbox/runtime/RuntimeOverlayLoading.d.ts +9 -0
- package/cjs/components/material-runbox/runtime/RuntimeOverlayLoading.js +283 -0
- package/cjs/components/material-runbox/runtime/RuntimeOverlayQueued.d.ts +5 -3
- package/cjs/components/material-runbox/runtime/RuntimeOverlayQueued.js +6 -64
- package/cjs/components/material-runbox/runtime/RuntimeOverlayTerminated.d.ts +4 -1
- package/cjs/components/material-runbox/runtime/RuntimeOverlayTerminated.js +92 -70
- package/cjs/components/material-runbox/runtime/runtime-loading-tips.d.ts +7 -0
- package/cjs/components/material-runbox/runtime/runtime-loading-tips.js +148 -0
- package/cjs/components/material-runbox/status/MaterialRunboxStatusButton.d.ts +15 -0
- package/cjs/components/material-runbox/status/MaterialRunboxStatusButton.js +117 -0
- package/cjs/components/material-runbox/status/MaterialRunboxStatusConnectionItem.d.ts +12 -0
- package/cjs/components/material-runbox/status/MaterialRunboxStatusConnectionItem.js +35 -0
- package/cjs/components/material-runbox/status/MaterialRunboxStatusPopover.d.ts +14 -0
- package/cjs/components/material-runbox/status/MaterialRunboxStatusPopover.js +161 -0
- package/cjs/components/material-runbox/status/MaterialRunboxStatusResourceItem.d.ts +11 -0
- package/cjs/components/material-runbox/status/MaterialRunboxStatusResourceItem.js +41 -0
- package/cjs/components/material-runbox/status/index.d.ts +4 -0
- package/cjs/components/material-runbox/status/index.js +9 -0
- package/cjs/components/material-runbox/theme.d.ts +2 -0
- package/cjs/components/material-runbox/theme.js +15 -0
- package/cjs/components/material-runbox/timer/MaterialRunboxQuotaAlmostEndDialog.d.ts +11 -0
- package/cjs/components/material-runbox/timer/MaterialRunboxQuotaAlmostEndDialog.js +125 -0
- package/cjs/components/material-runbox/timer/MaterialRunboxQuotaAmount.d.ts +13 -0
- package/cjs/components/material-runbox/timer/MaterialRunboxQuotaAmount.js +56 -0
- package/cjs/components/material-runbox/timer/MaterialRunboxQuotaPerSessionAlmostEndDialog.d.ts +12 -0
- package/cjs/components/material-runbox/timer/MaterialRunboxQuotaPerSessionAlmostEndDialog.js +126 -0
- package/cjs/components/material-runbox/timer/MaterialRunboxQuotaTimePart.d.ts +15 -0
- package/cjs/components/material-runbox/timer/MaterialRunboxQuotaTimePart.js +50 -0
- package/cjs/components/material-runbox/timer/MaterialRunboxTimer.d.ts +6 -1
- package/cjs/components/material-runbox/timer/MaterialRunboxTimer.js +26 -18
- package/cjs/components/material-runbox/timer/MaterialRunboxTimerDetailPopover.js +21 -81
- package/cjs/components/shared/hooks/index.d.ts +1 -0
- package/cjs/components/shared/hooks/index.js +7 -0
- package/cjs/components/shared/hooks/useBreakpoint.d.ts +4 -0
- package/cjs/components/shared/hooks/useBreakpoint.js +12 -0
- package/es/_virtual/_rollupPluginBabelHelpers.js +13 -1
- package/es/assets/runbox-loading.svg.js +3 -0
- package/es/components/material-runbox/MaterialRunbox.js +16 -11
- package/es/components/material-runbox/MaterialRunboxContent.d.ts +2 -0
- package/es/components/material-runbox/MaterialRunboxContent.js +94 -66
- package/es/components/material-runbox/MaterialRunboxHeader.js +56 -70
- package/es/components/material-runbox/actions/MaterialRunboxActionDisconnect.d.ts +1 -4
- package/es/components/material-runbox/actions/MaterialRunboxActionDisconnect.js +30 -3
- package/es/components/material-runbox/actions/MaterialRunboxActionDisconnectMenuItem.d.ts +3 -0
- package/es/components/material-runbox/actions/MaterialRunboxActionDisconnectMenuItem.js +82 -0
- package/es/components/material-runbox/actions/MaterialRunboxActionMenu.d.ts +3 -1
- package/es/components/material-runbox/actions/MaterialRunboxActionMenu.js +28 -9
- package/es/components/material-runbox/actions/MaterialRunboxActionRestart.d.ts +1 -2
- package/es/components/material-runbox/actions/MaterialRunboxActionRestart.js +9 -26
- package/es/components/material-runbox/contexts/MaterialRunboxControlContext.d.ts +14 -0
- package/es/components/material-runbox/contexts/MaterialRunboxControlContext.js +46 -0
- package/es/components/material-runbox/contexts/index.d.ts +2 -0
- package/es/components/material-runbox/contexts/index.js +1 -0
- package/es/components/material-runbox/disk/MaterialRunboxDiskUsageAlert.d.ts +13 -0
- package/es/components/material-runbox/disk/MaterialRunboxDiskUsageAlert.js +67 -0
- package/es/components/material-runbox/disk/MaterialRunboxDiskUsageDialog.d.ts +10 -0
- package/es/components/material-runbox/disk/MaterialRunboxDiskUsageDialog.js +94 -0
- package/es/components/material-runbox/disk/MaterialRunboxEnvResetButton.d.ts +10 -0
- package/es/components/material-runbox/disk/MaterialRunboxEnvResetButton.js +143 -0
- package/es/components/material-runbox/disk/MaterialRunboxEnvResetDialog.d.ts +13 -0
- package/es/components/material-runbox/disk/MaterialRunboxEnvResetDialog.js +90 -0
- package/es/components/material-runbox/disk/index.d.ts +8 -1
- package/es/components/material-runbox/disk/index.js +4 -1
- package/es/components/material-runbox/hooks/index.d.ts +3 -0
- package/es/components/material-runbox/hooks/index.js +3 -0
- package/es/components/material-runbox/hooks/useRunboxControl.d.ts +4 -3
- package/es/components/material-runbox/hooks/useRunboxControl.js +43 -14
- package/es/components/material-runbox/hooks/useRunboxDiskUsage.d.ts +16 -0
- package/es/components/material-runbox/hooks/useRunboxDiskUsage.js +42 -0
- package/es/components/material-runbox/hooks/useRunboxNetworkStatus.d.ts +14 -0
- package/es/components/material-runbox/hooks/useRunboxNetworkStatus.js +59 -0
- package/es/components/material-runbox/hooks/useRunboxSessionEndWarning.d.ts +18 -0
- package/es/components/material-runbox/hooks/useRunboxSessionEndWarning.js +63 -0
- package/es/components/material-runbox/locales/en.json.js +1 -1
- package/es/components/material-runbox/locales/ja.json.js +1 -1
- package/es/components/material-runbox/locales/ko.json.js +1 -1
- package/es/components/material-runbox/locales/th.json.js +1 -1
- package/es/components/material-runbox/runtime/Runtime.js +22 -19
- package/es/components/material-runbox/runtime/RuntimeChangeMaterialDialog.d.ts +0 -1
- package/es/components/material-runbox/runtime/RuntimeChangeMaterialDialog.js +9 -3
- package/es/components/material-runbox/runtime/RuntimeOverlayAssigned.d.ts +5 -3
- package/es/components/material-runbox/runtime/RuntimeOverlayAssigned.js +7 -55
- package/es/components/material-runbox/runtime/RuntimeOverlayConflicted.d.ts +0 -1
- package/es/components/material-runbox/runtime/RuntimeOverlayConflicted.js +69 -65
- package/es/components/material-runbox/runtime/RuntimeOverlayLoading.d.ts +9 -0
- package/es/components/material-runbox/runtime/RuntimeOverlayLoading.js +275 -0
- package/es/components/material-runbox/runtime/RuntimeOverlayQueued.d.ts +5 -3
- package/es/components/material-runbox/runtime/RuntimeOverlayQueued.js +7 -65
- package/es/components/material-runbox/runtime/RuntimeOverlayTerminated.d.ts +4 -1
- package/es/components/material-runbox/runtime/RuntimeOverlayTerminated.js +82 -60
- package/es/components/material-runbox/runtime/runtime-loading-tips.d.ts +7 -0
- package/es/components/material-runbox/runtime/runtime-loading-tips.js +146 -0
- package/es/components/material-runbox/status/MaterialRunboxStatusButton.d.ts +15 -0
- package/es/components/material-runbox/status/MaterialRunboxStatusButton.js +109 -0
- package/es/components/material-runbox/status/MaterialRunboxStatusConnectionItem.d.ts +12 -0
- package/es/components/material-runbox/status/MaterialRunboxStatusConnectionItem.js +31 -0
- package/es/components/material-runbox/status/MaterialRunboxStatusPopover.d.ts +14 -0
- package/es/components/material-runbox/status/MaterialRunboxStatusPopover.js +157 -0
- package/es/components/material-runbox/status/MaterialRunboxStatusResourceItem.d.ts +11 -0
- package/es/components/material-runbox/status/MaterialRunboxStatusResourceItem.js +37 -0
- package/es/components/material-runbox/status/index.d.ts +4 -0
- package/es/components/material-runbox/status/index.js +2 -0
- package/es/components/material-runbox/theme.d.ts +2 -0
- package/es/components/material-runbox/theme.js +12 -0
- package/es/components/material-runbox/timer/MaterialRunboxQuotaAlmostEndDialog.d.ts +11 -0
- package/es/components/material-runbox/timer/MaterialRunboxQuotaAlmostEndDialog.js +121 -0
- package/es/components/material-runbox/timer/MaterialRunboxQuotaAmount.d.ts +13 -0
- package/es/components/material-runbox/timer/MaterialRunboxQuotaAmount.js +52 -0
- package/es/components/material-runbox/timer/MaterialRunboxQuotaPerSessionAlmostEndDialog.d.ts +12 -0
- package/es/components/material-runbox/timer/MaterialRunboxQuotaPerSessionAlmostEndDialog.js +122 -0
- package/es/components/material-runbox/timer/MaterialRunboxQuotaTimePart.d.ts +15 -0
- package/es/components/material-runbox/timer/MaterialRunboxQuotaTimePart.js +46 -0
- package/es/components/material-runbox/timer/MaterialRunboxTimer.d.ts +6 -1
- package/es/components/material-runbox/timer/MaterialRunboxTimer.js +25 -17
- package/es/components/material-runbox/timer/MaterialRunboxTimerDetailPopover.js +18 -78
- package/es/components/shared/hooks/index.d.ts +1 -0
- package/es/components/shared/hooks/index.js +1 -0
- package/es/components/shared/hooks/useBreakpoint.d.ts +4 -0
- package/es/components/shared/hooks/useBreakpoint.js +10 -0
- package/package.json +7 -7
- package/cjs/assets/queue.gif.js +0 -7
- package/cjs/assets/runbox_logo.png.js +0 -7
- package/cjs/components/material-runbox/MaterialRunboxFooter.d.ts +0 -4
- package/cjs/components/material-runbox/MaterialRunboxFooter.js +0 -64
- package/cjs/components/material-runbox/disk/MaterialRunboxDiskAlmostFullSnackbar.d.ts +0 -5
- package/cjs/components/material-runbox/disk/MaterialRunboxDiskAlmostFullSnackbar.js +0 -98
- package/cjs/components/material-runbox/timer/MaterialRunboxAlmostEndSnackbars.d.ts +0 -6
- package/cjs/components/material-runbox/timer/MaterialRunboxAlmostEndSnackbars.js +0 -90
- package/es/assets/queue.gif.js +0 -3
- package/es/assets/runbox_logo.png.js +0 -3
- package/es/components/material-runbox/MaterialRunboxFooter.d.ts +0 -4
- package/es/components/material-runbox/MaterialRunboxFooter.js +0 -56
- package/es/components/material-runbox/disk/MaterialRunboxDiskAlmostFullSnackbar.d.ts +0 -5
- package/es/components/material-runbox/disk/MaterialRunboxDiskAlmostFullSnackbar.js +0 -94
- package/es/components/material-runbox/timer/MaterialRunboxAlmostEndSnackbars.d.ts +0 -6
- package/es/components/material-runbox/timer/MaterialRunboxAlmostEndSnackbars.js +0 -86
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
+
var tslib = require('tslib');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var React = require('react');
|
|
9
|
+
var intl = require('@elice/intl');
|
|
10
|
+
var muiXSnackbar = require('@elice/mui-x-snackbar');
|
|
11
|
+
var lab = require('@mui/lab');
|
|
12
|
+
var material = require('@mui/material');
|
|
13
|
+
var theme = require('../theme.js');
|
|
14
|
+
var MaterialRunboxEnvResetDialog = require('./MaterialRunboxEnvResetDialog.js');
|
|
15
|
+
var MaterialRunboxApiContext = require('../contexts/MaterialRunboxApiContext.js');
|
|
16
|
+
var MaterialRunboxControlContext = require('../contexts/MaterialRunboxControlContext.js');
|
|
17
|
+
|
|
18
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
19
|
+
|
|
20
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
21
|
+
|
|
22
|
+
//
|
|
23
|
+
//
|
|
24
|
+
//
|
|
25
|
+
var MaterialRunboxEnvResetButton = function MaterialRunboxEnvResetButton(_a) {
|
|
26
|
+
var runtimeTemplateId = _a.runtimeTemplateId,
|
|
27
|
+
courseId = _a.courseId,
|
|
28
|
+
userId = _a.userId,
|
|
29
|
+
onSuccess = _a.onSuccess,
|
|
30
|
+
props = tslib.__rest(_a, ["runtimeTemplateId", "courseId", "userId", "onSuccess"]);
|
|
31
|
+
var intl$1 = intl.useRawEliceIntl();
|
|
32
|
+
var _useSnackbar = muiXSnackbar.useSnackbar(),
|
|
33
|
+
enqueueSnackbar = _useSnackbar.enqueueSnackbar;
|
|
34
|
+
var materialRunboxApi = MaterialRunboxApiContext.useMaterialRunboxApiContext();
|
|
35
|
+
var _useMaterialRunboxCon = MaterialRunboxControlContext.useMaterialRunboxControlContext(),
|
|
36
|
+
startRuntime = _useMaterialRunboxCon.start;
|
|
37
|
+
var _React$useState = React__default.default.useState(false),
|
|
38
|
+
_React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
|
|
39
|
+
isDialogOpened = _React$useState2[0],
|
|
40
|
+
setDialogOpened = _React$useState2[1];
|
|
41
|
+
var _React$useState3 = React__default.default.useState(false),
|
|
42
|
+
_React$useState4 = _rollupPluginBabelHelpers.slicedToArray(_React$useState3, 2),
|
|
43
|
+
isResetting = _React$useState4[0],
|
|
44
|
+
setResetting = _React$useState4[1];
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
*/
|
|
48
|
+
var handleConfirm = /*#__PURE__*/function () {
|
|
49
|
+
var _ref = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee() {
|
|
50
|
+
var _yield$materialRunbox, _yield$materialRunbox2, runtime;
|
|
51
|
+
return _rollupPluginBabelHelpers.regenerator().w(function (_context) {
|
|
52
|
+
while (1) switch (_context.p = _context.n) {
|
|
53
|
+
case 0:
|
|
54
|
+
setDialogOpened(false);
|
|
55
|
+
setResetting(true);
|
|
56
|
+
_context.p = 1;
|
|
57
|
+
_context.n = 2;
|
|
58
|
+
return materialRunboxApi.runtime.runtimeGet({
|
|
59
|
+
filterRuntimeTemplateId: runtimeTemplateId,
|
|
60
|
+
skip: 0,
|
|
61
|
+
count: 1,
|
|
62
|
+
userId: userId,
|
|
63
|
+
eliceCourseId: courseId
|
|
64
|
+
});
|
|
65
|
+
case 2:
|
|
66
|
+
_yield$materialRunbox = _context.v;
|
|
67
|
+
_yield$materialRunbox2 = _rollupPluginBabelHelpers.slicedToArray(_yield$materialRunbox, 1);
|
|
68
|
+
runtime = _yield$materialRunbox2[0];
|
|
69
|
+
if (runtime) {
|
|
70
|
+
_context.n = 3;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
enqueueSnackbar(intl$1.formatMessage({
|
|
74
|
+
id: 'runbox.disk.env_reset.noti.no_runtime'
|
|
75
|
+
}), {
|
|
76
|
+
variant: 'error'
|
|
77
|
+
});
|
|
78
|
+
return _context.a(2);
|
|
79
|
+
case 3:
|
|
80
|
+
_context.n = 4;
|
|
81
|
+
return materialRunboxApi.runtime.runtimeRuntimeIdDiskResetPost({
|
|
82
|
+
runtimeId: runtime.id,
|
|
83
|
+
eliceCourseId: courseId
|
|
84
|
+
});
|
|
85
|
+
case 4:
|
|
86
|
+
enqueueSnackbar(intl$1.formatMessage({
|
|
87
|
+
id: 'runbox.disk.env_reset.noti.success'
|
|
88
|
+
}), {
|
|
89
|
+
variant: 'success'
|
|
90
|
+
});
|
|
91
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
|
|
92
|
+
// The reset replaces the disk, which the server can only do with the
|
|
93
|
+
// runtime detached, so the session is always gone by now. Start it back
|
|
94
|
+
// up so the learner lands on the practice screen instead of a dead one.
|
|
95
|
+
_context.n = 5;
|
|
96
|
+
return startRuntime({
|
|
97
|
+
force: true,
|
|
98
|
+
runPreCheck: false
|
|
99
|
+
});
|
|
100
|
+
case 5:
|
|
101
|
+
_context.n = 7;
|
|
102
|
+
break;
|
|
103
|
+
case 6:
|
|
104
|
+
_context.p = 6;
|
|
105
|
+
_context.v;
|
|
106
|
+
enqueueSnackbar(intl$1.formatMessage({
|
|
107
|
+
id: 'runbox.disk.env_reset.noti.error'
|
|
108
|
+
}), {
|
|
109
|
+
variant: 'error'
|
|
110
|
+
});
|
|
111
|
+
case 7:
|
|
112
|
+
_context.p = 7;
|
|
113
|
+
setResetting(false);
|
|
114
|
+
return _context.f(7);
|
|
115
|
+
case 8:
|
|
116
|
+
return _context.a(2);
|
|
117
|
+
}
|
|
118
|
+
}, _callee, null, [[1, 6, 7, 8]]);
|
|
119
|
+
}));
|
|
120
|
+
return function handleConfirm() {
|
|
121
|
+
return _ref.apply(this, arguments);
|
|
122
|
+
};
|
|
123
|
+
}();
|
|
124
|
+
//
|
|
125
|
+
//
|
|
126
|
+
//
|
|
127
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
128
|
+
children: [jsxRuntime.jsx(lab.LoadingButton, Object.assign({}, props, {
|
|
129
|
+
loading: isResetting,
|
|
130
|
+
onClick: function onClick() {
|
|
131
|
+
return setDialogOpened(true);
|
|
132
|
+
},
|
|
133
|
+
children: intl$1.formatMessage({
|
|
134
|
+
id: 'runbox.disk.env_reset.title'
|
|
135
|
+
})
|
|
136
|
+
})), jsxRuntime.jsx(material.ThemeProvider, {
|
|
137
|
+
theme: theme.runboxDarkTheme,
|
|
138
|
+
children: jsxRuntime.jsx(MaterialRunboxEnvResetDialog.default, {
|
|
139
|
+
open: isDialogOpened,
|
|
140
|
+
onClose: function onClose() {
|
|
141
|
+
return setDialogOpened(false);
|
|
142
|
+
},
|
|
143
|
+
onConfirm: function onConfirm() {
|
|
144
|
+
return void handleConfirm();
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
})]
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
exports.default = MaterialRunboxEnvResetButton;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface MaterialRunboxEnvResetDialogProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
onConfirm: () => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Confirms clearing the practice environment. The checkbox is the explicit
|
|
9
|
+
* acknowledgement `[R-3]` asks for: the delete action stays disabled until it
|
|
10
|
+
* is ticked.
|
|
11
|
+
*/
|
|
12
|
+
declare const MaterialRunboxEnvResetDialog: React.FC<MaterialRunboxEnvResetDialogProps>;
|
|
13
|
+
export default MaterialRunboxEnvResetDialog;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var intl = require('@elice/intl');
|
|
9
|
+
var muiElements = require('@elice/mui-elements');
|
|
10
|
+
var proSolidSvgIcons = require('@fortawesome/pro-solid-svg-icons');
|
|
11
|
+
var material = require('@mui/material');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
14
|
+
|
|
15
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
16
|
+
|
|
17
|
+
//
|
|
18
|
+
//
|
|
19
|
+
//
|
|
20
|
+
/**
|
|
21
|
+
* Confirms clearing the practice environment. The checkbox is the explicit
|
|
22
|
+
* acknowledgement `[R-3]` asks for: the delete action stays disabled until it
|
|
23
|
+
* is ticked.
|
|
24
|
+
*/
|
|
25
|
+
var MaterialRunboxEnvResetDialog = function MaterialRunboxEnvResetDialog(_ref) {
|
|
26
|
+
var open = _ref.open,
|
|
27
|
+
onClose = _ref.onClose,
|
|
28
|
+
onConfirm = _ref.onConfirm;
|
|
29
|
+
var intl$1 = intl.useRawEliceIntl();
|
|
30
|
+
var _React$useState = React__default.default.useState(false),
|
|
31
|
+
_React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
|
|
32
|
+
isAcknowledged = _React$useState2[0],
|
|
33
|
+
setAcknowledged = _React$useState2[1];
|
|
34
|
+
React__default.default.useEffect(function () {
|
|
35
|
+
if (!open) {
|
|
36
|
+
setAcknowledged(false);
|
|
37
|
+
}
|
|
38
|
+
}, [open]);
|
|
39
|
+
//
|
|
40
|
+
//
|
|
41
|
+
//
|
|
42
|
+
return jsxRuntime.jsxs(material.Dialog, {
|
|
43
|
+
fullWidth: true,
|
|
44
|
+
open: open,
|
|
45
|
+
maxWidth: "xs",
|
|
46
|
+
onClose: onClose,
|
|
47
|
+
children: [jsxRuntime.jsx(material.DialogTitle, {
|
|
48
|
+
children: jsxRuntime.jsxs(material.Stack, {
|
|
49
|
+
direction: "row",
|
|
50
|
+
alignItems: "center",
|
|
51
|
+
gap: "0.5rem",
|
|
52
|
+
children: [jsxRuntime.jsx(muiElements.EliceIcon, {
|
|
53
|
+
icon: proSolidSvgIcons.faCircleExclamation,
|
|
54
|
+
color: "error"
|
|
55
|
+
}), intl$1.formatMessage({
|
|
56
|
+
id: 'runbox.disk.env_reset.dialog.title'
|
|
57
|
+
})]
|
|
58
|
+
})
|
|
59
|
+
}), jsxRuntime.jsxs(material.DialogContent, {
|
|
60
|
+
children: [jsxRuntime.jsx(material.DialogContentText, {
|
|
61
|
+
whiteSpace: "pre-line",
|
|
62
|
+
children: intl$1.formatMessage({
|
|
63
|
+
id: 'runbox.disk.env_reset.dialog.description'
|
|
64
|
+
})
|
|
65
|
+
}), jsxRuntime.jsx(material.FormControlLabel, {
|
|
66
|
+
sx: {
|
|
67
|
+
marginTop: '1rem'
|
|
68
|
+
},
|
|
69
|
+
control: jsxRuntime.jsx(material.Checkbox, {
|
|
70
|
+
checked: isAcknowledged,
|
|
71
|
+
onChange: function onChange(e) {
|
|
72
|
+
return setAcknowledged(e.target.checked);
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
label: intl$1.formatMessage({
|
|
76
|
+
id: 'runbox.disk.env_reset.dialog.acknowledge'
|
|
77
|
+
})
|
|
78
|
+
})]
|
|
79
|
+
}), jsxRuntime.jsxs(material.DialogActions, {
|
|
80
|
+
children: [jsxRuntime.jsx(material.Button, {
|
|
81
|
+
color: "inherit",
|
|
82
|
+
onClick: onClose,
|
|
83
|
+
children: intl$1.formatMessage({
|
|
84
|
+
id: 'runbox.disk.env_reset.dialog.actions.cancel'
|
|
85
|
+
})
|
|
86
|
+
}), jsxRuntime.jsx(material.Button, {
|
|
87
|
+
color: "error",
|
|
88
|
+
disabled: !isAcknowledged,
|
|
89
|
+
onClick: onConfirm,
|
|
90
|
+
children: intl$1.formatMessage({
|
|
91
|
+
id: 'runbox.disk.env_reset.dialog.actions.confirm'
|
|
92
|
+
})
|
|
93
|
+
})]
|
|
94
|
+
})]
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
exports.default = MaterialRunboxEnvResetDialog;
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
export { default as
|
|
1
|
+
export { default as MaterialRunboxDiskUsageAlert } from './MaterialRunboxDiskUsageAlert';
|
|
2
|
+
export { default as MaterialRunboxDiskUsageDialog } from './MaterialRunboxDiskUsageDialog';
|
|
3
|
+
export { default as MaterialRunboxEnvResetButton } from './MaterialRunboxEnvResetButton';
|
|
4
|
+
export { default as MaterialRunboxEnvResetDialog } from './MaterialRunboxEnvResetDialog';
|
|
5
|
+
export type { MaterialRunboxDiskUsageAlertProps } from './MaterialRunboxDiskUsageAlert';
|
|
6
|
+
export type { MaterialRunboxDiskUsageDialogProps } from './MaterialRunboxDiskUsageDialog';
|
|
7
|
+
export type { MaterialRunboxEnvResetButtonProps } from './MaterialRunboxEnvResetButton';
|
|
8
|
+
export type { MaterialRunboxEnvResetDialogProps } from './MaterialRunboxEnvResetDialog';
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var MaterialRunboxDiskUsageAlert = require('./MaterialRunboxDiskUsageAlert.js');
|
|
4
|
+
var MaterialRunboxDiskUsageDialog = require('./MaterialRunboxDiskUsageDialog.js');
|
|
5
|
+
var MaterialRunboxEnvResetButton = require('./MaterialRunboxEnvResetButton.js');
|
|
6
|
+
var MaterialRunboxEnvResetDialog = require('./MaterialRunboxEnvResetDialog.js');
|
|
4
7
|
|
|
5
8
|
|
|
6
9
|
|
|
7
|
-
exports.
|
|
10
|
+
exports.MaterialRunboxDiskUsageAlert = MaterialRunboxDiskUsageAlert.default;
|
|
11
|
+
exports.MaterialRunboxDiskUsageDialog = MaterialRunboxDiskUsageDialog.default;
|
|
12
|
+
exports.MaterialRunboxEnvResetButton = MaterialRunboxEnvResetButton.default;
|
|
13
|
+
exports.MaterialRunboxEnvResetDialog = MaterialRunboxEnvResetDialog.default;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export * from './useRunboxControl';
|
|
2
|
+
export * from './useRunboxSessionEndWarning';
|
|
2
3
|
export * from './useRunboxTimer';
|
|
3
4
|
export * from './useInfiniteRunboxRunboxIdGrade';
|
|
4
5
|
export * from './useMaterialRunboxRunboxIdStarterGet';
|
|
6
|
+
export * from './useRunboxNetworkStatus';
|
|
7
|
+
export * from './useRunboxDiskUsage';
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var useRunboxControl = require('./useRunboxControl.js');
|
|
4
|
+
var useRunboxSessionEndWarning = require('./useRunboxSessionEndWarning.js');
|
|
4
5
|
var useRunboxTimer = require('./useRunboxTimer.js');
|
|
5
6
|
var useInfiniteRunboxRunboxIdGrade = require('./useInfiniteRunboxRunboxIdGrade.js');
|
|
6
7
|
var useMaterialRunboxRunboxIdStarterGet = require('./useMaterialRunboxRunboxIdStarterGet.js');
|
|
8
|
+
var useRunboxNetworkStatus = require('./useRunboxNetworkStatus.js');
|
|
9
|
+
var useRunboxDiskUsage = require('./useRunboxDiskUsage.js');
|
|
7
10
|
|
|
8
11
|
|
|
9
12
|
|
|
@@ -12,6 +15,17 @@ Object.defineProperty(exports, "RunboxPreCheckResultType", {
|
|
|
12
15
|
get: function () { return useRunboxControl.RunboxPreCheckResultType; }
|
|
13
16
|
});
|
|
14
17
|
exports.useRunboxControl = useRunboxControl.useRunboxControl;
|
|
18
|
+
exports.QUOTA_ALMOST_END_MINUTES = useRunboxSessionEndWarning.QUOTA_ALMOST_END_MINUTES;
|
|
19
|
+
exports.QUOTA_PER_SESSION_ALMOST_END_MINUTES = useRunboxSessionEndWarning.QUOTA_PER_SESSION_ALMOST_END_MINUTES;
|
|
20
|
+
exports.useRunboxSessionEndWarning = useRunboxSessionEndWarning.useRunboxSessionEndWarning;
|
|
15
21
|
exports.useRunboxTimer = useRunboxTimer.useRunboxTimer;
|
|
16
22
|
exports.useInfiniteRunboxRunboxIdGrade = useInfiniteRunboxRunboxIdGrade.useInfiniteRunboxRunboxIdGrade;
|
|
17
23
|
exports.useMaterialRunboxRunboxIdStarterGet = useMaterialRunboxRunboxIdStarterGet.useMaterialRunboxRunboxIdStarterGet;
|
|
24
|
+
Object.defineProperty(exports, "RunboxNetworkStatus", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return useRunboxNetworkStatus.RunboxNetworkStatus; }
|
|
27
|
+
});
|
|
28
|
+
exports.useRunboxNetworkStatus = useRunboxNetworkStatus.useRunboxNetworkStatus;
|
|
29
|
+
exports.DISK_USAGE_ERROR_RATIO = useRunboxDiskUsage.DISK_USAGE_ERROR_RATIO;
|
|
30
|
+
exports.DISK_USAGE_WARNING_RATIO = useRunboxDiskUsage.DISK_USAGE_WARNING_RATIO;
|
|
31
|
+
exports.useRunboxDiskUsage = useRunboxDiskUsage.useRunboxDiskUsage;
|
|
@@ -10,17 +10,18 @@ export type RunboxPreCheckResult = {
|
|
|
10
10
|
type: RunboxPreCheckResultType.RuntimeRunningOnOtherRunbox;
|
|
11
11
|
runningRunbox: RunningRunbox;
|
|
12
12
|
};
|
|
13
|
-
type UseRunboxControlProps = Pick<RuntimeProps, 'runbox' | 'runtime' | 'courseId' | 'refetch' | 'userId' | 'studentUserId' | 'isTutoring'>;
|
|
14
|
-
interface UseRunboxControlReturn {
|
|
13
|
+
export type UseRunboxControlProps = Pick<RuntimeProps, 'runbox' | 'runtime' | 'courseId' | 'refetch' | 'userId' | 'studentUserId' | 'isTutoring'>;
|
|
14
|
+
export interface UseRunboxControlReturn {
|
|
15
15
|
start: (args?: {
|
|
16
16
|
force?: boolean;
|
|
17
17
|
runPreCheck?: boolean;
|
|
18
18
|
}) => Promise<void>;
|
|
19
19
|
stop: () => Promise<void>;
|
|
20
|
+
isStarting: boolean;
|
|
21
|
+
isStopping: boolean;
|
|
20
22
|
preCheckStatus: RunboxPreCheckResult | null;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Hook for runbox control and status.
|
|
24
26
|
*/
|
|
25
27
|
export declare const useRunboxControl: (props: UseRunboxControlProps) => UseRunboxControlReturn;
|
|
26
|
-
export {};
|
|
@@ -35,6 +35,14 @@ var useRunboxControl = function useRunboxControl(props) {
|
|
|
35
35
|
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
|
36
36
|
preCheckStatus = _useState2[0],
|
|
37
37
|
setPreCheckStatus = _useState2[1];
|
|
38
|
+
var _useState3 = React.useState(false),
|
|
39
|
+
_useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
|
|
40
|
+
isStarting = _useState4[0],
|
|
41
|
+
setStarting = _useState4[1];
|
|
42
|
+
var _useState5 = React.useState(false),
|
|
43
|
+
_useState6 = _rollupPluginBabelHelpers.slicedToArray(_useState5, 2),
|
|
44
|
+
isStopping = _useState6[0],
|
|
45
|
+
setStopping = _useState6[1];
|
|
38
46
|
var userId = props.isTutoring ? props.studentUserId : props.userId;
|
|
39
47
|
var preCheck = React.useCallback(/*#__PURE__*/_rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee() {
|
|
40
48
|
var runningRunbox;
|
|
@@ -87,29 +95,33 @@ var useRunboxControl = function useRunboxControl(props) {
|
|
|
87
95
|
result,
|
|
88
96
|
_args2 = arguments;
|
|
89
97
|
return _rollupPluginBabelHelpers.regenerator().w(function (_context2) {
|
|
90
|
-
while (1) switch (_context2.n) {
|
|
98
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
91
99
|
case 0:
|
|
92
100
|
_ref3 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref3$force = _ref3.force, force = _ref3$force === void 0 ? false : _ref3$force, _ref3$runPreCheck = _ref3.runPreCheck, runPreCheck = _ref3$runPreCheck === void 0 ? true : _ref3$runPreCheck;
|
|
93
101
|
setPreCheckStatus(null);
|
|
94
|
-
|
|
102
|
+
setStarting(true);
|
|
103
|
+
// try/finally, not a promise finally: a rejected pre-check would skip the
|
|
104
|
+
// chain below and leave the shared flag stuck for every consumer.
|
|
105
|
+
_context2.p = 1;
|
|
95
106
|
if (!runPreCheck) {
|
|
96
|
-
_context2.n =
|
|
107
|
+
_context2.n = 3;
|
|
97
108
|
break;
|
|
98
109
|
}
|
|
99
|
-
_context2.n =
|
|
110
|
+
_context2.n = 2;
|
|
100
111
|
return preCheck();
|
|
101
|
-
case
|
|
112
|
+
case 2:
|
|
102
113
|
result = _context2.v;
|
|
103
114
|
// Store to state to display UIs.
|
|
104
115
|
setPreCheckStatus(result);
|
|
105
116
|
// Don't start if pre-check is not passed.
|
|
106
117
|
if (!(result && result.type !== exports.RunboxPreCheckResultType.Passed)) {
|
|
107
|
-
_context2.n =
|
|
118
|
+
_context2.n = 3;
|
|
108
119
|
break;
|
|
109
120
|
}
|
|
110
121
|
return _context2.a(2);
|
|
111
|
-
case
|
|
112
|
-
|
|
122
|
+
case 3:
|
|
123
|
+
_context2.n = 4;
|
|
124
|
+
return runboxStart(function (signal) {
|
|
113
125
|
return materialRunboxApi.runbox.runboxRunboxIdStartPost({
|
|
114
126
|
runboxId: props.runbox.id,
|
|
115
127
|
eliceCourseId: props.courseId,
|
|
@@ -129,9 +141,15 @@ var useRunboxControl = function useRunboxControl(props) {
|
|
|
129
141
|
variant: 'error'
|
|
130
142
|
});
|
|
131
143
|
}
|
|
132
|
-
})
|
|
144
|
+
});
|
|
145
|
+
case 4:
|
|
146
|
+
_context2.p = 4;
|
|
147
|
+
setStarting(false);
|
|
148
|
+
return _context2.f(4);
|
|
149
|
+
case 5:
|
|
150
|
+
return _context2.a(2);
|
|
133
151
|
}
|
|
134
|
-
}, _callee2);
|
|
152
|
+
}, _callee2, null, [[1,, 4, 5]]);
|
|
135
153
|
})),
|
|
136
154
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
137
155
|
[props.runbox.id, props.courseId, userId, runboxStart]);
|
|
@@ -140,9 +158,12 @@ var useRunboxControl = function useRunboxControl(props) {
|
|
|
140
158
|
*/
|
|
141
159
|
var stop = React.useCallback(/*#__PURE__*/_rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee3() {
|
|
142
160
|
return _rollupPluginBabelHelpers.regenerator().w(function (_context3) {
|
|
143
|
-
while (1) switch (_context3.n) {
|
|
161
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
144
162
|
case 0:
|
|
145
|
-
|
|
163
|
+
setStopping(true);
|
|
164
|
+
_context3.p = 1;
|
|
165
|
+
_context3.n = 2;
|
|
166
|
+
return runboxStop(function (signal) {
|
|
146
167
|
return materialRunboxApi.runbox.runboxRunboxIdStopPost({
|
|
147
168
|
runboxId: props.runbox.id,
|
|
148
169
|
eliceCourseId: props.courseId,
|
|
@@ -156,9 +177,15 @@ var useRunboxControl = function useRunboxControl(props) {
|
|
|
156
177
|
//
|
|
157
178
|
})["catch"](function (err) {
|
|
158
179
|
if (err.name !== 'AbortError') ;
|
|
159
|
-
})
|
|
180
|
+
});
|
|
181
|
+
case 2:
|
|
182
|
+
_context3.p = 2;
|
|
183
|
+
setStopping(false);
|
|
184
|
+
return _context3.f(2);
|
|
185
|
+
case 3:
|
|
186
|
+
return _context3.a(2);
|
|
160
187
|
}
|
|
161
|
-
}, _callee3);
|
|
188
|
+
}, _callee3, null, [[1,, 2, 3]]);
|
|
162
189
|
})),
|
|
163
190
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
164
191
|
[props.runbox.id, props.courseId, runboxStop]);
|
|
@@ -167,6 +194,8 @@ var useRunboxControl = function useRunboxControl(props) {
|
|
|
167
194
|
//
|
|
168
195
|
_return.current.start = start;
|
|
169
196
|
_return.current.stop = stop;
|
|
197
|
+
_return.current.isStarting = isStarting;
|
|
198
|
+
_return.current.isStopping = isStopping;
|
|
170
199
|
_return.current.preCheckStatus = preCheckStatus;
|
|
171
200
|
return _return.current;
|
|
172
201
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Matches MUI's `Alert` severity, which is where this value ends up. */
|
|
2
|
+
export type RunboxDiskUsageSeverity = 'warning' | 'error';
|
|
3
|
+
interface UseRunboxDiskUsageReturn {
|
|
4
|
+
/** `null` below the first threshold, or while the container reports no stats. */
|
|
5
|
+
severity: RunboxDiskUsageSeverity | null;
|
|
6
|
+
diskCurrent: number;
|
|
7
|
+
diskTotal: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const DISK_USAGE_WARNING_RATIO = 0.8;
|
|
10
|
+
export declare const DISK_USAGE_ERROR_RATIO = 0.9;
|
|
11
|
+
/**
|
|
12
|
+
* Disk usage against the 80% / 90% thresholds. The numbers come from the
|
|
13
|
+
* container stats stream, so they are only available while the runtime is up.
|
|
14
|
+
*/
|
|
15
|
+
export declare const useRunboxDiskUsage: () => UseRunboxDiskUsageReturn;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var runboxClient = require('@elice/runbox-client');
|
|
5
|
+
|
|
6
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
9
|
+
|
|
10
|
+
//
|
|
11
|
+
//
|
|
12
|
+
//
|
|
13
|
+
var DISK_USAGE_WARNING_RATIO = 0.8;
|
|
14
|
+
var DISK_USAGE_ERROR_RATIO = 0.9;
|
|
15
|
+
//
|
|
16
|
+
//
|
|
17
|
+
//
|
|
18
|
+
/**
|
|
19
|
+
* Disk usage against the 80% / 90% thresholds. The numbers come from the
|
|
20
|
+
* container stats stream, so they are only available while the runtime is up.
|
|
21
|
+
*/
|
|
22
|
+
var useRunboxDiskUsage = function useRunboxDiskUsage() {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
var contStats = runboxClient.useEliceRunboxContainerStats();
|
|
25
|
+
var stats = contStats ? contStats[contStats.length - 1] : null;
|
|
26
|
+
var diskCurrent = (_a = stats === null || stats === void 0 ? void 0 : stats.diskCurrent) !== null && _a !== void 0 ? _a : 0;
|
|
27
|
+
var diskTotal = (_b = stats === null || stats === void 0 ? void 0 : stats.diskTotal) !== null && _b !== void 0 ? _b : 0;
|
|
28
|
+
var severity = React__default.default.useMemo(function () {
|
|
29
|
+
if (!stats || diskTotal <= 0) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
var ratio = diskCurrent / diskTotal;
|
|
33
|
+
if (ratio >= DISK_USAGE_ERROR_RATIO) {
|
|
34
|
+
return 'error';
|
|
35
|
+
}
|
|
36
|
+
if (ratio >= DISK_USAGE_WARNING_RATIO) {
|
|
37
|
+
return 'warning';
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}, [stats, diskCurrent, diskTotal]);
|
|
41
|
+
return {
|
|
42
|
+
severity: severity,
|
|
43
|
+
diskCurrent: diskCurrent,
|
|
44
|
+
diskTotal: diskTotal
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.DISK_USAGE_ERROR_RATIO = DISK_USAGE_ERROR_RATIO;
|
|
49
|
+
exports.DISK_USAGE_WARNING_RATIO = DISK_USAGE_WARNING_RATIO;
|
|
50
|
+
exports.useRunboxDiskUsage = useRunboxDiskUsage;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare enum RunboxNetworkStatus {
|
|
2
|
+
Good = "good",
|
|
3
|
+
NotGood = "not_good",
|
|
4
|
+
Bad = "bad"
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Runbox network quality, derived from the heartbeat round trip.
|
|
8
|
+
*
|
|
9
|
+
* `null` until the first sample arrives.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useRunboxNetworkStatus: () => {
|
|
12
|
+
avgRtt: number | null;
|
|
13
|
+
status: RunboxNetworkStatus | null;
|
|
14
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var runboxClient = require('@elice/runbox-client');
|
|
5
|
+
|
|
6
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
9
|
+
|
|
10
|
+
//
|
|
11
|
+
//
|
|
12
|
+
//
|
|
13
|
+
exports.RunboxNetworkStatus = void 0;
|
|
14
|
+
(function (RunboxNetworkStatus) {
|
|
15
|
+
RunboxNetworkStatus["Good"] = "good";
|
|
16
|
+
RunboxNetworkStatus["NotGood"] = "not_good";
|
|
17
|
+
RunboxNetworkStatus["Bad"] = "bad";
|
|
18
|
+
})(exports.RunboxNetworkStatus || (exports.RunboxNetworkStatus = {}));
|
|
19
|
+
//
|
|
20
|
+
//
|
|
21
|
+
//
|
|
22
|
+
var RTT_THRESHOLD_GOOD = 600; // Fast 3G
|
|
23
|
+
var RTT_THRESHOLD_BAD = 1200; // Slow 3G
|
|
24
|
+
/** A failed heartbeat carries no `__rtt`, which counts as the worst latency. */
|
|
25
|
+
var MISSING_RTT = 1e10;
|
|
26
|
+
//
|
|
27
|
+
//
|
|
28
|
+
//
|
|
29
|
+
/**
|
|
30
|
+
* Runbox network quality, derived from the heartbeat round trip.
|
|
31
|
+
*
|
|
32
|
+
* `null` until the first sample arrives.
|
|
33
|
+
*/
|
|
34
|
+
var useRunboxNetworkStatus = function useRunboxNetworkStatus() {
|
|
35
|
+
var stats = runboxClient.useEliceRunboxContainerStats();
|
|
36
|
+
/** Averaged over the newer half, so a recovered connection is not held back. */
|
|
37
|
+
var avgRtt = React__default.default.useMemo(function () {
|
|
38
|
+
if (!stats.length) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
var recent = stats.slice(stats.length / 2, stats.length);
|
|
42
|
+
return recent.reduce(function (acc, stat) {
|
|
43
|
+
var _a;
|
|
44
|
+
return acc + ((_a = stat === null || stat === void 0 ? void 0 : stat.__rtt) !== null && _a !== void 0 ? _a : MISSING_RTT);
|
|
45
|
+
}, 0) / recent.length;
|
|
46
|
+
}, [stats]);
|
|
47
|
+
var status = React__default.default.useMemo(function () {
|
|
48
|
+
if (avgRtt === null) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
if (avgRtt < RTT_THRESHOLD_GOOD) {
|
|
52
|
+
return exports.RunboxNetworkStatus.Good;
|
|
53
|
+
}
|
|
54
|
+
if (avgRtt < RTT_THRESHOLD_BAD) {
|
|
55
|
+
return exports.RunboxNetworkStatus.NotGood;
|
|
56
|
+
}
|
|
57
|
+
return exports.RunboxNetworkStatus.Bad;
|
|
58
|
+
}, [avgRtt]);
|
|
59
|
+
return {
|
|
60
|
+
avgRtt: avgRtt,
|
|
61
|
+
status: status
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.useRunboxNetworkStatus = useRunboxNetworkStatus;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type RunboxSessionEndWarning = 'quota' | 'quotaPerSession';
|
|
2
|
+
interface UseRunboxSessionEndWarningParams {
|
|
3
|
+
runboxId: string;
|
|
4
|
+
/**
|
|
5
|
+
* Suppress every warning.
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface UseRunboxSessionEndWarningReturn {
|
|
11
|
+
warning: RunboxSessionEndWarning | null;
|
|
12
|
+
/** Marks the current warning as seen, which is what closes it. */
|
|
13
|
+
dismiss: () => void;
|
|
14
|
+
}
|
|
15
|
+
export declare const QUOTA_ALMOST_END_MINUTES = 30;
|
|
16
|
+
export declare const QUOTA_PER_SESSION_ALMOST_END_MINUTES = 10;
|
|
17
|
+
export declare function useRunboxSessionEndWarning({ runboxId, disabled, }: UseRunboxSessionEndWarningParams): UseRunboxSessionEndWarningReturn;
|
|
18
|
+
export {};
|