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

Bugfix/scrolling entire page #548

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion src/main/zapHomeFiles/hud/drawer.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
</table>
<table id="websockets-messages" class="table table-striped table-hover table-scroll table-history drawer-messages" style="min-width: fit-content;">
<tbody>
<tr v-for="message in filteredMessages" @click="messageSelected(message.channelId, message.messageId)" :id="'message-tr-'+message.messageId" class="message-tr">
<tr v-for="message in filteredMessages" @click="messageSelected(message.channelId, message.messageId)" :id="'ws-message-tr-'+message.messageId" class="message-tr">
<td class="field time"> {{ message.time }} </td>
<td class="field direction"> {{ $t('message.websockets_direction_' + message.direction.toLowerCase()) }} </td>
<td class="field opcode"> {{ message.opCode }} </td>
Expand Down
72 changes: 43 additions & 29 deletions src/main/zapHomeFiles/hud/drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ Vue.component('history', {
},
historyItemsFiltered() {
this.historyItemsFilteredMessage = I18n.t("common_items_filtered", [this.hiddenMessageCount, this.messageCount]);
},
scrollToBottom() {
if (this.messages.length > 0) {
let lastMessage = this.messages[this.messages.length - 1]
let lastid = 'message-tr-' + lastMessage.id
let lastIdElem = document.getElementById(lastid);

if(lastIdElem) {
lastIdElem.scrollIntoView(false)
}

//move horizontal scroll bar to the left
let tabsDetailsElems = document.querySelectorAll('tabs-details');
if (tabsDetailsElems.length > 0){
tabsDetails[0].scrollTo(0, tabsDetails.scrollHeight);
}
}
}
},
watch: {
Expand All @@ -82,6 +99,9 @@ Vue.component('history', {
.then(tool => {
this.messages = tool.messages
})
.then(() => {
this.scrollToBottom()
})
.catch(utils.errorHandler)

eventBus.$on('setMessages', data => {
Expand All @@ -97,21 +117,7 @@ Vue.component('history', {

},
updated() {
if (this.messages.length > 0) {
let lastMessage = this.messages[this.messages.length - 1]
let lastid = 'message-tr-' + lastMessage.id
let lastIdElem = document.getElementById(lastid);

if(lastIdElem) {
lastIdElem.scrollIntoView({block:'end', behavior:'smooth'});
}

//move horizontal scroll bar to the left
let tabsDetailsElems = document.querySelectorAll('tabs-details');
if (tabsDetailsElems.length > 0){
tabsDetails[0].scrollTo(0, tabsDetails.scrollHeight);
}
}
this.scrollToBottom()
},
beforeDestroy () {
eventBus.$off('setMessages')
Expand Down Expand Up @@ -174,6 +180,23 @@ Vue.component('websockets', {
},
websocketsItemsFiltered() {
this.websocketsItemsFilteredMessage = I18n.t("common_items_filtered", [this.hiddenMessageCount, this.messageCount]);
},
scrollToBottom() {
if (this.messages.length > 0) {
let lastMessage = this.messages[this.messages.length - 1]
let lastid = 'ws-message-tr-' + lastMessage.messageId
let lastIdElem = document.getElementById(lastid);

if(lastIdElem) {
lastIdElem.scrollIntoView(false)
}

//move horizontal scroll bar to the left
let tabsDetailsElems = document.querySelectorAll('tabs-details');
if (tabsDetailsElems.length > 0){
tabsDetails[0].scrollTo(0, tabsDetails.scrollHeight);
}
}
}
},
watch: {
Expand All @@ -193,6 +216,9 @@ Vue.component('websockets', {
.then(tool => {
this.messages = tool.messages
})
.then(() => {
this.scrollToBottom()
})
.catch(utils.errorHandler)

eventBus.$on('setMessages', data => {
Expand All @@ -201,26 +227,14 @@ Vue.component('websockets', {

eventBus.$on('updateWebSockets', data => {
this.messages = this.messages.concat(data.messages);
this.scrollToBottom()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not added to updateMessages?


let count = data.messages.length;
this.$parent.$emit('badgeDataEvent', {data: count})
});
},
updated() {
if (this.messages.length > 0) {
let lastMessage = this.messages[this.messages.length - 1]
let lastid = 'message-tr-' + lastMessage.messageId
let lastIdElem = document.querySelector(lastid);
if(lastIdElem){
lastIdElem.scrollIntoView({block:'end', behavior:'smooth'});
}

//move horizontal scroll bar to the left
let tabsDetailsElems = document.querySelectorAll('tabs-details');
if (tabsDetailsElems.length > 0){
tabsDetails[0].scrollTo(0, tabsDetails.scrollHeight);
}
}
this.scrollToBottom()
},
});

Expand Down