mirror of
https://github.com/esphome/esp-web-tools.git
synced 2025-07-28 14:16:41 +00:00
Add check for secure context + fix doc typos (#11)
This commit is contained in:
parent
11df2a9e4e
commit
017d8edbf2
@ -84,6 +84,7 @@ The following slots are available:
|
|||||||
| -- | -- |
|
| -- | -- |
|
||||||
| `activate` | Button to start the flash progress
|
| `activate` | Button to start the flash progress
|
||||||
| `unsupported` | Message to show when the browser is not supported
|
| `unsupported` | Message to show when the browser is not supported
|
||||||
|
| `not-allowed` | Message to show when not a secure context
|
||||||
|
|
||||||
## Events
|
## Events
|
||||||
|
|
||||||
@ -96,6 +97,7 @@ Field | Description
|
|||||||
state | The current [state](https://github.com/esphome/esp-web-tools/blob/main/src/const.ts)
|
state | The current [state](https://github.com/esphome/esp-web-tools/blob/main/src/const.ts)
|
||||||
message | A description of the current state
|
message | A description of the current state
|
||||||
manifest | The loaded manifest
|
manifest | The loaded manifest
|
||||||
|
build | The manifest's build that was selected
|
||||||
chipFamily | The chip that was detected; "ESP32" \| "ESP8266" \| "ESP32-S2" \| "Unknown Chip"
|
chipFamily | The chip that was detected; "ESP32" \| "ESP8266" \| "ESP32-S2" \| "Unknown Chip"
|
||||||
details | An optional extra field that is different [per state](https://github.com/esphome/esp-web-tools/blob/main/src/const.ts)
|
details | An optional extra field that is different [per state](https://github.com/esphome/esp-web-tools/blob/main/src/const.ts)
|
||||||
|
|
||||||
|
12
index.html
12
index.html
@ -285,9 +285,9 @@
|
|||||||
<h4>Replace the button and message with a custom one</h4>
|
<h4>Replace the button and message with a custom one</h4>
|
||||||
<p>
|
<p>
|
||||||
You can replace both the activation button and the message that is shown
|
You can replace both the activation button and the message that is shown
|
||||||
when the user uses an unsupported browser with your own elements. This
|
when the user uses an unsupported browser or non secure context with
|
||||||
can be done using the <code>activate</code> and
|
your own elements. This can be done using the <code>activate</code>,
|
||||||
<code>unsupported</code> slots:
|
<code>unsupported</code> and <code>not-allowed</code> slots:
|
||||||
</p>
|
</p>
|
||||||
<pre>
|
<pre>
|
||||||
<esp-web-install-button
|
<esp-web-install-button
|
||||||
@ -297,17 +297,19 @@
|
|||||||
>
|
>
|
||||||
<button slot="activate">Custom install button</button>
|
<button slot="activate">Custom install button</button>
|
||||||
<span slot="unsupported">Ah snap, your browser doesn't work!</span>
|
<span slot="unsupported">Ah snap, your browser doesn't work!</span>
|
||||||
|
<span slot="not-allowed">Ah snap, you are not allowed to use this on HTTP!</span>
|
||||||
</esp-web-install-button>
|
</esp-web-install-button>
|
||||||
</pre
|
</pre
|
||||||
>
|
>
|
||||||
<h4>Show or hide the progress bar and log</h4>
|
<h4>Show or hide the progress bar and log</h4>
|
||||||
<p>
|
<p>
|
||||||
By default there is a progress bar showing the state and progress of the
|
By default there is a progress bar showing the state and progress of the
|
||||||
flashing progress, you can chnage this progress bar to a log view with
|
flashing progress, you can change this progress bar to a log view with
|
||||||
the <code>show-log</code> attribute.
|
the <code>show-log</code> attribute.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
You can also hide all progress indicators by adding the `hide-progress`
|
You can also hide all progress indicators by adding the
|
||||||
|
<code>hide-progress</code>
|
||||||
attribute. This will hide both the progress bar and the log view. You
|
attribute. This will hide both the progress bar and the log view. You
|
||||||
can then implement your own progress elements using the
|
can then implement your own progress elements using the
|
||||||
<a href="#state-events">state events</a>.
|
<a href="#state-events">state events</a>.
|
||||||
|
@ -69,6 +69,9 @@ export class FlashProgress extends LitElement {
|
|||||||
color: var(--esp-tools-success-color, #28a745);
|
color: var(--esp-tools-success-color, #28a745);
|
||||||
--mdc-theme-primary: var(--esp-tools-success-color, #28a745);
|
--mdc-theme-primary: var(--esp-tools-success-color, #28a745);
|
||||||
}
|
}
|
||||||
|
mwc-linear-progress {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
h2 {
|
h2 {
|
||||||
margin: 16px 0 0;
|
margin: 16px 0 0;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ import { FlashState } from "./const";
|
|||||||
export class InstallButton extends HTMLElement {
|
export class InstallButton extends HTMLElement {
|
||||||
public static isSupported = "serial" in navigator;
|
public static isSupported = "serial" in navigator;
|
||||||
|
|
||||||
|
public static isAllowed = window.isSecureContext;
|
||||||
|
|
||||||
private static style = `
|
private static style = `
|
||||||
button {
|
button {
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -80,13 +82,11 @@ export class InstallButton extends HTMLElement {
|
|||||||
|
|
||||||
this.renderRoot = this.attachShadow({ mode: "open" });
|
this.renderRoot = this.attachShadow({ mode: "open" });
|
||||||
|
|
||||||
if (!InstallButton.isSupported) {
|
if (!InstallButton.isSupported || !InstallButton.isAllowed) {
|
||||||
this.toggleAttribute("install-unsupported", true);
|
this.toggleAttribute("install-unsupported", true);
|
||||||
const slot = document.createElement("slot");
|
this.renderRoot.innerHTML = !InstallButton.isSupported
|
||||||
slot.name = "unsupported";
|
? "<slot name='unsupported'>Your browser does not support installing things on ESP devices. Use Google Chrome or Microsoft Edge.</slot>"
|
||||||
slot.innerText =
|
: "<slot name='not-allowed'>You can only install ESP devices on HTTPS websites or on the localhost.</slot>";
|
||||||
"Your browser does not support installing things on ESP devices. Use Google Chrome or Microsoft Edge.";
|
|
||||||
this.renderRoot.append(slot);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user