@elice/material-runbox 1.230328.0 → 1.230418.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.
Files changed (84) hide show
  1. package/cjs/_virtual/_rollupPluginBabelHelpers.js +404 -0
  2. package/cjs/assets/queue.gif.js +8 -0
  3. package/cjs/assets/runbox_logo.png.js +8 -0
  4. package/cjs/assets/terminated.png.js +8 -0
  5. package/cjs/components/material-runbox/MaterialRunbox.d.ts +7 -3
  6. package/cjs/components/material-runbox/MaterialRunbox.js +148 -30
  7. package/cjs/components/material-runbox/MaterialRunboxBody.d.ts +4 -0
  8. package/cjs/components/material-runbox/MaterialRunboxBody.js +27 -0
  9. package/cjs/components/material-runbox/MaterialRunboxFooter.d.ts +4 -0
  10. package/cjs/components/material-runbox/MaterialRunboxFooter.js +57 -0
  11. package/cjs/components/material-runbox/MaterialRunboxHeader.d.ts +4 -0
  12. package/cjs/components/material-runbox/MaterialRunboxHeader.js +139 -0
  13. package/cjs/components/material-runbox/context.d.ts +11 -0
  14. package/cjs/components/material-runbox/context.js +12 -0
  15. package/cjs/components/material-runbox/hooks/index.d.ts +2 -0
  16. package/cjs/components/material-runbox/hooks/useMaterialRunboxApi.d.ts +14 -0
  17. package/cjs/components/material-runbox/hooks/useMaterialRunboxApi.js +46 -0
  18. package/cjs/components/material-runbox/hooks/useRunboxControl.d.ts +11 -0
  19. package/cjs/components/material-runbox/hooks/useRunboxControl.js +99 -0
  20. package/cjs/components/material-runbox/runtime/Runtime.d.ts +21 -0
  21. package/cjs/components/material-runbox/runtime/Runtime.js +58 -0
  22. package/cjs/components/material-runbox/runtime/RuntimeOverlayAssigned.d.ts +4 -0
  23. package/cjs/components/material-runbox/runtime/RuntimeOverlayAssigned.js +48 -0
  24. package/cjs/components/material-runbox/runtime/RuntimeOverlayQueued.d.ts +4 -0
  25. package/cjs/components/material-runbox/runtime/RuntimeOverlayQueued.js +63 -0
  26. package/cjs/components/material-runbox/runtime/RuntimeOverlayTerminated.d.ts +7 -0
  27. package/cjs/components/material-runbox/runtime/RuntimeOverlayTerminated.js +144 -0
  28. package/cjs/index.js +1 -1
  29. package/es/_virtual/_rollupPluginBabelHelpers.js +392 -0
  30. package/es/assets/queue.gif.js +4 -0
  31. package/es/assets/runbox_logo.png.js +4 -0
  32. package/es/assets/terminated.png.js +4 -0
  33. package/es/components/material-runbox/MaterialRunbox.d.ts +7 -3
  34. package/es/components/material-runbox/MaterialRunbox.js +146 -32
  35. package/es/components/material-runbox/MaterialRunboxBody.d.ts +4 -0
  36. package/es/components/material-runbox/MaterialRunboxBody.js +18 -0
  37. package/es/components/material-runbox/MaterialRunboxFooter.d.ts +4 -0
  38. package/es/components/material-runbox/MaterialRunboxFooter.js +48 -0
  39. package/es/components/material-runbox/MaterialRunboxHeader.d.ts +4 -0
  40. package/es/components/material-runbox/MaterialRunboxHeader.js +130 -0
  41. package/es/components/material-runbox/context.d.ts +11 -0
  42. package/es/components/material-runbox/context.js +8 -0
  43. package/es/components/material-runbox/hooks/index.d.ts +2 -0
  44. package/es/components/material-runbox/hooks/useMaterialRunboxApi.d.ts +14 -0
  45. package/es/components/material-runbox/hooks/useMaterialRunboxApi.js +42 -0
  46. package/es/components/material-runbox/hooks/useRunboxControl.d.ts +11 -0
  47. package/es/components/material-runbox/hooks/useRunboxControl.js +95 -0
  48. package/es/components/material-runbox/runtime/Runtime.d.ts +21 -0
  49. package/es/components/material-runbox/runtime/Runtime.js +50 -0
  50. package/es/components/material-runbox/runtime/RuntimeOverlayAssigned.d.ts +4 -0
  51. package/es/components/material-runbox/runtime/RuntimeOverlayAssigned.js +40 -0
  52. package/es/components/material-runbox/runtime/RuntimeOverlayQueued.d.ts +4 -0
  53. package/es/components/material-runbox/runtime/RuntimeOverlayQueued.js +55 -0
  54. package/es/components/material-runbox/runtime/RuntimeOverlayTerminated.d.ts +7 -0
  55. package/es/components/material-runbox/runtime/RuntimeOverlayTerminated.js +136 -0
  56. package/package.json +24 -24
  57. package/cjs/components/material-runbox/MaterialRunbox.styled.d.ts +0 -1
  58. package/cjs/components/material-runbox/MaterialRunbox.styled.js +0 -15
  59. package/cjs/components/material-runbox/MaterialRunboxContent.d.ts +0 -18
  60. package/cjs/components/material-runbox/MaterialRunboxContent.js +0 -305
  61. package/cjs/components/material-runbox/MaterialRunboxContent.styled.d.ts +0 -8
  62. package/cjs/components/material-runbox/MaterialRunboxContent.styled.js +0 -50
  63. package/cjs/components/material-runbox/MaterialRunboxRunnerRoomWrapper.d.ts +0 -6
  64. package/cjs/components/material-runbox/MaterialRunboxRunnerRoomWrapper.js +0 -72
  65. package/cjs/components/material-runbox/MaterialRunboxStdioWrapper.d.ts +0 -7
  66. package/cjs/components/material-runbox/MaterialRunboxStdioWrapper.js +0 -80
  67. package/cjs/components/material-runbox/locales.d.ts +0 -15
  68. package/cjs/components/material-runbox/locales.js +0 -35
  69. package/cjs/components/material-runbox/websocket.d.ts +0 -10
  70. package/cjs/components/material-runbox/websocket.js +0 -20
  71. package/es/components/material-runbox/MaterialRunbox.styled.d.ts +0 -1
  72. package/es/components/material-runbox/MaterialRunbox.styled.js +0 -7
  73. package/es/components/material-runbox/MaterialRunboxContent.d.ts +0 -18
  74. package/es/components/material-runbox/MaterialRunboxContent.js +0 -297
  75. package/es/components/material-runbox/MaterialRunboxContent.styled.d.ts +0 -8
  76. package/es/components/material-runbox/MaterialRunboxContent.styled.js +0 -38
  77. package/es/components/material-runbox/MaterialRunboxRunnerRoomWrapper.d.ts +0 -6
  78. package/es/components/material-runbox/MaterialRunboxRunnerRoomWrapper.js +0 -66
  79. package/es/components/material-runbox/MaterialRunboxStdioWrapper.d.ts +0 -7
  80. package/es/components/material-runbox/MaterialRunboxStdioWrapper.js +0 -74
  81. package/es/components/material-runbox/locales.d.ts +0 -15
  82. package/es/components/material-runbox/locales.js +0 -30
  83. package/es/components/material-runbox/websocket.d.ts +0 -10
  84. package/es/components/material-runbox/websocket.js +0 -15
