diff --git a/README.md b/README.md index eaed26c..618fc5c 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,8 @@ session: application: logfile: /var/log/smon.log - nodata_interval: 60 ``` # Data from systems to datapoints -`curl -d "$(time +'%F %T +02')" http://localhost:9000/entry/datapoint_name` +`curl -d "$(time +'%F %T +02')" http://localhost:9000/entry/datapoint_name` \ No newline at end of file diff --git a/main.go b/main.go index 9496441..b8d04e0 100644 --- a/main.go +++ b/main.go @@ -27,7 +27,7 @@ import ( "time" ) -const VERSION = "v17" +const VERSION = "v16" var ( logger *slog.Logger @@ -143,7 +143,6 @@ func main() { // {{{ service.Register("/trigger/addDatapoint/{id}/{datapointName}", false, false, pageTriggerDatapointAdd) service.Register("/trigger/update/{id}", false, false, pageTriggerUpdate) service.Register("/trigger/run/{id}", false, false, pageTriggerRun) - service.Register("/trigger/delete/{id}", false, false, actionTriggerDelete) service.Register("/configuration", false, false, pageConfiguration) service.Register("/entry/{datapoint}", false, false, entryDatapoint) @@ -696,7 +695,7 @@ func triggerCreate(w http.ResponseWriter, r *http.Request, _ *session.T) { // {{ } resp := struct { - OK bool + OK bool Trigger Trigger }{ true, @@ -863,23 +862,6 @@ func pageTriggerRun(w http.ResponseWriter, r *http.Request, _ *session.T) { // { w.Header().Add("Content-Type", "application/json") w.Write(j) } // }}} -func actionTriggerDelete(w http.ResponseWriter, r *http.Request, _ *session.T) { // {{{ - idStr := r.PathValue("id") - id, err := strconv.Atoi(idStr) - if err != nil { - httpError(w, werr.Wrap(err).Log()) - return - } - - err = TriggerDelete(id) - if err != nil { - httpError(w, werr.Wrap(err).Log()) - return - } - - w.Header().Add("Location", "/triggers") - w.WriteHeader(302) -} // }}} func pageConfiguration(w http.ResponseWriter, _ *http.Request, _ *session.T) { // {{{ areas, err := AreaRetrieve() diff --git a/static/css/index.css b/static/css/index.css index 5c0077f..97b1882 100644 --- a/static/css/index.css +++ b/static/css/index.css @@ -103,6 +103,7 @@ label { border-radius: 8px; } .graph { - margin-top: 192px; + margin-top: 32px; + padding: 32px; border-radius: 16px; } diff --git a/static/css/main.css b/static/css/main.css index a213f0d..eda60f3 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -201,6 +201,19 @@ label { #areas .area .section > .name { font-weight: 800; } +#areas .area .section .triggers .trigger { + display: grid; + grid-template-columns: min-content 1fr; + grid-gap: 8px; + align-items: center; + margin-top: 8px; +} +#areas .area .section .triggers .trigger img { + height: 16px; +} +#areas .area .section .triggers .trigger .label { + color: inherit; +} dialog { background: #202020; border: 1px solid #606060; diff --git a/static/css/triggers.css b/static/css/triggers.css deleted file mode 100644 index 352428d..0000000 --- a/static/css/triggers.css +++ /dev/null @@ -1,117 +0,0 @@ -html { - box-sizing: border-box; -} -*, -*:before, -*:after { - box-sizing: inherit; -} -*:focus { - outline: none; -} -[onClick] { - cursor: pointer; -} -html, -body { - margin: 0; - padding: 0; -} -body { - background: #282828; - font-family: sans-serif; - font-weight: 300; - color: #d5c4a1; - font-size: 11pt; -} -h1, -h2 { - margin-bottom: 4px; -} -h1:first-child, -h2:first-child { - margin-top: 0px; -} -h1 { - font-size: 1.5em; - color: #fb4934; - font-weight: 800; -} -h2 { - font-size: 1.25em; - color: #b8bb26; - font-weight: 800; -} -a { - color: #3f9da1; - text-decoration: none; -} -a:hover { - text-decoration: underline; -} -b { - font-weight: 800; -} -input[type="text"], -textarea, -select { - font-family: monospace; - background: #202020; - color: #d5c4a1; - padding: 4px 8px; - border: none; - font-size: 1em; - line-height: 1.5em; -} -button { - background: #202020; - color: #d5c4a1; - padding: 8px 32px; - border: 1px solid #535353; - font-size: 1em; - height: 3em; -} -button:focus { - background: #333; -} -.line { - grid-column: 1 / -1; - border-bottom: 1px solid #4e4e4e; -} -span.date { - color: #d5c4a1; - font-weight: 800; -} -span.time { - font-size: 0.9em; - color: #d5c4a1; -} -span.seconds { - display: none; -} -label { - user-select: none; -} -.description { - border: 1px solid #737373; - color: #3f9da1; - background: #202020; - padding: 4px 8px; - margin-top: 8px; - white-space: nowrap; - width: min-content; - border-radius: 8px; -} -#areas .area .section .triggers .trigger { - display: grid; - grid-template-columns: min-content 1fr min-content; - grid-gap: 8px; - align-items: center; - margin-top: 8px; -} -#areas .area .section .triggers .trigger img { - height: 16px; -} -#areas .area .section .triggers .trigger .label { - color: inherit; -} diff --git a/static/less/index.less b/static/less/index.less index 97eb0bb..7c65786 100644 --- a/static/less/index.less +++ b/static/less/index.less @@ -1,6 +1,7 @@ @import "theme.less"; .graph { - margin-top: 192px; + margin-top: 32px; + padding: 32px; border-radius: 16px; } diff --git a/static/less/main.less b/static/less/main.less index de80c87..0f061e2 100644 --- a/static/less/main.less +++ b/static/less/main.less @@ -117,6 +117,24 @@ &>.name { font-weight: @bold; } + + .triggers { + .trigger { + display: grid; + grid-template-columns: min-content 1fr; + grid-gap: 8px; + align-items: center; + margin-top: 8px; + + img { + height: 16px; + } + + .label { + color: inherit; + } + } + } } } } diff --git a/static/less/triggers.less b/static/less/triggers.less deleted file mode 100644 index 9fecbe5..0000000 --- a/static/less/triggers.less +++ /dev/null @@ -1,26 +0,0 @@ -@import 'theme.less'; - - -#areas { - .area { - .section { - .triggers { - .trigger { - display: grid; - grid-template-columns: min-content 1fr min-content; - grid-gap: 8px; - align-items: center; - margin-top: 8px; - - img { - height: 16px; - } - - .label { - color: inherit; - } - } - } - } - } -} diff --git a/trigger.go b/trigger.go index 6525598..6020f12 100644 --- a/trigger.go +++ b/trigger.go @@ -2,7 +2,7 @@ package main import ( // External - werr "git.gibonuddevalla.se/go/wrappederror" + we "git.gibonuddevalla.se/go/wrappederror" "github.com/expr-lang/expr" "github.com/lib/pq" @@ -67,7 +67,7 @@ func TriggersRetrieve() (areas []Area, err error) { // {{{ var jsonData []byte err = row.Scan(&jsonData) if err != nil { - err = werr.Wrap(err) + err = we.Wrap(err) return } @@ -77,7 +77,7 @@ func TriggersRetrieve() (areas []Area, err error) { // {{{ err = json.Unmarshal(jsonData, &areas) if err != nil { - err = werr.Wrap(err) + err = we.Wrap(err) return } @@ -97,13 +97,13 @@ func TriggersRetrieveByDatapoint(datapointName string) (triggers []Trigger, err var data []byte err = row.Scan(&data) if err != nil { - err = werr.Wrap(err).WithData(datapointName) + err = we.Wrap(err).WithData(datapointName) return } err = json.Unmarshal(data, &triggers) if err != nil { - err = werr.Wrap(err).WithData(datapointName) + err = we.Wrap(err).WithData(datapointName) return } @@ -114,7 +114,7 @@ func TriggerRetrieve(id int) (trigger Trigger, err error) { // {{{ var jsonData []byte err = row.Scan(&jsonData) if err != nil { - err = werr.Wrap(err) + err = we.Wrap(err) return } @@ -158,7 +158,7 @@ func (t *Trigger) Update() (err error) { // {{{ ) err = row.Scan(&t.ID) if err != nil { - err = werr.Wrap(err).WithData( + err = we.Wrap(err).WithData( struct { SectionID int Name string @@ -191,7 +191,7 @@ func (t *Trigger) Update() (err error) { // {{{ } if pqErr, ok := err.(*pq.Error); ok { - err = werr.Wrap(err).WithData( + err = we.Wrap(err).WithData( struct { Trigger *Trigger PostgresCode pq.ErrorCode @@ -202,14 +202,7 @@ func (t *Trigger) Update() (err error) { // {{{ pqErr.Code.Name(), }) } else if err != nil { - err = werr.Wrap(err).WithData(t) - } - return -} // }}} -func TriggerDelete(id int) (err error) { // {{{ - _, err = service.Db.Conn.Exec(`DELETE FROM public.trigger WHERE id=$1`, id) - if err != nil { - return werr.Wrap(err).WithData(id) + err = we.Wrap(err).WithData(t) } return } // }}} @@ -220,7 +213,7 @@ func (t *Trigger) Run() (output any, err error) { // {{{ var dp Datapoint dp, err = DatapointRetrieve(0, dpname) if err != nil { - err = werr.Wrap(err) + err = we.Wrap(err) return } datapoints[dpname] = dp diff --git a/views/pages/index.gotmpl b/views/pages/index.gotmpl index a922a56..718cc72 100644 --- a/views/pages/index.gotmpl +++ b/views/pages/index.gotmpl @@ -9,9 +9,9 @@

SMon

{{ .VERSION }}

+
+ +
-
- -
{{ end }} diff --git a/views/pages/triggers.gotmpl b/views/pages/triggers.gotmpl index a0a5bef..60baf48 100644 --- a/views/pages/triggers.gotmpl +++ b/views/pages/triggers.gotmpl @@ -2,7 +2,6 @@ {{ block "page_label" . }}{{end}} {{ $version := .VERSION }} -
@@ -49,11 +42,12 @@ {{ if eq .Name "" }} {{ continue }} {{ end }} -
- - - -
+ +
+ +
{{ .Name }}
+
+
{{ end }}