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

v3 Expand-on-header-dbclick-only #81

Merged
merged 8 commits into from
Apr 25, 2024
Merged
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
23 changes: 9 additions & 14 deletions packages/v3/src/esp-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ export default class EspApp extends LitElement {
setInterval(() => {
this.connected = !!this.ping && Date.now() - this.lastUpdate < 15000;
}, 5000);
document.addEventListener('entity-tab-header-double-clicked', (e) => {
const mainElement = this.shadowRoot?.querySelector('main.flex-grid-half');
mainElement?.classList.toggle('expanded_entity');
});
document.addEventListener('log-tab-header-double-clicked', (e) => {
const mainElement = this.shadowRoot?.querySelector('main.flex-grid-half');
mainElement?.classList.toggle('expanded_logs');
});
}

schemeDefault() {
Expand Down Expand Up @@ -162,7 +170,6 @@ export default class EspApp extends LitElement {
? html`<section
id="col_logs"
class="col"
@dblclick="${this._handleDblClick}"
>
<esp-log rows="50" .scheme="${this.scheme}"></esp-log>
</section>`
Expand Down Expand Up @@ -210,8 +217,7 @@ export default class EspApp extends LitElement {
<main class="flex-grid-half" @toggle-layout="${this._handleLayoutToggle}">
<section
id="col_entities"
class="col"
@dblclick="${this._handleDblClick}"
class="col"
>
<esp-entity-table .scheme="${this.scheme}"></esp-entity-table>
${this.renderOta()}
Expand All @@ -221,17 +227,6 @@ export default class EspApp extends LitElement {
`;
}

private _handleDblClick(e: Event) {
e.currentTarget?.parentNode?.classList.toggle(
"expanded_entity",
e.currentTarget?.id === "col_entities" ? undefined : false
);
e.currentTarget?.parentNode?.classList.toggle(
"expanded_logs",
e.currentTarget?.id === "col_logs" ? undefined : false
);
}

private _updateUptime(e: MessageEvent) {
if (e.lastEventId) {
this.ping = parseInt(e.lastEventId);
Expand Down
13 changes: 12 additions & 1 deletion packages/v3/src/esp-entity-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ export class EntityTable extends LitElement implements RestAction {
<div>
${elems.map(
(group) => html`
<div class="tab-header">
<div
class="tab-header"
@dblclick="${this._handleTabHeaderDblClick}"
>
${EntityTable.ENTITY_CATEGORIES[parseInt(group.name)] ||
EntityTable.ENTITY_UNDEFINED}
</div>
Expand Down Expand Up @@ -240,8 +243,16 @@ export class EntityTable extends LitElement implements RestAction {
);
}
}
_handleTabHeaderDblClick(e: Event) {
const doubleClickEvent = new CustomEvent('entity-tab-header-double-clicked', {
bubbles: true,
composed: true,
});
e.target?.dispatchEvent(doubleClickEvent);
}
}


type ActionRendererNonCallable = "entity" | "actioner" | "exec";
type ActionRendererMethodKey = keyof Omit<
ActionRenderer,
Expand Down
15 changes: 14 additions & 1 deletion packages/v3/src/esp-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ export class DebugLog extends LitElement {

render() {
return html`
<div class="tab-header">Debug Log</div>
<div
class="tab-header"
@dblclick="${this._handleTabHeaderDblClick}"
>
Debug Log
</div>
<div class="tab-container">
<div class="logs" color-scheme="${this.scheme}">
<div class="thead trow">
Expand All @@ -77,6 +82,14 @@ export class DebugLog extends LitElement {
`;
}

_handleTabHeaderDblClick(e: Event) {
const doubleClickEvent = new CustomEvent('log-tab-header-double-clicked', {
bubbles: true,
composed: true,
});
e.target?.dispatchEvent(doubleClickEvent);
}

static get styles() {
return [
cssTab,
Expand Down