diff --git a/CHANGELOG.md b/CHANGELOG.md index 2399eda7140..a0741e2e0ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,18 @@ # 3.0.0-beta3 (unreleased) +### Enhancements +* **InfluxDB**: Changed multi query encoding to work with InfluxDB 0.11 & 0.12, closes [#4533](https://github.com/grafana/grafana/issues/4533) + ### Bug fixes * **Postgres**: Fixed page render crash when using postgres, fixes [#4558](https://github.com/grafana/grafana/issues/4558) * **Table panel**: Fixed table panel bug when trying to show annotations in table panel, fixes [#4563](https://github.com/grafana/grafana/issues/4563) * **App Config**: Fixed app config issue showing content of other app config, fixes [#4575](https://github.com/grafana/grafana/issues/4575) * **Graph Panel**: Fixed legend option max not updating, fixes [#4601](https://github.com/grafana/grafana/issues/4601) * **Graph Panel**: Fixed issue where newly added graph panels shared same axes config, fixes [#4582](https://github.com/grafana/grafana/issues/4582) +* **Graph Panel**: Fixed issue with axis labels overlapping Y-axis, fixes [#4626](https://github.com/grafana/grafana/issues/4626) +* **InfluxDB**: Fixed issue with templating query containing template variable, fixes [#4602](https://github.com/grafana/grafana/issues/4602) +* **Graph Panel**: Fixed issue with hiding series and stacking, fixes [#4557](https://github.com/grafana/grafana/issues/4557) +* **Mixed Datasources**: Fixed issue with mixing many datasources in same graph, fixes [#4604](https://github.com/grafana/grafana/issues/4604) # 3.0.0-beta2 (2016-04-04) diff --git a/pkg/api/api.go b/pkg/api/api.go index 62da5c8f084..fae78053962 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -30,6 +30,7 @@ func Register(r *macaron.Macaron) { // authed views r.Get("/profile/", reqSignedIn, Index) r.Get("/profile/password", reqSignedIn, Index) + r.Get("/profile/switch-org/:id", reqSignedIn, ChangeActiveOrgAndRedirectToHome) r.Get("/org/", reqSignedIn, Index) r.Get("/org/new", reqSignedIn, Index) r.Get("/datasources/", reqSignedIn, Index) diff --git a/pkg/api/user.go b/pkg/api/user.go index 5af243eeb22..8f54feaf6a0 100644 --- a/pkg/api/user.go +++ b/pkg/api/user.go @@ -4,6 +4,7 @@ import ( "github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/middleware" m "github.com/grafana/grafana/pkg/models" + "github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/util" ) @@ -109,6 +110,23 @@ func UserSetUsingOrg(c *middleware.Context) Response { return ApiSuccess("Active organization changed") } +// GET /profile/switch-org/:id +func ChangeActiveOrgAndRedirectToHome(c *middleware.Context) { + orgId := c.ParamsInt64(":id") + + if !validateUsingOrg(c.UserId, orgId) { + NotFoundHandler(c) + } + + cmd := m.SetUsingOrgCommand{UserId: c.UserId, OrgId: orgId} + + if err := bus.Dispatch(&cmd); err != nil { + NotFoundHandler(c) + } + + c.Redirect(setting.AppSubUrl + "/") +} + func ChangeUserPassword(c *middleware.Context, cmd m.ChangeUserPasswordCommand) Response { userQuery := m.GetUserByIdQuery{Id: c.UserId} diff --git a/public/app/core/components/sidemenu/sidemenu.html b/public/app/core/components/sidemenu/sidemenu.html index 4ff30c92f47..25aa38c45b8 100644 --- a/public/app/core/components/sidemenu/sidemenu.html +++ b/public/app/core/components/sidemenu/sidemenu.html @@ -21,10 +21,6 @@ {{::menuItem.text}} - - - {{::menuItem.text}} - diff --git a/public/app/core/components/sidemenu/sidemenu.ts b/public/app/core/components/sidemenu/sidemenu.ts index a47704f9d7d..30230586e78 100644 --- a/public/app/core/components/sidemenu/sidemenu.ts +++ b/public/app/core/components/sidemenu/sidemenu.ts @@ -72,9 +72,8 @@ export class SideMenuCtrl { this.orgMenu.push({ text: "Switch to " + org.name, icon: "fa fa-fw fa-random", - click: () => { - this.switchOrg(org.orgId); - } + url: this.getUrl('/profile/switch-org/' + org.orgId), + target: '_self' }); }); @@ -83,12 +82,6 @@ export class SideMenuCtrl { } }); } - - switchOrg(orgId) { - this.backendSrv.post('/api/user/using/' + orgId).then(() => { - window.location.href = `${config.appSubUrl}/`; - }); - }; } export function sideMenuDirective() { diff --git a/public/app/core/services/popover_srv.ts b/public/app/core/services/popover_srv.ts index 4711dc1b23c..73249a67b5b 100644 --- a/public/app/core/services/popover_srv.ts +++ b/public/app/core/services/popover_srv.ts @@ -46,9 +46,12 @@ function popoverSrv($compile, $rootScope) { drop.on('close', () => { popoverScope.dismiss({fromDropClose: true}); destroyDrop(); + if (options.onClose) { + options.onClose(); + } }); - drop.open(); + setTimeout(() => { drop.open(); }, 10); }; } diff --git a/public/app/features/panel/metrics_panel_ctrl.ts b/public/app/features/panel/metrics_panel_ctrl.ts index 4e610e3ed05..df4e912211e 100644 --- a/public/app/features/panel/metrics_panel_ctrl.ts +++ b/public/app/features/panel/metrics_panel_ctrl.ts @@ -184,7 +184,6 @@ class MetricsPanelCtrl extends PanelCtrl { cacheTimeout: this.panel.cacheTimeout }; - this.setTimeQueryStart(); return datasource.query(metricsQuery); } @@ -252,8 +251,12 @@ class MetricsPanelCtrl extends PanelCtrl { } addDataQuery(datasource) { - var target = { - }; + var target: any = {}; + + if (datasource) { + target.datasource = datasource.name; + } + this.panel.targets.push(target); } } diff --git a/public/app/plugins/datasource/influxdb/datasource.ts b/public/app/plugins/datasource/influxdb/datasource.ts index daa6ada3420..4037e963bcb 100644 --- a/public/app/plugins/datasource/influxdb/datasource.ts +++ b/public/app/plugins/datasource/influxdb/datasource.ts @@ -55,7 +55,7 @@ export default class InfluxDatasource { query = query.replace(/\$interval/g, (target.interval || options.interval)); return query; - }).join("\n"); + }).join(";"); // replace grafana variables allQueries = allQueries.replace(/\$timeFilter/g, timeFilter); @@ -107,7 +107,7 @@ export default class InfluxDatasource { var timeFilter = this.getTimeFilter({rangeRaw: options.rangeRaw}); var query = options.annotation.query.replace('$timeFilter', timeFilter); - query = this.templateSrv.replace(query); + query = this.templateSrv.replace(query, null, 'regex'); return this._seriesQuery(query).then(data => { if (!data || !data.results || !data.results[0]) { @@ -133,6 +133,17 @@ export default class InfluxDatasource { return this._influxRequest('GET', '/query', {q: query, epoch: 'ms'}); } + + serializeParams(params) { + if (!params) { return '';} + + return _.reduce(params, (memo, value, key) => { + if (value === null || value === undefined) { return memo; } + memo.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); + return memo; + }, []).join("&"); + } + testDatasource() { return this.metricFindQuery('SHOW MEASUREMENTS LIMIT 1').then(() => { return { status: "success", message: "Data source is working", title: "Success" }; @@ -166,6 +177,7 @@ export default class InfluxDatasource { data: data, precision: "ms", inspect: { type: 'influxdb' }, + paramSerializer: this.serializeParams, }; options.headers = options.headers || {}; diff --git a/public/app/plugins/panel/graph/graph.js b/public/app/plugins/panel/graph/graph.js index 4e948bf8e5b..9e6633b5551 100755 --- a/public/app/plugins/panel/graph/graph.js +++ b/public/app/plugins/panel/graph/graph.js @@ -151,8 +151,10 @@ function (angular, $, moment, _, kbn, GraphTooltip) { } function processOffsetHook(plot, gridMargin) { - if (panel.yaxis) { gridMargin.left = 20; } - if (panel.rightYAxisLabel) { gridMargin.right = 20; } + var left = panel.yaxes[0]; + var right = panel.yaxes[1]; + if (left.show && left.label) { gridMargin.left = 20; } + if (right.show && right.label) { gridMargin.right = 20; } } // Function for rendering panel diff --git a/public/app/plugins/panel/graph/graph_tooltip.js b/public/app/plugins/panel/graph/graph_tooltip.js index 3e2900be4e9..7f2b83220a8 100644 --- a/public/app/plugins/panel/graph/graph_tooltip.js +++ b/public/app/plugins/panel/graph/graph_tooltip.js @@ -33,9 +33,8 @@ function ($) { return j - 1; }; - this.showTooltip = function(absoluteTime, relativeTime, innerHtml, pos) { - var body = '