Compare commits

..

5 Commits

Author SHA1 Message Date
Magnus Åhall
63956de837 Bumped to v9 2024-05-20 18:58:17 +02:00
Magnus Åhall
e4dbabfea5 Fixed last updated value on datapoints 2024-05-20 18:57:47 +02:00
Magnus Åhall
7724c742ad Version parameter 2024-05-20 13:21:22 +02:00
Magnus Åhall
ff1c848c58 Bumped to v8 2024-05-20 13:19:22 +02:00
Magnus Åhall
787009c621 Removed fonts 2024-05-20 13:18:40 +02:00
5 changed files with 34 additions and 6 deletions

View File

@ -117,6 +117,8 @@ func DatapointAdd[T any](name string, value T) (err error) { // {{{
return
}
service.Db.Conn.Exec(`UPDATE datapoint SET last_value = NOW() WHERE name=$1`, name)
return
} // }}}

View File

@ -26,12 +26,13 @@ import (
"time"
)
const VERSION = "v7"
const VERSION = "v9"
var (
logger *slog.Logger
flagConfigFile string
flagDev bool
flagVersion bool
service *ws.Service
logFile *os.File
parsedTemplates map[string]*template.Template
@ -59,6 +60,7 @@ func init() { // {{{
cfgPath := path.Join(confDir, "smon.yaml")
flag.StringVar(&flagConfigFile, "config", cfgPath, "Path and filename of the YAML configuration file")
flag.BoolVar(&flagDev, "dev", false, "reload templates on each request")
flag.BoolVar(&flagVersion, "version", false, "Display version and exit")
flag.Parse()
componentFilenames, err = getComponentFilenames(viewFS)
@ -70,6 +72,11 @@ func init() { // {{{
} // }}}
func main() { // {{{
if flagVersion {
fmt.Println(VERSION)
os.Exit(0)
}
var err error
werr.Init()

View File

@ -1,6 +1,2 @@
{{ define "fonts" }}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap" rel="stylesheet">
{{ end }}

View File

@ -5,6 +5,18 @@
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
{{ template "fonts" }}
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/main.css">
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.2.1/dist/chart.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/luxon@3.3.0/build/global/luxon.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@1.3.1"></script>
<script type="importmap">
{
"imports": {
"chart.js": "/js/{{ .VERSION }}/lib/chartjs/index.d.ts"
}
}
</script>
</head>
<body>
<div id="layout">

View File

@ -2,8 +2,19 @@
{{ $version := .VERSION }}
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/datapoints.css">
<script type="module" defer>
import { DataGraph } from "/js/{{ .VERSION }}/datapoint_graph.mjs"
const graph = new DataGraph({{ .Data.Datapoint }})
graph.setData({{ .Data.Values }})
graph.render('chart')
</script>
{{ block "page_label" . }}{{end}}
<div>
<canvas id="chart"></canvas>
</div>
<div id="values">
{{ range .Data.Values }}
<div class="value">{{ format_time .Ts }}</div>