first try to set timer from web ui

This commit is contained in:
Marvin Preuss 2021-08-13 14:44:00 +02:00
parent 538de91555
commit b563f3890a
5 changed files with 11010 additions and 13 deletions

10881
assets/web/files/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
if(typeof(EventSource) !== "undefined") {
var source = new EventSource("/log");
source.onmessage = function(event) {
var j = JSON.parse(event.data);
if (j.hasOwnProperty('message')) {
document.getElementById("log").innerHTML += j.message + "<br>";
}
};
} else {
document.getElementById("log").innerHTML = "Sorry, your browser does not support server-sent events...";
}
$("#timerForm").submit(function(event){
event.preventDefault();
var $form = $(this),
duration = $form.find("input[name='s']").val(),
url = $form.attr("action");
$.ajax({
url: url,
type: "POST",
data: JSON.stringify({"duration": duration}),
contentType: "application/json",
dataType: "json"
});
})

View File

@ -0,0 +1,46 @@
{
"swagger": "2.0",
"info": {
"title": "google/api/annotations.proto",
"version": "version not set"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"protobufAny": {
"type": "object",
"properties": {
"typeUrl": {
"type": "string"
},
"value": {
"type": "string",
"format": "byte"
}
}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}

View File

@ -0,0 +1,46 @@
{
"swagger": "2.0",
"info": {
"title": "google/api/http.proto",
"version": "version not set"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"protobufAny": {
"type": "object",
"properties": {
"typeUrl": {
"type": "string"
},
"value": {
"type": "string",
"format": "byte"
}
}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}

View File

@ -10,6 +10,14 @@
<body>
<div class="container">
<h1>schnutibox</h1>
<h2>Timer</h2>
Takes only seconds. Example: 600s
<form action="/api/v1/timer" id="timerForm">
<input type="text" name="s" placeholder="600s">
<input type="submit" value="Set">
</form>
<h2>logs</h2>
<pre>
<code>
@ -17,18 +25,7 @@
</code>
</pre>
</div>
<script>
if(typeof(EventSource) !== "undefined") {
var source = new EventSource("/log");
source.onmessage = function(event) {
var j = JSON.parse(event.data);
if (j.hasOwnProperty('message')) {
document.getElementById("log").innerHTML += j.message + "<br>";
}
};
} else {
document.getElementById("log").innerHTML = "Sorry, your browser does not support server-sent events...";
}
</script>
<script src=/static/jquery.js></script>
<script src=/static/schnutibox.js></script>
</body>
</html>