enhance settings
This commit is contained in:
parent
c687cfcdd8
commit
8b0367caf4
2
main.go
2
main.go
|
|
@ -11,6 +11,8 @@ import (
|
||||||
type Scale struct {
|
type Scale struct {
|
||||||
Deveui string
|
Deveui string
|
||||||
Alias string
|
Alias string
|
||||||
|
Alarmactive string
|
||||||
|
Smsnumber string
|
||||||
Last_measurement string
|
Last_measurement string
|
||||||
Last_temp string
|
Last_temp string
|
||||||
Last_humidity string
|
Last_humidity string
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ import (
|
||||||
type OneMetric struct {
|
type OneMetric struct {
|
||||||
Deveui string
|
Deveui string
|
||||||
Alias string
|
Alias string
|
||||||
|
Alarmactive string
|
||||||
|
Smsnumber string
|
||||||
Timestamp string
|
Timestamp string
|
||||||
Temperature string
|
Temperature string
|
||||||
Humidity string
|
Humidity string
|
||||||
|
|
@ -296,5 +298,7 @@ func getLastMetrics(deveui string) OneMetric {
|
||||||
}
|
}
|
||||||
res.Deveui = deveui
|
res.Deveui = deveui
|
||||||
res.Alias = getDevAlias(deveui)
|
res.Alias = getDevAlias(deveui)
|
||||||
|
res.Alarmactive = getDevAlarmactive(deveui)
|
||||||
|
res.Smsnumber = getDevSmsnumber(deveui)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,8 @@ type User struct {
|
||||||
type Dev struct {
|
type Dev struct {
|
||||||
Deveui string `json:"deveui"`
|
Deveui string `json:"deveui"`
|
||||||
Alias string `json:"alias"`
|
Alias string `json:"alias"`
|
||||||
|
Alarmactive string `json:"alarmactive"`
|
||||||
|
Smsnumber string `json:"smsnumber"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,6 +188,52 @@ func getDevAlias(deveui string) string {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getDevAlarmactive(deveui string) string {
|
||||||
|
res := "0"
|
||||||
|
|
||||||
|
if deveui == "" {
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
conn := globalPool.Get()
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
logit("getDevAlarmactive: Deveui: "+deveui)
|
||||||
|
alarmactive, err := redis.String(conn.Do("HGET", devPrefix+deveui, "alarmactive"))
|
||||||
|
if err == nil {
|
||||||
|
logit("getDevAlarmactive: alarmactive: "+alarmactive)
|
||||||
|
res = alarmactive
|
||||||
|
} else {
|
||||||
|
log.Print(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func getDevSmsnumber(deveui string) string {
|
||||||
|
res := "+4179XXXXXXX"
|
||||||
|
|
||||||
|
if deveui == "" {
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
conn := globalPool.Get()
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
logit("getDevSmsnumber: Deveui: "+deveui)
|
||||||
|
smsnumber, err := redis.String(conn.Do("HGET", devPrefix+deveui, "smsnumber"))
|
||||||
|
if err == nil {
|
||||||
|
logit("getDevAlarmactive: smsnumber: "+smsnumber)
|
||||||
|
res = smsnumber
|
||||||
|
} else {
|
||||||
|
log.Print(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
func randString(n int) string {
|
func randString(n int) string {
|
||||||
const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||||
var bytes = make([]byte, n)
|
var bytes = make([]byte, n)
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,16 @@
|
||||||
<section class="modal-card-body">
|
<section class="modal-card-body">
|
||||||
<!-- Content ... -->
|
<!-- Content ... -->
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">Bezeichnung (1234567812345678)</label>
|
<label id="label" class="label">Bezeichnung (1234567812345678)</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" type="text" placeholder="Waage Volk 1">
|
<input id="alias" class="input" type="text">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox">
|
<input id="checkbox" type="checkbox">
|
||||||
SMS Alarmierung aktiv
|
SMS Alarmierung aktiv
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">Alarmnummer (SMS)</label>
|
<label class="label">Alarmnummer (SMS)</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" type="text" placeholder="+41791234567">
|
<input id="smsnumber" class="input" type="text">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -42,6 +42,8 @@
|
||||||
{{range .LastMetrics}}
|
{{range .LastMetrics}}
|
||||||
<div class="column is-full notification is-warning">
|
<div class="column is-full notification is-warning">
|
||||||
<p class="is-size-2 is-size-5-mobile has-text-centered has-text-weight-bold" ><span 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 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 id="alarmactive_{{.Deveui}}" hidden>{{.Alarmactive}}</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>
|
||||||
<div id="{{.Deveui}}">
|
<div id="{{.Deveui}}">
|
||||||
<div class="colums is-full notification is-warning">
|
<div class="colums is-full notification is-warning">
|
||||||
|
|
@ -99,6 +101,21 @@
|
||||||
// A $( document ).ready() block.
|
// A $( document ).ready() block.
|
||||||
$( document ).ready(function() {
|
$( document ).ready(function() {
|
||||||
$(".show-modal").click(function() {
|
$(".show-modal").click(function() {
|
||||||
|
var alias = $(this).prev().html();
|
||||||
|
var deveui = $(this).prev().attr('id').replace("alias_","");
|
||||||
|
var alarmactive = $('#alarmactive_'+deveui).html();
|
||||||
|
var smsnumber = $('#smsnumber_'+deveui).html();
|
||||||
|
|
||||||
|
var label = "Bezeichnung (" + deveui + ")";
|
||||||
|
$("#alias").val(alias);
|
||||||
|
$("#label").html(label);
|
||||||
|
console.log(alarmactive);
|
||||||
|
if (alarmactive == "1") {
|
||||||
|
$('#checkbox').prop('checked', true);
|
||||||
|
} else {
|
||||||
|
$('#checkbox').prop('checked', false);
|
||||||
|
}
|
||||||
|
$("#smsnumber").val(smsnumber);
|
||||||
$("#modal").addClass("is-active");
|
$("#modal").addClass("is-active");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue