various filemanager and logs improvements

This commit is contained in:
Johannes Zellner
2023-07-13 15:36:57 +02:00
parent 25328d884f
commit d75c8e2858
4 changed files with 54 additions and 24 deletions

View File

@@ -8,10 +8,11 @@
<span class="title">{{ name }}</span>
</template>
<template #right>
<a class="p-button p-button-primary" style="margin-right: 5px;" :href="'/terminal.html?id=' + id" target="_blank" v-show="type === 'app'"><span class="p-button-icon p-button-icon-left pi pi-desktop"></span> {{ $t('terminal.title') }}</a>
<a class="p-button p-button-primary" style="margin-right: 5px;" :href="'/frontend/filemanager.html#/home/app/' + id" target="_blank" v-show="type === 'app'"><span class="p-button-icon p-button-icon-left pi pi-folder"></span> {{ $t('filemanager.title') }}</a>
<Button type="button" :label="$t('logs.clear')" icon="pi pi-eraser" @click="onClear()" style="margin-right: 5px" />
<a class="p-button p-button-primary" :href="downloadUrl" target="_blank"><span class="p-button-icon p-button-icon-left pi pi-download"></span> {{ $t('logs.download') }}</a>
<a style="margin-right: 25px;" :href="downloadUrl" target="_blank"><Button :label="$t('logs.download')" icon="pi pi-download" /></a>
<a style="margin-right: 5px;" :href="'/frontend/filemanager.html#/home/app/' + id" target="_blank" v-show="type === 'app'"><Button type="button" severity="secondary" icon="pi pi-folder" :label="$t('filemanager.title')" /></a>
<a style="margin-right: 5px;" :href="'/terminal.html?id=' + id" target="_blank" v-show="type === 'app'"><Button severity="secondary" icon="pi pi-desktop" :label="$t('terminal.title')" /></a>
<Button type="button" :label="$t('filemanager.toolbar.restartApp')" severity="secondary" icon="pi pi-sync" @click="onRestartApp" :loading="busyRestart" v-show="type === 'app'"/>
</template>
</TopBar>
</template>
@@ -54,6 +55,7 @@ export default {
accessToken: localStorage.token,
apiOrigin: API_ORIGIN || '',
logsModel: null,
busyRestart: false,
id: '',
name: '',
type: '',
@@ -67,6 +69,15 @@ export default {
},
onDownload() {
this.logsModel.download();
},
async onRestartApp() {
if (this.type !== 'app') return;
this.busyRestart = true;
await this.logsModel.restartApp();
this.busyRestart = false;
}
},
async mounted() {
@@ -113,12 +124,14 @@ export default {
if (this.type === 'app') {
try {
const app = await this.logsModel.getApp();
this.name = app.fqdn + ' (' + app.manifest.title + ')';
this.name = `${app.label || app.fqdn} (${app.manifest.title})`;
} catch (e) {
console.error(`Failed to get app info for ${this.id}:`, e);
}
}
window.document.title = `Logs Viewer - ${this.name}`;
this.downloadUrl = this.logsModel.getDownloadUrl();
this.logsModel.stream((id, time, html) => {
@@ -155,6 +168,7 @@ body {
background-color: black;
color: white;
margin-bottom: 0 !important;
padding: 5px 10px;
}
.log-line {
@@ -186,12 +200,5 @@ body {
height: 5px;
}
a.p-button:hover, a.p-button:focus {
color: white;
text-decoration: none;
background: #0d89ec;
border-color: #0d89ec;
}
</style>