2 Commits

Author SHA1 Message Date
4e9a902a1c doc: added documentation for CORS error mitigation during ui development
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 4m54s
Check code formatting / Check-C-Format (push) Successful in 7s
Check code formatting / Check-Python-Flake8 (push) Successful in 10s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s
Run pytests / Check-Pytest (push) Successful in 11s
2026-01-27 18:41:51 +01:00
bd15a45090 feat: filesystem browser button in nav bar
Previously, the playlist_filebrowser always contained a 'cancel' and
'add tracks' button, because it was used in context of the playlist
editor only.

The playlist_filebrowser now differentiates between the intents it is
being used with. In context of the new filesystem browser button, the
'cancel' and 'add tracks' buttons are actively hidden.
2026-01-27 18:29:33 +01:00
2 changed files with 44 additions and 2 deletions

View File

@@ -52,3 +52,23 @@ would be stored in the following key/value pairs in the btree db:
* 00aa11bb22/playlist/00000: a.mp3 * 00aa11bb22/playlist/00000: a.mp3
* 00aa11bb22/playlist/00001: b.mp3 * 00aa11bb22/playlist/00001: b.mp3
* 00aa11bb22/playlistpos: 00000 * 00aa11bb22/playlistpos: 00000
## Notes for UI development with chromium
Features for the web interface are best prototyped in a browser directly. By using the built-in developmer tools and
and their "override" feature, the web contents are replaced by a locally stored copy, which can be used to directly
test the modifications without going all the way through the build and flash process.
However, modern browsers may restrict or even completely forbid the execution of dynamic content like JavaScript, if
the content is stored on the local machine and/or the content is accessed using http. In such a case, chromium issues
an error message similar to the following one:
> Access to fetch at 'http://192.168.4.1/api/v1/audiofiles' from origin 'http://192.168.4.1' has been blocked by CORS
> policy: The request client is not a secure context and the resource is in more-private address space `local`.
To mitigate this, chromium offers two flags that need modification:
- 'chrome://flags/#local-network-access-check' must be `Disabled`
- 'chrome://flags/#unsafely-treat-insecure-origin-as-secure' must be `Enabled`
Note that these settings leave the browser susceptible to security issues and should be returned to
their default values as soon as possible.

View File

@@ -147,6 +147,7 @@
<button onclick="showScreen('menu')">🏠 Main Menu</button> <button onclick="showScreen('menu')">🏠 Main Menu</button>
<button onclick="showScreen('config')">⚙️ Config Editor</button> <button onclick="showScreen('config')">⚙️ Config Editor</button>
<button onclick="showScreen('playlist')">🖹 Playlist Editor</button> <button onclick="showScreen('playlist')">🖹 Playlist Editor</button>
<button onclick="showScreen('playlist_filebrowser', 'filesystem')">📂 Filesystem</button>
</nav> </nav>
<!-- MAIN MENU --> <!-- MAIN MENU -->
@@ -243,7 +244,7 @@
<!-- PLAYLIST EDITOR SCREEN 3: file browser --> <!-- PLAYLIST EDITOR SCREEN 3: file browser -->
<div id="screen-playlist_filebrowser" class="screen"> <div id="screen-playlist_filebrowser" class="screen">
<h2>Playlist Editor</h2> <h2 id="playlist-filebrowser-title">Playlist Editor</h2>
<div id="playlist-filebrowser-container"> <div id="playlist-filebrowser-container">
<div class="scroll-container"> <div class="scroll-container">
<div class="tree" id="playlist-filebrowser-tree"> <div class="tree" id="playlist-filebrowser-tree">
@@ -787,6 +788,8 @@
PLAYLIST EDITOR LOGIC - ADD FILES SCREEN PLAYLIST EDITOR LOGIC - ADD FILES SCREEN
------------------------------------------- */ ------------------------------------------- */
Screens.playlist_filebrowser = (() => { Screens.playlist_filebrowser = (() => {
let isFilesystemMode = false;
function init() { function init() {
document.getElementById('playlist-filebrowser-cancel').addEventListener("click", (e) => { document.getElementById('playlist-filebrowser-cancel').addEventListener("click", (e) => {
showScreen("playlist_edit", {}); showScreen("playlist_edit", {});
@@ -805,13 +808,32 @@
}); });
tree.init(); tree.init();
} }
async function onShow(intent) { async function onShow(intent) {
console.log(intent)
document.getElementById('playlist-filebrowser-addtrack').disabled = true; document.getElementById('playlist-filebrowser-addtrack').disabled = true;
const title = document.getElementById('playlist-filebrowser-title');
const cancelButton = document.getElementById('playlist-filebrowser-cancel');
const addTracksButton = document.getElementById('playlist-filebrowser-addtrack');
if (intent !== 'refresh') { if (intent !== 'refresh') {
isFilesystemMode = (intent === 'filesystem');
document.getElementById('playlist-filebrowser-upload-progress').value = 0; document.getElementById('playlist-filebrowser-upload-progress').value = 0;
document.getElementById("playlist-filebrowser-upload-files").value = ""; document.getElementById("playlist-filebrowser-upload-files").value = "";
} }
if (isFilesystemMode) {
title.innerText = "Filesystem";
cancelButton.style.display = 'none';
addTracksButton.style.display = 'none';
} else {
title.innerText = "Playlist Editor";
cancelButton.style.display = ''
addTracksButton.style.display = ''
}
tree = document.getElementById("playlist-filebrowser-tree"); tree = document.getElementById("playlist-filebrowser-tree");
tree.innerHTML = "Loading..."; tree.innerHTML = "Loading...";
fetch('/api/v1/audiofiles') fetch('/api/v1/audiofiles')