@@ -0,0 +1,130 @@
1
+ import { taggedTemplateLiteral as _taggedTemplateLiteral } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React from 'react';
3
+ import { useIntl } from 'react-intl';
4
+ import { useEliceRunboxRunning } from '@elice/runbox-client';
5
+ import styled from '@emotion/styled';
6
+ import { RestartAlt } from '@mui/icons-material';
7
+ import { Stack, Box, Tooltip, FormControlLabel, Switch, IconButton } from '@mui/material';
8
+ import { MaterialRunboxContext } from './context.js';
9
+ import '@elice/openapi-client-material-runbox';
10
+ import { useRunboxControl } from './hooks/useRunboxControl.js';
11
+ import runboxLogoImage from '../../assets/runbox_logo.png.js';
12
+
13
+ var _templateObject;
14
+ //
15
+ //
16
+ //
17
+ var StyledHeader = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n flex: 0 0 3rem;\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 0 1rem;\n width: 100%;\n border-bottom: 1px solid ", ";\n overflow: hidden;\n"])), function (_ref) {
18
+ var theme = _ref.theme;
19
+ return theme.palette.divider;
20
+ });
21
+ //
22
+ //
23
+ //
24
+ var MaterialRunboxHeader = function MaterialRunboxHeader(_ref2) {
25
+ var runbox = _ref2.runbox,
26
+ runtime = _ref2.runtime,
27
+ runtimeTemplate = _ref2.runtimeTemplate,
28
+ courseId = _ref2.courseId,
29
+ refetch = _ref2.refetch;
30
+ var intl = useIntl();
31
+ var _React$useContext = React.useContext(MaterialRunboxContext),
32
+ materialRunboxApi = _React$useContext.materialRunboxApi;
33
+ var _useEliceRunboxRunnin = useEliceRunboxRunning(),
34
+ status = _useEliceRunboxRunnin.status;
35
+ var _useRunboxControl = useRunboxControl({
36
+ runbox: runbox,
37
+ courseId: courseId,
38
+ refetch: refetch
39
+ }),
40
+ start = _useRunboxControl.start;
41
+ var isRunboxRunning = status === 'running';
42
+ /**
43
+ *
44
+ */
45
+ var handleAutoShutdownSwitchChange = function handleAutoShutdownSwitchChange(_, shutdown) {
46
+ if (!runtime) {
47
+ return;
48
+ }
49
+ materialRunboxApi.runtime.runtimeRuntimeIdPatch({
50
+ runtimeId: runtime.id,
51
+ runtimePatchRequest: {
52
+ autoShutdown: !shutdown
53
+ },
54
+ eliceCourseId: courseId
55
+ }).then(refetch).catch(function () {
56
+ //
57
+ });
58
+ };
59
+ /**
60
+ *
61
+ */
62
+ var renderHeaderAutoShutdownSwitch = function renderHeaderAutoShutdownSwitch() {
63
+ var _a;
64
+ return React.createElement(Tooltip, {
65
+ title: intl.formatMessage({
66
+ id: runtimeTemplate.autoShutdown ? 'material.runbox.header.autoShutdownDisabledTooltip' : 'material.runbox.header.autoShutdownTooltip'
67
+ }, {
68
+ time: intl.formatNumber((_a = runtimeTemplate.quotaPerSession) !== null && _a !== void 0 ? _a : 2880, {
69
+ style: 'unit',
70
+ unit: 'minute',
71
+ unitDisplay: 'short'
72
+ })
73
+ })
74
+ }, React.createElement(FormControlLabel, {
75
+ control: React.createElement(Switch, {
76
+ checked: !(runtime === null || runtime === void 0 ? void 0 : runtime.autoShutdown),
77
+ disabled: !runtime || runtimeTemplate.autoShutdown,
78
+ onChange: handleAutoShutdownSwitchChange
79
+ }),
80
+ label: intl.formatMessage({
81
+ id: 'material.runbox.header.autoShutdown'
82
+ }),
83
+ componentsProps: {
84
+ typography: {
85
+ variant: 'body2'
86
+ }
87
+ }
88
+ }));
89
+ };
90
+ /**
91
+ *
92
+ */
93
+ var renderHeaderRestartButton = function renderHeaderRestartButton() {
94
+ return React.createElement(Tooltip, {
95
+ title: intl.formatMessage({
96
+ id: 'material.runbox.header.restart'
97
+ })
98
+ }, React.createElement(IconButton, {
99
+ disabled: !isRunboxRunning,
100
+ sx: {
101
+ width: '38px'
102
+ },
103
+ onClick: function onClick() {
104
+ return start(true);
105
+ }
106
+ }, React.createElement(RestartAlt, null)));
107
+ };
108
+ //
109
+ //
110
+ //
111
+ return React.createElement(StyledHeader, null, React.createElement(Stack, {
112
+ direction: "row",
113
+ sx: {
114
+ height: '100%',
115
+ padding: '0.75rem 0'
116
+ }
117
+ }, React.createElement(Box, {
118
+ component: "img",
119
+ src: runboxLogoImage,
120
+ alt: "elice runbox",
121
+ sx: {
122
+ width: 'auto',
123
+ height: '100%'
124
+ }
125
+ })), React.createElement(Stack, {
126
+ direction: "row"
127
+ }, renderHeaderAutoShutdownSwitch(), renderHeaderRestartButton()));
128
+ };
129
+
130
+ export { MaterialRunboxHeader as default };
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import type { UseMaterialRunboxApiReturn } from './hooks';
3
+ export declare type MaterialRunboxContextValue = MaterialRunboxContextExternalValue & MaterialRunboxContextInternalValue;
4
+ export interface MaterialRunboxContextExternalValue {
5
+ /** */
6
+ locale: string;
7
+ /** */
8
+ showMessenger: () => void;
9
+ }
10
+ export declare type MaterialRunboxContextInternalValue = UseMaterialRunboxApiReturn;
11
+ export declare const MaterialRunboxContext: import("react").Context<MaterialRunboxContextValue>;
@@ -0,0 +1,8 @@
1
+ import { createContext } from 'react';
2
+
3
+ //
4
+ //
5
+ //
6
+ var MaterialRunboxContext = createContext({});
7
+
8
+ export { MaterialRunboxContext };
@@ -0,0 +1,2 @@
1
+ export * from './useMaterialRunboxApi';
2
+ export * from './useRunboxControl';
@@ -0,0 +1,14 @@
1
+ import { RunboxApi as EliceMaterialRunboxRunboxApi, RuntimeApi as EliceMaterialRunboxRuntimeApi, RuntimeTemplateApi as EliceMaterialRuntimeTemplateApi } from '@elice/openapi-client-material-runbox';
2
+ import type { Configuration as EliceMaterialRunboxApiConfiguration } from '@elice/openapi-client-material-runbox';
3
+ export interface UseMaterialRunboxApiProps {
4
+ eliceMaterialRunboxApiConfiguration: EliceMaterialRunboxApiConfiguration;
5
+ }
6
+ export interface UseMaterialRunboxApiReturnMaterialRunbox {
7
+ runbox: EliceMaterialRunboxRunboxApi;
8
+ runtime: EliceMaterialRunboxRuntimeApi;
9
+ runtimeTemplate: EliceMaterialRuntimeTemplateApi;
10
+ }
11
+ export interface UseMaterialRunboxApiReturn {
12
+ materialRunboxApi: UseMaterialRunboxApiReturnMaterialRunbox;
13
+ }
14
+ export declare const useMaterialRunboxApi: (props: UseMaterialRunboxApiProps) => UseMaterialRunboxApiReturn;
@@ -0,0 +1,42 @@
1
+ import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { useRef, useState, useEffect } from 'react';
3
+ import { RunboxApi, RuntimeApi, RuntimeTemplateApi } from '@elice/openapi-client-material-runbox';
4
+
5
+ //
6
+ //
7
+ //
8
+ var useMaterialRunboxApi = function useMaterialRunboxApi(props) {
9
+ var _return = useRef({});
10
+ //
11
+ //
12
+ //
13
+ var createMaterialRunboxApi = function createMaterialRunboxApi() {
14
+ return Object.freeze({
15
+ runbox: new RunboxApi(props.eliceMaterialRunboxApiConfiguration),
16
+ runtime: new RuntimeApi(props.eliceMaterialRunboxApiConfiguration),
17
+ runtimeTemplate: new RuntimeTemplateApi(props.eliceMaterialRunboxApiConfiguration)
18
+ });
19
+ };
20
+ //
21
+ //
22
+ //
23
+ var _useState = useState(createMaterialRunboxApi),
24
+ _useState2 = _slicedToArray(_useState, 2),
25
+ materialRunboxApi = _useState2[0],
26
+ setMaterialRunboxApi = _useState2[1];
27
+ //
28
+ //
29
+ //
30
+ useEffect(function () {
31
+ return setMaterialRunboxApi(createMaterialRunboxApi);
32
+ },
33
+ // eslint-disable-next-line react-hooks/exhaustive-deps
34
+ [props.eliceMaterialRunboxApiConfiguration]);
35
+ //
36
+ //
37
+ //
38
+ _return.current.materialRunboxApi = materialRunboxApi;
39
+ return _return.current;
40
+ };
41
+
42
+ export { useMaterialRunboxApi };
@@ -0,0 +1,11 @@
1
+ import type { RuntimeProps } from '../runtime/Runtime';
2
+ declare type UseRunboxControlProps = Pick<RuntimeProps, 'runbox' | 'courseId' | 'refetch'>;
3
+ interface UseRunboxControlReturn {
4
+ start: (force?: boolean) => Promise<void>;
5
+ stop: () => Promise<void>;
6
+ }
7
+ /**
8
+ * Hook for runbox control and status.
9
+ */
10
+ export declare const useRunboxControl: (props: UseRunboxControlProps) => UseRunboxControlReturn;
11
+ export {};
@@ -0,0 +1,95 @@
1
+ import { asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { useRef, useContext, useCallback } from 'react';
3
+ import { useIntl } from 'react-intl';
4
+ import { useEliceRunboxRunning } from '@elice/runbox-client';
5
+ import { useSnackbar } from 'notistack';
6
+ import { MaterialRunboxContext } from '../context.js';
7
+
8
+ //
9
+ //
10
+ //
11
+ /**
12
+ * Hook for runbox control and status.
13
+ */
14
+ var useRunboxControl = function useRunboxControl(props) {
15
+ var _return = useRef({});
16
+ var intl = useIntl();
17
+ var _useSnackbar = useSnackbar(),
18
+ enqueueSnackbar = _useSnackbar.enqueueSnackbar;
19
+ var _useContext = useContext(MaterialRunboxContext),
20
+ materialRunboxApi = _useContext.materialRunboxApi;
21
+ var _useEliceRunboxRunnin = useEliceRunboxRunning(),
22
+ runboxStart = _useEliceRunboxRunnin.start,
23
+ runboxStop = _useEliceRunboxRunnin.stop;
24
+ /**
25
+ * Start project.
26
+ */
27
+ var start = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
28
+ var force,
29
+ _args = arguments;
30
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
31
+ while (1) switch (_context.prev = _context.next) {
32
+ case 0:
33
+ force = _args.length > 0 && _args[0] !== undefined ? _args[0] : false;
34
+ return _context.abrupt("return", runboxStart(function (signal) {
35
+ return materialRunboxApi.runbox.runboxRunboxIdStartPost({
36
+ runboxId: props.runbox.id,
37
+ eliceCourseId: props.courseId
38
+ }, {
39
+ signal: signal
40
+ });
41
+ }, force).then(function () {
42
+ return void props.refetch();
43
+ }).catch(function (err) {
44
+ if (err.name !== 'AbortError') {
45
+ enqueueSnackbar(intl.formatMessage({
46
+ id: 'material.runbox.runtime.message.startError'
47
+ }), {
48
+ variant: 'error'
49
+ });
50
+ }
51
+ }));
52
+ case 2:
53
+ case "end":
54
+ return _context.stop();
55
+ }
56
+ }, _callee);
57
+ })),
58
+ // eslint-disable-next-line react-hooks/exhaustive-deps
59
+ [props.runbox.id, props.courseId, runboxStart]);
60
+ /**
61
+ * Stop project.
62
+ */
63
+ var stop = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
64
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
65
+ while (1) switch (_context2.prev = _context2.next) {
66
+ case 0:
67
+ return _context2.abrupt("return", runboxStop(function (signal) {
68
+ return materialRunboxApi.runbox.runboxRunboxIdStopPost({
69
+ runboxId: props.runbox.id,
70
+ eliceCourseId: props.courseId
71
+ }, {
72
+ signal: signal
73
+ });
74
+ }).then(function () {
75
+ //
76
+ }).catch(function (err) {
77
+ if (err.name !== 'AbortError') ;
78
+ }));
79
+ case 1:
80
+ case "end":
81
+ return _context2.stop();
82
+ }
83
+ }, _callee2);
84
+ })),
85
+ // eslint-disable-next-line react-hooks/exhaustive-deps
86
+ [props.runbox.id, props.courseId, runboxStop]);
87
+ //
88
+ //
89
+ //
90
+ _return.current.start = start;
91
+ _return.current.stop = stop;
92
+ return _return.current;
93
+ };
94
+
95
+ export { useRunboxControl };
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import type { RunboxGetAndListResponse, RuntimeGetAndListResponse, RuntimeTemplateGetAndListResponse } from '@elice/openapi-client-material-runbox';
3
+ import type { QueryObserverResult } from '@tanstack/react-query';
4
+ export interface RuntimeProps {
5
+ /** */
6
+ runbox: RunboxGetAndListResponse;
7
+ /** */
8
+ runtime: RuntimeGetAndListResponse | null;
9
+ /** */
10
+ runtimeTemplate: RuntimeTemplateGetAndListResponse;
11
+ /** */
12
+ courseId: number;
13
+ /** */
14
+ refetch: () => Promise<QueryObserverResult<[
15
+ RunboxGetAndListResponse,
16
+ RuntimeGetAndListResponse,
17
+ RuntimeTemplateGetAndListResponse
18
+ ], unknown>>;
19
+ }
20
+ declare const Runtime: React.FC<RuntimeProps>;
21
+ export default Runtime;
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import { EliceRunboxView } from '@elice/runbox-client';
3
+ import '@elice/openapi-client-material-runbox';
4
+ import { useRunboxControl } from '../hooks/useRunboxControl.js';
5
+ import RuntimeOverlayAssigned from './RuntimeOverlayAssigned.js';
6
+ import RuntimeOverlayQueued from './RuntimeOverlayQueued.js';
7
+ import RuntimeOverlayTerminated from './RuntimeOverlayTerminated.js';
8
+
9
+ //
10
+ //
11
+ //
12
+ var Runtime = function Runtime(props) {
13
+ var _useRunboxControl = useRunboxControl(props),
14
+ startRuntime = _useRunboxControl.start;
15
+ //
16
+ //
17
+ //
18
+ React.useEffect(function () {
19
+ if (!props.runbox.id) {
20
+ return;
21
+ }
22
+ void startRuntime(
23
+ // check whether runtime is already assigned, or not.
24
+ // if runtime not assigned, should be restarted (ignore previous running state)
25
+ !props.runtime);
26
+ // NOTICE: do not stop runtime when unmounting,
27
+ // since it will automatically stopped by the server.
28
+ // return () => {
29
+ // if (props.runtimeTemplate.autoShutdown) {
30
+ // stopRuntime();
31
+ // }
32
+ // };
33
+ },
34
+ // eslint-disable-next-line react-hooks/exhaustive-deps
35
+ [props.runbox.id]);
36
+ //
37
+ //
38
+ //
39
+ return React.createElement(EliceRunboxView, {
40
+ OverlayAssigned: RuntimeOverlayAssigned,
41
+ OverlayQueued: RuntimeOverlayQueued,
42
+ OverlayTerminated: function OverlayTerminated(props) {
43
+ return React.createElement(RuntimeOverlayTerminated, Object.assign({}, props, {
44
+ startRuntime: startRuntime
45
+ }));
46
+ }
47
+ });
48
+ };
49
+
50
+ export { Runtime as default };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { EliceRunboxViewerOverlayAssignedComponentProps as AssignedComponentProps } from '@elice/runbox-client';
3
+ declare const RuntimeOverlayAssigned: React.FC<AssignedComponentProps>;
4
+ export default RuntimeOverlayAssigned;
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import { FormattedMessage } from 'react-intl';
3
+ import { Stack, Box, Typography } from '@mui/material';
4
+ import queueAnimationImage from '../../../assets/queue.gif.js';
5
+
6
+ //
7
+ //
8
+ //
9
+ var RuntimeOverlayAssigned = function RuntimeOverlayAssigned() {
10
+ return React.createElement(Stack, {
11
+ gap: "1.5rem",
12
+ sx: {
13
+ display: 'flex',
14
+ justifyContent: 'center',
15
+ alignItems: 'center',
16
+ width: '100%',
17
+ height: '100%'
18
+ }
19
+ }, React.createElement(Box, {
20
+ component: "img",
21
+ src: queueAnimationImage,
22
+ alt: "queue",
23
+ sx: {
24
+ width: '100%',
25
+ height: 'auto',
26
+ maxWidth: '13.375rem'
27
+ }
28
+ }), React.createElement(Typography, {
29
+ variant: "subtitle2",
30
+ color: "text:secondary",
31
+ sx: {
32
+ whiteSpace: 'pre-wrap',
33
+ textAlign: 'center'
34
+ }
35
+ }, React.createElement(FormattedMessage, {
36
+ id: "material.runbox.runtime.overlay.assigned.description"
37
+ })));
38
+ };
39
+
40
+ export { RuntimeOverlayAssigned as default };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { EliceRunboxViewerOverlayQueuedComponentProps as QueuedComponentProps } from '@elice/runbox-client';
3
+ declare const RuntimeOverlayQueued: React.FC<QueuedComponentProps>;
4
+ export default RuntimeOverlayQueued;
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import { FormattedMessage } from 'react-intl';
3
+ import { QuestionAnswer } from '@mui/icons-material';
4
+ import { Stack, Box, Typography, Button } from '@mui/material';
5
+ import { MaterialRunboxContext } from '../context.js';
6
+ import queueAnimationImage from '../../../assets/queue.gif.js';
7
+
8
+ //
9
+ //
10
+ //
11
+ var RuntimeOverlayQueued = function RuntimeOverlayQueued(_ref) {
12
+ var numWaiters = _ref.numWaiters;
13
+ var _React$useContext = React.useContext(MaterialRunboxContext),
14
+ showMessenger = _React$useContext.showMessenger;
15
+ //
16
+ //
17
+ //
18
+ return React.createElement(Stack, {
19
+ gap: "1.5rem",
20
+ sx: {
21
+ display: 'flex',
22
+ justifyContent: 'center',
23
+ alignItems: 'center',
24
+ width: '100%',
25
+ height: '100%'
26
+ }
27
+ }, React.createElement(Box, {
28
+ component: "img",
29
+ src: queueAnimationImage,
30
+ alt: "queue",
31
+ sx: {
32
+ width: '100%',
33
+ height: 'auto',
34
+ maxWidth: '13.375rem'
35
+ }
36
+ }), React.createElement(Typography, {
37
+ variant: "subtitle2",
38
+ color: "text:secondary"
39
+ }, numWaiters > 0 ? React.createElement(FormattedMessage, {
40
+ id: "material.runbox.runtime.overlay.queued.description",
41
+ values: {
42
+ waiters: numWaiters
43
+ }
44
+ }) : React.createElement(FormattedMessage, {
45
+ id: "material.runbox.runtime.overlay.queued.description_zero"
46
+ })), React.createElement(Button, {
47
+ variant: "outlined",
48
+ startIcon: React.createElement(QuestionAnswer, null),
49
+ onClick: showMessenger
50
+ }, React.createElement(FormattedMessage, {
51
+ id: "common.support"
52
+ })));
53
+ };
54
+
55
+ export { RuntimeOverlayQueued as default };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { EliceRunboxViewerOverlayTerminatedComponentProps as TerminatedComponentProps } from '@elice/runbox-client';
3
+ interface RuntimeOverlayTerminatedProps extends TerminatedComponentProps {
4
+ startRuntime: () => Promise<void>;
5
+ }
6
+ declare const RuntimeOverlayTerminated: React.FC<RuntimeOverlayTerminatedProps>;
7
+ export default RuntimeOverlayTerminated;
@@ -0,0 +1,136 @@
1
+ import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React from 'react';
3
+ import { useIntl, FormattedMessage } from 'react-intl';
4
+ import { PlayArrow } from '@mui/icons-material';
5
+ import { LoadingButton } from '@mui/lab';
6
+ import { Box, Stack, Typography, Button } from '@mui/material';
7
+ import { MaterialRunboxContext } from '../context.js';
8
+ import runboxTerminatedImage from '../../../assets/terminated.png.js';
9
+
10
+ //
11
+ //
12
+ //
13
+ var RuntimeOverlayTerminated = function RuntimeOverlayTerminated(_ref) {
14
+ var reason = _ref.reason,
15
+ startRuntime = _ref.startRuntime;
16
+ var intl = useIntl();
17
+ var _React$useContext = React.useContext(MaterialRunboxContext),
18
+ showMessenger = _React$useContext.showMessenger;
19
+ var _React$useState = React.useState(false),
20
+ _React$useState2 = _slicedToArray(_React$useState, 2),
21
+ isRestarting = _React$useState2[0],
22
+ setRestarting = _React$useState2[1];
23
+ /**
24
+ * Restart the project.
25
+ */
26
+ var handleRestart = function handleRestart() {
27
+ setRestarting(true);
28
+ startRuntime().finally(function () {
29
+ setRestarting(false);
30
+ });
31
+ };
32
+ /**
33
+ * Terminated description and action.
34
+ */
35
+ var runtimeTerminatedAction = React.useMemo(function () {
36
+ switch (reason) {
37
+ // general shutdown
38
+ case 'stopped_by_user':
39
+ case 'auto_shutdown':
40
+ return {
41
+ description: intl.formatMessage({
42
+ id: 'material.runbox.runtime.overlay.terminated.description.general'
43
+ }),
44
+ unexpected: false
45
+ };
46
+ case 'quota_exceeded':
47
+ return {
48
+ description: intl.formatMessage({
49
+ id: 'material.runbox.runtime.overlay.terminated.description.quota_exceeded'
50
+ }),
51
+ unexpected: false
52
+ };
53
+ // quota exceeded
54
+ case 'quota_per_session_exceeded':
55
+ return {
56
+ description: intl.formatMessage({
57
+ id: 'material.runbox.runtime.overlay.terminated.description.quota_per_session_exceeded'
58
+ }),
59
+ unexpected: false
60
+ };
61
+ // disk full
62
+ case 'os_disk_is_full':
63
+ return {
64
+ description: intl.formatMessage({
65
+ id: 'material.runbox.runtime.overlay.terminated.description.os_disk_is_full'
66
+ }),
67
+ unexpected: true
68
+ };
69
+ default:
70
+ return {
71
+ description: intl.formatMessage({
72
+ id: 'material.runbox.runtime.overlay.terminated.description.default'
73
+ }),
74
+ unexpected: true
75
+ };
76
+ }
77
+ },
78
+ // eslint-disable-next-line react-hooks/exhaustive-deps
79
+ [reason, intl]);
80
+ //
81
+ //
82
+ //
83
+ return React.createElement(Box, {
84
+ sx: {
85
+ display: 'flex',
86
+ justifyContent: 'center',
87
+ alignItems: 'center',
88
+ width: '100%',
89
+ height: '100%'
90
+ }
91
+ }, React.createElement(Stack, {
92
+ gap: "1.5rem",
93
+ alignItems: "center"
94
+ }, React.createElement(Box, {
95
+ component: "img",
96
+ src: runboxTerminatedImage,
97
+ alt: "terminated",
98
+ sx: {
99
+ maxWidth: '10rem',
100
+ height: 'auto'
101
+ }
102
+ }), React.createElement(Stack, {
103
+ gap: "0.5rem"
104
+ }, React.createElement(Typography, {
105
+ variant: "h6",
106
+ textAlign: "center"
107
+ }, React.createElement(FormattedMessage, {
108
+ id: "material.runbox.runtime.overlay.terminated.title"
109
+ })), React.createElement(Typography, {
110
+ variant: "body2",
111
+ textAlign: "center",
112
+ whiteSpace: "pre-line"
113
+ }, runtimeTerminatedAction.unexpected ? runtimeTerminatedAction.description.concat('\n', intl.formatMessage({
114
+ id: 'material.runbox.runtime.overlay.terminated.description.unexpected'
115
+ })) : runtimeTerminatedAction.description)), React.createElement(Stack, {
116
+ gap: "0.5rem",
117
+ sx: {
118
+ width: '100%',
119
+ maxWidth: '17rem'
120
+ }
121
+ }, React.createElement(LoadingButton, {
122
+ variant: "contained",
123
+ loading: isRestarting,
124
+ startIcon: React.createElement(PlayArrow, null),
125
+ onClick: handleRestart
126
+ }, React.createElement(FormattedMessage, {
127
+ id: "material.runbox.runtime.overlay.terminated.restart"
128
+ })), runtimeTerminatedAction.unexpected ? React.createElement(Button, {
129
+ variant: "text",
130
+ onClick: showMessenger
131
+ }, React.createElement(FormattedMessage, {
132
+ id: "common.support"
133
+ })) : null)));
134
+ };
135
+
136
+ export { RuntimeOverlayTerminated as default };