Add dev menu (#72)
This commit is contained in:
1 parent
763cb64ba7
commit
4fb796b13b
4 files changed
+69
No files matched your search
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Added
|
### Added
|
||||||
- Add watched videos to Invidious watch history
|
- Add watched videos to Invidious watch history
|
||||||
- App info screen
|
- 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
|
### Fixed
|
||||||
- A crash where the metadata of a video is not validated [#57](https://github.com/iBicha/playlet/issues/57)
|
- 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")
|
RegistryUtils.Delete("search_history")
|
||||||
response.Default(204, "OK")
|
response.Default(204, "OK")
|
||||||
return true
|
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
|
end if
|
||||||
|
|
||||||
response.Default(400, `Invalid command: ${payload.command}`)
|
response.Default(400, `Invalid command: ${payload.command}`)
|
||||||
|
|||||||
@@ -69,7 +69,9 @@ function WebServerLoop()
|
|||||||
#if WEB_SERVER_BASIC_AUTH
|
#if WEB_SERVER_BASIC_AUTH
|
||||||
m.server.UseRouter(new Http.BasicAuthMiddleware())
|
m.server.UseRouter(new Http.BasicAuthMiddleware())
|
||||||
#end if
|
#end if
|
||||||
|
#if DEBUG
|
||||||
m.server.UseRouter(new Http.RegistryApiRouter())
|
m.server.UseRouter(new Http.RegistryApiRouter())
|
||||||
|
#end if
|
||||||
m.server.UseRouter(new Http.HttpDefaultRouter())
|
m.server.UseRouter(new Http.HttpDefaultRouter())
|
||||||
|
|
||||||
timeout = m.settings.Timeout
|
timeout = m.settings.Timeout
|
||||||
|
|||||||
@@ -76,6 +76,15 @@
|
|||||||
<h5>Feedback is welcome over at: <a id="feedback-url" href="https://github.com/iBicha/playlet"
|
<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>
|
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>
|
<script>
|
||||||
function Login() {
|
function Login() {
|
||||||
if (!window.appState) {
|
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() {
|
function Initialize() {
|
||||||
fetch("/api/state")
|
fetch("/api/state")
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
@@ -293,6 +345,10 @@ ${JSON.stringify(window.appState.invidious, null, 2)}
|
|||||||
});
|
});
|
||||||
|
|
||||||
SetupWebSocket();
|
SetupWebSocket();
|
||||||
|
if(ShouldShowDevMenu()){
|
||||||
|
document.getElementById("dev-menu").style.display = "block";
|
||||||
|
FetchReleaseTags();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var tableRow;
|
var tableRow;
|
||||||
|
|||||||
Reference in new issue
Block a user