diff --git a/datapoint.go b/datapoint.go index 02acec4..084e4bf 100644 --- a/datapoint.go +++ b/datapoint.go @@ -25,6 +25,7 @@ type Datapoint struct { Group string Name string Datatype DatapointType + Comment string LastValue time.Time `db:"last_value"` DatapointValueJSON []byte `db:"datapoint_value_json"` LastDatapointValue DatapointValue @@ -73,11 +74,12 @@ func (dp Datapoint) Update() (err error) { // {{{ if dp.ID == 0 { _, err = service.Db.Conn.Exec( - `INSERT INTO datapoint("group", name, datatype, nodata_problem_seconds) VALUES($1, $2, $3, $4)`, + `INSERT INTO datapoint("group", name, datatype, nodata_problem_seconds, comment) VALUES($1, $2, $3, $4, $5)`, dp.Group, name, dp.Datatype, dp.NodataProblemSeconds, + dp.Comment, ) } else { /* Keep nodata_is_problem as is unless the nodata_problem_seconds is changed. @@ -90,10 +92,11 @@ func (dp Datapoint) Update() (err error) { // {{{ "group"=$2, name=$3, datatype=$4, - nodata_problem_seconds=$5, + comment=$5, + nodata_problem_seconds=$6, nodata_is_problem = ( CASE - WHEN $5 != nodata_problem_seconds THEN false + WHEN $6 != nodata_problem_seconds THEN false ELSE nodata_is_problem END @@ -105,6 +108,7 @@ func (dp Datapoint) Update() (err error) { // {{{ dp.Group, name, dp.Datatype, + dp.Comment, dp.NodataProblemSeconds, ) } @@ -161,6 +165,7 @@ func DatapointsRetrieve() (dps []Datapoint, err error) { // {{{ dp.datatype, dp.last_value, dp.group, + dp.comment, dp.nodata_problem_seconds, dpv.id AS v_id, @@ -190,6 +195,7 @@ func DatapointsRetrieve() (dps []Datapoint, err error) { // {{{ Group string Name string Datatype DatapointType + Comment string LastValue time.Time `db:"last_value"` NodataProblemSeconds int `db:"nodata_problem_seconds"` @@ -214,6 +220,7 @@ func DatapointsRetrieve() (dps []Datapoint, err error) { // {{{ dp.Name = res.Name dp.Group = res.Group dp.Datatype = res.Datatype + dp.Comment = res.Comment dp.LastValue = res.LastValue dp.Found = true dp.NodataProblemSeconds = res.NodataProblemSeconds diff --git a/main.go b/main.go index c3919fa..569d99f 100644 --- a/main.go +++ b/main.go @@ -626,6 +626,7 @@ func actionDatapointUpdate(w http.ResponseWriter, r *http.Request, _ *session.T) dp.Group = r.FormValue("group") dp.Name = r.FormValue("name") dp.Datatype = DatapointType(r.FormValue("datatype")) + dp.Comment = r.FormValue("comment") dp.NodataProblemSeconds = nodataSeconds err = dp.Update() if err != nil { diff --git a/sql/00017.sql b/sql/00017.sql new file mode 100644 index 0000000..8603963 --- /dev/null +++ b/sql/00017.sql @@ -0,0 +1 @@ +ALTER TABLE public.datapoint ADD COLUMN comment VARCHAR DEFAULT '' NOT NULL; diff --git a/static/css/datapoints.css b/static/css/datapoints.css index 0057c02..3baa3b0 100644 --- a/static/css/datapoints.css +++ b/static/css/datapoints.css @@ -125,12 +125,16 @@ label { } #datapoints div { white-space: nowrap; + align-self: center; } #datapoints .icons { display: flex; gap: 12px; align-items: center; } +#datapoints img.info { + height: 20px; +} #values { display: grid; grid-template-columns: repeat(2, min-content); diff --git a/static/images/info-filled.svg b/static/images/info-filled.svg new file mode 100644 index 0000000..71e7cb2 --- /dev/null +++ b/static/images/info-filled.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + information-slab-circle + information + + + diff --git a/static/images/info-outline.svg b/static/images/info-outline.svg new file mode 100644 index 0000000..e53a3ce --- /dev/null +++ b/static/images/info-outline.svg @@ -0,0 +1,71 @@ + + + + + + + + + + image/svg+xml + + + + + + information-slab-circle + information-slab-circle-outline + information-outline + + + diff --git a/static/less/datapoints.less b/static/less/datapoints.less index b8ce8c5..8ecc09a 100644 --- a/static/less/datapoints.less +++ b/static/less/datapoints.less @@ -13,6 +13,7 @@ margin-top: 1.5em; padding-bottom: 4px; } + h2 { border-bottom: unset; } @@ -26,6 +27,7 @@ div { white-space: nowrap; + align-self: center; } .icons { @@ -33,6 +35,10 @@ gap: 12px; align-items: center; } + + img.info { + height: 20px; + } } #values { diff --git a/views/pages/datapoint_edit.gotmpl b/views/pages/datapoint_edit.gotmpl index 9d65b50..12b2fc2 100644 --- a/views/pages/datapoint_edit.gotmpl +++ b/views/pages/datapoint_edit.gotmpl @@ -32,6 +32,12 @@
Set to 0 to disable.
+
Comment
+
+ +
+ +
{{ if eq .Data.Datapoint.ID 0 }} diff --git a/views/pages/datapoints.gotmpl b/views/pages/datapoints.gotmpl index 1300e55..aa3327b 100644 --- a/views/pages/datapoints.gotmpl +++ b/views/pages/datapoints.gotmpl @@ -31,6 +31,11 @@
{{ .LastDatapointValue.Value }}
{{ end }}
+ {{ if eq .Comment "" }} +
+ {{ else }} +
+ {{ end }}