feat: add read-only mode to API and UI, disable write actions

This commit is contained in:
Sergey Krashevich
2026-02-01 04:13:43 +03:00
parent 6085c8aabe
commit cc453dd9ed
24 changed files with 438 additions and 8 deletions
+21 -6
View File
@@ -45,11 +45,18 @@
</main>
<script>
const templates = [
let templates = [
'<a href="stream.html?src={name}">stream</a>',
'<a href="links.html?src={name}">links</a>',
'<a href="#" data-name="{name}">delete</a>',
];
let readOnly = false;
const applyReadOnly = (flag) => {
if (!flag || readOnly) return;
readOnly = true;
templates = templates.filter(link => link.indexOf('delete') < 0);
};
document.querySelector('.controls > button')
.addEventListener('click', () => {
@@ -144,13 +151,21 @@
// Auto-reload
setInterval(reload, 1000);
const url = new URL('api', location.href);
fetch(url, {cache: 'no-cache'}).then(r => r.json()).then(data => {
const info = document.querySelector('.info');
const info = document.querySelector('.info');
const applyInfo = (data) => {
info.innerText = `version: ${data.version} / config: ${data.config_path}`;
});
applyReadOnly(Boolean(data.read_only));
reload();
};
reload();
if (window.go2rtcReady) {
window.go2rtcReady.then(data => {
if (data) applyInfo(data);
});
} else {
const url = new URL('api', location.href);
fetch(url, {cache: 'no-cache'}).then(r => r.json()).then(data => applyInfo(data));
}
</script>
</body>