diff --git a/main.go b/main.go index ad13df4..cc67c04 100644 --- a/main.go +++ b/main.go @@ -535,15 +535,7 @@ func pageProblems(w http.ResponseWriter, r *http.Request, _ *session.T) { // {{{ return } - // GET parameters for this page - var selection string - if r.URL.Query().Get("selection") == "all" { - selection = "ALL" - } else { - selection = "CURRENT" - } - - problems, err := ProblemsRetrieve(selection == "ALL", timeFrom, timeTo) + problems, err := ProblemsRetrieve(true, timeFrom, timeTo) if err != nil { httpError(w, werr.Wrap(err).Log()) return @@ -568,9 +560,7 @@ func pageProblems(w http.ResponseWriter, r *http.Request, _ *session.T) { // {{{ page.Data = map[string]any{ "Problems": problems, "ProblemsGrouped": problemsGrouped, - "Selection": selection, - "TimeHidden": selection == "CURRENT", "TimeSubmit": "/problems", "TimeFrom": timeFrom.Format("2006-01-02T15:04:05"), "TimeTo": timeTo.Format("2006-01-02T15:04:05"), diff --git a/problem.go b/problem.go index 425dc63..24f8151 100644 --- a/problem.go +++ b/problem.go @@ -26,7 +26,7 @@ type Problem struct { // {{{ SectionName string `json:"section_name"` } // }}} -func ProblemsRetrieve(showCurrent bool, from, to time.Time) (problems []Problem, err error) { // {{{ +func ProblemsRetrieve(archived bool, from, to time.Time) (problems []Problem, err error) { // {{{ problems = []Problem{} row := service.Db.Conn.QueryRow(` SELECT @@ -39,23 +39,20 @@ func ProblemsRetrieve(showCurrent bool, from, to time.Time) (problems []Problem, p.acknowledged, p.datapoints, t.id AS trigger_id, - p.trigger_name AS trigger_name, + t.name AS trigger_name, a.name AS area_name, s.name AS section_name FROM problem p - LEFT JOIN "trigger" t ON p.trigger_id = t.id - LEFT JOIN section s ON t.section_id = s.id - LEFT JOIN area a ON s.area_id = a.id + INNER JOIN "trigger" t ON p.trigger_id = t.id + INNER JOIN section s ON t.section_id = s.id + INNER JOIN area a ON s.area_id = a.id WHERE CASE - WHEN NOT $1 THEN p.end IS NULL - WHEN $1 THEN - p.start >= $2 AND - ( - p.end IS NULL OR - p.end <= $3 - ) - END + WHEN $1 THEN true + WHEN NOT $1 THEN p.end IS NULL + END AND + p.start >= $2 AND + p.end <= $3 ORDER BY p.start DESC) @@ -64,7 +61,7 @@ func ProblemsRetrieve(showCurrent bool, from, to time.Time) (problems []Problem, (SELECT -1 AS id, - dp.last_value, + null, null, false, '{}', @@ -81,7 +78,7 @@ func ProblemsRetrieve(showCurrent bool, from, to time.Time) (problems []Problem, ORDER BY dp.name ASC) ) AS problems`, - showCurrent, + archived, from, to, ) @@ -125,9 +122,8 @@ func ProblemStart(trigger Trigger) (problemID int, err error) { // {{{ if openProblems == 0 { datapointValuesJson, _ := json.Marshal(trigger.DatapointValues) row = service.Db.Conn.QueryRow( - `INSERT INTO problem(trigger_id, trigger_name, datapoints, trigger_expression) VALUES($1, $2, $3, $4) RETURNING id`, + `INSERT INTO problem(trigger_id, datapoints, trigger_expression) VALUES($1, $2, $3) RETURNING id`, trigger.ID, - trigger.Name, datapointValuesJson, trigger.Expression, ) diff --git a/static/css/default_light/gruvbox.css b/static/css/default_light/gruvbox.css index f2b59e8..d0860ec 100644 --- a/static/css/default_light/gruvbox.css +++ b/static/css/default_light/gruvbox.css @@ -13,12 +13,3 @@ body { background-color: #a00; text-align: center; } -span.error { - color: #f66; -} -input[type="datetime-local"] { - background-color: #1b4e78; - color: #ccc; - border: 1px solid #535353; - padding: 6px; -} diff --git a/static/css/default_light/main.css b/static/css/default_light/main.css index 9189a40..4bae369 100644 --- a/static/css/default_light/main.css +++ b/static/css/default_light/main.css @@ -213,12 +213,6 @@ span.time { span.seconds { display: none; } -span.ok { - color: #0a0; -} -span.error { - color: #a00; -} label { user-select: none; } @@ -239,9 +233,6 @@ label { width: min-content; border-radius: 6px; } -#time-selector.hidden { - display: none; -} #time-selector button { width: 100px; margin-top: 12px; diff --git a/static/css/default_light/notifications.css b/static/css/default_light/notifications.css index f294e27..9dee5c0 100644 --- a/static/css/default_light/notifications.css +++ b/static/css/default_light/notifications.css @@ -21,3 +21,9 @@ input[type="datetime-local"] { font-weight: 800; color: #7bb8eb; } +#notifications .ok { + color: #0a0; +} +#notifications .error { + color: #a00; +} diff --git a/static/css/default_light/problems.css b/static/css/default_light/problems.css index 85cb0b5..b8d440b 100644 --- a/static/css/default_light/problems.css +++ b/static/css/default_light/problems.css @@ -45,7 +45,7 @@ } #areas .area .section { display: grid; - grid-template-columns: repeat(4, min-content); + grid-template-columns: repeat(3, min-content); grid-gap: 8px 12px; } #areas .area .section .name { diff --git a/static/css/gruvbox/gruvbox.css b/static/css/gruvbox/gruvbox.css index 400e861..d0860ec 100644 --- a/static/css/gruvbox/gruvbox.css +++ b/static/css/gruvbox/gruvbox.css @@ -13,12 +13,3 @@ body { background-color: #a00; text-align: center; } -span.error { - color: #f66; -} -input[type="datetime-local"] { - background-color: #202020; - color: #ccc; - border: 1px solid #535353; - padding: 6px; -} diff --git a/static/css/gruvbox/main.css b/static/css/gruvbox/main.css index 6d2377f..727b671 100644 --- a/static/css/gruvbox/main.css +++ b/static/css/gruvbox/main.css @@ -213,12 +213,6 @@ span.time { span.seconds { display: none; } -span.ok { - color: #0a0; -} -span.error { - color: #a00; -} label { user-select: none; } @@ -239,9 +233,6 @@ label { width: min-content; border-radius: 6px; } -#time-selector.hidden { - display: none; -} #time-selector button { width: 100px; margin-top: 12px; diff --git a/static/css/gruvbox/notifications.css b/static/css/gruvbox/notifications.css index 601d899..1cc900e 100644 --- a/static/css/gruvbox/notifications.css +++ b/static/css/gruvbox/notifications.css @@ -21,3 +21,9 @@ input[type="datetime-local"] { font-weight: 800; color: #777; } +#notifications .ok { + color: #0a0; +} +#notifications .error { + color: #a00; +} diff --git a/static/css/gruvbox/problems.css b/static/css/gruvbox/problems.css index 7670ba8..0e69462 100644 --- a/static/css/gruvbox/problems.css +++ b/static/css/gruvbox/problems.css @@ -45,7 +45,7 @@ } #areas .area .section { display: grid; - grid-template-columns: repeat(4, min-content); + grid-template-columns: repeat(3, min-content); grid-gap: 8px 12px; } #areas .area .section .name { diff --git a/static/js/problems.mjs b/static/js/problems.mjs index 8f45b3e..1e2361f 100644 --- a/static/js/problems.mjs +++ b/static/js/problems.mjs @@ -34,14 +34,6 @@ export class UI { } } - selectCurrent() { - location.href = '/problems?selection=current' - } - - selectAll() { - location.href = '/problems?selection=all' - } - displayList() { document.querySelector('.display-list').classList.remove('hidden') document.querySelector('.display-areas').classList.add('hidden') diff --git a/static/less/gruvbox.less b/static/less/gruvbox.less index 7fa24ef..04e8977 100644 --- a/static/less/gruvbox.less +++ b/static/less/gruvbox.less @@ -20,14 +20,3 @@ body { background-color: #a00; text-align: center; } - -span.error { - color: #f66; -} - -input[type="datetime-local"] { - background-color: @bg2; - color: #ccc; - border: 1px solid #535353; - padding: 6px; -} diff --git a/static/less/main.less b/static/less/main.less index dc4e7d5..689ca8f 100644 --- a/static/less/main.less +++ b/static/less/main.less @@ -266,14 +266,6 @@ span.seconds { display: none; } -span.ok { - color: #0a0; -} - -span.error { - color: #a00; -} - label { user-select: none; } @@ -297,10 +289,6 @@ label { width: min-content; border-radius: 6px; - &.hidden { - display: none; - } - button { width: 100px; margin-top: 12px; diff --git a/static/less/notifications.less b/static/less/notifications.less index 6c9ee4e..48a9614 100644 --- a/static/less/notifications.less +++ b/static/less/notifications.less @@ -25,4 +25,12 @@ input[type="datetime-local"] { font-weight: @bold; color: @text3; } + + .ok { + color: #0a0; + } + + .error { + color: #a00; + } } diff --git a/static/less/problems.less b/static/less/problems.less index 92d3723..79f711f 100644 --- a/static/less/problems.less +++ b/static/less/problems.less @@ -51,7 +51,7 @@ .area { .section { display: grid; - grid-template-columns: repeat(4, min-content); + grid-template-columns: repeat(3, min-content); grid-gap: 8px 12px; .name { diff --git a/views/components/timefilter.gotmpl b/views/components/timefilter.gotmpl index 0944254..8742015 100644 --- a/views/components/timefilter.gotmpl +++ b/views/components/timefilter.gotmpl @@ -14,7 +14,7 @@ -
+ diff --git a/views/pages/datapoint_values.gotmpl b/views/pages/datapoint_values.gotmpl index 3aa49e0..40895ae 100644 --- a/views/pages/datapoint_values.gotmpl +++ b/views/pages/datapoint_values.gotmpl @@ -7,22 +7,19 @@ {{ block "page_label" . }}{{end}} - {{ block "timefilter" . }}{{ end }} - - {{ if eq .Data.Datapoint.Datatype "INT" }} -
+
- {{ end }} + + {{ block "timefilter" . }}{{ end }} {{ if $graph }} diff --git a/views/pages/problems.gotmpl b/views/pages/problems.gotmpl index 48a4510..a258601 100644 --- a/views/pages/problems.gotmpl +++ b/views/pages/problems.gotmpl @@ -11,22 +11,15 @@ {{ block "page_label" . }}{{ end }}
- - -
- -
- - {{ block "timefilter" . }}{{ end }} - -
+ {{ block "timefilter" . }}{{ end }} + - - {{ end }}