mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'v4.0.x' of github.com:grafana/grafana into v4.0.x
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
"company": "Coding Instinct AB"
|
"company": "Coding Instinct AB"
|
||||||
},
|
},
|
||||||
"name": "grafana",
|
"name": "grafana",
|
||||||
"version": "4.0.1",
|
"version": "4.0.2",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "http://github.com/grafana/grafana.git"
|
"url": "http://github.com/grafana/grafana.git"
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/util"
|
"github.com/grafana/grafana/pkg/util"
|
||||||
)
|
)
|
||||||
@@ -19,14 +18,17 @@ type WebdavUploader struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *WebdavUploader) Upload(pa string) (string, error) {
|
func (u *WebdavUploader) Upload(pa string) (string, error) {
|
||||||
client := http.Client{Timeout: time.Duration(10 * time.Second)}
|
|
||||||
|
|
||||||
url, _ := url.Parse(u.url)
|
url, _ := url.Parse(u.url)
|
||||||
url.Path = path.Join(url.Path, util.GetRandomString(20)+".png")
|
url.Path = path.Join(url.Path, util.GetRandomString(20)+".png")
|
||||||
|
|
||||||
imgData, err := ioutil.ReadFile(pa)
|
imgData, err := ioutil.ReadFile(pa)
|
||||||
req, err := http.NewRequest("PUT", url.String(), bytes.NewReader(imgData))
|
req, err := http.NewRequest("PUT", url.String(), bytes.NewReader(imgData))
|
||||||
res, err := client.Do(req)
|
|
||||||
|
if u.username != "" {
|
||||||
|
req.SetBasicAuth(u.username, u.password)
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := http.DefaultClient.Do(req)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|||||||
@@ -27,13 +27,17 @@ func (s *SimpleReducer) Reduce(series *tsdb.TimeSeries) null.Float {
|
|||||||
|
|
||||||
switch s.Type {
|
switch s.Type {
|
||||||
case "avg":
|
case "avg":
|
||||||
|
validPointsCount := 0
|
||||||
for _, point := range series.Points {
|
for _, point := range series.Points {
|
||||||
if point[0].Valid {
|
if point[0].Valid {
|
||||||
value += point[0].Float64
|
value += point[0].Float64
|
||||||
|
validPointsCount += 1
|
||||||
allNull = false
|
allNull = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
value = value / float64(len(series.Points))
|
if validPointsCount > 0 {
|
||||||
|
value = value / float64(validPointsCount)
|
||||||
|
}
|
||||||
case "sum":
|
case "sum":
|
||||||
for _, point := range series.Points {
|
for _, point := range series.Points {
|
||||||
if point[0].Valid {
|
if point[0].Valid {
|
||||||
@@ -90,7 +94,6 @@ func (s *SimpleReducer) Reduce(series *tsdb.TimeSeries) null.Float {
|
|||||||
value = (values[(length/2)-1] + values[length/2]) / 2
|
value = (values[(length/2)-1] + values[length/2]) / 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if allNull {
|
if allNull {
|
||||||
|
|||||||
@@ -16,6 +16,20 @@ func TestSimpleReducer(t *testing.T) {
|
|||||||
So(result, ShouldEqual, float64(2))
|
So(result, ShouldEqual, float64(2))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Convey("avg of none null data", func() {
|
||||||
|
reducer := NewSimpleReducer("avg")
|
||||||
|
series := &tsdb.TimeSeries{
|
||||||
|
Name: "test time serie",
|
||||||
|
}
|
||||||
|
|
||||||
|
series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFrom(3), 1))
|
||||||
|
series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFromPtr(nil), 2))
|
||||||
|
series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFromPtr(nil), 3))
|
||||||
|
series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFrom(3), 4))
|
||||||
|
|
||||||
|
So(reducer.Reduce(series).Float64, ShouldEqual, float64(3))
|
||||||
|
})
|
||||||
|
|
||||||
Convey("sum", func() {
|
Convey("sum", func() {
|
||||||
result := testReducer("sum", 1, 2, 3)
|
result := testReducer("sum", 1, 2, 3)
|
||||||
So(result, ShouldEqual, float64(6))
|
So(result, ShouldEqual, float64(6))
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ export class SubmenuCtrl {
|
|||||||
private $location) {
|
private $location) {
|
||||||
this.annotations = this.dashboard.templating.list;
|
this.annotations = this.dashboard.templating.list;
|
||||||
this.variables = this.variableSrv.variables;
|
this.variables = this.variableSrv.variables;
|
||||||
console.log(this.variables);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
annotationStateChanged() {
|
annotationStateChanged() {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export class AxesEditorCtrl {
|
|||||||
this.xAxisStatOptions = [
|
this.xAxisStatOptions = [
|
||||||
{text: 'Avg', value: 'avg'},
|
{text: 'Avg', value: 'avg'},
|
||||||
{text: 'Min', value: 'min'},
|
{text: 'Min', value: 'min'},
|
||||||
{text: 'Max', value: 'min'},
|
{text: 'Max', value: 'max'},
|
||||||
{text: 'Total', value: 'total'},
|
{text: 'Total', value: 'total'},
|
||||||
{text: 'Count', value: 'count'},
|
{text: 'Count', value: 'count'},
|
||||||
{text: 'Current', value: 'current'},
|
{text: 'Current', value: 'current'},
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ export class DataProcessor {
|
|||||||
return [
|
return [
|
||||||
{text: 'Avg', value: 'avg'},
|
{text: 'Avg', value: 'avg'},
|
||||||
{text: 'Min', value: 'min'},
|
{text: 'Min', value: 'min'},
|
||||||
{text: 'Max', value: 'min'},
|
{text: 'Max', value: 'max'},
|
||||||
{text: 'Total', value: 'total'},
|
{text: 'Total', value: 'total'},
|
||||||
{text: 'Count', value: 'count'},
|
{text: 'Count', value: 'count'},
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user