@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,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* simulate download
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export default function download (filename, text) {
|
|
6
|
+
const pom = document.createElement('a')
|
|
7
|
+
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text))
|
|
8
|
+
pom.setAttribute('download', filename)
|
|
9
|
+
if (document.createEvent) {
|
|
10
|
+
const event = document.createEvent('MouseEvents')
|
|
11
|
+
event.initEvent('click', true, true)
|
|
12
|
+
pom.dispatchEvent(event)
|
|
13
|
+
} else {
|
|
14
|
+
pom.click()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* common error handler
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { notification } from 'antd'
|
|
6
|
+
|
|
7
|
+
export default (e) => {
|
|
8
|
+
const { message = 'error', stack } = e
|
|
9
|
+
log.error(e)
|
|
10
|
+
const msg = (
|
|
11
|
+
<div className='mw240 elli wordbreak' title={message}>
|
|
12
|
+
{message}
|
|
13
|
+
</div>
|
|
14
|
+
)
|
|
15
|
+
const description = (
|
|
16
|
+
<div
|
|
17
|
+
className='mw300 elli common-err-desc wordbreak'
|
|
18
|
+
>
|
|
19
|
+
{stack}
|
|
20
|
+
</div>
|
|
21
|
+
)
|
|
22
|
+
notification.error({
|
|
23
|
+
message: msg,
|
|
24
|
+
description,
|
|
25
|
+
duration: 55
|
|
26
|
+
})
|
|
27
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fetch from server
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import initWs from './ws'
|
|
6
|
+
import generate from './uid'
|
|
7
|
+
import { NewPromise } from './promise-timeout'
|
|
8
|
+
|
|
9
|
+
const id = 's'
|
|
10
|
+
window.et.wsOpened = false
|
|
11
|
+
|
|
12
|
+
export const initWsCommon = async () => {
|
|
13
|
+
if (window.et.wsOpened) {
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
const ws = await initWs('common', id, undefined, undefined, true)
|
|
17
|
+
window.et.wsOpened = true
|
|
18
|
+
ws.onclose = () => {
|
|
19
|
+
window.et.wsOpened = false
|
|
20
|
+
}
|
|
21
|
+
window.et.commonWs = ws
|
|
22
|
+
window.store.wsInited = true
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
window.pre.ipcOnEvent('power-resume', initWsCommon)
|
|
26
|
+
|
|
27
|
+
const wsFetch = async (data) => {
|
|
28
|
+
if (!window.et.wsOpened) {
|
|
29
|
+
await initWsCommon()
|
|
30
|
+
}
|
|
31
|
+
const id = generate()
|
|
32
|
+
return new NewPromise((resolve, reject) => {
|
|
33
|
+
window.et.commonWs.once((arg) => {
|
|
34
|
+
if (arg.error) {
|
|
35
|
+
log.error('fetch error', arg.error)
|
|
36
|
+
return reject(new Error(arg.error.message))
|
|
37
|
+
}
|
|
38
|
+
resolve(arg.data)
|
|
39
|
+
}, id)
|
|
40
|
+
window.et.commonWs.s({
|
|
41
|
+
id,
|
|
42
|
+
...data
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
window.wsFetch = wsFetch
|
|
47
|
+
export default wsFetch
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// the final fetch wrapper
|
|
2
|
+
import { isString, isFunction } from 'lodash-es'
|
|
3
|
+
import { notification } from 'antd'
|
|
4
|
+
|
|
5
|
+
function jsonHeader () {
|
|
6
|
+
return {
|
|
7
|
+
Accept: 'application/json',
|
|
8
|
+
'Content-Type': 'application/json',
|
|
9
|
+
token: window.store?.config.tokenElecterm
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function parseResponse (response) {
|
|
14
|
+
const contentType = response.headers.get('content-type') || ''
|
|
15
|
+
const isJsonResult = contentType.toLowerCase().includes('application/json')
|
|
16
|
+
return isJsonResult ? response.json() : response.text()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function handleErr (res) {
|
|
20
|
+
log.debug(res)
|
|
21
|
+
let text = res.message || res.statusText
|
|
22
|
+
if (!isString(text)) {
|
|
23
|
+
try {
|
|
24
|
+
text = isFunction(res.text)
|
|
25
|
+
? await res.text()
|
|
26
|
+
: isFunction(res.json) ? await res.json() : ''
|
|
27
|
+
} catch (e) {
|
|
28
|
+
log.error('fetch response parse fails', e)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
log.debug(text, 'fetch err info')
|
|
32
|
+
notification.error({
|
|
33
|
+
message: 'error',
|
|
34
|
+
description: (
|
|
35
|
+
<div className='common-err'>
|
|
36
|
+
{text}
|
|
37
|
+
</div>
|
|
38
|
+
),
|
|
39
|
+
duration: 55
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default class Fetch {
|
|
44
|
+
static get (url, data, options) {
|
|
45
|
+
return Fetch.connect(url, 'get', null, options)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static post (url, data, options) {
|
|
49
|
+
return Fetch.connect(url, 'post', data, options)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static connect (url, method, data, options = {}) {
|
|
53
|
+
const body = {
|
|
54
|
+
method,
|
|
55
|
+
body: data
|
|
56
|
+
? JSON.stringify(data)
|
|
57
|
+
: undefined,
|
|
58
|
+
headers: jsonHeader(),
|
|
59
|
+
timeout: 180000,
|
|
60
|
+
...options
|
|
61
|
+
}
|
|
62
|
+
return window.fetch(url, body)
|
|
63
|
+
.then(res => {
|
|
64
|
+
if (res.status > 304) {
|
|
65
|
+
throw res
|
|
66
|
+
}
|
|
67
|
+
return res
|
|
68
|
+
})
|
|
69
|
+
.then(options.handleResponse || parseResponse, options.handleErr || handleErr)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* find bookmark group id for bookmark id
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
defaultBookmarkGroupId
|
|
7
|
+
} from './constants'
|
|
8
|
+
import { find } from 'lodash-es'
|
|
9
|
+
|
|
10
|
+
export default (bookmarkGroups, id) => {
|
|
11
|
+
const obj = find(bookmarkGroups, bg => {
|
|
12
|
+
return bg.bookmarkIds.includes(id)
|
|
13
|
+
})
|
|
14
|
+
return obj ? obj.id : defaultBookmarkGroupId
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* find the target parentNode
|
|
3
|
+
* @param {Node} node
|
|
4
|
+
* @param {String} className
|
|
5
|
+
* @return {Boolean}
|
|
6
|
+
*/
|
|
7
|
+
export default function findParentBySel (node, sel) {
|
|
8
|
+
if (!node) {
|
|
9
|
+
return false
|
|
10
|
+
}
|
|
11
|
+
let parent = node
|
|
12
|
+
if (!parent || !parent.matches) {
|
|
13
|
+
return false
|
|
14
|
+
}
|
|
15
|
+
if (parent.matches(sel)) {
|
|
16
|
+
return parent
|
|
17
|
+
}
|
|
18
|
+
let res = false
|
|
19
|
+
while (parent !== document.body) {
|
|
20
|
+
parent = parent.parentNode
|
|
21
|
+
if (!parent || !parent.matches) {
|
|
22
|
+
break
|
|
23
|
+
}
|
|
24
|
+
if (parent.matches(sel)) {
|
|
25
|
+
res = parent
|
|
26
|
+
break
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return res
|
|
30
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* form layout
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export const formItemLayout = {
|
|
6
|
+
labelCol: {
|
|
7
|
+
xs: { span: 24 },
|
|
8
|
+
sm: { span: 8 }
|
|
9
|
+
},
|
|
10
|
+
wrapperCol: {
|
|
11
|
+
xs: { span: 24 },
|
|
12
|
+
sm: { span: 16 }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const tailFormItemLayout = {
|
|
17
|
+
wrapperCol: {
|
|
18
|
+
xs: {
|
|
19
|
+
span: 24,
|
|
20
|
+
offset: 0
|
|
21
|
+
},
|
|
22
|
+
sm: {
|
|
23
|
+
span: 14,
|
|
24
|
+
offset: 8
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fs through ws
|
|
3
|
+
*/
|
|
4
|
+
import fetch from './fetch-from-server'
|
|
5
|
+
|
|
6
|
+
const fsFunctions = typeof window.pre.fsFunctions === 'undefined' ? window.et.fsFunctions : window.pre.fsFunctions
|
|
7
|
+
|
|
8
|
+
const fs = fsFunctions.reduce((prev, func) => {
|
|
9
|
+
prev[func] = (...args) => {
|
|
10
|
+
return fetch({
|
|
11
|
+
action: 'fs',
|
|
12
|
+
args,
|
|
13
|
+
func
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
return prev
|
|
17
|
+
}, {})
|
|
18
|
+
|
|
19
|
+
window.fs = fs
|
|
20
|
+
|
|
21
|
+
export default fs
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* get init setting item
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
settingMap,
|
|
7
|
+
newBookmarkIdPrefix,
|
|
8
|
+
settingCommonId
|
|
9
|
+
} from './constants'
|
|
10
|
+
import { buildNewTheme } from '../common/terminal-theme'
|
|
11
|
+
|
|
12
|
+
const { prefix } = window
|
|
13
|
+
const e = prefix('control')
|
|
14
|
+
const newQuickCommand = 'newQuickCommand'
|
|
15
|
+
const q = prefix('quickCommands')
|
|
16
|
+
|
|
17
|
+
export default (arr, tab) => {
|
|
18
|
+
if (tab === settingMap.history) {
|
|
19
|
+
return arr[0] || {}
|
|
20
|
+
} else if (tab === settingMap.bookmarks) {
|
|
21
|
+
return { id: newBookmarkIdPrefix + ':' + (Date.now()), title: '' }
|
|
22
|
+
} else if (tab === settingMap.setting) {
|
|
23
|
+
return { id: settingCommonId, title: e('common') }
|
|
24
|
+
} else if (tab === settingMap.terminalThemes) {
|
|
25
|
+
return buildNewTheme()
|
|
26
|
+
} else if (tab === settingMap.quickCommands) {
|
|
27
|
+
return {
|
|
28
|
+
id: '',
|
|
29
|
+
name: q(newQuickCommand)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function isValidIP (input) {
|
|
2
|
+
// Check IPv4 format
|
|
3
|
+
const ipv4Pattern = /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
|
|
4
|
+
if (ipv4Pattern.test(input)) {
|
|
5
|
+
return true
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Check IPv6 format
|
|
9
|
+
const ipv6Pattern = /^([\da-f]{1,4}:){7}[\da-f]{1,4}$/i
|
|
10
|
+
if (ipv6Pattern.test(input)) {
|
|
11
|
+
return true
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// If input doesn't match IPv4 or IPv6 patterns, it's not a valid IP
|
|
15
|
+
return false
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* check if given key is pressed
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export default (e, key, type) => {
|
|
6
|
+
const keyPressed = 'key' in e
|
|
7
|
+
? e.key.toLowerCase() === key.toLowerCase()
|
|
8
|
+
: false
|
|
9
|
+
const typeMatch = type
|
|
10
|
+
? e.type === type
|
|
11
|
+
: true
|
|
12
|
+
return typeMatch && keyPressed
|
|
13
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* convert mode / permission converter
|
|
3
|
+
* (33188).toString(8) => 100644
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* digit to permission
|
|
8
|
+
* @param {string} _d
|
|
9
|
+
* @return {object} {read: Boolean, write: Boolean, exec: Boolean}
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import parseInt10 from './parse-int10'
|
|
13
|
+
|
|
14
|
+
function digit2permission (_d) {
|
|
15
|
+
const d = parseInt10(_d)
|
|
16
|
+
const arr = d.toString(2).split('')
|
|
17
|
+
const len = arr.length
|
|
18
|
+
for (let a = len - 3, i = 0; i < a; i++) {
|
|
19
|
+
arr.unshift('0')
|
|
20
|
+
}
|
|
21
|
+
const [rr, ww, xx] = arr
|
|
22
|
+
const read = rr === '1'
|
|
23
|
+
const write = ww === '1'
|
|
24
|
+
const exec = xx === '1'
|
|
25
|
+
return {
|
|
26
|
+
read,
|
|
27
|
+
write,
|
|
28
|
+
exec
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* permission to digit
|
|
34
|
+
* @param {object} {read: Boolean, write: Boolean, exec: Boolean}
|
|
35
|
+
* @return {string}
|
|
36
|
+
*/
|
|
37
|
+
function permission2digit ({
|
|
38
|
+
read,
|
|
39
|
+
write,
|
|
40
|
+
exec
|
|
41
|
+
}) {
|
|
42
|
+
const arr = [
|
|
43
|
+
read ? '1' : '0',
|
|
44
|
+
write ? '1' : '0',
|
|
45
|
+
exec ? '1' : '0'
|
|
46
|
+
]
|
|
47
|
+
return Number('0b' + arr.join('')).toString()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* mode to permission
|
|
52
|
+
* @param {number} mode
|
|
53
|
+
* @return {array}
|
|
54
|
+
*/
|
|
55
|
+
export function mode2permission (mode) {
|
|
56
|
+
const str = mode.toString(8)
|
|
57
|
+
const len = str.length
|
|
58
|
+
const perms = str.slice(len - 3, len).split('')
|
|
59
|
+
const permNames = [
|
|
60
|
+
'owner',
|
|
61
|
+
'group',
|
|
62
|
+
'other'
|
|
63
|
+
]
|
|
64
|
+
return permNames.map((name, i) => {
|
|
65
|
+
return {
|
|
66
|
+
name,
|
|
67
|
+
permission: digit2permission(perms[i])
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* permission to mode
|
|
74
|
+
* @param {array} arr
|
|
75
|
+
* @return {string} eg, '644'
|
|
76
|
+
*/
|
|
77
|
+
export function permission2mode (arr) {
|
|
78
|
+
return arr.reduce((prev, { permission }) => {
|
|
79
|
+
return prev + permission2digit(permission)
|
|
80
|
+
}, '')
|
|
81
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* output default new terminal data obj
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import generate from './uid'
|
|
6
|
+
import {
|
|
7
|
+
paneMap
|
|
8
|
+
} from './constants'
|
|
9
|
+
|
|
10
|
+
const { prefix } = window
|
|
11
|
+
const e = prefix('control')
|
|
12
|
+
window.et.tabCount = 0
|
|
13
|
+
|
|
14
|
+
export function updateCount (tab) {
|
|
15
|
+
tab.tabCount = window.et.tabCount
|
|
16
|
+
window.et.tabCount++
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default (removeTitle) => {
|
|
20
|
+
const res = {
|
|
21
|
+
id: generate(),
|
|
22
|
+
status: 'processing',
|
|
23
|
+
pane: paneMap.terminal,
|
|
24
|
+
title: e('newTerminal')
|
|
25
|
+
}
|
|
26
|
+
if (removeTitle) {
|
|
27
|
+
delete res.title
|
|
28
|
+
}
|
|
29
|
+
updateCount(res)
|
|
30
|
+
return res
|
|
31
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { enc, dec } from '../../app/common/pass-enc'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* enc password
|
|
5
|
+
* @param {object} obj
|
|
6
|
+
*/
|
|
7
|
+
export function encObj (obj) {
|
|
8
|
+
if (!obj.passwordEncrypted && obj.password) {
|
|
9
|
+
obj.password = enc(obj.password)
|
|
10
|
+
obj.passwordEncrypted = true
|
|
11
|
+
}
|
|
12
|
+
return obj
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* dec password
|
|
17
|
+
* @param {object} obj
|
|
18
|
+
*/
|
|
19
|
+
export function decObj (obj) {
|
|
20
|
+
if (obj.passwordEncrypted && obj.password) {
|
|
21
|
+
obj.password = dec(obj.password)
|
|
22
|
+
delete obj.passwordEncrypted
|
|
23
|
+
}
|
|
24
|
+
return obj
|
|
25
|
+
}
|