remove public from gitignore

master
bel 2020-03-15 16:41:55 +00:00
parent a6ea7a79e8
commit fe6e721d84
5 changed files with 126 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,5 +1,4 @@
gollum
public
**.sw*
**/**.sw*
*.sw*

33
public/css/water.css Executable file

File diff suppressed because one or more lines are too long

0
public/favicon.ico Executable file
View File

29
public/index.html Executable file
View File

@ -0,0 +1,29 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="/css/water.css"/>
</head>
<body>
<h1>
Firestormy
</h1>
<details>
<summary>Upsert Job</summary>
<form id="upserts" action="#" method="get" onsubmit="upserts(); return false;">
<input type="text" name="id" placeholder="id"/>
<select name="language" required>
<option value="bash" selected>bash</option>
</select>
<input type="text" name="cron" placeholder="cron" value="@daily"/>
<textarea name="script" placeholder="script" required rows="5"></textarea>
<button type="submit">Upsert</button>
</form>
</details>
<table id="jobs">
<tbody>
</tbody>
</table>
</body>
<footer>
<script src="/js/js.js"></script>
</footer>
</html>

64
public/js/js.js Executable file
View File

@ -0,0 +1,64 @@
function http(method, remote, callback, body) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == XMLHttpRequest.DONE) {
callback(xmlhttp.responseText, xmlhttp.status)
}
};
xmlhttp.open(method, remote, true);
if (typeof body == "undefined") {
body = null
}
xmlhttp.send(body);
}
function upserts() {
function cb(body, status) {
console.log(status, body)
}
http("POST", "/upserts", cb, jsonifyForm("upserts"))
}
function jsonifyForm(id) {
var form = document.getElementById(id)
var entries = new FormData(form).entries();
var json = Object.assign(...Array.from(entries, ([x,y]) => ({[x]:y})));
var s = JSON.stringify(json)
return s
}
function init() {
function cb(body, status) {
var jobs = JSON.parse(body)
jobs.forEach(function(job) {
var s = format(job)
inject(s)
console.log("job=", job)
console.log("s=", s)
})
}
function format(job) {
return `<tr><td><details>
<summary>(${job.last.status}) ${job.id}</summary>
<table>
<tr>
<td><code>${job.cron}</code></td>
<td><code>${job.language}</code></td>
<td><code>${job.script}</code></td>
</tr>
<tr>
<td><code>${job.last.run}</code></td>
<td><code>${job.last.runtime}</code></td>
<td><code>${job.last.output}</code></td>
</tr>
</table>
</details></td></tr>`
}
function inject(s) {
var table = document.getElementById("jobs").getElementsByTagName("tbody")[0]
table.innerHTML += s
}
http("GET", "/list", cb, null)
}
init()