Initial work

This commit is contained in:
jamesread 2021-05-31 21:16:30 +01:00
parent 0e06d22633
commit 1a8426a71d
6 changed files with 98 additions and 5 deletions

View File

@ -23,7 +23,7 @@ daemon-unittests:
go tool cover -html=reports/unittests.out -o reports/unittests.html
grpc:
protoc -I.:$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/ --go_out=. --go-grpc_out=. --grpc-gateway_out=. OliveTin.proto
protoc -I.:/home/xconspirisist/sandbox/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.16.0/third_party/googleapis/ --go_out=. --go-grpc_out=. --grpc-gateway_out=. OliveTin.proto
podman-image:
buildah bud -t olivetin

View File

@ -27,6 +27,17 @@ message StartActionResponse {
int32 exitCode = 4;
}
message GetLogsRequest{};
message LogEntry {
string datetime = 1;
string content = 2;
}
message GetLogsResponse {
repeated LogEntry logs = 1;
}
service OliveTinApi {
rpc GetButtons(GetButtonsRequest) returns (GetButtonsResponse) {
option (google.api.http) = {
@ -40,4 +51,10 @@ service OliveTinApi {
};
}
rpc GetLogs(GetLogsRequst) returns (GetLogsResponse) {
option (google.api.http) = {
get: "/api/GetLogs"
}
}
}

View File

@ -12,9 +12,26 @@
<body>
<main title = "main content">
<fieldset id = "rootGroup">
<legend>OliveTin Actions</legend>
<fieldset id = "switcher">
<button id = "showActions">Actions</button>
<button id = "showLogs">Logs</button>
</fieldset>
<section id = "contentLogs" title = "Logs" hidden>
<table>
<tr>
<td>12 seconds ago</td> <td>blat blat <button>Logs</button></td>
</tr>
<tr>
<td>4 seconds ago</td> <td>blat blat foo foo <button>Logs</button></td>
</tr>
</table>
</section>
<section id = "contentActions" title = "Actions" hidden >
<fieldset id = "rootGroup">
</fieldset>
</section>
</main>
<footer title = "footer">
<p><img title = "application icon" src = "OliveTinLogo.png" height = "1em" class = "logo" /> <a href = "http://github.com/jamesread/OliveTin" target = "_new">OliveTin</a></p>

View File

@ -44,6 +44,10 @@ class ActionButton extends window.HTMLButtonElement {
this.temporaryStatusMessage = '[ ' + temporaryStatusMessage + ' ]'
this.updateHtml()
this.classList.add(cssClass)
setTimeout(() => {
this.classList.remove(cssClass)
}, 1000);
}
onActionError (err) {
@ -52,6 +56,10 @@ class ActionButton extends window.HTMLButtonElement {
this.isWaiting = false
this.updateHtml()
this.classList.add('actionFailed')
setTimeout(() => {
this.classList.remove('actionFailed')
}, 1000);
}
constructTemplate () {

View File

@ -12,7 +12,23 @@ function showBigError (type, friendlyType, message) {
document.getElementById('rootGroup').appendChild(domErr)
}
function showSection (name) {
for (let otherName of ["Actions", "Logs"]) {
document.getElementById('show' + otherName).classList.remove('activeSection');
document.getElementById('content' + otherName).hidden = true;
}
document.getElementById('show' + name).classList.add('activeSection')
document.getElementById('content' + name).hidden = false;
}
function onInitialLoad (res) {
document.getElementById('showActions').onclick = () => { showSection('Actions') };
document.getElementById('showLogs').onclick = () => { showSection('Logs') }
showSection('Actions');
window.restBaseUrl = res.Rest
window.fetch(window.restBaseUrl + 'GetButtons', {

View File

@ -7,16 +7,47 @@ body {
margin: 0;
}
fieldset {
fieldset {
padding: 0;
}
fieldset#rootGroup {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
grid-template-rows: auto auto auto auto;
padding: 1em;
grid-gap: 1em;
text-align: center;
border: 0;
}
fieldset#switcher {
border: 0;
text-align: right;
margin-bottom: 1em;
}
fieldset#switcher button:first-child{
border-radius: 1em 0em 0em 1em;
}
fieldset#switcher button:last-child{
border-radius: 0 1em 1em 0;
}
table {
background-color: white;
border-collapse: collapse;
}
td {
border: 1px solid #efefef;
}
button.activeSection {
font-weight: bold;
}
legend {
padding-top: 1em;
}
@ -154,3 +185,7 @@ img.logo {
background-color: black;
}
}
main {
padding: 1em;
}