Compare commits
No commits in common. "ac7ffcda23590ba805e99d26ffe7c58ae271c839" and "e549e18d44b524fa5eb55f58fb10b9feda6b6975" have entirely different histories.
ac7ffcda23
...
e549e18d44
@ -233,10 +233,3 @@ func DatapointRetrieve(id int, name string) (dp Datapoint, err error) { // {{{
|
|||||||
|
|
||||||
return
|
return
|
||||||
} // }}}
|
} // }}}
|
||||||
func DatapointDelete(id int) (err error) {// {{{
|
|
||||||
_, err = service.Db.Conn.Exec(`DELETE FROM datapoint WHERE id=$1`, id)
|
|
||||||
if err != nil {
|
|
||||||
err = we.Wrap(err).WithData(id)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}// }}}
|
|
||||||
|
20
main.go
20
main.go
@ -23,7 +23,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const VERSION = "v5"
|
const VERSION = "v4"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logger *slog.Logger
|
logger *slog.Logger
|
||||||
@ -111,7 +111,6 @@ func main() { // {{{
|
|||||||
service.Register("/datapoints", false, false, pageDatapoints)
|
service.Register("/datapoints", false, false, pageDatapoints)
|
||||||
service.Register("/datapoint/edit/{id}", false, false, pageDatapointEdit)
|
service.Register("/datapoint/edit/{id}", false, false, pageDatapointEdit)
|
||||||
service.Register("/datapoint/update/{id}", false, false, pageDatapointUpdate)
|
service.Register("/datapoint/update/{id}", false, false, pageDatapointUpdate)
|
||||||
service.Register("/datapoint/delete/{id}", false, false, pageDatapointDelete)
|
|
||||||
|
|
||||||
service.Register("/triggers", false, false, pageTriggers)
|
service.Register("/triggers", false, false, pageTriggers)
|
||||||
service.Register("/trigger/edit/{id}", false, false, pageTriggerEdit)
|
service.Register("/trigger/edit/{id}", false, false, pageTriggerEdit)
|
||||||
@ -492,23 +491,6 @@ func pageDatapointUpdate(w http.ResponseWriter, r *http.Request, _ *session.T) {
|
|||||||
w.Header().Add("Location", "/datapoints")
|
w.Header().Add("Location", "/datapoints")
|
||||||
w.WriteHeader(302)
|
w.WriteHeader(302)
|
||||||
} // }}}
|
} // }}}
|
||||||
func pageDatapointDelete(w http.ResponseWriter, r *http.Request, _ *session.T) { // {{{
|
|
||||||
idStr := r.PathValue("id")
|
|
||||||
id, err := strconv.Atoi(idStr)
|
|
||||||
if err != nil {
|
|
||||||
httpError(w, we.Wrap(err).Log())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err = DatapointDelete(id)
|
|
||||||
if err != nil {
|
|
||||||
httpError(w, we.Wrap(err).Log())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
w.Header().Add("Location", "/datapoints")
|
|
||||||
w.WriteHeader(302)
|
|
||||||
} // }}}
|
|
||||||
|
|
||||||
func pageTriggers(w http.ResponseWriter, _ *http.Request, _ *session.T) { // {{{
|
func pageTriggers(w http.ResponseWriter, _ *http.Request, _ *session.T) { // {{{
|
||||||
areas, err := TriggersRetrieve()
|
areas, err := TriggersRetrieve()
|
||||||
|
@ -99,7 +99,7 @@ label {
|
|||||||
}
|
}
|
||||||
#datapoints {
|
#datapoints {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(5, min-content);
|
grid-template-columns: repeat(4, min-content);
|
||||||
grid-gap: 8px 16px;
|
grid-gap: 8px 16px;
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
}
|
}
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
|
|
||||||
<svg
|
|
||||||
width="16.000025"
|
|
||||||
height="18"
|
|
||||||
viewBox="0 0 4.2333398 4.7625001"
|
|
||||||
version="1.1"
|
|
||||||
id="svg8"
|
|
||||||
inkscape:version="1.3.2 (1:1.3.2+202311252150+091e20ef0f)"
|
|
||||||
sodipodi:docname="delete.svg"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
||||||
xmlns:cc="http://creativecommons.org/ns#"
|
|
||||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
|
||||||
<defs
|
|
||||||
id="defs2" />
|
|
||||||
<sodipodi:namedview
|
|
||||||
id="base"
|
|
||||||
pagecolor="#ffffff"
|
|
||||||
bordercolor="#666666"
|
|
||||||
borderopacity="1.0"
|
|
||||||
inkscape:pageopacity="0.0"
|
|
||||||
inkscape:pageshadow="2"
|
|
||||||
inkscape:zoom="0.70710678"
|
|
||||||
inkscape:cx="-458.9123"
|
|
||||||
inkscape:cy="132.93608"
|
|
||||||
inkscape:document-units="px"
|
|
||||||
inkscape:current-layer="layer1"
|
|
||||||
showgrid="false"
|
|
||||||
units="px"
|
|
||||||
inkscape:window-width="2190"
|
|
||||||
inkscape:window-height="1404"
|
|
||||||
inkscape:window-x="1463"
|
|
||||||
inkscape:window-y="16"
|
|
||||||
inkscape:window-maximized="0"
|
|
||||||
inkscape:showpageshadow="true"
|
|
||||||
inkscape:pagecheckerboard="0"
|
|
||||||
inkscape:deskcolor="#d6d6d6"
|
|
||||||
showborder="true" />
|
|
||||||
<metadata
|
|
||||||
id="metadata5">
|
|
||||||
<rdf:RDF>
|
|
||||||
<cc:Work
|
|
||||||
rdf:about="">
|
|
||||||
<dc:format>image/svg+xml</dc:format>
|
|
||||||
<dc:type
|
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
|
||||||
</cc:Work>
|
|
||||||
</rdf:RDF>
|
|
||||||
</metadata>
|
|
||||||
<g
|
|
||||||
inkscape:label="Layer 1"
|
|
||||||
inkscape:groupmode="layer"
|
|
||||||
id="layer1"
|
|
||||||
transform="translate(-214.57708,-116.15208)">
|
|
||||||
<title
|
|
||||||
id="title1">trash-can-outline</title>
|
|
||||||
<path
|
|
||||||
d="m 215.9,116.15208 v 0.26459 h -1.32292 v 0.52916 h 0.26459 v 3.43959 a 0.52916667,0.52916667 0 0 0 0.52916,0.52916 h 2.64584 a 0.52916667,0.52916667 0 0 0 0.52916,-0.52916 v -3.43959 h 0.26459 v -0.52916 h -1.32292 v -0.26459 H 215.9 m -0.52917,0.79375 h 2.64584 v 3.43959 h -2.64584 v -3.43959 M 215.9,117.475 v 2.38125 h 0.52917 V 117.475 H 215.9 m 1.05833,0 v 2.38125 h 0.52917 V 117.475 Z"
|
|
||||||
id="path1"
|
|
||||||
style="fill:#fb4934;fill-opacity:1;stroke-width:0.264583" />
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 2.3 KiB |
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#datapoints {
|
#datapoints {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(5, min-content);
|
grid-template-columns: repeat(4, min-content);
|
||||||
grid-gap: 8px 16px;
|
grid-gap: 8px 16px;
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{{ define "page" }}
|
{{ define "page" }}
|
||||||
{{ $version := .VERSION }}
|
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/datapoints.css">
|
||||||
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/datapoints.css">
|
|
||||||
|
|
||||||
{{ block "page_label" . }}{{end}}
|
{{ block "page_label" . }}{{end}}
|
||||||
|
|
||||||
@ -11,7 +10,6 @@
|
|||||||
<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>
|
|
||||||
|
|
||||||
{{ range .Data.Datapoints }}
|
{{ range .Data.Datapoints }}
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
@ -22,8 +20,8 @@
|
|||||||
<div class="value">{{ if .LastDatapointValue.ValueDateTime.Valid }}{{ format_time .LastDatapointValue.Value }}{{ end }}</div>
|
<div class="value">{{ if .LastDatapointValue.ValueDateTime.Valid }}{{ format_time .LastDatapointValue.Value }}{{ end }}</div>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<div class="value">{{ .LastDatapointValue.Value }}</div>
|
<div class="value">{{ .LastDatapointValue.Value }}</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<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>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
Loading…
Reference in New Issue
Block a user