Add dev menu (#72)
This commit is contained in:
1 parent
763cb64ba7
commit
4fb796b13b
4 files changed
+70
-1
No files matched your search
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Added
|
||||
- Add watched videos to Invidious watch history
|
||||
- App info screen
|
||||
- A dev menu selector to test newer or older versions of playlet lib
|
||||
- Makes it possible to test unstable releases before they officially release
|
||||
|
||||
### Fixed
|
||||
- A crash where the metadata of a video is not validated [#57](https://github.com/iBicha/playlet/issues/57)
|
||||
|
||||
@@ -31,6 +31,15 @@ namespace Http
|
||||
RegistryUtils.Delete("search_history")
|
||||
response.Default(204, "OK")
|
||||
return true
|
||||
else if payload.command = "set-playlet-lib-urls"
|
||||
content = payload.content
|
||||
if content = invalid
|
||||
RegistryUtils.Delete("playlet_lib_urls")
|
||||
else
|
||||
RegistryUtils.Write("playlet_lib_urls", content)
|
||||
end if
|
||||
response.Default(204, "OK")
|
||||
return true
|
||||
end if
|
||||
|
||||
response.Default(400, `Invalid command: ${payload.command}`)
|
||||
|
||||
@@ -69,7 +69,9 @@ function WebServerLoop()
|
||||
#if WEB_SERVER_BASIC_AUTH
|
||||
m.server.UseRouter(new Http.BasicAuthMiddleware())
|
||||
#end if
|
||||
m.server.UseRouter(new Http.RegistryApiRouter())
|
||||
#if DEBUG
|
||||
m.server.UseRouter(new Http.RegistryApiRouter())
|
||||
#end if
|
||||
m.server.UseRouter(new Http.HttpDefaultRouter())
|
||||
|
||||
timeout = m.settings.Timeout
|
||||
|
||||
@@ -76,6 +76,15 @@
|
||||
<h5>Feedback is welcome over at: <a id="feedback-url" href="https://github.com/iBicha/playlet"
|
||||
target="_blank">https://github.com/iBicha/playlet</a></h5>
|
||||
|
||||
<div id="dev-menu" style="display: none;">
|
||||
<h4>Developer menu</h4>
|
||||
<p><small>These are for testing purposes only, and are not meant to be used by end users.</small></p>
|
||||
<label for="playlet-lib-tag">Playlet Lib Tag:</label>
|
||||
<select name="playlet-lib-tag" id="playlet-lib-tag">
|
||||
<option value="">latest (default)</option>
|
||||
</select>
|
||||
<button onclick="SetPlayletLibUrls()">Apply</button>
|
||||
</div>
|
||||
<script>
|
||||
function Login() {
|
||||
if (!window.appState) {
|
||||
@@ -249,6 +258,49 @@ ${JSON.stringify(window.appState.invidious, null, 2)}
|
||||
})
|
||||
}
|
||||
|
||||
function FetchReleaseTags() {
|
||||
fetch("https://api.github.com/repos/iBicha/playlet/releases")
|
||||
.then(function (response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function (releases) {
|
||||
releases.filter(release => release.assets.filter(asset => asset.name === "playlet-lib.zip").length > 0)
|
||||
.forEach(r => {
|
||||
var option = document.createElement("option");
|
||||
option.text = r.tag_name;
|
||||
option.value = r.tag_name;
|
||||
document.getElementById("playlet-lib-tag").add(option);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function SetPlayletLibUrls() {
|
||||
var tags = document.getElementById("playlet-lib-tag");
|
||||
var value = tags.value;
|
||||
let content = null
|
||||
|
||||
if(value !== ""){
|
||||
content = JSON.stringify([{
|
||||
link: `https://github.com/iBicha/playlet/releases/download/${value}/playlet-lib.zip`,
|
||||
type: 'custom'
|
||||
}]);
|
||||
}
|
||||
|
||||
PostJson('/api/command', { command: "set-playlet-lib-urls", content: content })
|
||||
.then(function (response) {
|
||||
alert("Playlet lib tag updated. Restart Playlet to reflect changes.");
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(function (err) {
|
||||
alert(err)
|
||||
});
|
||||
}
|
||||
|
||||
function ShouldShowDevMenu() {
|
||||
const urlSearchParams = new URLSearchParams(window.location.search);
|
||||
return !!urlSearchParams.get('dev')
|
||||
}
|
||||
|
||||
function Initialize() {
|
||||
fetch("/api/state")
|
||||
.then(function (response) {
|
||||
@@ -293,6 +345,10 @@ ${JSON.stringify(window.appState.invidious, null, 2)}
|
||||
});
|
||||
|
||||
SetupWebSocket();
|
||||
if(ShouldShowDevMenu()){
|
||||
document.getElementById("dev-menu").style.display = "block";
|
||||
FetchReleaseTags();
|
||||
}
|
||||
}
|
||||
|
||||
var tableRow;
|
||||
|
||||
Reference in new issue
Block a user