From 91dbdf86c14dac9bff7275c3d009bacceb2f4321 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 14 Nov 2021 08:56:33 -0800 Subject: [PATCH] Split out non-improv dashboard from install dialog (#120) --- src/install-dialog.ts | 93 ++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 42 deletions(-) diff --git a/src/install-dialog.ts b/src/install-dialog.ts index 4fdcc94a..ee205913 100644 --- a/src/install-dialog.ts +++ b/src/install-dialog.ts @@ -1,6 +1,5 @@ import { LitElement, html, PropertyValues, css, TemplateResult } from "lit"; import { state } from "lit/decorators.js"; -import { ifDefined } from "lit/directives/if-defined.js"; import "./components/ewt-dialog"; import "./components/ewt-textfield"; import "./components/ewt-button"; @@ -88,7 +87,9 @@ class EwtInstallDialog extends LitElement { heading = "Error"; content = this._renderMessage(ERROR_ICON, this._error!, true); } else if (this._state === "DASHBOARD") { - [heading, content, hideActions, allowClosing] = this._renderDashboard(); + [heading, content, hideActions, allowClosing] = this._client + ? this._renderDashboard() + : this._renderDashboardNoImprov(); } else if (this._state === "PROVISION") { [heading, content, hideActions] = this._renderProvision(); } else if (this._state === "LOGS") { @@ -161,7 +162,7 @@ class EwtInstallDialog extends LitElement {
- +
- + this._startInstall(!this._isSameFirmware)} > @@ -268,6 +269,36 @@ class EwtInstallDialog extends LitElement { return [heading, content, hideActions, allowClosing]; } + _renderDashboardNoImprov(): [string, TemplateResult, boolean, boolean] { + const heading = "Device Dashboard"; + let content: TemplateResult; + let hideActions = true; + let allowClosing = true; + + content = html` +
+
+ this._startInstall(true)} + > +
+ +
+ { + // Also set `null` back to undefined. + this._client = undefined; + this._state = "LOGS"; + }} + > +
+
+ `; + + return [heading, content, hideActions, allowClosing]; + } _renderProvision(): [string | undefined, TemplateResult, boolean] { let heading: string | undefined = "Configure Wi-Fi"; @@ -398,7 +429,7 @@ class EwtInstallDialog extends LitElement { } ${this._manifest!.name}`; let content: TemplateResult; let hideActions = false; - let allowClosing = false; + const allowClosing = false; const isUpdate = !this._installErase && this._isSameFirmware; @@ -431,29 +462,14 @@ class EwtInstallDialog extends LitElement { label="Install" @click=${this._confirmInstall} > - ${this._client - ? html` - { - this._state = "DASHBOARD"; - }} - > - ` - : html` - { - // In case it was null - this._client = undefined; - this._state = "LOGS"; - }} - > - `} + { + this._state = "DASHBOARD"; + }} + > `; - allowClosing = !this._client; } else if ( !this._installState || this._installState.state === FlashStateType.INITIALIZING || @@ -491,14 +507,12 @@ class EwtInstallDialog extends LitElement { ${messageTemplate(OK_ICON, "Installation complete!")} { - this._state = this._installErase ? "PROVISION" : "DASHBOARD"; - }} + @click=${() => { + this._state = + supportsImprov && this._installErase ? "PROVISION" : "DASHBOARD"; + }} > `; } else if (this._installState.state === FlashStateType.ERROR) { @@ -627,12 +641,6 @@ class EwtInstallDialog extends LitElement { } else { this._client = null; // not supported this.logger.error("Improv initialization failed.", err); - // initialize is also called at the end of an installation - // When it can't detect improv (ie because install failed) - // We shouldn't reset settings but instead show the error - if (this._state !== "INSTALL") { - this._startInstall(!this._manifest.new_install_skip_erase); - } } } @@ -746,6 +754,7 @@ class EwtInstallDialog extends LitElement { table { border-spacing: 0; color: rgba(0, 0, 0, 0.6); + margin-bottom: 16px; } table svg { width: 20px; @@ -768,7 +777,7 @@ class EwtInstallDialog extends LitElement { text-align: center; } .dashboard-buttons { - margin: 16px 0 -16px -8px; + margin: 0 0 -16px -8px; } .dashboard-buttons div { display: block;