Terminal: add file upload to /tmp
This commit is contained in:
@@ -18,15 +18,26 @@
|
||||
<Button severity="success" style="margin-right: 5px;" @click="terminalInject('mongodb')" v-show="usesAddon('mongodb')" :disabled="!connected" label="MongoDB"/>
|
||||
<Button severity="success" style="margin-right: 5px;" @click="terminalInject('redis')" v-show="usesAddon('redis')" :disabled="!connected" label="Redis"/>
|
||||
|
||||
<a style="margin-right: 5px;" :href="'/frontend/logs.html?appId=' + id" target="_blank"><Button severity="primary" icon="pi pi-align-left" :label="$t('logs.title')" /></a>
|
||||
<a style="margin-right: 5px;" :href="'/frontend/filemanager.html#/home/app/' + id" target="_blank"><Button severity="primary" type="button" icon="pi pi-folder" :label="$t('filemanager.title')" /></a>
|
||||
<Button severity="primary" type="button" :label="$t('filemanager.toolbar.restartApp')" icon="pi pi-sync" @click="onRestartApp" :loading="busyRestart"/>
|
||||
<!-- upload/download actions -->
|
||||
<Button severity="primary" style="margin-right: 5px;" :disabled="!connected" @click="onUpload" icon="pi pi-upload" :label="$t('terminal.uploadToTmp')"/>
|
||||
<Button severity="primary" style="margin-right: 5px;" :disabled="!connected" @click="onDownload" icon="pi pi-download" :label="$t('terminal.downloadAction')"/>
|
||||
|
||||
<a style="margin-right: 5px;" :href="'/frontend/logs.html?appId=' + id" target="_blank"><Button severity="secondary" icon="pi pi-align-left" :label="$t('logs.title')" /></a>
|
||||
<a style="margin-right: 5px;" :href="'/frontend/filemanager.html#/home/app/' + id" target="_blank"><Button severity="secondary" type="button" icon="pi pi-folder" :label="$t('filemanager.title')" /></a>
|
||||
<Button severity="secondary" type="button" :label="$t('filemanager.toolbar.restartApp')" icon="pi pi-sync" @click="onRestartApp" :loading="busyRestart"/>
|
||||
</template>
|
||||
</TopBar>
|
||||
</template>
|
||||
<template #body>
|
||||
<div id="terminal"></div>
|
||||
</template>
|
||||
<template #footer>
|
||||
<FileUploader
|
||||
ref="fileUploader"
|
||||
:upload-handler="uploadHandler"
|
||||
:tr="$t"
|
||||
/>
|
||||
</template>
|
||||
</MainLayout>
|
||||
</template>
|
||||
|
||||
@@ -40,7 +51,7 @@ import InputText from 'primevue/inputtext';
|
||||
import Menu from 'primevue/menu';
|
||||
import ProgressSpinner from 'primevue/progressspinner';
|
||||
|
||||
import { TopBar, MainLayout } from 'pankow';
|
||||
import { TopBar, MainLayout, FileUploader } from 'pankow';
|
||||
|
||||
import 'xterm/css/xterm.css';
|
||||
import { Terminal } from 'xterm';
|
||||
@@ -56,6 +67,7 @@ export default {
|
||||
components: {
|
||||
Button,
|
||||
Dialog,
|
||||
FileUploader,
|
||||
InputText,
|
||||
MainLayout,
|
||||
Menu,
|
||||
@@ -80,6 +92,18 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onUpload() {
|
||||
this.$refs.fileUploader.onUploadFile('/tmp');
|
||||
},
|
||||
onDownload() {
|
||||
|
||||
},
|
||||
async uploadHandler(targetDir, file, progressHandler) {
|
||||
await superagent.post(`${this.apiOrigin}/api/v1/apps/${this.id}/upload`)
|
||||
.query({ access_token: this.accessToken, file: `${targetDir}/${file.name}` })
|
||||
.attach('file', file)
|
||||
.on('progress', progressHandler);
|
||||
},
|
||||
usesAddon(addon) {
|
||||
return !!Object.keys(this.addons).find(function (a) { return a === addon; });
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user