add feature for read-only devs (prefixed with @)
This commit is contained in:
parent
5548949e9d
commit
7aaf75d1f1
|
|
@ -12,6 +12,9 @@ func Contains(a []string, x string) bool {
|
||||||
if x == n {
|
if x == n {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if "@" + x == n {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
main.go
10
main.go
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func serveTemplate(w http.ResponseWriter, r *http.Request) {
|
func serveTemplate(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
@ -47,7 +48,14 @@ func serveTemplate(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.Path == "/scales.html" {
|
if r.URL.Path == "/scales.html" {
|
||||||
// wir holen noch die letzten Metriken
|
// wir holen noch die letzten Metriken
|
||||||
for _, v := range scales {
|
for _, v := range scales {
|
||||||
last_metric := getLastMetrics(v)
|
deveui := v
|
||||||
|
readonly := false
|
||||||
|
if strings.HasPrefix(deveui, "@") {
|
||||||
|
deveui = deveui[1:]
|
||||||
|
readonly = true
|
||||||
|
}
|
||||||
|
last_metric := getLastMetrics(deveui)
|
||||||
|
last_metric.Readonly = readonly
|
||||||
last_metrics = append(last_metrics, last_metric)
|
last_metrics = append(last_metrics, last_metric)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import (
|
||||||
type OneMetric struct {
|
type OneMetric struct {
|
||||||
Deveui string
|
Deveui string
|
||||||
Alias string
|
Alias string
|
||||||
|
Readonly bool
|
||||||
Alarmactive string
|
Alarmactive string
|
||||||
Smsnumber string
|
Smsnumber string
|
||||||
Timestamp string
|
Timestamp string
|
||||||
|
|
@ -346,6 +347,7 @@ func getLastMetrics(deveui string) OneMetric {
|
||||||
}
|
}
|
||||||
res.Deveui = deveui
|
res.Deveui = deveui
|
||||||
res.Alias = getDevAlias(deveui)
|
res.Alias = getDevAlias(deveui)
|
||||||
|
res.Readonly = false
|
||||||
res.Alarmactive = getDevAlarmactive(deveui)
|
res.Alarmactive = getDevAlarmactive(deveui)
|
||||||
res.Smsnumber = getDevSmsnumber(deveui)
|
res.Smsnumber = getDevSmsnumber(deveui)
|
||||||
res.ActiveUntil = getActiveUntil(deveui)
|
res.ActiveUntil = getActiveUntil(deveui)
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ Sie erhalten eine E-Mail, sobald die Zahlung erfolgreich abgeschlossen ist.
|
||||||
|
|
||||||
{{range .LastMetrics}}
|
{{range .LastMetrics}}
|
||||||
<div class="column waage is-full notification is-warning">
|
<div class="column waage is-full notification is-warning">
|
||||||
<p class="is-size-2 is-size-5-mobile has-text-centered has-text-weight-bold" ><span class="alias" id="alias_{{.Deveui}}">{{.Alias}}</span><a class="show-modal" class="block-link"><span style="float:right;" class="icon is-size-4 is-size-5-mobile"><i class="fa fa-cog"></i></span></a></p>
|
<p class="is-size-2 is-size-5-mobile has-text-centered has-text-weight-bold" ><span class="alias" id="alias_{{.Deveui}}">{{.Alias}}</span>{{ if not .Readonly }}<a class="show-modal" class="block-link"><span style="float:right;" class="icon is-size-4 is-size-5-mobile"><i class="fa fa-cog"></i></span></a>{{ end }}</p>
|
||||||
<p id="alarmactive_{{.Deveui}}" hidden>{{.Alarmactive}}</p>
|
<p id="alarmactive_{{.Deveui}}" hidden>{{.Alarmactive}}</p>
|
||||||
<p id="smsnumber_{{.Deveui}}" hidden>{{.Smsnumber}}</p>
|
<p id="smsnumber_{{.Deveui}}" hidden>{{.Smsnumber}}</p>
|
||||||
<p id="lastmeasurement_{{.Deveui}}" class="has-text-centered">letzte übermittelte Messung: {{.Timestamp}}</p>
|
<p id="lastmeasurement_{{.Deveui}}" class="has-text-centered">letzte übermittelte Messung: {{.Timestamp}}</p>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue