Compare commits

..

No commits in common. "458769c6e59476ba873633be803755f766351d8d" and "63956de837f5cf608524df892ebfac69f63a2029" have entirely different histories.

7 changed files with 9 additions and 49 deletions

View File

@ -22,7 +22,6 @@ const (
type Datapoint struct { type Datapoint struct {
ID int ID int
Group string
Name string Name string
Datatype DatapointType Datatype DatapointType
LastValue time.Time `db:"last_value"` LastValue time.Time `db:"last_value"`
@ -71,16 +70,14 @@ func (dp Datapoint) Update() (err error) {// {{{
if dp.ID == 0 { if dp.ID == 0 {
_, err = service.Db.Conn.Exec( _, err = service.Db.Conn.Exec(
`INSERT INTO datapoint("group", name, datatype) VALUES($1, $2, $3)`, `INSERT INTO datapoint(name, datatype) VALUES($1, $2)`,
dp.Group,
name, name,
dp.Datatype, dp.Datatype,
) )
} else { } else {
_, err = service.Db.Conn.Exec( _, err = service.Db.Conn.Exec(
`UPDATE datapoint SET "group"=$2, name=$3, datatype=$4 WHERE id=$1`, `UPDATE datapoint SET name=$2, datatype=$3 WHERE id=$1`,
dp.ID, dp.ID,
dp.Group,
name, name,
dp.Datatype, dp.Datatype,
) )
@ -134,7 +131,6 @@ func DatapointsRetrieve() (dps []Datapoint, err error) { // {{{
dp.name, dp.name,
dp.datatype, dp.datatype,
dp.last_value, dp.last_value,
dp.group,
dpv.id AS v_id, dpv.id AS v_id,
dpv.ts, dpv.ts,
@ -150,7 +146,6 @@ func DatapointsRetrieve() (dps []Datapoint, err error) { // {{{
FROM datapoint_value FROM datapoint_value
) dpv ON dpv.datapoint_id = dp.id AND rn = 1 ) dpv ON dpv.datapoint_id = dp.id AND rn = 1
ORDER BY ORDER BY
dp.group ASC,
dp.name ASC dp.name ASC
`) `)
if err != nil { if err != nil {
@ -160,7 +155,6 @@ func DatapointsRetrieve() (dps []Datapoint, err error) { // {{{
type DbRes struct { type DbRes struct {
ID int ID int
Group string
Name string Name string
Datatype DatapointType Datatype DatapointType
LastValue time.Time `db:"last_value"` LastValue time.Time `db:"last_value"`
@ -184,7 +178,6 @@ func DatapointsRetrieve() (dps []Datapoint, err error) { // {{{
dp.ID = res.ID dp.ID = res.ID
dp.Name = res.Name dp.Name = res.Name
dp.Group = res.Group
dp.Datatype = res.Datatype dp.Datatype = res.Datatype
dp.LastValue = res.LastValue dp.LastValue = res.LastValue
dp.Found = true dp.Found = true

View File

@ -26,7 +26,7 @@ import (
"time" "time"
) )
const VERSION = "v10" const VERSION = "v9"
var ( var (
logger *slog.Logger logger *slog.Logger
@ -555,7 +555,6 @@ func pageDatapointUpdate(w http.ResponseWriter, r *http.Request, _ *session.T) {
var dp Datapoint var dp Datapoint
dp.ID = id dp.ID = id
dp.Group = r.FormValue("group")
dp.Name = r.FormValue("name") dp.Name = r.FormValue("name")
dp.Datatype = DatapointType(r.FormValue("datatype")) dp.Datatype = DatapointType(r.FormValue("datatype"))
err = dp.Update() err = dp.Update()

View File

@ -1 +0,0 @@
ALTER TABLE datapoint ADD COLUMN "group" varchar NOT NULL DEFAULT '';

View File

@ -103,18 +103,8 @@ label {
grid-gap: 8px 16px; grid-gap: 8px 16px;
margin-top: 16px; margin-top: 16px;
} }
#datapoints .group {
font-size: 1.1em;
font-weight: bold;
color: #fabd2f;
margin-top: 1.5em;
padding-bottom: 4px;
border-bottom: unset;
}
#datapoints .header { #datapoints .header {
font-weight: 500; font-weight: 500;
font-size: 0.85em;
color: #d5c4a1;
} }
#datapoints div { #datapoints div {
white-space: nowrap; white-space: nowrap;

View File

@ -6,20 +6,8 @@
grid-gap: 8px 16px; grid-gap: 8px 16px;
margin-top: 16px; margin-top: 16px;
.group {
font-size: 1.10em;
font-weight: bold;
color: @color2;
margin-top: 1.5em;
padding-bottom: 4px;
border-bottom: unset;
}
.header { .header {
font-weight: @bold; font-weight: @bold;
font-size: 0.85em;
color: @text1;
} }
div { div {

View File

@ -10,9 +10,6 @@
<form id="form-trigger" action="/datapoint/update/{{ .Data.Datapoint.ID }}" method="post"> <form id="form-trigger" action="/datapoint/update/{{ .Data.Datapoint.ID }}" method="post">
<div id="widgets" class="widgets"> <div id="widgets" class="widgets">
<div class="label">Group</div>
<div><input type="text" name="group" value="{{ .Data.Datapoint.Group }}"></div>
<div class="label">Name</div> <div class="label">Name</div>
<div><input type="text" name="name" value="{{ .Data.Datapoint.Name }}"></div> <div><input type="text" name="name" value="{{ .Data.Datapoint.Name }}"></div>

View File

@ -7,19 +7,14 @@
<a href="/datapoint/edit/0">Create</a> <a href="/datapoint/edit/0">Create</a>
<div id="datapoints"> <div id="datapoints">
{{ $prevGroup := "kalle" }}
{{ range .Data.Datapoints }}
{{ if ne $prevGroup .Group }}
<div class="line group">{{ .Group }}</div>
<div class="header">Name</div> <div class="header">Name</div>
<div class="header">Datatype</div> <div class="header">Datatype</div>
<div class="header">Last value</div> <div class="header">Last value</div>
<div class="header">Value</div> <div class="header">Value</div>
<div class="header"></div> <div class="header"></div>
{{ else }} {{ range .Data.Datapoints }}
<div class="line"></div> <div class="line"></div>
{{ end }}
<div class="name"><a href="/datapoint/edit/{{ .ID }}">{{ .Name }}</a></div> <div class="name"><a href="/datapoint/edit/{{ .ID }}">{{ .Name }}</a></div>
<div class="datatype">{{ .Datatype }}</div> <div class="datatype">{{ .Datatype }}</div>
<div class="last-value">{{ format_time .LastValue }}</div> <div class="last-value">{{ format_time .LastValue }}</div>
@ -32,7 +27,6 @@
<div class="values"><a href="/datapoint/values/{{ .ID }}"><img src="/images/{{ $version }}/values.svg"></a></div> <div class="values"><a href="/datapoint/values/{{ .ID }}"><img src="/images/{{ $version }}/values.svg"></a></div>
<div class="delete"><a href="/datapoint/delete/{{ .ID }}" onclick="confirm(`Are you sure you want to delete '{{ .Name }}'?`)"><img src="/images/{{ $version }}/delete.svg"></a></div> <div class="delete"><a href="/datapoint/delete/{{ .ID }}" onclick="confirm(`Are you sure you want to delete '{{ .Name }}'?`)"><img src="/images/{{ $version }}/delete.svg"></a></div>
</div> </div>
{{ $prevGroup = .Group }}
{{ end }} {{ end }}
</div> </div>
{{ end }} {{ end }}