fix: live SSH update log re-renders in modal (v0.5.7)
Remove cached openLogs computed that blocked Vue updates to output/loading; preserve log tail on empty poll; auto-scroll log panel.
This commit is contained in:
@@ -24,9 +24,12 @@
|
||||
<p v-if="message && !loading" class="host-action-log-message" :class="messageClass">{{ message }}</p>
|
||||
<p v-else-if="message && loading" class="muted host-action-log-sub host-action-log-message">{{ message }}</p>
|
||||
<p v-if="!loading && ok" class="muted host-action-log-sub">Окно закроется автоматически через ~30 с</p>
|
||||
<pre v-if="logVisible" class="host-action-log-output">{{
|
||||
output || "Ожидание лога с хоста…\n(обновление /var/log/update_script.log)"
|
||||
}}</pre>
|
||||
<pre
|
||||
v-show="logVisible"
|
||||
ref="logPreRef"
|
||||
:key="`${output.length}-${loading}`"
|
||||
class="host-action-log-output"
|
||||
>{{ displayOutput }}</pre>
|
||||
<div class="host-action-log-actions">
|
||||
<button
|
||||
v-if="loading || output"
|
||||
@@ -48,7 +51,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { computed, nextTick, ref, watch } from "vue";
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
@@ -65,10 +68,29 @@ const emit = defineEmits<{
|
||||
"toggle-log": [];
|
||||
}>();
|
||||
|
||||
const logPreRef = ref<HTMLElement | null>(null);
|
||||
|
||||
const displayOutput = computed(() => {
|
||||
const text = props.output.trim();
|
||||
return text || "Ожидание лога с хоста…\n(обновление /var/log/update_script.log)";
|
||||
});
|
||||
|
||||
const messageClass = computed(() => {
|
||||
if (props.loading || props.ok == null) return "muted";
|
||||
return props.ok ? "success" : "error";
|
||||
});
|
||||
|
||||
watch(
|
||||
() => [props.output, props.loading, props.logVisible] as const,
|
||||
async () => {
|
||||
if (!props.logVisible) return;
|
||||
await nextTick();
|
||||
const el = logPreRef.value;
|
||||
if (el) {
|
||||
el.scrollTop = el.scrollHeight;
|
||||
}
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
<template>
|
||||
<div v-if="openLogs.length" class="host-action-log-stack" aria-live="polite">
|
||||
<HostActionLogModal
|
||||
v-for="entry in openLogs"
|
||||
:key="entry.id"
|
||||
:open="true"
|
||||
:title="entry.title"
|
||||
:loading="entry.loading"
|
||||
:ok="entry.ok"
|
||||
:message="entry.message"
|
||||
:output="entry.output"
|
||||
:log-visible="entry.logVisible"
|
||||
@close="closeHostRemoteActionLog(entry.id)"
|
||||
@toggle-log="toggleHostRemoteActionLog(entry.id)"
|
||||
/>
|
||||
<div v-if="hasOpenLogs" class="host-action-log-stack" aria-live="polite">
|
||||
<template v-for="entry in hostRemoteActionLogs" :key="entry.id">
|
||||
<HostActionLogModal
|
||||
v-if="entry.open"
|
||||
:open="true"
|
||||
:title="entry.title"
|
||||
:loading="entry.loading"
|
||||
:ok="entry.ok"
|
||||
:message="entry.message"
|
||||
:output="entry.output"
|
||||
:log-visible="entry.logVisible"
|
||||
@close="closeHostRemoteActionLog(entry.id)"
|
||||
@toggle-log="toggleHostRemoteActionLog(entry.id)"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -25,7 +26,7 @@ import {
|
||||
toggleHostRemoteActionLog,
|
||||
} from "../composables/useHostRemoteAction";
|
||||
|
||||
const openLogs = computed(() => hostRemoteActionLogs.filter((e) => e.open));
|
||||
const hasOpenLogs = computed(() => hostRemoteActionLogs.some((e) => e.open));
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -82,9 +82,16 @@ function scheduleSuccessAutoClose(entryId: string) {
|
||||
}
|
||||
|
||||
function applyJobToEntry(entry: HostRemoteActionLogEntry, job: HostRemoteActionJobStatus) {
|
||||
entry.title = job.title || entry.title;
|
||||
entry.message = job.message || entry.message;
|
||||
entry.output = job.output || job.stdout || "";
|
||||
if (job.title) {
|
||||
entry.title = job.title;
|
||||
}
|
||||
if (job.message) {
|
||||
entry.message = job.message;
|
||||
}
|
||||
const nextOutput = (job.output || job.stdout || "").trim();
|
||||
if (nextOutput) {
|
||||
entry.output = job.output || job.stdout || "";
|
||||
}
|
||||
}
|
||||
|
||||
function finishEntry(entry: HostRemoteActionLogEntry, job: HostRemoteActionJobStatus) {
|
||||
|
||||
Reference in New Issue
Block a user