Update logging

This commit is contained in:
Laura Hausmann 2022-11-21 02:03:01 +01:00
parent 5408f1a1eb
commit 480cd8329c
Signed by: zotan
GPG key ID: D044E84C5BE01605
2 changed files with 13 additions and 5 deletions

View file

@ -21,7 +21,7 @@ else {
@if (Model.LogConditionsMet) {
<br/>
<a class="action-muted">[--]</a>
<a href="/log?artist=@Model.LogArtist&album=@Model.LogAlbum&url=@Model.LogUrl" target="_blank" class="entry-muted cfont"> Log playback</a>
<span id="log" onclick="get('/log?artist=@Model.LogArtist&album=@Model.LogAlbum&url=@Model.LogUrl')" class="entry-muted cfont"> Log playback</span>
}
<br/>
<a class="action-muted">[--]</a>
@ -51,3 +51,11 @@ else {
</li>
}
}
<script>
function get(url) {
fetch(url).then(function(response) {
document.getElementById('log').innerText = ' Log playback (' + response + ')';
});
}
</script>

View file

@ -24,10 +24,10 @@ public class Log : Controller {
Response.StatusCode = (int)res;
return res switch {
HttpStatusCode.Created => $"Logged: {artist} - {album}",
HttpStatusCode.Accepted => $"Skipped: {artist} - {album}",
HttpStatusCode.Forbidden => "Invalid token.",
_ => $"Error {Response.StatusCode} \"{res}\" occured."
HttpStatusCode.Created => $"Logged",
HttpStatusCode.Accepted => $"Skipped",
HttpStatusCode.Forbidden => "Invalid token",
_ => $"Error {Response.StatusCode} \"{res}\" occured"
};
}