Merge branch 'action-log-collapse' into 'v3'
Collapse action logs by default See merge request openflexure/openflexure-microscope-server!616
This commit is contained in:
commit
9807643da1
3 changed files with 167 additions and 32 deletions
|
|
@ -1,25 +1,55 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="log-wrapper" @mouseenter="onMouseEnter" @mouseleave="onMouseLeave">
|
<div class="action-log-display">
|
||||||
<div ref="logContainer" class="log-container uk-margin-left uk-margin-right uk-margin">
|
<!-- Toggle button -->
|
||||||
<div v-if="log">
|
<button
|
||||||
<div v-for="(item, index) in log" :key="`log_entry_${index}`">
|
v-if="log.length"
|
||||||
{{ item.message }}
|
class="log-toggle"
|
||||||
</div>
|
:title="isCollapsed ? 'Show full log' : 'Hide full log'"
|
||||||
</div>
|
:aria-label="isCollapsed ? 'Show full log' : 'Hide full log'"
|
||||||
<div v-if="taskStatus == 'error'" class="uk-alert uk-alert-danger">
|
@click="toggleLog"
|
||||||
<p><b>The task failed due to an error:</b></p>
|
>
|
||||||
<p>{{ errorMessage }}</p>
|
<span class="material-symbols-outlined" aria-hidden="true">
|
||||||
</div>
|
{{ isCollapsed ? "expand_more" : "expand_less" }}
|
||||||
<div v-if="taskStatus == 'cancelled'" class="uk-alert uk-alert-warning">
|
</span>
|
||||||
The task was cancelled.
|
</button>
|
||||||
</div>
|
|
||||||
<div v-if="taskStatus == 'completed'" class="uk-alert uk-alert-success">
|
|
||||||
The task completed successfully.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Paused banner outside scroll container, positioned relative to wrapper -->
|
<!-- Header always shows latest message-->
|
||||||
<div v-if="userIsHovering" class="paused-banner">Auto-scroll paused</div>
|
<div class="log-summary">
|
||||||
|
<span v-if="latestMessage">
|
||||||
|
{{ latestMessage }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Expanded view shows log -->
|
||||||
|
<transition name="log-fade">
|
||||||
|
<div
|
||||||
|
v-if="!isCollapsed"
|
||||||
|
class="log-wrapper"
|
||||||
|
@mouseenter="onMouseEnter"
|
||||||
|
@mouseleave="onMouseLeave"
|
||||||
|
>
|
||||||
|
<div ref="logContainer" class="log-container uk-margin-left uk-margin-right uk-margin">
|
||||||
|
<div v-if="log">
|
||||||
|
<div v-for="(item, index) in log" :key="`log_entry_${index}`">
|
||||||
|
{{ item.message }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="taskStatus === 'error'" class="uk-alert uk-alert-danger">
|
||||||
|
<p><b>The task failed due to an error:</b></p>
|
||||||
|
<p>{{ errorMessage }}</p>
|
||||||
|
</div>
|
||||||
|
<div v-if="taskStatus == 'cancelled'" class="uk-alert uk-alert-warning">
|
||||||
|
The task was cancelled.
|
||||||
|
</div>
|
||||||
|
<div v-if="taskStatus == 'completed'" class="uk-alert uk-alert-success">
|
||||||
|
The task completed successfully.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Paused banner outside scroll container, positioned relative to wrapper -->
|
||||||
|
<div v-if="userIsHovering" class="paused-banner">Auto-scroll paused</div>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -36,15 +66,28 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
collapsedByDefault: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
userIsHovering: false,
|
userIsHovering: false,
|
||||||
|
isCollapsed: this.collapsedByDefault,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
latestMessage() {
|
||||||
|
if (!this.log.length) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.log[this.log.length - 1].message;
|
||||||
|
},
|
||||||
|
|
||||||
errorMessage() {
|
errorMessage() {
|
||||||
let logLength = this.log.length;
|
let logLength = this.log.length;
|
||||||
var defaultMessage = "Unexpected error, please check the logs";
|
var defaultMessage = "Unexpected error, please check the logs";
|
||||||
|
|
@ -62,18 +105,33 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
log: {
|
log: {
|
||||||
handler() {
|
handler() {
|
||||||
this.scrollToBottom();
|
if (!this.isCollapsed) {
|
||||||
|
this.scrollToBottom();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
deep: true,
|
deep: true,
|
||||||
},
|
},
|
||||||
taskStatus: {
|
|
||||||
handler() {
|
taskStatus() {
|
||||||
|
if (!this.isCollapsed) {
|
||||||
this.scrollToBottom();
|
this.scrollToBottom();
|
||||||
},
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
collapsedByDefault(newValue) {
|
||||||
|
this.isCollapsed = newValue;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
toggleLog() {
|
||||||
|
this.isCollapsed = !this.isCollapsed;
|
||||||
|
|
||||||
|
if (!this.isCollapsed) {
|
||||||
|
this.scrollToBottom();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onMouseEnter() {
|
onMouseEnter() {
|
||||||
this.userIsHovering = true;
|
this.userIsHovering = true;
|
||||||
},
|
},
|
||||||
|
|
@ -95,16 +153,41 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
/* Expanded view */
|
||||||
.log-wrapper {
|
.log-wrapper {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 200px;
|
flex: 1 1 200px; /* prefer 200px, but shrink if the container runs out of room */
|
||||||
|
min-height: 2.6em; /* hard floor: roughly two lines of text */
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-bottom: 1em;
|
margin-bottom: 0;
|
||||||
margin-top: 1em;
|
margin-top: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-log-display {
|
||||||
|
width: 100%;
|
||||||
|
position: relative;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-summary {
|
||||||
|
padding: 0.6em;
|
||||||
|
padding-right: 2.5em; /* reserve room for the toggle button, prevents overlap */
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
font-size: large;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.log-container {
|
.log-container {
|
||||||
height: 100%;
|
flex: 1 1 auto;
|
||||||
|
min-height: 0;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
color: black;
|
color: black;
|
||||||
|
|
@ -128,4 +211,43 @@ export default {
|
||||||
box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
|
box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
|
||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Toggle button */
|
||||||
|
.log-toggle {
|
||||||
|
position: absolute;
|
||||||
|
top: 6px;
|
||||||
|
right: 6px;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
padding: 4px;
|
||||||
|
color: var(--uk-inverse-color, inherit); /* get the colour of the text from ui-kit */
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-symbols-outlined {
|
||||||
|
font-size: 28px;
|
||||||
|
color: inherit; /* inherit from .log-toggle so it tracks the theme color */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handles the entire animation, from either enter-from or leave-to */
|
||||||
|
.log-fade-enter-active,
|
||||||
|
.log-fade-leave-active {
|
||||||
|
transition:
|
||||||
|
max-height 0.25s ease,
|
||||||
|
opacity 0.25s ease;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The collapsed part of the animation, whether at the start or end */
|
||||||
|
.log-fade-enter-from,
|
||||||
|
.log-fade-leave-to {
|
||||||
|
max-height: 0;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The expanded part of the animation, whether at the start or end */
|
||||||
|
.log-fade-enter-to,
|
||||||
|
.log-fade-leave-from {
|
||||||
|
max-height: 200px;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ export default {
|
||||||
place-content: stretch flex-start;
|
place-content: stretch flex-start;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
flex: 0 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#progress-and-cancel-row .stretchy {
|
#progress-and-cancel-row .stretchy {
|
||||||
|
|
@ -130,7 +131,23 @@ export default {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#status-modal h2 {
|
||||||
|
flex: 0 0 auto; // title never shrinks
|
||||||
|
}
|
||||||
|
|
||||||
|
#status-modal .action-log-display {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#status-modal .log-wrapper {
|
||||||
|
flex: 1 1 200px; // prefer 200px, shrink only under pressure
|
||||||
|
min-height: 2.6em; // floor: one line
|
||||||
|
}
|
||||||
|
|
||||||
#status-modal .log-container {
|
#status-modal .log-container {
|
||||||
height: 10em;
|
height: auto;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-height: 2.6em;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -219,8 +219,4 @@ export default {
|
||||||
.control-component {
|
.control-component {
|
||||||
width: 33%;
|
width: 33%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#log-display {
|
|
||||||
height: 20em;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue