@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.
Files changed (273) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +31 -0
  3. package/client/common/auto-complete-data-mapper.js +6 -0
  4. package/client/common/byte-format.js +14 -0
  5. package/client/common/class.js +52 -0
  6. package/client/common/clipboard.js +49 -0
  7. package/client/common/constants.js +308 -0
  8. package/client/common/create-lang-edit-link.js +7 -0
  9. package/client/common/create-title.js +29 -0
  10. package/client/common/db-fix.js +24 -0
  11. package/client/common/db.js +155 -0
  12. package/client/common/download-mirrors.js +10 -0
  13. package/client/common/download.js +16 -0
  14. package/client/common/error-handler.jsx +27 -0
  15. package/client/common/fetch-from-server.js +47 -0
  16. package/client/common/fetch.jsx +71 -0
  17. package/client/common/find-bookmark-group-id.js +15 -0
  18. package/client/common/find-parent.js +30 -0
  19. package/client/common/form-layout.js +27 -0
  20. package/client/common/fs.js +21 -0
  21. package/client/common/get-proxy.js +8 -0
  22. package/client/common/id-with-stamp.js +10 -0
  23. package/client/common/index-sorter.js +4 -0
  24. package/client/common/init-setting-item.js +32 -0
  25. package/client/common/is-absolute-path.js +3 -0
  26. package/client/common/is-ip.js +16 -0
  27. package/client/common/is-valid-path.js +7 -0
  28. package/client/common/key-control-pressed.js +13 -0
  29. package/client/common/key-pressed.js +13 -0
  30. package/client/common/key-shift-pressed.js +7 -0
  31. package/client/common/mode2permission.js +81 -0
  32. package/client/common/new-terminal.js +31 -0
  33. package/client/common/parse-int10.js +3 -0
  34. package/client/common/parse-json-safe.js +11 -0
  35. package/client/common/pass-enc.js +25 -0
  36. package/client/common/post-msg.js +3 -0
  37. package/client/common/pre.js +156 -0
  38. package/client/common/promise-timeout.js +27 -0
  39. package/client/common/resolve.js +31 -0
  40. package/client/common/run-idle.js +1 -0
  41. package/client/common/safe-local-storage.js +35 -0
  42. package/client/common/safe-name.js +19 -0
  43. package/client/common/sftp.js +74 -0
  44. package/client/common/terminal-theme.js +158 -0
  45. package/client/common/test-connection.js +12 -0
  46. package/client/common/time.js +30 -0
  47. package/client/common/to-simple-obj.js +5 -0
  48. package/client/common/track.js +7 -0
  49. package/client/common/transfer.js +76 -0
  50. package/client/common/trzsz.js +62 -0
  51. package/client/common/ui-theme.js +44 -0
  52. package/client/common/uid.js +5 -0
  53. package/client/common/update-check.js +79 -0
  54. package/client/common/upgrade.js +68 -0
  55. package/client/common/wait.js +8 -0
  56. package/client/common/ws.js +161 -0
  57. package/client/components/batch-op/batch-op.jsx +650 -0
  58. package/client/components/bookmark-form/bookmark-form.styl +8 -0
  59. package/client/components/bookmark-form/bookmark-group-tree-format.js +39 -0
  60. package/client/components/bookmark-form/encodes.js +44 -0
  61. package/client/components/bookmark-form/form-ssh-common.jsx +208 -0
  62. package/client/components/bookmark-form/form-tabs.jsx +69 -0
  63. package/client/components/bookmark-form/index.jsx +159 -0
  64. package/client/components/bookmark-form/local-form-ui.jsx +152 -0
  65. package/client/components/bookmark-form/local-form.jsx +16 -0
  66. package/client/components/bookmark-form/proxy.jsx +49 -0
  67. package/client/components/bookmark-form/quick-command-list.jsx +31 -0
  68. package/client/components/bookmark-form/quick-command.jsx +228 -0
  69. package/client/components/bookmark-form/render-auth-ssh.jsx +104 -0
  70. package/client/components/bookmark-form/render-connection-hopping.jsx +229 -0
  71. package/client/components/bookmark-form/render-delayed-scripts.jsx +88 -0
  72. package/client/components/bookmark-form/render-ssh-tunnel.jsx +116 -0
  73. package/client/components/bookmark-form/serial-form-ui.jsx +311 -0
  74. package/client/components/bookmark-form/serial-form.jsx +20 -0
  75. package/client/components/bookmark-form/sftp-enable.jsx +33 -0
  76. package/client/components/bookmark-form/ssh-form-ui.jsx +100 -0
  77. package/client/components/bookmark-form/ssh-form.jsx +348 -0
  78. package/client/components/bookmark-form/telnet-form-ui.jsx +154 -0
  79. package/client/components/bookmark-form/telnet-form.jsx +16 -0
  80. package/client/components/bookmark-form/tree-delete.jsx +87 -0
  81. package/client/components/bookmark-form/use-form-funcs.jsx +50 -0
  82. package/client/components/bookmark-form/use-quick-commands.jsx +83 -0
  83. package/client/components/bookmark-form/use-submit.jsx +77 -0
  84. package/client/components/bookmark-form/use-ui.jsx +82 -0
  85. package/client/components/bookmark-form/x11.jsx +23 -0
  86. package/client/components/common/animate-text.jsx +37 -0
  87. package/client/components/common/animate-text.styl +54 -0
  88. package/client/components/common/external-link.jsx +28 -0
  89. package/client/components/common/help-icon.jsx +25 -0
  90. package/client/components/common/highlight.jsx +23 -0
  91. package/client/components/common/highlight.styl +3 -0
  92. package/client/components/common/input-auto-focus.jsx +68 -0
  93. package/client/components/common/input-confirm.jsx +66 -0
  94. package/client/components/common/logo-elem.jsx +22 -0
  95. package/client/components/common/markdown.jsx +27 -0
  96. package/client/components/common/react-subx.jsx +1 -0
  97. package/client/components/common/resize-wrap.jsx +222 -0
  98. package/client/components/common/resize-wrap.styl +9 -0
  99. package/client/components/common/search.jsx +9 -0
  100. package/client/components/common/show-item.jsx +27 -0
  101. package/client/components/context-menu/boomarks.jsx +15 -0
  102. package/client/components/context-menu/context-menu.jsx +340 -0
  103. package/client/components/context-menu/context-menu.styl +90 -0
  104. package/client/components/context-menu/history.jsx +27 -0
  105. package/client/components/context-menu/icon-holder.jsx +5 -0
  106. package/client/components/context-menu/menu-btn.jsx +224 -0
  107. package/client/components/context-menu/sub-tab-menu.jsx +23 -0
  108. package/client/components/context-menu/tabs.jsx +22 -0
  109. package/client/components/context-menu/zoom.jsx +40 -0
  110. package/client/components/footer/batch-input.jsx +177 -0
  111. package/client/components/footer/footer-entry.jsx +141 -0
  112. package/client/components/footer/footer.styl +47 -0
  113. package/client/components/icons/match-case.jsx +10 -0
  114. package/client/components/icons/match-whole-word.jsx +13 -0
  115. package/client/components/icons/regular-exp.jsx +10 -0
  116. package/client/components/main/css-overwrite.jsx +92 -0
  117. package/client/components/main/error-wrapper.jsx +59 -0
  118. package/client/components/main/index.jsx +11 -0
  119. package/client/components/main/loading.jsx +25 -0
  120. package/client/components/main/main.jsx +149 -0
  121. package/client/components/main/term-fullscreen-control.jsx +21 -0
  122. package/client/components/main/term-fullscreen.styl +27 -0
  123. package/client/components/main/ui-theme.jsx +31 -0
  124. package/client/components/main/upgrade.jsx +351 -0
  125. package/client/components/main/upgrade.styl +27 -0
  126. package/client/components/main/wrapper.styl +41 -0
  127. package/client/components/quick-commands/qm.styl +29 -0
  128. package/client/components/quick-commands/quick-command-item.jsx +36 -0
  129. package/client/components/quick-commands/quick-command-transport-mod.jsx +54 -0
  130. package/client/components/quick-commands/quick-command-transport.jsx +12 -0
  131. package/client/components/quick-commands/quick-commands-box.jsx +233 -0
  132. package/client/components/quick-commands/quick-commands-form-elem.jsx +119 -0
  133. package/client/components/quick-commands/quick-commands-form.jsx +33 -0
  134. package/client/components/quick-commands/quick-commands-list.jsx +128 -0
  135. package/client/components/quick-commands/quick-commands-select.jsx +38 -0
  136. package/client/components/session/session.jsx +533 -0
  137. package/client/components/session/session.styl +53 -0
  138. package/client/components/session/sessions.jsx +445 -0
  139. package/client/components/setting-panel/bookmark-transport.jsx +148 -0
  140. package/client/components/setting-panel/bookmark-tree-list.jsx +14 -0
  141. package/client/components/setting-panel/col.jsx +18 -0
  142. package/client/components/setting-panel/list.jsx +186 -0
  143. package/client/components/setting-panel/list.styl +33 -0
  144. package/client/components/setting-panel/on-tree-drop.js +222 -0
  145. package/client/components/setting-panel/setting-modal.jsx +163 -0
  146. package/client/components/setting-panel/setting-wrap.jsx +37 -0
  147. package/client/components/setting-panel/setting-wrap.styl +52 -0
  148. package/client/components/setting-panel/setting.jsx +858 -0
  149. package/client/components/setting-panel/setting.styl +4 -0
  150. package/client/components/setting-panel/start-session-select.jsx +91 -0
  151. package/client/components/setting-panel/tab-bookmarks.jsx +37 -0
  152. package/client/components/setting-panel/tab-history.jsx +44 -0
  153. package/client/components/setting-panel/tab-quick-commands.jsx +38 -0
  154. package/client/components/setting-panel/tab-settings.jsx +42 -0
  155. package/client/components/setting-panel/tab-themes.jsx +34 -0
  156. package/client/components/setting-panel/tree-list.jsx +978 -0
  157. package/client/components/setting-panel/tree-list.styl +57 -0
  158. package/client/components/setting-sync/data-import.jsx +65 -0
  159. package/client/components/setting-sync/setting-sync-form.jsx +271 -0
  160. package/client/components/setting-sync/setting-sync.jsx +81 -0
  161. package/client/components/setting-sync/sync.styl +7 -0
  162. package/client/components/sftp/address-bar.jsx +139 -0
  163. package/client/components/sftp/address-bookmark-item.jsx +47 -0
  164. package/client/components/sftp/address-bookmark.jsx +81 -0
  165. package/client/components/sftp/address-bookmark.styl +8 -0
  166. package/client/components/sftp/confirm-modal.jsx +184 -0
  167. package/client/components/sftp/file-icon.jsx +22 -0
  168. package/client/components/sftp/file-item.jsx +1226 -0
  169. package/client/components/sftp/file-mode-modal.jsx +205 -0
  170. package/client/components/sftp/file-props-modal.jsx +211 -0
  171. package/client/components/sftp/file-read.js +81 -0
  172. package/client/components/sftp/list-table-ui.jsx +547 -0
  173. package/client/components/sftp/owner-list.js +97 -0
  174. package/client/components/sftp/paged-list.jsx +60 -0
  175. package/client/components/sftp/permission-render.jsx +42 -0
  176. package/client/components/sftp/sftp-entry.jsx +1069 -0
  177. package/client/components/sftp/sftp.styl +217 -0
  178. package/client/components/sftp/transfer-common.js +9 -0
  179. package/client/components/sftp/transfer-conflict.jsx +315 -0
  180. package/client/components/sftp/transfer-speed-format.js +60 -0
  181. package/client/components/sftp/transfer-tag.jsx +40 -0
  182. package/client/components/sftp/transfer-tag.styl +11 -0
  183. package/client/components/sftp/transfer.styl +55 -0
  184. package/client/components/sftp/transport-action.jsx +410 -0
  185. package/client/components/sftp/transport-entry.jsx +108 -0
  186. package/client/components/sftp/transport-types.js +8 -0
  187. package/client/components/sftp/transports-action.jsx +111 -0
  188. package/client/components/sftp/transports-ui.jsx +93 -0
  189. package/client/components/sftp/zip.js +42 -0
  190. package/client/components/sidebar/bookmark-select.jsx +48 -0
  191. package/client/components/sidebar/bookmark.jsx +82 -0
  192. package/client/components/sidebar/history.jsx +66 -0
  193. package/client/components/sidebar/index.jsx +230 -0
  194. package/client/components/sidebar/info-modal.jsx +250 -0
  195. package/client/components/sidebar/info.styl +27 -0
  196. package/client/components/sidebar/side-icon.jsx +25 -0
  197. package/client/components/sidebar/sidebar.styl +128 -0
  198. package/client/components/sidebar/transfer-history-modal.jsx +110 -0
  199. package/client/components/sidebar/transfer-history.styl +3 -0
  200. package/client/components/sidebar/transfer-list-control.jsx +205 -0
  201. package/client/components/sidebar/transfer-list.jsx +55 -0
  202. package/client/components/sidebar/transfer-modal.jsx +76 -0
  203. package/client/components/sidebar/transfer.styl +8 -0
  204. package/client/components/sidebar/transport-ui.jsx +109 -0
  205. package/client/components/tabs/index.jsx +320 -0
  206. package/client/components/tabs/tab.jsx +427 -0
  207. package/client/components/tabs/tabs.styl +220 -0
  208. package/client/components/tabs/window-control.jsx +55 -0
  209. package/client/components/terminal/attach-addon-custom.js +70 -0
  210. package/client/components/terminal/build-ls-term-id.js +5 -0
  211. package/client/components/terminal/index.jsx +1358 -0
  212. package/client/components/terminal/normal-buffer.jsx +33 -0
  213. package/client/components/terminal/term-search.jsx +224 -0
  214. package/client/components/terminal/term-search.styl +15 -0
  215. package/client/components/terminal/terminal-apis.js +31 -0
  216. package/client/components/terminal/terminal-interactive.jsx +148 -0
  217. package/client/components/terminal/terminal.styl +96 -0
  218. package/client/components/terminal/xterm-zmodem.js +48 -0
  219. package/client/components/terminal/zmodem-transfer.jsx +98 -0
  220. package/client/components/terminal/zmodem.styl +14 -0
  221. package/client/components/terminal-info/activity.jsx +54 -0
  222. package/client/components/terminal-info/base.jsx +25 -0
  223. package/client/components/terminal-info/content.jsx +101 -0
  224. package/client/components/terminal-info/data-cols-parser.jsx +50 -0
  225. package/client/components/terminal-info/disk.jsx +29 -0
  226. package/client/components/terminal-info/index.jsx +25 -0
  227. package/client/components/terminal-info/network.jsx +114 -0
  228. package/client/components/terminal-info/resource.jsx +80 -0
  229. package/client/components/terminal-info/run-cmd.jsx +273 -0
  230. package/client/components/terminal-info/terminal-info.styl +29 -0
  231. package/client/components/terminal-info/up.jsx +15 -0
  232. package/client/components/terminal-theme/index.jsx +264 -0
  233. package/client/components/terminal-theme/terminal-theme-list.styl +3 -0
  234. package/client/components/terminal-theme/theme-list.jsx +146 -0
  235. package/client/components/text-editor/text-editor-form.jsx +97 -0
  236. package/client/components/text-editor/text-editor.jsx +182 -0
  237. package/client/css/antd-overwrite.styl +14 -0
  238. package/client/css/basic.styl +38 -0
  239. package/client/css/includes/box.styl +154 -0
  240. package/client/css/includes/font-size.styl +6 -0
  241. package/client/css/includes/index.styl +3 -0
  242. package/client/css/includes/text.styl +31 -0
  243. package/client/css/includes/theme-default.styl +20 -0
  244. package/client/entry/basic.js +58 -0
  245. package/client/entry/index.jsx +15 -0
  246. package/client/entry/worker.js +137 -0
  247. package/client/store/address-bookmark.js +25 -0
  248. package/client/store/app-upgrade.js +23 -0
  249. package/client/store/batch-input-history.js +26 -0
  250. package/client/store/bookmark-group.js +128 -0
  251. package/client/store/bookmark.js +22 -0
  252. package/client/store/common.js +140 -0
  253. package/client/store/context-menu.js +23 -0
  254. package/client/store/db-upgrade.js +43 -0
  255. package/client/store/event.js +70 -0
  256. package/client/store/index.js +335 -0
  257. package/client/store/init-state.js +191 -0
  258. package/client/store/item.js +120 -0
  259. package/client/store/load-data.js +198 -0
  260. package/client/store/quick-command.js +43 -0
  261. package/client/store/session.js +54 -0
  262. package/client/store/setting.js +208 -0
  263. package/client/store/sidebar.js +48 -0
  264. package/client/store/sync.js +390 -0
  265. package/client/store/system-menu.js +120 -0
  266. package/client/store/tab.js +74 -0
  267. package/client/store/terminal-theme.js +116 -0
  268. package/client/store/transfer-history.js +27 -0
  269. package/client/store/transfer-list.js +20 -0
  270. package/client/store/ui-theme.js +71 -0
  271. package/client/store/watch.js +116 -0
  272. package/client/views/index.pug +58 -0
  273. package/package.json +34 -0
