fun day
parent
4eb2117f21
commit
ac6bf30042
20
report.go
20
report.go
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
@ -27,20 +28,13 @@ func ReportSince(ctx context.Context, w io.Writer, s Storage, t time.Time) error
|
||||||
}
|
}
|
||||||
return nil, errors.New("not impl")
|
return nil, errors.New("not impl")
|
||||||
},
|
},
|
||||||
"null": func() any {
|
"json": func(foo string, args ...any) (any, error) {
|
||||||
return nil
|
switch foo {
|
||||||
},
|
case "Marshal":
|
||||||
"append": func(arr any, v any) (any, error) {
|
b, err := json.Marshal(args[0])
|
||||||
if v == nil {
|
return string(b), err
|
||||||
return arr, nil
|
|
||||||
}
|
}
|
||||||
switch arr := arr.(type) {
|
return nil, errors.New("not impl")
|
||||||
case []any:
|
|
||||||
return append(arr, v), nil
|
|
||||||
case nil:
|
|
||||||
return []any{v}, nil
|
|
||||||
}
|
|
||||||
return nil, errors.New("unknown type in append")
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
tmpl, err := tmpl.Parse(reportTMPL)
|
tmpl, err := tmpl.Parse(reportTMPL)
|
||||||
|
|
|
||||||
55
report.tmpl
55
report.tmpl
|
|
@ -1,11 +1,52 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<header>
|
<head>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import * as d3 from "https://cdn.jsdelivr.net/npm/d3@7/+esm";
|
import * as d3 from "https://cdn.jsdelivr.net/npm/d3@7/+esm";
|
||||||
</script>
|
</script>
|
||||||
|
<script>
|
||||||
|
const allMessages = {{ json "Marshal" .messages }};
|
||||||
|
console.log(allMessages);
|
||||||
|
|
||||||
|
function fillForm() {
|
||||||
|
const filterableFields = [
|
||||||
|
"EventName",
|
||||||
|
"Asset",
|
||||||
|
];
|
||||||
|
const fieldsToOptions = {};
|
||||||
|
filterableFields.map((field) => {fieldsToOptions[field] = {}});
|
||||||
|
allMessages.map((message) => {
|
||||||
|
Object.keys(fieldsToOptions).map((field) => {fieldsToOptions[field][message[field]] = true});
|
||||||
|
});
|
||||||
|
Object.keys(fieldsToOptions).map((field) => {fieldsToOptions[field] = Object.keys(fieldsToOptions[field])});
|
||||||
|
|
||||||
|
document.getElementById("form").innerHTML = Object.keys(fieldsToOptions).map((field) => {
|
||||||
|
}).join("");
|
||||||
|
|
||||||
|
console.log(fieldsToOptions);
|
||||||
|
`
|
||||||
|
<select name="filter1" multiple>
|
||||||
|
<option selected>a</option>
|
||||||
|
<option selected>b</option>
|
||||||
|
</select>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
function drawAll() {
|
||||||
|
const messages = filterMessages(allMessages)
|
||||||
|
drawEventVolumeByName(messages)
|
||||||
|
drawEventVolumeByWeekday(messages)
|
||||||
|
drawEventVolumeByHour(messages)
|
||||||
|
drawEventVolumeByAsset(messages)
|
||||||
|
}
|
||||||
|
function filterMessages(messages) {
|
||||||
|
}
|
||||||
|
function drawEventVolumeByName() {}
|
||||||
|
function drawEventVolumeByWeekday() {}
|
||||||
|
function drawEventVolumeByHour() {}
|
||||||
|
function drawEventVolumeByAsset() {}
|
||||||
|
</script>
|
||||||
<style>
|
<style>
|
||||||
rows {
|
rows {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
@ -19,14 +60,12 @@
|
||||||
}
|
}
|
||||||
rows, columns { border: 1px solid red; }
|
rows, columns { border: 1px solid red; }
|
||||||
</style>
|
</style>
|
||||||
</header>
|
</head>
|
||||||
<body>
|
<body onload="fillForm()">
|
||||||
<h1>Report</h1>
|
<h1>Report</h1>
|
||||||
<columns>
|
<columns>
|
||||||
<div style="width: 10em; flex-shrink: 0;">
|
<form id="form" style="width: 10em; flex-shrink: 0;" onchange="drawAll()">
|
||||||
<columns>filter1</columns>
|
</form>
|
||||||
<columns>filter2</columns>
|
|
||||||
</div>
|
|
||||||
<rows>
|
<rows>
|
||||||
<rows>
|
<rows>
|
||||||
<rows>
|
<rows>
|
||||||
|
|
@ -35,7 +74,7 @@
|
||||||
</rows>
|
</rows>
|
||||||
<columns>
|
<columns>
|
||||||
<rows>
|
<rows>
|
||||||
<h3>by Day</h3>
|
<h3>by Weekday</h3>
|
||||||
<div>DRAW ME</div>
|
<div>DRAW ME</div>
|
||||||
</rows>
|
</rows>
|
||||||
<rows>
|
<rows>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue