mirror of
https://github.com/esphome/esp-web-tools.git
synced 2025-07-28 14:16:41 +00:00
Allow resetting data when firmware and version are the same (#103)
This commit is contained in:
parent
1a18108a55
commit
6e2976c229
@ -157,15 +157,23 @@ class EwtInstallDialog extends LitElement {
|
|||||||
let hideActions = true;
|
let hideActions = true;
|
||||||
let allowClosing = true;
|
let allowClosing = true;
|
||||||
|
|
||||||
const isSameFirmware = this._info!.firmware === this._manifest!.name;
|
|
||||||
const isSameVersion =
|
|
||||||
isSameFirmware && this._info!.version === this._manifest!.version;
|
|
||||||
|
|
||||||
content = html`
|
content = html`
|
||||||
<div class="device-info">
|
<div class="device-info">
|
||||||
${this._info!.firmware} ${this._info!.version}
|
${this._info!.firmware} ${this._info!.version}
|
||||||
</div>
|
</div>
|
||||||
<div class="dashboard-buttons">
|
<div class="dashboard-buttons">
|
||||||
|
${!this._isSameVersion
|
||||||
|
? html`
|
||||||
|
<div>
|
||||||
|
<ewt-button
|
||||||
|
.label=${!this._isSameFirmware
|
||||||
|
? `Install ${this._manifest!.name}`
|
||||||
|
: "Update"}
|
||||||
|
@click=${() => this._startInstall(!this._isSameFirmware)}
|
||||||
|
></ewt-button>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
: ""}
|
||||||
${this._client!.nextUrl === undefined
|
${this._client!.nextUrl === undefined
|
||||||
? ""
|
? ""
|
||||||
: html`
|
: html`
|
||||||
@ -208,17 +216,6 @@ class EwtInstallDialog extends LitElement {
|
|||||||
}}
|
}}
|
||||||
></ewt-button>
|
></ewt-button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<ewt-button
|
|
||||||
.label=${!isSameFirmware
|
|
||||||
? `Install ${this._manifest!.name}`
|
|
||||||
: isSameVersion
|
|
||||||
? "Up to date"
|
|
||||||
: "Update"}
|
|
||||||
@click=${() => this._startInstall(!isSameFirmware)}
|
|
||||||
.disabled=${isSameVersion}
|
|
||||||
></ewt-button>
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
<ewt-button
|
<ewt-button
|
||||||
label="Logs"
|
label="Logs"
|
||||||
@ -234,6 +231,17 @@ class EwtInstallDialog extends LitElement {
|
|||||||
}}
|
}}
|
||||||
></ewt-button>
|
></ewt-button>
|
||||||
</div>
|
</div>
|
||||||
|
${this._isSameVersion
|
||||||
|
? html`
|
||||||
|
<div>
|
||||||
|
<ewt-button
|
||||||
|
class="danger"
|
||||||
|
label="Reset Data"
|
||||||
|
@click=${() => this._startInstall(true)}
|
||||||
|
></ewt-button>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -362,9 +370,21 @@ class EwtInstallDialog extends LitElement {
|
|||||||
let hideActions = false;
|
let hideActions = false;
|
||||||
let allowClosing = false;
|
let allowClosing = false;
|
||||||
|
|
||||||
const isUpdate = !this._installErase && this._isUpdate;
|
const isUpdate = !this._installErase && this._isSameFirmware;
|
||||||
|
|
||||||
if (!this._installConfirmed) {
|
if (!this._installConfirmed && this._isSameVersion) {
|
||||||
|
heading = "Reset data";
|
||||||
|
content = html`
|
||||||
|
Do you want to reset your device and erase all existing data from your
|
||||||
|
device?
|
||||||
|
<ewt-button
|
||||||
|
class="danger"
|
||||||
|
slot="primaryAction"
|
||||||
|
label="Reset data"
|
||||||
|
@click=${this._confirmInstall}
|
||||||
|
></ewt-button>
|
||||||
|
`;
|
||||||
|
} else if (!this._installConfirmed) {
|
||||||
const action = isUpdate ? "update to" : "install";
|
const action = isUpdate ? "update to" : "install";
|
||||||
content = html`
|
content = html`
|
||||||
${isUpdate
|
${isUpdate
|
||||||
@ -657,10 +677,22 @@ class EwtInstallDialog extends LitElement {
|
|||||||
this.parentNode!.removeChild(this);
|
this.parentNode!.removeChild(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private get _isUpdate() {
|
/**
|
||||||
|
* Return if the device runs same firmware as manifest.
|
||||||
|
*/
|
||||||
|
private get _isSameFirmware() {
|
||||||
return this._info?.firmware === this._manifest!.name;
|
return this._info?.firmware === this._manifest!.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return if the device runs same firmware and version as manifest.
|
||||||
|
*/
|
||||||
|
private get _isSameVersion() {
|
||||||
|
return (
|
||||||
|
this._isSameFirmware && this._info!.version === this._manifest!.version
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private async _closeClientWithoutEvents(client: ImprovSerial) {
|
private async _closeClientWithoutEvents(client: ImprovSerial) {
|
||||||
client.removeEventListener("disconnect", this._handleDisconnect);
|
client.removeEventListener("disconnect", this._handleDisconnect);
|
||||||
await client.close();
|
await client.close();
|
||||||
@ -714,6 +746,9 @@ class EwtInstallDialog extends LitElement {
|
|||||||
.error {
|
.error {
|
||||||
color: #db4437;
|
color: #db4437;
|
||||||
}
|
}
|
||||||
|
.danger {
|
||||||
|
--mdc-theme-primary: #db4437;
|
||||||
|
}
|
||||||
button.link {
|
button.link {
|
||||||
background: none;
|
background: none;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user