@abtnode/ux 1.16.14-beta-ab7f615e → 1.16.14-beta-cb53c14b

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 (202) hide show
  1. package/es/actions.js +97 -0
  2. package/es/analytics/card.js +92 -0
  3. package/es/analytics/chart.js +96 -0
  4. package/es/analytics/cpu.js +36 -0
  5. package/es/analytics/disk.js +111 -0
  6. package/es/analytics/memory.js +72 -0
  7. package/es/analytics/runtime.js +173 -0
  8. package/es/analytics/traffic.js +259 -0
  9. package/es/blocklet/access/config-access.js +307 -0
  10. package/es/blocklet/access/index.js +216 -0
  11. package/es/blocklet/actions.js +474 -0
  12. package/es/blocklet/add-cert.js +177 -0
  13. package/es/blocklet/agreement-app.js +21 -0
  14. package/es/blocklet/agreement.js +127 -0
  15. package/es/blocklet/app-avatar.js +57 -0
  16. package/es/blocklet/audit-logs.js +259 -0
  17. package/es/blocklet/blocklet-source.js +48 -0
  18. package/es/blocklet/bundle-avatar.js +64 -0
  19. package/es/blocklet/component/add.js +1308 -0
  20. package/es/blocklet/component/configuration.js +122 -0
  21. package/es/blocklet/component/delete.js +134 -0
  22. package/es/blocklet/component/environment.js +370 -0
  23. package/es/blocklet/component/index.js +975 -0
  24. package/es/blocklet/component/line.js +20 -0
  25. package/es/blocklet/component/navigation/locale-tabs.js +225 -0
  26. package/es/blocklet/component/navigation/navigation-actions.js +112 -0
  27. package/es/blocklet/component/navigation/navigation-dialog.js +607 -0
  28. package/es/blocklet/component/navigation/navigation-preview.js +101 -0
  29. package/es/blocklet/component/navigation/simple-select.js +124 -0
  30. package/es/blocklet/component/select-store.js +155 -0
  31. package/es/blocklet/component/setting.js +109 -0
  32. package/es/blocklet/component/sortable-tree.js +126 -0
  33. package/es/blocklet/component/space-connector.js +199 -0
  34. package/es/blocklet/component/space-selector.js +178 -0
  35. package/es/blocklet/component/start.js +101 -0
  36. package/es/blocklet/component/store-blocklet-list.js +200 -0
  37. package/es/blocklet/component/switch-control.js +57 -0
  38. package/es/blocklet/config-navigation.js +331 -0
  39. package/es/blocklet/configuration.js +603 -0
  40. package/es/blocklet/disk-info.js +75 -0
  41. package/es/blocklet/icons.js +18 -0
  42. package/es/blocklet/install-from-url.js +337 -0
  43. package/es/blocklet/log.js +90 -0
  44. package/es/blocklet/migration.js +149 -0
  45. package/es/blocklet/mode.js +19 -0
  46. package/es/blocklet/notification/email.js +257 -0
  47. package/es/blocklet/notification/index.js +49 -0
  48. package/es/blocklet/oauth/auth0.js +145 -0
  49. package/es/blocklet/oauth/common-settings.js +133 -0
  50. package/es/blocklet/oauth/federated-detail-dialog.js +175 -0
  51. package/es/blocklet/oauth/federated-invite-dialog.js +83 -0
  52. package/es/blocklet/oauth/federated-join-dialog.js +111 -0
  53. package/es/blocklet/oauth/federated-site-list.js +338 -0
  54. package/es/blocklet/oauth/federated.js +81 -0
  55. package/es/blocklet/oauth/index.js +69 -0
  56. package/es/blocklet/overview.js +293 -0
  57. package/es/blocklet/page-group.js +19 -0
  58. package/es/blocklet/preferences/app-sk.js +142 -0
  59. package/es/blocklet/preferences/index.js +305 -0
  60. package/es/blocklet/purchase/common.js +95 -0
  61. package/es/blocklet/purchase/component-purchase.js +237 -0
  62. package/es/blocklet/purchase/index.js +4 -0
  63. package/es/blocklet/router/action/add-domain-alias.js +167 -0
  64. package/es/blocklet/router/action/add-rule.js +211 -0
  65. package/es/blocklet/router/action/config-routing-rule.js +232 -0
  66. package/es/blocklet/router/action/delete-domain-alias.js +99 -0
  67. package/es/blocklet/router/action/delete-rule.js +108 -0
  68. package/es/blocklet/router/action/update-rule.js +209 -0
  69. package/es/blocklet/router/domain-actions.js +64 -0
  70. package/es/blocklet/router/domain-status.js +88 -0
  71. package/es/blocklet/router/rule-actions.js +66 -0
  72. package/es/blocklet/router/rule-list.js +190 -0
  73. package/es/blocklet/router/util.js +131 -0
  74. package/es/blocklet/runtime-info.js +68 -0
  75. package/es/blocklet/status.js +91 -0
  76. package/es/blocklet/storage/action.js +134 -0
  77. package/es/blocklet/storage/backups.js +241 -0
  78. package/es/blocklet/storage/connect-to.js +373 -0
  79. package/es/blocklet/storage/connected.js +198 -0
  80. package/es/blocklet/storage/delete.js +113 -0
  81. package/es/blocklet/storage/disconnect.js +243 -0
  82. package/es/blocklet/storage/index.js +19 -0
  83. package/es/blocklet/storage/item.js +558 -0
  84. package/es/blocklet/storage/preview-nft.js +286 -0
  85. package/es/blocklet/transfer-owner.js +198 -0
  86. package/es/blocklet/types.js +18 -0
  87. package/es/blocklet/util.js +145 -0
  88. package/es/blocklet/version.js +141 -0
  89. package/es/card-selector.js +134 -0
  90. package/es/certificate.js +105 -0
  91. package/es/chain.js +13 -0
  92. package/es/click-to-copy.js +22 -0
  93. package/es/confirm.js +149 -0
  94. package/es/contexts/audit-log.js +152 -0
  95. package/es/contexts/blocklet.js +10 -0
  96. package/es/contexts/deleting-blocklets.js +70 -0
  97. package/es/contexts/node.js +17 -0
  98. package/es/contexts/session.js +8 -0
  99. package/es/contexts/team.js +10 -0
  100. package/es/delete-confirm.js +121 -0
  101. package/es/did-address.js +46 -0
  102. package/es/dot.js +14 -0
  103. package/es/exchange-passport.js +102 -0
  104. package/es/form/form-select-input.js +184 -0
  105. package/es/form/form-text-input.js +178 -0
  106. package/es/form/form-wrapper.js +88 -0
  107. package/es/form/input-triggers.js +98 -0
  108. package/es/form/required.js +8 -0
  109. package/es/hooks/blocklet.js +229 -0
  110. package/es/hooks/confirm.js +90 -0
  111. package/es/hooks/mobile-width.js +11 -0
  112. package/es/hooks/url-evaluation.js +155 -0
  113. package/es/hooks/use-app-logo.js +16 -0
  114. package/es/hooks/use-backup-progress.js +31 -0
  115. package/es/hooks/use-blocklet-info-for-connect-did-spaces.js +50 -0
  116. package/es/hooks/use-bundle-logo.js +27 -0
  117. package/es/hooks/use-navigation.js +347 -0
  118. package/es/hooks/use-passport-id.js +14 -0
  119. package/es/hooks/use-subscription.js +22 -0
  120. package/es/icons/empty-space-nft.svg +59 -0
  121. package/es/icons/empty-spaces-nft.svg +58 -0
  122. package/es/icons/long-arrow.svg +5 -0
  123. package/es/icons/space-connected.svg +3 -0
  124. package/es/icons/space-disconnect.svg +3 -0
  125. package/es/index.js +3 -0
  126. package/es/invitation/invitation-app.js +58 -0
  127. package/es/invitation/invitation-login.js +68 -0
  128. package/es/invitation/invitation-passport.js +144 -0
  129. package/es/invitation/invitation-receive.js +138 -0
  130. package/es/invitation/invitation-success.js +93 -0
  131. package/es/invitation/invitation-user.js +90 -0
  132. package/es/invitation/invitation.js +90 -0
  133. package/es/issue-passport.js +142 -0
  134. package/es/launch-blocklet/content-layout.js +58 -0
  135. package/es/launch-blocklet/page-header.js +43 -0
  136. package/es/layout/addon.js +114 -0
  137. package/es/layout/feedback.js +55 -0
  138. package/es/locales/en.js +1534 -0
  139. package/es/locales/index.js +9 -0
  140. package/es/locales/zh.js +1537 -0
  141. package/es/logs/clock.js +11 -0
  142. package/es/logs/download.js +132 -0
  143. package/es/logs/log-terminal.js +253 -0
  144. package/es/lost-passport.js +452 -0
  145. package/es/nav-logo.js +219 -0
  146. package/es/passport-tag.js +43 -0
  147. package/es/permission.js +57 -0
  148. package/es/relative-time.js +53 -0
  149. package/es/result-message.js +11 -0
  150. package/es/schema-form/color-input.js +98 -0
  151. package/es/schema-form/common-prop-types.js +13 -0
  152. package/es/schema-form/index.js +215 -0
  153. package/es/schema-form/passport-input.js +54 -0
  154. package/es/schema-form/text-input.js +57 -0
  155. package/es/store/add.js +179 -0
  156. package/es/store/delete.js +96 -0
  157. package/es/store/item.js +76 -0
  158. package/es/subscription.js +144 -0
  159. package/es/table-icons.js +34 -0
  160. package/es/table.js +52 -0
  161. package/es/tag.js +21 -0
  162. package/es/team/members/actions.js +89 -0
  163. package/es/team/members/index.js +636 -0
  164. package/es/team/members/invitations.js +188 -0
  165. package/es/team/members/invite-member.js +208 -0
  166. package/es/team/members/issue-passport.js +152 -0
  167. package/es/team/members/member.js +408 -0
  168. package/es/team/members/passport-issuances.js +155 -0
  169. package/es/team/members/passports.js +364 -0
  170. package/es/team/members/toggle-user-approval.js +122 -0
  171. package/es/team/members/transfer-node.js +256 -0
  172. package/es/team/members/util.js +14 -0
  173. package/es/team/passports/color.js +126 -0
  174. package/es/team/passports/detail.js +312 -0
  175. package/es/team/passports/index.js +282 -0
  176. package/es/team/passports/mutate-role.js +198 -0
  177. package/es/team/passports/trusted-factories.js +221 -0
  178. package/es/team/passports/trusted-factory.js +343 -0
  179. package/es/team/passports/trusted-issuer.js +296 -0
  180. package/es/team/passports/trusted-issuers.js +226 -0
  181. package/es/team/search-input.js +46 -0
  182. package/es/team/styles/dialog.js +72 -0
  183. package/es/team/styles/list-header.js +31 -0
  184. package/es/util/api.js +6 -0
  185. package/es/util/constants.js +2 -0
  186. package/es/util/index.js +598 -0
  187. package/es/util/mode.js +4 -0
  188. package/es/util/space-gateway.js +51 -0
  189. package/es/util/spaces.js +151 -0
  190. package/es/who-can-access/config.js +38 -0
  191. package/es/wrap-locale.js +15 -0
  192. package/lib/blocklet/component/space-connector.js +1 -1
  193. package/lib/blocklet/component/space-selector.js +1 -1
  194. package/lib/blocklet/storage/backups.js +1 -1
  195. package/lib/blocklet/storage/connect-to.js +1 -1
  196. package/lib/blocklet/storage/connected.js +1 -1
  197. package/lib/blocklet/storage/disconnect.js +1 -1
  198. package/lib/blocklet/storage/index.js +1 -1
  199. package/lib/blocklet/storage/item.js +1 -1
  200. package/lib/invitation/invitation-receive.js +1 -1
  201. package/lib/team/passports/trusted-factory.js +1 -1
  202. package/package.json +81 -18
package/es/actions.js ADDED
@@ -0,0 +1,97 @@
1
+ import { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from '@emotion/styled';
4
+ import IconButton from '@mui/material/IconButton';
5
+ import Menu from '@mui/material/Menu';
6
+ import MenuItem from '@mui/material/MenuItem';
7
+ import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
8
+ import ListItemIcon from '@mui/material/ListItemIcon';
9
+ import ListItemText from '@mui/material/ListItemText';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { createElement as _createElement } from "react";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
+ export default function Actions({
14
+ actions,
15
+ ...props
16
+ }) {
17
+ const [anchorEl, setAnchorEl] = useState(null);
18
+ const open = Boolean(anchorEl);
19
+ const onOpen = e => {
20
+ try {
21
+ e.stopPropagation();
22
+ e.preventDefault();
23
+ // eslint-disable-next-line no-empty
24
+ } catch {}
25
+ setAnchorEl(e.currentTarget);
26
+ };
27
+ const onClose = e => {
28
+ try {
29
+ e.stopPropagation();
30
+ e.preventDefault();
31
+ // eslint-disable-next-line no-empty
32
+ } catch {}
33
+ setAnchorEl(null);
34
+ };
35
+ return /*#__PURE__*/_jsxs(Div, {
36
+ ...props,
37
+ children: [/*#__PURE__*/_jsx(IconButton, {
38
+ "aria-label": "more",
39
+ "aria-controls": "actions-menu",
40
+ "aria-haspopup": "true",
41
+ "data-cy": "actions-menu-icon",
42
+ onClick: onOpen,
43
+ size: "small",
44
+ children: /*#__PURE__*/_jsx(MoreHorizIcon, {})
45
+ }), /*#__PURE__*/_jsx(Menu, {
46
+ id: "actions-menu",
47
+ "data-cy": "actions-menu",
48
+ anchorEl: anchorEl,
49
+ keepMounted: true,
50
+ open: open,
51
+ onClose: onClose,
52
+ PaperProps: {},
53
+ children: actions.map((action, index) => {
54
+ if (typeof action === 'function') {
55
+ return action({
56
+ close: onClose
57
+ });
58
+ }
59
+ const {
60
+ icon,
61
+ text,
62
+ onClick,
63
+ disabled = false,
64
+ ...opts
65
+ } = action;
66
+ return /*#__PURE__*/_createElement(MenuItem, {
67
+ ...opts,
68
+ disabled: disabled,
69
+ dense: true,
70
+ onClick: async e => {
71
+ await onClick(e);
72
+ onClose();
73
+ }
74
+ // eslint-disable-next-line react/no-array-index-key
75
+ ,
76
+ key: index,
77
+ "data-cy": `actions-menu-${index}`
78
+ }, /*#__PURE__*/_jsx(ListItemIcon, {
79
+ style: {
80
+ minWidth: 24,
81
+ marginRight: 8
82
+ },
83
+ children: icon
84
+ }), /*#__PURE__*/_jsx(ListItemText, {
85
+ primary: text
86
+ }));
87
+ })
88
+ })]
89
+ });
90
+ }
91
+ Actions.propTypes = {
92
+ actions: PropTypes.array
93
+ };
94
+ Actions.defaultProps = {
95
+ actions: []
96
+ };
97
+ const Div = styled.div``;
@@ -0,0 +1,92 @@
1
+ import PropTypes from 'prop-types';
2
+ import styled from '@emotion/styled';
3
+ import Card from '@mui/material/Card';
4
+ import CardContent from '@mui/material/CardContent';
5
+ import Typography from '@mui/material/Typography';
6
+ import Box from '@mui/material/Box';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { jsxs as _jsxs } from "react/jsx-runtime";
9
+ export default function InsightCard({
10
+ style,
11
+ title,
12
+ value,
13
+ graph,
14
+ description
15
+ }) {
16
+ return /*#__PURE__*/_jsx(StyledCard, {
17
+ children: /*#__PURE__*/_jsxs(CardContent, {
18
+ style: {
19
+ ...style
20
+ },
21
+ children: [/*#__PURE__*/_jsx(Typography, {
22
+ sx: {
23
+ fontSize: 14
24
+ },
25
+ color: "text.secondary",
26
+ children: title
27
+ }), /*#__PURE__*/_jsx(Typography, {
28
+ variant: "h5",
29
+ component: "div",
30
+ mt: 1,
31
+ children: value
32
+ }), graph, !!description && /*#__PURE__*/_jsx(Box, {
33
+ display: "flex",
34
+ sx: {
35
+ fontSize: 12,
36
+ marginTop: 3
37
+ },
38
+ color: "text.secondary",
39
+ children: description
40
+ })]
41
+ })
42
+ });
43
+ }
44
+ InsightCard.propTypes = {
45
+ style: PropTypes.object,
46
+ title: PropTypes.node,
47
+ value: PropTypes.node,
48
+ graph: PropTypes.node,
49
+ description: PropTypes.any
50
+ };
51
+ InsightCard.defaultProps = {
52
+ style: {},
53
+ title: null,
54
+ value: null,
55
+ graph: null,
56
+ description: null
57
+ };
58
+ const StyledCard = styled(Card)`
59
+ .card-content {
60
+ height: 150px;
61
+ }
62
+
63
+ .card-sparkline {
64
+ flex: 2;
65
+ display: flex;
66
+ position: relative;
67
+ *[hidden] {
68
+ display: none;
69
+ }
70
+ }
71
+ .sparkline {
72
+ stroke: ${props => props.theme.palette.primary.main};
73
+ fill: ${props => props.theme.palette.primary.main}1A;
74
+ }
75
+ .tooltip {
76
+ position: absolute;
77
+ background: rgba(0, 0, 0, 0.7);
78
+ color: #fff;
79
+ padding: 2px 5px;
80
+ font-size: 12px;
81
+ white-space: nowrap;
82
+ z-index: 9999;
83
+ }
84
+ .sparkline--cursor {
85
+ stroke: orange;
86
+ }
87
+
88
+ .sparkline--spot {
89
+ fill: red;
90
+ stroke: red;
91
+ }
92
+ `;
@@ -0,0 +1,96 @@
1
+ import React, { useEffect, useState, useRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useSize, useReactive } from 'ahooks';
4
+ import Sparkline from '@arcblock/ux/lib/Sparkline';
5
+ import Card from './card';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ export default function InsightChart({
9
+ id,
10
+ title,
11
+ current,
12
+ description,
13
+ data,
14
+ dateFn,
15
+ valueFn
16
+ }) {
17
+ const svgRef = useRef(null);
18
+ const tooltipRef = useRef(null);
19
+ const tooltipState = useReactive({
20
+ style: {
21
+ top: 0,
22
+ left: 0
23
+ },
24
+ hidden: true,
25
+ textContent: ''
26
+ });
27
+ const [container, setContainer] = useState(null);
28
+ const size = useSize(container);
29
+ const sparklineOptions = {
30
+ onmousemove(e, dataPoint) {
31
+ const {
32
+ date,
33
+ value
34
+ } = dataPoint;
35
+ tooltipState.textContent = `${dateFn(date)}: ${valueFn(value)}`;
36
+ tooltipState.style.top = -30;
37
+ tooltipState.style.left = 80;
38
+ tooltipState.hidden = false;
39
+ },
40
+ onmouseout() {
41
+ tooltipState.hidden = true;
42
+ }
43
+ };
44
+ useEffect(() => {
45
+ setTimeout(() => {
46
+ setContainer(document.querySelector(`.${id}`));
47
+ setTimeout(() => {
48
+ if (svgRef.current) {
49
+ Sparkline(svgRef.current, data || [], sparklineOptions);
50
+ }
51
+ }, 400);
52
+ });
53
+ }, [data]); // eslint-disable-line react-hooks/exhaustive-deps
54
+
55
+ return /*#__PURE__*/_jsx(Card, {
56
+ title: title,
57
+ value: current,
58
+ graph: /*#__PURE__*/_jsxs("div", {
59
+ className: `card-sparkline ${id}`,
60
+ style: {
61
+ marginTop: 16
62
+ },
63
+ children: [/*#__PURE__*/_jsx("svg", {
64
+ ref: svgRef,
65
+ className: "sparkline",
66
+ width: size?.width || 100,
67
+ height: 30,
68
+ strokeWidth: "2"
69
+ }), /*#__PURE__*/_jsx("span", {
70
+ className: "tooltip",
71
+ ref: tooltipRef,
72
+ hidden: tooltipState.hidden,
73
+ style: {
74
+ ...tooltipState.style
75
+ },
76
+ children: tooltipState.textContent
77
+ })]
78
+ }),
79
+ description: description
80
+ });
81
+ }
82
+ InsightChart.propTypes = {
83
+ id: PropTypes.string.isRequired,
84
+ title: PropTypes.string.isRequired,
85
+ current: PropTypes.any.isRequired,
86
+ description: PropTypes.any,
87
+ data: PropTypes.array,
88
+ dateFn: PropTypes.func,
89
+ valueFn: PropTypes.func
90
+ };
91
+ InsightChart.defaultProps = {
92
+ description: null,
93
+ data: [],
94
+ dateFn: x => x,
95
+ valueFn: x => x
96
+ };
@@ -0,0 +1,36 @@
1
+ import { useContext } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
4
+ import Chart from './chart';
5
+ import { formatTime } from '../util';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const formatNumber = x => `${x}%`;
8
+ export default function CpuMonitor({
9
+ cpus,
10
+ currentLoad,
11
+ history
12
+ }) {
13
+ const {
14
+ t,
15
+ locale
16
+ } = useContext(LocaleContext);
17
+ return /*#__PURE__*/_jsx(Chart, {
18
+ id: "cpu-sparkline",
19
+ title: t('common.cpu'),
20
+ current: `${Math.floor(currentLoad || 0)}%`,
21
+ data: history,
22
+ description: `${t('system.cores')}: ${cpus?.length || 0}`,
23
+ dateFn: v => formatTime(v, 'HH:mm', locale),
24
+ valueFn: formatNumber
25
+ });
26
+ }
27
+ CpuMonitor.propTypes = {
28
+ cpus: PropTypes.array,
29
+ currentLoad: PropTypes.number,
30
+ history: PropTypes.array
31
+ };
32
+ CpuMonitor.defaultProps = {
33
+ cpus: [],
34
+ currentLoad: 0,
35
+ history: []
36
+ };
@@ -0,0 +1,111 @@
1
+ import { useContext } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { withStyles } from '@mui/styles';
4
+ import Typography from '@mui/material/Typography';
5
+ import LinearProgress from '@mui/material/LinearProgress';
6
+ import Box from '@mui/material/Box';
7
+ import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
8
+ import Card from './card';
9
+ import { formatDiskSize } from '../util/index';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ const BorderLinearProgress = withStyles(theme => ({
13
+ root: {
14
+ height: 10
15
+ },
16
+ colorPrimary: {
17
+ backgroundColor: theme.palette.grey[theme.palette.mode === 'light' ? 200 : 700]
18
+ },
19
+ bar: {
20
+ backgroundColor: theme.palette.secondary.main
21
+ }
22
+ }))(LinearProgress);
23
+ function LinearProgressWithLabel(props) {
24
+ const {
25
+ value
26
+ } = props;
27
+ return /*#__PURE__*/_jsxs(Box, {
28
+ display: "flex",
29
+ alignItems: "center",
30
+ mt: 2,
31
+ children: [/*#__PURE__*/_jsx(Box, {
32
+ width: "100%",
33
+ style: {
34
+ overflow: 'hidden'
35
+ },
36
+ mr: 1,
37
+ children: /*#__PURE__*/_jsx(BorderLinearProgress, {
38
+ variant: "determinate",
39
+ ...props
40
+ })
41
+ }), /*#__PURE__*/_jsx(Box, {
42
+ minWidth: 35,
43
+ children: /*#__PURE__*/_jsx(Typography, {
44
+ variant: "body2",
45
+ color: "textSecondary",
46
+ children: `${Math.round(value)}%`
47
+ })
48
+ })]
49
+ });
50
+ }
51
+ LinearProgressWithLabel.propTypes = {
52
+ value: PropTypes.number.isRequired
53
+ };
54
+ export default function DiskMonitor({
55
+ disk,
56
+ platform
57
+ }) {
58
+ const {
59
+ t
60
+ } = useContext(LocaleContext);
61
+ const metrics = [{
62
+ id: 1,
63
+ className: 'used',
64
+ title: t('system.used'),
65
+ metric: formatDiskSize(disk.used, platform)
66
+ }, {
67
+ id: 2,
68
+ className: 'free',
69
+ title: t('system.free'),
70
+ metric: formatDiskSize(disk.free, platform)
71
+ }, {
72
+ id: 3,
73
+ className: 'total',
74
+ title: t('system.total'),
75
+ metric: formatDiskSize(disk.total, platform)
76
+ }];
77
+ return /*#__PURE__*/_jsx(Card, {
78
+ title: `${t('common.disk')} (${disk.device})`,
79
+ value: formatDiskSize(disk.used, platform),
80
+ graph: /*#__PURE__*/_jsx(Box, {
81
+ mt: 3,
82
+ children: /*#__PURE__*/_jsx(LinearProgressWithLabel, {
83
+ value: disk.used / disk.total * 100
84
+ })
85
+ }),
86
+ description: metrics.map((x, index) => /*#__PURE__*/_jsxs(Box, {
87
+ sx: {
88
+ marginLeft: index === 0 ? 0 : 2
89
+ },
90
+ children: [x.title, ": ", x.metric]
91
+ }, x.title))
92
+ });
93
+ }
94
+ DiskMonitor.propTypes = {
95
+ disk: PropTypes.shape({
96
+ used: PropTypes.number,
97
+ free: PropTypes.number,
98
+ total: PropTypes.number,
99
+ device: PropTypes.string
100
+ }),
101
+ platform: PropTypes.string
102
+ };
103
+ DiskMonitor.defaultProps = {
104
+ disk: {
105
+ used: 0,
106
+ free: 0,
107
+ total: 1,
108
+ device: ''
109
+ },
110
+ platform: ''
111
+ };
@@ -0,0 +1,72 @@
1
+ /* eslint-disable react/jsx-one-expression-per-line */
2
+ import PropTypes from 'prop-types';
3
+ import filesize from 'filesize';
4
+ import Box from '@mui/material/Box';
5
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
6
+ import Chart from './chart';
7
+ import { formatTime } from '../util';
8
+ import { jsxs as _jsxs } from "react/jsx-runtime";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ export default function MemoryMonitor({
11
+ instanceCount,
12
+ title,
13
+ total,
14
+ used,
15
+ history
16
+ }) {
17
+ const {
18
+ t,
19
+ locale
20
+ } = useLocaleContext();
21
+ const showPercent = !!total;
22
+ const available = total - used;
23
+ const memoryPercent = showPercent ? `(${Math.floor(used / total * 100)}%)` : '';
24
+ const memoryList = [];
25
+ if (instanceCount) {
26
+ memoryList.push({
27
+ title: t('system.instances'),
28
+ metric: instanceCount
29
+ });
30
+ }
31
+ memoryList.push({
32
+ title: t('system.used'),
33
+ metric: filesize(used)
34
+ });
35
+ if (showPercent) {
36
+ memoryList.push({
37
+ title: t('system.free'),
38
+ metric: filesize(available)
39
+ }, {
40
+ title: t('system.total'),
41
+ metric: filesize(total)
42
+ });
43
+ }
44
+ return /*#__PURE__*/_jsx(Chart, {
45
+ id: "mem-sparkline",
46
+ title: title || t('common.memory'),
47
+ current: `${filesize(Math.floor(used || 0))} ${memoryPercent}`,
48
+ data: history,
49
+ description: memoryList.map((x, index) => /*#__PURE__*/_jsxs(Box, {
50
+ sx: {
51
+ marginLeft: index === 0 ? 0 : 2
52
+ },
53
+ children: [x.title, ": ", x.metric]
54
+ }, x.title)),
55
+ dateFn: v => formatTime(v, 'HH:mm', locale),
56
+ valueFn: filesize
57
+ });
58
+ }
59
+ MemoryMonitor.propTypes = {
60
+ title: PropTypes.string,
61
+ instanceCount: PropTypes.number,
62
+ total: PropTypes.number,
63
+ used: PropTypes.number,
64
+ history: PropTypes.array
65
+ };
66
+ MemoryMonitor.defaultProps = {
67
+ title: '',
68
+ instanceCount: null,
69
+ total: null,
70
+ used: null,
71
+ history: []
72
+ };
@@ -0,0 +1,173 @@
1
+ import React, { useEffect, useMemo } from 'react';
2
+ import styled from '@emotion/styled';
3
+ import filesize from 'filesize';
4
+ import prettyMs from 'pretty-ms-i18n';
5
+ import Box from '@mui/material/Box';
6
+ import Datatable from '@arcblock/ux/lib/Datatable';
7
+ import Typography from '@mui/material/Typography';
8
+ import { getDisplayName, forEachBlockletSync } from '@blocklet/meta/lib/util';
9
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
10
+ import { useBlockletContext } from '../contexts/blocklet';
11
+ import { formatLocale } from '../util';
12
+ import RuntimeInfo from '../blocklet/runtime-info';
13
+ import BundleAvatar from '../blocklet/bundle-avatar';
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ import { jsxs as _jsxs } from "react/jsx-runtime";
16
+ export default function RuntimeInsight() {
17
+ const {
18
+ t,
19
+ locale
20
+ } = useLocaleContext();
21
+ const {
22
+ blocklet,
23
+ runtimeHistory,
24
+ actions: {
25
+ refreshBlocklet
26
+ }
27
+ } = useBlockletContext();
28
+ const monitList = useMemo(() => {
29
+ const arr = [];
30
+ forEachBlockletSync(blocklet, (component, {
31
+ ancestors,
32
+ id,
33
+ level
34
+ }) => {
35
+ if (component.runtimeInfo) {
36
+ arr.push({
37
+ type: 'blocklet',
38
+ groupId: blocklet.meta.did,
39
+ groupName: getDisplayName(blocklet),
40
+ id,
41
+ name: getDisplayName(component, true),
42
+ blocklet,
43
+ component,
44
+ level: level - 1 >= 0 ? level - 1 : 0,
45
+ runtimeInfo: component.runtimeInfo,
46
+ ancestors
47
+ });
48
+ }
49
+ });
50
+ return arr;
51
+ }, [blocklet]); // eslint-disable-line react-hooks/exhaustive-deps
52
+
53
+ useEffect(() => {
54
+ const interval = setInterval(() => {
55
+ refreshBlocklet();
56
+ }, 1000 * 10);
57
+ return () => {
58
+ clearInterval(interval);
59
+ };
60
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
61
+
62
+ const formatUptime = uptime => {
63
+ return prettyMs(Number(uptime || 0), {
64
+ locale: formatLocale(locale)
65
+ });
66
+ };
67
+ const monitorColumns = [{
68
+ label: t('common.name'),
69
+ name: 'name',
70
+ options: {
71
+ // eslint-disable-next-line react/no-unstable-nested-components
72
+ customBodyRenderLite(rawIndex) {
73
+ const {
74
+ name,
75
+ component,
76
+ level,
77
+ ancestors
78
+ } = monitList[rawIndex];
79
+ return /*#__PURE__*/_jsxs(Box, {
80
+ display: "flex",
81
+ alignItems: "center",
82
+ pl: level * 2,
83
+ children: [/*#__PURE__*/_jsx(BundleAvatar, {
84
+ size: 14,
85
+ blocklet: component,
86
+ ancestors: ancestors
87
+ }), /*#__PURE__*/_jsx(Box, {
88
+ ml: 1,
89
+ children: name
90
+ })]
91
+ });
92
+ }
93
+ }
94
+ }, {
95
+ label: t('common.uptime'),
96
+ name: 'runtimeInfo.uptime',
97
+ options: {
98
+ customBodyRenderLite(rawIndex) {
99
+ const {
100
+ runtimeInfo
101
+ } = monitList[rawIndex];
102
+ return formatUptime(runtimeInfo.uptime);
103
+ }
104
+ }
105
+ }, {
106
+ label: t('blocklet.runtimeInfo.memoryUsage'),
107
+ name: 'runtimeInfo.memoryUsage',
108
+ options: {
109
+ customBodyRenderLite(rawIndex) {
110
+ const {
111
+ runtimeInfo
112
+ } = monitList[rawIndex];
113
+ return filesize(runtimeInfo?.memoryUsage || 0);
114
+ }
115
+ }
116
+ }, {
117
+ label: t('blocklet.runtimeInfo.cpuUsage'),
118
+ name: 'runtimeInfo.cpuUsage',
119
+ options: {
120
+ customBodyRenderLite(rawIndex) {
121
+ const {
122
+ runtimeInfo
123
+ } = monitList[rawIndex];
124
+ return `${(runtimeInfo.cpuUsage || 0).toFixed(1)}%`;
125
+ }
126
+ }
127
+ }, {
128
+ label: t('blocklet.runtimeInfo.processId'),
129
+ name: 'runtimeInfo.pid'
130
+ }];
131
+ return /*#__PURE__*/_jsxs(Div, {
132
+ component: "div",
133
+ children: [/*#__PURE__*/_jsx(Typography, {
134
+ component: "h3",
135
+ variant: "h5",
136
+ color: "textPrimary",
137
+ style: {
138
+ fontSize: 18,
139
+ fontWeight: 'bold'
140
+ },
141
+ mb: 2,
142
+ children: t('analytics.trend')
143
+ }), blocklet.status === 'running' ? [/*#__PURE__*/_jsx(Box, {
144
+ children: /*#__PURE__*/_jsx(RuntimeInfo, {
145
+ blocklet: blocklet,
146
+ cpuHistory: runtimeHistory.cpu,
147
+ memoryHistory: runtimeHistory.memory
148
+ })
149
+ }), /*#__PURE__*/_jsx(Box, {
150
+ mt: 3,
151
+ children: /*#__PURE__*/_jsx(Datatable, {
152
+ title: t('analytics.detail'),
153
+ className: "monitor-table",
154
+ locale: locale,
155
+ data: monitList,
156
+ columns: monitorColumns,
157
+ options: {
158
+ search: false,
159
+ download: false,
160
+ filter: false,
161
+ print: false,
162
+ viewColumns: false,
163
+ pagination: false,
164
+ rowsPerPage: 100
165
+ }
166
+ })
167
+ })] : /*#__PURE__*/_jsx(Typography, {
168
+ children: t('blocklet.runtimeInfo.noRunning')
169
+ })]
170
+ });
171
+ }
172
+ RuntimeInsight.propTypes = {};
173
+ const Div = styled(Typography)``;