@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,205 @@
|
|
|
1
|
+
import { Component } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Select
|
|
4
|
+
} from 'antd'
|
|
5
|
+
import Transport from './transport-ui'
|
|
6
|
+
import {
|
|
7
|
+
PlayCircleOutlined,
|
|
8
|
+
PauseCircleOutlined
|
|
9
|
+
} from '@ant-design/icons'
|
|
10
|
+
import { get } from 'lodash-es'
|
|
11
|
+
import {
|
|
12
|
+
transportTypes
|
|
13
|
+
} from '../sftp/transport-types'
|
|
14
|
+
import postMessage from '../../common/post-msg'
|
|
15
|
+
|
|
16
|
+
const { Option } = Select
|
|
17
|
+
|
|
18
|
+
const { prefix } = window
|
|
19
|
+
const e = prefix('sftp')
|
|
20
|
+
|
|
21
|
+
export default class TransferModalUI extends Component {
|
|
22
|
+
state = {
|
|
23
|
+
filter: 'all'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getCurrentTransports = () => {
|
|
27
|
+
return this.getTransferList().filter(t => t.inited)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
handlePauseOrResumeAll = () => {
|
|
31
|
+
postMessage({
|
|
32
|
+
action: transportTypes.pauseOrResumeAll,
|
|
33
|
+
id: this.state.filter
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
handleCancelAll = () => {
|
|
38
|
+
postMessage({
|
|
39
|
+
action: transportTypes.cancelAll,
|
|
40
|
+
id: this.state.filter
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getGroups = () => {
|
|
45
|
+
const fileTransfers = this.props.store.getTransfers()
|
|
46
|
+
const tree = fileTransfers.reduce((p, k) => {
|
|
47
|
+
const {
|
|
48
|
+
id,
|
|
49
|
+
title,
|
|
50
|
+
sessionId
|
|
51
|
+
} = k
|
|
52
|
+
if (!p[sessionId]) {
|
|
53
|
+
p[sessionId] = {
|
|
54
|
+
title,
|
|
55
|
+
transfers: []
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
p[sessionId].transfers.push(id)
|
|
59
|
+
return p
|
|
60
|
+
}, {})
|
|
61
|
+
return Object.keys(tree)
|
|
62
|
+
.map(id => {
|
|
63
|
+
const { transfers, title } = tree[id]
|
|
64
|
+
return {
|
|
65
|
+
id,
|
|
66
|
+
transfers,
|
|
67
|
+
title
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
handleFilter = (filter) => {
|
|
73
|
+
this.setState({
|
|
74
|
+
filter
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
getTransferList = () => {
|
|
79
|
+
const {
|
|
80
|
+
filter
|
|
81
|
+
} = this.state
|
|
82
|
+
const fileTransfers = this.props.store.getTransfers()
|
|
83
|
+
return filter === 'all'
|
|
84
|
+
? fileTransfers
|
|
85
|
+
: fileTransfers.filter(d => d.sessionId === filter)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
computePercent = () => {
|
|
89
|
+
const { all, transfered } = this.getTransferList().reduce((prev, c) => {
|
|
90
|
+
prev.all += c?.fromFile?.size || 0
|
|
91
|
+
prev.transfered += (c.transferred || 0)
|
|
92
|
+
return prev
|
|
93
|
+
}, {
|
|
94
|
+
all: 0,
|
|
95
|
+
transfered: 0
|
|
96
|
+
})
|
|
97
|
+
let percent = all === 0
|
|
98
|
+
? 0
|
|
99
|
+
: Math.floor(100 * transfered / all)
|
|
100
|
+
percent = percent >= 100 ? 99 : percent
|
|
101
|
+
return percent
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
computeLeftTime = () => {
|
|
105
|
+
const sorted = this.getCurrentTransports().sort((b, a) => a.leftTimeInt - b.leftTimeInt)
|
|
106
|
+
return get(sorted, '[0].leftTime') || '-'
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
computePausing = () => {
|
|
110
|
+
return this.getCurrentTransports().reduce((prev, c) => {
|
|
111
|
+
return prev && c.pausing
|
|
112
|
+
}, true)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
renderTransportIcon = () => {
|
|
116
|
+
const pausing = this.computePausing()
|
|
117
|
+
const Icon = pausing ? PlayCircleOutlined : PauseCircleOutlined
|
|
118
|
+
return <Icon className='font14' />
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
renderTransfers = () => {
|
|
122
|
+
return (
|
|
123
|
+
<div className='transports-content overscroll-y'>
|
|
124
|
+
{
|
|
125
|
+
this.getTransferList().map((t, i) => {
|
|
126
|
+
const { id } = t
|
|
127
|
+
return (
|
|
128
|
+
<Transport
|
|
129
|
+
transfer={t}
|
|
130
|
+
key={id + ':tr:' + i}
|
|
131
|
+
/>
|
|
132
|
+
)
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
</div>
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
renderFilters = () => {
|
|
140
|
+
const groups = this.getGroups()
|
|
141
|
+
const all = [
|
|
142
|
+
{
|
|
143
|
+
id: 'all',
|
|
144
|
+
title: 'All'
|
|
145
|
+
},
|
|
146
|
+
...groups
|
|
147
|
+
]
|
|
148
|
+
return (
|
|
149
|
+
<div>
|
|
150
|
+
<Select
|
|
151
|
+
value={this.state.filter}
|
|
152
|
+
onChange={this.handleFilter}
|
|
153
|
+
popupMatchSelectWidth={false}
|
|
154
|
+
>
|
|
155
|
+
{
|
|
156
|
+
all.map(item => {
|
|
157
|
+
return (
|
|
158
|
+
<Option
|
|
159
|
+
key={item.id}
|
|
160
|
+
value={item.id}
|
|
161
|
+
>
|
|
162
|
+
{item.title}
|
|
163
|
+
</Option>
|
|
164
|
+
)
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
</Select>
|
|
168
|
+
</div>
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
render () {
|
|
173
|
+
return (
|
|
174
|
+
<div className='pd1t'>
|
|
175
|
+
<div className='transports-wrap-side fix pd1y'>
|
|
176
|
+
<div
|
|
177
|
+
className='fleft'
|
|
178
|
+
>
|
|
179
|
+
{
|
|
180
|
+
this.renderFilters()
|
|
181
|
+
}
|
|
182
|
+
</div>
|
|
183
|
+
<div className='fright'>
|
|
184
|
+
<span
|
|
185
|
+
className='pointer'
|
|
186
|
+
onClick={this.handlePauseOrResumeAll}
|
|
187
|
+
>
|
|
188
|
+
{this.renderTransportIcon()} {this.computePercent()}%({this.computeLeftTime()})
|
|
189
|
+
<span className='mg1x'>
|
|
190
|
+
[{this.getCurrentTransports().length} / {this.getTransferList().length}]
|
|
191
|
+
</span>
|
|
192
|
+
</span>
|
|
193
|
+
<span
|
|
194
|
+
className='color-red pointer'
|
|
195
|
+
onClick={this.handleCancelAll}
|
|
196
|
+
>
|
|
197
|
+
{e('cancelAll')}
|
|
198
|
+
</span>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
{this.renderTransfers()}
|
|
202
|
+
</div>
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Component } from '../common/react-subx'
|
|
2
|
+
import {
|
|
3
|
+
SwapOutlined
|
|
4
|
+
} from '@ant-design/icons'
|
|
5
|
+
import {
|
|
6
|
+
Badge,
|
|
7
|
+
Popover
|
|
8
|
+
} from 'antd'
|
|
9
|
+
import TransferModal from './transfer-modal'
|
|
10
|
+
import './transfer.styl'
|
|
11
|
+
|
|
12
|
+
const { prefix } = window
|
|
13
|
+
const e = prefix('sftp')
|
|
14
|
+
|
|
15
|
+
export default class TransferList extends Component {
|
|
16
|
+
render () {
|
|
17
|
+
const { store } = this.props
|
|
18
|
+
const {
|
|
19
|
+
fileTransfers,
|
|
20
|
+
transferHistory
|
|
21
|
+
} = store
|
|
22
|
+
if (!fileTransfers.length && !transferHistory.length) {
|
|
23
|
+
return null
|
|
24
|
+
}
|
|
25
|
+
const color = fileTransfers.some(item => item.error) ? 'red' : 'green'
|
|
26
|
+
const bdProps = {
|
|
27
|
+
count: fileTransfers.length,
|
|
28
|
+
size: 'small',
|
|
29
|
+
offset: [-10, -5],
|
|
30
|
+
color,
|
|
31
|
+
overflowCount: 99
|
|
32
|
+
}
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
className='control-icon-wrap'
|
|
36
|
+
title={e('fileTransfers')}
|
|
37
|
+
>
|
|
38
|
+
<Popover
|
|
39
|
+
placement='right'
|
|
40
|
+
destroyTooltipOnHide
|
|
41
|
+
overlayClassName='transfer-list-card'
|
|
42
|
+
content={<TransferModal store={store} />}
|
|
43
|
+
>
|
|
44
|
+
<Badge
|
|
45
|
+
{...bdProps}
|
|
46
|
+
>
|
|
47
|
+
<SwapOutlined
|
|
48
|
+
className='iblock font20 control-icon'
|
|
49
|
+
/>
|
|
50
|
+
</Badge>
|
|
51
|
+
</Popover>
|
|
52
|
+
</div>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Component } from '../common/react-subx'
|
|
2
|
+
import {
|
|
3
|
+
Tabs
|
|
4
|
+
} from 'antd'
|
|
5
|
+
import Transports from './transfer-list-control'
|
|
6
|
+
import TransportHistory from './transfer-history-modal'
|
|
7
|
+
|
|
8
|
+
const { prefix } = window
|
|
9
|
+
const e = prefix('sftp')
|
|
10
|
+
const t = prefix('transferHistory')
|
|
11
|
+
|
|
12
|
+
export default class TransferModal extends Component {
|
|
13
|
+
renderTransfer = () => {
|
|
14
|
+
return (
|
|
15
|
+
<Transports
|
|
16
|
+
store={this.props.store}
|
|
17
|
+
/>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
renderHistory = () => {
|
|
22
|
+
return (
|
|
23
|
+
<TransportHistory
|
|
24
|
+
store={this.props.store}
|
|
25
|
+
/>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
render () {
|
|
30
|
+
const {
|
|
31
|
+
fileTransfers,
|
|
32
|
+
transferHistory,
|
|
33
|
+
transferTab,
|
|
34
|
+
handleTransferTab
|
|
35
|
+
} = this.props.store
|
|
36
|
+
if (!fileTransfers.length && !transferHistory.length) {
|
|
37
|
+
return null
|
|
38
|
+
}
|
|
39
|
+
const tabs = []
|
|
40
|
+
if (fileTransfers.length) {
|
|
41
|
+
tabs.push({
|
|
42
|
+
title: e('fileTransfers'),
|
|
43
|
+
id: 'transfer',
|
|
44
|
+
render: this.renderTransfer
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
if (transferHistory.length) {
|
|
48
|
+
tabs.push({
|
|
49
|
+
title: t('transferHistory'),
|
|
50
|
+
id: 'history',
|
|
51
|
+
render: this.renderHistory
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
const activeTab = tabs.map(d => d.id).includes(transferTab)
|
|
55
|
+
? transferTab
|
|
56
|
+
: tabs[0].id
|
|
57
|
+
const items = tabs.map(tab => {
|
|
58
|
+
return {
|
|
59
|
+
key: tab.id,
|
|
60
|
+
label: tab.title,
|
|
61
|
+
children: tab.render()
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
className='pd1'
|
|
67
|
+
>
|
|
68
|
+
<Tabs
|
|
69
|
+
activeKey={activeTab}
|
|
70
|
+
onChange={handleTransferTab}
|
|
71
|
+
items={items}
|
|
72
|
+
/>
|
|
73
|
+
</div>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* transporter UI component
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import Tag from '../sftp/transfer-tag'
|
|
6
|
+
import {
|
|
7
|
+
CloseCircleOutlined,
|
|
8
|
+
PlayCircleOutlined,
|
|
9
|
+
PauseCircleOutlined
|
|
10
|
+
} from '@ant-design/icons'
|
|
11
|
+
import {
|
|
12
|
+
transportTypes
|
|
13
|
+
} from '../sftp/transport-types'
|
|
14
|
+
import postMessage from '../../common/post-msg'
|
|
15
|
+
import './transfer.styl'
|
|
16
|
+
|
|
17
|
+
const { prefix } = window
|
|
18
|
+
const e = prefix('sftp')
|
|
19
|
+
|
|
20
|
+
export default function Transporter (props) {
|
|
21
|
+
const {
|
|
22
|
+
fromPath,
|
|
23
|
+
toPath,
|
|
24
|
+
fromPathReal,
|
|
25
|
+
toPathReal,
|
|
26
|
+
typeTo,
|
|
27
|
+
typeFrom,
|
|
28
|
+
percent,
|
|
29
|
+
speed,
|
|
30
|
+
pausing = false,
|
|
31
|
+
leftTime,
|
|
32
|
+
passedTime,
|
|
33
|
+
error,
|
|
34
|
+
inited,
|
|
35
|
+
id
|
|
36
|
+
} = props.transfer
|
|
37
|
+
function cancel () {
|
|
38
|
+
postMessage({
|
|
39
|
+
action: transportTypes.cancelTransport,
|
|
40
|
+
id
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
function handlePauseOrResume () {
|
|
44
|
+
postMessage({
|
|
45
|
+
action: transportTypes.pauseOrResumeTransfer,
|
|
46
|
+
id
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
const isTransfer = typeTo !== typeFrom
|
|
50
|
+
const Icon = !pausing ? PauseCircleOutlined : PlayCircleOutlined
|
|
51
|
+
const pauseTitle = pausing ? e('resume') : e('pause')
|
|
52
|
+
const cls = 'sftp-transport mg1b pd1x'
|
|
53
|
+
const typeFromTitle = e(typeFrom)
|
|
54
|
+
const typeToTitle = e(typeTo)
|
|
55
|
+
const title = `${typeFromTitle}→${typeToTitle}: ${fromPath} -> ${toPath} ${speed || ''} ${percent || 0}%`
|
|
56
|
+
const cancelIcon = (
|
|
57
|
+
<CloseCircleOutlined
|
|
58
|
+
className='transfer-control-icon pointer hover-black font14'
|
|
59
|
+
onClick={cancel}
|
|
60
|
+
title={e('cancel')}
|
|
61
|
+
/>
|
|
62
|
+
)
|
|
63
|
+
const controlIcon = isTransfer
|
|
64
|
+
? (
|
|
65
|
+
<Icon
|
|
66
|
+
className='flex-child transfer-control-icon pointer hover-black font14'
|
|
67
|
+
onClick={handlePauseOrResume}
|
|
68
|
+
title={pauseTitle}
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
71
|
+
: null
|
|
72
|
+
return (
|
|
73
|
+
<div className={cls} title={title} id={`transfer-unit-${id}`}>
|
|
74
|
+
<Tag
|
|
75
|
+
transfer={{
|
|
76
|
+
typeTo,
|
|
77
|
+
typeFrom,
|
|
78
|
+
error,
|
|
79
|
+
inited
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
82
|
+
<span
|
|
83
|
+
className='flex-child sftp-file sftp-local-file elli'
|
|
84
|
+
title={fromPath}
|
|
85
|
+
>{fromPathReal || fromPath}
|
|
86
|
+
</span>
|
|
87
|
+
<span className='flex-child sftp-transfer-arrow'>
|
|
88
|
+
→
|
|
89
|
+
</span>
|
|
90
|
+
<span
|
|
91
|
+
className='flex-child sftp-file sftp-remote-file elli'
|
|
92
|
+
>{toPathReal || toPath}
|
|
93
|
+
</span>
|
|
94
|
+
<span
|
|
95
|
+
className='flex-child sftp-file-percent'
|
|
96
|
+
>
|
|
97
|
+
{percent || 0}%
|
|
98
|
+
{speed ? `(${speed})` : null}
|
|
99
|
+
</span>
|
|
100
|
+
<span
|
|
101
|
+
className='flex-child sftp-file-percent'
|
|
102
|
+
>
|
|
103
|
+
{passedTime || '-'}|{leftTime || '-'}
|
|
104
|
+
</span>
|
|
105
|
+
{controlIcon}
|
|
106
|
+
{cancelIcon}
|
|
107
|
+
</div>
|
|
108
|
+
)
|
|
109
|
+
}
|