Add dialout permissions instructions to no-port (#427)

* Add dialout permissions instructions to no-port

* Add OS check

* Remove || true

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
James Chaloupka 2024-02-09 20:18:02 -06:00 committed by GitHub
parent cb8f72e4d0
commit 21c23206d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 45 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import { customElement } from "lit/decorators.js";
import "../components/ewt-dialog"; import "../components/ewt-dialog";
import "../components/ewt-button"; import "../components/ewt-button";
import { dialogStyles } from "../styles"; import { dialogStyles } from "../styles";
import { getOperatingSystem } from "../util/get-operating-system";
const cloudDownload = svg` const cloudDownload = svg`
<svg <svg
@ -30,6 +31,8 @@ class EwtNoPortPickedDialog extends LitElement {
public doTryAgain?: () => void; public doTryAgain?: () => void;
public render() { public render() {
const OS = getOperatingSystem();
return html` return html`
<ewt-dialog <ewt-dialog
open open
@ -54,6 +57,20 @@ class EwtNoPortPickedDialog extends LitElement {
Make sure that the USB cable you use can be used for data and is not Make sure that the USB cable you use can be used for data and is not
a power-only cable. a power-only cable.
</li> </li>
${OS === "Linux"
? html`
<li>
If you are using a Linux flavor, make sure that your user is
part of the <code>dialout</code> group so it has permission to
access the device.
<code class="block"
>sudo usermod -a -G dialout YourUserName</code
>
You may need to log out & back in or reboot to activate the
new group access.
</li>
`
: ""}
<li> <li>
Make sure you have the right drivers installed. Below are the Make sure you have the right drivers installed. Below are the
drivers for common chips used in ESP devices: drivers for common chips used in ESP devices:
@ -147,6 +164,10 @@ class EwtNoPortPickedDialog extends LitElement {
margin-bottom: 0; margin-bottom: 0;
padding-left: 1.5em; padding-left: 1.5em;
} }
li code.block {
display: block;
margin: 0.5em 0;
}
`, `,
]; ];
} }

View File

@ -0,0 +1,24 @@
// From https://stackoverflow.com/a/38241481
export const getOperatingSystem = () => {
const userAgent = window.navigator.userAgent;
const platform =
// @ts-expect-error
window.navigator?.userAgentData?.platform || window.navigator.platform;
const macosPlatforms = ["macOS", "Macintosh", "MacIntel", "MacPPC", "Mac68K"];
const windowsPlatforms = ["Win32", "Win64", "Windows", "WinCE"];
const iosPlatforms = ["iPhone", "iPad", "iPod"];
if (macosPlatforms.indexOf(platform) !== -1) {
return "Mac OS";
} else if (iosPlatforms.indexOf(platform) !== -1) {
return "iOS";
} else if (windowsPlatforms.indexOf(platform) !== -1) {
return "Windows";
} else if (/Android/.test(userAgent)) {
return "Android";
} else if (/Linux/.test(platform)) {
return "Linux";
}
return null;
};