@abtnode/ux 1.16.14-beta-c308dc3b → 1.16.14-beta-963cb583
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/es/actions.js +97 -0
- package/es/analytics/card.js +92 -0
- package/es/analytics/chart.js +96 -0
- package/es/analytics/cpu.js +36 -0
- package/es/analytics/disk.js +111 -0
- package/es/analytics/memory.js +72 -0
- package/es/analytics/runtime.js +173 -0
- package/es/analytics/traffic.js +259 -0
- package/es/blocklet/access/config-access.js +307 -0
- package/es/blocklet/access/index.js +216 -0
- package/es/blocklet/actions.js +474 -0
- package/es/blocklet/add-cert.js +177 -0
- package/es/blocklet/agreement-app.js +21 -0
- package/es/blocklet/agreement.js +127 -0
- package/es/blocklet/app-avatar.js +57 -0
- package/es/blocklet/audit-logs.js +259 -0
- package/es/blocklet/blocklet-source.js +48 -0
- package/es/blocklet/bundle-avatar.js +64 -0
- package/es/blocklet/component/add.js +1313 -0
- package/es/blocklet/component/configuration.js +122 -0
- package/es/blocklet/component/delete.js +134 -0
- package/es/blocklet/component/environment.js +370 -0
- package/es/blocklet/component/index.js +975 -0
- package/es/blocklet/component/line.js +20 -0
- package/es/blocklet/component/navigation/locale-tabs.js +225 -0
- package/es/blocklet/component/navigation/navigation-actions.js +112 -0
- package/es/blocklet/component/navigation/navigation-dialog.js +607 -0
- package/es/blocklet/component/navigation/navigation-preview.js +101 -0
- package/es/blocklet/component/navigation/simple-select.js +124 -0
- package/es/blocklet/component/select-store.js +155 -0
- package/es/blocklet/component/selected/index.js +94 -0
- package/es/blocklet/component/setting.js +109 -0
- package/es/blocklet/component/sortable-tree.js +126 -0
- package/es/blocklet/component/space-connector.js +199 -0
- package/es/blocklet/component/space-selector.js +178 -0
- package/es/blocklet/component/start.js +101 -0
- package/es/blocklet/component/store-blocklet-list.js +200 -0
- package/es/blocklet/component/switch-control.js +57 -0
- package/es/blocklet/config-navigation.js +331 -0
- package/es/blocklet/configuration.js +603 -0
- package/es/blocklet/disk-info.js +75 -0
- package/es/blocklet/icons.js +18 -0
- package/es/blocklet/install-from-url.js +337 -0
- package/es/blocklet/log.js +90 -0
- package/es/blocklet/migration.js +149 -0
- package/es/blocklet/mode.js +19 -0
- package/es/blocklet/notification/email.js +257 -0
- package/es/blocklet/notification/index.js +49 -0
- package/es/blocklet/oauth/auth0.js +145 -0
- package/es/blocklet/oauth/common-settings.js +133 -0
- package/es/blocklet/oauth/federated-detail-dialog.js +175 -0
- package/es/blocklet/oauth/federated-invite-dialog.js +83 -0
- package/es/blocklet/oauth/federated-join-dialog.js +111 -0
- package/es/blocklet/oauth/federated-site-list.js +338 -0
- package/es/blocklet/oauth/federated.js +81 -0
- package/es/blocklet/oauth/index.js +69 -0
- package/es/blocklet/overview.js +293 -0
- package/es/blocklet/page-group.js +19 -0
- package/es/blocklet/preferences/app-sk.js +142 -0
- package/es/blocklet/preferences/index.js +305 -0
- package/es/blocklet/purchase/common.js +95 -0
- package/es/blocklet/purchase/component-purchase.js +237 -0
- package/es/blocklet/purchase/index.js +4 -0
- package/es/blocklet/router/action/add-domain-alias.js +167 -0
- package/es/blocklet/router/action/add-rule.js +211 -0
- package/es/blocklet/router/action/config-routing-rule.js +232 -0
- package/es/blocklet/router/action/delete-domain-alias.js +99 -0
- package/es/blocklet/router/action/delete-rule.js +108 -0
- package/es/blocklet/router/action/update-rule.js +209 -0
- package/es/blocklet/router/domain-actions.js +64 -0
- package/es/blocklet/router/domain-status.js +88 -0
- package/es/blocklet/router/rule-actions.js +66 -0
- package/es/blocklet/router/rule-list.js +190 -0
- package/es/blocklet/router/util.js +131 -0
- package/es/blocklet/runtime-info.js +68 -0
- package/es/blocklet/status.js +91 -0
- package/es/blocklet/storage/action.js +134 -0
- package/es/blocklet/storage/backups.js +241 -0
- package/es/blocklet/storage/connect-to.js +372 -0
- package/es/blocklet/storage/connected.js +198 -0
- package/es/blocklet/storage/delete.js +113 -0
- package/es/blocklet/storage/disconnect.js +243 -0
- package/es/blocklet/storage/index.js +19 -0
- package/es/blocklet/storage/item.js +558 -0
- package/es/blocklet/storage/preview-nft.js +286 -0
- package/es/blocklet/transfer-owner.js +198 -0
- package/es/blocklet/types.js +18 -0
- package/es/blocklet/util.js +145 -0
- package/es/blocklet/version.js +141 -0
- package/es/card-selector.js +134 -0
- package/es/certificate.js +105 -0
- package/es/chain.js +13 -0
- package/es/click-to-copy.js +22 -0
- package/es/confirm.js +149 -0
- package/es/contexts/audit-log.js +152 -0
- package/es/contexts/blocklet.js +10 -0
- package/es/contexts/deleting-blocklets.js +70 -0
- package/es/contexts/node.js +17 -0
- package/es/contexts/session.js +8 -0
- package/es/contexts/team.js +10 -0
- package/es/delete-confirm.js +121 -0
- package/es/did-address.js +46 -0
- package/es/dot.js +14 -0
- package/es/exchange-passport.js +102 -0
- package/es/form/form-select-input.js +184 -0
- package/es/form/form-text-input.js +178 -0
- package/es/form/form-wrapper.js +88 -0
- package/es/form/input-triggers.js +98 -0
- package/es/form/required.js +8 -0
- package/es/hooks/blocklet.js +229 -0
- package/es/hooks/confirm.js +90 -0
- package/es/hooks/mobile-width.js +11 -0
- package/es/hooks/url-evaluation.js +155 -0
- package/es/hooks/use-app-logo.js +16 -0
- package/es/hooks/use-backup-progress.js +31 -0
- package/es/hooks/use-blocklet-info-for-connect-did-spaces.js +50 -0
- package/es/hooks/use-bundle-logo.js +27 -0
- package/es/hooks/use-navigation.js +347 -0
- package/es/hooks/use-passport-id.js +14 -0
- package/es/hooks/use-subscription.js +22 -0
- package/es/icons/empty-space-nft.svg +59 -0
- package/es/icons/empty-spaces-nft.svg +58 -0
- package/es/icons/long-arrow.svg +5 -0
- package/es/icons/space-connected.svg +3 -0
- package/es/icons/space-disconnect.svg +3 -0
- package/es/index.js +3 -0
- package/es/invitation/invitation-app.js +58 -0
- package/es/invitation/invitation-login.js +68 -0
- package/es/invitation/invitation-passport.js +146 -0
- package/es/invitation/invitation-receive.js +138 -0
- package/es/invitation/invitation-success.js +93 -0
- package/es/invitation/invitation-user.js +90 -0
- package/es/invitation/invitation.js +90 -0
- package/es/issue-passport.js +142 -0
- package/es/launch-blocklet/content-layout.js +58 -0
- package/es/launch-blocklet/page-header.js +43 -0
- package/es/layout/addon.js +114 -0
- package/es/layout/feedback.js +55 -0
- package/es/locales/en.js +1541 -0
- package/es/locales/index.js +9 -0
- package/es/locales/zh.js +1544 -0
- package/es/logs/clock.js +11 -0
- package/es/logs/download.js +132 -0
- package/es/logs/log-terminal.js +253 -0
- package/es/lost-passport.js +452 -0
- package/es/nav-logo.js +219 -0
- package/es/passport-tag.js +43 -0
- package/es/permission.js +57 -0
- package/es/relative-time.js +53 -0
- package/es/result-message.js +11 -0
- package/es/schema-form/color-input.js +98 -0
- package/es/schema-form/common-prop-types.js +13 -0
- package/es/schema-form/index.js +215 -0
- package/es/schema-form/passport-input.js +55 -0
- package/es/schema-form/text-input.js +57 -0
- package/es/store/add.js +179 -0
- package/es/store/delete.js +96 -0
- package/es/store/item.js +76 -0
- package/es/subscription.js +144 -0
- package/es/table-icons.js +34 -0
- package/es/table.js +52 -0
- package/es/tag.js +21 -0
- package/es/team/members/actions.js +89 -0
- package/es/team/members/index.js +636 -0
- package/es/team/members/invitations.js +188 -0
- package/es/team/members/invite-member.js +208 -0
- package/es/team/members/issue-passport.js +152 -0
- package/es/team/members/member.js +408 -0
- package/es/team/members/passport-issuances.js +155 -0
- package/es/team/members/passports.js +364 -0
- package/es/team/members/toggle-user-approval.js +122 -0
- package/es/team/members/transfer-node.js +256 -0
- package/es/team/members/util.js +14 -0
- package/es/team/passports/color.js +127 -0
- package/es/team/passports/detail.js +312 -0
- package/es/team/passports/index.js +282 -0
- package/es/team/passports/mutate-role.js +198 -0
- package/es/team/passports/trusted-factories.js +221 -0
- package/es/team/passports/trusted-factory.js +343 -0
- package/es/team/passports/trusted-issuer.js +296 -0
- package/es/team/passports/trusted-issuers.js +226 -0
- package/es/team/search-input.js +46 -0
- package/es/team/styles/dialog.js +72 -0
- package/es/team/styles/list-header.js +31 -0
- package/es/util/api.js +6 -0
- package/es/util/constants.js +2 -0
- package/es/util/index.js +598 -0
- package/es/util/mode.js +4 -0
- package/es/util/space-gateway.js +51 -0
- package/es/util/spaces.js +160 -0
- package/es/who-can-access/config.js +38 -0
- package/es/wrap-locale.js +15 -0
- package/lib/blocklet/component/add.js +5 -0
- package/lib/blocklet/component/selected/index.js +47 -0
- package/lib/blocklet/component/space-connector.js +1 -1
- package/lib/blocklet/component/space-selector.js +1 -1
- package/lib/blocklet/storage/backups.js +1 -1
- package/lib/blocklet/storage/connect-to.js +6 -7
- package/lib/blocklet/storage/connected.js +1 -1
- package/lib/blocklet/storage/disconnect.js +1 -1
- package/lib/blocklet/storage/index.js +1 -1
- package/lib/blocklet/storage/item.js +1 -1
- package/lib/card-selector.js +14 -14
- package/lib/invitation/invitation-passport.js +7 -6
- package/lib/invitation/invitation-receive.js +1 -1
- package/lib/locales/en.js +12 -5
- package/lib/locales/zh.js +10 -3
- package/lib/lost-passport.js +2 -2
- package/lib/schema-form/passport-input.js +12 -11
- package/lib/team/passports/color.js +14 -14
- package/lib/team/passports/trusted-factory.js +1 -1
- package/lib/util/spaces.js +13 -1
- package/package.json +88 -21
package/es/logs/clock.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import useInterval from 'react-use/lib/useInterval';
|
|
3
|
+
import { formatTime } from '../util';
|
|
4
|
+
function Clock() {
|
|
5
|
+
const [currentTime, setCurrentTime] = useState(+new Date());
|
|
6
|
+
useInterval(() => {
|
|
7
|
+
setCurrentTime(+new Date());
|
|
8
|
+
}, 1000);
|
|
9
|
+
return formatTime(currentTime, 'MMMM Do YYYY, h:mm:ss a');
|
|
10
|
+
}
|
|
11
|
+
export default Clock;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import dayjs from '@abtnode/util/lib/dayjs';
|
|
4
|
+
import Box from '@mui/material/Box';
|
|
5
|
+
import DownloadIcon from '@mui/icons-material/Download';
|
|
6
|
+
import FormControl from '@mui/material/FormControl';
|
|
7
|
+
import Select from '@mui/material/Select';
|
|
8
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
9
|
+
import Spinner from '@mui/material/CircularProgress';
|
|
10
|
+
import Button from '@arcblock/ux/lib/Button';
|
|
11
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
12
|
+
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
13
|
+
import formatName from '@abtnode/util/lib/format-name';
|
|
14
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
15
|
+
import { useNodeContext } from '../contexts/node';
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
const DAYS = [1, 7];
|
|
19
|
+
export default function DownloadLog({
|
|
20
|
+
id,
|
|
21
|
+
name
|
|
22
|
+
}) {
|
|
23
|
+
const {
|
|
24
|
+
t
|
|
25
|
+
} = useLocaleContext();
|
|
26
|
+
const {
|
|
27
|
+
restApi,
|
|
28
|
+
inService
|
|
29
|
+
} = useNodeContext();
|
|
30
|
+
const [showDialog, setShowDialog] = useState(false);
|
|
31
|
+
const [isDownloading, setIsDownloading] = useState(false);
|
|
32
|
+
const [days, setDays] = useState(1);
|
|
33
|
+
const onDownload = async () => {
|
|
34
|
+
if (isDownloading) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
setIsDownloading(true);
|
|
39
|
+
const logId = inService ? '' : `/${id}`;
|
|
40
|
+
const res = await restApi.get(`/download/log${logId}?days=${days}`, {
|
|
41
|
+
responseType: 'blob'
|
|
42
|
+
});
|
|
43
|
+
const href = URL.createObjectURL(res.data);
|
|
44
|
+
const link = document.createElement('a');
|
|
45
|
+
link.href = href;
|
|
46
|
+
link.setAttribute('download', `${formatName(name || id)}.${dayjs().format('YYYYMMDDHHmmss')}.log.zip`);
|
|
47
|
+
document.body.appendChild(link);
|
|
48
|
+
link.click();
|
|
49
|
+
document.body.removeChild(link);
|
|
50
|
+
URL.revokeObjectURL(href);
|
|
51
|
+
setIsDownloading(false);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
setIsDownloading(false);
|
|
54
|
+
Toast.error(error.message);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const onDaysChange = e => {
|
|
58
|
+
setDays(e.target.value);
|
|
59
|
+
};
|
|
60
|
+
return [/*#__PURE__*/_jsx(Box, {
|
|
61
|
+
display: "flex",
|
|
62
|
+
alignItems: "center",
|
|
63
|
+
style: {
|
|
64
|
+
gap: 16
|
|
65
|
+
},
|
|
66
|
+
children: /*#__PURE__*/_jsxs(Button, {
|
|
67
|
+
"data-cy": "download-logs",
|
|
68
|
+
variant: "outlined",
|
|
69
|
+
onClick: () => setShowDialog(true),
|
|
70
|
+
disabled: isDownloading,
|
|
71
|
+
children: [isDownloading ? /*#__PURE__*/_jsx(Spinner, {
|
|
72
|
+
size: 16
|
|
73
|
+
}) : /*#__PURE__*/_jsx(DownloadIcon, {
|
|
74
|
+
fontSize: "small",
|
|
75
|
+
style: {
|
|
76
|
+
transform: 'translateY(2px)'
|
|
77
|
+
}
|
|
78
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
79
|
+
ml: 0.5,
|
|
80
|
+
children: t('common.download')
|
|
81
|
+
})]
|
|
82
|
+
})
|
|
83
|
+
}), showDialog && /*#__PURE__*/_jsx(Dialog, {
|
|
84
|
+
open: true,
|
|
85
|
+
onClose: () => {
|
|
86
|
+
setShowDialog(false);
|
|
87
|
+
},
|
|
88
|
+
disableEscapeKeyDown: true,
|
|
89
|
+
title: t('common.download'),
|
|
90
|
+
PaperProps: {
|
|
91
|
+
style: {
|
|
92
|
+
minHeight: 'auto'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
actions: /*#__PURE__*/_jsxs(Button, {
|
|
96
|
+
"data-cy": "download-logs",
|
|
97
|
+
variant: "outlined",
|
|
98
|
+
onClick: () => onDownload(),
|
|
99
|
+
disabled: isDownloading,
|
|
100
|
+
children: [isDownloading && /*#__PURE__*/_jsx(Spinner, {
|
|
101
|
+
size: 16
|
|
102
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
103
|
+
ml: 0.5,
|
|
104
|
+
children: t('common.confirm')
|
|
105
|
+
})]
|
|
106
|
+
}),
|
|
107
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
108
|
+
mb: 2,
|
|
109
|
+
display: "flex",
|
|
110
|
+
justifyContent: "center",
|
|
111
|
+
children: /*#__PURE__*/_jsx(FormControl, {
|
|
112
|
+
size: "small",
|
|
113
|
+
fullWidth: true,
|
|
114
|
+
children: /*#__PURE__*/_jsx(Select, {
|
|
115
|
+
value: days,
|
|
116
|
+
onChange: onDaysChange,
|
|
117
|
+
children: DAYS.map(x => /*#__PURE__*/_jsx(MenuItem, {
|
|
118
|
+
value: x,
|
|
119
|
+
children: t(`log.lastDays.${x}`)
|
|
120
|
+
}, x))
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
})];
|
|
125
|
+
}
|
|
126
|
+
DownloadLog.propTypes = {
|
|
127
|
+
id: PropTypes.string.isRequired,
|
|
128
|
+
name: PropTypes.string
|
|
129
|
+
};
|
|
130
|
+
DownloadLog.defaultProps = {
|
|
131
|
+
name: ''
|
|
132
|
+
};
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { useRef, useState, useEffect, forwardRef } from 'react';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import Button from '@mui/material/Button';
|
|
5
|
+
import ButtonGroup from '@mui/material/ButtonGroup';
|
|
6
|
+
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
7
|
+
import Terminal from '@arcblock/terminal/lib/Terminal';
|
|
8
|
+
import Clock from './clock';
|
|
9
|
+
import { useNodeContext } from '../contexts/node';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 按 level/destination 分类的一组 terminal
|
|
13
|
+
*/
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
export function LogTerminalGroup({
|
|
17
|
+
name,
|
|
18
|
+
logId,
|
|
19
|
+
types,
|
|
20
|
+
defaultTypeIndex,
|
|
21
|
+
initialData,
|
|
22
|
+
prepend,
|
|
23
|
+
postpend,
|
|
24
|
+
onTypeChange,
|
|
25
|
+
...rest
|
|
26
|
+
}) {
|
|
27
|
+
const {
|
|
28
|
+
ws: {
|
|
29
|
+
useSubscription
|
|
30
|
+
}
|
|
31
|
+
} = useNodeContext();
|
|
32
|
+
const logTypeLabels = {
|
|
33
|
+
info: 'Info',
|
|
34
|
+
error: 'Error',
|
|
35
|
+
access: 'Access',
|
|
36
|
+
stdout: 'stdout',
|
|
37
|
+
stderr: 'stderr'
|
|
38
|
+
};
|
|
39
|
+
const isMobile = useMediaQuery(theme => theme.breakpoints.down('md'));
|
|
40
|
+
const [currentType, setCurrentType] = useState(types[defaultTypeIndex || 0]);
|
|
41
|
+
const [logFiles, setLogFiles] = useState();
|
|
42
|
+
const terminalRefs = useRef({});
|
|
43
|
+
|
|
44
|
+
// 组件挂载时, 写入初始数据
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
types.forEach(type => {
|
|
47
|
+
const terminal = terminalRefs.current[type];
|
|
48
|
+
if (terminal) {
|
|
49
|
+
terminal.write(`Collecting ${type} logs for ${name}...`);
|
|
50
|
+
terminal.write('\r\n\r\n');
|
|
51
|
+
initialData.forEach(item => terminal.write(item));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
|
+
}, []);
|
|
56
|
+
|
|
57
|
+
// 监听 log 数据, 写入 terminal
|
|
58
|
+
useSubscription(`log.${logId}`, log => {
|
|
59
|
+
if (!logFiles) {
|
|
60
|
+
setLogFiles(log.logFiles || {});
|
|
61
|
+
}
|
|
62
|
+
const terminal = terminalRefs.current[log.level];
|
|
63
|
+
if (terminal) {
|
|
64
|
+
terminal.write(log.data.replace(/.\n/g, p => p === '\r\n' ? p : `${p[0]}\r\n\r\n`));
|
|
65
|
+
terminal.write('\r\n\r\n');
|
|
66
|
+
}
|
|
67
|
+
}, []);
|
|
68
|
+
return /*#__PURE__*/_jsxs(LogTerminalGroupRoot, {
|
|
69
|
+
...rest,
|
|
70
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
71
|
+
className: "log-terminal-group-head",
|
|
72
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
73
|
+
className: "log-terminal-group-head-start",
|
|
74
|
+
children: [prepend, /*#__PURE__*/_jsx(ButtonGroup, {
|
|
75
|
+
variant: "outlined",
|
|
76
|
+
size: isMobile ? 'small' : 'medium',
|
|
77
|
+
children: types.map(type => {
|
|
78
|
+
const props = type === currentType ? {
|
|
79
|
+
variant: 'contained'
|
|
80
|
+
} : {};
|
|
81
|
+
return /*#__PURE__*/_jsx(Button, {
|
|
82
|
+
...props,
|
|
83
|
+
onClick: () => {
|
|
84
|
+
setCurrentType(type);
|
|
85
|
+
onTypeChange(type);
|
|
86
|
+
},
|
|
87
|
+
children: logTypeLabels[type]
|
|
88
|
+
}, type);
|
|
89
|
+
})
|
|
90
|
+
})]
|
|
91
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
92
|
+
className: "log-terminal-group-head-end",
|
|
93
|
+
children: postpend
|
|
94
|
+
})]
|
|
95
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
96
|
+
className: "log-terminal-group-terminals",
|
|
97
|
+
children: types.map(type => {
|
|
98
|
+
return /*#__PURE__*/_jsx(LogTerminal, {
|
|
99
|
+
ref: ref => {
|
|
100
|
+
terminalRefs.current[type] = ref;
|
|
101
|
+
},
|
|
102
|
+
logFile: logFiles?.[type],
|
|
103
|
+
style: {
|
|
104
|
+
visibility: type === currentType ? 'visible' : 'hidden'
|
|
105
|
+
}
|
|
106
|
+
}, type);
|
|
107
|
+
})
|
|
108
|
+
})]
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
LogTerminalGroup.propTypes = {
|
|
112
|
+
// log name, 比如: blocklet display name
|
|
113
|
+
name: PropTypes.string.isRequired,
|
|
114
|
+
// 比如: abtnode | blocklet-services | blocklet-<did>
|
|
115
|
+
logId: PropTypes.string.isRequired,
|
|
116
|
+
// 日志类型, info/error 或 stdin/stdout/access
|
|
117
|
+
types: PropTypes.arrayOf(PropTypes.string),
|
|
118
|
+
defaultTypeIndex: PropTypes.number,
|
|
119
|
+
// 写入 terminal 的初始数据
|
|
120
|
+
initialData: PropTypes.arrayOf(PropTypes.string),
|
|
121
|
+
prepend: PropTypes.node,
|
|
122
|
+
postpend: PropTypes.node,
|
|
123
|
+
onTypeChange: PropTypes.func
|
|
124
|
+
};
|
|
125
|
+
LogTerminalGroup.defaultProps = {
|
|
126
|
+
types: ['error', 'info', 'access', 'stdout', 'stderr'],
|
|
127
|
+
defaultTypeIndex: 0,
|
|
128
|
+
initialData: [],
|
|
129
|
+
prepend: null,
|
|
130
|
+
postpend: null,
|
|
131
|
+
onTypeChange: () => {}
|
|
132
|
+
};
|
|
133
|
+
const LogTerminalGroupRoot = styled.div`
|
|
134
|
+
display: flex;
|
|
135
|
+
flex-direction: column;
|
|
136
|
+
height: 100%;
|
|
137
|
+
.log-terminal-group-head {
|
|
138
|
+
display: flex;
|
|
139
|
+
align-items: center;
|
|
140
|
+
justify-content: space-between;
|
|
141
|
+
padding-bottom: 16px;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.log-terminal-group-head-start {
|
|
145
|
+
flex: 0 0 auto;
|
|
146
|
+
display: flex;
|
|
147
|
+
align-items: center;
|
|
148
|
+
gap: 16px;
|
|
149
|
+
${props => props.theme.breakpoints.down('md')} {
|
|
150
|
+
flex-direction: column;
|
|
151
|
+
align-items: start;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.log-terminal-group-head-end {
|
|
156
|
+
flex: 0 0 auto;
|
|
157
|
+
display: flex;
|
|
158
|
+
align-items: center;
|
|
159
|
+
gap: 16px;
|
|
160
|
+
${props => props.theme.breakpoints.down('md')} {
|
|
161
|
+
flex-direction: column;
|
|
162
|
+
align-items: start;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
.log-terminal-group-terminals {
|
|
166
|
+
flex: 1;
|
|
167
|
+
position: relative;
|
|
168
|
+
overflow: hidden;
|
|
169
|
+
> * {
|
|
170
|
+
position: absolute;
|
|
171
|
+
top: 0;
|
|
172
|
+
bottom: 0;
|
|
173
|
+
left: 0;
|
|
174
|
+
right: 0;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
`;
|
|
178
|
+
export const LogTerminal = /*#__PURE__*/forwardRef(({
|
|
179
|
+
logFile,
|
|
180
|
+
...rest
|
|
181
|
+
}, ref) => {
|
|
182
|
+
const terminalStyle = {
|
|
183
|
+
width: '100%',
|
|
184
|
+
boxSizing: 'border-box',
|
|
185
|
+
height: '100%'
|
|
186
|
+
};
|
|
187
|
+
const terminalOptions = {
|
|
188
|
+
theme: {
|
|
189
|
+
background: '#2C313C',
|
|
190
|
+
foreground: '#EEEEEE'
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
return /*#__PURE__*/_jsxs(LogTerminalRoot, {
|
|
194
|
+
...rest,
|
|
195
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
196
|
+
className: "log-terminal-top",
|
|
197
|
+
children: [/*#__PURE__*/_jsx(Clock, {}), logFile && /*#__PURE__*/_jsx("span", {
|
|
198
|
+
children: logFile
|
|
199
|
+
})]
|
|
200
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
201
|
+
className: "log-terminal-container",
|
|
202
|
+
style: {
|
|
203
|
+
position: 'relative'
|
|
204
|
+
},
|
|
205
|
+
children: /*#__PURE__*/_jsx(Terminal, {
|
|
206
|
+
ref: ref,
|
|
207
|
+
style: terminalStyle,
|
|
208
|
+
options: terminalOptions
|
|
209
|
+
})
|
|
210
|
+
})]
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
LogTerminal.propTypes = {
|
|
214
|
+
logFile: PropTypes.string
|
|
215
|
+
};
|
|
216
|
+
LogTerminal.defaultProps = {
|
|
217
|
+
logFile: ''
|
|
218
|
+
};
|
|
219
|
+
const LogTerminalRoot = styled.div`
|
|
220
|
+
height: 100%;
|
|
221
|
+
display: flex;
|
|
222
|
+
flex-direction: column;
|
|
223
|
+
.log-terminal-top {
|
|
224
|
+
flex: 0 0 auto;
|
|
225
|
+
display: flex;
|
|
226
|
+
justify-content: space-between;
|
|
227
|
+
align-items: center;
|
|
228
|
+
flex-wrap: wrap;
|
|
229
|
+
padding: 8px;
|
|
230
|
+
font-size: 14px;
|
|
231
|
+
color: aquamarine;
|
|
232
|
+
background: darkgray;
|
|
233
|
+
word-break: break-word;
|
|
234
|
+
}
|
|
235
|
+
.log-terminal-container {
|
|
236
|
+
flex: 1;
|
|
237
|
+
height: 100%;
|
|
238
|
+
padding: 8px;
|
|
239
|
+
overflow: hidden;
|
|
240
|
+
background: #2c313c;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.xterm-viewport::-webkit-scrollbar {
|
|
244
|
+
width: 10px;
|
|
245
|
+
}
|
|
246
|
+
.xterm-viewport::-webkit-scrollbar-track {
|
|
247
|
+
opacity: 0;
|
|
248
|
+
}
|
|
249
|
+
.xterm-viewport::-webkit-scrollbar-thumb {
|
|
250
|
+
min-height: 20px;
|
|
251
|
+
background-color: #ffffff20;
|
|
252
|
+
}
|
|
253
|
+
`;
|