migrate to new server
This commit is contained in:
parent
23aa879522
commit
f1a6e6df86
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -280,7 +281,10 @@ func getLastMetrics(deveui string) OneMetric {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set headers
|
// Set headers
|
||||||
req.Header.Set("Authorization", "Token nKYCoz3TA-LItYXG988DjdiStMhrfKmFXQqzxrjzJJ7Ek_iUttzFSE9lfe3s6q99EMdcrjuGlDAjp4Y0VnNRXw==")
|
var INFLUX_RO_TOKEN = os.Getenv("INFLUX_RO_TOKEN")
|
||||||
|
|
||||||
|
// Set headers
|
||||||
|
req.Header.Set("Authorization", "Token "+INFLUX_RO_TOKEN)
|
||||||
req.Header.Set("accept", "application/csv")
|
req.Header.Set("accept", "application/csv")
|
||||||
req.Header.Set("content-type", "application/vnd.flux")
|
req.Header.Set("content-type", "application/vnd.flux")
|
||||||
|
|
||||||
|
|
|
||||||
23
metrics.go
23
metrics.go
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -29,6 +30,8 @@ type OneMetric struct {
|
||||||
DaysUntilDeactivated int // berechneter Wert
|
DaysUntilDeactivated int // berechneter Wert
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var INFLUX_RO_TOKEN = os.Getenv("INFLUX_RO_TOKEN")
|
||||||
|
|
||||||
// metrics handler
|
// metrics handler
|
||||||
|
|
||||||
func validProperty(prop string) bool {
|
func validProperty(prop string) bool {
|
||||||
|
|
@ -115,8 +118,8 @@ func metricsHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
mystart = start[0]
|
mystart = start[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "http://localhost:8086/api/v2/query?org=beieliorg"
|
url := "http://localhost:8086/api/v2/query?org=minibeieliorg"
|
||||||
data := []byte(fmt.Sprintf(`from(bucket:"beielibucket") |> range(start: %s, stop: %s) |> filter(fn: (r) => r._measurement == "measurement") |> filter(fn: (r) => r._field == "%s") |> filter(fn: (r) => r.deveui == "%s")`, mystart, mystop, property[0], mydeveui))
|
data := []byte(fmt.Sprintf(`from(bucket:"minibeielibucket") |> range(start: %s, stop: %s) |> filter(fn: (r) => r._measurement == "measurement") |> filter(fn: (r) => r._field == "%s") |> filter(fn: (r) => r.deveui == "%s")`, mystart, mystop, property[0], mydeveui))
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
|
req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -124,7 +127,7 @@ func metricsHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set headers
|
// Set headers
|
||||||
req.Header.Set("Authorization", "Token nKYCoz3TA-LItYXG988DjdiStMhrfKmFXQqzxrjzJJ7Ek_iUttzFSE9lfe3s6q99EMdcrjuGlDAjp4Y0VnNRXw==")
|
req.Header.Set("Authorization", "Token "+INFLUX_RO_TOKEN)
|
||||||
req.Header.Set("accept", "application/csv")
|
req.Header.Set("accept", "application/csv")
|
||||||
req.Header.Set("content-type", "application/vnd.flux")
|
req.Header.Set("content-type", "application/vnd.flux")
|
||||||
|
|
||||||
|
|
@ -196,9 +199,9 @@ func lastmetricsHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
|
|
||||||
log.Println("Url Param 'deveui' is: " + string(mydeveui))
|
log.Println("Url Param 'deveui' is: " + string(mydeveui))
|
||||||
|
|
||||||
url := "http://localhost:8086/api/v2/query?org=beieliorg"
|
url := "http://localhost:8086/api/v2/query?org=minibeieliorg"
|
||||||
//data := []byte(fmt.Sprintf(`from(bucket:"beielibucket") |> range(start:-365d) |> filter(fn: (r) => r.deveui == "%s") |> filter(fn: (r) => r._field == "v" or r._field == "t") |> last() |> yield(name: "last")`,mydeveui))
|
//data := []byte(fmt.Sprintf(`from(bucket:"minibeielibucket") |> range(start:-365d) |> filter(fn: (r) => r.deveui == "%s") |> filter(fn: (r) => r._field == "v" or r._field == "t") |> last() |> yield(name: "last")`,mydeveui))
|
||||||
data := []byte(fmt.Sprintf(`from(bucket:"beielibucket")
|
data := []byte(fmt.Sprintf(`from(bucket:"minibeielibucket")
|
||||||
|> range(start:-365d)
|
|> range(start:-365d)
|
||||||
|> filter(fn: (r) => r._measurement == "measurement" and r.deveui == "%s")
|
|> filter(fn: (r) => r._measurement == "measurement" and r.deveui == "%s")
|
||||||
|> filter(fn: (r) => r._field == "t" or r._field == "h" or r._field == "w" or r._field == "p" or r._field == "vp")
|
|> filter(fn: (r) => r._field == "t" or r._field == "h" or r._field == "w" or r._field == "p" or r._field == "vp")
|
||||||
|
|
@ -210,7 +213,7 @@ func lastmetricsHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set headers
|
// Set headers
|
||||||
req.Header.Set("Authorization", "Token nKYCoz3TA-LItYXG988DjdiStMhrfKmFXQqzxrjzJJ7Ek_iUttzFSE9lfe3s6q99EMdcrjuGlDAjp4Y0VnNRXw==")
|
req.Header.Set("Authorization", "Token "+INFLUX_RO_TOKEN)
|
||||||
req.Header.Set("accept", "application/csv")
|
req.Header.Set("accept", "application/csv")
|
||||||
req.Header.Set("content-type", "application/vnd.flux")
|
req.Header.Set("content-type", "application/vnd.flux")
|
||||||
|
|
||||||
|
|
@ -294,8 +297,8 @@ func CalcDaysUntil(mydate string) int {
|
||||||
func getLastMetrics(deveui string) OneMetric {
|
func getLastMetrics(deveui string) OneMetric {
|
||||||
var res OneMetric
|
var res OneMetric
|
||||||
|
|
||||||
url := "http://localhost:8086/api/v2/query?org=beieliorg"
|
url := "http://localhost:8086/api/v2/query?org=minibeieliorg"
|
||||||
data := []byte(fmt.Sprintf(`from(bucket:"beielibucket")
|
data := []byte(fmt.Sprintf(`from(bucket:"minibeielibucket")
|
||||||
|> range(start:-365d)
|
|> range(start:-365d)
|
||||||
|> filter(fn: (r) => r._measurement == "measurement" and r.deveui == "%s")
|
|> filter(fn: (r) => r._measurement == "measurement" and r.deveui == "%s")
|
||||||
|> filter(fn: (r) => r._field == "t" or r._field == "h" or r._field == "w" or r._field == "p" or r._field == "vp")
|
|> filter(fn: (r) => r._field == "t" or r._field == "h" or r._field == "w" or r._field == "p" or r._field == "vp")
|
||||||
|
|
@ -308,7 +311,7 @@ func getLastMetrics(deveui string) OneMetric {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set headers
|
// Set headers
|
||||||
req.Header.Set("Authorization", "Token nKYCoz3TA-LItYXG988DjdiStMhrfKmFXQqzxrjzJJ7Ek_iUttzFSE9lfe3s6q99EMdcrjuGlDAjp4Y0VnNRXw==")
|
req.Header.Set("Authorization", "Token "+INFLUX_RO_TOKEN)
|
||||||
req.Header.Set("accept", "application/csv")
|
req.Header.Set("accept", "application/csv")
|
||||||
req.Header.Set("content-type", "application/vnd.flux")
|
req.Header.Set("content-type", "application/vnd.flux")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>mini-beieli.ch - die besondere Bienenstockwaage</title>
|
||||||
|
<link rel="stylesheet" href="/mini-beieli-web.css">
|
||||||
|
<link rel="stylesheet" href="/mini-beieli-web-custom.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="section px-4 py-4">
|
||||||
|
<div class="notification is-danger">
|
||||||
|
<strong>Oops, da ist was schiefgegangen!</strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
.image.is-10by1 img, .image.is-20by3 img {
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image.is-10by1 {
|
||||||
|
padding-top: 10%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image.is-20by3 {
|
||||||
|
padding-top: 15%;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
margin: 0 0 15px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.signup-box {
|
||||||
|
margin: auto;
|
||||||
|
width: 300px;
|
||||||
|
background: rgba(255,255,255,0.05);
|
||||||
|
border: 1px solid rgba(255,255,255,0.3);
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block-link {
|
||||||
|
text-decoration: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.apexcharts-title-text {
|
||||||
|
font-weight: 700 !important;
|
||||||
|
font-size: 24px !important;
|
||||||
|
font-family: "Rubik", sans-serif !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.apexcharts-legend {
|
||||||
|
font-family: "Rubik", sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * The CSS shown here will not be introduced in the Quickstart guide, but
|
||||||
|
* * shows how you can use CSS to style your Element's container.
|
||||||
|
* */
|
||||||
|
input,
|
||||||
|
.StripeElement {
|
||||||
|
height: 40px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
|
||||||
|
color: #32325d;
|
||||||
|
background-color: white;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
border-radius: 4px;
|
||||||
|
|
||||||
|
box-shadow: 0 1px 3px 0 #e6ebf1;
|
||||||
|
-webkit-transition: box-shadow 150ms ease;
|
||||||
|
transition: box-shadow 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:focus,
|
||||||
|
.StripeElement--focus {
|
||||||
|
box-shadow: 0 1px 3px 0 #cfd7df;
|
||||||
|
}
|
||||||
|
|
||||||
|
.StripeElement--invalid {
|
||||||
|
border-color: #fa755a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.StripeElement--webkit-autofill {
|
||||||
|
background-color: #fefde5 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkboxes input {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkboxes label span {
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -4,6 +4,9 @@ After=syslog.target
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
Environment="INFLUX_RO_TOKEN=xxx"
|
||||||
|
Environment="STRIPE_KEY=sk_xxx"
|
||||||
|
Environment="STRIPE_PK=pk_xxx"
|
||||||
Type=simple
|
Type=simple
|
||||||
User=beieli
|
User=beieli
|
||||||
Group=beieli
|
Group=beieli
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue