Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added log autoscroll #2017

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/components/cylc/log/Log.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
v-for="(log, index) in computedLogs"
:key="index"
:class="wordWrap ? 'text-pre-wrap' : 'text-pre'"
>{{ log }}</span></pre>
>{{ log }}</span>
</pre>
</template>

<script>
Expand Down Expand Up @@ -84,6 +85,15 @@ export default {
}
return logLine
}
},

watch: {
computedLogs: {
handler (val, old) {
this.$emit('updating')
},
deep: true
}
}
}

Expand Down
27 changes: 26 additions & 1 deletion src/views/Log.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
:logs="results.lines"
:timestamps="timestamps"
:word-wrap="wordWrap"
@updating="updating"
/>
<!-- a div to use for autoscrolling -->
<div class="auto-scroll-end"></div>
</template>
</v-col>
</v-row>
Expand All @@ -188,6 +191,7 @@ import {
mdiPowerPlugOff,
mdiPowerPlug,
mdiWrap,
mdiMouseScrollWheel,
} from '@mdi/js'
import { btnProps } from '@/utils/viewToolbar'
import graphqlMixin from '@/mixins/graphql'
Expand Down Expand Up @@ -411,6 +415,7 @@ export default {

data () {
return {
autoScroll: false,
controlGroups: [
{
title: 'Log',
Expand All @@ -429,6 +434,13 @@ export default {
value: this.wordWrap,
key: 'wordWrap',
},
{
title: 'Auto scroll',
icon: mdiMouseScrollWheel,
action: 'toggle',
value: this.autoScroll,
key: 'autoScroll',
},
]
}
],
Expand Down Expand Up @@ -478,6 +490,19 @@ export default {
},

methods: {
scrollToElement (elementCLassName, options) {
const el = this.$el.getElementsByClassName(elementCLassName)[0]

if (el) {
// Use el.scrollIntoView() to instantly scroll to the element
el.scrollIntoView(options)
}
},
updating () {
if (this.autoScroll) {
this.scrollToElement('auto-scroll-end', { behavior: 'smooth' })
}
},
setOption (option, value) {
// used by the ViewToolbar to update settings
this[option] = value
Expand Down Expand Up @@ -568,7 +593,7 @@ export default {
this.file = null
// go back to last chosen job if we are switching back to job logs
this.relativeID = val ? this.previousRelativeID : null
},
}
},

// Misc options
Expand Down
Loading