@electerm/electerm-react 1.34.30
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/LICENSE +21 -0
- package/README.md +31 -0
- package/client/common/auto-complete-data-mapper.js +6 -0
- package/client/common/byte-format.js +14 -0
- package/client/common/class.js +52 -0
- package/client/common/clipboard.js +49 -0
- package/client/common/constants.js +308 -0
- package/client/common/create-lang-edit-link.js +7 -0
- package/client/common/create-title.js +29 -0
- package/client/common/db-fix.js +24 -0
- package/client/common/db.js +155 -0
- package/client/common/download-mirrors.js +10 -0
- package/client/common/download.js +16 -0
- package/client/common/error-handler.jsx +27 -0
- package/client/common/fetch-from-server.js +47 -0
- package/client/common/fetch.jsx +71 -0
- package/client/common/find-bookmark-group-id.js +15 -0
- package/client/common/find-parent.js +30 -0
- package/client/common/form-layout.js +27 -0
- package/client/common/fs.js +21 -0
- package/client/common/get-proxy.js +8 -0
- package/client/common/id-with-stamp.js +10 -0
- package/client/common/index-sorter.js +4 -0
- package/client/common/init-setting-item.js +32 -0
- package/client/common/is-absolute-path.js +3 -0
- package/client/common/is-ip.js +16 -0
- package/client/common/is-valid-path.js +7 -0
- package/client/common/key-control-pressed.js +13 -0
- package/client/common/key-pressed.js +13 -0
- package/client/common/key-shift-pressed.js +7 -0
- package/client/common/mode2permission.js +81 -0
- package/client/common/new-terminal.js +31 -0
- package/client/common/parse-int10.js +3 -0
- package/client/common/parse-json-safe.js +11 -0
- package/client/common/pass-enc.js +25 -0
- package/client/common/post-msg.js +3 -0
- package/client/common/pre.js +156 -0
- package/client/common/promise-timeout.js +27 -0
- package/client/common/resolve.js +31 -0
- package/client/common/run-idle.js +1 -0
- package/client/common/safe-local-storage.js +35 -0
- package/client/common/safe-name.js +19 -0
- package/client/common/sftp.js +74 -0
- package/client/common/terminal-theme.js +158 -0
- package/client/common/test-connection.js +12 -0
- package/client/common/time.js +30 -0
- package/client/common/to-simple-obj.js +5 -0
- package/client/common/track.js +7 -0
- package/client/common/transfer.js +76 -0
- package/client/common/trzsz.js +62 -0
- package/client/common/ui-theme.js +44 -0
- package/client/common/uid.js +5 -0
- package/client/common/update-check.js +79 -0
- package/client/common/upgrade.js +68 -0
- package/client/common/wait.js +8 -0
- package/client/common/ws.js +161 -0
- package/client/components/batch-op/batch-op.jsx +650 -0
- package/client/components/bookmark-form/bookmark-form.styl +8 -0
- package/client/components/bookmark-form/bookmark-group-tree-format.js +39 -0
- package/client/components/bookmark-form/encodes.js +44 -0
- package/client/components/bookmark-form/form-ssh-common.jsx +208 -0
- package/client/components/bookmark-form/form-tabs.jsx +69 -0
- package/client/components/bookmark-form/index.jsx +159 -0
- package/client/components/bookmark-form/local-form-ui.jsx +152 -0
- package/client/components/bookmark-form/local-form.jsx +16 -0
- package/client/components/bookmark-form/proxy.jsx +49 -0
- package/client/components/bookmark-form/quick-command-list.jsx +31 -0
- package/client/components/bookmark-form/quick-command.jsx +228 -0
- package/client/components/bookmark-form/render-auth-ssh.jsx +104 -0
- package/client/components/bookmark-form/render-connection-hopping.jsx +229 -0
- package/client/components/bookmark-form/render-delayed-scripts.jsx +88 -0
- package/client/components/bookmark-form/render-ssh-tunnel.jsx +116 -0
- package/client/components/bookmark-form/serial-form-ui.jsx +311 -0
- package/client/components/bookmark-form/serial-form.jsx +20 -0
- package/client/components/bookmark-form/sftp-enable.jsx +33 -0
- package/client/components/bookmark-form/ssh-form-ui.jsx +100 -0
- package/client/components/bookmark-form/ssh-form.jsx +348 -0
- package/client/components/bookmark-form/telnet-form-ui.jsx +154 -0
- package/client/components/bookmark-form/telnet-form.jsx +16 -0
- package/client/components/bookmark-form/tree-delete.jsx +87 -0
- package/client/components/bookmark-form/use-form-funcs.jsx +50 -0
- package/client/components/bookmark-form/use-quick-commands.jsx +83 -0
- package/client/components/bookmark-form/use-submit.jsx +77 -0
- package/client/components/bookmark-form/use-ui.jsx +82 -0
- package/client/components/bookmark-form/x11.jsx +23 -0
- package/client/components/common/animate-text.jsx +37 -0
- package/client/components/common/animate-text.styl +54 -0
- package/client/components/common/external-link.jsx +28 -0
- package/client/components/common/help-icon.jsx +25 -0
- package/client/components/common/highlight.jsx +23 -0
- package/client/components/common/highlight.styl +3 -0
- package/client/components/common/input-auto-focus.jsx +68 -0
- package/client/components/common/input-confirm.jsx +66 -0
- package/client/components/common/logo-elem.jsx +22 -0
- package/client/components/common/markdown.jsx +27 -0
- package/client/components/common/react-subx.jsx +1 -0
- package/client/components/common/resize-wrap.jsx +222 -0
- package/client/components/common/resize-wrap.styl +9 -0
- package/client/components/common/search.jsx +9 -0
- package/client/components/common/show-item.jsx +27 -0
- package/client/components/context-menu/boomarks.jsx +15 -0
- package/client/components/context-menu/context-menu.jsx +340 -0
- package/client/components/context-menu/context-menu.styl +90 -0
- package/client/components/context-menu/history.jsx +27 -0
- package/client/components/context-menu/icon-holder.jsx +5 -0
- package/client/components/context-menu/menu-btn.jsx +224 -0
- package/client/components/context-menu/sub-tab-menu.jsx +23 -0
- package/client/components/context-menu/tabs.jsx +22 -0
- package/client/components/context-menu/zoom.jsx +40 -0
- package/client/components/footer/batch-input.jsx +177 -0
- package/client/components/footer/footer-entry.jsx +141 -0
- package/client/components/footer/footer.styl +47 -0
- package/client/components/icons/match-case.jsx +10 -0
- package/client/components/icons/match-whole-word.jsx +13 -0
- package/client/components/icons/regular-exp.jsx +10 -0
- package/client/components/main/css-overwrite.jsx +92 -0
- package/client/components/main/error-wrapper.jsx +59 -0
- package/client/components/main/index.jsx +11 -0
- package/client/components/main/loading.jsx +25 -0
- package/client/components/main/main.jsx +149 -0
- package/client/components/main/term-fullscreen-control.jsx +21 -0
- package/client/components/main/term-fullscreen.styl +27 -0
- package/client/components/main/ui-theme.jsx +31 -0
- package/client/components/main/upgrade.jsx +351 -0
- package/client/components/main/upgrade.styl +27 -0
- package/client/components/main/wrapper.styl +41 -0
- package/client/components/quick-commands/qm.styl +29 -0
- package/client/components/quick-commands/quick-command-item.jsx +36 -0
- package/client/components/quick-commands/quick-command-transport-mod.jsx +54 -0
- package/client/components/quick-commands/quick-command-transport.jsx +12 -0
- package/client/components/quick-commands/quick-commands-box.jsx +233 -0
- package/client/components/quick-commands/quick-commands-form-elem.jsx +119 -0
- package/client/components/quick-commands/quick-commands-form.jsx +33 -0
- package/client/components/quick-commands/quick-commands-list.jsx +128 -0
- package/client/components/quick-commands/quick-commands-select.jsx +38 -0
- package/client/components/session/session.jsx +533 -0
- package/client/components/session/session.styl +53 -0
- package/client/components/session/sessions.jsx +445 -0
- package/client/components/setting-panel/bookmark-transport.jsx +148 -0
- package/client/components/setting-panel/bookmark-tree-list.jsx +14 -0
- package/client/components/setting-panel/col.jsx +18 -0
- package/client/components/setting-panel/list.jsx +186 -0
- package/client/components/setting-panel/list.styl +33 -0
- package/client/components/setting-panel/on-tree-drop.js +222 -0
- package/client/components/setting-panel/setting-modal.jsx +163 -0
- package/client/components/setting-panel/setting-wrap.jsx +37 -0
- package/client/components/setting-panel/setting-wrap.styl +52 -0
- package/client/components/setting-panel/setting.jsx +858 -0
- package/client/components/setting-panel/setting.styl +4 -0
- package/client/components/setting-panel/start-session-select.jsx +91 -0
- package/client/components/setting-panel/tab-bookmarks.jsx +37 -0
- package/client/components/setting-panel/tab-history.jsx +44 -0
- package/client/components/setting-panel/tab-quick-commands.jsx +38 -0
- package/client/components/setting-panel/tab-settings.jsx +42 -0
- package/client/components/setting-panel/tab-themes.jsx +34 -0
- package/client/components/setting-panel/tree-list.jsx +978 -0
- package/client/components/setting-panel/tree-list.styl +57 -0
- package/client/components/setting-sync/data-import.jsx +65 -0
- package/client/components/setting-sync/setting-sync-form.jsx +271 -0
- package/client/components/setting-sync/setting-sync.jsx +81 -0
- package/client/components/setting-sync/sync.styl +7 -0
- package/client/components/sftp/address-bar.jsx +139 -0
- package/client/components/sftp/address-bookmark-item.jsx +47 -0
- package/client/components/sftp/address-bookmark.jsx +81 -0
- package/client/components/sftp/address-bookmark.styl +8 -0
- package/client/components/sftp/confirm-modal.jsx +184 -0
- package/client/components/sftp/file-icon.jsx +22 -0
- package/client/components/sftp/file-item.jsx +1226 -0
- package/client/components/sftp/file-mode-modal.jsx +205 -0
- package/client/components/sftp/file-props-modal.jsx +211 -0
- package/client/components/sftp/file-read.js +81 -0
- package/client/components/sftp/list-table-ui.jsx +547 -0
- package/client/components/sftp/owner-list.js +97 -0
- package/client/components/sftp/paged-list.jsx +60 -0
- package/client/components/sftp/permission-render.jsx +42 -0
- package/client/components/sftp/sftp-entry.jsx +1069 -0
- package/client/components/sftp/sftp.styl +217 -0
- package/client/components/sftp/transfer-common.js +9 -0
- package/client/components/sftp/transfer-conflict.jsx +315 -0
- package/client/components/sftp/transfer-speed-format.js +60 -0
- package/client/components/sftp/transfer-tag.jsx +40 -0
- package/client/components/sftp/transfer-tag.styl +11 -0
- package/client/components/sftp/transfer.styl +55 -0
- package/client/components/sftp/transport-action.jsx +410 -0
- package/client/components/sftp/transport-entry.jsx +108 -0
- package/client/components/sftp/transport-types.js +8 -0
- package/client/components/sftp/transports-action.jsx +111 -0
- package/client/components/sftp/transports-ui.jsx +93 -0
- package/client/components/sftp/zip.js +42 -0
- package/client/components/sidebar/bookmark-select.jsx +48 -0
- package/client/components/sidebar/bookmark.jsx +82 -0
- package/client/components/sidebar/history.jsx +66 -0
- package/client/components/sidebar/index.jsx +230 -0
- package/client/components/sidebar/info-modal.jsx +250 -0
- package/client/components/sidebar/info.styl +27 -0
- package/client/components/sidebar/side-icon.jsx +25 -0
- package/client/components/sidebar/sidebar.styl +128 -0
- package/client/components/sidebar/transfer-history-modal.jsx +110 -0
- package/client/components/sidebar/transfer-history.styl +3 -0
- package/client/components/sidebar/transfer-list-control.jsx +205 -0
- package/client/components/sidebar/transfer-list.jsx +55 -0
- package/client/components/sidebar/transfer-modal.jsx +76 -0
- package/client/components/sidebar/transfer.styl +8 -0
- package/client/components/sidebar/transport-ui.jsx +109 -0
- package/client/components/tabs/index.jsx +320 -0
- package/client/components/tabs/tab.jsx +427 -0
- package/client/components/tabs/tabs.styl +220 -0
- package/client/components/tabs/window-control.jsx +55 -0
- package/client/components/terminal/attach-addon-custom.js +70 -0
- package/client/components/terminal/build-ls-term-id.js +5 -0
- package/client/components/terminal/index.jsx +1358 -0
- package/client/components/terminal/normal-buffer.jsx +33 -0
- package/client/components/terminal/term-search.jsx +224 -0
- package/client/components/terminal/term-search.styl +15 -0
- package/client/components/terminal/terminal-apis.js +31 -0
- package/client/components/terminal/terminal-interactive.jsx +148 -0
- package/client/components/terminal/terminal.styl +96 -0
- package/client/components/terminal/xterm-zmodem.js +48 -0
- package/client/components/terminal/zmodem-transfer.jsx +98 -0
- package/client/components/terminal/zmodem.styl +14 -0
- package/client/components/terminal-info/activity.jsx +54 -0
- package/client/components/terminal-info/base.jsx +25 -0
- package/client/components/terminal-info/content.jsx +101 -0
- package/client/components/terminal-info/data-cols-parser.jsx +50 -0
- package/client/components/terminal-info/disk.jsx +29 -0
- package/client/components/terminal-info/index.jsx +25 -0
- package/client/components/terminal-info/network.jsx +114 -0
- package/client/components/terminal-info/resource.jsx +80 -0
- package/client/components/terminal-info/run-cmd.jsx +273 -0
- package/client/components/terminal-info/terminal-info.styl +29 -0
- package/client/components/terminal-info/up.jsx +15 -0
- package/client/components/terminal-theme/index.jsx +264 -0
- package/client/components/terminal-theme/terminal-theme-list.styl +3 -0
- package/client/components/terminal-theme/theme-list.jsx +146 -0
- package/client/components/text-editor/text-editor-form.jsx +97 -0
- package/client/components/text-editor/text-editor.jsx +182 -0
- package/client/css/antd-overwrite.styl +14 -0
- package/client/css/basic.styl +38 -0
- package/client/css/includes/box.styl +154 -0
- package/client/css/includes/font-size.styl +6 -0
- package/client/css/includes/index.styl +3 -0
- package/client/css/includes/text.styl +31 -0
- package/client/css/includes/theme-default.styl +20 -0
- package/client/entry/basic.js +58 -0
- package/client/entry/index.jsx +15 -0
- package/client/entry/worker.js +137 -0
- package/client/store/address-bookmark.js +25 -0
- package/client/store/app-upgrade.js +23 -0
- package/client/store/batch-input-history.js +26 -0
- package/client/store/bookmark-group.js +128 -0
- package/client/store/bookmark.js +22 -0
- package/client/store/common.js +140 -0
- package/client/store/context-menu.js +23 -0
- package/client/store/db-upgrade.js +43 -0
- package/client/store/event.js +70 -0
- package/client/store/index.js +335 -0
- package/client/store/init-state.js +191 -0
- package/client/store/item.js +120 -0
- package/client/store/load-data.js +198 -0
- package/client/store/quick-command.js +43 -0
- package/client/store/session.js +54 -0
- package/client/store/setting.js +208 -0
- package/client/store/sidebar.js +48 -0
- package/client/store/sync.js +390 -0
- package/client/store/system-menu.js +120 -0
- package/client/store/tab.js +74 -0
- package/client/store/terminal-theme.js +116 -0
- package/client/store/transfer-history.js +27 -0
- package/client/store/transfer-list.js +20 -0
- package/client/store/ui-theme.js +71 -0
- package/client/store/watch.js +116 -0
- package/client/views/index.pug +58 -0
- package/package.json +34 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* process cpu/mem activities
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Table, Tooltip, Popconfirm } from 'antd'
|
|
6
|
+
import { isEmpty } from 'lodash-es'
|
|
7
|
+
import { CloseCircleOutlined } from '@ant-design/icons'
|
|
8
|
+
import colsParser from './data-cols-parser'
|
|
9
|
+
|
|
10
|
+
const { prefix } = window
|
|
11
|
+
const m = prefix('menu')
|
|
12
|
+
|
|
13
|
+
export default function TerminalInfoActivities (props) {
|
|
14
|
+
const { activities } = props
|
|
15
|
+
if (isEmpty(activities) || !props.isRemote) {
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
const col = colsParser(activities[0])
|
|
19
|
+
col.unshift({
|
|
20
|
+
dataIndex: 'kill',
|
|
21
|
+
key: 'kill',
|
|
22
|
+
title: m('close'),
|
|
23
|
+
render: (txt, inst) => {
|
|
24
|
+
return (
|
|
25
|
+
<Tooltip
|
|
26
|
+
title={m('close')}
|
|
27
|
+
>
|
|
28
|
+
<Popconfirm
|
|
29
|
+
title={m('close') + ' pid:' + inst.pid + ' ?'}
|
|
30
|
+
onConfirm={() => props.killProcess(inst.pid)}
|
|
31
|
+
>
|
|
32
|
+
<CloseCircleOutlined
|
|
33
|
+
className='pointer'
|
|
34
|
+
/>
|
|
35
|
+
</Popconfirm>
|
|
36
|
+
</Tooltip>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
const ps = {
|
|
41
|
+
rowKey: 'pid',
|
|
42
|
+
dataSource: activities,
|
|
43
|
+
bordered: true,
|
|
44
|
+
columns: col,
|
|
45
|
+
size: 'small',
|
|
46
|
+
pagination: false
|
|
47
|
+
}
|
|
48
|
+
return (
|
|
49
|
+
<div className='terminal-info-section terminal-info-act'>
|
|
50
|
+
<div className='pd1y bold'>Activities</div>
|
|
51
|
+
<Table {...ps} />
|
|
52
|
+
</div>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* show base terminal info, id sessionID
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// import { createLogFileName } from '../../../app/common/create-session-log-file-path'
|
|
6
|
+
import { osResolve } from '../../common/resolve'
|
|
7
|
+
import ShowItem from '../common/show-item'
|
|
8
|
+
|
|
9
|
+
const { prefix } = window
|
|
10
|
+
const c = prefix('common')
|
|
11
|
+
const st = prefix('setting')
|
|
12
|
+
|
|
13
|
+
export default function TerminalInfoBase (props) {
|
|
14
|
+
const { id, saveTerminalLogToFile, logName } = props
|
|
15
|
+
const path = osResolve(props.appPath, 'electerm', 'session_logs', logName + '.log')
|
|
16
|
+
const to = saveTerminalLogToFile
|
|
17
|
+
? <ShowItem disabled={!saveTerminalLogToFile} to={path}>{path}</ShowItem>
|
|
18
|
+
: `-> ${c('setting')} -> ${st('saveTerminalLogToFile')}`
|
|
19
|
+
return (
|
|
20
|
+
<div className='terminal-info-section terminal-info-base'>
|
|
21
|
+
<p><b>ID:</b> {id}</p>
|
|
22
|
+
<p><b>log:</b> {to}</p>
|
|
23
|
+
</div>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* info content module
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import TerminalInfoBase from './base'
|
|
6
|
+
import TerminalInfoUp from './up'
|
|
7
|
+
import TerminalInfoNetwork from './network'
|
|
8
|
+
import TerminalInfoResource from './resource'
|
|
9
|
+
import TerminalInfoActivities from './activity'
|
|
10
|
+
import TerminalInfoDisk from './disk'
|
|
11
|
+
import { useState } from 'react'
|
|
12
|
+
import RunCmd from './run-cmd'
|
|
13
|
+
import {
|
|
14
|
+
sidebarWidth,
|
|
15
|
+
termControlHeight
|
|
16
|
+
} from '../../common/constants'
|
|
17
|
+
import { runCmd } from '../terminal/terminal-apis'
|
|
18
|
+
import { CloseCircleOutlined, LeftCircleOutlined, RightCircleOutlined } from '@ant-design/icons'
|
|
19
|
+
|
|
20
|
+
export default function TerminalInfoContent (props) {
|
|
21
|
+
if (!props.showInfo) {
|
|
22
|
+
return null
|
|
23
|
+
}
|
|
24
|
+
const [state, setter] = useState({
|
|
25
|
+
expand: false,
|
|
26
|
+
uptime: '',
|
|
27
|
+
cpu: '',
|
|
28
|
+
mem: {},
|
|
29
|
+
swap: {},
|
|
30
|
+
activities: [],
|
|
31
|
+
disks: [],
|
|
32
|
+
network: {}
|
|
33
|
+
})
|
|
34
|
+
function setState (ext) {
|
|
35
|
+
setter(s => {
|
|
36
|
+
return Object.assign({}, s, ext)
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
async function killProcess (id) {
|
|
40
|
+
const {
|
|
41
|
+
pid,
|
|
42
|
+
sessionId
|
|
43
|
+
} = props
|
|
44
|
+
const cmd = `kill ${id}`
|
|
45
|
+
runCmd(pid, sessionId, cmd)
|
|
46
|
+
}
|
|
47
|
+
const pops = {
|
|
48
|
+
onClick: props.hideInfoPanel,
|
|
49
|
+
className: 'pointer font20 hide-info-panel-wrap'
|
|
50
|
+
}
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
className='info-panel-wrap'
|
|
54
|
+
style={{
|
|
55
|
+
width: state.expand ? `calc(100% - ${sidebarWidth}px)` : '50%',
|
|
56
|
+
top: props.topMenuHeight + props.tabsHeight + termControlHeight - 4
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
<div className='pd2t pd2x'>
|
|
60
|
+
<CloseCircleOutlined
|
|
61
|
+
{...pops}
|
|
62
|
+
/>
|
|
63
|
+
{
|
|
64
|
+
state.expand
|
|
65
|
+
? (
|
|
66
|
+
<RightCircleOutlined
|
|
67
|
+
onClick={() => setState({
|
|
68
|
+
expand: false
|
|
69
|
+
})}
|
|
70
|
+
className='pointer font20 mg1l'
|
|
71
|
+
/>
|
|
72
|
+
)
|
|
73
|
+
: (
|
|
74
|
+
<LeftCircleOutlined
|
|
75
|
+
onClick={() => setState({
|
|
76
|
+
expand: true
|
|
77
|
+
})}
|
|
78
|
+
className='pointer font20 mg1l'
|
|
79
|
+
/>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
</div>
|
|
84
|
+
<div className='pd2'>
|
|
85
|
+
<TerminalInfoBase {...props} {...state} />
|
|
86
|
+
<TerminalInfoUp {...props} {...state} />
|
|
87
|
+
<TerminalInfoResource
|
|
88
|
+
{...props} {...state}
|
|
89
|
+
/>
|
|
90
|
+
<TerminalInfoActivities
|
|
91
|
+
{...props}
|
|
92
|
+
{...state}
|
|
93
|
+
killProcess={killProcess}
|
|
94
|
+
/>
|
|
95
|
+
<TerminalInfoNetwork {...props} {...state} />
|
|
96
|
+
<TerminalInfoDisk {...props} {...state} />
|
|
97
|
+
<RunCmd {...props} setState={setState} />
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { copy } from '../../common/clipboard'
|
|
2
|
+
import filesizeParser from 'filesize-parser'
|
|
3
|
+
import { formatBytes } from '../../common/byte-format'
|
|
4
|
+
|
|
5
|
+
const { prefix } = window
|
|
6
|
+
const m = prefix('menu')
|
|
7
|
+
|
|
8
|
+
const valueParserMaps = {
|
|
9
|
+
size: v => v,
|
|
10
|
+
used: filesizeParser,
|
|
11
|
+
avail: filesizeParser,
|
|
12
|
+
usedPercent: v => parseFloat(v.replace('%', ''))
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function valueParse (obj, k) {
|
|
16
|
+
if (valueParserMaps[k]) {
|
|
17
|
+
return valueParserMaps[k](obj[k])
|
|
18
|
+
}
|
|
19
|
+
return obj[k]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default (data) => {
|
|
23
|
+
return Object.keys(data).map(k => {
|
|
24
|
+
const rd = (txt) => {
|
|
25
|
+
const r = k === 'mem' ? formatBytes(parseInt(txt, 10)) : txt
|
|
26
|
+
return (
|
|
27
|
+
<div className='activity-item'>
|
|
28
|
+
<span>{r}</span>
|
|
29
|
+
<span
|
|
30
|
+
className='pointer activity-item-copy mg1l bold color-blue'
|
|
31
|
+
onClick={() => copy(txt)}
|
|
32
|
+
>
|
|
33
|
+
{m('copy')}
|
|
34
|
+
</span>
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
title: k,
|
|
40
|
+
dataIndex: k,
|
|
41
|
+
key: k,
|
|
42
|
+
sorter: (a, b) => {
|
|
43
|
+
const va = valueParse(a, k)
|
|
44
|
+
const vb = valueParse(b, k)
|
|
45
|
+
return va > vb ? 1 : -1
|
|
46
|
+
},
|
|
47
|
+
render: rd
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* disk info
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Table } from 'antd'
|
|
6
|
+
import { isEmpty } from 'lodash-es'
|
|
7
|
+
import colsParser from './data-cols-parser'
|
|
8
|
+
|
|
9
|
+
export default function TerminalInfoDisk (props) {
|
|
10
|
+
const { disks } = props
|
|
11
|
+
if (isEmpty(disks) || !props.isRemote) {
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
const col = colsParser(disks[0])
|
|
15
|
+
const ps = {
|
|
16
|
+
rowKey: (rec) => `${rec.mount}_${rec.filesystem}`,
|
|
17
|
+
dataSource: disks,
|
|
18
|
+
bordered: true,
|
|
19
|
+
columns: col,
|
|
20
|
+
size: 'small',
|
|
21
|
+
pagination: false
|
|
22
|
+
}
|
|
23
|
+
return (
|
|
24
|
+
<div className='terminal-info-section terminal-info-disk'>
|
|
25
|
+
<div className='pd1y bold'>File system</div>
|
|
26
|
+
<Table {...ps} />
|
|
27
|
+
</div>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* show terminal info
|
|
3
|
+
* inluding id log path, and system info for remote session
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { InfoCircleOutlined } from '@ant-design/icons'
|
|
7
|
+
|
|
8
|
+
import { Tooltip } from 'antd'
|
|
9
|
+
import './terminal-info.styl'
|
|
10
|
+
|
|
11
|
+
export default function TerminalInfoIndex (props) {
|
|
12
|
+
const pops = {
|
|
13
|
+
onClick: props.showInfoPanel,
|
|
14
|
+
className: 'pointer font18 terminal-info-icon'
|
|
15
|
+
}
|
|
16
|
+
return (
|
|
17
|
+
<Tooltip
|
|
18
|
+
title='Terminal Info'
|
|
19
|
+
>
|
|
20
|
+
<InfoCircleOutlined
|
|
21
|
+
{...pops}
|
|
22
|
+
/>
|
|
23
|
+
</Tooltip>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* network info
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Table } from 'antd'
|
|
6
|
+
import { isEmpty } from 'lodash-es'
|
|
7
|
+
import { useEffect, useState } from 'react'
|
|
8
|
+
import { formatBytes } from '../../common/byte-format'
|
|
9
|
+
import copy from 'json-deep-copy'
|
|
10
|
+
|
|
11
|
+
export default function TerminalInfoDisk (props) {
|
|
12
|
+
const { network } = props
|
|
13
|
+
if (isEmpty(network) || !props.isRemote) {
|
|
14
|
+
return null
|
|
15
|
+
}
|
|
16
|
+
const [state, setter] = useState({
|
|
17
|
+
network: props.network,
|
|
18
|
+
time: Date.now()
|
|
19
|
+
})
|
|
20
|
+
function setState (ext) {
|
|
21
|
+
setter(s => {
|
|
22
|
+
return Object.assign({}, s, ext)
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
function updateTraffic () {
|
|
26
|
+
const network = copy(props.network)
|
|
27
|
+
const keys = Object.keys(network)
|
|
28
|
+
const net = copy(state.network)
|
|
29
|
+
const now = Date.now()
|
|
30
|
+
const { time } = state
|
|
31
|
+
const diff = (now - time) / 1000
|
|
32
|
+
for (const k of keys) {
|
|
33
|
+
const p = network[k]
|
|
34
|
+
const pv = net[k]
|
|
35
|
+
if (
|
|
36
|
+
p &&
|
|
37
|
+
pv &&
|
|
38
|
+
p.download &&
|
|
39
|
+
pv.download &&
|
|
40
|
+
p.download > pv.download
|
|
41
|
+
) {
|
|
42
|
+
p.down = Math.floor((p.download - pv.download) / diff)
|
|
43
|
+
}
|
|
44
|
+
if (
|
|
45
|
+
p &&
|
|
46
|
+
pv &&
|
|
47
|
+
p.upload &&
|
|
48
|
+
pv.upload &&
|
|
49
|
+
p.upload > pv.upload
|
|
50
|
+
) {
|
|
51
|
+
p.up = Math.floor((p.upload - pv.upload) / diff)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
setState({
|
|
55
|
+
network,
|
|
56
|
+
time: now
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
updateTraffic()
|
|
61
|
+
}, [props.network])
|
|
62
|
+
if (isEmpty(state)) {
|
|
63
|
+
return null
|
|
64
|
+
}
|
|
65
|
+
const arr = Object.keys(state.network).map(k => {
|
|
66
|
+
return {
|
|
67
|
+
name: k,
|
|
68
|
+
...state.network[k]
|
|
69
|
+
}
|
|
70
|
+
}).sort((a, b) => {
|
|
71
|
+
const ai = a.name.startsWith('eth') ? 100 : 10
|
|
72
|
+
const bi = b.name.startsWith('eth') ? 100 : 10
|
|
73
|
+
if (ai !== bi) {
|
|
74
|
+
return bi - ai
|
|
75
|
+
}
|
|
76
|
+
return a.name > b.name ? 1 : -1
|
|
77
|
+
})
|
|
78
|
+
const map = {
|
|
79
|
+
up: '↑',
|
|
80
|
+
down: '↓',
|
|
81
|
+
name: 'name',
|
|
82
|
+
ip: 'ipv4'
|
|
83
|
+
}
|
|
84
|
+
const col = ['name', 'ip', 'up', 'down'].map((k, i) => {
|
|
85
|
+
return {
|
|
86
|
+
title: map[k],
|
|
87
|
+
dataIndex: k,
|
|
88
|
+
key: k,
|
|
89
|
+
sorter: (a, b) => {
|
|
90
|
+
return a[k] > b[k] ? 1 : -1
|
|
91
|
+
},
|
|
92
|
+
render: (v) => {
|
|
93
|
+
if (k === 'up' || k === 'down') {
|
|
94
|
+
return formatBytes(v)
|
|
95
|
+
}
|
|
96
|
+
return v
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
const ps = {
|
|
101
|
+
rowKey: 'name',
|
|
102
|
+
dataSource: arr,
|
|
103
|
+
bordered: true,
|
|
104
|
+
size: 'small',
|
|
105
|
+
columns: col,
|
|
106
|
+
pagination: false
|
|
107
|
+
}
|
|
108
|
+
return (
|
|
109
|
+
<div className='terminal-info-section terminal-info-network'>
|
|
110
|
+
<div className='pd1y bold'>Network</div>
|
|
111
|
+
<Table {...ps} />
|
|
112
|
+
</div>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cpu/swap/mem general usage
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { isEmpty, isUndefined } from 'lodash-es'
|
|
6
|
+
import { Progress } from 'antd'
|
|
7
|
+
import parseInt10 from '../../common/parse-int10'
|
|
8
|
+
|
|
9
|
+
function toNumber (n = '') {
|
|
10
|
+
let f = 1
|
|
11
|
+
if (n.includes('G')) {
|
|
12
|
+
f = 1024 * 1024
|
|
13
|
+
} else if (n.includes('T')) {
|
|
14
|
+
f = 1024 * 1024 * 1024
|
|
15
|
+
} else if (n.includes('M')) {
|
|
16
|
+
f = 1024
|
|
17
|
+
}
|
|
18
|
+
return f * parseFloat(n)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function computePercent (used, total) {
|
|
22
|
+
const u = toNumber(used)
|
|
23
|
+
const t = toNumber(total)
|
|
24
|
+
return Math.floor(u * 100 / (t || (u + 1)))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default function TerminalInfoResource (props) {
|
|
28
|
+
const { cpu, mem, swap } = props
|
|
29
|
+
if (!props.isRemote) {
|
|
30
|
+
return null
|
|
31
|
+
}
|
|
32
|
+
function renderItem (obj) {
|
|
33
|
+
if (isEmpty(obj)) {
|
|
34
|
+
return <div className='pd1b' key={obj.name}>NA</div>
|
|
35
|
+
}
|
|
36
|
+
const {
|
|
37
|
+
used,
|
|
38
|
+
total,
|
|
39
|
+
percent,
|
|
40
|
+
name
|
|
41
|
+
} = obj
|
|
42
|
+
const hasPercent = !isUndefined(percent)
|
|
43
|
+
const p = hasPercent
|
|
44
|
+
? percent
|
|
45
|
+
: computePercent(used, total) || 0
|
|
46
|
+
const fmt = hasPercent
|
|
47
|
+
? (p) => `${name}: ${p || ''}%`
|
|
48
|
+
: (p) => `${name}: ${p || ''}%(${used || ''}/${total || ''})`
|
|
49
|
+
return (
|
|
50
|
+
<div className='pd1b' key={name}>
|
|
51
|
+
<Progress
|
|
52
|
+
style={{ width: '50%' }}
|
|
53
|
+
percent={p}
|
|
54
|
+
format={fmt}
|
|
55
|
+
/>
|
|
56
|
+
</div>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
const data = [
|
|
60
|
+
{
|
|
61
|
+
name: 'cpu',
|
|
62
|
+
percent: parseInt10(cpu)
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'mem',
|
|
66
|
+
...mem
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'swap',
|
|
70
|
+
...swap
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
return (
|
|
74
|
+
<div className='terminal-info-section terminal-info-resource'>
|
|
75
|
+
{
|
|
76
|
+
data.map(renderItem)
|
|
77
|
+
}
|
|
78
|
+
</div>
|
|
79
|
+
)
|
|
80
|
+
}
|