Skip to content

Commit 7349427

Browse files
committed
feat(data source variable): progress on data source as variable
2 parents 13471ae + 89ea25c commit 7349427

File tree

103 files changed

+2702
-1133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+2702
-1133
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
# 3.0.0-beta6 (unreleased)
2+
3+
### Enhancements
4+
* **Singlestat**: Support for gauges in singlestat panel. closes [#3688](https://github.com/grafana/grafana/pull/3688)
5+
6+
### Bug fixes
7+
* **InfluxDB 0.12**: Fixed issue templating and `show tag values` query only returning tags for first measurement, fixes [#4726](https://github.com/grafana/grafana/issues/4726)
8+
* **Templating**: Fixed issue with regex formating when matching multiple values, fixes [#4755](https://github.com/grafana/grafana/issues/4755)
9+
* **Templating**: Fixed issue with custom all value and escaping, fixes [#4736](https://github.com/grafana/grafana/issues/4736)
10+
* **Dashlist**: Fixed issue dashboard list panel and caching tags, fixes [#4768](https://github.com/grafana/grafana/issues/4768)
11+
* **Graph**: Fixed issue with unneeded scrollbar in legend for Firefox, fixes [#4760](https://github.com/grafana/grafana/issues/4760)
12+
* **Table panel**: Fixed issue table panel formating string array properties, fixes [#4791](https://github.com/grafana/grafana/issues/4791)
13+
* **grafana-cli**: Improve error message when failing to install plugins due to corrupt response, fixes [#4651](https://github.com/grafana/grafana/issues/4651)
14+
* **Singlestat**: Fixes prefix an postfix for gauges, fixes [#4812](https://github.com/grafana/grafana/issues/4812)
15+
* **Singlestat**: Fixes auto-refresh on change for some options, fixes [#4809](https://github.com/grafana/grafana/issues/4809)
16+
17+
### Breaking changes
18+
**Data Source Query Editors**: Issue [#3900](https://github.com/grafana/grafana/issues/3900)
19+
20+
Query editors have been updated to use the new form styles. External data source plugins needs to be
21+
updated to work. Sorry to introduce breaking change this late in beta phase. We wanted to get this change
22+
in before 3.0 stable is released so we don't have to break data sources in next release (3.1). If you are
23+
a data source plugin author and want help for how the new form styles work please ask for help in
24+
slack channel (link to slack channel in readme).
25+
126
# 3.0.0-beta5 (2016-04-15)
227

328
### Bug fixes

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
all: deps build
2+
3+
deps:
4+
go run build.go setup
5+
godep restore
6+
npm install
7+
8+
build:
9+
go run build.go build
10+
npm run build
11+
12+
test:
13+
godep go test -v ./pkg/...
14+
npm test
15+
16+
run:
17+
./bin/grafana-server

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ npm (v2.5.0) and grunt (v0.4.5). Run the following:
103103

104104
```bash
105105
npm install
106-
npm install -g grunt-cli
107-
grunt
106+
npm run build
108107
```
109108

110109
### Recompile backend on source change
@@ -145,4 +144,3 @@ please [sign the CLA](http://docs.grafana.org/project/cla/)
145144

146145
Grafana is distributed under Apache 2.0 License.
147146
Work in progress Grafana 2.0 (with included Grafana backend)
148-

build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func ChangeWorkingDir(dir string) {
306306
}
307307

308308
func grunt(params ...string) {
309-
runPrint("./node_modules/grunt-cli/bin/grunt", params...)
309+
runPrint("./node_modules/.bin/grunt", params...)
310310
}
311311

312312
func setup() {

circle.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ test:
2525
# Go test
2626
- godep go test -v ./pkg/...
2727
# js tests
28-
- ./node_modules/grunt-cli/bin/grunt test
28+
- npm test
2929
- npm run coveralls
3030

3131
deployment:
3232
master:
3333
branch: master
3434
owner: grafana
35-
commands:
35+
commands:
3636
- ./trigger_grafana_packer.sh ${TRIGGER_GRAFANA_PACKER_CIRCLECI_TOKEN}

docs/sources/http_api/dashboard.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ Will return the home dashboard.
191191

192192
`GET /api/dashboards/tags`
193193

194-
Get all tabs of dashboards
194+
Get all tags of dashboards
195195

196196
**Example Request**:
197197

docs/sources/plugins/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Grafana already have a strong community of contributors and plugin developers.
1515
By making it easier to develop and install plugins we hope that the community
1616
can grow even stronger and develop new plugins that we would never think about.
1717

18-
You can discover available plugins on [Grafana.net](http://grafana.net)
18+
You can discover available plugins on [Grafana.net](https://grafana.net)
1919

2020

2121

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,15 @@
5454
"phantomjs-prebuilt": "^2.1.3",
5555
"reflect-metadata": "0.1.2",
5656
"rxjs": "5.0.0-beta.4",
57-
"sass-lint": "^1.5.0",
57+
"sass-lint": "^1.6.0",
5858
"systemjs": "0.19.24"
5959
},
6060
"engines": {
6161
"node": "0.4.x",
6262
"npm": "2.14.x"
6363
},
6464
"scripts": {
65+
"build": "grunt",
6566
"test": "grunt test",
6667
"coveralls": "grunt karma:coveralls && rm -rf ./coverage"
6768
},

pkg/api/cloudwatch/metrics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func init() {
5656
"HbaseBackupFailed", "MostRecentBackupDuration", "TimeSinceLastSuccessfulBackup"},
5757
"AWS/ES": {"ClusterStatus.green", "ClusterStatus.yellow", "ClusterStatus.red", "Nodes", "SearchableDocuments", "DeletedDocuments", "CPUUtilization", "FreeStorageSpace", "JVMMemoryPressure", "AutomatedSnapshotFailure", "MasterCPUUtilization", "MasterFreeStorageSpace", "MasterJVMMemoryPressure", "ReadLatency", "WriteLatency", "ReadThroughput", "WriteThroughput", "DiskQueueLength", "ReadIOPS", "WriteIOPS"},
5858
"AWS/Events": {"Invocations", "FailedInvocations", "TriggeredRules", "MatchedEvents", "ThrottledRules"},
59-
"AWS/Kinesis": {"PutRecord.Bytes", "PutRecord.Latency", "PutRecord.Success", "PutRecords.Bytes", "PutRecords.Latency", "PutRecords.Records", "PutRecords.Success", "IncomingBytes", "IncomingRecords", "GetRecords.Bytes", "GetRecords.IteratorAgeMilliseconds", "GetRecords.Latency", "GetRecords.Success"},
59+
"AWS/Kinesis": {"GetRecords.Bytes", "GetRecords.IteratorAge", "GetRecords.IteratorAgeMilliseconds", "GetRecords.Latency", "GetRecords.Records", "GetRecords.Success", "IncomingBytes", "IncomingRecords", "PutRecord.Bytes", "PutRecord.Latency", "PutRecord.Success", "PutRecords.Bytes", "PutRecords.Latency", "PutRecords.Records", "PutRecords.Success", "ReadProvisionedThroughputExceeded", "WriteProvisionedThroughputExceeded", "IteratorAgeMilliseconds", "OutgoingBytes", "OutgoingRecords"},
6060
"AWS/Lambda": {"Invocations", "Errors", "Duration", "Throttles"},
6161
"AWS/Logs": {"IncomingBytes", "IncomingLogEvents", "ForwardedBytes", "ForwardedLogEvents", "DeliveryErrors", "DeliveryThrottling"},
6262
"AWS/ML": {"PredictCount", "PredictFailureCount"},
@@ -88,7 +88,7 @@ func init() {
8888
"AWS/ElasticMapReduce": {"ClusterId", "JobFlowId", "JobId"},
8989
"AWS/ES": {},
9090
"AWS/Events": {"RuleName"},
91-
"AWS/Kinesis": {"StreamName"},
91+
"AWS/Kinesis": {"StreamName", "ShardID"},
9292
"AWS/Lambda": {"FunctionName"},
9393
"AWS/Logs": {"LogGroupName", "DestinationType", "FilterName"},
9494
"AWS/ML": {"MLModelId", "RequestMode"},

pkg/api/dashboard_snapshot.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ func GetSharingOptions(c *middleware.Context) {
2121
}
2222

2323
func CreateDashboardSnapshot(c *middleware.Context, cmd m.CreateDashboardSnapshotCommand) {
24+
if cmd.Name == "" {
25+
cmd.Name = "Unnamed snapshot"
26+
}
27+
2428
if cmd.External {
2529
// external snapshot ref requires key and delete key
2630
if cmd.Key == "" || cmd.DeleteKey == "" {

pkg/api/dataproxy.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ func NewReverseProxy(ds *m.DataSource, proxyPath string, targetUrl *url.URL) *ht
4141
req.URL.RawQuery = reqQueryVals.Encode()
4242
} else if ds.Type == m.DS_INFLUXDB {
4343
req.URL.Path = util.JoinUrlFragments(targetUrl.Path, proxyPath)
44-
reqQueryVals.Add("db", ds.Database)
4544
req.URL.RawQuery = reqQueryVals.Encode()
4645
if !ds.BasicAuth {
4746
req.Header.Del("Authorization")

pkg/api/dtos/plugins.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ func (slice PluginList) Swap(i, j int) {
4848
type ImportDashboardCommand struct {
4949
PluginId string `json:"pluginId"`
5050
Path string `json:"path"`
51-
Reinstall bool `json:"reinstall"`
51+
Overwrite bool `json:"overwrite"`
5252
Inputs []plugins.ImportDashboardInput `json:"inputs"`
5353
}

pkg/api/index.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,18 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
103103
}
104104

105105
for _, include := range plugin.Includes {
106+
if !c.HasUserRole(include.Role) {
107+
continue
108+
}
109+
106110
if include.Type == "page" && include.AddToNav {
107111
link := &dtos.NavLink{
108112
Url: setting.AppSubUrl + "/plugins/" + plugin.Id + "/page/" + include.Slug,
109113
Text: include.Name,
110114
}
111115
appLink.Children = append(appLink.Children, link)
112116
}
117+
113118
if include.Type == "dashboard" && include.AddToNav {
114119
link := &dtos.NavLink{
115120
Url: setting.AppSubUrl + "/dashboard/db/" + include.Slug,
@@ -124,7 +129,9 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
124129
appLink.Children = append(appLink.Children, &dtos.NavLink{Text: "Plugin Config", Icon: "fa fa-cog", Url: setting.AppSubUrl + "/plugins/" + plugin.Id + "/edit"})
125130
}
126131

127-
data.MainNavLinks = append(data.MainNavLinks, appLink)
132+
if len(appLink.Children) > 0 {
133+
data.MainNavLinks = append(data.MainNavLinks, appLink)
134+
}
128135
}
129136
}
130137

pkg/api/plugins.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,12 @@ func GetPluginReadme(c *middleware.Context) Response {
156156
func ImportDashboard(c *middleware.Context, apiCmd dtos.ImportDashboardCommand) Response {
157157

158158
cmd := plugins.ImportDashboardCommand{
159-
OrgId: c.OrgId,
160-
UserId: c.UserId,
161-
PluginId: apiCmd.PluginId,
162-
Path: apiCmd.Path,
163-
Inputs: apiCmd.Inputs,
159+
OrgId: c.OrgId,
160+
UserId: c.UserId,
161+
PluginId: apiCmd.PluginId,
162+
Path: apiCmd.Path,
163+
Inputs: apiCmd.Inputs,
164+
Overwrite: apiCmd.Overwrite,
164165
}
165166

166167
if err := bus.Dispatch(&cmd); err != nil {

pkg/cmd/grafana-cli/commands/commands.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"os"
55

66
"github.com/codegangsta/cli"
7+
"github.com/fatih/color"
78
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
89
)
910

@@ -12,7 +13,7 @@ func runCommand(command func(commandLine CommandLine) error) func(context *cli.C
1213

1314
cmd := &contextCommandLine{context}
1415
if err := command(cmd); err != nil {
15-
log.Error("\nError: ")
16+
log.Errorf("\n%s: ", color.RedString("Error"))
1617
log.Errorf("%s\n\n", err)
1718

1819
cmd.ShowHelp()

pkg/cmd/grafana-cli/commands/install_command.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,16 @@ func downloadFile(pluginName, filePath, url string) (err error) {
126126
defer func() {
127127
if r := recover(); r != nil {
128128
retryCount++
129-
if retryCount == 1 {
130-
log.Debug("\nFailed downloading. Will retry once.\n")
131-
downloadFile(pluginName, filePath, url)
129+
if retryCount < 3 {
130+
fmt.Println("Failed downloading. Will retry once.")
131+
err = downloadFile(pluginName, filePath, url)
132132
} else {
133-
panic(r)
133+
failure := fmt.Sprintf("%v", r)
134+
if failure == "runtime error: makeslice: len out of range" {
135+
err = fmt.Errorf("Corrupt http response from source. Please try again.\n")
136+
} else {
137+
panic(r)
138+
}
134139
}
135140
}
136141
}()
@@ -164,14 +169,14 @@ func downloadFile(pluginName, filePath, url string) (err error) {
164169
return fmt.Errorf(permissionsDeniedMessage, newFile)
165170
}
166171

167-
defer dst.Close()
168172
src, err := zf.Open()
169173
if err != nil {
170-
log.Errorf("%v", err)
174+
log.Errorf("Failed to extract file: %v", err)
171175
}
172-
defer src.Close()
173176

174177
io.Copy(dst, src)
178+
dst.Close()
179+
src.Close()
175180
}
176181
}
177182

pkg/cmd/grafana-cli/commands/remove_command.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package commands
33
import (
44
"errors"
55

6-
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
6+
"fmt"
77
m "github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
88
services "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
99
)
@@ -15,22 +15,17 @@ func removeCommand(c CommandLine) error {
1515
pluginPath := c.GlobalString("pluginsDir")
1616
localPlugins := getPluginss(pluginPath)
1717

18-
log.Info("remove!\n")
19-
2018
plugin := c.Args().First()
21-
log.Info("plugin: " + plugin + "\n")
2219
if plugin == "" {
2320
return errors.New("Missing plugin parameter")
2421
}
2522

26-
log.Infof("plugins : \n%v\n", localPlugins)
27-
2823
for _, p := range localPlugins {
2924
if p.Id == c.Args().First() {
30-
log.Infof("removing plugin %s", p.Id)
3125
removePlugin(pluginPath, p.Id)
26+
return nil
3227
}
3328
}
3429

35-
return nil
30+
return fmt.Errorf("Could not find plugin named %s", c.Args().First())
3631
}

pkg/cmd/grafana-cli/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/codegangsta/cli"
99
"github.com/grafana/grafana/pkg/cmd/grafana-cli/commands"
1010
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
11-
"strings"
1211
)
1312

1413
var version = "master"
@@ -18,7 +17,7 @@ func getGrafanaPluginDir() string {
1817
defaultNix := "/var/lib/grafana/plugins"
1918

2019
if currentOS == "windows" {
21-
return "C:\\opt\\grafana\\plugins"
20+
return "../data/plugins"
2221
}
2322

2423
pwd, err := os.Getwd()
@@ -29,16 +28,17 @@ func getGrafanaPluginDir() string {
2928
}
3029

3130
if isDevenvironment(pwd) {
32-
return "../../../data/plugins"
31+
return "../data/plugins"
3332
}
3433

3534
return defaultNix
3635
}
3736

3837
func isDevenvironment(pwd string) bool {
39-
// if grafana-cli is executed from the cmd folder we can assume
38+
// if ../conf/defaults.ini exists, grafana is not installed as package
4039
// that its in development environment.
41-
return strings.HasSuffix(pwd, "/pkg/cmd/grafana-cli")
40+
_, err := os.Stat("../conf/defaults.ini")
41+
return err == nil
4242
}
4343

4444
func main() {

pkg/models/dashboard_snapshot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type DashboardSnapshotDTO struct {
4545

4646
type CreateDashboardSnapshotCommand struct {
4747
Dashboard *simplejson.Json `json:"dashboard" binding:"Required"`
48-
Name string `json:"name" binding:"Required"`
48+
Name string `json:"name"`
4949
Expires int64 `json:"expires"`
5050

5151
// these are passed when storing an external snapshot ref

pkg/models/org_user.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package models
22

33
import (
4+
"encoding/json"
45
"errors"
6+
"fmt"
57
"time"
68
)
79

@@ -37,6 +39,26 @@ func (r RoleType) Includes(other RoleType) bool {
3739
return r == other
3840
}
3941

42+
func (r *RoleType) UnmarshalJSON(data []byte) error {
43+
var str string
44+
err := json.Unmarshal(data, &str)
45+
if err != nil {
46+
return err
47+
}
48+
49+
*r = RoleType(str)
50+
51+
if (*r).IsValid() == false {
52+
if (*r) != "" {
53+
return errors.New(fmt.Sprintf("JSON validation error: invalid role value: %s", *r))
54+
}
55+
56+
*r = ROLE_VIEWER
57+
}
58+
59+
return nil
60+
}
61+
4062
type OrgUser struct {
4163
Id int64
4264
OrgId int64

0 commit comments

Comments
 (0)