Skip to content

Commit

Permalink
feat(desktop & web): display el-tooltip only when the connection name…
Browse files Browse the repository at this point in the history
… is too long
  • Loading branch information
XL-YiBai committed Jul 18, 2024
1 parent 069f7fa commit 8285b8a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
17 changes: 15 additions & 2 deletions src/views/connections/ConnectionsDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
</a>
</el-tooltip>
<el-tooltip
:disabled="!showTitleTooltip"
:effect="theme !== 'light' ? 'light' : 'dark'"
:content="`${titleName}`"
:content="titleName"
:open-delay="500"
placement="top"
>
<h2 :class="[ { offline: !client.connected }, 'title-name' ]">
<h2 ref="title" :class="[{ offline: !client.connected }, 'title-name']">
{{ titleName }}
</h2>
</el-tooltip>
Expand Down Expand Up @@ -439,6 +440,7 @@ export default class ConnectionsDetail extends Vue {
private showImportData = false
private showTimedMessage = false
private showUseScript = false
private showTitleTooltip = false
private connectLoading = false
private disconnectLoding = false
Expand Down Expand Up @@ -567,6 +569,17 @@ export default class ConnectionsDetail extends Vue {
}, 500)
}
@Watch('titleName')
private async checkTitleOverflow() {
await this.$nextTick()
const titleElement = this.$refs.title as HTMLElement
if (titleElement?.scrollWidth > 200) {
this.showTitleTooltip = true
} else {
this.showTitleTooltip = false
}
}
private checkScriptOption(optionName: 'function' | 'schema', optionMethod: 'received' | 'publish') {
const applyOption: any = this.scriptOption?.apply
const optionNameExists = Boolean(this.scriptOption?.[optionName]?.name)
Expand Down
22 changes: 18 additions & 4 deletions web/src/views/connections/ConnectionsDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
<div class="topbar">
<div class="connection-head">
<el-tooltip
:disabled="!showTitleTooltip"
:effect="theme !== 'light' ? 'light' : 'dark'"
:content="`${titleName}`"
:content="titleName"
:open-delay="500"
placement="top"
>
<h2 :class="[ { offline: !client.connected }, 'title-name' ]">
<h2 ref="title" :class="[{ offline: !client.connected }, 'title-name']">
{{ titleName }}
</h2>
</el-tooltip>
Expand Down Expand Up @@ -278,9 +279,12 @@ export default class ConnectionsDetail extends Vue {
}
private showSubs = true
private showClientInfo = true
private showContextmenu: boolean = false
private showTitleTooltip = false
private largeDesktop = false
private screenWidth = document.body.clientWidth
private showClientInfo = true
private connectLoading = false
private disconnectLoding = false
private isReconnect = false
Expand All @@ -301,7 +305,6 @@ export default class ConnectionsDetail extends Vue {
private messageListMarginTop: number = 19
private messagesAddedNewItem: boolean = false
private activeTopic = ''
private showContextmenu: boolean = false
private selectedMessage: MessageModel | null = null
private contextmenuConfig: ContextmenuModel = {
top: 0,
Expand Down Expand Up @@ -515,6 +518,17 @@ export default class ConnectionsDetail extends Vue {
}, 500)
}
@Watch('titleName')
private async checkTitleOverflow() {
await this.$nextTick()
const titleElement = this.$refs.title as HTMLElement
if (titleElement?.scrollWidth > 200) {
this.showTitleTooltip = true
} else {
this.showTitleTooltip = false
}
}
private getConnectionValue(id: string) {
const currentActiveConnection:
| {
Expand Down

0 comments on commit 8285b8a

Please sign in to comment.