@@ -0,0 +1,33 @@
1
+ /**
2
+ * when in alternate buffer, user press cmd + arrow up to open normal buffer content
3
+ */
4
+
5
+ import { CloseCircleOutlined } from '@ant-design/icons'
6
+ import { memo } from 'react'
7
+
8
+ export default memo(function NormalBuffer (props) {
9
+ if (!props.lines.length) {
10
+ return null
11
+ }
12
+ const pops = {
13
+ className: 'terminal-normal-buffer-close',
14
+ onClick: props.close
15
+ }
16
+ return (
17
+ <div className='terminal-normal-buffer'>
18
+ <div className='terminal-normal-buffer-body'>
19
+ {props.lines.map((d, i) => (<div key={`${i}-nmb`}>{d}</div>))}
20
+ </div>
21
+ <div className='terminal-normal-buffer-footer fix'>
22
+ <span className='fleft pd1l'>
23
+ Normal buffer content
24
+ </span>
25
+ <span className='fright pd1r'>
26
+ <CloseCircleOutlined
27
+ {...pops}
28
+ />
29
+ </span>
30
+ </div>
31
+ </div>
32
+ )
33
+ })
@@ -0,0 +1,224 @@
1
+ import { Component } from '../common/react-subx'
2
+ import {
3
+ Tooltip
4
+ } from 'antd'
5
+ import InputAutoFocus from '../common/input-auto-focus'
6
+ import {
7
+ ArrowLeftOutlined,
8
+ ArrowRightOutlined,
9
+ CloseCircleOutlined
10
+ } from '@ant-design/icons'
11
+ import { paneMap, terminalActions, isMac } from '../../common/constants'
12
+ import postMessage from '../../common/post-msg'
13
+ import { MatchCaseIcon } from '../icons/match-case'
14
+ import { MatchWholWordIcon } from '../icons/match-whole-word'
15
+ import { RegularExpIcon } from '../icons/regular-exp'
16
+ import classNames from 'classnames'
17
+ import copy from 'json-deep-copy'
18
+ import keyShiftPressed from '../../common/key-shift-pressed'
19
+ import keyControlPressed from '../../common/key-control-pressed'
20
+ import keyPressed from '../../common/key-pressed'
21
+ import './term-search.styl'
22
+
23
+ const { prefix } = window
24
+ const s = prefix('ssh')
25
+
26
+ export default class TermSearch extends Component {
27
+ searchControls = [{
28
+ id: 'matchCase',
29
+ icon: MatchCaseIcon,
30
+ prop: 'caseSensitive'
31
+ }, {
32
+ id: 'matchWholeWord',
33
+ icon: MatchWholWordIcon,
34
+ prop: 'wholeWord'
35
+ }, {
36
+ id: 'useRegExp',
37
+ icon: RegularExpIcon,
38
+ prop: 'regex'
39
+ }]
40
+
41
+ searchActions = [{
42
+ id: 'prev',
43
+ icon: ArrowLeftOutlined,
44
+ cls: 'mg1l'
45
+ }, {
46
+ id: 'next',
47
+ icon: ArrowRightOutlined,
48
+ cls: 'mg1l'
49
+ }, {
50
+ id: 'close',
51
+ icon: CloseCircleOutlined,
52
+ cls: 'mg2l'
53
+ }]
54
+
55
+ componentDidMount () {
56
+ window.addEventListener('keydown', this.handleEvent)
57
+ }
58
+
59
+ componentWillUnmount () {
60
+ window.removeEventListener('keydown', this.handleEvent)
61
+ }
62
+
63
+ toggleSearch = () => {
64
+ this.props.store.toggleTerminalSearch()
65
+ setTimeout(window.store.focus, 100)
66
+ }
67
+
68
+ handleEvent = (e) => {
69
+ if (
70
+ keyPressed(e, 'f') && keyControlPressed(e) &&
71
+ (
72
+ isMac ||
73
+ (!isMac && keyShiftPressed(e))
74
+ )
75
+ ) {
76
+ e.stopPropagation()
77
+ this.toggleSearch()
78
+ }
79
+ }
80
+
81
+ prev = () => {
82
+ const { activeTerminalId } = this.props.store
83
+ postMessage({
84
+ action: terminalActions.doSearchPrev,
85
+ keyword: this.props.store.termSearch,
86
+ activeSplitId: activeTerminalId,
87
+ options: copy(this.props.store.termSearchOptions)
88
+ })
89
+ }
90
+
91
+ next = () => {
92
+ const { activeTerminalId } = this.props.store
93
+ postMessage({
94
+ action: terminalActions.doSearchNext,
95
+ activeSplitId: activeTerminalId,
96
+ keyword: this.props.store.termSearch,
97
+ options: copy(this.props.store.termSearchOptions)
98
+ })
99
+ }
100
+
101
+ handleChange = e => {
102
+ this.props.store.termSearch = e.target.value
103
+ this.next()
104
+ }
105
+
106
+ close = () => {
107
+ this.props.store.termSearchOpen = false
108
+ }
109
+
110
+ renderSearchAction = item => {
111
+ const {
112
+ id,
113
+ icon: Icon,
114
+ cls
115
+ } = item
116
+ const props = {
117
+ onClick: this[id],
118
+ className: 'term-search-act mg1x ' + cls
119
+ }
120
+ return (
121
+ <Icon
122
+ key={id}
123
+ {...props}
124
+ />
125
+ )
126
+ }
127
+
128
+ renderMatchData = () => {
129
+ const {
130
+ termSearchMatchCount,
131
+ termSearchMatchIndex
132
+ } = this.props.store
133
+ if (!termSearchMatchCount) {
134
+ return null
135
+ }
136
+ return <span className='mg1x'>({termSearchMatchIndex + 1}/{termSearchMatchCount})</span>
137
+ }
138
+
139
+ renderAfter = () => {
140
+ return (
141
+ <div>
142
+ {
143
+ this.renderMatchData()
144
+ }
145
+ {
146
+ this.searchActions.map(this.renderSearchAction)
147
+ }
148
+ </div>
149
+ )
150
+ }
151
+
152
+ toggle = prop => {
153
+ const {
154
+ store
155
+ } = this.props
156
+ const v = store.termSearchOptions[prop]
157
+ store.setTermSearchOption({
158
+ [prop]: !v
159
+ })
160
+ this.next()
161
+ }
162
+
163
+ renderSearchControl = (item) => {
164
+ const {
165
+ id,
166
+ icon: Icon,
167
+ prop
168
+ } = item
169
+ const v = this.props.store.termSearchOptions[prop]
170
+ const cls = classNames('term-search-opt-icon', {
171
+ 'term-search-on': v
172
+ })
173
+ return (
174
+ <Tooltip
175
+ key={id}
176
+ title={s(id)}
177
+ >
178
+ <Icon
179
+ className={cls}
180
+ onClick={() => this.toggle(prop)}
181
+ />
182
+ </Tooltip>
183
+ )
184
+ }
185
+
186
+ renderSuffix = () => {
187
+ return (
188
+ <div>
189
+ {
190
+ this.searchControls.map(this.renderSearchControl)
191
+ }
192
+ </div>
193
+ )
194
+ }
195
+
196
+ render () {
197
+ const { store, currentTab } = this.props
198
+ const {
199
+ termSearchOpen,
200
+ termSearch
201
+ } = store
202
+ if (!termSearchOpen) {
203
+ return null
204
+ }
205
+ if (currentTab.pane === paneMap.fileManager) {
206
+ return null
207
+ }
208
+ const props = {
209
+ value: termSearch,
210
+ className: 'iblock',
211
+ onChange: this.handleChange,
212
+ suffix: this.renderSuffix(),
213
+ onPressEnter: this.next,
214
+ addonAfter: this.renderAfter()
215
+ }
216
+ return (
217
+ <div className='term-search-wrap'>
218
+ <InputAutoFocus
219
+ {...props}
220
+ />
221
+ </div>
222
+ )
223
+ }
224
+ }
@@ -0,0 +1,15 @@
1
+ @require '../../css/includes/theme-default'
2
+ .term-search-opt-icon
3
+ margin 0 3px
4
+ color text-light
5
+ font-size 15px
6
+ &:hover
7
+ color text
8
+ &.term-search-on
9
+ background #333
10
+ color #aaa
11
+ .term-search-wrap
12
+ position absolute
13
+ top 100px
14
+ right 5px
15
+ z-index 200
@@ -0,0 +1,31 @@
1
+ /**
2
+ * terminal apis
3
+ */
4
+
5
+ import fetch from '../../common/fetch-from-server'
6
+
7
+ export function createTerm (body) {
8
+ return fetch({
9
+ body,
10
+ action: 'create-terminal'
11
+ })
12
+ }
13
+
14
+ export function runCmd (pid, sessionId, cmd) {
15
+ return fetch({
16
+ pid,
17
+ sessionId,
18
+ cmd,
19
+ action: 'run-cmd'
20
+ })
21
+ }
22
+
23
+ export function resizeTerm (pid, sessionId, cols, rows) {
24
+ return fetch({
25
+ pid,
26
+ sessionId,
27
+ cols,
28
+ rows,
29
+ action: 'resize-terminal'
30
+ })
31
+ }
@@ -0,0 +1,148 @@
1
+ /**
2
+ * handle terminal interactive operation
3
+ */
4
+
5
+ import { useEffect, useState } from 'react'
6
+ import { Modal, Form, Button } from 'antd'
7
+ import InputAutoFocus from '../common/input-auto-focus'
8
+ import wait from '../../common/wait'
9
+
10
+ const { prefix } = window
11
+ const e = prefix('sftp')
12
+ const c = prefix('common')
13
+ const FormItem = Form.Item
14
+
15
+ export default function TermInteractive () {
16
+ const [trigger] = useState(0)
17
+ const [opts, setter] = useState(null)
18
+ const [form] = Form.useForm()
19
+ function onMsg (e) {
20
+ if (e.data.includes('session-interactive')) {
21
+ setter(JSON.parse(e.data))
22
+ }
23
+ }
24
+ function clear () {
25
+ setter(null)
26
+ form.resetFields()
27
+ }
28
+ function onCancel () {
29
+ window.et.commonWs.s({
30
+ id: opts.id,
31
+ results: []
32
+ })
33
+ clear()
34
+ }
35
+ function onOk () {
36
+ form.submit()
37
+ }
38
+ function onIgnore () {
39
+ window.et.commonWs.s({
40
+ id: opts.id,
41
+ results: Object.keys(opts.options.prompts).map(() => '')
42
+ })
43
+ clear()
44
+ }
45
+ function onFinish (res) {
46
+ window.et.commonWs.s({
47
+ id: opts.id,
48
+ results: Object.values(res)
49
+ })
50
+ clear()
51
+ }
52
+ function renderFormItem (pro, i) {
53
+ const {
54
+ prompt,
55
+ echo
56
+ } = pro
57
+ const note = (opts.options.instructions || [])[i]
58
+ const type = echo
59
+ ? 'input'
60
+ : 'password'
61
+ return (
62
+ <FormItem
63
+ key={prompt + i}
64
+ label={prompt}
65
+ rules={[{
66
+ required: true, message: 'required'
67
+ }]}
68
+ >
69
+ <div>
70
+ <pre>{note}</pre>
71
+ </div>
72
+ <FormItem noStyle name={'item' + i}>
73
+ <InputAutoFocus
74
+ type={type}
75
+ autofocustrigger={trigger}
76
+ placeholder={note}
77
+ />
78
+ </FormItem>
79
+ </FormItem>
80
+ )
81
+ }
82
+ async function initWatch () {
83
+ let done = false
84
+ while (!done) {
85
+ if (window.et.commonWs) {
86
+ window.et.commonWs.addEventListener('message', onMsg)
87
+ done = true
88
+ } else {
89
+ await wait(400)
90
+ }
91
+ }
92
+ }
93
+ function init () {
94
+ initWatch()
95
+ }
96
+ useEffect(() => {
97
+ init()
98
+ }, [])
99
+ if (!opts) {
100
+ return null
101
+ }
102
+ const props = {
103
+ maskClosable: false,
104
+ okText: e('submit'),
105
+ onCancel,
106
+ onOk,
107
+ closable: false,
108
+ open: true,
109
+ title: opts.options?.name || '?',
110
+ footer: null
111
+ }
112
+ return (
113
+ <Modal
114
+ {...props}
115
+ >
116
+ <Form
117
+ form={form}
118
+ layout='vertical'
119
+ onFinish={onFinish}
120
+ >
121
+ {
122
+ opts.options.prompts.map(renderFormItem)
123
+ }
124
+ <FormItem>
125
+ <Button
126
+ type='primary'
127
+ htmlType='submit'
128
+ >
129
+ {e('submit')}
130
+ </Button>
131
+ <Button
132
+ type='dashed'
133
+ className='mg1l'
134
+ onClick={onIgnore}
135
+ >
136
+ {c('ignore')}
137
+ </Button>
138
+ <Button
139
+ className='mg1l'
140
+ onClick={onCancel}
141
+ >
142
+ {e('cancel')}
143
+ </Button>
144
+ </FormItem>
145
+ </Form>
146
+ </Modal>
147
+ )
148
+ }
@@ -0,0 +1,96 @@
1
+ @require '../../css/includes/theme-default'
2
+ .terms-box
3
+ .term-wrap
4
+ background main
5
+ position relative
6
+ .loading-wrapper
7
+ padding 30px
8
+ z-index 100
9
+ // .ant-spin
10
+ // color #fff
11
+ // background #000
12
+ // .ant-spin-blur
13
+ // opacity 0
14
+ .term-search-box
15
+ position absolute
16
+ right 5px
17
+ top 5px
18
+ z-index 30
19
+ // .term-sftp-box
20
+ // .ant-tabs-bar
21
+ // margin-bottom 0
22
+ // .ant-tabs-tab
23
+ // color #999
24
+ // .ant-tabs-tab-active
25
+ // color #fff
26
+ // .ant-tabs-nav-wrap
27
+ // background #333
28
+ .terminal-control
29
+ background main
30
+ line-height 32px
31
+ padding 0 10px
32
+ // .fileManager
33
+ // .terminal-control
34
+ // background main-dark
35
+ // .type-tab
36
+ // color text
37
+ // &:hover
38
+ // &.active
39
+ // color text-dark
40
+ // &.active
41
+ // border-bottom 1px solid text-dark
42
+
43
+ .terms-box
44
+ position relative
45
+ .term-wrap
46
+ position absolute
47
+
48
+ .vertical
49
+ .term-wrap.not-first-term
50
+ border-top 1px solid main-light
51
+ .horizontal
52
+ .term-wrap.not-first-term
53
+ border-left 1px solid main-light
54
+ .term-sftp-tabs
55
+ margin-left 5px
56
+
57
+ #container
58
+ .xterm-viewport
59
+ // background-color transparent !important
60
+ // background-image url("./images/electerm-watermark.")
61
+ background-repeat no-repeat
62
+ background-position 50% 50%
63
+
64
+ .terminal-not-active .xterm-text-layer
65
+ opacity .74
66
+
67
+ .terminal-normal-buffer
68
+ position absolute
69
+ left 0
70
+ top 0
71
+ width 100%
72
+ background main
73
+ color text
74
+ box-shadow 0px 3px 3px 0px alpha(text, .25)
75
+ z-index 66
76
+ padding-bottom 32px
77
+ .terminal-normal-buffer-body
78
+ overflow-y scroll
79
+ max-height 300px
80
+ .terminal-normal-buffer-close
81
+ cursor pointer
82
+ font-size 14px
83
+ color text
84
+ &:hover
85
+ color text-light
86
+ .terminal-normal-buffer-footer
87
+ position absolute
88
+ left 0
89
+ top calc(100% - 32px)
90
+ width 100%
91
+ height 32px
92
+ line-height 32px
93
+ box-shadow 0px -3px 3px 0px alpha(text, .25)
94
+ background main-light
95
+ .batch-input-wrap
96
+ width calc(100% - 80px)
@@ -0,0 +1,48 @@
1
+ import zmodem from 'zmodem.js/src/zmodem_browser'
2
+
3
+ function zmodemAttach (ws, opts, ctx) {
4
+ if (opts === undefined) { opts = {} }
5
+ const term = this
6
+ const senderFunc = function (octets) { return ws.send(new Uint8Array(octets)) }
7
+ let zsentry = null
8
+ function shouldWrite () {
9
+ return !!zsentry.get_confirmed_session() || !opts.noTerminalWriteOutsideSession
10
+ }
11
+ zsentry = new zmodem.Sentry({
12
+ to_terminal: function (octets) {
13
+ if (shouldWrite()) {
14
+ term.write(String.fromCharCode.apply(String, octets))
15
+ }
16
+ },
17
+ sender: senderFunc,
18
+ on_retract: ctx.onzmodemRetract,
19
+ on_detect: ctx.onZmodemDetect
20
+ })
21
+ function handleWSMessage (evt) {
22
+ if (typeof evt.data === 'string') {
23
+ if (shouldWrite()) {
24
+ term.write(evt.data)
25
+ }
26
+ } else {
27
+ zsentry.consume(evt.data)
28
+ }
29
+ }
30
+ ws.binaryType = 'arraybuffer'
31
+ ws.addEventListener('message', handleWSMessage)
32
+ }
33
+
34
+ export class AddonZmodem {
35
+ _disposables = []
36
+
37
+ activate (terminal) {
38
+ terminal.zmodemAttach = zmodemAttach
39
+ terminal.zmodemBrowser = zmodem.Browser
40
+ }
41
+
42
+ dispose () {
43
+ this._disposables.forEach(d => d.dispose())
44
+ this._disposables.length = 0
45
+ }
46
+ }
47
+
48
+ export const Zmodem = zmodem
@@ -0,0 +1,98 @@
1
+ /**
2
+ * zmodem transfer UI module
3
+ * then run rz to send from your browser or
4
+ * sz <file> to send from the remote peer.
5
+ */
6
+
7
+ import { memo } from 'react'
8
+ import { Progress, Button, Upload, Tag } from 'antd'
9
+ import { transferTypeMap } from '../../common/constants'
10
+ import Link from '../common/external-link'
11
+ import './zmodem.styl'
12
+
13
+ const { prefix } = window
14
+ const s = prefix('sftp')
15
+ const c = prefix('common')
16
+
17
+ export default memo((props) => {
18
+ const { zmodemTransfer, cancelZmodem, beforeZmodemUpload } = props
19
+ if (!zmodemTransfer) {
20
+ return null
21
+ }
22
+ const {
23
+ fileInfo,
24
+ type,
25
+ transferedSize,
26
+ percent
27
+ // options
28
+ } = zmodemTransfer
29
+ let btn = null
30
+ let progress = null
31
+ const recm = (
32
+ <Tag color='success'>
33
+ <div className='pd1y'>
34
+ <b className='mg1r'>Recommend Use trzsz instead:</b>
35
+ <Link to='https://github.com/trzsz/trzsz'>https://github.com/trzsz/trzsz</Link>
36
+ </div>
37
+ </Tag>
38
+ )
39
+ const cancelBtn = (
40
+ <Button
41
+ type='danger'
42
+ className='iblock mg2l'
43
+ onClick={cancelZmodem}
44
+ >{c('cancel')}
45
+ </Button>
46
+ )
47
+ if (type === transferTypeMap.upload) {
48
+ btn = (
49
+ <div className={fileInfo ? 'hide' : 'mg2b'}>
50
+ <div className='iblock'>
51
+ <Upload
52
+ showUploadList={false}
53
+ beforeUpload={beforeZmodemUpload}
54
+ className={fileInfo ? 'hide' : 'iblock'}
55
+ >
56
+ <Button>
57
+ {s(type)}
58
+ </Button>
59
+ </Upload>
60
+ </div>
61
+ {cancelBtn}
62
+ </div>
63
+ )
64
+ }
65
+ if (fileInfo) {
66
+ const {
67
+ size,
68
+ name
69
+ } = fileInfo
70
+ progress = (
71
+ <div className='pd1b'>
72
+ <Progress
73
+ percent={percent}
74
+ size='small'
75
+ status='active'
76
+ format={() => {
77
+ return `%${percent}(${transferedSize}/${size})`
78
+ }}
79
+ />
80
+ <h2 className='pd2y'>
81
+ <span className='iblock'>
82
+ {s(type)}: {name}
83
+ </span>
84
+ </h2>
85
+ <h4 className='pd2t pd2x'>Upload file(❯1M) may not show progress and may not end properly, but still would finish uploading in background.</h4>
86
+ </div>
87
+ )
88
+ }
89
+ return (
90
+ <div className='zmodem-transfer'>
91
+ <div className='zmodem-transfer-inner'>
92
+ {btn}
93
+ {progress}
94
+ {recm}
95
+ </div>
96
+ </div>
97
+ )
98
+ })
@@ -0,0 +1,14 @@
1
+ @require '../../css/includes/theme-default'
2
+ .zmodem-transfer
3
+ position absolute
4
+ left 0
5
+ right 0
6
+ height 100%
7
+ width 100%
8
+ background alpha(main-dark, .95)
9
+ display flex
10
+ flex-direction column
11
+ align-items center
12
+ justify-content center
13
+ z-index 20
14
+ padding 20px 180px 20px 20px