From a2574ac068e0d6adec9727901784d5ac1cfbc749 Mon Sep 17 00:00:00 2001 From: Kim Christensen Date: Fri, 13 Jul 2018 13:24:56 +0200 Subject: [PATCH 01/99] Support timeFilter in templating for InfluxDB After support for queries in template variables was added to InfluxDB, it can be necessary to added dymanic time constraints. This can now be done changing the variable refresh to "On Time Range Changed" for InfluxDB --- public/app/plugins/datasource/influxdb/datasource.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/app/plugins/datasource/influxdb/datasource.ts b/public/app/plugins/datasource/influxdb/datasource.ts index f971ac2f649..b9f2b2e03fb 100644 --- a/public/app/plugins/datasource/influxdb/datasource.ts +++ b/public/app/plugins/datasource/influxdb/datasource.ts @@ -187,6 +187,11 @@ export default class InfluxDatasource { return this.$q.when({ results: [] }); } + if (options && options.range) { + var timeFilter = this.getTimeFilter({ rangeRaw: options.range }); + query = query.replace('$timeFilter', timeFilter); + } + return this._influxRequest('GET', '/query', { q: query, epoch: 'ms' }, options); } From dd81f4381de8e663c17e12595b33b46020c153cf Mon Sep 17 00:00:00 2001 From: Kim Christensen Date: Sat, 21 Jul 2018 02:13:41 +0200 Subject: [PATCH 02/99] Add unit test for InfluxDB datasource --- .../influxdb/specs/datasource.jest.ts | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 public/app/plugins/datasource/influxdb/specs/datasource.jest.ts diff --git a/public/app/plugins/datasource/influxdb/specs/datasource.jest.ts b/public/app/plugins/datasource/influxdb/specs/datasource.jest.ts new file mode 100644 index 00000000000..6ccbf843dd5 --- /dev/null +++ b/public/app/plugins/datasource/influxdb/specs/datasource.jest.ts @@ -0,0 +1,53 @@ +import InfluxDatasource from '../datasource'; +import $q from 'q'; +import { TemplateSrvStub } from 'test/specs/helpers'; + +describe('InfluxDataSource', () => { + let ctx: any = { + backendSrv: {}, + $q: $q, + templateSrv: new TemplateSrvStub(), + instanceSettings: { url: 'url', name: 'influxDb', jsonData: {} }, + }; + + beforeEach(function() { + ctx.instanceSettings.url = '/api/datasources/proxy/1'; + ctx.ds = new InfluxDatasource(ctx.instanceSettings, ctx.$q, ctx.backendSrv, ctx.templateSrv); + }); + + describe('When issuing metricFindQuery', () => { + let query = 'SELECT max(value) FROM measurement WHERE $timeFilter'; + let queryOptions: any = { + range: { + from: '2018-01-01 00:00:00', + to: '2018-01-02 00:00:00', + }, + }; + let requestQuery; + + beforeEach(async () => { + ctx.backendSrv.datasourceRequest = function(req) { + requestQuery = req.params.q; + return ctx.$q.when({ + results: [ + { + series: [ + { + name: 'measurement', + columns: ['max'], + values: [[1]], + }, + ], + }, + ], + }); + }; + + await ctx.ds.metricFindQuery(query, queryOptions).then(function(_) {}); + }); + + it('should replace $timefilter', () => { + expect(requestQuery).toMatch('time >= 1514761200000ms and time <= 1514847600000ms'); + }); + }); +}); From 8c52e2cd5703632b568225c87f311cc27b604e54 Mon Sep 17 00:00:00 2001 From: Kim Christensen Date: Mon, 23 Jul 2018 10:05:46 +0200 Subject: [PATCH 03/99] Fix timezone issues in test --- .../plugins/datasource/influxdb/specs/datasource.jest.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/datasource/influxdb/specs/datasource.jest.ts b/public/app/plugins/datasource/influxdb/specs/datasource.jest.ts index 6ccbf843dd5..10974cdad97 100644 --- a/public/app/plugins/datasource/influxdb/specs/datasource.jest.ts +++ b/public/app/plugins/datasource/influxdb/specs/datasource.jest.ts @@ -19,8 +19,8 @@ describe('InfluxDataSource', () => { let query = 'SELECT max(value) FROM measurement WHERE $timeFilter'; let queryOptions: any = { range: { - from: '2018-01-01 00:00:00', - to: '2018-01-02 00:00:00', + from: '2018-01-01T00:00:00Z', + to: '2018-01-02T00:00:00Z', }, }; let requestQuery; @@ -47,7 +47,7 @@ describe('InfluxDataSource', () => { }); it('should replace $timefilter', () => { - expect(requestQuery).toMatch('time >= 1514761200000ms and time <= 1514847600000ms'); + expect(requestQuery).toMatch('time >= 1514764800000ms and time <= 1514851200000ms'); }); }); }); From 1bb5a57036d435299bc287bb4e93eab92b77f7bd Mon Sep 17 00:00:00 2001 From: Patrick O'Carroll Date: Fri, 27 Jul 2018 13:45:16 +0200 Subject: [PATCH 04/99] frontend part with mock-team-list --- public/app/features/org/partials/profile.html | 99 +++++++++++-------- public/app/features/org/profile_ctrl.ts | 15 +++ 2 files changed, 73 insertions(+), 41 deletions(-) diff --git a/public/app/features/org/partials/profile.html b/public/app/features/org/partials/profile.html index 66e41fbb4b4..96540911290 100644 --- a/public/app/features/org/partials/profile.html +++ b/public/app/features/org/partials/profile.html @@ -3,53 +3,70 @@

User Profile

-
+ -
- Name - -
-
- Email - +
+ Name + +
+
+ Email +
-
- Username +
+ Username
-
- -
- +
+ +
+ - + -

Organizations

+

Teams

+
+ + + + + + + + + + + + + +
NameEmail
{{team.name}}{{team.email}}
+
+ +

Organizations

- - - - - - - - - - - - - - - -
NameRole
{{org.name}}{{org.role}} - - Current - - - Select - -
-
- + + + + + + + + + + + + + + + +
NameRole
{{org.name}}{{org.role}} + + Current + + + Select + +
+
diff --git a/public/app/features/org/profile_ctrl.ts b/public/app/features/org/profile_ctrl.ts index 5c62a7a5fdb..1ac950699be 100644 --- a/public/app/features/org/profile_ctrl.ts +++ b/public/app/features/org/profile_ctrl.ts @@ -4,8 +4,10 @@ import { coreModule } from 'app/core/core'; export class ProfileCtrl { user: any; old_theme: any; + teams: any = []; orgs: any = []; userForm: any; + showTeamsList = false; showOrgsList = false; readonlyLoginFields = config.disableLoginForm; navModel: any; @@ -13,6 +15,7 @@ export class ProfileCtrl { /** @ngInject **/ constructor(private backendSrv, private contextSrv, private $location, navModelSrv) { this.getUser(); + this.getUserTeams(); this.getUserOrgs(); this.navModel = navModelSrv.getNav('profile', 'profile-settings', 0); } @@ -24,6 +27,18 @@ export class ProfileCtrl { }); } + getUserTeams() { + console.log(this.backendSrv.get('/api/teams')); + this.backendSrv.get('/api/user').then(teams => { + this.user.teams = [ + { name: 'Backend', email: 'backend@grafana.com', members: 2 }, + { name: 'Frontend', email: 'frontend@grafana.com', members: 2 }, + { name: 'Ops', email: 'ops@grafana.com', members: 2 }, + ]; + this.showTeamsList = this.user.teams.length > 1; + }); + } + getUserOrgs() { this.backendSrv.get('/api/user/orgs').then(orgs => { this.orgs = orgs; From 5bea54eaaa404f7eef95d798cd87a5c52fae3294 Mon Sep 17 00:00:00 2001 From: Emil Flink Date: Fri, 3 Aug 2018 12:00:20 +0200 Subject: [PATCH 05/99] Support client certificates for LDAP servers --- conf/ldap.toml | 3 +++ docs/sources/installation/ldap.md | 3 +++ pkg/login/ldap.go | 10 ++++++++++ pkg/login/ldap_settings.go | 2 ++ 4 files changed, 18 insertions(+) diff --git a/conf/ldap.toml b/conf/ldap.toml index a74b2b6cc2c..9a7088ed823 100644 --- a/conf/ldap.toml +++ b/conf/ldap.toml @@ -15,6 +15,9 @@ start_tls = false ssl_skip_verify = false # set to the path to your root CA certificate or leave unset to use system defaults # root_ca_cert = "/path/to/certificate.crt" +# Authentication against LDAP servers requiring client certificates +# client_cert = "/path/to/client.crt" +# client_key = "/path/to/client.key" # Search user bind dn bind_dn = "cn=admin,dc=grafana,dc=org" diff --git a/docs/sources/installation/ldap.md b/docs/sources/installation/ldap.md index 9a381b9e467..b555eaf06e0 100644 --- a/docs/sources/installation/ldap.md +++ b/docs/sources/installation/ldap.md @@ -40,6 +40,9 @@ start_tls = false ssl_skip_verify = false # set to the path to your root CA certificate or leave unset to use system defaults # root_ca_cert = "/path/to/certificate.crt" +# Authentication against LDAP servers requiring client certificates +# client_cert = "/path/to/client.crt" +# client_key = "/path/to/client.key" # Search user bind dn bind_dn = "cn=admin,dc=grafana,dc=org" diff --git a/pkg/login/ldap.go b/pkg/login/ldap.go index 9e4918f0290..053778e8deb 100644 --- a/pkg/login/ldap.go +++ b/pkg/login/ldap.go @@ -59,6 +59,13 @@ func (a *ldapAuther) Dial() error { } } } + var clientCert tls.Certificate + if a.server.ClientCert != "" && a.server.ClientKey != "" { + clientCert, err = tls.LoadX509KeyPair(a.server.ClientCert, a.server.ClientKey) + if err != nil { + return err + } + } for _, host := range strings.Split(a.server.Host, " ") { address := fmt.Sprintf("%s:%d", host, a.server.Port) if a.server.UseSSL { @@ -67,6 +74,9 @@ func (a *ldapAuther) Dial() error { ServerName: host, RootCAs: certPool, } + if len(clientCert.Certificate) > 0 { + tlsCfg.Certificates = append(tlsCfg.Certificates, clientCert) + } if a.server.StartTLS { a.conn, err = ldap.Dial("tcp", address) if err == nil { diff --git a/pkg/login/ldap_settings.go b/pkg/login/ldap_settings.go index c4f5982b237..7ebfbc79ba8 100644 --- a/pkg/login/ldap_settings.go +++ b/pkg/login/ldap_settings.go @@ -21,6 +21,8 @@ type LdapServerConf struct { StartTLS bool `toml:"start_tls"` SkipVerifySSL bool `toml:"ssl_skip_verify"` RootCACert string `toml:"root_ca_cert"` + ClientCert string `toml:"client_cert"` + ClientKey string `toml:"client_key"` BindDN string `toml:"bind_dn"` BindPassword string `toml:"bind_password"` Attr LdapAttributeMap `toml:"attributes"` From b0ddc15e1ab7f28c6924e3f8448eea2561fcdb45 Mon Sep 17 00:00:00 2001 From: Patrick O'Carroll Date: Wed, 8 Aug 2018 09:23:36 +0200 Subject: [PATCH 06/99] team list for profile page + mock teams --- public/app/features/org/partials/profile.html | 4 ++-- public/app/features/org/profile_ctrl.ts | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/public/app/features/org/partials/profile.html b/public/app/features/org/partials/profile.html index 96540911290..5cbb21f488a 100644 --- a/public/app/features/org/partials/profile.html +++ b/public/app/features/org/partials/profile.html @@ -32,13 +32,13 @@ Name - Email + Members {{team.name}} - {{team.email}} + {{team.members}} diff --git a/public/app/features/org/profile_ctrl.ts b/public/app/features/org/profile_ctrl.ts index 1ac950699be..361dfa9e52f 100644 --- a/public/app/features/org/profile_ctrl.ts +++ b/public/app/features/org/profile_ctrl.ts @@ -28,12 +28,11 @@ export class ProfileCtrl { } getUserTeams() { - console.log(this.backendSrv.get('/api/teams')); this.backendSrv.get('/api/user').then(teams => { this.user.teams = [ - { name: 'Backend', email: 'backend@grafana.com', members: 2 }, - { name: 'Frontend', email: 'frontend@grafana.com', members: 2 }, - { name: 'Ops', email: 'ops@grafana.com', members: 2 }, + { name: 'Backend', email: 'backend@grafana.com', members: 5 }, + { name: 'Frontend', email: 'frontend@grafana.com', members: 4 }, + { name: 'Ops', email: 'ops@grafana.com', members: 6 }, ]; this.showTeamsList = this.user.teams.length > 1; }); From beddfdd86b33a965ba30df121c76ce720e83a809 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Wed, 8 Aug 2018 10:26:05 +0200 Subject: [PATCH 07/99] add api route for retrieving teams of signed in user --- docs/sources/http_api/user.md | 33 +++++++++++++++++++++++++++++++++ pkg/api/api.go | 1 + pkg/api/user.go | 15 +++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/docs/sources/http_api/user.md b/docs/sources/http_api/user.md index 134c1842851..b9047187b2d 100644 --- a/docs/sources/http_api/user.md +++ b/docs/sources/http_api/user.md @@ -363,6 +363,39 @@ Content-Type: application/json ] ``` +## Teams that the actual User is member of + +`GET /api/user/teams` + +Return a list of all teams that the current user is member of. + +**Example Request**: + +```http +GET /api/user/teams HTTP/1.1 +Accept: application/json +Content-Type: application/json +Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk +``` + +**Example Response**: + +```http +HTTP/1.1 200 +Content-Type: application/json + +[ + { + "id": 1, + "orgId": 1, + "name": "MyTestTeam", + "email": "", + "avatarUrl": "\/avatar\/3f49c15916554246daa714b9bd0ee398", + "memberCount": 1 + } +] +``` + ## Star a dashboard `POST /api/user/stars/dashboard/:dashboardId` diff --git a/pkg/api/api.go b/pkg/api/api.go index 84425fdae3d..906481bbb8a 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -120,6 +120,7 @@ func (hs *HTTPServer) registerRoutes() { userRoute.Put("/", bind(m.UpdateUserCommand{}), Wrap(UpdateSignedInUser)) userRoute.Post("/using/:id", Wrap(UserSetUsingOrg)) userRoute.Get("/orgs", Wrap(GetSignedInUserOrgList)) + userRoute.Get("/teams", Wrap(GetSignedInUserTeamList)) userRoute.Post("/stars/dashboard/:id", Wrap(StarDashboard)) userRoute.Delete("/stars/dashboard/:id", Wrap(UnstarDashboard)) diff --git a/pkg/api/user.go b/pkg/api/user.go index 725c623575f..4b916202e65 100644 --- a/pkg/api/user.go +++ b/pkg/api/user.go @@ -111,6 +111,21 @@ func GetSignedInUserOrgList(c *m.ReqContext) Response { return getUserOrgList(c.UserId) } +// GET /api/user/teams +func GetSignedInUserTeamList(c *m.ReqContext) Response { + query := m.GetTeamsByUserQuery{OrgId: c.OrgId, UserId: c.UserId} + + if err := bus.Dispatch(&query); err != nil { + return Error(500, "Failed to get user teams", err) + } + + for _, team := range query.Result { + team.AvatarUrl = dtos.GetGravatarUrlWithDefault(team.Email, team.Name) + } + + return JSON(200, query.Result) +} + // GET /api/user/:id/orgs func GetUserOrgList(c *m.ReqContext) Response { return getUserOrgList(c.ParamsInt64(":id")) From ca06893e691b07f938788af65e8d8847e05be9fc Mon Sep 17 00:00:00 2001 From: Patrick O'Carroll Date: Wed, 8 Aug 2018 10:50:27 +0200 Subject: [PATCH 08/99] removed mock-teams, now gets teams from backend --- public/app/features/org/partials/profile.html | 4 +--- public/app/features/org/profile_ctrl.ts | 10 +++------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/public/app/features/org/partials/profile.html b/public/app/features/org/partials/profile.html index 5cbb21f488a..790872d9789 100644 --- a/public/app/features/org/partials/profile.html +++ b/public/app/features/org/partials/profile.html @@ -32,13 +32,11 @@ Name - Members - + {{team.name}} - {{team.members}} diff --git a/public/app/features/org/profile_ctrl.ts b/public/app/features/org/profile_ctrl.ts index 361dfa9e52f..6cfcdc2e64c 100644 --- a/public/app/features/org/profile_ctrl.ts +++ b/public/app/features/org/profile_ctrl.ts @@ -28,13 +28,9 @@ export class ProfileCtrl { } getUserTeams() { - this.backendSrv.get('/api/user').then(teams => { - this.user.teams = [ - { name: 'Backend', email: 'backend@grafana.com', members: 5 }, - { name: 'Frontend', email: 'frontend@grafana.com', members: 4 }, - { name: 'Ops', email: 'ops@grafana.com', members: 6 }, - ]; - this.showTeamsList = this.user.teams.length > 1; + this.backendSrv.get('/api/user/teams').then(teams => { + this.teams = teams; + this.showTeamsList = this.teams.length > 1; }); } From a94406ac53f58e4617d30f7cd18d11613ed2476c Mon Sep 17 00:00:00 2001 From: Patrick O'Carroll Date: Wed, 8 Aug 2018 11:22:47 +0200 Subject: [PATCH 09/99] added more info about the teams --- public/app/features/org/partials/profile.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/public/app/features/org/partials/profile.html b/public/app/features/org/partials/profile.html index 790872d9789..b204c223138 100644 --- a/public/app/features/org/partials/profile.html +++ b/public/app/features/org/partials/profile.html @@ -31,12 +31,18 @@ + + + + + +
NameEmailMembers
{{team.name}}{{team.email}}{{team.memberCount}}
From 8dfe4a97efb0389f8c0ea77f823670a01e8361ae Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Wed, 8 Aug 2018 16:01:01 +0200 Subject: [PATCH 10/99] use uid when linking to dashboards internally in a dashboard --- public/app/features/dashlinks/module.ts | 3 +-- public/app/features/panellinks/link_srv.ts | 4 ++++ public/app/features/panellinks/module.ts | 7 ++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/public/app/features/dashlinks/module.ts b/public/app/features/dashlinks/module.ts index 380144dbcd5..6322e39f290 100644 --- a/public/app/features/dashlinks/module.ts +++ b/public/app/features/dashlinks/module.ts @@ -144,8 +144,7 @@ export class DashLinksContainerCtrl { if (dash.id !== currentDashId) { memo.push({ title: dash.title, - url: 'dashboard/' + dash.uri, - target: link.target, + url: dash.url, icon: 'fa fa-th-large', keepTime: link.keepTime, includeVars: link.includeVars, diff --git a/public/app/features/panellinks/link_srv.ts b/public/app/features/panellinks/link_srv.ts index b20294485a5..9aee17f83ed 100644 --- a/public/app/features/panellinks/link_srv.ts +++ b/public/app/features/panellinks/link_srv.ts @@ -77,6 +77,10 @@ export class LinkSrv { info.target = link.targetBlank ? '_blank' : '_self'; info.href = this.templateSrv.replace(link.url || '', scopedVars); info.title = this.templateSrv.replace(link.title || '', scopedVars); + } else if (link.url) { + info.href = link.url; + info.title = this.templateSrv.replace(link.title || '', scopedVars); + info.target = link.targetBlank ? '_blank' : ''; } else if (link.dashUri) { info.href = 'dashboard/' + link.dashUri + '?'; info.title = this.templateSrv.replace(link.title || '', scopedVars); diff --git a/public/app/features/panellinks/module.ts b/public/app/features/panellinks/module.ts index 034e99f4296..66d4bd5b37f 100644 --- a/public/app/features/panellinks/module.ts +++ b/public/app/features/panellinks/module.ts @@ -39,7 +39,12 @@ export class PanelLinksEditorCtrl { backendSrv.search({ query: link.dashboard }).then(function(hits) { var dashboard = _.find(hits, { title: link.dashboard }); if (dashboard) { - link.dashUri = dashboard.uri; + if (dashboard.url) { + link.url = dashboard.url; + } else { + // To support legacy url's + link.dashUri = dashboard.uri; + } link.title = dashboard.title; } }); From e97251fe28198055fa054e50ccd4c42d5ca6bd8e Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Wed, 8 Aug 2018 16:01:35 +0200 Subject: [PATCH 11/99] skip target _self to remove full page reload --- public/app/features/dashlinks/module.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/public/app/features/dashlinks/module.ts b/public/app/features/dashlinks/module.ts index 6322e39f290..4d80f3632e6 100644 --- a/public/app/features/dashlinks/module.ts +++ b/public/app/features/dashlinks/module.ts @@ -145,6 +145,7 @@ export class DashLinksContainerCtrl { memo.push({ title: dash.title, url: dash.url, + target: link.target === '_self' ? '' : link.target, icon: 'fa fa-th-large', keepTime: link.keepTime, includeVars: link.includeVars, From b987aee7cffe873a01380b4ed6dbf60838f97736 Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Sat, 21 Jul 2018 20:00:26 +0200 Subject: [PATCH 12/99] add timescaledb option to postgres datasource This adds an option to the postgres datasource config for timescaledb support. When set to auto it will check for timescaledb when testing the datasource. When this option is enabled the $__timeGroup macro will use the time_bucket function from timescaledb to group times by an interval. This also passes the datasource edit control to testDatasource to allow for setting additional settings, this might be useful for other datasources aswell which have optional or version dependant features which can be queried. --- pkg/tsdb/postgres/macros.go | 8 +++- pkg/tsdb/postgres/macros_test.go | 22 +++++++++- pkg/tsdb/postgres/postgres_test.go | 23 ++++++++++- public/app/features/plugins/ds_edit_ctrl.ts | 2 +- .../plugins/datasource/postgres/datasource.ts | 40 +++++++++---------- .../datasource/postgres/partials/config.html | 14 +++++++ 6 files changed, 85 insertions(+), 24 deletions(-) diff --git a/pkg/tsdb/postgres/macros.go b/pkg/tsdb/postgres/macros.go index aebdc55d1d7..4f1d3f72558 100644 --- a/pkg/tsdb/postgres/macros.go +++ b/pkg/tsdb/postgres/macros.go @@ -130,13 +130,19 @@ func (m *postgresMacroEngine) evaluateMacro(name string, args []string) (string, m.query.Model.Set("fillValue", floatVal) } } - return fmt.Sprintf("floor(extract(epoch from %s)/%v)*%v", args[0], interval.Seconds(), interval.Seconds()), nil + + if m.query.DataSource.JsonData.Get("timescaledb").MustString("auto") == "enabled" { + return fmt.Sprintf("time_bucket('%vs',%s) AS time", interval.Seconds(), args[0]), nil + } else { + return fmt.Sprintf("floor(extract(epoch from %s)/%v)*%v AS time", args[0], interval.Seconds(), interval.Seconds()), nil + } case "__timeGroupAlias": tg, err := m.evaluateMacro("__timeGroup", args) if err == nil { return tg + " AS \"time\"", err } return "", err + case "__unixEpochFilter": if len(args) == 0 { return "", fmt.Errorf("missing time column argument for macro %v", name) diff --git a/pkg/tsdb/postgres/macros_test.go b/pkg/tsdb/postgres/macros_test.go index beeea93893b..6c4ba8305b1 100644 --- a/pkg/tsdb/postgres/macros_test.go +++ b/pkg/tsdb/postgres/macros_test.go @@ -6,6 +6,8 @@ import ( "testing" "time" + "github.com/grafana/grafana/pkg/components/simplejson" + "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/tsdb" . "github.com/smartystreets/goconvey/convey" ) @@ -13,7 +15,9 @@ import ( func TestMacroEngine(t *testing.T) { Convey("MacroEngine", t, func() { engine := newPostgresMacroEngine() - query := &tsdb.Query{} + query := &tsdb.Query{DataSource: &models.DataSource{JsonData: simplejson.New()}} + queryTS := &tsdb.Query{DataSource: &models.DataSource{JsonData: simplejson.New()}} + queryTS.DataSource.JsonData.Set("timescaledb", "enabled") Convey("Given a time range between 2018-04-12 00:00 and 2018-04-12 00:05", func() { from := time.Date(2018, 4, 12, 18, 0, 0, 0, time.UTC) @@ -83,6 +87,22 @@ func TestMacroEngine(t *testing.T) { So(sql2, ShouldEqual, sql+" AS \"time\"") }) + Convey("interpolate __timeGroup function with TimescaleDB enabled", func() { + + sql, err := engine.Interpolate(queryTS, timeRange, "GROUP BY $__timeGroup(time_column,'5m')") + So(err, ShouldBeNil) + + So(sql, ShouldEqual, "GROUP BY time_bucket('300s',time_column) AS time") + }) + + Convey("interpolate __timeGroup function with spaces between args and TimescaleDB enabled", func() { + + sql, err := engine.Interpolate(queryTS, timeRange, "GROUP BY $__timeGroup(time_column , '5m')") + So(err, ShouldBeNil) + + So(sql, ShouldEqual, "GROUP BY time_bucket('300s',time_column) AS time") + }) + Convey("interpolate __timeTo function", func() { sql, err := engine.Interpolate(query, timeRange, "select $__timeTo(time_column)") So(err, ShouldBeNil) diff --git a/pkg/tsdb/postgres/postgres_test.go b/pkg/tsdb/postgres/postgres_test.go index 9e363529df1..27888b318a9 100644 --- a/pkg/tsdb/postgres/postgres_test.go +++ b/pkg/tsdb/postgres/postgres_test.go @@ -27,7 +27,7 @@ import ( // use to verify that the generated data are vizualized as expected, see // devenv/README.md for setup instructions. func TestPostgres(t *testing.T) { - // change to true to run the MySQL tests + // change to true to run the PostgreSQL tests runPostgresTests := false // runPostgresTests := true @@ -102,6 +102,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": "SELECT * FROM postgres_types", "format": "table", @@ -182,6 +183,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": "SELECT $__timeGroup(time, '5m') AS time, avg(value) as value FROM metric GROUP BY 1 ORDER BY 1", "format": "time_series", @@ -226,6 +228,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": "SELECT $__timeGroup(time, '5m', NULL) AS time, avg(value) as value FROM metric GROUP BY 1 ORDER BY 1", "format": "time_series", @@ -280,6 +283,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": "SELECT $__timeGroup(time, '5m', 1.5) AS time, avg(value) as value FROM metric GROUP BY 1 ORDER BY 1", "format": "time_series", @@ -401,6 +405,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "timeInt64" as time, "timeInt64" FROM metric_values ORDER BY time LIMIT 1`, "format": "time_series", @@ -423,6 +428,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "timeInt64Nullable" as time, "timeInt64Nullable" FROM metric_values ORDER BY time LIMIT 1`, "format": "time_series", @@ -445,6 +451,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "timeFloat64" as time, "timeFloat64" FROM metric_values ORDER BY time LIMIT 1`, "format": "time_series", @@ -467,6 +474,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "timeFloat64Nullable" as time, "timeFloat64Nullable" FROM metric_values ORDER BY time LIMIT 1`, "format": "time_series", @@ -511,6 +519,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "timeInt32Nullable" as time, "timeInt32Nullable" FROM metric_values ORDER BY time LIMIT 1`, "format": "time_series", @@ -533,6 +542,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "timeFloat32" as time, "timeFloat32" FROM metric_values ORDER BY time LIMIT 1`, "format": "time_series", @@ -555,6 +565,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "timeFloat32Nullable" as time, "timeFloat32Nullable" FROM metric_values ORDER BY time LIMIT 1`, "format": "time_series", @@ -577,6 +588,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT $__timeEpoch(time), measurement || ' - value one' as metric, "valueOne" FROM metric_values ORDER BY 1`, "format": "time_series", @@ -625,6 +637,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT $__timeEpoch(time), "valueOne", "valueTwo" FROM metric_values ORDER BY 1`, "format": "time_series", @@ -682,6 +695,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "time_sec" as time, description as text, tags FROM event WHERE $__unixEpochFilter(time_sec) AND tags='deploy' ORDER BY 1 ASC`, "format": "table", @@ -705,6 +719,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "time_sec" as time, description as text, tags FROM event WHERE $__unixEpochFilter(time_sec) AND tags='ticket' ORDER BY 1 ASC`, "format": "table", @@ -731,6 +746,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": fmt.Sprintf(`SELECT CAST('%s' AS TIMESTAMP) as time, @@ -761,6 +777,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": fmt.Sprintf(`SELECT %d as time, @@ -791,6 +808,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": fmt.Sprintf(`SELECT cast(%d as bigint) as time, @@ -821,6 +839,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": fmt.Sprintf(`SELECT %d as time, @@ -849,6 +868,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT cast(null as bigint) as time, @@ -877,6 +897,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT cast(null as timestamp) as time, diff --git a/public/app/features/plugins/ds_edit_ctrl.ts b/public/app/features/plugins/ds_edit_ctrl.ts index 542e9cc3648..6e05ddc36be 100644 --- a/public/app/features/plugins/ds_edit_ctrl.ts +++ b/public/app/features/plugins/ds_edit_ctrl.ts @@ -132,7 +132,7 @@ export class DataSourceEditCtrl { this.backendSrv .withNoBackendCache(() => { return datasource - .testDatasource() + .testDatasource(this) .then(result => { this.testing.message = result.message; this.testing.status = result.status; diff --git a/public/app/plugins/datasource/postgres/datasource.ts b/public/app/plugins/datasource/postgres/datasource.ts index 644c9e48b9b..88c928e425a 100644 --- a/public/app/plugins/datasource/postgres/datasource.ts +++ b/public/app/plugins/datasource/postgres/datasource.ts @@ -123,27 +123,27 @@ export class PostgresDatasource { .then(data => this.responseParser.parseMetricFindQueryResult(refId, data)); } - testDatasource() { - return this.backendSrv - .datasourceRequest({ - url: '/api/tsdb/query', - method: 'POST', - data: { - from: '5m', - to: 'now', - queries: [ - { - refId: 'A', - intervalMs: 1, - maxDataPoints: 1, - datasourceId: this.id, - rawSql: 'SELECT 1', - format: 'table', - }, - ], - }, - }) + testDatasource(control) { + return this.metricFindQuery('SELECT 1', {}) .then(res => { + if (control.current.jsonData.timescaledb === 'auto') { + return this.metricFindQuery("SELECT 1 FROM pg_extension WHERE extname='timescaledb'", {}) + .then(res => { + if (res.length === 1) { + control.current.jsonData.timescaledb = 'enabled'; + return this.backendSrv.put('/api/datasources/' + this.id, control.current).then(settings => { + control.current = settings.datasource; + control.updateFrontendSettings(); + return { status: 'success', message: 'Database Connection OK, TimescaleDB found' }; + }); + } + throw new Error('timescaledb not found'); + }) + .catch(err => { + // query errored out or empty so timescaledb is not available + return { status: 'success', message: 'Database Connection OK' }; + }); + } return { status: 'success', message: 'Database Connection OK' }; }) .catch(err => { diff --git a/public/app/plugins/datasource/postgres/partials/config.html b/public/app/plugins/datasource/postgres/partials/config.html index 77f0dcfa4a5..07568fdc459 100644 --- a/public/app/plugins/datasource/postgres/partials/config.html +++ b/public/app/plugins/datasource/postgres/partials/config.html @@ -38,6 +38,20 @@
+

PostgreSQL details

+ +
+
+ +
+ + + This option determines whether TimescaleDB features will be used. + +
+
+
+
User Permission
From c3aad100472063957ecf869115cde521c7d5ccf9 Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Thu, 9 Aug 2018 09:19:16 +0200 Subject: [PATCH 13/99] change timescaledb to checkbox instead of select --- pkg/tsdb/postgres/macros.go | 2 +- pkg/tsdb/postgres/macros_test.go | 2 +- .../plugins/datasource/postgres/datasource.ts | 20 +------------------ .../datasource/postgres/partials/config.html | 8 +------- 4 files changed, 4 insertions(+), 28 deletions(-) diff --git a/pkg/tsdb/postgres/macros.go b/pkg/tsdb/postgres/macros.go index 4f1d3f72558..69aa04f45f5 100644 --- a/pkg/tsdb/postgres/macros.go +++ b/pkg/tsdb/postgres/macros.go @@ -131,7 +131,7 @@ func (m *postgresMacroEngine) evaluateMacro(name string, args []string) (string, } } - if m.query.DataSource.JsonData.Get("timescaledb").MustString("auto") == "enabled" { + if m.query.DataSource.JsonData.Get("timescaledb").MustBool() { return fmt.Sprintf("time_bucket('%vs',%s) AS time", interval.Seconds(), args[0]), nil } else { return fmt.Sprintf("floor(extract(epoch from %s)/%v)*%v AS time", args[0], interval.Seconds(), interval.Seconds()), nil diff --git a/pkg/tsdb/postgres/macros_test.go b/pkg/tsdb/postgres/macros_test.go index 6c4ba8305b1..8b2fd7a32f8 100644 --- a/pkg/tsdb/postgres/macros_test.go +++ b/pkg/tsdb/postgres/macros_test.go @@ -17,7 +17,7 @@ func TestMacroEngine(t *testing.T) { engine := newPostgresMacroEngine() query := &tsdb.Query{DataSource: &models.DataSource{JsonData: simplejson.New()}} queryTS := &tsdb.Query{DataSource: &models.DataSource{JsonData: simplejson.New()}} - queryTS.DataSource.JsonData.Set("timescaledb", "enabled") + queryTS.DataSource.JsonData.Set("timescaledb", true) Convey("Given a time range between 2018-04-12 00:00 and 2018-04-12 00:05", func() { from := time.Date(2018, 4, 12, 18, 0, 0, 0, time.UTC) diff --git a/public/app/plugins/datasource/postgres/datasource.ts b/public/app/plugins/datasource/postgres/datasource.ts index 88c928e425a..3d48dce45b2 100644 --- a/public/app/plugins/datasource/postgres/datasource.ts +++ b/public/app/plugins/datasource/postgres/datasource.ts @@ -123,27 +123,9 @@ export class PostgresDatasource { .then(data => this.responseParser.parseMetricFindQueryResult(refId, data)); } - testDatasource(control) { + testDatasource() { return this.metricFindQuery('SELECT 1', {}) .then(res => { - if (control.current.jsonData.timescaledb === 'auto') { - return this.metricFindQuery("SELECT 1 FROM pg_extension WHERE extname='timescaledb'", {}) - .then(res => { - if (res.length === 1) { - control.current.jsonData.timescaledb = 'enabled'; - return this.backendSrv.put('/api/datasources/' + this.id, control.current).then(settings => { - control.current = settings.datasource; - control.updateFrontendSettings(); - return { status: 'success', message: 'Database Connection OK, TimescaleDB found' }; - }); - } - throw new Error('timescaledb not found'); - }) - .catch(err => { - // query errored out or empty so timescaledb is not available - return { status: 'success', message: 'Database Connection OK' }; - }); - } return { status: 'success', message: 'Database Connection OK' }; }) .catch(err => { diff --git a/public/app/plugins/datasource/postgres/partials/config.html b/public/app/plugins/datasource/postgres/partials/config.html index 07568fdc459..14b0b03ddb5 100644 --- a/public/app/plugins/datasource/postgres/partials/config.html +++ b/public/app/plugins/datasource/postgres/partials/config.html @@ -42,13 +42,7 @@
- -
- - - This option determines whether TimescaleDB features will be used. - -
+
From acd1acba2d426270ddb54a6e9b233562ec5f1ebd Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Thu, 9 Aug 2018 09:22:02 +0200 Subject: [PATCH 14/99] revert passing ctrl to testDatasource --- public/app/features/plugins/ds_edit_ctrl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/features/plugins/ds_edit_ctrl.ts b/public/app/features/plugins/ds_edit_ctrl.ts index 6e05ddc36be..542e9cc3648 100644 --- a/public/app/features/plugins/ds_edit_ctrl.ts +++ b/public/app/features/plugins/ds_edit_ctrl.ts @@ -132,7 +132,7 @@ export class DataSourceEditCtrl { this.backendSrv .withNoBackendCache(() => { return datasource - .testDatasource(this) + .testDatasource() .then(result => { this.testing.message = result.message; this.testing.status = result.status; From d2984f3b0f578423a56444516682f475842fa6e7 Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Thu, 9 Aug 2018 10:14:14 +0200 Subject: [PATCH 15/99] fix rebase error --- pkg/tsdb/postgres/macros.go | 4 ++-- pkg/tsdb/postgres/macros_test.go | 4 ++-- pkg/tsdb/postgres/postgres_test.go | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/tsdb/postgres/macros.go b/pkg/tsdb/postgres/macros.go index 69aa04f45f5..d9f97e9262c 100644 --- a/pkg/tsdb/postgres/macros.go +++ b/pkg/tsdb/postgres/macros.go @@ -132,9 +132,9 @@ func (m *postgresMacroEngine) evaluateMacro(name string, args []string) (string, } if m.query.DataSource.JsonData.Get("timescaledb").MustBool() { - return fmt.Sprintf("time_bucket('%vs',%s) AS time", interval.Seconds(), args[0]), nil + return fmt.Sprintf("time_bucket('%vs',%s)", interval.Seconds(), args[0]), nil } else { - return fmt.Sprintf("floor(extract(epoch from %s)/%v)*%v AS time", args[0], interval.Seconds(), interval.Seconds()), nil + return fmt.Sprintf("floor(extract(epoch from %s)/%v)*%v", args[0], interval.Seconds(), interval.Seconds()), nil } case "__timeGroupAlias": tg, err := m.evaluateMacro("__timeGroup", args) diff --git a/pkg/tsdb/postgres/macros_test.go b/pkg/tsdb/postgres/macros_test.go index 8b2fd7a32f8..449331224c2 100644 --- a/pkg/tsdb/postgres/macros_test.go +++ b/pkg/tsdb/postgres/macros_test.go @@ -92,7 +92,7 @@ func TestMacroEngine(t *testing.T) { sql, err := engine.Interpolate(queryTS, timeRange, "GROUP BY $__timeGroup(time_column,'5m')") So(err, ShouldBeNil) - So(sql, ShouldEqual, "GROUP BY time_bucket('300s',time_column) AS time") + So(sql, ShouldEqual, "GROUP BY time_bucket('300s',time_column)") }) Convey("interpolate __timeGroup function with spaces between args and TimescaleDB enabled", func() { @@ -100,7 +100,7 @@ func TestMacroEngine(t *testing.T) { sql, err := engine.Interpolate(queryTS, timeRange, "GROUP BY $__timeGroup(time_column , '5m')") So(err, ShouldBeNil) - So(sql, ShouldEqual, "GROUP BY time_bucket('300s',time_column) AS time") + So(sql, ShouldEqual, "GROUP BY time_bucket('300s',time_column)") }) Convey("interpolate __timeTo function", func() { diff --git a/pkg/tsdb/postgres/postgres_test.go b/pkg/tsdb/postgres/postgres_test.go index 27888b318a9..87b7f916ca9 100644 --- a/pkg/tsdb/postgres/postgres_test.go +++ b/pkg/tsdb/postgres/postgres_test.go @@ -311,6 +311,7 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { + DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": "SELECT $__timeGroup(time, '5m', previous), avg(value) as value FROM metric GROUP BY 1 ORDER BY 1", "format": "time_series", From a4a33d80dbe1ee0dfe4a3a53a434c90919842e76 Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Thu, 9 Aug 2018 17:30:46 +0200 Subject: [PATCH 16/99] mention time_bucket in timescaledb tooltip --- public/app/plugins/datasource/postgres/partials/config.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/postgres/partials/config.html b/public/app/plugins/datasource/postgres/partials/config.html index 14b0b03ddb5..a1783c09dc4 100644 --- a/public/app/plugins/datasource/postgres/partials/config.html +++ b/public/app/plugins/datasource/postgres/partials/config.html @@ -42,7 +42,7 @@
- +
From 9188f7423c6340c4898792b0fba594729869d19f Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Mon, 6 Aug 2018 09:06:29 +0200 Subject: [PATCH 17/99] Begin conversion --- .../panel/heatmap/specs/renderer.jest.ts | 319 ++++++++++++++++++ 1 file changed, 319 insertions(+) create mode 100644 public/app/plugins/panel/heatmap/specs/renderer.jest.ts diff --git a/public/app/plugins/panel/heatmap/specs/renderer.jest.ts b/public/app/plugins/panel/heatmap/specs/renderer.jest.ts new file mode 100644 index 00000000000..4e0e8d1b6a9 --- /dev/null +++ b/public/app/plugins/panel/heatmap/specs/renderer.jest.ts @@ -0,0 +1,319 @@ +// import { describe, beforeEach, it, sinon, expect, angularMocks } from '../../../../../test/lib/common'; + +import '../module'; +import angular from 'angular'; +import $ from 'jquery'; +// import helpers from 'test/specs/helpers'; +import TimeSeries from 'app/core/time_series2'; +import moment from 'moment'; +import { Emitter } from 'app/core/core'; +import rendering from '../rendering'; +import { convertToHeatMap, convertToCards, histogramToHeatmap, calculateBucketSize } from '../heatmap_data_converter'; + +describe('grafanaHeatmap', function() { + // beforeEach(angularMocks.module('grafana.core')); + + function heatmapScenario(desc, func, elementWidth = 500) { + describe(desc, function() { + var ctx: any = {}; + + ctx.setup = function(setupFunc) { + // beforeEach( + // angularMocks.module(function($provide) { + // $provide.value('timeSrv', new helpers.TimeSrvStub()); + // }) + // ); + + beforeEach(() => { + // angularMocks.inject(function($rootScope, $compile) { + var ctrl: any = { + colorSchemes: [ + { + name: 'Oranges', + value: 'interpolateOranges', + invert: 'dark', + }, + { name: 'Reds', value: 'interpolateReds', invert: 'dark' }, + ], + // events: new Emitter(), + height: 200, + panel: { + heatmap: {}, + cards: { + cardPadding: null, + cardRound: null, + }, + color: { + mode: 'spectrum', + cardColor: '#b4ff00', + colorScale: 'linear', + exponent: 0.5, + colorScheme: 'interpolateOranges', + fillBackground: false, + }, + legend: { + show: false, + }, + xBucketSize: 1000, + xBucketNumber: null, + yBucketSize: 1, + yBucketNumber: null, + xAxis: { + show: true, + }, + yAxis: { + show: true, + format: 'short', + decimals: null, + logBase: 1, + splitFactor: null, + min: null, + max: null, + removeZeroValues: false, + }, + tooltip: { + show: true, + seriesStat: false, + showHistogram: false, + }, + highlightCards: true, + }, + renderingCompleted: jest.fn(), + hiddenSeries: {}, + dashboard: { + getTimezone: () => 'utc', + }, + range: { + from: moment.utc('01 Mar 2017 10:00:00', 'DD MMM YYYY HH:mm:ss'), + to: moment.utc('01 Mar 2017 11:00:00', 'DD MMM YYYY HH:mm:ss'), + }, + }; + + var scope = $rootScope.$new(); + scope.ctrl = ctrl; + + ctx.series = []; + ctx.series.push( + new TimeSeries({ + datapoints: [[1, 1422774000000], [2, 1422774060000]], + alias: 'series1', + }) + ); + ctx.series.push( + new TimeSeries({ + datapoints: [[2, 1422774000000], [3, 1422774060000]], + alias: 'series2', + }) + ); + + ctx.data = { + heatmapStats: { + min: 1, + max: 3, + minLog: 1, + }, + xBucketSize: ctrl.panel.xBucketSize, + yBucketSize: ctrl.panel.yBucketSize, + }; + + setupFunc(ctrl, ctx); + + let logBase = ctrl.panel.yAxis.logBase; + let bucketsData; + if (ctrl.panel.dataFormat === 'tsbuckets') { + bucketsData = histogramToHeatmap(ctx.series); + } else { + bucketsData = convertToHeatMap(ctx.series, ctx.data.yBucketSize, ctx.data.xBucketSize, logBase); + } + ctx.data.buckets = bucketsData; + + let { cards, cardStats } = convertToCards(bucketsData); + ctx.data.cards = cards; + ctx.data.cardStats = cardStats; + + let elemHtml = ` +
+
+
+
+
`; + + var element = $.parseHTML(elemHtml); + // $compile(element)(scope); + // scope.$digest(); + + ctrl.data = ctx.data; + ctx.element = element; + rendering(scope, $(element), [], ctrl); + ctrl.events.emit('render'); + }); + }; + + func(ctx); + }); + } + + heatmapScenario('default options', function(ctx) { + ctx.setup(function(ctrl) { + ctrl.panel.yAxis.logBase = 1; + }); + + it('should draw correct Y axis', function() { + var yTicks = getTicks(ctx.element, '.axis-y'); + expect(yTicks).toEqual(['1', '2', '3']); + }); + + it('should draw correct X axis', function() { + var xTicks = getTicks(ctx.element, '.axis-x'); + let expectedTicks = [ + formatTime('01 Mar 2017 10:00:00'), + formatTime('01 Mar 2017 10:15:00'), + formatTime('01 Mar 2017 10:30:00'), + formatTime('01 Mar 2017 10:45:00'), + formatTime('01 Mar 2017 11:00:00'), + ]; + expect(xTicks).toEqual(expectedTicks); + }); + }); + + heatmapScenario('when logBase is 2', function(ctx) { + ctx.setup(function(ctrl) { + ctrl.panel.yAxis.logBase = 2; + }); + + it('should draw correct Y axis', function() { + var yTicks = getTicks(ctx.element, '.axis-y'); + expect(yTicks).toEqual(['1', '2', '4']); + }); + }); + + heatmapScenario('when logBase is 10', function(ctx) { + ctx.setup(function(ctrl, ctx) { + ctrl.panel.yAxis.logBase = 10; + + ctx.series.push( + new TimeSeries({ + datapoints: [[10, 1422774000000], [20, 1422774060000]], + alias: 'series3', + }) + ); + ctx.data.heatmapStats.max = 20; + }); + + it('should draw correct Y axis', function() { + var yTicks = getTicks(ctx.element, '.axis-y'); + expect(yTicks).toEqual(['1', '10', '100']); + }); + }); + + heatmapScenario('when logBase is 32', function(ctx) { + ctx.setup(function(ctrl) { + ctrl.panel.yAxis.logBase = 32; + + ctx.series.push( + new TimeSeries({ + datapoints: [[10, 1422774000000], [100, 1422774060000]], + alias: 'series3', + }) + ); + ctx.data.heatmapStats.max = 100; + }); + + it('should draw correct Y axis', function() { + var yTicks = getTicks(ctx.element, '.axis-y'); + expect(yTicks).toEqual(['1', '32', '1.0 K']); + }); + }); + + heatmapScenario('when logBase is 1024', function(ctx) { + ctx.setup(function(ctrl) { + ctrl.panel.yAxis.logBase = 1024; + + ctx.series.push( + new TimeSeries({ + datapoints: [[2000, 1422774000000], [300000, 1422774060000]], + alias: 'series3', + }) + ); + ctx.data.heatmapStats.max = 300000; + }); + + it('should draw correct Y axis', function() { + var yTicks = getTicks(ctx.element, '.axis-y'); + expect(yTicks).toEqual(['1', '1 K', '1.0 Mil']); + }); + }); + + heatmapScenario('when Y axis format set to "none"', function(ctx) { + ctx.setup(function(ctrl) { + ctrl.panel.yAxis.logBase = 1; + ctrl.panel.yAxis.format = 'none'; + ctx.data.heatmapStats.max = 10000; + }); + + it('should draw correct Y axis', function() { + var yTicks = getTicks(ctx.element, '.axis-y'); + expect(yTicks).toEqual(['0', '2000', '4000', '6000', '8000', '10000', '12000']); + }); + }); + + heatmapScenario('when Y axis format set to "second"', function(ctx) { + ctx.setup(function(ctrl) { + ctrl.panel.yAxis.logBase = 1; + ctrl.panel.yAxis.format = 's'; + ctx.data.heatmapStats.max = 3600; + }); + + it('should draw correct Y axis', function() { + var yTicks = getTicks(ctx.element, '.axis-y'); + expect(yTicks).toEqual(['0 ns', '17 min', '33 min', '50 min', '1.11 hour']); + }); + }); + + heatmapScenario('when data format is Time series buckets', function(ctx) { + ctx.setup(function(ctrl, ctx) { + ctrl.panel.dataFormat = 'tsbuckets'; + + const series = [ + { + alias: '1', + datapoints: [[1000, 1422774000000], [200000, 1422774060000]], + }, + { + alias: '2', + datapoints: [[3000, 1422774000000], [400000, 1422774060000]], + }, + { + alias: '3', + datapoints: [[2000, 1422774000000], [300000, 1422774060000]], + }, + ]; + ctx.series = series.map(s => new TimeSeries(s)); + + ctx.data.tsBuckets = series.map(s => s.alias).concat(''); + ctx.data.yBucketSize = 1; + let xBucketBoundSet = series[0].datapoints.map(dp => dp[1]); + ctx.data.xBucketSize = calculateBucketSize(xBucketBoundSet); + }); + + it('should draw correct Y axis', function() { + var yTicks = getTicks(ctx.element, '.axis-y'); + expect(yTicks).toEqual(['1', '2', '3', '']); + }); + }); +}); + +function getTicks(element, axisSelector) { + return element + .find(axisSelector) + .find('text') + .map(function() { + return this.textContent; + }) + .get(); +} + +function formatTime(timeStr) { + let format = 'HH:mm'; + return moment.utc(timeStr, 'DD MMM YYYY HH:mm:ss').format(format); +} From e832f91fb6331ed76ae7fa94e714544c0be516ec Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Fri, 10 Aug 2018 13:37:15 +0200 Subject: [PATCH 18/99] Fix initial state in split explore - remove `edited` from query state to reset queries - clear more properties in state --- public/app/containers/Explore/Explore.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/public/app/containers/Explore/Explore.tsx b/public/app/containers/Explore/Explore.tsx index 9620ac4f91b..d161e7689cf 100644 --- a/public/app/containers/Explore/Explore.tsx +++ b/public/app/containers/Explore/Explore.tsx @@ -207,6 +207,7 @@ export class Explore extends React.Component { datasourceError: null, datasourceLoading: true, graphResult: null, + latency: 0, logsResult: null, queryErrors: [], queryHints: [], @@ -254,7 +255,10 @@ export class Explore extends React.Component { this.setState({ graphResult: null, logsResult: null, + latency: 0, queries: ensureQueries(), + queryErrors: [], + queryHints: [], tableResult: null, }); }; @@ -276,8 +280,10 @@ export class Explore extends React.Component { onClickSplit = () => { const { onChangeSplit } = this.props; + const state = { ...this.state }; + state.queries = state.queries.map(({ edited, ...rest }) => rest); if (onChangeSplit) { - onChangeSplit(true, this.state); + onChangeSplit(true, state); } }; From 076bfea3628861189a41c6e363d3311bbfe4f49b Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Fri, 10 Aug 2018 15:35:47 +0200 Subject: [PATCH 19/99] Rewrite heatmap to class --- .../app/plugins/panel/heatmap/heatmap_ctrl.ts | 2 +- public/app/plugins/panel/heatmap/rendering.ts | 696 +++++++++--------- 2 files changed, 353 insertions(+), 345 deletions(-) diff --git a/public/app/plugins/panel/heatmap/heatmap_ctrl.ts b/public/app/plugins/panel/heatmap/heatmap_ctrl.ts index 1d35ff2ea84..1749403edf0 100644 --- a/public/app/plugins/panel/heatmap/heatmap_ctrl.ts +++ b/public/app/plugins/panel/heatmap/heatmap_ctrl.ts @@ -358,6 +358,6 @@ export class HeatmapCtrl extends MetricsPanelCtrl { } link(scope, elem, attrs, ctrl) { - rendering(scope, elem, attrs, ctrl); + let render = new rendering(scope, elem, attrs, ctrl); } } diff --git a/public/app/plugins/panel/heatmap/rendering.ts b/public/app/plugins/panel/heatmap/rendering.ts index 54d17146532..d54eb5750cd 100644 --- a/public/app/plugins/panel/heatmap/rendering.ts +++ b/public/app/plugins/panel/heatmap/rendering.ts @@ -19,56 +19,91 @@ let MIN_CARD_SIZE = 1, Y_AXIS_TICK_PADDING = 5, MIN_SELECTION_WIDTH = 2; -export default function link(scope, elem, attrs, ctrl) { - let data, timeRange, panel, heatmap; +export default class Link { + width: number; + height: number; + yScale: any; + xScale: any; + chartWidth: number; + chartHeight: number; + chartTop: number; + chartBottom: number; + yAxisWidth: number; + xAxisHeight: number; + cardPadding: number; + cardRound: number; + cardWidth: number; + cardHeight: number; + colorScale: any; + opacityScale: any; + mouseUpHandler: any; + data: any; + panel: any; + $heatmap: any; + tooltip: HeatmapTooltip; + heatmap: any; + timeRange: any; - // $heatmap is JQuery object, but heatmap is D3 - let $heatmap = elem.find('.heatmap-panel'); - let tooltip = new HeatmapTooltip($heatmap, scope); + selection: any; + padding: any; + margin: any; + dataRangeWidingFactor: number; + constructor(private scope, private elem, attrs, private ctrl) { + // $heatmap is JQuery object, but heatmap is D3 + this.$heatmap = elem.find('.heatmap-panel'); + this.tooltip = new HeatmapTooltip(this.$heatmap, this.scope); - let width, - height, - yScale, - xScale, - chartWidth, - chartHeight, - chartTop, - chartBottom, - yAxisWidth, - xAxisHeight, - cardPadding, - cardRound, - cardWidth, - cardHeight, - colorScale, - opacityScale, - mouseUpHandler; + this.selection = { + active: false, + x1: -1, + x2: -1, + }; - let selection = { - active: false, - x1: -1, - x2: -1, - }; + this.padding = { left: 0, right: 0, top: 0, bottom: 0 }; + this.margin = { left: 25, right: 15, top: 10, bottom: 20 }; + this.dataRangeWidingFactor = DATA_RANGE_WIDING_FACTOR; - let padding = { left: 0, right: 0, top: 0, bottom: 0 }, - margin = { left: 25, right: 15, top: 10, bottom: 20 }, - dataRangeWidingFactor = DATA_RANGE_WIDING_FACTOR; + this.ctrl.events.on('render', this.onRender.bind(this)); - ctrl.events.on('render', () => { - render(); - ctrl.renderingCompleted(); - }); + this.ctrl.tickValueFormatter = this.tickValueFormatter; + ///////////////////////////// + // Selection and crosshair // + ///////////////////////////// - function setElementHeight() { + // Shared crosshair and tooltip + appEvents.on('graph-hover', this.onGraphHover.bind(this), this.scope); + + appEvents.on('graph-hover-clear', this.onGraphHoverClear.bind(this), this.scope); + + // Register selection listeners + this.$heatmap.on('mousedown', this.onMouseDown.bind(this)); + this.$heatmap.on('mousemove', this.onMouseMove.bind(this)); + this.$heatmap.on('mouseleave', this.onMouseLeave.bind(this)); + } + + onGraphHoverClear() { + this.clearCrosshair(); + } + + onGraphHover(event) { + this.drawSharedCrosshair(event.pos); + } + + onRender() { + this.render(); + this.ctrl.renderingCompleted(); + } + + setElementHeight() { try { - var height = ctrl.height || panel.height || ctrl.row.height; + var height = this.ctrl.height || this.panel.height || this.ctrl.row.height; if (_.isString(height)) { height = parseInt(height.replace('px', ''), 10); } - height -= panel.legend.show ? 28 : 11; // bottom padding and space for legend + height -= this.panel.legend.show ? 28 : 11; // bottom padding and space for legend - $heatmap.css('height', height + 'px'); + this.$heatmap.css('height', height + 'px'); return true; } catch (e) { @@ -77,7 +112,7 @@ export default function link(scope, elem, attrs, ctrl) { } } - function getYAxisWidth(elem) { + getYAxisWidth(elem) { let axis_text = elem.selectAll('.axis-y text').nodes(); let max_text_width = _.max( _.map(axis_text, text => { @@ -89,7 +124,7 @@ export default function link(scope, elem, attrs, ctrl) { return max_text_width; } - function getXAxisHeight(elem) { + getXAxisHeight(elem) { let axis_line = elem.select('.axis-x line'); if (!axis_line.empty()) { let axis_line_position = parseFloat(elem.select('.axis-x line').attr('y2')); @@ -101,16 +136,16 @@ export default function link(scope, elem, attrs, ctrl) { } } - function addXAxis() { - scope.xScale = xScale = d3 + addXAxis() { + this.scope.xScale = this.xScale = d3 .scaleTime() - .domain([timeRange.from, timeRange.to]) - .range([0, chartWidth]); + .domain([this.timeRange.from, this.timeRange.to]) + .range([0, this.chartWidth]); - let ticks = chartWidth / DEFAULT_X_TICK_SIZE_PX; - let grafanaTimeFormatter = ticksUtils.grafanaTimeFormat(ticks, timeRange.from, timeRange.to); + let ticks = this.chartWidth / DEFAULT_X_TICK_SIZE_PX; + let grafanaTimeFormatter = ticksUtils.grafanaTimeFormat(ticks, this.timeRange.from, this.timeRange.to); let timeFormat; - let dashboardTimeZone = ctrl.dashboard.getTimezone(); + let dashboardTimeZone = this.ctrl.dashboard.getTimezone(); if (dashboardTimeZone === 'utc') { timeFormat = d3.utcFormat(grafanaTimeFormatter); } else { @@ -118,100 +153,100 @@ export default function link(scope, elem, attrs, ctrl) { } let xAxis = d3 - .axisBottom(xScale) + .axisBottom(this.xScale) .ticks(ticks) .tickFormat(timeFormat) .tickPadding(X_AXIS_TICK_PADDING) - .tickSize(chartHeight); + .tickSize(this.chartHeight); - let posY = margin.top; - let posX = yAxisWidth; - heatmap + let posY = this.margin.top; + let posX = this.yAxisWidth; + this.heatmap .append('g') .attr('class', 'axis axis-x') .attr('transform', 'translate(' + posX + ',' + posY + ')') .call(xAxis); // Remove horizontal line in the top of axis labels (called domain in d3) - heatmap + this.heatmap .select('.axis-x') .select('.domain') .remove(); } - function addYAxis() { - let ticks = Math.ceil(chartHeight / DEFAULT_Y_TICK_SIZE_PX); - let tick_interval = ticksUtils.tickStep(data.heatmapStats.min, data.heatmapStats.max, ticks); - let { y_min, y_max } = wideYAxisRange(data.heatmapStats.min, data.heatmapStats.max, tick_interval); + addYAxis() { + let ticks = Math.ceil(this.chartHeight / DEFAULT_Y_TICK_SIZE_PX); + let tick_interval = ticksUtils.tickStep(this.data.heatmapStats.min, this.data.heatmapStats.max, ticks); + let { y_min, y_max } = this.wideYAxisRange(this.data.heatmapStats.min, this.data.heatmapStats.max, tick_interval); // Rewrite min and max if it have been set explicitly - y_min = panel.yAxis.min !== null ? panel.yAxis.min : y_min; - y_max = panel.yAxis.max !== null ? panel.yAxis.max : y_max; + y_min = this.panel.yAxis.min !== null ? this.panel.yAxis.min : y_min; + y_max = this.panel.yAxis.max !== null ? this.panel.yAxis.max : y_max; // Adjust ticks after Y range widening tick_interval = ticksUtils.tickStep(y_min, y_max, ticks); ticks = Math.ceil((y_max - y_min) / tick_interval); let decimalsAuto = ticksUtils.getPrecision(tick_interval); - let decimals = panel.yAxis.decimals === null ? decimalsAuto : panel.yAxis.decimals; + let decimals = this.panel.yAxis.decimals === null ? decimalsAuto : this.panel.yAxis.decimals; // Calculate scaledDecimals for log scales using tick size (as in jquery.flot.js) let flot_tick_size = ticksUtils.getFlotTickSize(y_min, y_max, ticks, decimalsAuto); let scaledDecimals = ticksUtils.getScaledDecimals(decimals, flot_tick_size); - ctrl.decimals = decimals; - ctrl.scaledDecimals = scaledDecimals; + this.ctrl.decimals = decimals; + this.ctrl.scaledDecimals = scaledDecimals; // Set default Y min and max if no data - if (_.isEmpty(data.buckets)) { + if (_.isEmpty(this.data.buckets)) { y_max = 1; y_min = -1; ticks = 3; decimals = 1; } - data.yAxis = { + this.data.yAxis = { min: y_min, max: y_max, ticks: ticks, }; - scope.yScale = yScale = d3 + this.scope.yScale = this.yScale = d3 .scaleLinear() .domain([y_min, y_max]) - .range([chartHeight, 0]); + .range([this.chartHeight, 0]); let yAxis = d3 - .axisLeft(yScale) + .axisLeft(this.yScale) .ticks(ticks) - .tickFormat(tickValueFormatter(decimals, scaledDecimals)) - .tickSizeInner(0 - width) + .tickFormat(this.tickValueFormatter(decimals, scaledDecimals)) + .tickSizeInner(0 - this.width) .tickSizeOuter(0) .tickPadding(Y_AXIS_TICK_PADDING); - heatmap + this.heatmap .append('g') .attr('class', 'axis axis-y') .call(yAxis); // Calculate Y axis width first, then move axis into visible area - let posY = margin.top; - let posX = getYAxisWidth(heatmap) + Y_AXIS_TICK_PADDING; - heatmap.select('.axis-y').attr('transform', 'translate(' + posX + ',' + posY + ')'); + let posY = this.margin.top; + let posX = this.getYAxisWidth(this.heatmap) + Y_AXIS_TICK_PADDING; + this.heatmap.select('.axis-y').attr('transform', 'translate(' + posX + ',' + posY + ')'); // Remove vertical line in the right of axis labels (called domain in d3) - heatmap + this.heatmap .select('.axis-y') .select('.domain') .remove(); } // Wide Y values range and anjust to bucket size - function wideYAxisRange(min, max, tickInterval) { - let y_widing = (max * (dataRangeWidingFactor - 1) - min * (dataRangeWidingFactor - 1)) / 2; + wideYAxisRange(min, max, tickInterval) { + let y_widing = (max * (this.dataRangeWidingFactor - 1) - min * (this.dataRangeWidingFactor - 1)) / 2; let y_min, y_max; if (tickInterval === 0) { - y_max = max * dataRangeWidingFactor; - y_min = min - min * (dataRangeWidingFactor - 1); + y_max = max * this.dataRangeWidingFactor; + y_min = min - min * (this.dataRangeWidingFactor - 1); tickInterval = (y_max - y_min) / 2; } else { y_max = Math.ceil((max + y_widing) / tickInterval) * tickInterval; @@ -226,152 +261,153 @@ export default function link(scope, elem, attrs, ctrl) { return { y_min, y_max }; } - function addLogYAxis() { - let log_base = panel.yAxis.logBase; - let { y_min, y_max } = adjustLogRange(data.heatmapStats.minLog, data.heatmapStats.max, log_base); + addLogYAxis() { + let log_base = this.panel.yAxis.logBase; + let { y_min, y_max } = this.adjustLogRange(this.data.heatmapStats.minLog, this.data.heatmapStats.max, log_base); - y_min = panel.yAxis.min && panel.yAxis.min !== '0' ? adjustLogMin(panel.yAxis.min, log_base) : y_min; - y_max = panel.yAxis.max !== null ? adjustLogMax(panel.yAxis.max, log_base) : y_max; + y_min = + this.panel.yAxis.min && this.panel.yAxis.min !== '0' ? this.adjustLogMin(this.panel.yAxis.min, log_base) : y_min; + y_max = this.panel.yAxis.max !== null ? this.adjustLogMax(this.panel.yAxis.max, log_base) : y_max; // Set default Y min and max if no data - if (_.isEmpty(data.buckets)) { + if (_.isEmpty(this.data.buckets)) { y_max = Math.pow(log_base, 2); y_min = 1; } - scope.yScale = yScale = d3 + this.scope.yScale = this.yScale = d3 .scaleLog() - .base(panel.yAxis.logBase) + .base(this.panel.yAxis.logBase) .domain([y_min, y_max]) - .range([chartHeight, 0]); + .range([this.chartHeight, 0]); - let domain = yScale.domain(); - let tick_values = logScaleTickValues(domain, log_base); + let domain = this.yScale.domain(); + let tick_values = this.logScaleTickValues(domain, log_base); let decimalsAuto = ticksUtils.getPrecision(y_min); - let decimals = panel.yAxis.decimals || decimalsAuto; + let decimals = this.panel.yAxis.decimals || decimalsAuto; // Calculate scaledDecimals for log scales using tick size (as in jquery.flot.js) let flot_tick_size = ticksUtils.getFlotTickSize(y_min, y_max, tick_values.length, decimalsAuto); let scaledDecimals = ticksUtils.getScaledDecimals(decimals, flot_tick_size); - ctrl.decimals = decimals; - ctrl.scaledDecimals = scaledDecimals; + this.ctrl.decimals = decimals; + this.ctrl.scaledDecimals = scaledDecimals; - data.yAxis = { + this.data.yAxis = { min: y_min, max: y_max, ticks: tick_values.length, }; let yAxis = d3 - .axisLeft(yScale) + .axisLeft(this.yScale) .tickValues(tick_values) - .tickFormat(tickValueFormatter(decimals, scaledDecimals)) - .tickSizeInner(0 - width) + .tickFormat(this.tickValueFormatter(decimals, scaledDecimals)) + .tickSizeInner(0 - this.width) .tickSizeOuter(0) .tickPadding(Y_AXIS_TICK_PADDING); - heatmap + this.heatmap .append('g') .attr('class', 'axis axis-y') .call(yAxis); // Calculate Y axis width first, then move axis into visible area - let posY = margin.top; - let posX = getYAxisWidth(heatmap) + Y_AXIS_TICK_PADDING; - heatmap.select('.axis-y').attr('transform', 'translate(' + posX + ',' + posY + ')'); + let posY = this.margin.top; + let posX = this.getYAxisWidth(this.heatmap) + Y_AXIS_TICK_PADDING; + this.heatmap.select('.axis-y').attr('transform', 'translate(' + posX + ',' + posY + ')'); // Set first tick as pseudo 0 if (y_min < 1) { - heatmap + this.heatmap .select('.axis-y') .select('.tick text') .text('0'); } // Remove vertical line in the right of axis labels (called domain in d3) - heatmap + this.heatmap .select('.axis-y') .select('.domain') .remove(); } - function addYAxisFromBuckets() { - const tsBuckets = data.tsBuckets; + addYAxisFromBuckets() { + const tsBuckets = this.data.tsBuckets; - scope.yScale = yScale = d3 + this.scope.yScale = this.yScale = d3 .scaleLinear() .domain([0, tsBuckets.length - 1]) - .range([chartHeight, 0]); + .range([this.chartHeight, 0]); const tick_values = _.map(tsBuckets, (b, i) => i); const decimalsAuto = _.max(_.map(tsBuckets, ticksUtils.getStringPrecision)); - const decimals = panel.yAxis.decimals === null ? decimalsAuto : panel.yAxis.decimals; - ctrl.decimals = decimals; + const decimals = this.panel.yAxis.decimals === null ? decimalsAuto : this.panel.yAxis.decimals; + this.ctrl.decimals = decimals; function tickFormatter(valIndex) { let valueFormatted = tsBuckets[valIndex]; if (!_.isNaN(_.toNumber(valueFormatted)) && valueFormatted !== '') { // Try to format numeric tick labels - valueFormatted = tickValueFormatter(decimals)(_.toNumber(valueFormatted)); + valueFormatted = this.tickValueFormatter(decimals)(_.toNumber(valueFormatted)); } return valueFormatted; } const tsBucketsFormatted = _.map(tsBuckets, (v, i) => tickFormatter(i)); - data.tsBucketsFormatted = tsBucketsFormatted; + this.data.tsBucketsFormatted = tsBucketsFormatted; let yAxis = d3 - .axisLeft(yScale) + .axisLeft(this.yScale) .tickValues(tick_values) .tickFormat(tickFormatter) - .tickSizeInner(0 - width) + .tickSizeInner(0 - this.width) .tickSizeOuter(0) .tickPadding(Y_AXIS_TICK_PADDING); - heatmap + this.heatmap .append('g') .attr('class', 'axis axis-y') .call(yAxis); // Calculate Y axis width first, then move axis into visible area - const posY = margin.top; - const posX = getYAxisWidth(heatmap) + Y_AXIS_TICK_PADDING; - heatmap.select('.axis-y').attr('transform', 'translate(' + posX + ',' + posY + ')'); + const posY = this.margin.top; + const posX = this.getYAxisWidth(this.heatmap) + Y_AXIS_TICK_PADDING; + this.heatmap.select('.axis-y').attr('transform', 'translate(' + posX + ',' + posY + ')'); // Remove vertical line in the right of axis labels (called domain in d3) - heatmap + this.heatmap .select('.axis-y') .select('.domain') .remove(); } // Adjust data range to log base - function adjustLogRange(min, max, logBase) { + adjustLogRange(min, max, logBase) { let y_min, y_max; - y_min = data.heatmapStats.minLog; - if (data.heatmapStats.minLog > 1 || !data.heatmapStats.minLog) { + y_min = this.data.heatmapStats.minLog; + if (this.data.heatmapStats.minLog > 1 || !this.data.heatmapStats.minLog) { y_min = 1; } else { - y_min = adjustLogMin(data.heatmapStats.minLog, logBase); + y_min = this.adjustLogMin(this.data.heatmapStats.minLog, logBase); } // Adjust max Y value to log base - y_max = adjustLogMax(data.heatmapStats.max, logBase); + y_max = this.adjustLogMax(this.data.heatmapStats.max, logBase); return { y_min, y_max }; } - function adjustLogMax(max, base) { + adjustLogMax(max, base) { return Math.pow(base, Math.ceil(ticksUtils.logp(max, base))); } - function adjustLogMin(min, base) { + adjustLogMin(min, base) { return Math.pow(base, Math.floor(ticksUtils.logp(min, base))); } - function logScaleTickValues(domain, base) { + logScaleTickValues(domain, base) { let domainMin = domain[0]; let domainMax = domain[1]; let tickValues = []; @@ -393,8 +429,8 @@ export default function link(scope, elem, attrs, ctrl) { return tickValues; } - function tickValueFormatter(decimals, scaledDecimals = null) { - let format = panel.yAxis.format; + tickValueFormatter(decimals, scaledDecimals = null) { + let format = this.panel.yAxis.format; return function(value) { try { return format !== 'none' ? kbn.valueFormats[format](value, decimals, scaledDecimals) : value; @@ -405,181 +441,179 @@ export default function link(scope, elem, attrs, ctrl) { }; } - ctrl.tickValueFormatter = tickValueFormatter; - - function fixYAxisTickSize() { - heatmap + fixYAxisTickSize() { + this.heatmap .select('.axis-y') .selectAll('.tick line') - .attr('x2', chartWidth); + .attr('x2', this.chartWidth); } - function addAxes() { - chartHeight = height - margin.top - margin.bottom; - chartTop = margin.top; - chartBottom = chartTop + chartHeight; + addAxes() { + this.chartHeight = this.height - this.margin.top - this.margin.bottom; + this.chartTop = this.margin.top; + this.chartBottom = this.chartTop + this.chartHeight; - if (panel.dataFormat === 'tsbuckets') { - addYAxisFromBuckets(); + if (this.panel.dataFormat === 'tsbuckets') { + this.addYAxisFromBuckets(); } else { - if (panel.yAxis.logBase === 1) { - addYAxis(); + if (this.panel.yAxis.logBase === 1) { + this.addYAxis(); } else { - addLogYAxis(); + this.addLogYAxis(); } } - yAxisWidth = getYAxisWidth(heatmap) + Y_AXIS_TICK_PADDING; - chartWidth = width - yAxisWidth - margin.right; - fixYAxisTickSize(); + this.yAxisWidth = this.getYAxisWidth(this.heatmap) + Y_AXIS_TICK_PADDING; + this.chartWidth = this.width - this.yAxisWidth - this.margin.right; + this.fixYAxisTickSize(); - addXAxis(); - xAxisHeight = getXAxisHeight(heatmap); + this.addXAxis(); + this.xAxisHeight = this.getXAxisHeight(this.heatmap); - if (!panel.yAxis.show) { - heatmap + if (!this.panel.yAxis.show) { + this.heatmap .select('.axis-y') .selectAll('line') .style('opacity', 0); } - if (!panel.xAxis.show) { - heatmap + if (!this.panel.xAxis.show) { + this.heatmap .select('.axis-x') .selectAll('line') .style('opacity', 0); } } - function addHeatmapCanvas() { - let heatmap_elem = $heatmap[0]; + addHeatmapCanvas() { + let heatmap_elem = this.$heatmap[0]; - width = Math.floor($heatmap.width()) - padding.right; - height = Math.floor($heatmap.height()) - padding.bottom; + this.width = Math.floor(this.$heatmap.width()) - this.padding.right; + this.height = Math.floor(this.$heatmap.height()) - this.padding.bottom; - cardPadding = panel.cards.cardPadding !== null ? panel.cards.cardPadding : CARD_PADDING; - cardRound = panel.cards.cardRound !== null ? panel.cards.cardRound : CARD_ROUND; + this.cardPadding = this.panel.cards.cardPadding !== null ? this.panel.cards.cardPadding : CARD_PADDING; + this.cardRound = this.panel.cards.cardRound !== null ? this.panel.cards.cardRound : CARD_ROUND; - if (heatmap) { - heatmap.remove(); + if (this.heatmap) { + this.heatmap.remove(); } - heatmap = d3 + this.heatmap = d3 .select(heatmap_elem) .append('svg') - .attr('width', width) - .attr('height', height); + .attr('width', this.width) + .attr('height', this.height); } - function addHeatmap() { - addHeatmapCanvas(); - addAxes(); + addHeatmap() { + this.addHeatmapCanvas(); + this.addAxes(); - if (panel.yAxis.logBase !== 1 && panel.dataFormat !== 'tsbuckets') { - let log_base = panel.yAxis.logBase; - let domain = yScale.domain(); - let tick_values = logScaleTickValues(domain, log_base); - data.buckets = mergeZeroBuckets(data.buckets, _.min(tick_values)); + if (this.panel.yAxis.logBase !== 1 && this.panel.dataFormat !== 'tsbuckets') { + let log_base = this.panel.yAxis.logBase; + let domain = this.yScale.domain(); + let tick_values = this.logScaleTickValues(domain, log_base); + this.data.buckets = mergeZeroBuckets(this.data.buckets, _.min(tick_values)); } - let cardsData = data.cards; - let maxValueAuto = data.cardStats.max; - let maxValue = panel.color.max || maxValueAuto; - let minValue = panel.color.min || 0; + let cardsData = this.data.cards; + let maxValueAuto = this.data.cardStats.max; + let maxValue = this.panel.color.max || maxValueAuto; + let minValue = this.panel.color.min || 0; - let colorScheme = _.find(ctrl.colorSchemes, { - value: panel.color.colorScheme, + let colorScheme = _.find(this.ctrl.colorSchemes, { + value: this.panel.color.colorScheme, }); - colorScale = getColorScale(colorScheme, contextSrv.user.lightTheme, maxValue, minValue); - opacityScale = getOpacityScale(panel.color, maxValue); - setCardSize(); + this.colorScale = getColorScale(colorScheme, contextSrv.user.lightTheme, maxValue, minValue); + this.opacityScale = getOpacityScale(this.panel.color, maxValue); + this.setCardSize(); - let cards = heatmap.selectAll('.heatmap-card').data(cardsData); + let cards = this.heatmap.selectAll('.heatmap-card').data(cardsData); cards.append('title'); cards = cards .enter() .append('rect') - .attr('x', getCardX) - .attr('width', getCardWidth) - .attr('y', getCardY) - .attr('height', getCardHeight) - .attr('rx', cardRound) - .attr('ry', cardRound) + .attr('x', this.getCardX) + .attr('width', this.getCardWidth) + .attr('y', this.getCardY) + .attr('height', this.getCardHeight) + .attr('rx', this.cardRound) + .attr('ry', this.cardRound) .attr('class', 'bordered heatmap-card') - .style('fill', getCardColor) - .style('stroke', getCardColor) + .style('fill', this.getCardColor) + .style('stroke', this.getCardColor) .style('stroke-width', 0) - .style('opacity', getCardOpacity); + .style('opacity', this.getCardOpacity); - let $cards = $heatmap.find('.heatmap-card'); + let $cards = this.$heatmap.find('.heatmap-card'); $cards .on('mouseenter', event => { - tooltip.mouseOverBucket = true; - highlightCard(event); + this.tooltip.mouseOverBucket = true; + this.highlightCard(event); }) .on('mouseleave', event => { - tooltip.mouseOverBucket = false; - resetCardHighLight(event); + this.tooltip.mouseOverBucket = false; + this.resetCardHighLight(event); }); } - function highlightCard(event) { + highlightCard(event) { let color = d3.select(event.target).style('fill'); let highlightColor = d3.color(color).darker(2); let strokeColor = d3.color(color).brighter(4); let current_card = d3.select(event.target); - tooltip.originalFillColor = color; + this.tooltip.originalFillColor = color; current_card .style('fill', highlightColor.toString()) .style('stroke', strokeColor.toString()) .style('stroke-width', 1); } - function resetCardHighLight(event) { + resetCardHighLight(event) { d3 .select(event.target) - .style('fill', tooltip.originalFillColor) - .style('stroke', tooltip.originalFillColor) + .style('fill', this.tooltip.originalFillColor) + .style('stroke', this.tooltip.originalFillColor) .style('stroke-width', 0); } - function setCardSize() { - let xGridSize = Math.floor(xScale(data.xBucketSize) - xScale(0)); - let yGridSize = Math.floor(yScale(yScale.invert(0) - data.yBucketSize)); + setCardSize() { + let xGridSize = Math.floor(this.xScale(this.data.xBucketSize) - this.xScale(0)); + let yGridSize = Math.floor(this.yScale(this.yScale.invert(0) - this.data.yBucketSize)); - if (panel.yAxis.logBase !== 1) { - let base = panel.yAxis.logBase; - let splitFactor = data.yBucketSize || 1; - yGridSize = Math.floor((yScale(1) - yScale(base)) / splitFactor); + if (this.panel.yAxis.logBase !== 1) { + let base = this.panel.yAxis.logBase; + let splitFactor = this.data.yBucketSize || 1; + yGridSize = Math.floor((this.yScale(1) - this.yScale(base)) / splitFactor); } - cardWidth = xGridSize - cardPadding * 2; - cardHeight = yGridSize ? yGridSize - cardPadding * 2 : 0; + this.cardWidth = xGridSize - this.cardPadding * 2; + this.cardHeight = yGridSize ? yGridSize - this.cardPadding * 2 : 0; } - function getCardX(d) { + getCardX(d) { let x; - if (xScale(d.x) < 0) { + if (this.xScale(d.x) < 0) { // Cut card left to prevent overlay - x = yAxisWidth + cardPadding; + x = this.yAxisWidth + this.cardPadding; } else { - x = xScale(d.x) + yAxisWidth + cardPadding; + x = this.xScale(d.x) + this.yAxisWidth + this.cardPadding; } return x; } - function getCardWidth(d) { + getCardWidth(d) { let w; - if (xScale(d.x) < 0) { + if (this.xScale(d.x) < 0) { // Cut card left to prevent overlay - let cutted_width = xScale(d.x) + cardWidth; + let cutted_width = this.xScale(d.x) + this.cardWidth; w = cutted_width > 0 ? cutted_width : 0; - } else if (xScale(d.x) + cardWidth > chartWidth) { + } else if (this.xScale(d.x) + this.cardWidth > this.chartWidth) { // Cut card right to prevent overlay - w = chartWidth - xScale(d.x) - cardPadding; + w = this.chartWidth - this.xScale(d.x) - this.cardPadding; } else { - w = cardWidth; + w = this.cardWidth; } // Card width should be MIN_CARD_SIZE at least @@ -587,138 +621,117 @@ export default function link(scope, elem, attrs, ctrl) { return w; } - function getCardY(d) { - let y = yScale(d.y) + chartTop - cardHeight - cardPadding; - if (panel.yAxis.logBase !== 1 && d.y === 0) { - y = chartBottom - cardHeight - cardPadding; + getCardY(d) { + let y = this.yScale(d.y) + this.chartTop - this.cardHeight - this.cardPadding; + if (this.panel.yAxis.logBase !== 1 && d.y === 0) { + y = this.chartBottom - this.cardHeight - this.cardPadding; } else { - if (y < chartTop) { - y = chartTop; + if (y < this.chartTop) { + y = this.chartTop; } } return y; } - function getCardHeight(d) { - let y = yScale(d.y) + chartTop - cardHeight - cardPadding; - let h = cardHeight; + getCardHeight(d) { + let y = this.yScale(d.y) + this.chartTop - this.cardHeight - this.cardPadding; + let h = this.cardHeight; - if (panel.yAxis.logBase !== 1 && d.y === 0) { - return cardHeight; + if (this.panel.yAxis.logBase !== 1 && d.y === 0) { + return this.cardHeight; } // Cut card height to prevent overlay - if (y < chartTop) { - h = yScale(d.y) - cardPadding; - } else if (yScale(d.y) > chartBottom) { - h = chartBottom - y; - } else if (y + cardHeight > chartBottom) { - h = chartBottom - y; + if (y < this.chartTop) { + h = this.yScale(d.y) - this.cardPadding; + } else if (this.yScale(d.y) > this.chartBottom) { + h = this.chartBottom - y; + } else if (y + this.cardHeight > this.chartBottom) { + h = this.chartBottom - y; } // Height can't be more than chart height - h = Math.min(h, chartHeight); + h = Math.min(h, this.chartHeight); // Card height should be MIN_CARD_SIZE at least h = Math.max(h, MIN_CARD_SIZE); return h; } - function getCardColor(d) { - if (panel.color.mode === 'opacity') { - return panel.color.cardColor; + getCardColor(d) { + if (this.panel.color.mode === 'opacity') { + return this.panel.color.cardColor; } else { - return colorScale(d.count); + return this.colorScale(d.count); } } - function getCardOpacity(d) { - if (panel.color.mode === 'opacity') { - return opacityScale(d.count); + getCardOpacity(d) { + if (this.panel.color.mode === 'opacity') { + return this.opacityScale(d.count); } else { return 1; } } - ///////////////////////////// - // Selection and crosshair // - ///////////////////////////// + onMouseDown(event) { + this.selection.active = true; + this.selection.x1 = event.offsetX; - // Shared crosshair and tooltip - appEvents.on( - 'graph-hover', - event => { - drawSharedCrosshair(event.pos); - }, - scope - ); - - appEvents.on( - 'graph-hover-clear', - () => { - clearCrosshair(); - }, - scope - ); - - function onMouseDown(event) { - selection.active = true; - selection.x1 = event.offsetX; - - mouseUpHandler = function() { - onMouseUp(); + this.mouseUpHandler = () => { + this.onMouseUp(); }; - $(document).one('mouseup', mouseUpHandler); + $(document).one('mouseup', this.mouseUpHandler); } - function onMouseUp() { - $(document).unbind('mouseup', mouseUpHandler); - mouseUpHandler = null; - selection.active = false; + onMouseUp() { + $(document).unbind('mouseup', this.mouseUpHandler); + this.mouseUpHandler = null; + this.selection.active = false; - let selectionRange = Math.abs(selection.x2 - selection.x1); - if (selection.x2 >= 0 && selectionRange > MIN_SELECTION_WIDTH) { - let timeFrom = xScale.invert(Math.min(selection.x1, selection.x2) - yAxisWidth); - let timeTo = xScale.invert(Math.max(selection.x1, selection.x2) - yAxisWidth); + let selectionRange = Math.abs(this.selection.x2 - this.selection.x1); + if (this.selection.x2 >= 0 && selectionRange > MIN_SELECTION_WIDTH) { + let timeFrom = this.xScale.invert(Math.min(this.selection.x1, this.selection.x2) - this.yAxisWidth); + let timeTo = this.xScale.invert(Math.max(this.selection.x1, this.selection.x2) - this.yAxisWidth); - ctrl.timeSrv.setTime({ + this.ctrl.timeSrv.setTime({ from: moment.utc(timeFrom), to: moment.utc(timeTo), }); } - clearSelection(); + this.clearSelection(); } - function onMouseLeave() { + onMouseLeave() { appEvents.emit('graph-hover-clear'); - clearCrosshair(); + this.clearCrosshair(); } - function onMouseMove(event) { - if (!heatmap) { + onMouseMove(event) { + if (!this.heatmap) { return; } - if (selection.active) { + if (this.selection.active) { // Clear crosshair and tooltip - clearCrosshair(); - tooltip.destroy(); + this.clearCrosshair(); + this.tooltip.destroy(); - selection.x2 = limitSelection(event.offsetX); - drawSelection(selection.x1, selection.x2); + this.selection.x2 = this.limitSelection(event.offsetX); + this.drawSelection(this.selection.x1, this.selection.x2); } else { - emitGraphHoverEvent(event); - drawCrosshair(event.offsetX); - tooltip.show(event, data); + this.emitGraphHoverEvent(event); + this.drawCrosshair(event.offsetX); + this.tooltip.show(event, this.data); } } - function emitGraphHoverEvent(event) { - let x = xScale.invert(event.offsetX - yAxisWidth).valueOf(); - let y = yScale.invert(event.offsetY); + emitGraphHoverEvent(event) { + let x = this.xScale.invert(event.offsetX - this.yAxisWidth).valueOf(); + let y = this.yScale.invert(event.offsetY); let pos = { pageX: event.pageX, pageY: event.pageY, @@ -730,105 +743,100 @@ export default function link(scope, elem, attrs, ctrl) { }; // Set minimum offset to prevent showing legend from another panel - pos.panelRelY = Math.max(event.offsetY / height, 0.001); + pos.panelRelY = Math.max(event.offsetY / this.height, 0.001); // broadcast to other graph panels that we are hovering - appEvents.emit('graph-hover', { pos: pos, panel: panel }); + appEvents.emit('graph-hover', { pos: pos, panel: this.panel }); } - function limitSelection(x2) { - x2 = Math.max(x2, yAxisWidth); - x2 = Math.min(x2, chartWidth + yAxisWidth); + limitSelection(x2) { + x2 = Math.max(x2, this.yAxisWidth); + x2 = Math.min(x2, this.chartWidth + this.yAxisWidth); return x2; } - function drawSelection(posX1, posX2) { - if (heatmap) { - heatmap.selectAll('.heatmap-selection').remove(); + drawSelection(posX1, posX2) { + if (this.heatmap) { + this.heatmap.selectAll('.heatmap-selection').remove(); let selectionX = Math.min(posX1, posX2); let selectionWidth = Math.abs(posX1 - posX2); if (selectionWidth > MIN_SELECTION_WIDTH) { - heatmap + this.heatmap .append('rect') .attr('class', 'heatmap-selection') .attr('x', selectionX) .attr('width', selectionWidth) - .attr('y', chartTop) - .attr('height', chartHeight); + .attr('y', this.chartTop) + .attr('height', this.chartHeight); } } } - function clearSelection() { - selection.x1 = -1; - selection.x2 = -1; + clearSelection() { + this.selection.x1 = -1; + this.selection.x2 = -1; - if (heatmap) { - heatmap.selectAll('.heatmap-selection').remove(); + if (this.heatmap) { + this.heatmap.selectAll('.heatmap-selection').remove(); } } - function drawCrosshair(position) { - if (heatmap) { - heatmap.selectAll('.heatmap-crosshair').remove(); + drawCrosshair(position) { + if (this.heatmap) { + this.heatmap.selectAll('.heatmap-crosshair').remove(); let posX = position; - posX = Math.max(posX, yAxisWidth); - posX = Math.min(posX, chartWidth + yAxisWidth); + posX = Math.max(posX, this.yAxisWidth); + posX = Math.min(posX, this.chartWidth + this.yAxisWidth); - heatmap + this.heatmap .append('g') .attr('class', 'heatmap-crosshair') .attr('transform', 'translate(' + posX + ',0)') .append('line') .attr('x1', 1) - .attr('y1', chartTop) + .attr('y1', this.chartTop) .attr('x2', 1) - .attr('y2', chartBottom) + .attr('y2', this.chartBottom) .attr('stroke-width', 1); } } - function drawSharedCrosshair(pos) { - if (heatmap && ctrl.dashboard.graphTooltip !== 0) { - let posX = xScale(pos.x) + yAxisWidth; - drawCrosshair(posX); + drawSharedCrosshair(pos) { + if (this.heatmap && this.ctrl.dashboard.graphTooltip !== 0) { + let posX = this.xScale(pos.x) + this.yAxisWidth; + this.drawCrosshair(posX); } } - function clearCrosshair() { - if (heatmap) { - heatmap.selectAll('.heatmap-crosshair').remove(); + clearCrosshair() { + if (this.heatmap) { + this.heatmap.selectAll('.heatmap-crosshair').remove(); } } - function render() { - data = ctrl.data; - panel = ctrl.panel; - timeRange = ctrl.range; + render() { + this.data = this.ctrl.data; + this.panel = this.ctrl.panel; + this.timeRange = this.ctrl.range; - if (!setElementHeight() || !data) { + if (!this.setElementHeight() || !this.data) { return; } // Draw default axes and return if no data - if (_.isEmpty(data.buckets)) { - addHeatmapCanvas(); - addAxes(); + if (_.isEmpty(this.data.buckets)) { + this.addHeatmapCanvas(); + this.addAxes(); return; } - addHeatmap(); - scope.yAxisWidth = yAxisWidth; - scope.xAxisHeight = xAxisHeight; - scope.chartHeight = chartHeight; - scope.chartWidth = chartWidth; - scope.chartTop = chartTop; + this.addHeatmap(); + this.scope.yAxisWidth = this.yAxisWidth; + this.scope.xAxisHeight = this.xAxisHeight; + this.scope.chartHeight = this.chartHeight; + this.scope.chartWidth = this.chartWidth; + this.scope.chartTop = this.chartTop; } - - // Register selection listeners - $heatmap.on('mousedown', onMouseDown); - $heatmap.on('mousemove', onMouseMove); - $heatmap.on('mouseleave', onMouseLeave); } From 520aad819d8b43fce404ab3452068605f044c48a Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Fri, 10 Aug 2018 16:30:51 +0200 Subject: [PATCH 20/99] Replace element --- .../panel/heatmap/specs/renderer.jest.ts | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/public/app/plugins/panel/heatmap/specs/renderer.jest.ts b/public/app/plugins/panel/heatmap/specs/renderer.jest.ts index 4e0e8d1b6a9..7001134bd70 100644 --- a/public/app/plugins/panel/heatmap/specs/renderer.jest.ts +++ b/public/app/plugins/panel/heatmap/specs/renderer.jest.ts @@ -13,6 +13,8 @@ import { convertToHeatMap, convertToCards, histogramToHeatmap, calculateBucketSi describe('grafanaHeatmap', function() { // beforeEach(angularMocks.module('grafana.core')); + let scope = {}; + function heatmapScenario(desc, func, elementWidth = 500) { describe(desc, function() { var ctx: any = {}; @@ -89,7 +91,7 @@ describe('grafanaHeatmap', function() { }, }; - var scope = $rootScope.$new(); + // var scope = $rootScope.$new(); scope.ctrl = ctrl; ctx.series = []; @@ -131,20 +133,21 @@ describe('grafanaHeatmap', function() { ctx.data.cards = cards; ctx.data.cardStats = cardStats; - let elemHtml = ` -
-
-
-
-
`; + // let elemHtml = ` + //
+ //
+ //
+ //
+ //
`; - var element = $.parseHTML(elemHtml); + // var element = $.parseHTML(elemHtml); // $compile(element)(scope); // scope.$digest(); ctrl.data = ctx.data; - ctx.element = element; - rendering(scope, $(element), [], ctrl); + // ctx.element = element; + let elem = {}; + let render = new rendering(scope, elem, [], ctrl); ctrl.events.emit('render'); }); }; From 8d2aac09366ba674663761cb16af31f319ab174c Mon Sep 17 00:00:00 2001 From: Ali Anwar Date: Sat, 11 Aug 2018 23:42:31 -0700 Subject: [PATCH 21/99] Fix typo --- docs/sources/http_api/folder.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/http_api/folder.md b/docs/sources/http_api/folder.md index fb318ecf58e..e8845c3b125 100644 --- a/docs/sources/http_api/folder.md +++ b/docs/sources/http_api/folder.md @@ -223,7 +223,7 @@ Status Codes: - **404** – Folder not found - **412** – Precondition failed -The **412** status code is used for explaing that you cannot update the folder and why. +The **412** status code is used for explaining that you cannot update the folder and why. There can be different reasons for this: - The folder has been changed by someone else, `status=version-mismatch` From 5fd8849d656d4ee90d24c394924010ce49f8089d Mon Sep 17 00:00:00 2001 From: Ali Anwar Date: Sat, 11 Aug 2018 23:44:15 -0700 Subject: [PATCH 22/99] Update dashboard.md --- docs/sources/http_api/dashboard.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/http_api/dashboard.md b/docs/sources/http_api/dashboard.md index ea1bd7f2ef7..3df36894901 100644 --- a/docs/sources/http_api/dashboard.md +++ b/docs/sources/http_api/dashboard.md @@ -85,7 +85,7 @@ Status Codes: - **403** – Access denied - **412** – Precondition failed -The **412** status code is used for explaing that you cannot create the dashboard and why. +The **412** status code is used for explaining that you cannot create the dashboard and why. There can be different reasons for this: - The dashboard has been changed by someone else, `status=version-mismatch` From a79c43420a54cad877d51d27cb5812a1fd3a3b02 Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Mon, 13 Aug 2018 10:57:32 +0200 Subject: [PATCH 23/99] Add mocks --- .../app/plugins/panel/heatmap/heatmap_ctrl.ts | 2 +- public/app/plugins/panel/heatmap/rendering.ts | 32 +++++++++++-------- .../panel/heatmap/specs/renderer.jest.ts | 24 ++++++++++---- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/public/app/plugins/panel/heatmap/heatmap_ctrl.ts b/public/app/plugins/panel/heatmap/heatmap_ctrl.ts index 1749403edf0..1d35ff2ea84 100644 --- a/public/app/plugins/panel/heatmap/heatmap_ctrl.ts +++ b/public/app/plugins/panel/heatmap/heatmap_ctrl.ts @@ -358,6 +358,6 @@ export class HeatmapCtrl extends MetricsPanelCtrl { } link(scope, elem, attrs, ctrl) { - let render = new rendering(scope, elem, attrs, ctrl); + rendering(scope, elem, attrs, ctrl); } } diff --git a/public/app/plugins/panel/heatmap/rendering.ts b/public/app/plugins/panel/heatmap/rendering.ts index d54eb5750cd..5af916ac13e 100644 --- a/public/app/plugins/panel/heatmap/rendering.ts +++ b/public/app/plugins/panel/heatmap/rendering.ts @@ -19,7 +19,10 @@ let MIN_CARD_SIZE = 1, Y_AXIS_TICK_PADDING = 5, MIN_SELECTION_WIDTH = 2; -export default class Link { +export default function rendering(scope, elem, attrs, ctrl) { + return new Link(scope, elem, attrs, ctrl); +} +export class Link { width: number; height: number; yScale: any; @@ -50,7 +53,7 @@ export default class Link { dataRangeWidingFactor: number; constructor(private scope, private elem, attrs, private ctrl) { // $heatmap is JQuery object, but heatmap is D3 - this.$heatmap = elem.find('.heatmap-panel'); + this.$heatmap = this.elem.find('.heatmap-panel'); this.tooltip = new HeatmapTooltip(this.$heatmap, this.scope); this.selection = { @@ -65,7 +68,7 @@ export default class Link { this.ctrl.events.on('render', this.onRender.bind(this)); - this.ctrl.tickValueFormatter = this.tickValueFormatter; + this.ctrl.tickValueFormatter = this.tickValueFormatter.bind(this); ///////////////////////////// // Selection and crosshair // ///////////////////////////// @@ -151,7 +154,7 @@ export default class Link { } else { timeFormat = d3.timeFormat(grafanaTimeFormatter); } - + console.log(ticks); let xAxis = d3 .axisBottom(this.xScale) .ticks(ticks) @@ -345,11 +348,12 @@ export default class Link { const decimals = this.panel.yAxis.decimals === null ? decimalsAuto : this.panel.yAxis.decimals; this.ctrl.decimals = decimals; + let tickValueFormatter = this.tickValueFormatter.bind(this); function tickFormatter(valIndex) { let valueFormatted = tsBuckets[valIndex]; if (!_.isNaN(_.toNumber(valueFormatted)) && valueFormatted !== '') { // Try to format numeric tick labels - valueFormatted = this.tickValueFormatter(decimals)(_.toNumber(valueFormatted)); + valueFormatted = tickValueFormatter(decimals)(_.toNumber(valueFormatted)); } return valueFormatted; } @@ -533,17 +537,17 @@ export default class Link { cards = cards .enter() .append('rect') - .attr('x', this.getCardX) - .attr('width', this.getCardWidth) - .attr('y', this.getCardY) - .attr('height', this.getCardHeight) + .attr('x', this.getCardX.bind(this)) + .attr('width', this.getCardWidth.bind(this)) + .attr('y', this.getCardY.bind(this)) + .attr('height', this.getCardHeight.bind(this)) .attr('rx', this.cardRound) .attr('ry', this.cardRound) .attr('class', 'bordered heatmap-card') - .style('fill', this.getCardColor) - .style('stroke', this.getCardColor) + .style('fill', this.getCardColor.bind(this)) + .style('stroke', this.getCardColor.bind(this)) .style('stroke-width', 0) - .style('opacity', this.getCardOpacity); + .style('opacity', this.getCardOpacity.bind(this)); let $cards = this.$heatmap.find('.heatmap-card'); $cards @@ -683,11 +687,11 @@ export default class Link { this.onMouseUp(); }; - $(document).one('mouseup', this.mouseUpHandler); + $(document).one('mouseup', this.mouseUpHandler.bind(this)); } onMouseUp() { - $(document).unbind('mouseup', this.mouseUpHandler); + $(document).unbind('mouseup', this.mouseUpHandler.bind(this)); this.mouseUpHandler = null; this.selection.active = false; diff --git a/public/app/plugins/panel/heatmap/specs/renderer.jest.ts b/public/app/plugins/panel/heatmap/specs/renderer.jest.ts index 7001134bd70..c660761890c 100644 --- a/public/app/plugins/panel/heatmap/specs/renderer.jest.ts +++ b/public/app/plugins/panel/heatmap/specs/renderer.jest.ts @@ -1,14 +1,19 @@ // import { describe, beforeEach, it, sinon, expect, angularMocks } from '../../../../../test/lib/common'; import '../module'; -import angular from 'angular'; -import $ from 'jquery'; +// import angular from 'angular'; +// import $ from 'jquery'; // import helpers from 'test/specs/helpers'; import TimeSeries from 'app/core/time_series2'; import moment from 'moment'; -import { Emitter } from 'app/core/core'; +// import { Emitter } from 'app/core/core'; import rendering from '../rendering'; import { convertToHeatMap, convertToCards, histogramToHeatmap, calculateBucketSize } from '../heatmap_data_converter'; +jest.mock('app/core/core', () => ({ + appEvents: { + on: () => {}, + }, +})); describe('grafanaHeatmap', function() { // beforeEach(angularMocks.module('grafana.core')); @@ -37,7 +42,10 @@ describe('grafanaHeatmap', function() { }, { name: 'Reds', value: 'interpolateReds', invert: 'dark' }, ], - // events: new Emitter(), + events: { + on: () => {}, + emit: () => {}, + }, height: 200, panel: { heatmap: {}, @@ -145,9 +153,11 @@ describe('grafanaHeatmap', function() { // scope.$digest(); ctrl.data = ctx.data; - // ctx.element = element; - let elem = {}; - let render = new rendering(scope, elem, [], ctrl); + ctx.element = { + find: () => ({ on: () => {} }), + on: () => {}, + }; + rendering(scope, ctx.element, [], ctrl); ctrl.events.emit('render'); }); }; From bfe28ee061ea42b27057c582f0b436cf12c46e88 Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Mon, 13 Aug 2018 12:08:14 +0200 Subject: [PATCH 24/99] Add $__unixEpochGroup macro to postgres datasource --- docs/sources/features/datasources/postgres.md | 2 ++ pkg/tsdb/postgres/macros.go | 21 +++++++++++++++++++ pkg/tsdb/postgres/macros_test.go | 12 +++++++++++ .../postgres/partials/query.editor.html | 2 ++ 4 files changed, 37 insertions(+) diff --git a/docs/sources/features/datasources/postgres.md b/docs/sources/features/datasources/postgres.md index 2be2db0837b..cf77643f06b 100644 --- a/docs/sources/features/datasources/postgres.md +++ b/docs/sources/features/datasources/postgres.md @@ -68,6 +68,8 @@ Macro example | Description *$__unixEpochFilter(dateColumn)* | Will be replaced by a time range filter using the specified column name with times represented as unix timestamp. For example, *dateColumn >= 1494410783 AND dateColumn <= 1494497183* *$__unixEpochFrom()* | Will be replaced by the start of the currently active time selection as unix timestamp. For example, *1494410783* *$__unixEpochTo()* | Will be replaced by the end of the currently active time selection as unix timestamp. For example, *1494497183* +*$__unixEpochGroup(dateColumn,'5m', [fillmode])* | Same as $__timeGroup but for times stored as unix timestamp (only available in Grafana 5.3+). +*$__unixEpochGroupAlias(dateColumn,'5m', [fillmode])* | Same as above but also adds a column alias (only available in Grafana 5.3+). We plan to add many more macros. If you have suggestions for what macros you would like to see, please [open an issue](https://github.com/grafana/grafana) in our GitHub repo. diff --git a/pkg/tsdb/postgres/macros.go b/pkg/tsdb/postgres/macros.go index a4b4aaa9d1e..d2a3d599441 100644 --- a/pkg/tsdb/postgres/macros.go +++ b/pkg/tsdb/postgres/macros.go @@ -134,6 +134,27 @@ func (m *postgresMacroEngine) evaluateMacro(name string, args []string) (string, return fmt.Sprintf("%d", m.timeRange.GetFromAsSecondsEpoch()), nil case "__unixEpochTo": return fmt.Sprintf("%d", m.timeRange.GetToAsSecondsEpoch()), nil + case "__unixEpochGroup": + if len(args) < 2 { + return "", fmt.Errorf("macro %v needs time column and interval and optional fill value", name) + } + interval, err := time.ParseDuration(strings.Trim(args[1], `'`)) + if err != nil { + return "", fmt.Errorf("error parsing interval %v", args[1]) + } + if len(args) == 3 { + err := tsdb.SetupFillmode(m.query, interval, args[2]) + if err != nil { + return "", err + } + } + return fmt.Sprintf("floor(%s/%v)*%v", args[0], interval.Seconds(), interval.Seconds()), nil + case "__unixEpochGroupAlias": + tg, err := m.evaluateMacro("__unixEpochGroup", args) + if err == nil { + return tg + " AS \"time\"", err + } + return "", err default: return "", fmt.Errorf("Unknown macro %v", name) } diff --git a/pkg/tsdb/postgres/macros_test.go b/pkg/tsdb/postgres/macros_test.go index beeea93893b..a029fc49ee0 100644 --- a/pkg/tsdb/postgres/macros_test.go +++ b/pkg/tsdb/postgres/macros_test.go @@ -110,6 +110,18 @@ func TestMacroEngine(t *testing.T) { So(sql, ShouldEqual, fmt.Sprintf("select %d", to.Unix())) }) + + Convey("interpolate __unixEpochGroup function", func() { + + sql, err := engine.Interpolate(query, timeRange, "SELECT $__unixEpochGroup(time_column,'5m')") + So(err, ShouldBeNil) + sql2, err := engine.Interpolate(query, timeRange, "SELECT $__unixEpochGroupAlias(time_column,'5m')") + So(err, ShouldBeNil) + + So(sql, ShouldEqual, "SELECT floor(time_column/300)*300") + So(sql2, ShouldEqual, sql+" AS \"time\"") + }) + }) Convey("Given a time range between 1960-02-01 07:00 and 1965-02-03 08:00", func() { diff --git a/public/app/plugins/datasource/postgres/partials/query.editor.html b/public/app/plugins/datasource/postgres/partials/query.editor.html index 20353b81ba2..763fd6a6e96 100644 --- a/public/app/plugins/datasource/postgres/partials/query.editor.html +++ b/public/app/plugins/datasource/postgres/partials/query.editor.html @@ -57,6 +57,8 @@ Macros: by setting fillvalue grafana will fill in missing values according to the interval fillvalue can be either a literal value, NULL or previous; previous will fill in the previous seen value or NULL if none has been seen yet - $__timeGroupAlias(column,'5m') -> (extract(epoch from column)/300)::bigint*300 AS "time" +- $__unixEpochGroup(column,'5m') -> floor(column/300)*300 +- $__unixEpochGroupAlias(column,'5m') -> floor(column/300)*300 AS "time" Example of group by and order by with $__timeGroup: SELECT From fbc67a1c64a0a94d169aea63aa00c0f1055dfc6d Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Mon, 13 Aug 2018 12:17:05 +0200 Subject: [PATCH 25/99] add $__unixEpochGroup to mysql datasource --- docs/sources/features/datasources/mysql.md | 2 ++ pkg/tsdb/mysql/macros.go | 21 +++++++++++++++++++ pkg/tsdb/mysql/macros_test.go | 12 +++++++++++ .../mysql/partials/query.editor.html | 2 ++ 4 files changed, 37 insertions(+) diff --git a/docs/sources/features/datasources/mysql.md b/docs/sources/features/datasources/mysql.md index cdb78deed35..afac746b050 100644 --- a/docs/sources/features/datasources/mysql.md +++ b/docs/sources/features/datasources/mysql.md @@ -71,6 +71,8 @@ Macro example | Description *$__unixEpochFilter(dateColumn)* | Will be replaced by a time range filter using the specified column name with times represented as unix timestamp. For example, *dateColumn > 1494410783 AND dateColumn < 1494497183* *$__unixEpochFrom()* | Will be replaced by the start of the currently active time selection as unix timestamp. For example, *1494410783* *$__unixEpochTo()* | Will be replaced by the end of the currently active time selection as unix timestamp. For example, *1494497183* +*$__unixEpochGroup(dateColumn,'5m', [fillmode])* | Same as $__timeGroup but for times stored as unix timestamp (only available in Grafana 5.3+). +*$__unixEpochGroupAlias(dateColumn,'5m', [fillmode])* | Same as above but also adds a column alias (only available in Grafana 5.3+). We plan to add many more macros. If you have suggestions for what macros you would like to see, please [open an issue](https://github.com/grafana/grafana) in our GitHub repo. diff --git a/pkg/tsdb/mysql/macros.go b/pkg/tsdb/mysql/macros.go index 48fa193edd5..0dabdd7c283 100644 --- a/pkg/tsdb/mysql/macros.go +++ b/pkg/tsdb/mysql/macros.go @@ -112,6 +112,27 @@ func (m *mySqlMacroEngine) evaluateMacro(name string, args []string) (string, er return fmt.Sprintf("%d", m.timeRange.GetFromAsSecondsEpoch()), nil case "__unixEpochTo": return fmt.Sprintf("%d", m.timeRange.GetToAsSecondsEpoch()), nil + case "__unixEpochGroup": + if len(args) < 2 { + return "", fmt.Errorf("macro %v needs time column and interval and optional fill value", name) + } + interval, err := time.ParseDuration(strings.Trim(args[1], `'`)) + if err != nil { + return "", fmt.Errorf("error parsing interval %v", args[1]) + } + if len(args) == 3 { + err := tsdb.SetupFillmode(m.query, interval, args[2]) + if err != nil { + return "", err + } + } + return fmt.Sprintf("%s DIV %v * %v", args[0], interval.Seconds(), interval.Seconds()), nil + case "__unixEpochGroupAlias": + tg, err := m.evaluateMacro("__unixEpochGroup", args) + if err == nil { + return tg + " AS \"time\"", err + } + return "", err default: return "", fmt.Errorf("Unknown macro %v", name) } diff --git a/pkg/tsdb/mysql/macros_test.go b/pkg/tsdb/mysql/macros_test.go index fd9d3f5688a..fe153ca3e2d 100644 --- a/pkg/tsdb/mysql/macros_test.go +++ b/pkg/tsdb/mysql/macros_test.go @@ -97,6 +97,18 @@ func TestMacroEngine(t *testing.T) { So(sql, ShouldEqual, fmt.Sprintf("select %d", to.Unix())) }) + + Convey("interpolate __unixEpochGroup function", func() { + + sql, err := engine.Interpolate(query, timeRange, "SELECT $__unixEpochGroup(time_column,'5m')") + So(err, ShouldBeNil) + sql2, err := engine.Interpolate(query, timeRange, "SELECT $__unixEpochGroupAlias(time_column,'5m')") + So(err, ShouldBeNil) + + So(sql, ShouldEqual, "SELECT time_column DIV 300 * 300") + So(sql2, ShouldEqual, sql+" AS \"time\"") + }) + }) Convey("Given a time range between 1960-02-01 07:00 and 1965-02-03 08:00", func() { diff --git a/public/app/plugins/datasource/mysql/partials/query.editor.html b/public/app/plugins/datasource/mysql/partials/query.editor.html index 7c799eec21b..1e829a1175d 100644 --- a/public/app/plugins/datasource/mysql/partials/query.editor.html +++ b/public/app/plugins/datasource/mysql/partials/query.editor.html @@ -57,6 +57,8 @@ Macros: by setting fillvalue grafana will fill in missing values according to the interval fillvalue can be either a literal value, NULL or previous; previous will fill in the previous seen value or NULL if none has been seen yet - $__timeGroupAlias(column,'5m') -> cast(cast(UNIX_TIMESTAMP(column)/(300) as signed)*300 as signed) AS "time" +- $__unixEpochGroup(column,'5m') -> column DIV 300 * 300 +- $__unixEpochGroupAlias(column,'5m') -> column DIV 300 * 300 AS "time" Example of group by and order by with $__timeGroup: SELECT From 8c4d59363e6aabd9cb772af41569f13e64951691 Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Mon, 13 Aug 2018 12:23:42 +0200 Subject: [PATCH 26/99] add $__unixEpochGroup to mssql datasource --- docs/sources/features/datasources/mssql.md | 2 ++ pkg/tsdb/mssql/macros.go | 21 +++++++++++++++++++ pkg/tsdb/mssql/macros_test.go | 12 +++++++++++ .../mssql/partials/query.editor.html | 2 ++ 4 files changed, 37 insertions(+) diff --git a/docs/sources/features/datasources/mssql.md b/docs/sources/features/datasources/mssql.md index caaf5a6b321..da0c9581e99 100644 --- a/docs/sources/features/datasources/mssql.md +++ b/docs/sources/features/datasources/mssql.md @@ -88,6 +88,8 @@ Macro example | Description *$__unixEpochFilter(dateColumn)* | Will be replaced by a time range filter using the specified column name with times represented as unix timestamp. For example, *dateColumn > 1494410783 AND dateColumn < 1494497183* *$__unixEpochFrom()* | Will be replaced by the start of the currently active time selection as unix timestamp. For example, *1494410783* *$__unixEpochTo()* | Will be replaced by the end of the currently active time selection as unix timestamp. For example, *1494497183* +*$__unixEpochGroup(dateColumn,'5m', [fillmode])* | Same as $__timeGroup but for times stored as unix timestamp (only available in Grafana 5.3+). +*$__unixEpochGroupAlias(dateColumn,'5m', [fillmode])* | Same as above but also adds a column alias (only available in Grafana 5.3+). We plan to add many more macros. If you have suggestions for what macros you would like to see, please [open an issue](https://github.com/grafana/grafana) in our GitHub repo. diff --git a/pkg/tsdb/mssql/macros.go b/pkg/tsdb/mssql/macros.go index 920e3781e0c..caba043e7b6 100644 --- a/pkg/tsdb/mssql/macros.go +++ b/pkg/tsdb/mssql/macros.go @@ -116,6 +116,27 @@ func (m *msSqlMacroEngine) evaluateMacro(name string, args []string) (string, er return fmt.Sprintf("%d", m.timeRange.GetFromAsSecondsEpoch()), nil case "__unixEpochTo": return fmt.Sprintf("%d", m.timeRange.GetToAsSecondsEpoch()), nil + case "__unixEpochGroup": + if len(args) < 2 { + return "", fmt.Errorf("macro %v needs time column and interval and optional fill value", name) + } + interval, err := time.ParseDuration(strings.Trim(args[1], `'`)) + if err != nil { + return "", fmt.Errorf("error parsing interval %v", args[1]) + } + if len(args) == 3 { + err := tsdb.SetupFillmode(m.query, interval, args[2]) + if err != nil { + return "", err + } + } + return fmt.Sprintf("FLOOR(%s/%v)*%v", args[0], interval.Seconds(), interval.Seconds()), nil + case "__unixEpochGroupAlias": + tg, err := m.evaluateMacro("__unixEpochGroup", args) + if err == nil { + return tg + " AS [time]", err + } + return "", err default: return "", fmt.Errorf("Unknown macro %v", name) } diff --git a/pkg/tsdb/mssql/macros_test.go b/pkg/tsdb/mssql/macros_test.go index 8362ae05aa6..8e0973b750c 100644 --- a/pkg/tsdb/mssql/macros_test.go +++ b/pkg/tsdb/mssql/macros_test.go @@ -145,6 +145,18 @@ func TestMacroEngine(t *testing.T) { So(sql, ShouldEqual, fmt.Sprintf("select %d", to.Unix())) }) + + Convey("interpolate __unixEpochGroup function", func() { + + sql, err := engine.Interpolate(query, timeRange, "SELECT $__unixEpochGroup(time_column,'5m')") + So(err, ShouldBeNil) + sql2, err := engine.Interpolate(query, timeRange, "SELECT $__unixEpochGroupAlias(time_column,'5m')") + So(err, ShouldBeNil) + + So(sql, ShouldEqual, "SELECT FLOOR(time_column/300)*300") + So(sql2, ShouldEqual, sql+" AS [time]") + }) + }) Convey("Given a time range between 1960-02-01 07:00 and 1965-02-03 08:00", func() { diff --git a/public/app/plugins/datasource/mssql/partials/query.editor.html b/public/app/plugins/datasource/mssql/partials/query.editor.html index 7888e36a24c..4b0a46b6412 100644 --- a/public/app/plugins/datasource/mssql/partials/query.editor.html +++ b/public/app/plugins/datasource/mssql/partials/query.editor.html @@ -57,6 +57,8 @@ Macros: by setting fillvalue grafana will fill in missing values according to the interval fillvalue can be either a literal value, NULL or previous; previous will fill in the previous seen value or NULL if none has been seen yet - $__timeGroupAlias(column, '5m'[, fillvalue]) -> CAST(ROUND(DATEDIFF(second, '1970-01-01', column)/300.0, 0) as bigint)*300 AS [time] +- $__unixEpochGroup(column,'5m') -> FLOOR(column/300)*300 +- $__unixEpochGroupAlias(column,'5m') -> FLOOR(column/300)*300 AS [time] Example of group by and order by with $__timeGroup: SELECT From 2e2de38b31918f704a0e76ec60e5d997e2ed0bb1 Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Mon, 13 Aug 2018 13:55:47 +0200 Subject: [PATCH 27/99] Mock things --- public/app/plugins/panel/heatmap/rendering.ts | 2 +- .../panel/heatmap/specs/renderer.jest.ts | 39 ++++++++++++++----- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/public/app/plugins/panel/heatmap/rendering.ts b/public/app/plugins/panel/heatmap/rendering.ts index 5af916ac13e..e68d63cfbf8 100644 --- a/public/app/plugins/panel/heatmap/rendering.ts +++ b/public/app/plugins/panel/heatmap/rendering.ts @@ -456,7 +456,6 @@ export class Link { this.chartHeight = this.height - this.margin.top - this.margin.bottom; this.chartTop = this.margin.top; this.chartBottom = this.chartTop + this.chartHeight; - if (this.panel.dataFormat === 'tsbuckets') { this.addYAxisFromBuckets(); } else { @@ -550,6 +549,7 @@ export class Link { .style('opacity', this.getCardOpacity.bind(this)); let $cards = this.$heatmap.find('.heatmap-card'); + console.log($cards); $cards .on('mouseenter', event => { this.tooltip.mouseOverBucket = true; diff --git a/public/app/plugins/panel/heatmap/specs/renderer.jest.ts b/public/app/plugins/panel/heatmap/specs/renderer.jest.ts index c660761890c..a5546624d65 100644 --- a/public/app/plugins/panel/heatmap/specs/renderer.jest.ts +++ b/public/app/plugins/panel/heatmap/specs/renderer.jest.ts @@ -8,17 +8,24 @@ import TimeSeries from 'app/core/time_series2'; import moment from 'moment'; // import { Emitter } from 'app/core/core'; import rendering from '../rendering'; +// import * as d3 from 'd3'; import { convertToHeatMap, convertToCards, histogramToHeatmap, calculateBucketSize } from '../heatmap_data_converter'; jest.mock('app/core/core', () => ({ appEvents: { on: () => {}, }, + contextSrv: { + user: { + lightTheme: false, + }, + }, })); describe('grafanaHeatmap', function() { // beforeEach(angularMocks.module('grafana.core')); let scope = {}; + let render; function heatmapScenario(desc, func, elementWidth = 500) { describe(desc, function() { @@ -154,11 +161,20 @@ describe('grafanaHeatmap', function() { ctrl.data = ctx.data; ctx.element = { - find: () => ({ on: () => {} }), + find: () => ({ + on: () => {}, + css: () => 189, + width: () => 189, + height: () => 200, + find: () => ({ + on: () => {}, + }), + }), on: () => {}, }; - rendering(scope, ctx.element, [], ctrl); - ctrl.events.emit('render'); + render = rendering(scope, ctx.element, [], ctrl); + render.render(); + render.ctrl.renderingCompleted(); }); }; @@ -172,6 +188,9 @@ describe('grafanaHeatmap', function() { }); it('should draw correct Y axis', function() { + console.log('Runnign first test'); + // console.log(render.ctrl.data); + console.log(render.scope.yScale); var yTicks = getTicks(ctx.element, '.axis-y'); expect(yTicks).toEqual(['1', '2', '3']); }); @@ -317,13 +336,13 @@ describe('grafanaHeatmap', function() { }); function getTicks(element, axisSelector) { - return element - .find(axisSelector) - .find('text') - .map(function() { - return this.textContent; - }) - .get(); + // return element + // .find(axisSelector) + // .find('text') + // .map(function() { + // return this.textContent; + // }) + // .get(); } function formatTime(timeStr) { From e6057e08de4cddf5ba1a9f6c163f66835a15161b Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Mon, 13 Aug 2018 14:24:15 +0200 Subject: [PATCH 28/99] Rename to HeatmapRenderer --- public/app/plugins/panel/heatmap/rendering.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/panel/heatmap/rendering.ts b/public/app/plugins/panel/heatmap/rendering.ts index e68d63cfbf8..6d3d21420e0 100644 --- a/public/app/plugins/panel/heatmap/rendering.ts +++ b/public/app/plugins/panel/heatmap/rendering.ts @@ -20,9 +20,9 @@ let MIN_CARD_SIZE = 1, MIN_SELECTION_WIDTH = 2; export default function rendering(scope, elem, attrs, ctrl) { - return new Link(scope, elem, attrs, ctrl); + return new HeatmapRenderer(scope, elem, attrs, ctrl); } -export class Link { +export class HeatmapRenderer { width: number; height: number; yScale: any; From 535bab1baaf45288e863fb04e89974f37b359421 Mon Sep 17 00:00:00 2001 From: Patrick O'Carroll Date: Mon, 13 Aug 2018 15:07:29 +0200 Subject: [PATCH 29/99] now hides team header when no teams + fix for list hidden when only one team --- public/app/features/org/partials/profile.html | 2 +- public/app/features/org/profile_ctrl.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/features/org/partials/profile.html b/public/app/features/org/partials/profile.html index b204c223138..7858e00c683 100644 --- a/public/app/features/org/partials/profile.html +++ b/public/app/features/org/partials/profile.html @@ -26,7 +26,7 @@ -

Teams

+

Teams

diff --git a/public/app/features/org/profile_ctrl.ts b/public/app/features/org/profile_ctrl.ts index 6cfcdc2e64c..40ee4d908a1 100644 --- a/public/app/features/org/profile_ctrl.ts +++ b/public/app/features/org/profile_ctrl.ts @@ -30,7 +30,7 @@ export class ProfileCtrl { getUserTeams() { this.backendSrv.get('/api/user/teams').then(teams => { this.teams = teams; - this.showTeamsList = this.teams.length > 1; + this.showTeamsList = this.teams.length > 0; }); } From fd032c11111833bba562966a6379c4e20c102da6 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Mon, 13 Aug 2018 15:18:33 +0200 Subject: [PATCH 30/99] changelog: add notes about closing #12476 [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d5ed3378de..0a36943af65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * **LDAP**: Define Grafana Admin permission in ldap group mappings [#2469](https://github.com/grafana/grafana/issues/2496), PR [#12622](https://github.com/grafana/grafana/issues/12622) * **Cloudwatch**: CloudWatch GetMetricData support [#11487](https://github.com/grafana/grafana/issues/11487), thx [@mtanda](https://github.com/mtanda) * **Configuration**: Allow auto-assigning users to specific organization (other than Main. Org) [#1823](https://github.com/grafana/grafana/issues/1823) [#12801](https://github.com/grafana/grafana/issues/12801), thx [@gzzo](https://github.com/gzzo) and [@ofosos](https://github.com/ofosos) +* **Profile**: List teams that the user is member of in current/active organization [#12476](https://github.com/grafana/grafana/issues/12476) ### Minor From f2b1fabd5c142d48f93f2499316d9a898fd09a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 13 Aug 2018 15:38:28 +0200 Subject: [PATCH 31/99] fix: Alerting rendering timeout was 30 seconds, same as alert rule eval timeout, this should be much lower so the rendering timeout does not timeout the rule context, fixes #12151 (#12903) --- pkg/services/alerting/notifier.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/services/alerting/notifier.go b/pkg/services/alerting/notifier.go index 07212746f7e..f4e0a0f434f 100644 --- a/pkg/services/alerting/notifier.go +++ b/pkg/services/alerting/notifier.go @@ -3,7 +3,6 @@ package alerting import ( "errors" "fmt" - "time" "golang.org/x/sync/errgroup" @@ -81,7 +80,7 @@ func (n *notificationService) uploadImage(context *EvalContext) (err error) { renderOpts := rendering.Opts{ Width: 1000, Height: 500, - Timeout: time.Second * 30, + Timeout: alertTimeout / 2, OrgId: context.Rule.OrgId, OrgRole: m.ROLE_ADMIN, } From b8a1385c77fd15ce7a15c3be956334f20f4de339 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Mon, 13 Aug 2018 15:38:37 +0200 Subject: [PATCH 32/99] build: increase frontend tests timeout without no output --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8f2e9b6c1af..977121c30ee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -104,6 +104,7 @@ jobs: - run: name: yarn install command: 'yarn install --pure-lockfile --no-progress' + no_output_timeout: 15m - save_cache: key: dependency-cache-{{ checksum "yarn.lock" }} paths: From b0f3ca16d9acc839560619284613814f4fcb3797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 13 Aug 2018 15:40:37 +0200 Subject: [PATCH 33/99] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a36943af65..6eea9bb7337 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ * **Postgres**: Escape ssl mode parameter in connectionstring [#12644](https://github.com/grafana/grafana/issues/12644), thx [@yogyrahmawan](https://github.com/yogyrahmawan) * **Github OAuth**: Allow changes of user info at Github to be synched to Grafana when signing in [#11818](https://github.com/grafana/grafana/issues/11818), thx [@rwaweber](https://github.com/rwaweber) * **Alerting**: Fix diff and percent_diff reducers [#11563](https://github.com/grafana/grafana/issues/11563), thx [@jessetane](https://github.com/jessetane) +* **Alerting**: Fix rendering timeout which could cause notifications to not be sent due to rendering timing out [#12151](https://github.com/grafana/grafana/issues/12151) * **Units**: Polish złoty currency [#12691](https://github.com/grafana/grafana/pull/12691), thx [@mwegrzynek](https://github.com/mwegrzynek) * **Cloudwatch**: Improved error handling [#12489](https://github.com/grafana/grafana/issues/12489), thx [@mtanda](https://github.com/mtanda) * **Cloudwatch**: AppSync metrics and dimensions [#12300](https://github.com/grafana/grafana/issues/12300), thx [@franciscocpg](https://github.com/franciscocpg) From 1c185ef8d824158765ecb2919c772a68876ecc74 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 13 Aug 2018 15:40:52 +0200 Subject: [PATCH 34/99] Add commit to external stylesheet url (#12902) - currently only the release is used as a fingerprint which produces caching issues for all lastest master builds - also add build commit to url fingerprint - make bra also watch go html template files --- .bra.toml | 2 +- public/views/index.template.html | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.bra.toml b/.bra.toml index dcf316466d6..15961e1e3fd 100644 --- a/.bra.toml +++ b/.bra.toml @@ -9,7 +9,7 @@ watch_dirs = [ "$WORKDIR/public/views", "$WORKDIR/conf", ] -watch_exts = [".go", ".ini", ".toml"] +watch_exts = [".go", ".ini", ".toml", ".template.html"] build_delay = 1500 cmds = [ ["go", "run", "build.go", "-dev", "build-server"], diff --git a/public/views/index.template.html b/public/views/index.template.html index ae35666b189..f4c5d183fc8 100644 --- a/public/views/index.template.html +++ b/public/views/index.template.html @@ -11,7 +11,7 @@ - + @@ -107,12 +107,12 @@ [[end]] - + \ No newline at end of file From 39669e5002207fd0b486eeb49a0fa417b51a1e09 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Mon, 13 Aug 2018 15:41:15 +0200 Subject: [PATCH 35/99] fix redirect to panel when using an outdated dashboard slug (#12901) --- public/app/routes/dashboard_loaders.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/app/routes/dashboard_loaders.ts b/public/app/routes/dashboard_loaders.ts index 3642b54c790..b33d5b6afb1 100644 --- a/public/app/routes/dashboard_loaders.ts +++ b/public/app/routes/dashboard_loaders.ts @@ -34,7 +34,9 @@ export class LoadDashboardCtrl { const url = locationUtil.stripBaseFromUrl(result.meta.url); if (url !== $location.path()) { + // replace url to not create additional history items and then return so that initDashboard below isn't executed multiple times. $location.path(url).replace(); + return; } } From 9031866caaa64b71a38395815985b715e821582e Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Mon, 13 Aug 2018 15:51:19 +0200 Subject: [PATCH 36/99] changelog: add notes about closing #12805 [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6eea9bb7337..efc7e44d31b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * **Cloudwatch**: CloudWatch GetMetricData support [#11487](https://github.com/grafana/grafana/issues/11487), thx [@mtanda](https://github.com/mtanda) * **Configuration**: Allow auto-assigning users to specific organization (other than Main. Org) [#1823](https://github.com/grafana/grafana/issues/1823) [#12801](https://github.com/grafana/grafana/issues/12801), thx [@gzzo](https://github.com/gzzo) and [@ofosos](https://github.com/ofosos) * **Profile**: List teams that the user is member of in current/active organization [#12476](https://github.com/grafana/grafana/issues/12476) +* **LDAP**: Client certificates support [#12805](https://github.com/grafana/grafana/issues/12805), thx [@nyxi](https://github.com/nyxi) ### Minor From 472b880939c98716de1ad5f654bb99e79aa11627 Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Mon, 13 Aug 2018 15:51:58 +0200 Subject: [PATCH 37/99] Add React container --- .../panel/heatmap/HeatmapRenderContainer.tsx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 public/app/plugins/panel/heatmap/HeatmapRenderContainer.tsx diff --git a/public/app/plugins/panel/heatmap/HeatmapRenderContainer.tsx b/public/app/plugins/panel/heatmap/HeatmapRenderContainer.tsx new file mode 100644 index 00000000000..e5982a485ca --- /dev/null +++ b/public/app/plugins/panel/heatmap/HeatmapRenderContainer.tsx @@ -0,0 +1,20 @@ +import React from 'react'; +import HeatmapRenderer from './rendering'; +import { HeatmapCtrl } from './heatmap_ctrl'; + +export class HeatmapRenderContainer extends React.Component { + renderer: any; + constructor(props) { + super(props); + this.renderer = HeatmapRenderer( + this.props.scope, + this.props.children[0], + [], + new HeatmapCtrl(this.props.scope, {}, {}) + ); + } + + render() { + return
; + } +} From c521f51780b12937cdc1c9c844f92d9515190320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 13 Aug 2018 15:56:11 +0200 Subject: [PATCH 38/99] tech: removed js related stuff now that 99% is typescript (#12905) --- .jscs.json | 13 -- .jshintrc | 37 ---- Gruntfile.js | 1 - package.json | 3 - scripts/grunt/default_task.js | 4 - scripts/grunt/options/jscs.js | 22 -- scripts/grunt/options/jshint.js | 20 -- tasks/options/copy.js | 45 ---- yarn.lock | 368 +++----------------------------- 9 files changed, 28 insertions(+), 485 deletions(-) delete mode 100644 .jscs.json delete mode 100644 .jshintrc delete mode 100644 scripts/grunt/options/jscs.js delete mode 100644 scripts/grunt/options/jshint.js delete mode 100644 tasks/options/copy.js diff --git a/.jscs.json b/.jscs.json deleted file mode 100644 index 8fdad332de5..00000000000 --- a/.jscs.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "disallowImplicitTypeConversion": ["string"], - "disallowKeywords": ["with"], - "disallowMultipleLineBreaks": true, - "disallowMixedSpacesAndTabs": true, - "disallowTrailingWhitespace": true, - "requireSpacesInFunctionExpression": { - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInsideArrayBrackets": true, - "disallowSpacesInsideParentheses": true, - "validateIndentation": 2 -} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 1d8fad63173..00000000000 --- a/.jshintrc +++ /dev/null @@ -1,37 +0,0 @@ -{ - "browser": true, - "esversion": 6, - "bitwise":false, - "curly": true, - "eqnull": true, - "strict": false, - "devel": true, - "eqeqeq": true, - "forin": false, - "immed": true, - "supernew": true, - "expr": true, - "indent": 2, - "latedef": false, - "newcap": true, - "noarg": true, - "noempty": true, - "undef": true, - "boss": true, - "trailing": true, - "laxbreak": true, - "laxcomma": true, - "sub": true, - "unused": true, - "maxdepth": 6, - "maxlen": 140, - - "globals": { - "System": true, - "Promise": true, - "define": true, - "require": true, - "Chromath": false, - "setImmediate": true - } -} diff --git a/Gruntfile.js b/Gruntfile.js index 23276e8a122..8a71fb44148 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,4 +1,3 @@ -/* jshint node:true */ 'use strict'; module.exports = function (grunt) { var os = require('os'); diff --git a/package.json b/package.json index 200285d7a1e..24e23b574df 100644 --- a/package.json +++ b/package.json @@ -45,9 +45,7 @@ "grunt-contrib-concat": "^1.0.1", "grunt-contrib-copy": "~1.0.0", "grunt-contrib-cssmin": "~1.0.2", - "grunt-contrib-jshint": "~1.1.0", "grunt-exec": "^1.0.1", - "grunt-jscs": "3.0.1", "grunt-karma": "~2.0.0", "grunt-notify": "^0.4.5", "grunt-postcss": "^0.8.0", @@ -60,7 +58,6 @@ "html-webpack-plugin": "^3.2.0", "husky": "^0.14.3", "jest": "^22.0.4", - "jshint-stylish": "~2.2.1", "karma": "1.7.0", "karma-chrome-launcher": "~2.2.0", "karma-expect": "~1.1.3", diff --git a/scripts/grunt/default_task.js b/scripts/grunt/default_task.js index 719f0ab4e95..efcdcd02963 100644 --- a/scripts/grunt/default_task.js +++ b/scripts/grunt/default_task.js @@ -9,8 +9,6 @@ module.exports = function(grunt) { ]); grunt.registerTask('test', [ - 'jscs', - 'jshint', 'sasslint', 'exec:tslint', "exec:jest", @@ -19,8 +17,6 @@ module.exports = function(grunt) { ]); grunt.registerTask('precommit', [ - 'jscs', - 'jshint', 'sasslint', 'exec:tslint', 'no-only-tests' diff --git a/scripts/grunt/options/jscs.js b/scripts/grunt/options/jscs.js deleted file mode 100644 index 8296e59a506..00000000000 --- a/scripts/grunt/options/jscs.js +++ /dev/null @@ -1,22 +0,0 @@ -module.exports = function(config) { - return { - src: [ - 'Gruntfile.js', - '<%= srcDir %>/app/**/*.js', - '<%= srcDir %>/plugin/**/*.js', - '!<%= srcDir %>/app/dashboards/*' - ], - options: { - config: ".jscs.json", - }, - }; -}; - -/* - "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], - "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], - "disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], - "disallowRightStickedOperators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], - "requireRightStickedOperators": ["!"], - "requireLeftStickedOperators": [","], - */ diff --git a/scripts/grunt/options/jshint.js b/scripts/grunt/options/jshint.js deleted file mode 100644 index 7ea36eac3ff..00000000000 --- a/scripts/grunt/options/jshint.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = function(config) { - return { - source: { - files: { - src: ['Gruntfile.js', '<%= srcDir %>/app/**/*.js'], - } - }, - options: { - jshintrc: true, - reporter: require('jshint-stylish'), - ignores: [ - 'node_modules/*', - 'dist/*', - 'sample/*', - '<%= srcDir %>/vendor/*', - '<%= srcDir %>/app/dashboards/*' - ] - } - }; -}; diff --git a/tasks/options/copy.js b/tasks/options/copy.js deleted file mode 100644 index 1ef32af6951..00000000000 --- a/tasks/options/copy.js +++ /dev/null @@ -1,45 +0,0 @@ -module.exports = function(config) { - return { - // copy source to temp, we will minify in place for the dist build - everything_but_less_to_temp: { - cwd: '<%= srcDir %>', - expand: true, - src: ['**/*', '!**/*.less'], - dest: '<%= tempDir %>' - }, - - public_to_gen: { - cwd: '<%= srcDir %>', - expand: true, - src: ['**/*', '!**/*.less'], - dest: '<%= genDir %>' - }, - - node_modules: { - cwd: './node_modules', - expand: true, - src: [ - 'ace-builds/src-noconflict/**/*', - 'eventemitter3/*.js', - 'systemjs/dist/*.js', - 'es6-promise/**/*', - 'es6-shim/*.js', - 'reflect-metadata/*.js', - 'reflect-metadata/*.ts', - 'reflect-metadata/*.d.ts', - 'rxjs/**/*', - 'tether/**/*', - 'tether-drop/**/*', - 'tether-drop/**/*', - 'remarkable/dist/*', - 'remarkable/dist/*', - 'virtual-scroll/**/*', - 'mousetrap/**/*', - 'twemoji/2/twemoji.amd*', - 'twemoji/2/svg/*.svg', - ], - dest: '<%= srcDir %>/vendor/npm' - } - - }; -}; diff --git a/yarn.lock b/yarn.lock index ed8a1eabec3..89e74828351 100644 --- a/yarn.lock +++ b/yarn.lock @@ -414,10 +414,6 @@ JSONStream@^1.3.2: jsonparse "^1.2.0" through ">=2.2.7 <3" -JSV@^4.0.x: - version "4.0.2" - resolved "https://registry.yarnpkg.com/JSV/-/JSV-4.0.2.tgz#d077f6825571f82132f9dffaed587b4029feff57" - abab@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e" @@ -869,10 +865,6 @@ async-limiter@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8" -async@0.2.x, async@~0.2.6, async@~0.2.9: - version "0.2.10" - resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" - async@^1.4.0, async@^1.5.0, async@^1.5.2, async@~1.5.2: version "1.5.2" resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" @@ -883,6 +875,10 @@ async@^2.0.0, async@^2.1.4, async@^2.4.1, async@^2.6.0: dependencies: lodash "^4.17.10" +async@~0.2.6: + version "0.2.10" + resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" + asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" @@ -1564,7 +1560,7 @@ babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.26 lodash "^4.17.4" to-fast-properties "^1.0.3" -babylon@^6.17.3, babylon@^6.18.0, babylon@^6.8.1: +babylon@^6.17.3, babylon@^6.18.0: version "6.18.0" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" @@ -1626,10 +1622,6 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" -beeper@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/beeper/-/beeper-1.1.1.tgz#e6d5ea8c5dad001304a70b22638447f69cb2f809" - better-assert@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/better-assert/-/better-assert-1.0.2.tgz#40866b9e1b9e0b55b481894311e68faffaebc522" @@ -2109,7 +2101,7 @@ center-align@^0.1.1: align-text "^0.1.3" lazy-cache "^1.0.3" -chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3, chalk@~1.1.0, chalk@~1.1.1: +chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3, chalk@~1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" dependencies: @@ -2315,7 +2307,7 @@ cli-table2@^0.2.0, cli-table2@~0.2.0: optionalDependencies: colors "^1.1.2" -cli-table@^0.3.1, cli-table@~0.3.1: +cli-table@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/cli-table/-/cli-table-0.3.1.tgz#f53b05266a8b1a0b934b3d0821e6e2dc5914ae23" dependencies: @@ -2332,13 +2324,6 @@ cli-width@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" -cli@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/cli/-/cli-1.0.1.tgz#22817534f24bfa4950c34d532d48ecbc621b8c14" - dependencies: - exit "0.1.2" - glob "^7.1.1" - clipboard@^1.7.1: version "1.7.1" resolved "https://registry.yarnpkg.com/clipboard/-/clipboard-1.7.1.tgz#360d6d6946e99a7a1fef395e42ba92b5e9b5a16b" @@ -2490,10 +2475,6 @@ colors@0.5.x: version "0.5.1" resolved "https://registry.yarnpkg.com/colors/-/colors-0.5.1.tgz#7d0023eaeb154e8ee9fce75dcb923d0ed1667774" -colors@0.6.x: - version "0.6.2" - resolved "https://registry.yarnpkg.com/colors/-/colors-0.6.2.tgz#2423fe6678ac0c5dae8852e5d0e5be08c997abcc" - colors@1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b" @@ -2539,7 +2520,7 @@ commander@2.8.x: dependencies: graceful-readlink ">= 1.0.0" -commander@2.9.x, commander@~2.9.0: +commander@2.9.x: version "2.9.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" dependencies: @@ -2549,12 +2530,6 @@ commander@~2.13.0: version "2.13.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" -comment-parser@^0.3.1: - version "0.3.2" - resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-0.3.2.tgz#3c03f0776b86a36dfd9a0a2c97c6307f332082fe" - dependencies: - readable-stream "^2.0.4" - commondir@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" @@ -2660,7 +2635,7 @@ connect@^3.6.0: parseurl "~1.3.2" utils-merge "1.0.1" -console-browserify@1.1.x, console-browserify@^1.1.0: +console-browserify@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10" dependencies: @@ -2978,14 +2953,6 @@ csstype@^2.2.0: version "2.5.3" resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.5.3.tgz#2504152e6e1cc59b32098b7f5d6a63f16294c1f7" -cst@^0.4.3: - version "0.4.10" - resolved "https://registry.yarnpkg.com/cst/-/cst-0.4.10.tgz#9c05c825290a762f0a85c0aabb8c0fe035ae8516" - dependencies: - babel-runtime "^6.9.2" - babylon "^6.8.1" - source-map-support "^0.4.0" - currently-unhandled@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" @@ -2996,10 +2963,6 @@ custom-event@~1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" -cycle@1.0.x: - version "1.0.3" - resolved "https://registry.yarnpkg.com/cycle/-/cycle-1.0.3.tgz#21e80b2be8580f98b468f379430662b046c34ad2" - cyclist@~0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-0.2.2.tgz#1b33792e11e914a2fd6d6ed6447464444e5fa640" @@ -3324,7 +3287,7 @@ dedent@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c" -deep-equal@*, deep-equal@^1.0.1: +deep-equal@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5" @@ -3604,12 +3567,6 @@ domhandler@2.1: dependencies: domelementtype "1" -domhandler@2.3: - version "2.3.0" - resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.3.0.tgz#2de59a0822d5027fabff6f032c2b25a2a8abe738" - dependencies: - domelementtype "1" - domhandler@^2.3.0: version "2.4.2" resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.4.2.tgz#8805097e933d65e85546f726d60f5eb88b44f803" @@ -3622,7 +3579,7 @@ domutils@1.1: dependencies: domelementtype "1" -domutils@1.5, domutils@1.5.1: +domutils@1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.5.1.tgz#dcd8488a26f563d61079e48c9f7b7e32373682cf" dependencies: @@ -3813,10 +3770,6 @@ ent@~2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" -entities@1.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-1.0.0.tgz#b2987aa3821347fcde642b24fdfc9e4fb712bf26" - entities@^1.1.1, entities@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" @@ -4181,7 +4134,7 @@ exit-hook@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" -exit@0.1.2, exit@0.1.x, exit@^0.1.2, exit@~0.1.1, exit@~0.1.2: +exit@^0.1.2, exit@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" @@ -4362,10 +4315,6 @@ extsprintf@^1.2.0: version "1.4.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" -eyes@0.1.x: - version "0.1.8" - resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0" - fast-deep-equal@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614" @@ -4945,9 +4894,9 @@ glob@7.1.2, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glo once "^1.3.0" path-is-absolute "^1.0.0" -glob@^5.0.1, glob@~5.0.0: - version "5.0.15" - resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" +glob@^6.0.4: + version "6.0.4" + resolved "https://registry.yarnpkg.com/glob/-/glob-6.0.4.tgz#0f08860f6a155127b2fadd4f9ce24b1aab6e4d22" dependencies: inflight "^1.0.4" inherits "2" @@ -4955,9 +4904,9 @@ glob@^5.0.1, glob@~5.0.0: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^6.0.4: - version "6.0.4" - resolved "https://registry.yarnpkg.com/glob/-/glob-6.0.4.tgz#0f08860f6a155127b2fadd4f9ce24b1aab6e4d22" +glob@~5.0.0: + version "5.0.15" + resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" dependencies: inflight "^1.0.4" inherits "2" @@ -5199,27 +5148,10 @@ grunt-contrib-cssmin@~1.0.2: clean-css "~3.4.2" maxmin "^1.1.0" -grunt-contrib-jshint@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/grunt-contrib-jshint/-/grunt-contrib-jshint-1.1.0.tgz#369d909b2593c40e8be79940b21340850c7939ac" - dependencies: - chalk "^1.1.1" - hooker "^0.2.3" - jshint "~2.9.4" - grunt-exec@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/grunt-exec/-/grunt-exec-1.0.1.tgz#e5d53a39c5f346901305edee5c87db0f2af999c4" -grunt-jscs@3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/grunt-jscs/-/grunt-jscs-3.0.1.tgz#1fae50e3e955df9e3a9d9425aec22accae008092" - dependencies: - hooker "~0.2.3" - jscs "~3.0.5" - lodash "~4.6.1" - vow "~0.4.1" - grunt-karma@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/grunt-karma/-/grunt-karma-2.0.0.tgz#753583d115dfdc055fe57e58f96d6b3c7e612118" @@ -5530,7 +5462,7 @@ homedir-polyfill@^1.0.1: dependencies: parse-passwd "^1.0.0" -hooker@^0.2.3, hooker@~0.2.3: +hooker@~0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/hooker/-/hooker-0.2.3.tgz#b834f723cc4a242aa65963459df6d984c5d3d959" @@ -5614,16 +5546,6 @@ html-webpack-plugin@^3.2.0: toposort "^1.0.0" util.promisify "1.0.0" -htmlparser2@3.8.3, htmlparser2@3.8.x: - version "3.8.3" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.8.3.tgz#996c28b191516a8be86501a7d79757e5c70c1068" - dependencies: - domelementtype "1" - domhandler "2.3" - domutils "1.5" - entities "1.0" - readable-stream "1.1" - htmlparser2@^3.9.1: version "3.9.2" resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.9.2.tgz#1bdf87acca0f3f9e53fa4fcceb0f4b4cbb00b338" @@ -5739,10 +5661,6 @@ husky@^0.14.3: normalize-path "^1.0.0" strip-indent "^2.0.0" -i@0.3.x: - version "0.3.6" - resolved "https://registry.yarnpkg.com/i/-/i-0.3.6.tgz#d96c92732076f072711b6b10fd7d4f65ad8ee23d" - iconv-lite@0.4, iconv-lite@0.4.23, iconv-lite@^0.4.17, iconv-lite@^0.4.4, iconv-lite@~0.4.13: version "0.4.23" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63" @@ -5838,10 +5756,6 @@ inflight@^1.0.4, inflight@~1.0.6: once "^1.3.0" wrappy "1" -inherit@^2.2.2: - version "2.2.6" - resolved "https://registry.yarnpkg.com/inherit/-/inherit-2.2.6.tgz#f1614b06c8544e8128e4229c86347db73ad9788d" - inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" @@ -5938,10 +5852,6 @@ ipaddr.js@1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.6.0.tgz#e3fa357b773da619f26e95f049d055c72796f86b" -irregular-plurals@^1.0.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/irregular-plurals/-/irregular-plurals-1.4.0.tgz#2ca9b033651111855412f16be5d77c62a458a766" - is-absolute-url@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-absolute-url/-/is-absolute-url-2.1.0.tgz#50530dfb84fcc9aa7dbe7852e83a37b93b9f2aa6" @@ -6348,7 +6258,7 @@ isomorphic-fetch@^2.1.1: node-fetch "^1.0.1" whatwg-fetch ">=0.10.0" -isstream@0.1.x, isstream@~0.1.2: +isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" @@ -6748,14 +6658,6 @@ js-yaml@^3.4.3, js-yaml@^3.4.6, js-yaml@^3.5.1, js-yaml@^3.5.4, js-yaml@^3.7.0, argparse "^1.0.7" esprima "^4.0.0" -js-yaml@~3.4.0: - version "3.4.6" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.4.6.tgz#6be1b23f6249f53d293370fd4d1aaa63ce1b4eb0" - dependencies: - argparse "^1.0.2" - esprima "^2.6.0" - inherit "^2.2.2" - js-yaml@~3.5.2: version "3.5.5" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.5.5.tgz#0377c38017cabc7322b0d1fbcd25a491641f2fbe" @@ -6814,54 +6716,6 @@ jscodeshift@^0.5.0: temp "^0.8.1" write-file-atomic "^1.2.0" -jscs-jsdoc@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/jscs-jsdoc/-/jscs-jsdoc-2.0.0.tgz#f53ebce029aa3125bd88290ba50d64d4510a4871" - dependencies: - comment-parser "^0.3.1" - jsdoctypeparser "~1.2.0" - -jscs-preset-wikimedia@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/jscs-preset-wikimedia/-/jscs-preset-wikimedia-1.0.1.tgz#a6a5fa5967fd67a5d609038e1c794eaf41d4233d" - -jscs@~3.0.5: - version "3.0.7" - resolved "https://registry.yarnpkg.com/jscs/-/jscs-3.0.7.tgz#7141b4dff5b86e32d0e99d764b836767c30d201a" - dependencies: - chalk "~1.1.0" - cli-table "~0.3.1" - commander "~2.9.0" - cst "^0.4.3" - estraverse "^4.1.0" - exit "~0.1.2" - glob "^5.0.1" - htmlparser2 "3.8.3" - js-yaml "~3.4.0" - jscs-jsdoc "^2.0.0" - jscs-preset-wikimedia "~1.0.0" - jsonlint "~1.6.2" - lodash "~3.10.0" - minimatch "~3.0.0" - natural-compare "~1.2.2" - pathval "~0.1.1" - prompt "~0.2.14" - reserved-words "^0.1.1" - resolve "^1.1.6" - strip-bom "^2.0.0" - strip-json-comments "~1.0.2" - to-double-quotes "^2.0.0" - to-single-quotes "^2.0.0" - vow "~0.4.8" - vow-fs "~0.3.4" - xmlbuilder "^3.1.0" - -jsdoctypeparser@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/jsdoctypeparser/-/jsdoctypeparser-1.2.0.tgz#e7dedc153a11849ffc5141144ae86a7ef0c25392" - dependencies: - lodash "^3.7.0" - jsdom@^11.5.1: version "11.11.0" resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-11.11.0.tgz#df486efad41aee96c59ad7a190e2449c7eb1110e" @@ -6901,30 +6755,6 @@ jsesc@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" -jshint-stylish@~2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/jshint-stylish/-/jshint-stylish-2.2.1.tgz#242082a2c035ae03fd81044e0570cc4208cf6e61" - dependencies: - beeper "^1.1.0" - chalk "^1.0.0" - log-symbols "^1.0.0" - plur "^2.1.0" - string-length "^1.0.0" - text-table "^0.2.0" - -jshint@~2.9.4: - version "2.9.5" - resolved "https://registry.yarnpkg.com/jshint/-/jshint-2.9.5.tgz#1e7252915ce681b40827ee14248c46d34e9aa62c" - dependencies: - cli "~1.0.0" - console-browserify "1.1.x" - exit "0.1.x" - htmlparser2 "3.8.x" - lodash "3.7.x" - minimatch "~3.0.2" - shelljs "0.3.x" - strip-json-comments "1.0.x" - json-buffer@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.0.tgz#5b1f397afc75d677bde8bcfc0e47e1f9a3d9a898" @@ -6981,13 +6811,6 @@ jsonify@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" -jsonlint@~1.6.2: - version "1.6.3" - resolved "https://registry.yarnpkg.com/jsonlint/-/jsonlint-1.6.3.tgz#cb5e31efc0b78291d0d862fbef05900adf212988" - dependencies: - JSV "^4.0.x" - nomnom "^1.5.x" - jsonparse@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" @@ -7497,11 +7320,7 @@ lodash.without@~4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.without/-/lodash.without-4.4.0.tgz#3cd4574a00b67bae373a94b748772640507b7aac" -lodash@3.7.x: - version "3.7.0" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.7.0.tgz#3678bd8ab995057c07ade836ed2ef087da811d45" - -lodash@^3.10.1, lodash@^3.5.0, lodash@^3.6.0, lodash@^3.7.0, lodash@^3.8.0, lodash@~3.10.0: +lodash@^3.10.1, lodash@^3.6.0, lodash@^3.8.0: version "3.10.1" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" @@ -7513,11 +7332,7 @@ lodash@~4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.3.0.tgz#efd9c4a6ec53f3b05412429915c3e4824e4d25a4" -lodash@~4.6.1: - version "4.6.1" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.6.1.tgz#df00c1164ad236b183cfc3887a5e8d38cc63cbbc" - -log-symbols@^1.0.0, log-symbols@^1.0.2: +log-symbols@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-1.0.2.tgz#376ff7b58ea3086a0f09facc74617eca501e1a18" dependencies: @@ -7990,7 +7805,7 @@ mixin-object@^2.0.1: for-in "^0.1.3" is-extendable "^0.1.1" -mkdirp@0.5.1, mkdirp@0.5.x, mkdirp@0.x.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: +mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" dependencies: @@ -8121,20 +7936,12 @@ natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" -natural-compare@~1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.2.2.tgz#1f96d60e3141cac1b6d05653ce0daeac763af6aa" - ncname@1.0.x: version "1.0.0" resolved "https://registry.yarnpkg.com/ncname/-/ncname-1.0.0.tgz#5b57ad18b1ca092864ef62b0b1ed8194f383b71c" dependencies: xml-char-classes "^1.0.0" -ncp@0.4.x: - version "0.4.2" - resolved "https://registry.yarnpkg.com/ncp/-/ncp-0.4.2.tgz#abcc6cbd3ec2ed2a729ff6e7c1fa8f01784a8574" - nearley@^2.7.10: version "2.13.0" resolved "https://registry.yarnpkg.com/nearley/-/nearley-2.13.0.tgz#6e7b0f4e68bfc3e74c99eaef2eda39e513143439" @@ -8359,7 +8166,7 @@ node-sass@^4.7.2: stdout-stream "^1.4.0" "true-case-path" "^1.0.2" -nomnom@^1.5.x, nomnom@^1.8.1: +nomnom@^1.8.1: version "1.8.1" resolved "https://registry.yarnpkg.com/nomnom/-/nomnom-1.8.1.tgz#2151f722472ba79e50a76fc125bb8c8f2e4dc2a7" dependencies: @@ -9207,10 +9014,6 @@ path-type@^3.0.0: dependencies: pify "^3.0.0" -pathval@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/pathval/-/pathval-0.1.1.tgz#08f911cdca9cce5942880da7817bc0b723b66d82" - pbkdf2@^3.0.3: version "3.0.16" resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.16.tgz#7404208ec6b01b62d85bf83853a8064f8d9c2a5c" @@ -9273,20 +9076,6 @@ pkg-up@^1.0.0: dependencies: find-up "^1.0.0" -pkginfo@0.3.x: - version "0.3.1" - resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.3.1.tgz#5b29f6a81f70717142e09e765bbeab97b4f81e21" - -pkginfo@0.x.x: - version "0.4.1" - resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.4.1.tgz#b5418ef0439de5425fc4995042dced14fb2a84ff" - -plur@^2.1.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/plur/-/plur-2.1.2.tgz#7482452c1a0f508e3e344eaec312c91c29dc655a" - dependencies: - irregular-plurals "^1.0.0" - pluralize@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45" @@ -9810,16 +9599,6 @@ promise@^7.1.1: dependencies: asap "~2.0.3" -prompt@~0.2.14: - version "0.2.14" - resolved "https://registry.yarnpkg.com/prompt/-/prompt-0.2.14.tgz#57754f64f543fd7b0845707c818ece618f05ffdc" - dependencies: - pkginfo "0.x.x" - read "1.0.x" - revalidator "0.1.x" - utile "0.2.x" - winston "0.8.x" - promzard@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/promzard/-/promzard-0.3.0.tgz#26a5d6ee8c7dee4cb12208305acfb93ba382a9ee" @@ -10304,7 +10083,7 @@ read-pkg@^3.0.0: normalize-package-data "^2.3.2" path-type "^3.0.0" -read@1, read@1.0.x, read@~1.0.1, read@~1.0.7: +read@1, read@~1.0.1, read@~1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/read/-/read-1.0.7.tgz#b3da19bd052431a97671d44a42634adf710b40c4" dependencies: @@ -10331,15 +10110,6 @@ readable-stream@1.0, readable-stream@~1.0.2: isarray "0.0.1" string_decoder "~0.10.x" -readable-stream@1.1: - version "1.1.13" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.13.tgz#f6eef764f514c89e2b9e23146a75ba106756d23e" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" - readable-stream@~1.1.10: version "1.1.14" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" @@ -10660,10 +10430,6 @@ requires-port@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" -reserved-words@^0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/reserved-words/-/reserved-words-0.1.2.tgz#00a0940f98cd501aeaaac316411d9adc52b31ab1" - resolve-cwd@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a" @@ -10754,17 +10520,13 @@ retry@^0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/retry/-/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b" -revalidator@0.1.x: - version "0.1.8" - resolved "https://registry.yarnpkg.com/revalidator/-/revalidator-0.1.8.tgz#fece61bfa0c1b52a206bd6b18198184bdd523a3b" - right-align@^0.1.1: version "0.1.3" resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" dependencies: align-text "^0.1.1" -rimraf@2, rimraf@2.x.x, rimraf@^2.2.8, rimraf@^2.4.4, rimraf@^2.5.1, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.0, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@~2.6.2: +rimraf@2, rimraf@^2.2.8, rimraf@^2.4.4, rimraf@^2.5.1, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.0, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@~2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" dependencies: @@ -11116,10 +10878,6 @@ shell-quote@^1.6.1: array-reduce "~0.0.0" jsonify "~0.0.0" -shelljs@0.3.x: - version "0.3.0" - resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.3.0.tgz#3596e6307a781544f591f37da618360f31db57b1" - shelljs@^0.6.0: version "0.6.1" resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.6.1.tgz#ec6211bed1920442088fe0f70b2837232ed2c8a8" @@ -11432,7 +11190,7 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" -source-map-support@^0.4.0, source-map-support@^0.4.15: +source-map-support@^0.4.15: version "0.4.18" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f" dependencies: @@ -11555,10 +11313,6 @@ stack-parser@^0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/stack-parser/-/stack-parser-0.0.1.tgz#7d3b63a17887e9e2c2bf55dbd3318fe34a39d1e7" -stack-trace@0.0.x: - version "0.0.10" - resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" - stack-utils@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-1.0.1.tgz#d4f33ab54e8e38778b0ca5cfd3b3afb12db68620" @@ -11649,12 +11403,6 @@ strict-uri-encode@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" -string-length@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/string-length/-/string-length-1.0.1.tgz#56970fb1c38558e9e70b728bf3de269ac45adfac" - dependencies: - strip-ansi "^3.0.0" - string-length@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/string-length/-/string-length-2.0.0.tgz#d40dbb686a3ace960c1cffca562bf2c45f8363ed" @@ -11766,7 +11514,7 @@ strip-indent@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68" -strip-json-comments@1.0.x, strip-json-comments@~1.0.1, strip-json-comments@~1.0.2: +strip-json-comments@~1.0.1: version "1.0.4" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91" @@ -12029,10 +11777,6 @@ to-buffer@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/to-buffer/-/to-buffer-1.1.1.tgz#493bd48f62d7c43fcded313a03dcadb2e1213a80" -to-double-quotes@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/to-double-quotes/-/to-double-quotes-2.0.0.tgz#aaf231d6fa948949f819301bbab4484d8588e4a7" - to-fast-properties@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" @@ -12059,10 +11803,6 @@ to-regex@^3.0.1, to-regex@^3.0.2: regex-not "^1.0.2" safe-regex "^1.1.0" -to-single-quotes@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/to-single-quotes/-/to-single-quotes-2.0.1.tgz#7cc29151f0f5f2c41946f119f5932fe554170125" - toposort@^1.0.0: version "1.0.7" resolved "https://registry.yarnpkg.com/toposort/-/toposort-1.0.7.tgz#2e68442d9f64ec720b8cc89e6443ac6caa950029" @@ -12527,25 +12267,10 @@ utila@~0.4: version "0.4.0" resolved "https://registry.yarnpkg.com/utila/-/utila-0.4.0.tgz#8a16a05d445657a3aea5eecc5b12a4fa5379772c" -utile@0.2.x: - version "0.2.1" - resolved "https://registry.yarnpkg.com/utile/-/utile-0.2.1.tgz#930c88e99098d6220834c356cbd9a770522d90d7" - dependencies: - async "~0.2.9" - deep-equal "*" - i "0.3.x" - mkdirp "0.x.x" - ncp "0.4.x" - rimraf "2.x.x" - utils-merge@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" -uuid@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a" - uuid@^3.0.0, uuid@^3.0.1, uuid@^3.1.0, uuid@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14" @@ -12623,25 +12348,6 @@ void-elements@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" -vow-fs@~0.3.4: - version "0.3.6" - resolved "https://registry.yarnpkg.com/vow-fs/-/vow-fs-0.3.6.tgz#2d4c59be22e2bf2618ddf597ab4baa923be7200d" - dependencies: - glob "^7.0.5" - uuid "^2.0.2" - vow "^0.4.7" - vow-queue "^0.4.1" - -vow-queue@^0.4.1: - version "0.4.3" - resolved "https://registry.yarnpkg.com/vow-queue/-/vow-queue-0.4.3.tgz#4ba8f64b56e9212c0dbe57f1405aeebd54cce78d" - dependencies: - vow "^0.4.17" - -vow@^0.4.17, vow@^0.4.7, vow@~0.4.1, vow@~0.4.8: - version "0.4.17" - resolved "https://registry.yarnpkg.com/vow/-/vow-0.4.17.tgz#b16e08fae58c52f3ebc6875f2441b26a92682904" - vue-parser@^1.1.5: version "1.1.6" resolved "https://registry.yarnpkg.com/vue-parser/-/vue-parser-1.1.6.tgz#3063c8431795664ebe429c23b5506899706e6355" @@ -12960,18 +12666,6 @@ window-size@0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" -winston@0.8.x: - version "0.8.3" - resolved "https://registry.yarnpkg.com/winston/-/winston-0.8.3.tgz#64b6abf4cd01adcaefd5009393b1d8e8bec19db0" - dependencies: - async "0.2.x" - colors "0.6.x" - cycle "1.0.x" - eyes "0.1.x" - isstream "0.1.x" - pkginfo "0.3.x" - stack-trace "0.0.x" - wordwrap@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" @@ -13053,12 +12747,6 @@ xml-name-validator@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" -xmlbuilder@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-3.1.0.tgz#2c86888f2d4eade850fa38ca7f7223f7209516e1" - dependencies: - lodash "^3.5.0" - xmlhttprequest-ssl@1.5.3: version "1.5.3" resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz#185a888c04eca46c3e4070d99f7b49de3528992d" From 739bee020779fa9af6ac88f087b33cc1d37328df Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Mon, 13 Aug 2018 16:08:01 +0200 Subject: [PATCH 39/99] Karma to Jest: graph (refactor) (#12860) * Begin conversion * Test setup started * Begin rewrite of graph * Rewrite as class * Some tests passing * Fix binding errors * Half tests passing * Call buildFlotPairs. More tests passing * All tests passing * Remove test test * Remove Karma test * Make methods out of event functions * Rename GraphElement --- public/app/plugins/panel/graph/graph.ts | 1403 +++++++++-------- public/app/plugins/panel/graph/module.ts | 1 + .../plugins/panel/graph/specs/graph.jest.ts | 518 ++++++ .../plugins/panel/graph/specs/graph_specs.ts | 454 ------ 4 files changed, 1236 insertions(+), 1140 deletions(-) create mode 100644 public/app/plugins/panel/graph/specs/graph.jest.ts delete mode 100644 public/app/plugins/panel/graph/specs/graph_specs.ts diff --git a/public/app/plugins/panel/graph/graph.ts b/public/app/plugins/panel/graph/graph.ts index 9f216c12288..35886aa5bf7 100755 --- a/public/app/plugins/panel/graph/graph.ts +++ b/public/app/plugins/panel/graph/graph.ts @@ -21,699 +21,730 @@ import { convertToHistogramData } from './histogram'; import { alignYLevel } from './align_yaxes'; import config from 'app/core/config'; +import { GraphCtrl } from './module'; + +class GraphElement { + ctrl: GraphCtrl; + tooltip: any; + dashboard: any; + annotations: Array; + panel: any; + plot: any; + sortedSeries: Array; + data: Array; + panelWidth: number; + eventManager: EventManager; + thresholdManager: ThresholdManager; + + constructor(private scope, private elem, private timeSrv) { + this.ctrl = scope.ctrl; + this.dashboard = this.ctrl.dashboard; + this.panel = this.ctrl.panel; + this.annotations = []; + + this.panelWidth = 0; + this.eventManager = new EventManager(this.ctrl); + this.thresholdManager = new ThresholdManager(this.ctrl); + this.tooltip = new GraphTooltip(this.elem, this.ctrl.dashboard, this.scope, () => { + return this.sortedSeries; + }); + + // panel events + this.ctrl.events.on('panel-teardown', this.onPanelteardown.bind(this)); + + /** + * Split graph rendering into two parts. + * First, calculate series stats in buildFlotPairs() function. Then legend rendering started + * (see ctrl.events.on('render') in legend.ts). + * When legend is rendered it emits 'legend-rendering-complete' and graph rendered. + */ + this.ctrl.events.on('render', this.onRender.bind(this)); + this.ctrl.events.on('legend-rendering-complete', this.onLegendRenderingComplete.bind(this)); + + // global events + appEvents.on('graph-hover', this.onGraphHover.bind(this), scope); + + appEvents.on('graph-hover-clear', this.onGraphHoverClear.bind(this), scope); + + this.elem.bind('plotselected', this.onPlotSelected.bind(this)); + + this.elem.bind('plotclick', this.onPlotClick.bind(this)); + scope.$on('$destroy', this.onScopeDestroy.bind(this)); + } + + onRender(renderData) { + this.data = renderData || this.data; + if (!this.data) { + return; + } + this.annotations = this.ctrl.annotations || []; + this.buildFlotPairs(this.data); + const graphHeight = this.elem.height(); + updateLegendValues(this.data, this.panel, graphHeight); + + this.ctrl.events.emit('render-legend'); + } + + onGraphHover(evt) { + // ignore other graph hover events if shared tooltip is disabled + if (!this.dashboard.sharedTooltipModeEnabled()) { + return; + } + + // ignore if we are the emitter + if (!this.plot || evt.panel.id === this.panel.id || this.ctrl.otherPanelInFullscreenMode()) { + return; + } + + this.tooltip.show(evt.pos); + } + + onPanelteardown() { + this.thresholdManager = null; + + if (this.plot) { + this.plot.destroy(); + this.plot = null; + } + } + + onLegendRenderingComplete() { + this.render_panel(); + } + + onGraphHoverClear(event, info) { + if (this.plot) { + this.tooltip.clear(this.plot); + } + } + + onPlotSelected(event, ranges) { + if (this.panel.xaxis.mode !== 'time') { + // Skip if panel in histogram or series mode + this.plot.clearSelection(); + return; + } + + if ((ranges.ctrlKey || ranges.metaKey) && (this.dashboard.meta.canEdit || this.dashboard.meta.canMakeEditable)) { + // Add annotation + setTimeout(() => { + this.eventManager.updateTime(ranges.xaxis); + }, 100); + } else { + this.scope.$apply(() => { + this.timeSrv.setTime({ + from: moment.utc(ranges.xaxis.from), + to: moment.utc(ranges.xaxis.to), + }); + }); + } + } + + onPlotClick(event, pos, item) { + if (this.panel.xaxis.mode !== 'time') { + // Skip if panel in histogram or series mode + return; + } + + if ((pos.ctrlKey || pos.metaKey) && (this.dashboard.meta.canEdit || this.dashboard.meta.canMakeEditable)) { + // Skip if range selected (added in "plotselected" event handler) + let isRangeSelection = pos.x !== pos.x1; + if (!isRangeSelection) { + setTimeout(() => { + this.eventManager.updateTime({ from: pos.x, to: null }); + }, 100); + } + } + } + + onScopeDestroy() { + this.tooltip.destroy(); + this.elem.off(); + this.elem.remove(); + } + + shouldAbortRender() { + if (!this.data) { + return true; + } + + if (this.panelWidth === 0) { + return true; + } + + return false; + } + + drawHook(plot) { + // add left axis labels + if (this.panel.yaxes[0].label && this.panel.yaxes[0].show) { + $("
") + .text(this.panel.yaxes[0].label) + .appendTo(this.elem); + } + + // add right axis labels + if (this.panel.yaxes[1].label && this.panel.yaxes[1].show) { + $("
") + .text(this.panel.yaxes[1].label) + .appendTo(this.elem); + } + + if (this.ctrl.dataWarning) { + $(`
${this.ctrl.dataWarning.title}
`).appendTo(this.elem); + } + + this.thresholdManager.draw(plot); + } + + processOffsetHook(plot, gridMargin) { + var left = this.panel.yaxes[0]; + var right = this.panel.yaxes[1]; + if (left.show && left.label) { + gridMargin.left = 20; + } + if (right.show && right.label) { + gridMargin.right = 20; + } + + // apply y-axis min/max options + var yaxis = plot.getYAxes(); + for (var i = 0; i < yaxis.length; i++) { + var axis = yaxis[i]; + var panelOptions = this.panel.yaxes[i]; + axis.options.max = axis.options.max !== null ? axis.options.max : panelOptions.max; + axis.options.min = axis.options.min !== null ? axis.options.min : panelOptions.min; + } + } + + processRangeHook(plot) { + var yAxes = plot.getYAxes(); + const align = this.panel.yaxis.align || false; + + if (yAxes.length > 1 && align === true) { + const level = this.panel.yaxis.alignLevel || 0; + alignYLevel(yAxes, parseFloat(level)); + } + } + + // Series could have different timeSteps, + // let's find the smallest one so that bars are correctly rendered. + // In addition, only take series which are rendered as bars for this. + getMinTimeStepOfSeries(data) { + var min = Number.MAX_VALUE; + + for (let i = 0; i < data.length; i++) { + if (!data[i].stats.timeStep) { + continue; + } + if (this.panel.bars) { + if (data[i].bars && data[i].bars.show === false) { + continue; + } + } else { + if (typeof data[i].bars === 'undefined' || typeof data[i].bars.show === 'undefined' || !data[i].bars.show) { + continue; + } + } + + if (data[i].stats.timeStep < min) { + min = data[i].stats.timeStep; + } + } + + return min; + } + + // Function for rendering panel + render_panel() { + this.panelWidth = this.elem.width(); + if (this.shouldAbortRender()) { + return; + } + + // give space to alert editing + this.thresholdManager.prepare(this.elem, this.data); + + // un-check dashes if lines are unchecked + this.panel.dashes = this.panel.lines ? this.panel.dashes : false; + + // Populate element + let options: any = this.buildFlotOptions(this.panel); + this.prepareXAxis(options, this.panel); + this.configureYAxisOptions(this.data, options); + this.thresholdManager.addFlotOptions(options, this.panel); + this.eventManager.addFlotEvents(this.annotations, options); + + this.sortedSeries = this.sortSeries(this.data, this.panel); + this.callPlot(options, true); + } + + buildFlotPairs(data) { + for (let i = 0; i < data.length; i++) { + let series = data[i]; + series.data = series.getFlotPairs(series.nullPointMode || this.panel.nullPointMode); + + // if hidden remove points and disable stack + if (this.ctrl.hiddenSeries[series.alias]) { + series.data = []; + series.stack = false; + } + } + } + + prepareXAxis(options, panel) { + switch (panel.xaxis.mode) { + case 'series': { + options.series.bars.barWidth = 0.7; + options.series.bars.align = 'center'; + + for (let i = 0; i < this.data.length; i++) { + let series = this.data[i]; + series.data = [[i + 1, series.stats[panel.xaxis.values[0]]]]; + } + + this.addXSeriesAxis(options); + break; + } + case 'histogram': { + let bucketSize: number; + + if (this.data.length) { + let histMin = _.min(_.map(this.data, s => s.stats.min)); + let histMax = _.max(_.map(this.data, s => s.stats.max)); + let ticks = panel.xaxis.buckets || this.panelWidth / 50; + bucketSize = tickStep(histMin, histMax, ticks); + options.series.bars.barWidth = bucketSize * 0.8; + this.data = convertToHistogramData(this.data, bucketSize, this.ctrl.hiddenSeries, histMin, histMax); + } else { + bucketSize = 0; + } + + this.addXHistogramAxis(options, bucketSize); + break; + } + case 'table': { + options.series.bars.barWidth = 0.7; + options.series.bars.align = 'center'; + this.addXTableAxis(options); + break; + } + default: { + options.series.bars.barWidth = this.getMinTimeStepOfSeries(this.data) / 1.5; + this.addTimeAxis(options); + break; + } + } + } + + callPlot(options, incrementRenderCounter) { + try { + this.plot = $.plot(this.elem, this.sortedSeries, options); + if (this.ctrl.renderError) { + delete this.ctrl.error; + delete this.ctrl.inspector; + } + } catch (e) { + console.log('flotcharts error', e); + this.ctrl.error = e.message || 'Render Error'; + this.ctrl.renderError = true; + this.ctrl.inspector = { error: e }; + } + + if (incrementRenderCounter) { + this.ctrl.renderingCompleted(); + } + } + + buildFlotOptions(panel) { + let gridColor = '#c8c8c8'; + if (config.bootData.user.lightTheme === true) { + gridColor = '#a1a1a1'; + } + const stack = panel.stack ? true : null; + let options = { + hooks: { + draw: [this.drawHook.bind(this)], + processOffset: [this.processOffsetHook.bind(this)], + processRange: [this.processRangeHook.bind(this)], + }, + legend: { show: false }, + series: { + stackpercent: panel.stack ? panel.percentage : false, + stack: panel.percentage ? null : stack, + lines: { + show: panel.lines, + zero: false, + fill: this.translateFillOption(panel.fill), + lineWidth: panel.dashes ? 0 : panel.linewidth, + steps: panel.steppedLine, + }, + dashes: { + show: panel.dashes, + lineWidth: panel.linewidth, + dashLength: [panel.dashLength, panel.spaceLength], + }, + bars: { + show: panel.bars, + fill: 1, + barWidth: 1, + zero: false, + lineWidth: 0, + }, + points: { + show: panel.points, + fill: 1, + fillColor: false, + radius: panel.points ? panel.pointradius : 2, + }, + shadowSize: 0, + }, + yaxes: [], + xaxis: {}, + grid: { + minBorderMargin: 0, + markings: [], + backgroundColor: null, + borderWidth: 0, + hoverable: true, + clickable: true, + color: gridColor, + margin: { left: 0, right: 0 }, + labelMarginX: 0, + }, + selection: { + mode: 'x', + color: '#666', + }, + crosshair: { + mode: 'x', + }, + }; + return options; + } + + sortSeries(series, panel) { + var sortBy = panel.legend.sort; + var sortOrder = panel.legend.sortDesc; + var haveSortBy = sortBy !== null && sortBy !== undefined; + var haveSortOrder = sortOrder !== null && sortOrder !== undefined; + var shouldSortBy = panel.stack && haveSortBy && haveSortOrder; + var sortDesc = panel.legend.sortDesc === true ? -1 : 1; + + if (shouldSortBy) { + return _.sortBy(series, s => s.stats[sortBy] * sortDesc); + } else { + return _.sortBy(series, s => s.zindex); + } + } + + translateFillOption(fill) { + if (this.panel.percentage && this.panel.stack) { + return fill === 0 ? 0.001 : fill / 10; + } else { + return fill / 10; + } + } + + addTimeAxis(options) { + var ticks = this.panelWidth / 100; + var min = _.isUndefined(this.ctrl.range.from) ? null : this.ctrl.range.from.valueOf(); + var max = _.isUndefined(this.ctrl.range.to) ? null : this.ctrl.range.to.valueOf(); + + options.xaxis = { + timezone: this.dashboard.getTimezone(), + show: this.panel.xaxis.show, + mode: 'time', + min: min, + max: max, + label: 'Datetime', + ticks: ticks, + timeformat: this.time_format(ticks, min, max), + }; + } + + addXSeriesAxis(options) { + var ticks = _.map(this.data, function(series, index) { + return [index + 1, series.alias]; + }); + + options.xaxis = { + timezone: this.dashboard.getTimezone(), + show: this.panel.xaxis.show, + mode: null, + min: 0, + max: ticks.length + 1, + label: 'Datetime', + ticks: ticks, + }; + } + + addXHistogramAxis(options, bucketSize) { + let ticks, min, max; + let defaultTicks = this.panelWidth / 50; + + if (this.data.length && bucketSize) { + let tick_values = []; + for (let d of this.data) { + for (let point of d.data) { + tick_values[point[0]] = true; + } + } + ticks = Object.keys(tick_values).map(v => Number(v)); + min = _.min(ticks); + max = _.max(ticks); + + // Adjust tick step + let tickStep = bucketSize; + let ticks_num = Math.floor((max - min) / tickStep); + while (ticks_num > defaultTicks) { + tickStep = tickStep * 2; + ticks_num = Math.ceil((max - min) / tickStep); + } + + // Expand ticks for pretty view + min = Math.floor(min / tickStep) * tickStep; + // 1.01 is 101% - ensure we have enough space for last bar + max = Math.ceil(max * 1.01 / tickStep) * tickStep; + + ticks = []; + for (let i = min; i <= max; i += tickStep) { + ticks.push(i); + } + } else { + // Set defaults if no data + ticks = defaultTicks / 2; + min = 0; + max = 1; + } + + options.xaxis = { + timezone: this.dashboard.getTimezone(), + show: this.panel.xaxis.show, + mode: null, + min: min, + max: max, + label: 'Histogram', + ticks: ticks, + }; + + // Use 'short' format for histogram values + this.configureAxisMode(options.xaxis, 'short'); + } + + addXTableAxis(options) { + var ticks = _.map(this.data, function(series, seriesIndex) { + return _.map(series.datapoints, function(point, pointIndex) { + var tickIndex = seriesIndex * series.datapoints.length + pointIndex; + return [tickIndex + 1, point[1]]; + }); + }); + ticks = _.flatten(ticks, true); + + options.xaxis = { + timezone: this.dashboard.getTimezone(), + show: this.panel.xaxis.show, + mode: null, + min: 0, + max: ticks.length + 1, + label: 'Datetime', + ticks: ticks, + }; + } + + configureYAxisOptions(data, options) { + var defaults = { + position: 'left', + show: this.panel.yaxes[0].show, + index: 1, + logBase: this.panel.yaxes[0].logBase || 1, + min: this.parseNumber(this.panel.yaxes[0].min), + max: this.parseNumber(this.panel.yaxes[0].max), + tickDecimals: this.panel.yaxes[0].decimals, + }; + + options.yaxes.push(defaults); + + if (_.find(data, { yaxis: 2 })) { + var secondY = _.clone(defaults); + secondY.index = 2; + secondY.show = this.panel.yaxes[1].show; + secondY.logBase = this.panel.yaxes[1].logBase || 1; + secondY.position = 'right'; + secondY.min = this.parseNumber(this.panel.yaxes[1].min); + secondY.max = this.parseNumber(this.panel.yaxes[1].max); + secondY.tickDecimals = this.panel.yaxes[1].decimals; + options.yaxes.push(secondY); + + this.applyLogScale(options.yaxes[1], data); + this.configureAxisMode( + options.yaxes[1], + this.panel.percentage && this.panel.stack ? 'percent' : this.panel.yaxes[1].format + ); + } + this.applyLogScale(options.yaxes[0], data); + this.configureAxisMode( + options.yaxes[0], + this.panel.percentage && this.panel.stack ? 'percent' : this.panel.yaxes[0].format + ); + } + + parseNumber(value: any) { + if (value === null || typeof value === 'undefined') { + return null; + } + + return _.toNumber(value); + } + + applyLogScale(axis, data) { + if (axis.logBase === 1) { + return; + } + + const minSetToZero = axis.min === 0; + + if (axis.min < Number.MIN_VALUE) { + axis.min = null; + } + if (axis.max < Number.MIN_VALUE) { + axis.max = null; + } + + var series, i; + var max = axis.max, + min = axis.min; + + for (i = 0; i < data.length; i++) { + series = data[i]; + if (series.yaxis === axis.index) { + if (!max || max < series.stats.max) { + max = series.stats.max; + } + if (!min || min > series.stats.logmin) { + min = series.stats.logmin; + } + } + } + + axis.transform = function(v) { + return v < Number.MIN_VALUE ? null : Math.log(v) / Math.log(axis.logBase); + }; + axis.inverseTransform = function(v) { + return Math.pow(axis.logBase, v); + }; + + if (!max && !min) { + max = axis.inverseTransform(+2); + min = axis.inverseTransform(-2); + } else if (!max) { + max = min * axis.inverseTransform(+4); + } else if (!min) { + min = max * axis.inverseTransform(-4); + } + + if (axis.min) { + min = axis.inverseTransform(Math.ceil(axis.transform(axis.min))); + } else { + min = axis.min = axis.inverseTransform(Math.floor(axis.transform(min))); + } + if (axis.max) { + max = axis.inverseTransform(Math.floor(axis.transform(axis.max))); + } else { + max = axis.max = axis.inverseTransform(Math.ceil(axis.transform(max))); + } + + if (!min || min < Number.MIN_VALUE || !max || max < Number.MIN_VALUE) { + return; + } + + if (Number.isFinite(min) && Number.isFinite(max)) { + if (minSetToZero) { + axis.min = 0.1; + min = 1; + } + + axis.ticks = this.generateTicksForLogScaleYAxis(min, max, axis.logBase); + if (minSetToZero) { + axis.ticks.unshift(0.1); + } + if (axis.ticks[axis.ticks.length - 1] > axis.max) { + axis.max = axis.ticks[axis.ticks.length - 1]; + } + } else { + axis.ticks = [1, 2]; + delete axis.min; + delete axis.max; + } + } + + generateTicksForLogScaleYAxis(min, max, logBase) { + let ticks = []; + + var nextTick; + for (nextTick = min; nextTick <= max; nextTick *= logBase) { + ticks.push(nextTick); + } + + const maxNumTicks = Math.ceil(this.ctrl.height / 25); + const numTicks = ticks.length; + if (numTicks > maxNumTicks) { + const factor = Math.ceil(numTicks / maxNumTicks) * logBase; + ticks = []; + + for (nextTick = min; nextTick <= max * factor; nextTick *= factor) { + ticks.push(nextTick); + } + } + + return ticks; + } + + configureAxisMode(axis, format) { + axis.tickFormatter = function(val, axis) { + if (!kbn.valueFormats[format]) { + throw new Error(`Unit '${format}' is not supported`); + } + return kbn.valueFormats[format](val, axis.tickDecimals, axis.scaledDecimals); + }; + } + + time_format(ticks, min, max) { + if (min && max && ticks) { + var range = max - min; + var secPerTick = range / ticks / 1000; + var oneDay = 86400000; + var oneYear = 31536000000; + + if (secPerTick <= 45) { + return '%H:%M:%S'; + } + if (secPerTick <= 7200 || range <= oneDay) { + return '%H:%M'; + } + if (secPerTick <= 80000) { + return '%m/%d %H:%M'; + } + if (secPerTick <= 2419200 || range <= oneYear) { + return '%m/%d'; + } + return '%Y-%m'; + } + + return '%H:%M'; + } +} + /** @ngInject **/ function graphDirective(timeSrv, popoverSrv, contextSrv) { return { restrict: 'A', template: '', - link: function(scope, elem) { - var ctrl = scope.ctrl; - var dashboard = ctrl.dashboard; - var panel = ctrl.panel; - var annotations = []; - var data; - var plot; - var sortedSeries; - var panelWidth = 0; - var eventManager = new EventManager(ctrl); - var thresholdManager = new ThresholdManager(ctrl); - var tooltip = new GraphTooltip(elem, dashboard, scope, function() { - return sortedSeries; - }); - - // panel events - ctrl.events.on('panel-teardown', () => { - thresholdManager = null; - - if (plot) { - plot.destroy(); - plot = null; - } - }); - - /** - * Split graph rendering into two parts. - * First, calculate series stats in buildFlotPairs() function. Then legend rendering started - * (see ctrl.events.on('render') in legend.ts). - * When legend is rendered it emits 'legend-rendering-complete' and graph rendered. - */ - ctrl.events.on('render', renderData => { - data = renderData || data; - if (!data) { - return; - } - annotations = ctrl.annotations || []; - buildFlotPairs(data); - const graphHeight = elem.height(); - updateLegendValues(data, panel, graphHeight); - - ctrl.events.emit('render-legend'); - }); - - ctrl.events.on('legend-rendering-complete', () => { - render_panel(); - }); - - // global events - appEvents.on( - 'graph-hover', - evt => { - // ignore other graph hover events if shared tooltip is disabled - if (!dashboard.sharedTooltipModeEnabled()) { - return; - } - - // ignore if we are the emitter - if (!plot || evt.panel.id === panel.id || ctrl.otherPanelInFullscreenMode()) { - return; - } - - tooltip.show(evt.pos); - }, - scope - ); - - appEvents.on( - 'graph-hover-clear', - (event, info) => { - if (plot) { - tooltip.clear(plot); - } - }, - scope - ); - - function shouldAbortRender() { - if (!data) { - return true; - } - - if (panelWidth === 0) { - return true; - } - - return false; - } - - function drawHook(plot) { - // add left axis labels - if (panel.yaxes[0].label && panel.yaxes[0].show) { - $("
") - .text(panel.yaxes[0].label) - .appendTo(elem); - } - - // add right axis labels - if (panel.yaxes[1].label && panel.yaxes[1].show) { - $("
") - .text(panel.yaxes[1].label) - .appendTo(elem); - } - - if (ctrl.dataWarning) { - $(`
${ctrl.dataWarning.title}
`).appendTo(elem); - } - - thresholdManager.draw(plot); - } - - function processOffsetHook(plot, gridMargin) { - 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; - } - - // apply y-axis min/max options - var yaxis = plot.getYAxes(); - for (var i = 0; i < yaxis.length; i++) { - var axis = yaxis[i]; - var panelOptions = panel.yaxes[i]; - axis.options.max = axis.options.max !== null ? axis.options.max : panelOptions.max; - axis.options.min = axis.options.min !== null ? axis.options.min : panelOptions.min; - } - } - - function processRangeHook(plot) { - var yAxes = plot.getYAxes(); - const align = panel.yaxis.align || false; - - if (yAxes.length > 1 && align === true) { - const level = panel.yaxis.alignLevel || 0; - alignYLevel(yAxes, parseFloat(level)); - } - } - - // Series could have different timeSteps, - // let's find the smallest one so that bars are correctly rendered. - // In addition, only take series which are rendered as bars for this. - function getMinTimeStepOfSeries(data) { - var min = Number.MAX_VALUE; - - for (let i = 0; i < data.length; i++) { - if (!data[i].stats.timeStep) { - continue; - } - if (panel.bars) { - if (data[i].bars && data[i].bars.show === false) { - continue; - } - } else { - if (typeof data[i].bars === 'undefined' || typeof data[i].bars.show === 'undefined' || !data[i].bars.show) { - continue; - } - } - - if (data[i].stats.timeStep < min) { - min = data[i].stats.timeStep; - } - } - - return min; - } - - // Function for rendering panel - function render_panel() { - panelWidth = elem.width(); - if (shouldAbortRender()) { - return; - } - - // give space to alert editing - thresholdManager.prepare(elem, data); - - // un-check dashes if lines are unchecked - panel.dashes = panel.lines ? panel.dashes : false; - - // Populate element - let options: any = buildFlotOptions(panel); - prepareXAxis(options, panel); - configureYAxisOptions(data, options); - thresholdManager.addFlotOptions(options, panel); - eventManager.addFlotEvents(annotations, options); - - sortedSeries = sortSeries(data, panel); - callPlot(options, true); - } - - function buildFlotPairs(data) { - for (let i = 0; i < data.length; i++) { - let series = data[i]; - series.data = series.getFlotPairs(series.nullPointMode || panel.nullPointMode); - - // if hidden remove points and disable stack - if (ctrl.hiddenSeries[series.alias]) { - series.data = []; - series.stack = false; - } - } - } - - function prepareXAxis(options, panel) { - switch (panel.xaxis.mode) { - case 'series': { - options.series.bars.barWidth = 0.7; - options.series.bars.align = 'center'; - - for (let i = 0; i < data.length; i++) { - let series = data[i]; - series.data = [[i + 1, series.stats[panel.xaxis.values[0]]]]; - } - - addXSeriesAxis(options); - break; - } - case 'histogram': { - let bucketSize: number; - - if (data.length) { - let histMin = _.min(_.map(data, s => s.stats.min)); - let histMax = _.max(_.map(data, s => s.stats.max)); - let ticks = panel.xaxis.buckets || panelWidth / 50; - bucketSize = tickStep(histMin, histMax, ticks); - options.series.bars.barWidth = bucketSize * 0.8; - data = convertToHistogramData(data, bucketSize, ctrl.hiddenSeries, histMin, histMax); - } else { - bucketSize = 0; - } - - addXHistogramAxis(options, bucketSize); - break; - } - case 'table': { - options.series.bars.barWidth = 0.7; - options.series.bars.align = 'center'; - addXTableAxis(options); - break; - } - default: { - options.series.bars.barWidth = getMinTimeStepOfSeries(data) / 1.5; - addTimeAxis(options); - break; - } - } - } - - function callPlot(options, incrementRenderCounter) { - try { - plot = $.plot(elem, sortedSeries, options); - if (ctrl.renderError) { - delete ctrl.error; - delete ctrl.inspector; - } - } catch (e) { - console.log('flotcharts error', e); - ctrl.error = e.message || 'Render Error'; - ctrl.renderError = true; - ctrl.inspector = { error: e }; - } - - if (incrementRenderCounter) { - ctrl.renderingCompleted(); - } - } - - function buildFlotOptions(panel) { - let gridColor = '#c8c8c8'; - if (config.bootData.user.lightTheme === true) { - gridColor = '#a1a1a1'; - } - const stack = panel.stack ? true : null; - let options = { - hooks: { - draw: [drawHook], - processOffset: [processOffsetHook], - processRange: [processRangeHook], - }, - legend: { show: false }, - series: { - stackpercent: panel.stack ? panel.percentage : false, - stack: panel.percentage ? null : stack, - lines: { - show: panel.lines, - zero: false, - fill: translateFillOption(panel.fill), - lineWidth: panel.dashes ? 0 : panel.linewidth, - steps: panel.steppedLine, - }, - dashes: { - show: panel.dashes, - lineWidth: panel.linewidth, - dashLength: [panel.dashLength, panel.spaceLength], - }, - bars: { - show: panel.bars, - fill: 1, - barWidth: 1, - zero: false, - lineWidth: 0, - }, - points: { - show: panel.points, - fill: 1, - fillColor: false, - radius: panel.points ? panel.pointradius : 2, - }, - shadowSize: 0, - }, - yaxes: [], - xaxis: {}, - grid: { - minBorderMargin: 0, - markings: [], - backgroundColor: null, - borderWidth: 0, - hoverable: true, - clickable: true, - color: gridColor, - margin: { left: 0, right: 0 }, - labelMarginX: 0, - }, - selection: { - mode: 'x', - color: '#666', - }, - crosshair: { - mode: 'x', - }, - }; - return options; - } - - function sortSeries(series, panel) { - var sortBy = panel.legend.sort; - var sortOrder = panel.legend.sortDesc; - var haveSortBy = sortBy !== null && sortBy !== undefined; - var haveSortOrder = sortOrder !== null && sortOrder !== undefined; - var shouldSortBy = panel.stack && haveSortBy && haveSortOrder; - var sortDesc = panel.legend.sortDesc === true ? -1 : 1; - - if (shouldSortBy) { - return _.sortBy(series, s => s.stats[sortBy] * sortDesc); - } else { - return _.sortBy(series, s => s.zindex); - } - } - - function translateFillOption(fill) { - if (panel.percentage && panel.stack) { - return fill === 0 ? 0.001 : fill / 10; - } else { - return fill / 10; - } - } - - function addTimeAxis(options) { - var ticks = panelWidth / 100; - var min = _.isUndefined(ctrl.range.from) ? null : ctrl.range.from.valueOf(); - var max = _.isUndefined(ctrl.range.to) ? null : ctrl.range.to.valueOf(); - - options.xaxis = { - timezone: dashboard.getTimezone(), - show: panel.xaxis.show, - mode: 'time', - min: min, - max: max, - label: 'Datetime', - ticks: ticks, - timeformat: time_format(ticks, min, max), - }; - } - - function addXSeriesAxis(options) { - var ticks = _.map(data, function(series, index) { - return [index + 1, series.alias]; - }); - - options.xaxis = { - timezone: dashboard.getTimezone(), - show: panel.xaxis.show, - mode: null, - min: 0, - max: ticks.length + 1, - label: 'Datetime', - ticks: ticks, - }; - } - - function addXHistogramAxis(options, bucketSize) { - let ticks, min, max; - let defaultTicks = panelWidth / 50; - - if (data.length && bucketSize) { - let tick_values = []; - for (let d of data) { - for (let point of d.data) { - tick_values[point[0]] = true; - } - } - ticks = Object.keys(tick_values).map(v => Number(v)); - min = _.min(ticks); - max = _.max(ticks); - - // Adjust tick step - let tickStep = bucketSize; - let ticks_num = Math.floor((max - min) / tickStep); - while (ticks_num > defaultTicks) { - tickStep = tickStep * 2; - ticks_num = Math.ceil((max - min) / tickStep); - } - - // Expand ticks for pretty view - min = Math.floor(min / tickStep) * tickStep; - // 1.01 is 101% - ensure we have enough space for last bar - max = Math.ceil(max * 1.01 / tickStep) * tickStep; - - ticks = []; - for (let i = min; i <= max; i += tickStep) { - ticks.push(i); - } - } else { - // Set defaults if no data - ticks = defaultTicks / 2; - min = 0; - max = 1; - } - - options.xaxis = { - timezone: dashboard.getTimezone(), - show: panel.xaxis.show, - mode: null, - min: min, - max: max, - label: 'Histogram', - ticks: ticks, - }; - - // Use 'short' format for histogram values - configureAxisMode(options.xaxis, 'short'); - } - - function addXTableAxis(options) { - var ticks = _.map(data, function(series, seriesIndex) { - return _.map(series.datapoints, function(point, pointIndex) { - var tickIndex = seriesIndex * series.datapoints.length + pointIndex; - return [tickIndex + 1, point[1]]; - }); - }); - ticks = _.flatten(ticks, true); - - options.xaxis = { - timezone: dashboard.getTimezone(), - show: panel.xaxis.show, - mode: null, - min: 0, - max: ticks.length + 1, - label: 'Datetime', - ticks: ticks, - }; - } - - function configureYAxisOptions(data, options) { - var defaults = { - position: 'left', - show: panel.yaxes[0].show, - index: 1, - logBase: panel.yaxes[0].logBase || 1, - min: parseNumber(panel.yaxes[0].min), - max: parseNumber(panel.yaxes[0].max), - tickDecimals: panel.yaxes[0].decimals, - }; - - options.yaxes.push(defaults); - - if (_.find(data, { yaxis: 2 })) { - var secondY = _.clone(defaults); - secondY.index = 2; - secondY.show = panel.yaxes[1].show; - secondY.logBase = panel.yaxes[1].logBase || 1; - secondY.position = 'right'; - secondY.min = parseNumber(panel.yaxes[1].min); - secondY.max = parseNumber(panel.yaxes[1].max); - secondY.tickDecimals = panel.yaxes[1].decimals; - options.yaxes.push(secondY); - - applyLogScale(options.yaxes[1], data); - configureAxisMode(options.yaxes[1], panel.percentage && panel.stack ? 'percent' : panel.yaxes[1].format); - } - applyLogScale(options.yaxes[0], data); - configureAxisMode(options.yaxes[0], panel.percentage && panel.stack ? 'percent' : panel.yaxes[0].format); - } - - function parseNumber(value: any) { - if (value === null || typeof value === 'undefined') { - return null; - } - - return _.toNumber(value); - } - - function applyLogScale(axis, data) { - if (axis.logBase === 1) { - return; - } - - const minSetToZero = axis.min === 0; - - if (axis.min < Number.MIN_VALUE) { - axis.min = null; - } - if (axis.max < Number.MIN_VALUE) { - axis.max = null; - } - - var series, i; - var max = axis.max, - min = axis.min; - - for (i = 0; i < data.length; i++) { - series = data[i]; - if (series.yaxis === axis.index) { - if (!max || max < series.stats.max) { - max = series.stats.max; - } - if (!min || min > series.stats.logmin) { - min = series.stats.logmin; - } - } - } - - axis.transform = function(v) { - return v < Number.MIN_VALUE ? null : Math.log(v) / Math.log(axis.logBase); - }; - axis.inverseTransform = function(v) { - return Math.pow(axis.logBase, v); - }; - - if (!max && !min) { - max = axis.inverseTransform(+2); - min = axis.inverseTransform(-2); - } else if (!max) { - max = min * axis.inverseTransform(+4); - } else if (!min) { - min = max * axis.inverseTransform(-4); - } - - if (axis.min) { - min = axis.inverseTransform(Math.ceil(axis.transform(axis.min))); - } else { - min = axis.min = axis.inverseTransform(Math.floor(axis.transform(min))); - } - if (axis.max) { - max = axis.inverseTransform(Math.floor(axis.transform(axis.max))); - } else { - max = axis.max = axis.inverseTransform(Math.ceil(axis.transform(max))); - } - - if (!min || min < Number.MIN_VALUE || !max || max < Number.MIN_VALUE) { - return; - } - - if (Number.isFinite(min) && Number.isFinite(max)) { - if (minSetToZero) { - axis.min = 0.1; - min = 1; - } - - axis.ticks = generateTicksForLogScaleYAxis(min, max, axis.logBase); - if (minSetToZero) { - axis.ticks.unshift(0.1); - } - if (axis.ticks[axis.ticks.length - 1] > axis.max) { - axis.max = axis.ticks[axis.ticks.length - 1]; - } - } else { - axis.ticks = [1, 2]; - delete axis.min; - delete axis.max; - } - } - - function generateTicksForLogScaleYAxis(min, max, logBase) { - let ticks = []; - - var nextTick; - for (nextTick = min; nextTick <= max; nextTick *= logBase) { - ticks.push(nextTick); - } - - const maxNumTicks = Math.ceil(ctrl.height / 25); - const numTicks = ticks.length; - if (numTicks > maxNumTicks) { - const factor = Math.ceil(numTicks / maxNumTicks) * logBase; - ticks = []; - - for (nextTick = min; nextTick <= max * factor; nextTick *= factor) { - ticks.push(nextTick); - } - } - - return ticks; - } - - function configureAxisMode(axis, format) { - axis.tickFormatter = function(val, axis) { - if (!kbn.valueFormats[format]) { - throw new Error(`Unit '${format}' is not supported`); - } - return kbn.valueFormats[format](val, axis.tickDecimals, axis.scaledDecimals); - }; - } - - function time_format(ticks, min, max) { - if (min && max && ticks) { - var range = max - min; - var secPerTick = range / ticks / 1000; - var oneDay = 86400000; - var oneYear = 31536000000; - - if (secPerTick <= 45) { - return '%H:%M:%S'; - } - if (secPerTick <= 7200 || range <= oneDay) { - return '%H:%M'; - } - if (secPerTick <= 80000) { - return '%m/%d %H:%M'; - } - if (secPerTick <= 2419200 || range <= oneYear) { - return '%m/%d'; - } - return '%Y-%m'; - } - - return '%H:%M'; - } - - elem.bind('plotselected', function(event, ranges) { - if (panel.xaxis.mode !== 'time') { - // Skip if panel in histogram or series mode - plot.clearSelection(); - return; - } - - if ((ranges.ctrlKey || ranges.metaKey) && (dashboard.meta.canEdit || dashboard.meta.canMakeEditable)) { - // Add annotation - setTimeout(() => { - eventManager.updateTime(ranges.xaxis); - }, 100); - } else { - scope.$apply(function() { - timeSrv.setTime({ - from: moment.utc(ranges.xaxis.from), - to: moment.utc(ranges.xaxis.to), - }); - }); - } - }); - - elem.bind('plotclick', function(event, pos, item) { - if (panel.xaxis.mode !== 'time') { - // Skip if panel in histogram or series mode - return; - } - - if ((pos.ctrlKey || pos.metaKey) && (dashboard.meta.canEdit || dashboard.meta.canMakeEditable)) { - // Skip if range selected (added in "plotselected" event handler) - let isRangeSelection = pos.x !== pos.x1; - if (!isRangeSelection) { - setTimeout(() => { - eventManager.updateTime({ from: pos.x, to: null }); - }, 100); - } - } - }); - - scope.$on('$destroy', function() { - tooltip.destroy(); - elem.off(); - elem.remove(); - }); + link: (scope, elem) => { + return new GraphElement(scope, elem, timeSrv); }, }; } coreModule.directive('grafanaGraph', graphDirective); +export { GraphElement, graphDirective }; diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index ef82fb395a5..ba151692147 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -13,6 +13,7 @@ import { axesEditorComponent } from './axes_editor'; class GraphCtrl extends MetricsPanelCtrl { static template = template; + renderError: boolean; hiddenSeries: any = {}; seriesList: any = []; dataList: any = []; diff --git a/public/app/plugins/panel/graph/specs/graph.jest.ts b/public/app/plugins/panel/graph/specs/graph.jest.ts new file mode 100644 index 00000000000..f75f7cd68ea --- /dev/null +++ b/public/app/plugins/panel/graph/specs/graph.jest.ts @@ -0,0 +1,518 @@ +jest.mock('app/features/annotations/all', () => ({ + EventManager: function() { + return { + on: () => {}, + addFlotEvents: () => {}, + }; + }, +})); + +jest.mock('app/core/core', () => ({ + coreModule: { + directive: () => {}, + }, + appEvents: { + on: () => {}, + }, +})); + +import '../module'; +import { GraphCtrl } from '../module'; +import { MetricsPanelCtrl } from 'app/features/panel/metrics_panel_ctrl'; +import { PanelCtrl } from 'app/features/panel/panel_ctrl'; + +import config from 'app/core/config'; + +import TimeSeries from 'app/core/time_series2'; +import moment from 'moment'; +import $ from 'jquery'; +import { graphDirective } from '../graph'; + +let ctx = {}; +let ctrl; +let scope = { + ctrl: {}, + range: { + from: moment([2015, 1, 1]), + to: moment([2015, 11, 20]), + }, + $on: () => {}, +}; +let link; + +describe('grafanaGraph', function() { + const setupCtx = (beforeRender?) => { + config.bootData = { + user: { + lightTheme: false, + }, + }; + GraphCtrl.prototype = { + ...MetricsPanelCtrl.prototype, + ...PanelCtrl.prototype, + ...GraphCtrl.prototype, + height: 200, + panel: { + events: { + on: () => {}, + }, + legend: {}, + grid: {}, + yaxes: [ + { + min: null, + max: null, + format: 'short', + logBase: 1, + }, + { + min: null, + max: null, + format: 'short', + logBase: 1, + }, + ], + thresholds: [], + xaxis: {}, + seriesOverrides: [], + tooltip: { + shared: true, + }, + }, + renderingCompleted: jest.fn(), + hiddenSeries: {}, + dashboard: { + getTimezone: () => 'browser', + }, + range: { + from: moment([2015, 1, 1, 10]), + to: moment([2015, 1, 1, 22]), + }, + }; + + ctx.data = []; + ctx.data.push( + new TimeSeries({ + datapoints: [[1, 1], [2, 2]], + alias: 'series1', + }) + ); + ctx.data.push( + new TimeSeries({ + datapoints: [[10, 1], [20, 2]], + alias: 'series2', + }) + ); + + ctrl = new GraphCtrl( + { + $on: () => {}, + }, + { + get: () => {}, + }, + {} + ); + + $.plot = ctrl.plot = jest.fn(); + scope.ctrl = ctrl; + + link = graphDirective({}, {}, {}).link(scope, { width: () => 500, mouseleave: () => {}, bind: () => {} }); + if (typeof beforeRender === 'function') { + beforeRender(); + } + link.data = ctx.data; + + //Emulate functions called by event listeners + link.buildFlotPairs(link.data); + link.render_panel(); + ctx.plotData = ctrl.plot.mock.calls[0][1]; + + ctx.plotOptions = ctrl.plot.mock.calls[0][2]; + }; + + describe('simple lines options', () => { + beforeEach(() => { + setupCtx(() => { + ctrl.panel.lines = true; + ctrl.panel.fill = 5; + ctrl.panel.linewidth = 3; + ctrl.panel.steppedLine = true; + }); + }); + + it('should configure plot with correct options', () => { + expect(ctx.plotOptions.series.lines.show).toBe(true); + expect(ctx.plotOptions.series.lines.fill).toBe(0.5); + expect(ctx.plotOptions.series.lines.lineWidth).toBe(3); + expect(ctx.plotOptions.series.lines.steps).toBe(true); + }); + }); + + describe('sorting stacked series as legend. disabled', () => { + beforeEach(() => { + setupCtx(() => { + ctrl.panel.legend.sort = undefined; + ctrl.panel.stack = false; + }); + }); + + it('should not modify order of time series', () => { + expect(ctx.plotData[0].alias).toBe('series1'); + expect(ctx.plotData[1].alias).toBe('series2'); + }); + }); + + describe('sorting stacked series as legend. min descending order', () => { + beforeEach(() => { + setupCtx(() => { + ctrl.panel.legend.sort = 'min'; + ctrl.panel.legend.sortDesc = true; + ctrl.panel.stack = true; + }); + }); + it('highest value should be first', () => { + expect(ctx.plotData[0].alias).toBe('series2'); + expect(ctx.plotData[1].alias).toBe('series1'); + }); + }); + + describe('sorting stacked series as legend. min ascending order', () => { + beforeEach(() => { + setupCtx(() => { + ctrl.panel.legend.sort = 'min'; + ctrl.panel.legend.sortDesc = false; + ctrl.panel.stack = true; + }); + }); + it('lowest value should be first', () => { + expect(ctx.plotData[0].alias).toBe('series1'); + expect(ctx.plotData[1].alias).toBe('series2'); + }); + }); + + describe('sorting stacked series as legend. stacking disabled', () => { + beforeEach(() => { + setupCtx(() => { + ctrl.panel.legend.sort = 'min'; + ctrl.panel.legend.sortDesc = true; + ctrl.panel.stack = false; + }); + }); + + it('highest value should be first', () => { + expect(ctx.plotData[0].alias).toBe('series1'); + expect(ctx.plotData[1].alias).toBe('series2'); + }); + }); + + describe('sorting stacked series as legend. current descending order', () => { + beforeEach(() => { + setupCtx(() => { + ctrl.panel.legend.sort = 'current'; + ctrl.panel.legend.sortDesc = true; + ctrl.panel.stack = true; + }); + }); + + it('highest last value should be first', () => { + expect(ctx.plotData[0].alias).toBe('series2'); + expect(ctx.plotData[1].alias).toBe('series1'); + }); + }); + + describe('when logBase is log 10', () => { + beforeEach(() => { + setupCtx(() => { + ctx.data[0] = new TimeSeries({ + datapoints: [[2000, 1], [0.002, 2], [0, 3], [-1, 4]], + alias: 'seriesAutoscale', + }); + ctx.data[0].yaxis = 1; + ctx.data[1] = new TimeSeries({ + datapoints: [[2000, 1], [0.002, 2], [0, 3], [-1, 4]], + alias: 'seriesFixedscale', + }); + ctx.data[1].yaxis = 2; + ctrl.panel.yaxes[0].logBase = 10; + + ctrl.panel.yaxes[1].logBase = 10; + ctrl.panel.yaxes[1].min = '0.05'; + ctrl.panel.yaxes[1].max = '1500'; + }); + }); + + it('should apply axis transform, autoscaling (if necessary) and ticks', function() { + var axisAutoscale = ctx.plotOptions.yaxes[0]; + expect(axisAutoscale.transform(100)).toBe(2); + expect(axisAutoscale.inverseTransform(-3)).toBeCloseTo(0.001); + expect(axisAutoscale.min).toBeCloseTo(0.001); + expect(axisAutoscale.max).toBe(10000); + expect(axisAutoscale.ticks.length).toBeCloseTo(8); + expect(axisAutoscale.ticks[0]).toBeCloseTo(0.001); + if (axisAutoscale.ticks.length === 7) { + expect(axisAutoscale.ticks[axisAutoscale.ticks.length - 1]).toBeCloseTo(1000); + } else { + expect(axisAutoscale.ticks[axisAutoscale.ticks.length - 1]).toBe(10000); + } + + var axisFixedscale = ctx.plotOptions.yaxes[1]; + expect(axisFixedscale.min).toBe(0.05); + expect(axisFixedscale.max).toBe(1500); + expect(axisFixedscale.ticks.length).toBe(5); + expect(axisFixedscale.ticks[0]).toBe(0.1); + expect(axisFixedscale.ticks[4]).toBe(1000); + }); + }); + + describe('when logBase is log 10 and data points contain only zeroes', () => { + beforeEach(() => { + setupCtx(() => { + ctrl.panel.yaxes[0].logBase = 10; + ctx.data[0] = new TimeSeries({ + datapoints: [[0, 1], [0, 2], [0, 3], [0, 4]], + alias: 'seriesAutoscale', + }); + ctx.data[0].yaxis = 1; + }); + }); + + it('should not set min and max and should create some fake ticks', function() { + var axisAutoscale = ctx.plotOptions.yaxes[0]; + expect(axisAutoscale.transform(100)).toBe(2); + expect(axisAutoscale.inverseTransform(-3)).toBeCloseTo(0.001); + expect(axisAutoscale.min).toBe(undefined); + expect(axisAutoscale.max).toBe(undefined); + expect(axisAutoscale.ticks.length).toBe(2); + expect(axisAutoscale.ticks[0]).toBe(1); + expect(axisAutoscale.ticks[1]).toBe(2); + }); + }); + + // y-min set 0 is a special case for log scale, + // this approximates it by setting min to 0.1 + describe('when logBase is log 10 and y-min is set to 0 and auto min is > 0.1', () => { + beforeEach(() => { + setupCtx(() => { + ctrl.panel.yaxes[0].logBase = 10; + ctrl.panel.yaxes[0].min = '0'; + ctx.data[0] = new TimeSeries({ + datapoints: [[2000, 1], [4, 2], [500, 3], [3000, 4]], + alias: 'seriesAutoscale', + }); + ctx.data[0].yaxis = 1; + }); + }); + it('should set min to 0.1 and add a tick for 0.1', function() { + var axisAutoscale = ctx.plotOptions.yaxes[0]; + expect(axisAutoscale.transform(100)).toBe(2); + expect(axisAutoscale.inverseTransform(-3)).toBeCloseTo(0.001); + expect(axisAutoscale.min).toBe(0.1); + expect(axisAutoscale.max).toBe(10000); + expect(axisAutoscale.ticks.length).toBe(6); + expect(axisAutoscale.ticks[0]).toBe(0.1); + expect(axisAutoscale.ticks[5]).toBe(10000); + }); + }); + + describe('when logBase is log 2 and y-min is set to 0 and num of ticks exceeds max', () => { + beforeEach(() => { + setupCtx(() => { + const heightForApprox5Ticks = 125; + ctrl.height = heightForApprox5Ticks; + ctrl.panel.yaxes[0].logBase = 2; + ctrl.panel.yaxes[0].min = '0'; + ctx.data[0] = new TimeSeries({ + datapoints: [[2000, 1], [4, 2], [500, 3], [3000, 4], [10000, 5], [100000, 6]], + alias: 'seriesAutoscale', + }); + ctx.data[0].yaxis = 1; + }); + }); + + it('should regenerate ticks so that if fits on the y-axis', function() { + var axisAutoscale = ctx.plotOptions.yaxes[0]; + expect(axisAutoscale.min).toBe(0.1); + expect(axisAutoscale.ticks.length).toBe(8); + expect(axisAutoscale.ticks[0]).toBe(0.1); + expect(axisAutoscale.ticks[7]).toBe(262144); + expect(axisAutoscale.max).toBe(262144); + }); + + it('should set axis max to be max tick value', function() { + expect(ctx.plotOptions.yaxes[0].max).toBe(262144); + }); + }); + + describe('dashed lines options', () => { + beforeEach(() => { + setupCtx(() => { + ctrl.panel.lines = true; + ctrl.panel.linewidth = 2; + ctrl.panel.dashes = true; + }); + }); + + it('should configure dashed plot with correct options', function() { + expect(ctx.plotOptions.series.lines.show).toBe(true); + expect(ctx.plotOptions.series.dashes.lineWidth).toBe(2); + expect(ctx.plotOptions.series.dashes.show).toBe(true); + }); + }); + + describe('should use timeStep for barWidth', () => { + beforeEach(() => { + setupCtx(() => { + ctrl.panel.bars = true; + ctx.data[0] = new TimeSeries({ + datapoints: [[1, 10], [2, 20]], + alias: 'series1', + }); + }); + }); + + it('should set barWidth', function() { + expect(ctx.plotOptions.series.bars.barWidth).toBe(1 / 1.5); + }); + }); + + describe('series option overrides, fill & points', () => { + beforeEach(() => { + setupCtx(() => { + ctrl.panel.lines = true; + ctrl.panel.fill = 5; + ctx.data[0].zindex = 10; + ctx.data[1].alias = 'test'; + ctx.data[1].lines = { fill: 0.001 }; + ctx.data[1].points = { show: true }; + }); + }); + + it('should match second series and fill zero, and enable points', function() { + expect(ctx.plotOptions.series.lines.fill).toBe(0.5); + expect(ctx.plotData[1].lines.fill).toBe(0.001); + expect(ctx.plotData[1].points.show).toBe(true); + }); + }); + + describe('should order series order according to zindex', () => { + beforeEach(() => { + setupCtx(() => { + ctx.data[1].zindex = 1; + ctx.data[0].zindex = 10; + }); + }); + + it('should move zindex 2 last', function() { + expect(ctx.plotData[0].alias).toBe('series2'); + expect(ctx.plotData[1].alias).toBe('series1'); + }); + }); + + describe('when series is hidden', () => { + beforeEach(() => { + setupCtx(() => { + ctrl.hiddenSeries = { series2: true }; + }); + }); + + it('should remove datapoints and disable stack', function() { + expect(ctx.plotData[0].alias).toBe('series1'); + expect(ctx.plotData[1].data.length).toBe(0); + expect(ctx.plotData[1].stack).toBe(false); + }); + }); + + describe('when stack and percent', () => { + beforeEach(() => { + setupCtx(() => { + ctrl.panel.percentage = true; + ctrl.panel.stack = true; + }); + }); + + it('should show percentage', function() { + var axis = ctx.plotOptions.yaxes[0]; + expect(axis.tickFormatter(100, axis)).toBe('100%'); + }); + }); + + describe('when panel too narrow to show x-axis dates in same granularity as wide panels', () => { + //Set width to 10px + describe('and the range is less than 24 hours', function() { + beforeEach(() => { + setupCtx(() => { + ctrl.range.from = moment([2015, 1, 1, 10]); + ctrl.range.to = moment([2015, 1, 1, 22]); + }); + }); + + it('should format dates as hours minutes', function() { + var axis = ctx.plotOptions.xaxis; + expect(axis.timeformat).toBe('%H:%M'); + }); + }); + + describe('and the range is less than one year', function() { + beforeEach(() => { + setupCtx(() => { + ctrl.range.from = moment([2015, 1, 1]); + ctrl.range.to = moment([2015, 11, 20]); + }); + }); + + it('should format dates as month days', function() { + var axis = ctx.plotOptions.xaxis; + expect(axis.timeformat).toBe('%m/%d'); + }); + }); + }); + + describe('when graph is histogram, and enable stack', () => { + beforeEach(() => { + setupCtx(() => { + ctrl.panel.xaxis.mode = 'histogram'; + ctrl.panel.stack = true; + ctrl.hiddenSeries = {}; + ctx.data[0] = new TimeSeries({ + datapoints: [[100, 1], [100, 2], [200, 3], [300, 4]], + alias: 'series1', + }); + ctx.data[1] = new TimeSeries({ + datapoints: [[100, 1], [100, 2], [200, 3], [300, 4]], + alias: 'series2', + }); + }); + }); + + it('should calculate correct histogram', function() { + expect(ctx.plotData[0].data[0][0]).toBe(100); + expect(ctx.plotData[0].data[0][1]).toBe(2); + expect(ctx.plotData[1].data[0][0]).toBe(100); + expect(ctx.plotData[1].data[0][1]).toBe(2); + }); + }); + + describe('when graph is histogram, and some series are hidden', () => { + beforeEach(() => { + setupCtx(() => { + ctrl.panel.xaxis.mode = 'histogram'; + ctrl.panel.stack = false; + ctrl.hiddenSeries = { series2: true }; + ctx.data[0] = new TimeSeries({ + datapoints: [[100, 1], [100, 2], [200, 3], [300, 4]], + alias: 'series1', + }); + ctx.data[1] = new TimeSeries({ + datapoints: [[100, 1], [100, 2], [200, 3], [300, 4]], + alias: 'series2', + }); + }); + }); + + it('should calculate correct histogram', function() { + expect(ctx.plotData[0].data[0][0]).toBe(100); + expect(ctx.plotData[0].data[0][1]).toBe(2); + }); + }); +}); diff --git a/public/app/plugins/panel/graph/specs/graph_specs.ts b/public/app/plugins/panel/graph/specs/graph_specs.ts deleted file mode 100644 index d29320a9d72..00000000000 --- a/public/app/plugins/panel/graph/specs/graph_specs.ts +++ /dev/null @@ -1,454 +0,0 @@ -import { describe, beforeEach, it, sinon, expect, angularMocks } from '../../../../../test/lib/common'; - -import '../module'; -import angular from 'angular'; -import $ from 'jquery'; -import helpers from 'test/specs/helpers'; -import TimeSeries from 'app/core/time_series2'; -import moment from 'moment'; -import { Emitter } from 'app/core/core'; - -describe('grafanaGraph', function() { - beforeEach(angularMocks.module('grafana.core')); - - function graphScenario(desc, func, elementWidth = 500) { - describe(desc, () => { - var ctx: any = {}; - - ctx.setup = setupFunc => { - beforeEach( - angularMocks.module($provide => { - $provide.value('timeSrv', new helpers.TimeSrvStub()); - }) - ); - - beforeEach( - angularMocks.inject(($rootScope, $compile) => { - var ctrl: any = { - height: 200, - panel: { - events: new Emitter(), - legend: {}, - grid: {}, - yaxes: [ - { - min: null, - max: null, - format: 'short', - logBase: 1, - }, - { - min: null, - max: null, - format: 'short', - logBase: 1, - }, - ], - thresholds: [], - xaxis: {}, - seriesOverrides: [], - tooltip: { - shared: true, - }, - }, - renderingCompleted: sinon.spy(), - hiddenSeries: {}, - dashboard: { - getTimezone: sinon.stub().returns('browser'), - }, - range: { - from: moment([2015, 1, 1, 10]), - to: moment([2015, 1, 1, 22]), - }, - }; - - var scope = $rootScope.$new(); - scope.ctrl = ctrl; - scope.ctrl.events = ctrl.panel.events; - - $rootScope.onAppEvent = sinon.spy(); - - ctx.data = []; - ctx.data.push( - new TimeSeries({ - datapoints: [[1, 1], [2, 2]], - alias: 'series1', - }) - ); - ctx.data.push( - new TimeSeries({ - datapoints: [[10, 1], [20, 2]], - alias: 'series2', - }) - ); - - setupFunc(ctrl, ctx.data); - - var element = angular.element("
"); - $compile(element)(scope); - scope.$digest(); - - $.plot = ctx.plotSpy = sinon.spy(); - ctrl.events.emit('render', ctx.data); - ctrl.events.emit('render-legend'); - ctrl.events.emit('legend-rendering-complete'); - ctx.plotData = ctx.plotSpy.getCall(0).args[1]; - ctx.plotOptions = ctx.plotSpy.getCall(0).args[2]; - }) - ); - }; - - func(ctx); - }); - } - - graphScenario('simple lines options', ctx => { - ctx.setup(ctrl => { - ctrl.panel.lines = true; - ctrl.panel.fill = 5; - ctrl.panel.linewidth = 3; - ctrl.panel.steppedLine = true; - }); - - it('should configure plot with correct options', () => { - expect(ctx.plotOptions.series.lines.show).to.be(true); - expect(ctx.plotOptions.series.lines.fill).to.be(0.5); - expect(ctx.plotOptions.series.lines.lineWidth).to.be(3); - expect(ctx.plotOptions.series.lines.steps).to.be(true); - }); - }); - - graphScenario('sorting stacked series as legend. disabled', ctx => { - ctx.setup(ctrl => { - ctrl.panel.legend.sort = undefined; - ctrl.panel.stack = false; - }); - - it('should not modify order of time series', () => { - expect(ctx.plotData[0].alias).to.be('series1'); - expect(ctx.plotData[1].alias).to.be('series2'); - }); - }); - - graphScenario('sorting stacked series as legend. min descending order', ctx => { - ctx.setup(ctrl => { - ctrl.panel.legend.sort = 'min'; - ctrl.panel.legend.sortDesc = true; - ctrl.panel.stack = true; - }); - - it('highest value should be first', () => { - expect(ctx.plotData[0].alias).to.be('series2'); - expect(ctx.plotData[1].alias).to.be('series1'); - }); - }); - - graphScenario('sorting stacked series as legend. min ascending order', ctx => { - ctx.setup((ctrl, data) => { - ctrl.panel.legend.sort = 'min'; - ctrl.panel.legend.sortDesc = false; - ctrl.panel.stack = true; - }); - - it('lowest value should be first', () => { - expect(ctx.plotData[0].alias).to.be('series1'); - expect(ctx.plotData[1].alias).to.be('series2'); - }); - }); - - graphScenario('sorting stacked series as legend. stacking disabled', ctx => { - ctx.setup(ctrl => { - ctrl.panel.legend.sort = 'min'; - ctrl.panel.legend.sortDesc = true; - ctrl.panel.stack = false; - }); - - it('highest value should be first', () => { - expect(ctx.plotData[0].alias).to.be('series1'); - expect(ctx.plotData[1].alias).to.be('series2'); - }); - }); - - graphScenario('sorting stacked series as legend. current descending order', ctx => { - ctx.setup(ctrl => { - ctrl.panel.legend.sort = 'current'; - ctrl.panel.legend.sortDesc = true; - ctrl.panel.stack = true; - }); - - it('highest last value should be first', () => { - expect(ctx.plotData[0].alias).to.be('series2'); - expect(ctx.plotData[1].alias).to.be('series1'); - }); - }); - - graphScenario('when logBase is log 10', function(ctx) { - ctx.setup(function(ctrl, data) { - ctrl.panel.yaxes[0].logBase = 10; - data[0] = new TimeSeries({ - datapoints: [[2000, 1], [0.002, 2], [0, 3], [-1, 4]], - alias: 'seriesAutoscale', - }); - data[0].yaxis = 1; - ctrl.panel.yaxes[1].logBase = 10; - ctrl.panel.yaxes[1].min = '0.05'; - ctrl.panel.yaxes[1].max = '1500'; - data[1] = new TimeSeries({ - datapoints: [[2000, 1], [0.002, 2], [0, 3], [-1, 4]], - alias: 'seriesFixedscale', - }); - data[1].yaxis = 2; - }); - - it('should apply axis transform, autoscaling (if necessary) and ticks', function() { - var axisAutoscale = ctx.plotOptions.yaxes[0]; - expect(axisAutoscale.transform(100)).to.be(2); - expect(axisAutoscale.inverseTransform(-3)).to.within(0.00099999999, 0.00100000001); - expect(axisAutoscale.min).to.within(0.00099999999, 0.00100000001); - expect(axisAutoscale.max).to.be(10000); - expect(axisAutoscale.ticks.length).to.within(7, 8); - expect(axisAutoscale.ticks[0]).to.within(0.00099999999, 0.00100000001); - if (axisAutoscale.ticks.length === 7) { - expect(axisAutoscale.ticks[axisAutoscale.ticks.length - 1]).to.within(999.9999, 1000.0001); - } else { - expect(axisAutoscale.ticks[axisAutoscale.ticks.length - 1]).to.be(10000); - } - - var axisFixedscale = ctx.plotOptions.yaxes[1]; - expect(axisFixedscale.min).to.be(0.05); - expect(axisFixedscale.max).to.be(1500); - expect(axisFixedscale.ticks.length).to.be(5); - expect(axisFixedscale.ticks[0]).to.be(0.1); - expect(axisFixedscale.ticks[4]).to.be(1000); - }); - }); - - graphScenario('when logBase is log 10 and data points contain only zeroes', function(ctx) { - ctx.setup(function(ctrl, data) { - ctrl.panel.yaxes[0].logBase = 10; - data[0] = new TimeSeries({ - datapoints: [[0, 1], [0, 2], [0, 3], [0, 4]], - alias: 'seriesAutoscale', - }); - data[0].yaxis = 1; - }); - - it('should not set min and max and should create some fake ticks', function() { - var axisAutoscale = ctx.plotOptions.yaxes[0]; - expect(axisAutoscale.transform(100)).to.be(2); - expect(axisAutoscale.inverseTransform(-3)).to.within(0.00099999999, 0.00100000001); - expect(axisAutoscale.min).to.be(undefined); - expect(axisAutoscale.max).to.be(undefined); - expect(axisAutoscale.ticks.length).to.be(2); - expect(axisAutoscale.ticks[0]).to.be(1); - expect(axisAutoscale.ticks[1]).to.be(2); - }); - }); - - // y-min set 0 is a special case for log scale, - // this approximates it by setting min to 0.1 - graphScenario('when logBase is log 10 and y-min is set to 0 and auto min is > 0.1', function(ctx) { - ctx.setup(function(ctrl, data) { - ctrl.panel.yaxes[0].logBase = 10; - ctrl.panel.yaxes[0].min = '0'; - data[0] = new TimeSeries({ - datapoints: [[2000, 1], [4, 2], [500, 3], [3000, 4]], - alias: 'seriesAutoscale', - }); - data[0].yaxis = 1; - }); - - it('should set min to 0.1 and add a tick for 0.1', function() { - var axisAutoscale = ctx.plotOptions.yaxes[0]; - expect(axisAutoscale.transform(100)).to.be(2); - expect(axisAutoscale.inverseTransform(-3)).to.within(0.00099999999, 0.00100000001); - expect(axisAutoscale.min).to.be(0.1); - expect(axisAutoscale.max).to.be(10000); - expect(axisAutoscale.ticks.length).to.be(6); - expect(axisAutoscale.ticks[0]).to.be(0.1); - expect(axisAutoscale.ticks[5]).to.be(10000); - }); - }); - - graphScenario('when logBase is log 2 and y-min is set to 0 and num of ticks exceeds max', function(ctx) { - ctx.setup(function(ctrl, data) { - const heightForApprox5Ticks = 125; - ctrl.height = heightForApprox5Ticks; - ctrl.panel.yaxes[0].logBase = 2; - ctrl.panel.yaxes[0].min = '0'; - data[0] = new TimeSeries({ - datapoints: [[2000, 1], [4, 2], [500, 3], [3000, 4], [10000, 5], [100000, 6]], - alias: 'seriesAutoscale', - }); - data[0].yaxis = 1; - }); - - it('should regenerate ticks so that if fits on the y-axis', function() { - var axisAutoscale = ctx.plotOptions.yaxes[0]; - expect(axisAutoscale.min).to.be(0.1); - expect(axisAutoscale.ticks.length).to.be(8); - expect(axisAutoscale.ticks[0]).to.be(0.1); - expect(axisAutoscale.ticks[7]).to.be(262144); - expect(axisAutoscale.max).to.be(262144); - }); - - it('should set axis max to be max tick value', function() { - expect(ctx.plotOptions.yaxes[0].max).to.be(262144); - }); - }); - - graphScenario('dashed lines options', function(ctx) { - ctx.setup(function(ctrl) { - ctrl.panel.lines = true; - ctrl.panel.linewidth = 2; - ctrl.panel.dashes = true; - }); - - it('should configure dashed plot with correct options', function() { - expect(ctx.plotOptions.series.lines.show).to.be(true); - expect(ctx.plotOptions.series.dashes.lineWidth).to.be(2); - expect(ctx.plotOptions.series.dashes.show).to.be(true); - }); - }); - - graphScenario('should use timeStep for barWidth', function(ctx) { - ctx.setup(function(ctrl, data) { - ctrl.panel.bars = true; - data[0] = new TimeSeries({ - datapoints: [[1, 10], [2, 20]], - alias: 'series1', - }); - }); - - it('should set barWidth', function() { - expect(ctx.plotOptions.series.bars.barWidth).to.be(1 / 1.5); - }); - }); - - graphScenario('series option overrides, fill & points', function(ctx) { - ctx.setup(function(ctrl, data) { - ctrl.panel.lines = true; - ctrl.panel.fill = 5; - data[0].zindex = 10; - data[1].alias = 'test'; - data[1].lines = { fill: 0.001 }; - data[1].points = { show: true }; - }); - - it('should match second series and fill zero, and enable points', function() { - expect(ctx.plotOptions.series.lines.fill).to.be(0.5); - expect(ctx.plotData[1].lines.fill).to.be(0.001); - expect(ctx.plotData[1].points.show).to.be(true); - }); - }); - - graphScenario('should order series order according to zindex', function(ctx) { - ctx.setup(function(ctrl, data) { - data[1].zindex = 1; - data[0].zindex = 10; - }); - - it('should move zindex 2 last', function() { - expect(ctx.plotData[0].alias).to.be('series2'); - expect(ctx.plotData[1].alias).to.be('series1'); - }); - }); - - graphScenario('when series is hidden', function(ctx) { - ctx.setup(function(ctrl) { - ctrl.hiddenSeries = { series2: true }; - }); - - it('should remove datapoints and disable stack', function() { - expect(ctx.plotData[0].alias).to.be('series1'); - expect(ctx.plotData[1].data.length).to.be(0); - expect(ctx.plotData[1].stack).to.be(false); - }); - }); - - graphScenario('when stack and percent', function(ctx) { - ctx.setup(function(ctrl) { - ctrl.panel.percentage = true; - ctrl.panel.stack = true; - }); - - it('should show percentage', function() { - var axis = ctx.plotOptions.yaxes[0]; - expect(axis.tickFormatter(100, axis)).to.be('100%'); - }); - }); - - graphScenario( - 'when panel too narrow to show x-axis dates in same granularity as wide panels', - function(ctx) { - describe('and the range is less than 24 hours', function() { - ctx.setup(function(ctrl) { - ctrl.range.from = moment([2015, 1, 1, 10]); - ctrl.range.to = moment([2015, 1, 1, 22]); - }); - - it('should format dates as hours minutes', function() { - var axis = ctx.plotOptions.xaxis; - expect(axis.timeformat).to.be('%H:%M'); - }); - }); - - describe('and the range is less than one year', function() { - ctx.setup(function(scope) { - scope.range.from = moment([2015, 1, 1]); - scope.range.to = moment([2015, 11, 20]); - }); - - it('should format dates as month days', function() { - var axis = ctx.plotOptions.xaxis; - expect(axis.timeformat).to.be('%m/%d'); - }); - }); - }, - 10 - ); - - graphScenario('when graph is histogram, and enable stack', function(ctx) { - ctx.setup(function(ctrl, data) { - ctrl.panel.xaxis.mode = 'histogram'; - ctrl.panel.stack = true; - ctrl.hiddenSeries = {}; - data[0] = new TimeSeries({ - datapoints: [[100, 1], [100, 2], [200, 3], [300, 4]], - alias: 'series1', - }); - data[1] = new TimeSeries({ - datapoints: [[100, 1], [100, 2], [200, 3], [300, 4]], - alias: 'series2', - }); - }); - - it('should calculate correct histogram', function() { - expect(ctx.plotData[0].data[0][0]).to.be(100); - expect(ctx.plotData[0].data[0][1]).to.be(2); - expect(ctx.plotData[1].data[0][0]).to.be(100); - expect(ctx.plotData[1].data[0][1]).to.be(2); - }); - }); - - graphScenario('when graph is histogram, and some series are hidden', function(ctx) { - ctx.setup(function(ctrl, data) { - ctrl.panel.xaxis.mode = 'histogram'; - ctrl.panel.stack = false; - ctrl.hiddenSeries = { series2: true }; - data[0] = new TimeSeries({ - datapoints: [[100, 1], [100, 2], [200, 3], [300, 4]], - alias: 'series1', - }); - data[1] = new TimeSeries({ - datapoints: [[100, 1], [100, 2], [200, 3], [300, 4]], - alias: 'series2', - }); - }); - - it('should calculate correct histogram', function() { - expect(ctx.plotData[0].data[0][0]).to.be(100); - expect(ctx.plotData[0].data[0][1]).to.be(2); - }); - }); -}); From 35694a76efbff0ebff57c1af7c6ecbc0a8365fc2 Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Wed, 1 Aug 2018 17:11:29 +0200 Subject: [PATCH 40/99] Class to function. Half tests passing --- .../app/features/dashboard/shareModalCtrl.ts | 180 +++++++++--------- .../dashboard/specs/share_modal_ctrl.jest.ts | 154 +++++++++++++++ 2 files changed, 243 insertions(+), 91 deletions(-) create mode 100644 public/app/features/dashboard/specs/share_modal_ctrl.jest.ts diff --git a/public/app/features/dashboard/shareModalCtrl.ts b/public/app/features/dashboard/shareModalCtrl.ts index 985c20f03b2..c32c2a79190 100644 --- a/public/app/features/dashboard/shareModalCtrl.ts +++ b/public/app/features/dashboard/shareModalCtrl.ts @@ -2,120 +2,118 @@ import angular from 'angular'; import config from 'app/core/config'; import moment from 'moment'; -export class ShareModalCtrl { - /** @ngInject */ - constructor($scope, $rootScope, $location, $timeout, timeSrv, templateSrv, linkSrv) { - $scope.options = { - forCurrent: true, - includeTemplateVars: true, - theme: 'current', - }; - $scope.editor = { index: $scope.tabIndex || 0 }; +/** @ngInject */ +export function ShareModalCtrl($scope, $rootScope, $location, $timeout, timeSrv, templateSrv, linkSrv) { + $scope.options = { + forCurrent: true, + includeTemplateVars: true, + theme: 'current', + }; + $scope.editor = { index: $scope.tabIndex || 0 }; - $scope.init = function() { - $scope.modeSharePanel = $scope.panel ? true : false; + $scope.init = function() { + $scope.modeSharePanel = $scope.panel ? true : false; - $scope.tabs = [{ title: 'Link', src: 'shareLink.html' }]; + $scope.tabs = [{ title: 'Link', src: 'shareLink.html' }]; - if ($scope.modeSharePanel) { - $scope.modalTitle = 'Share Panel'; - $scope.tabs.push({ title: 'Embed', src: 'shareEmbed.html' }); - } else { - $scope.modalTitle = 'Share'; - } + if ($scope.modeSharePanel) { + $scope.modalTitle = 'Share Panel'; + $scope.tabs.push({ title: 'Embed', src: 'shareEmbed.html' }); + } else { + $scope.modalTitle = 'Share'; + } - if (!$scope.dashboard.meta.isSnapshot) { - $scope.tabs.push({ title: 'Snapshot', src: 'shareSnapshot.html' }); - } + if (!$scope.dashboard.meta.isSnapshot) { + $scope.tabs.push({ title: 'Snapshot', src: 'shareSnapshot.html' }); + } - if (!$scope.dashboard.meta.isSnapshot && !$scope.modeSharePanel) { - $scope.tabs.push({ title: 'Export', src: 'shareExport.html' }); - } + if (!$scope.dashboard.meta.isSnapshot && !$scope.modeSharePanel) { + $scope.tabs.push({ title: 'Export', src: 'shareExport.html' }); + } - $scope.buildUrl(); - }; + $scope.buildUrl(); + }; - $scope.buildUrl = function() { - var baseUrl = $location.absUrl(); - var queryStart = baseUrl.indexOf('?'); + $scope.buildUrl = function() { + var baseUrl = $location.absUrl(); + var queryStart = baseUrl.indexOf('?'); - if (queryStart !== -1) { - baseUrl = baseUrl.substring(0, queryStart); - } + if (queryStart !== -1) { + baseUrl = baseUrl.substring(0, queryStart); + } - var params = angular.copy($location.search()); + var params = angular.copy($location.search()); - var range = timeSrv.timeRange(); - params.from = range.from.valueOf(); - params.to = range.to.valueOf(); - params.orgId = config.bootData.user.orgId; + var range = timeSrv.timeRange(); + params.from = range.from.valueOf(); + params.to = range.to.valueOf(); + params.orgId = config.bootData.user.orgId; - if ($scope.options.includeTemplateVars) { - templateSrv.fillVariableValuesForUrl(params); - } + if ($scope.options.includeTemplateVars) { + templateSrv.fillVariableValuesForUrl(params); + } - if (!$scope.options.forCurrent) { - delete params.from; - delete params.to; - } + if (!$scope.options.forCurrent) { + delete params.from; + delete params.to; + } - if ($scope.options.theme !== 'current') { - params.theme = $scope.options.theme; - } + if ($scope.options.theme !== 'current') { + params.theme = $scope.options.theme; + } - if ($scope.modeSharePanel) { - params.panelId = $scope.panel.id; - params.fullscreen = true; - } else { - delete params.panelId; - delete params.fullscreen; - } - - $scope.shareUrl = linkSrv.addParamsToUrl(baseUrl, params); - - var soloUrl = baseUrl.replace(config.appSubUrl + '/dashboard/', config.appSubUrl + '/dashboard-solo/'); - soloUrl = soloUrl.replace(config.appSubUrl + '/d/', config.appSubUrl + '/d-solo/'); + if ($scope.modeSharePanel) { + params.panelId = $scope.panel.id; + params.fullscreen = true; + } else { + delete params.panelId; delete params.fullscreen; - delete params.edit; - soloUrl = linkSrv.addParamsToUrl(soloUrl, params); + } - $scope.iframeHtml = ''; + $scope.shareUrl = linkSrv.addParamsToUrl(baseUrl, params); - $scope.imageUrl = soloUrl.replace( - config.appSubUrl + '/dashboard-solo/', - config.appSubUrl + '/render/dashboard-solo/' - ); - $scope.imageUrl = $scope.imageUrl.replace(config.appSubUrl + '/d-solo/', config.appSubUrl + '/render/d-solo/'); - $scope.imageUrl += '&width=1000&height=500' + $scope.getLocalTimeZone(); - }; + var soloUrl = baseUrl.replace(config.appSubUrl + '/dashboard/', config.appSubUrl + '/dashboard-solo/'); + soloUrl = soloUrl.replace(config.appSubUrl + '/d/', config.appSubUrl + '/d-solo/'); + delete params.fullscreen; + delete params.edit; + soloUrl = linkSrv.addParamsToUrl(soloUrl, params); - // This function will try to return the proper full name of the local timezone - // Chrome does not handle the timezone offset (but phantomjs does) - $scope.getLocalTimeZone = function() { - let utcOffset = '&tz=UTC' + encodeURIComponent(moment().format('Z')); + $scope.iframeHtml = ''; - // Older browser does not the internationalization API - if (!(window).Intl) { - return utcOffset; - } + $scope.imageUrl = soloUrl.replace( + config.appSubUrl + '/dashboard-solo/', + config.appSubUrl + '/render/dashboard-solo/' + ); + $scope.imageUrl = $scope.imageUrl.replace(config.appSubUrl + '/d-solo/', config.appSubUrl + '/render/d-solo/'); + $scope.imageUrl += '&width=1000&height=500' + $scope.getLocalTimeZone(); + }; - const dateFormat = (window).Intl.DateTimeFormat(); - if (!dateFormat.resolvedOptions) { - return utcOffset; - } + // This function will try to return the proper full name of the local timezone + // Chrome does not handle the timezone offset (but phantomjs does) + $scope.getLocalTimeZone = function() { + let utcOffset = '&tz=UTC' + encodeURIComponent(moment().format('Z')); - const options = dateFormat.resolvedOptions(); - if (!options.timeZone) { - return utcOffset; - } + // Older browser does not the internationalization API + if (!(window).Intl) { + return utcOffset; + } - return '&tz=' + encodeURIComponent(options.timeZone); - }; + const dateFormat = (window).Intl.DateTimeFormat(); + if (!dateFormat.resolvedOptions) { + return utcOffset; + } - $scope.getShareUrl = function() { - return $scope.shareUrl; - }; - } + const options = dateFormat.resolvedOptions(); + if (!options.timeZone) { + return utcOffset; + } + + return '&tz=' + encodeURIComponent(options.timeZone); + }; + + $scope.getShareUrl = function() { + return $scope.shareUrl; + }; } angular.module('grafana.controllers').controller('ShareModalCtrl', ShareModalCtrl); diff --git a/public/app/features/dashboard/specs/share_modal_ctrl.jest.ts b/public/app/features/dashboard/specs/share_modal_ctrl.jest.ts new file mode 100644 index 00000000000..47b2a2189cd --- /dev/null +++ b/public/app/features/dashboard/specs/share_modal_ctrl.jest.ts @@ -0,0 +1,154 @@ +import '../shareModalCtrl'; +import { ShareModalCtrl } from '../shareModalCtrl'; +import config from 'app/core/config'; +import { LinkSrv } from 'app/features/panellinks/link_srv'; + +describe('ShareModalCtrl', () => { + var ctx = { + timeSrv: { + timeRange: () => { + return { from: new Date(1000), to: new Date(2000) }; + }, + }, + $location: { + absUrl: () => 'http://server/#!/test', + search: () => { + return { from: '', to: '' }; + }, + }, + scope: { + dashboard: { + meta: { + isSnapshot: true, + }, + }, + }, + templateSrv: { + fillVariableValuesForUrl: () => {}, + }, + }; + // function setTime(range) { + // ctx.timeSrv.timeRange = () => range; + // } + + beforeEach(() => { + config.bootData = { + user: { + orgId: 1, + }, + }; + }); + + // setTime({ from: new Date(1000), to: new Date(2000) }); + + // beforeEach(angularMocks.module('grafana.controllers')); + // beforeEach(angularMocks.module('grafana.services')); + // beforeEach( + // angularMocks.module(function($compileProvider) { + // $compileProvider.preAssignBindingsEnabled(true); + // }) + // ); + + // beforeEach(ctx.providePhase()); + + // beforeEach(ctx.createControllerPhase('ShareModalCtrl')); + beforeEach(() => { + ctx.ctrl = new ShareModalCtrl( + ctx.scope, + {}, + ctx.$location, + {}, + ctx.timeSrv, + ctx.templateSrv, + new LinkSrv({}, ctx.stimeSrv) + ); + }); + + describe('shareUrl with current time range and panel', () => { + it('should generate share url absolute time', () => { + // ctx.$location.path('/test'); + ctx.scope.panel = { id: 22 }; + + ctx.scope.init(); + expect(ctx.scope.shareUrl).toBe('http://server/#!/test?from=1000&to=2000&orgId=1&panelId=22&fullscreen'); + }); + + it('should generate render url', () => { + ctx.$location.absUrl = () => 'http://dashboards.grafana.com/d/abcdefghi/my-dash'; + + ctx.scope.panel = { id: 22 }; + + ctx.scope.init(); + var base = 'http://dashboards.grafana.com/render/d-solo/abcdefghi/my-dash'; + var params = '?from=1000&to=2000&orgId=1&panelId=22&width=1000&height=500&tz=UTC'; + expect(ctx.scope.imageUrl).toContain(base + params); + }); + + it('should generate render url for scripted dashboard', () => { + ctx.$location.absUrl = () => 'http://dashboards.grafana.com/dashboard/script/my-dash.js'; + + ctx.scope.panel = { id: 22 }; + + ctx.scope.init(); + var base = 'http://dashboards.grafana.com/render/dashboard-solo/script/my-dash.js'; + var params = '?from=1000&to=2000&orgId=1&panelId=22&width=1000&height=500&tz=UTC'; + expect(ctx.scope.imageUrl).toContain(base + params); + }); + + it('should remove panel id when no panel in scope', () => { + // ctx.$location.path('/test'); + ctx.$location.absUrl = () => 'http://server/#!/test'; + ctx.scope.options.forCurrent = true; + ctx.scope.panel = null; + + ctx.scope.init(); + expect(ctx.scope.shareUrl).toBe('http://server/#!/test?from=1000&to=2000&orgId=1'); + }); + + it('should add theme when specified', () => { + // ctx.$location.path('/test'); + ctx.scope.options.theme = 'light'; + ctx.scope.panel = null; + + ctx.scope.init(); + expect(ctx.scope.shareUrl).toBe('http://server/#!/test?from=1000&to=2000&orgId=1&theme=light'); + }); + + it('should remove fullscreen from image url when is first param in querystring and modeSharePanel is true', () => { + ctx.$location.absUrl = () => 'http://server/#!/test?fullscreen&edit'; + ctx.scope.modeSharePanel = true; + ctx.scope.panel = { id: 1 }; + + ctx.scope.buildUrl(); + + expect(ctx.scope.shareUrl).toContain('?fullscreen&edit&from=1000&to=2000&orgId=1&panelId=1'); + expect(ctx.scope.imageUrl).toContain('?from=1000&to=2000&orgId=1&panelId=1&width=1000&height=500&tz=UTC'); + }); + + it('should remove edit from image url when is first param in querystring and modeSharePanel is true', () => { + ctx.$location.absUrl = () => 'http://server/#!/test?edit&fullscreen'; + ctx.scope.modeSharePanel = true; + ctx.scope.panel = { id: 1 }; + + ctx.scope.buildUrl(); + + expect(ctx.scope.shareUrl).toContain('?edit&fullscreen&from=1000&to=2000&orgId=1&panelId=1'); + expect(ctx.scope.imageUrl).toContain('?from=1000&to=2000&orgId=1&panelId=1&width=1000&height=500&tz=UTC'); + }); + + it('should include template variables in url', () => { + ctx.$location.absUrl = () => 'http://server/#!/test'; + ctx.scope.options.includeTemplateVars = true; + + ctx.templateSrv.fillVariableValuesForUrl = function(params) { + params['var-app'] = 'mupp'; + params['var-server'] = 'srv-01'; + }; + + ctx.scope.buildUrl(); + expect(ctx.scope.shareUrl).toContain( + 'http://server/#!/test?from=1000&to=2000&orgId=1&var-app=mupp&var-server=srv-01' + ); + }); + }); +}); From 38422ce8a4128da4c4ff7370d5a3e7becaf0e588 Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Fri, 3 Aug 2018 14:37:31 +0200 Subject: [PATCH 41/99] All tests passing --- .../dashboard/specs/share_modal_ctrl.jest.ts | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/public/app/features/dashboard/specs/share_modal_ctrl.jest.ts b/public/app/features/dashboard/specs/share_modal_ctrl.jest.ts index 47b2a2189cd..31f09a6c08a 100644 --- a/public/app/features/dashboard/specs/share_modal_ctrl.jest.ts +++ b/public/app/features/dashboard/specs/share_modal_ctrl.jest.ts @@ -27,6 +27,14 @@ describe('ShareModalCtrl', () => { fillVariableValuesForUrl: () => {}, }, }; + + (window).Intl.DateTimeFormat = () => { + return { + resolvedOptions: () => { + return { timeZone: 'UTC' }; + }, + }; + }; // function setTime(range) { // ctx.timeSrv.timeRange = () => range; // } @@ -48,10 +56,6 @@ describe('ShareModalCtrl', () => { // $compileProvider.preAssignBindingsEnabled(true); // }) // ); - - // beforeEach(ctx.providePhase()); - - // beforeEach(ctx.createControllerPhase('ShareModalCtrl')); beforeEach(() => { ctx.ctrl = new ShareModalCtrl( ctx.scope, @@ -115,6 +119,9 @@ describe('ShareModalCtrl', () => { }); it('should remove fullscreen from image url when is first param in querystring and modeSharePanel is true', () => { + ctx.$location.search = () => { + return { fullscreen: true, edit: true }; + }; ctx.$location.absUrl = () => 'http://server/#!/test?fullscreen&edit'; ctx.scope.modeSharePanel = true; ctx.scope.panel = { id: 1 }; @@ -126,6 +133,9 @@ describe('ShareModalCtrl', () => { }); it('should remove edit from image url when is first param in querystring and modeSharePanel is true', () => { + ctx.$location.search = () => { + return { edit: true, fullscreen: true }; + }; ctx.$location.absUrl = () => 'http://server/#!/test?edit&fullscreen'; ctx.scope.modeSharePanel = true; ctx.scope.panel = { id: 1 }; @@ -137,6 +147,9 @@ describe('ShareModalCtrl', () => { }); it('should include template variables in url', () => { + ctx.$location.search = () => { + return {}; + }; ctx.$location.absUrl = () => 'http://server/#!/test'; ctx.scope.options.includeTemplateVars = true; From be7b663369386689a62801b06bfaaafabaff8e52 Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Fri, 3 Aug 2018 14:40:44 +0200 Subject: [PATCH 42/99] Cleanup --- .../dashboard/specs/share_modal_ctrl.jest.ts | 16 --- .../dashboard/specs/share_modal_ctrl_specs.ts | 122 ------------------ 2 files changed, 138 deletions(-) delete mode 100644 public/app/features/dashboard/specs/share_modal_ctrl_specs.ts diff --git a/public/app/features/dashboard/specs/share_modal_ctrl.jest.ts b/public/app/features/dashboard/specs/share_modal_ctrl.jest.ts index 31f09a6c08a..e5b5340aca5 100644 --- a/public/app/features/dashboard/specs/share_modal_ctrl.jest.ts +++ b/public/app/features/dashboard/specs/share_modal_ctrl.jest.ts @@ -35,9 +35,6 @@ describe('ShareModalCtrl', () => { }, }; }; - // function setTime(range) { - // ctx.timeSrv.timeRange = () => range; - // } beforeEach(() => { config.bootData = { @@ -45,18 +42,7 @@ describe('ShareModalCtrl', () => { orgId: 1, }, }; - }); - // setTime({ from: new Date(1000), to: new Date(2000) }); - - // beforeEach(angularMocks.module('grafana.controllers')); - // beforeEach(angularMocks.module('grafana.services')); - // beforeEach( - // angularMocks.module(function($compileProvider) { - // $compileProvider.preAssignBindingsEnabled(true); - // }) - // ); - beforeEach(() => { ctx.ctrl = new ShareModalCtrl( ctx.scope, {}, @@ -100,7 +86,6 @@ describe('ShareModalCtrl', () => { }); it('should remove panel id when no panel in scope', () => { - // ctx.$location.path('/test'); ctx.$location.absUrl = () => 'http://server/#!/test'; ctx.scope.options.forCurrent = true; ctx.scope.panel = null; @@ -110,7 +95,6 @@ describe('ShareModalCtrl', () => { }); it('should add theme when specified', () => { - // ctx.$location.path('/test'); ctx.scope.options.theme = 'light'; ctx.scope.panel = null; diff --git a/public/app/features/dashboard/specs/share_modal_ctrl_specs.ts b/public/app/features/dashboard/specs/share_modal_ctrl_specs.ts deleted file mode 100644 index fc70a54a41c..00000000000 --- a/public/app/features/dashboard/specs/share_modal_ctrl_specs.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { describe, beforeEach, it, expect, sinon, angularMocks } from 'test/lib/common'; -import helpers from 'test/specs/helpers'; -import '../shareModalCtrl'; -import config from 'app/core/config'; -import 'app/features/panellinks/link_srv'; - -describe('ShareModalCtrl', function() { - var ctx = new helpers.ControllerTestContext(); - - function setTime(range) { - ctx.timeSrv.timeRange = sinon.stub().returns(range); - } - - beforeEach(function() { - config.bootData = { - user: { - orgId: 1, - }, - }; - }); - - setTime({ from: new Date(1000), to: new Date(2000) }); - - beforeEach(angularMocks.module('grafana.controllers')); - beforeEach(angularMocks.module('grafana.services')); - beforeEach( - angularMocks.module(function($compileProvider) { - $compileProvider.preAssignBindingsEnabled(true); - }) - ); - - beforeEach(ctx.providePhase()); - - beforeEach(ctx.createControllerPhase('ShareModalCtrl')); - - describe('shareUrl with current time range and panel', function() { - it('should generate share url absolute time', function() { - ctx.$location.path('/test'); - ctx.scope.panel = { id: 22 }; - - ctx.scope.init(); - expect(ctx.scope.shareUrl).to.be('http://server/#!/test?from=1000&to=2000&orgId=1&panelId=22&fullscreen'); - }); - - it('should generate render url', function() { - ctx.$location.$$absUrl = 'http://dashboards.grafana.com/d/abcdefghi/my-dash'; - - ctx.scope.panel = { id: 22 }; - - ctx.scope.init(); - var base = 'http://dashboards.grafana.com/render/d-solo/abcdefghi/my-dash'; - var params = '?from=1000&to=2000&orgId=1&panelId=22&width=1000&height=500&tz=UTC'; - expect(ctx.scope.imageUrl).to.contain(base + params); - }); - - it('should generate render url for scripted dashboard', function() { - ctx.$location.$$absUrl = 'http://dashboards.grafana.com/dashboard/script/my-dash.js'; - - ctx.scope.panel = { id: 22 }; - - ctx.scope.init(); - var base = 'http://dashboards.grafana.com/render/dashboard-solo/script/my-dash.js'; - var params = '?from=1000&to=2000&orgId=1&panelId=22&width=1000&height=500&tz=UTC'; - expect(ctx.scope.imageUrl).to.contain(base + params); - }); - - it('should remove panel id when no panel in scope', function() { - ctx.$location.path('/test'); - ctx.scope.options.forCurrent = true; - ctx.scope.panel = null; - - ctx.scope.init(); - expect(ctx.scope.shareUrl).to.be('http://server/#!/test?from=1000&to=2000&orgId=1'); - }); - - it('should add theme when specified', function() { - ctx.$location.path('/test'); - ctx.scope.options.theme = 'light'; - ctx.scope.panel = null; - - ctx.scope.init(); - expect(ctx.scope.shareUrl).to.be('http://server/#!/test?from=1000&to=2000&orgId=1&theme=light'); - }); - - it('should remove fullscreen from image url when is first param in querystring and modeSharePanel is true', function() { - ctx.$location.url('/test?fullscreen&edit'); - ctx.scope.modeSharePanel = true; - ctx.scope.panel = { id: 1 }; - - ctx.scope.buildUrl(); - - expect(ctx.scope.shareUrl).to.contain('?fullscreen&edit&from=1000&to=2000&orgId=1&panelId=1'); - expect(ctx.scope.imageUrl).to.contain('?from=1000&to=2000&orgId=1&panelId=1&width=1000&height=500&tz=UTC'); - }); - - it('should remove edit from image url when is first param in querystring and modeSharePanel is true', function() { - ctx.$location.url('/test?edit&fullscreen'); - ctx.scope.modeSharePanel = true; - ctx.scope.panel = { id: 1 }; - - ctx.scope.buildUrl(); - - expect(ctx.scope.shareUrl).to.contain('?edit&fullscreen&from=1000&to=2000&orgId=1&panelId=1'); - expect(ctx.scope.imageUrl).to.contain('?from=1000&to=2000&orgId=1&panelId=1&width=1000&height=500&tz=UTC'); - }); - - it('should include template variables in url', function() { - ctx.$location.path('/test'); - ctx.scope.options.includeTemplateVars = true; - - ctx.templateSrv.fillVariableValuesForUrl = function(params) { - params['var-app'] = 'mupp'; - params['var-server'] = 'srv-01'; - }; - - ctx.scope.buildUrl(); - expect(ctx.scope.shareUrl).to.be( - 'http://server/#!/test?from=1000&to=2000&orgId=1&var-app=mupp&var-server=srv-01' - ); - }); - }); -}); From fa6d25af72f8191dc67f2948c6748def69b1a8c1 Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Fri, 3 Aug 2018 14:44:40 +0200 Subject: [PATCH 43/99] Remove comment --- public/app/features/dashboard/specs/share_modal_ctrl.jest.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/public/app/features/dashboard/specs/share_modal_ctrl.jest.ts b/public/app/features/dashboard/specs/share_modal_ctrl.jest.ts index e5b5340aca5..35261256566 100644 --- a/public/app/features/dashboard/specs/share_modal_ctrl.jest.ts +++ b/public/app/features/dashboard/specs/share_modal_ctrl.jest.ts @@ -56,7 +56,6 @@ describe('ShareModalCtrl', () => { describe('shareUrl with current time range and panel', () => { it('should generate share url absolute time', () => { - // ctx.$location.path('/test'); ctx.scope.panel = { id: 22 }; ctx.scope.init(); From 2459b177f914a12438424cf068638b9ce107d115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 13 Aug 2018 18:09:01 +0200 Subject: [PATCH 44/99] change: Set User-Agent to Grafana/%Version% Proxied-DS-Request %DS-Type% in all proxied ds requests --- pkg/api/pluginproxy/ds_proxy.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/api/pluginproxy/ds_proxy.go b/pkg/api/pluginproxy/ds_proxy.go index b420398f9a9..74ad4e226fd 100644 --- a/pkg/api/pluginproxy/ds_proxy.go +++ b/pkg/api/pluginproxy/ds_proxy.go @@ -203,6 +203,7 @@ func (proxy *DataSourceProxy) getDirector() func(req *http.Request) { req.Header.Del("X-Forwarded-Host") req.Header.Del("X-Forwarded-Port") req.Header.Del("X-Forwarded-Proto") + req.Header.Set("User-Agent", fmt.Sprintf("Grafana/%s Proxied-DS-Request %s", setting.BuildVersion, proxy.ds.Type)) // set X-Forwarded-For header if req.RemoteAddr != "" { From 3552a4cb86151c91ecbf0b2d3265761b276dbaa6 Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Tue, 14 Aug 2018 08:34:20 +0200 Subject: [PATCH 45/99] refactor timescaledb handling in MacroEngine --- pkg/tsdb/postgres/macros.go | 15 +++++++++------ pkg/tsdb/postgres/macros_test.go | 14 ++++++++------ pkg/tsdb/postgres/postgres.go | 2 +- pkg/tsdb/postgres/postgres_test.go | 22 ---------------------- 4 files changed, 18 insertions(+), 35 deletions(-) diff --git a/pkg/tsdb/postgres/macros.go b/pkg/tsdb/postgres/macros.go index d9f97e9262c..81b0da9fbce 100644 --- a/pkg/tsdb/postgres/macros.go +++ b/pkg/tsdb/postgres/macros.go @@ -7,6 +7,7 @@ import ( "strings" "time" + "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/tsdb" ) @@ -15,12 +16,15 @@ const rsIdentifier = `([_a-zA-Z0-9]+)` const sExpr = `\$` + rsIdentifier + `\(([^\)]*)\)` type postgresMacroEngine struct { - timeRange *tsdb.TimeRange - query *tsdb.Query + timeRange *tsdb.TimeRange + query *tsdb.Query + timescaledb bool } -func newPostgresMacroEngine() tsdb.SqlMacroEngine { - return &postgresMacroEngine{} +func newPostgresMacroEngine(datasource *models.DataSource) tsdb.SqlMacroEngine { + engine := &postgresMacroEngine{} + engine.timescaledb = datasource.JsonData.Get("timescaledb").MustBool(false) + return engine } func (m *postgresMacroEngine) Interpolate(query *tsdb.Query, timeRange *tsdb.TimeRange, sql string) (string, error) { @@ -131,7 +135,7 @@ func (m *postgresMacroEngine) evaluateMacro(name string, args []string) (string, } } - if m.query.DataSource.JsonData.Get("timescaledb").MustBool() { + if m.timescaledb { return fmt.Sprintf("time_bucket('%vs',%s)", interval.Seconds(), args[0]), nil } else { return fmt.Sprintf("floor(extract(epoch from %s)/%v)*%v", args[0], interval.Seconds(), interval.Seconds()), nil @@ -142,7 +146,6 @@ func (m *postgresMacroEngine) evaluateMacro(name string, args []string) (string, return tg + " AS \"time\"", err } return "", err - case "__unixEpochFilter": if len(args) == 0 { return "", fmt.Errorf("missing time column argument for macro %v", name) diff --git a/pkg/tsdb/postgres/macros_test.go b/pkg/tsdb/postgres/macros_test.go index 449331224c2..fe95535fe0c 100644 --- a/pkg/tsdb/postgres/macros_test.go +++ b/pkg/tsdb/postgres/macros_test.go @@ -14,10 +14,12 @@ import ( func TestMacroEngine(t *testing.T) { Convey("MacroEngine", t, func() { - engine := newPostgresMacroEngine() - query := &tsdb.Query{DataSource: &models.DataSource{JsonData: simplejson.New()}} - queryTS := &tsdb.Query{DataSource: &models.DataSource{JsonData: simplejson.New()}} - queryTS.DataSource.JsonData.Set("timescaledb", true) + datasource := &models.DataSource{JsonData: simplejson.New()} + engine := newPostgresMacroEngine(datasource) + datasourceTS := &models.DataSource{JsonData: simplejson.New()} + datasourceTS.JsonData.Set("timescaledb", true) + engineTS := newPostgresMacroEngine(datasourceTS) + query := &tsdb.Query{} Convey("Given a time range between 2018-04-12 00:00 and 2018-04-12 00:05", func() { from := time.Date(2018, 4, 12, 18, 0, 0, 0, time.UTC) @@ -89,7 +91,7 @@ func TestMacroEngine(t *testing.T) { Convey("interpolate __timeGroup function with TimescaleDB enabled", func() { - sql, err := engine.Interpolate(queryTS, timeRange, "GROUP BY $__timeGroup(time_column,'5m')") + sql, err := engineTS.Interpolate(query, timeRange, "GROUP BY $__timeGroup(time_column,'5m')") So(err, ShouldBeNil) So(sql, ShouldEqual, "GROUP BY time_bucket('300s',time_column)") @@ -97,7 +99,7 @@ func TestMacroEngine(t *testing.T) { Convey("interpolate __timeGroup function with spaces between args and TimescaleDB enabled", func() { - sql, err := engine.Interpolate(queryTS, timeRange, "GROUP BY $__timeGroup(time_column , '5m')") + sql, err := engineTS.Interpolate(query, timeRange, "GROUP BY $__timeGroup(time_column , '5m')") So(err, ShouldBeNil) So(sql, ShouldEqual, "GROUP BY time_bucket('300s',time_column)") diff --git a/pkg/tsdb/postgres/postgres.go b/pkg/tsdb/postgres/postgres.go index b9f333db127..46d766f9a11 100644 --- a/pkg/tsdb/postgres/postgres.go +++ b/pkg/tsdb/postgres/postgres.go @@ -32,7 +32,7 @@ func newPostgresQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndp log: logger, } - return tsdb.NewSqlQueryEndpoint(&config, &rowTransformer, newPostgresMacroEngine(), logger) + return tsdb.NewSqlQueryEndpoint(&config, &rowTransformer, newPostgresMacroEngine(datasource), logger) } func generateConnectionString(datasource *models.DataSource) string { diff --git a/pkg/tsdb/postgres/postgres_test.go b/pkg/tsdb/postgres/postgres_test.go index 87b7f916ca9..4e05f676682 100644 --- a/pkg/tsdb/postgres/postgres_test.go +++ b/pkg/tsdb/postgres/postgres_test.go @@ -102,7 +102,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": "SELECT * FROM postgres_types", "format": "table", @@ -183,7 +182,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": "SELECT $__timeGroup(time, '5m') AS time, avg(value) as value FROM metric GROUP BY 1 ORDER BY 1", "format": "time_series", @@ -228,7 +226,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": "SELECT $__timeGroup(time, '5m', NULL) AS time, avg(value) as value FROM metric GROUP BY 1 ORDER BY 1", "format": "time_series", @@ -283,7 +280,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": "SELECT $__timeGroup(time, '5m', 1.5) AS time, avg(value) as value FROM metric GROUP BY 1 ORDER BY 1", "format": "time_series", @@ -311,7 +307,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": "SELECT $__timeGroup(time, '5m', previous), avg(value) as value FROM metric GROUP BY 1 ORDER BY 1", "format": "time_series", @@ -406,7 +401,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "timeInt64" as time, "timeInt64" FROM metric_values ORDER BY time LIMIT 1`, "format": "time_series", @@ -429,7 +423,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "timeInt64Nullable" as time, "timeInt64Nullable" FROM metric_values ORDER BY time LIMIT 1`, "format": "time_series", @@ -452,7 +445,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "timeFloat64" as time, "timeFloat64" FROM metric_values ORDER BY time LIMIT 1`, "format": "time_series", @@ -475,7 +467,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "timeFloat64Nullable" as time, "timeFloat64Nullable" FROM metric_values ORDER BY time LIMIT 1`, "format": "time_series", @@ -520,7 +511,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "timeInt32Nullable" as time, "timeInt32Nullable" FROM metric_values ORDER BY time LIMIT 1`, "format": "time_series", @@ -543,7 +533,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "timeFloat32" as time, "timeFloat32" FROM metric_values ORDER BY time LIMIT 1`, "format": "time_series", @@ -566,7 +555,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "timeFloat32Nullable" as time, "timeFloat32Nullable" FROM metric_values ORDER BY time LIMIT 1`, "format": "time_series", @@ -589,7 +577,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT $__timeEpoch(time), measurement || ' - value one' as metric, "valueOne" FROM metric_values ORDER BY 1`, "format": "time_series", @@ -638,7 +625,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT $__timeEpoch(time), "valueOne", "valueTwo" FROM metric_values ORDER BY 1`, "format": "time_series", @@ -696,7 +682,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "time_sec" as time, description as text, tags FROM event WHERE $__unixEpochFilter(time_sec) AND tags='deploy' ORDER BY 1 ASC`, "format": "table", @@ -720,7 +705,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT "time_sec" as time, description as text, tags FROM event WHERE $__unixEpochFilter(time_sec) AND tags='ticket' ORDER BY 1 ASC`, "format": "table", @@ -747,7 +731,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": fmt.Sprintf(`SELECT CAST('%s' AS TIMESTAMP) as time, @@ -778,7 +761,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": fmt.Sprintf(`SELECT %d as time, @@ -809,7 +791,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": fmt.Sprintf(`SELECT cast(%d as bigint) as time, @@ -840,7 +821,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": fmt.Sprintf(`SELECT %d as time, @@ -869,7 +849,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT cast(null as bigint) as time, @@ -898,7 +877,6 @@ func TestPostgres(t *testing.T) { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { - DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ "rawSql": `SELECT cast(null as timestamp) as time, From 277a696fa577f307da16a45048261b7850e20ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 14 Aug 2018 08:49:56 +0200 Subject: [PATCH 46/99] fix: added missing ini default keys, fixes #12800 (#12912) --- conf/defaults.ini | 3 +++ conf/sample.ini | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/conf/defaults.ini b/conf/defaults.ini index b0caed81e90..99c1537eb95 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -315,6 +315,9 @@ api_url = team_ids = allowed_organizations = tls_skip_verify_insecure = false +tls_client_cert = +tls_client_key = +tls_client_ca = #################################### Basic Auth ########################## [auth.basic] diff --git a/conf/sample.ini b/conf/sample.ini index 87544a5ac39..4291071e026 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -272,6 +272,10 @@ log_queries = ;api_url = https://foo.bar/user ;team_ids = ;allowed_organizations = +;tls_skip_verify_insecure = false +;tls_client_cert = +;tls_client_key = +;tls_client_ca = #################################### Grafana.com Auth #################### [auth.grafana_com] From 36e808834d8aa32364663a22a977f6462567a2ae Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Tue, 14 Aug 2018 08:50:22 +0200 Subject: [PATCH 47/99] don't render hidden columns in table panel (#12911) --- public/app/plugins/panel/table/module.html | 2 +- public/app/plugins/panel/table/renderer.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/panel/table/module.html b/public/app/plugins/panel/table/module.html index 5c6fcbfdb1e..e328cb09a75 100644 --- a/public/app/plugins/panel/table/module.html +++ b/public/app/plugins/panel/table/module.html @@ -5,7 +5,7 @@
-
+
{{col.title}} diff --git a/public/app/plugins/panel/table/renderer.ts b/public/app/plugins/panel/table/renderer.ts index 95f54a64904..d85c20a87cc 100644 --- a/public/app/plugins/panel/table/renderer.ts +++ b/public/app/plugins/panel/table/renderer.ts @@ -238,6 +238,10 @@ export class TableRenderer { column.hidden = false; } + if (column.hidden === true) { + return ''; + } + if (column.style && column.style.preserveFormat) { cellClasses.push('table-panel-cell-pre'); } From e37931b79dc07ea19df5ab2891c2588910a22f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 14 Aug 2018 08:52:30 +0200 Subject: [PATCH 48/99] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index efc7e44d31b..f75458820b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,8 @@ * **Cloudwatch**: Add new Redshift metrics and dimensions [#12063](https://github.com/grafana/grafana/pulls/12063), thx [@A21z](https://github.com/A21z) * **Table**: Adjust header contrast for the light theme [#12668](https://github.com/grafana/grafana/issues/12668) * **Table**: Fix link color when using light theme and thresholds in use [#12766](https://github.com/grafana/grafana/issues/12766) +om/grafana/grafana/issues/12668) +* **Table**: Fix for useless horizontal scrollbar for table panel [#9964](https://github.com/grafana/grafana/issues/9964) * **Elasticsearch**: For alerting/backend, support having index name to the right of pattern in index pattern [#12731](https://github.com/grafana/grafana/issues/12731) * **OAuth**: Fix overriding tls_skip_verify_insecure using environment variable [#12747](https://github.com/grafana/grafana/issues/12747), thx [@jangaraj](https://github.com/jangaraj) * **Units**: Change units to include characters for power of 2 and 3 [#12744](https://github.com/grafana/grafana/pull/12744), thx [@Worty](https://github.com/Worty) From 7e0482e78d0b71872a1afed3154770922142d991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 14 Aug 2018 08:52:51 +0200 Subject: [PATCH 49/99] Fix for Graphite function parameter quoting (#12907) * fix: graphite function parameters should never be quoted for boolean, node, int and float types, fixes #11927 * Update gfunc.ts --- .../app/plugins/datasource/graphite/gfunc.ts | 9 ++++----- .../datasource/graphite/specs/gfunc.jest.ts | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/public/app/plugins/datasource/graphite/gfunc.ts b/public/app/plugins/datasource/graphite/gfunc.ts index 3d33d0f1005..430d0257b71 100644 --- a/public/app/plugins/datasource/graphite/gfunc.ts +++ b/public/app/plugins/datasource/graphite/gfunc.ts @@ -973,13 +973,12 @@ export class FuncInstance { } else if (_.get(_.last(this.def.params), 'multiple')) { paramType = _.get(_.last(this.def.params), 'type'); } - if (paramType === 'value_or_series') { + // param types that should never be quoted + if (_.includes(['value_or_series', 'boolean', 'int', 'float', 'node'], paramType)) { return value; } - if (paramType === 'boolean' && _.includes(['true', 'false'], value)) { - return value; - } - if (_.includes(['int', 'float', 'int_or_interval', 'node_or_tag', 'node'], paramType) && _.isFinite(+value)) { + // param types that might be quoted + if (_.includes(['int_or_interval', 'node_or_tag'], paramType) && _.isFinite(+value)) { return _.toString(+value); } return "'" + value + "'"; diff --git a/public/app/plugins/datasource/graphite/specs/gfunc.jest.ts b/public/app/plugins/datasource/graphite/specs/gfunc.jest.ts index feeaea2df67..08373582e73 100644 --- a/public/app/plugins/datasource/graphite/specs/gfunc.jest.ts +++ b/public/app/plugins/datasource/graphite/specs/gfunc.jest.ts @@ -55,6 +55,24 @@ describe('when rendering func instance', function() { expect(func.render('hello')).toEqual("movingMedian(hello, '5min')"); }); + it('should never quote boolean paramater', function() { + var func = gfunc.createFuncInstance('sortByName'); + func.params[0] = '$natural'; + expect(func.render('hello')).toEqual('sortByName(hello, $natural)'); + }); + + it('should never quote int paramater', function() { + var func = gfunc.createFuncInstance('maximumAbove'); + func.params[0] = '$value'; + expect(func.render('hello')).toEqual('maximumAbove(hello, $value)'); + }); + + it('should never quote node paramater', function() { + var func = gfunc.createFuncInstance('aliasByNode'); + func.params[0] = '$node'; + expect(func.render('hello')).toEqual('aliasByNode(hello, $node)'); + }); + it('should handle metric param and int param and string param', function() { var func = gfunc.createFuncInstance('groupByNode'); func.params[0] = 5; From 0fa47c5ef49ba645e6945fe2d5004e84a36a5563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 14 Aug 2018 08:55:27 +0200 Subject: [PATCH 50/99] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f75458820b1..8af8027508a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,6 @@ * **Api**: Delete nonexistent datasource should return 404 [#12313](https://github.com/grafana/grafana/issues/12313), thx [@AustinWinstanley](https://github.com/AustinWinstanley) * **Dashboard**: Fix selecting current dashboard from search should not reload dashboard [#12248](https://github.com/grafana/grafana/issues/12248) * **Singlestat**: Make colorization of prefix and postfix optional in singlestat [#11892](https://github.com/grafana/grafana/pull/11892), thx [@ApsOps](https://github.com/ApsOps) -* **Table**: Make table sorting stable when null values exist [#12362](https://github.com/grafana/grafana/pull/12362), thx [@bz2](https://github.com/bz2) * **Prometheus**: Fix graph panel bar width issue in aligned prometheus queries [#12379](https://github.com/grafana/grafana/issues/12379) * **Prometheus**: Heatmap - fix unhandled error when some points are missing [#12484](https://github.com/grafana/grafana/issues/12484) * **Prometheus**: Add $__interval, $__interval_ms, $__range, $__range_s & $__range_ms support for dashboard and template queries [#12597](https://github.com/grafana/grafana/issues/12597) [#12882](https://github.com/grafana/grafana/issues/12882), thx [@roidelapluie](https://github.com/roidelapluie) @@ -38,6 +37,7 @@ * **Table**: Fix link color when using light theme and thresholds in use [#12766](https://github.com/grafana/grafana/issues/12766) om/grafana/grafana/issues/12668) * **Table**: Fix for useless horizontal scrollbar for table panel [#9964](https://github.com/grafana/grafana/issues/9964) +* **Table**: Make table sorting stable when null values exist [#12362](https://github.com/grafana/grafana/pull/12362), thx [@bz2](https://github.com/bz2) * **Elasticsearch**: For alerting/backend, support having index name to the right of pattern in index pattern [#12731](https://github.com/grafana/grafana/issues/12731) * **OAuth**: Fix overriding tls_skip_verify_insecure using environment variable [#12747](https://github.com/grafana/grafana/issues/12747), thx [@jangaraj](https://github.com/jangaraj) * **Units**: Change units to include characters for power of 2 and 3 [#12744](https://github.com/grafana/grafana/pull/12744), thx [@Worty](https://github.com/Worty) @@ -46,6 +46,7 @@ om/grafana/grafana/issues/12668) * **Datasource**: Fix UI issue with secret fields after updating datasource [#11270](https://github.com/grafana/grafana/issues/11270) * **Plugins**: Convert URL-like text to links in plugins readme [#12843](https://github.com/grafana/grafana/pull/12843), thx [pgiraud](https://github.com/pgiraud) * **Docker**: Make it possible to set a specific plugin url [#12861](https://github.com/grafana/grafana/pull/12861), thx [ClementGautier](https://github.com/ClementGautier) +* **Graphite**: Fix for quoting of int function parameters (when using variables) [#11927](https://github.com/grafana/grafana/pull/11927) ### Breaking changes From 53bab1a84bfb38e21762bdd40cdb70ca48994f4b Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Tue, 14 Aug 2018 09:15:14 +0200 Subject: [PATCH 51/99] Remove tests and logs --- .../panel/heatmap/HeatmapRenderContainer.tsx | 20 - public/app/plugins/panel/heatmap/rendering.ts | 3 +- .../panel/heatmap/specs/renderer.jest.ts | 351 ------------------ .../panel/heatmap/specs/renderer_specs.ts | 320 ---------------- 4 files changed, 1 insertion(+), 693 deletions(-) delete mode 100644 public/app/plugins/panel/heatmap/HeatmapRenderContainer.tsx delete mode 100644 public/app/plugins/panel/heatmap/specs/renderer.jest.ts delete mode 100644 public/app/plugins/panel/heatmap/specs/renderer_specs.ts diff --git a/public/app/plugins/panel/heatmap/HeatmapRenderContainer.tsx b/public/app/plugins/panel/heatmap/HeatmapRenderContainer.tsx deleted file mode 100644 index e5982a485ca..00000000000 --- a/public/app/plugins/panel/heatmap/HeatmapRenderContainer.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react'; -import HeatmapRenderer from './rendering'; -import { HeatmapCtrl } from './heatmap_ctrl'; - -export class HeatmapRenderContainer extends React.Component { - renderer: any; - constructor(props) { - super(props); - this.renderer = HeatmapRenderer( - this.props.scope, - this.props.children[0], - [], - new HeatmapCtrl(this.props.scope, {}, {}) - ); - } - - render() { - return
; - } -} diff --git a/public/app/plugins/panel/heatmap/rendering.ts b/public/app/plugins/panel/heatmap/rendering.ts index 6d3d21420e0..e3318ea7e23 100644 --- a/public/app/plugins/panel/heatmap/rendering.ts +++ b/public/app/plugins/panel/heatmap/rendering.ts @@ -154,7 +154,7 @@ export class HeatmapRenderer { } else { timeFormat = d3.timeFormat(grafanaTimeFormatter); } - console.log(ticks); + let xAxis = d3 .axisBottom(this.xScale) .ticks(ticks) @@ -549,7 +549,6 @@ export class HeatmapRenderer { .style('opacity', this.getCardOpacity.bind(this)); let $cards = this.$heatmap.find('.heatmap-card'); - console.log($cards); $cards .on('mouseenter', event => { this.tooltip.mouseOverBucket = true; diff --git a/public/app/plugins/panel/heatmap/specs/renderer.jest.ts b/public/app/plugins/panel/heatmap/specs/renderer.jest.ts deleted file mode 100644 index a5546624d65..00000000000 --- a/public/app/plugins/panel/heatmap/specs/renderer.jest.ts +++ /dev/null @@ -1,351 +0,0 @@ -// import { describe, beforeEach, it, sinon, expect, angularMocks } from '../../../../../test/lib/common'; - -import '../module'; -// import angular from 'angular'; -// import $ from 'jquery'; -// import helpers from 'test/specs/helpers'; -import TimeSeries from 'app/core/time_series2'; -import moment from 'moment'; -// import { Emitter } from 'app/core/core'; -import rendering from '../rendering'; -// import * as d3 from 'd3'; -import { convertToHeatMap, convertToCards, histogramToHeatmap, calculateBucketSize } from '../heatmap_data_converter'; -jest.mock('app/core/core', () => ({ - appEvents: { - on: () => {}, - }, - contextSrv: { - user: { - lightTheme: false, - }, - }, -})); - -describe('grafanaHeatmap', function() { - // beforeEach(angularMocks.module('grafana.core')); - - let scope = {}; - let render; - - function heatmapScenario(desc, func, elementWidth = 500) { - describe(desc, function() { - var ctx: any = {}; - - ctx.setup = function(setupFunc) { - // beforeEach( - // angularMocks.module(function($provide) { - // $provide.value('timeSrv', new helpers.TimeSrvStub()); - // }) - // ); - - beforeEach(() => { - // angularMocks.inject(function($rootScope, $compile) { - var ctrl: any = { - colorSchemes: [ - { - name: 'Oranges', - value: 'interpolateOranges', - invert: 'dark', - }, - { name: 'Reds', value: 'interpolateReds', invert: 'dark' }, - ], - events: { - on: () => {}, - emit: () => {}, - }, - height: 200, - panel: { - heatmap: {}, - cards: { - cardPadding: null, - cardRound: null, - }, - color: { - mode: 'spectrum', - cardColor: '#b4ff00', - colorScale: 'linear', - exponent: 0.5, - colorScheme: 'interpolateOranges', - fillBackground: false, - }, - legend: { - show: false, - }, - xBucketSize: 1000, - xBucketNumber: null, - yBucketSize: 1, - yBucketNumber: null, - xAxis: { - show: true, - }, - yAxis: { - show: true, - format: 'short', - decimals: null, - logBase: 1, - splitFactor: null, - min: null, - max: null, - removeZeroValues: false, - }, - tooltip: { - show: true, - seriesStat: false, - showHistogram: false, - }, - highlightCards: true, - }, - renderingCompleted: jest.fn(), - hiddenSeries: {}, - dashboard: { - getTimezone: () => 'utc', - }, - range: { - from: moment.utc('01 Mar 2017 10:00:00', 'DD MMM YYYY HH:mm:ss'), - to: moment.utc('01 Mar 2017 11:00:00', 'DD MMM YYYY HH:mm:ss'), - }, - }; - - // var scope = $rootScope.$new(); - scope.ctrl = ctrl; - - ctx.series = []; - ctx.series.push( - new TimeSeries({ - datapoints: [[1, 1422774000000], [2, 1422774060000]], - alias: 'series1', - }) - ); - ctx.series.push( - new TimeSeries({ - datapoints: [[2, 1422774000000], [3, 1422774060000]], - alias: 'series2', - }) - ); - - ctx.data = { - heatmapStats: { - min: 1, - max: 3, - minLog: 1, - }, - xBucketSize: ctrl.panel.xBucketSize, - yBucketSize: ctrl.panel.yBucketSize, - }; - - setupFunc(ctrl, ctx); - - let logBase = ctrl.panel.yAxis.logBase; - let bucketsData; - if (ctrl.panel.dataFormat === 'tsbuckets') { - bucketsData = histogramToHeatmap(ctx.series); - } else { - bucketsData = convertToHeatMap(ctx.series, ctx.data.yBucketSize, ctx.data.xBucketSize, logBase); - } - ctx.data.buckets = bucketsData; - - let { cards, cardStats } = convertToCards(bucketsData); - ctx.data.cards = cards; - ctx.data.cardStats = cardStats; - - // let elemHtml = ` - //
- //
- //
- //
- //
`; - - // var element = $.parseHTML(elemHtml); - // $compile(element)(scope); - // scope.$digest(); - - ctrl.data = ctx.data; - ctx.element = { - find: () => ({ - on: () => {}, - css: () => 189, - width: () => 189, - height: () => 200, - find: () => ({ - on: () => {}, - }), - }), - on: () => {}, - }; - render = rendering(scope, ctx.element, [], ctrl); - render.render(); - render.ctrl.renderingCompleted(); - }); - }; - - func(ctx); - }); - } - - heatmapScenario('default options', function(ctx) { - ctx.setup(function(ctrl) { - ctrl.panel.yAxis.logBase = 1; - }); - - it('should draw correct Y axis', function() { - console.log('Runnign first test'); - // console.log(render.ctrl.data); - console.log(render.scope.yScale); - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).toEqual(['1', '2', '3']); - }); - - it('should draw correct X axis', function() { - var xTicks = getTicks(ctx.element, '.axis-x'); - let expectedTicks = [ - formatTime('01 Mar 2017 10:00:00'), - formatTime('01 Mar 2017 10:15:00'), - formatTime('01 Mar 2017 10:30:00'), - formatTime('01 Mar 2017 10:45:00'), - formatTime('01 Mar 2017 11:00:00'), - ]; - expect(xTicks).toEqual(expectedTicks); - }); - }); - - heatmapScenario('when logBase is 2', function(ctx) { - ctx.setup(function(ctrl) { - ctrl.panel.yAxis.logBase = 2; - }); - - it('should draw correct Y axis', function() { - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).toEqual(['1', '2', '4']); - }); - }); - - heatmapScenario('when logBase is 10', function(ctx) { - ctx.setup(function(ctrl, ctx) { - ctrl.panel.yAxis.logBase = 10; - - ctx.series.push( - new TimeSeries({ - datapoints: [[10, 1422774000000], [20, 1422774060000]], - alias: 'series3', - }) - ); - ctx.data.heatmapStats.max = 20; - }); - - it('should draw correct Y axis', function() { - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).toEqual(['1', '10', '100']); - }); - }); - - heatmapScenario('when logBase is 32', function(ctx) { - ctx.setup(function(ctrl) { - ctrl.panel.yAxis.logBase = 32; - - ctx.series.push( - new TimeSeries({ - datapoints: [[10, 1422774000000], [100, 1422774060000]], - alias: 'series3', - }) - ); - ctx.data.heatmapStats.max = 100; - }); - - it('should draw correct Y axis', function() { - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).toEqual(['1', '32', '1.0 K']); - }); - }); - - heatmapScenario('when logBase is 1024', function(ctx) { - ctx.setup(function(ctrl) { - ctrl.panel.yAxis.logBase = 1024; - - ctx.series.push( - new TimeSeries({ - datapoints: [[2000, 1422774000000], [300000, 1422774060000]], - alias: 'series3', - }) - ); - ctx.data.heatmapStats.max = 300000; - }); - - it('should draw correct Y axis', function() { - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).toEqual(['1', '1 K', '1.0 Mil']); - }); - }); - - heatmapScenario('when Y axis format set to "none"', function(ctx) { - ctx.setup(function(ctrl) { - ctrl.panel.yAxis.logBase = 1; - ctrl.panel.yAxis.format = 'none'; - ctx.data.heatmapStats.max = 10000; - }); - - it('should draw correct Y axis', function() { - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).toEqual(['0', '2000', '4000', '6000', '8000', '10000', '12000']); - }); - }); - - heatmapScenario('when Y axis format set to "second"', function(ctx) { - ctx.setup(function(ctrl) { - ctrl.panel.yAxis.logBase = 1; - ctrl.panel.yAxis.format = 's'; - ctx.data.heatmapStats.max = 3600; - }); - - it('should draw correct Y axis', function() { - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).toEqual(['0 ns', '17 min', '33 min', '50 min', '1.11 hour']); - }); - }); - - heatmapScenario('when data format is Time series buckets', function(ctx) { - ctx.setup(function(ctrl, ctx) { - ctrl.panel.dataFormat = 'tsbuckets'; - - const series = [ - { - alias: '1', - datapoints: [[1000, 1422774000000], [200000, 1422774060000]], - }, - { - alias: '2', - datapoints: [[3000, 1422774000000], [400000, 1422774060000]], - }, - { - alias: '3', - datapoints: [[2000, 1422774000000], [300000, 1422774060000]], - }, - ]; - ctx.series = series.map(s => new TimeSeries(s)); - - ctx.data.tsBuckets = series.map(s => s.alias).concat(''); - ctx.data.yBucketSize = 1; - let xBucketBoundSet = series[0].datapoints.map(dp => dp[1]); - ctx.data.xBucketSize = calculateBucketSize(xBucketBoundSet); - }); - - it('should draw correct Y axis', function() { - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).toEqual(['1', '2', '3', '']); - }); - }); -}); - -function getTicks(element, axisSelector) { - // return element - // .find(axisSelector) - // .find('text') - // .map(function() { - // return this.textContent; - // }) - // .get(); -} - -function formatTime(timeStr) { - let format = 'HH:mm'; - return moment.utc(timeStr, 'DD MMM YYYY HH:mm:ss').format(format); -} diff --git a/public/app/plugins/panel/heatmap/specs/renderer_specs.ts b/public/app/plugins/panel/heatmap/specs/renderer_specs.ts deleted file mode 100644 index f52b6d1d985..00000000000 --- a/public/app/plugins/panel/heatmap/specs/renderer_specs.ts +++ /dev/null @@ -1,320 +0,0 @@ -import { describe, beforeEach, it, sinon, expect, angularMocks } from '../../../../../test/lib/common'; - -import '../module'; -import angular from 'angular'; -import $ from 'jquery'; -import helpers from 'test/specs/helpers'; -import TimeSeries from 'app/core/time_series2'; -import moment from 'moment'; -import { Emitter } from 'app/core/core'; -import rendering from '../rendering'; -import { convertToHeatMap, convertToCards, histogramToHeatmap, calculateBucketSize } from '../heatmap_data_converter'; - -describe('grafanaHeatmap', function() { - beforeEach(angularMocks.module('grafana.core')); - - function heatmapScenario(desc, func, elementWidth = 500) { - describe(desc, function() { - var ctx: any = {}; - - ctx.setup = function(setupFunc) { - beforeEach( - angularMocks.module(function($provide) { - $provide.value('timeSrv', new helpers.TimeSrvStub()); - }) - ); - - beforeEach( - angularMocks.inject(function($rootScope, $compile) { - var ctrl: any = { - colorSchemes: [ - { - name: 'Oranges', - value: 'interpolateOranges', - invert: 'dark', - }, - { name: 'Reds', value: 'interpolateReds', invert: 'dark' }, - ], - events: new Emitter(), - height: 200, - panel: { - heatmap: {}, - cards: { - cardPadding: null, - cardRound: null, - }, - color: { - mode: 'spectrum', - cardColor: '#b4ff00', - colorScale: 'linear', - exponent: 0.5, - colorScheme: 'interpolateOranges', - fillBackground: false, - }, - legend: { - show: false, - }, - xBucketSize: 1000, - xBucketNumber: null, - yBucketSize: 1, - yBucketNumber: null, - xAxis: { - show: true, - }, - yAxis: { - show: true, - format: 'short', - decimals: null, - logBase: 1, - splitFactor: null, - min: null, - max: null, - removeZeroValues: false, - }, - tooltip: { - show: true, - seriesStat: false, - showHistogram: false, - }, - highlightCards: true, - }, - renderingCompleted: sinon.spy(), - hiddenSeries: {}, - dashboard: { - getTimezone: sinon.stub().returns('utc'), - }, - range: { - from: moment.utc('01 Mar 2017 10:00:00', 'DD MMM YYYY HH:mm:ss'), - to: moment.utc('01 Mar 2017 11:00:00', 'DD MMM YYYY HH:mm:ss'), - }, - }; - - var scope = $rootScope.$new(); - scope.ctrl = ctrl; - - ctx.series = []; - ctx.series.push( - new TimeSeries({ - datapoints: [[1, 1422774000000], [2, 1422774060000]], - alias: 'series1', - }) - ); - ctx.series.push( - new TimeSeries({ - datapoints: [[2, 1422774000000], [3, 1422774060000]], - alias: 'series2', - }) - ); - - ctx.data = { - heatmapStats: { - min: 1, - max: 3, - minLog: 1, - }, - xBucketSize: ctrl.panel.xBucketSize, - yBucketSize: ctrl.panel.yBucketSize, - }; - - setupFunc(ctrl, ctx); - - let logBase = ctrl.panel.yAxis.logBase; - let bucketsData; - if (ctrl.panel.dataFormat === 'tsbuckets') { - bucketsData = histogramToHeatmap(ctx.series); - } else { - bucketsData = convertToHeatMap(ctx.series, ctx.data.yBucketSize, ctx.data.xBucketSize, logBase); - } - ctx.data.buckets = bucketsData; - - let { cards, cardStats } = convertToCards(bucketsData); - ctx.data.cards = cards; - ctx.data.cardStats = cardStats; - - let elemHtml = ` -
-
-
-
-
`; - - var element = angular.element(elemHtml); - $compile(element)(scope); - scope.$digest(); - - ctrl.data = ctx.data; - ctx.element = element; - rendering(scope, $(element), [], ctrl); - ctrl.events.emit('render'); - }) - ); - }; - - func(ctx); - }); - } - - heatmapScenario('default options', function(ctx) { - ctx.setup(function(ctrl) { - ctrl.panel.yAxis.logBase = 1; - }); - - it('should draw correct Y axis', function() { - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).to.eql(['1', '2', '3']); - }); - - it('should draw correct X axis', function() { - var xTicks = getTicks(ctx.element, '.axis-x'); - let expectedTicks = [ - formatTime('01 Mar 2017 10:00:00'), - formatTime('01 Mar 2017 10:15:00'), - formatTime('01 Mar 2017 10:30:00'), - formatTime('01 Mar 2017 10:45:00'), - formatTime('01 Mar 2017 11:00:00'), - ]; - expect(xTicks).to.eql(expectedTicks); - }); - }); - - heatmapScenario('when logBase is 2', function(ctx) { - ctx.setup(function(ctrl) { - ctrl.panel.yAxis.logBase = 2; - }); - - it('should draw correct Y axis', function() { - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).to.eql(['1', '2', '4']); - }); - }); - - heatmapScenario('when logBase is 10', function(ctx) { - ctx.setup(function(ctrl, ctx) { - ctrl.panel.yAxis.logBase = 10; - - ctx.series.push( - new TimeSeries({ - datapoints: [[10, 1422774000000], [20, 1422774060000]], - alias: 'series3', - }) - ); - ctx.data.heatmapStats.max = 20; - }); - - it('should draw correct Y axis', function() { - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).to.eql(['1', '10', '100']); - }); - }); - - heatmapScenario('when logBase is 32', function(ctx) { - ctx.setup(function(ctrl) { - ctrl.panel.yAxis.logBase = 32; - - ctx.series.push( - new TimeSeries({ - datapoints: [[10, 1422774000000], [100, 1422774060000]], - alias: 'series3', - }) - ); - ctx.data.heatmapStats.max = 100; - }); - - it('should draw correct Y axis', function() { - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).to.eql(['1', '32', '1.0 K']); - }); - }); - - heatmapScenario('when logBase is 1024', function(ctx) { - ctx.setup(function(ctrl) { - ctrl.panel.yAxis.logBase = 1024; - - ctx.series.push( - new TimeSeries({ - datapoints: [[2000, 1422774000000], [300000, 1422774060000]], - alias: 'series3', - }) - ); - ctx.data.heatmapStats.max = 300000; - }); - - it('should draw correct Y axis', function() { - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).to.eql(['1', '1 K', '1.0 Mil']); - }); - }); - - heatmapScenario('when Y axis format set to "none"', function(ctx) { - ctx.setup(function(ctrl) { - ctrl.panel.yAxis.logBase = 1; - ctrl.panel.yAxis.format = 'none'; - ctx.data.heatmapStats.max = 10000; - }); - - it('should draw correct Y axis', function() { - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).to.eql(['0', '2000', '4000', '6000', '8000', '10000', '12000']); - }); - }); - - heatmapScenario('when Y axis format set to "second"', function(ctx) { - ctx.setup(function(ctrl) { - ctrl.panel.yAxis.logBase = 1; - ctrl.panel.yAxis.format = 's'; - ctx.data.heatmapStats.max = 3600; - }); - - it('should draw correct Y axis', function() { - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).to.eql(['0 ns', '17 min', '33 min', '50 min', '1.11 hour']); - }); - }); - - heatmapScenario('when data format is Time series buckets', function(ctx) { - ctx.setup(function(ctrl, ctx) { - ctrl.panel.dataFormat = 'tsbuckets'; - - const series = [ - { - alias: '1', - datapoints: [[1000, 1422774000000], [200000, 1422774060000]], - }, - { - alias: '2', - datapoints: [[3000, 1422774000000], [400000, 1422774060000]], - }, - { - alias: '3', - datapoints: [[2000, 1422774000000], [300000, 1422774060000]], - }, - ]; - ctx.series = series.map(s => new TimeSeries(s)); - - ctx.data.tsBuckets = series.map(s => s.alias).concat(''); - ctx.data.yBucketSize = 1; - let xBucketBoundSet = series[0].datapoints.map(dp => dp[1]); - ctx.data.xBucketSize = calculateBucketSize(xBucketBoundSet); - }); - - it('should draw correct Y axis', function() { - var yTicks = getTicks(ctx.element, '.axis-y'); - expect(yTicks).to.eql(['1', '2', '3', '']); - }); - }); -}); - -function getTicks(element, axisSelector) { - return element - .find(axisSelector) - .find('text') - .map(function() { - return this.textContent; - }) - .get(); -} - -function formatTime(timeStr) { - let format = 'HH:mm'; - return moment.utc(timeStr, 'DD MMM YYYY HH:mm:ss').format(format); -} From 3955133f7e143002bd7b141808a1323ade444694 Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Tue, 14 Aug 2018 09:15:24 +0200 Subject: [PATCH 52/99] Don't pass datasource to newPostgresMacroEngine --- pkg/tsdb/postgres/macros.go | 7 ++----- pkg/tsdb/postgres/macros_test.go | 9 ++------- pkg/tsdb/postgres/postgres.go | 4 +++- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/pkg/tsdb/postgres/macros.go b/pkg/tsdb/postgres/macros.go index 81b0da9fbce..0a9162a2d4c 100644 --- a/pkg/tsdb/postgres/macros.go +++ b/pkg/tsdb/postgres/macros.go @@ -7,7 +7,6 @@ import ( "strings" "time" - "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/tsdb" ) @@ -21,10 +20,8 @@ type postgresMacroEngine struct { timescaledb bool } -func newPostgresMacroEngine(datasource *models.DataSource) tsdb.SqlMacroEngine { - engine := &postgresMacroEngine{} - engine.timescaledb = datasource.JsonData.Get("timescaledb").MustBool(false) - return engine +func newPostgresMacroEngine(timescaledb bool) tsdb.SqlMacroEngine { + return &postgresMacroEngine{timescaledb: timescaledb} } func (m *postgresMacroEngine) Interpolate(query *tsdb.Query, timeRange *tsdb.TimeRange, sql string) (string, error) { diff --git a/pkg/tsdb/postgres/macros_test.go b/pkg/tsdb/postgres/macros_test.go index fe95535fe0c..30a57a7095f 100644 --- a/pkg/tsdb/postgres/macros_test.go +++ b/pkg/tsdb/postgres/macros_test.go @@ -6,19 +6,14 @@ import ( "testing" "time" - "github.com/grafana/grafana/pkg/components/simplejson" - "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/tsdb" . "github.com/smartystreets/goconvey/convey" ) func TestMacroEngine(t *testing.T) { Convey("MacroEngine", t, func() { - datasource := &models.DataSource{JsonData: simplejson.New()} - engine := newPostgresMacroEngine(datasource) - datasourceTS := &models.DataSource{JsonData: simplejson.New()} - datasourceTS.JsonData.Set("timescaledb", true) - engineTS := newPostgresMacroEngine(datasourceTS) + engine := newPostgresMacroEngine(false) + engineTS := newPostgresMacroEngine(true) query := &tsdb.Query{} Convey("Given a time range between 2018-04-12 00:00 and 2018-04-12 00:05", func() { diff --git a/pkg/tsdb/postgres/postgres.go b/pkg/tsdb/postgres/postgres.go index 46d766f9a11..4bcf06638f4 100644 --- a/pkg/tsdb/postgres/postgres.go +++ b/pkg/tsdb/postgres/postgres.go @@ -32,7 +32,9 @@ func newPostgresQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndp log: logger, } - return tsdb.NewSqlQueryEndpoint(&config, &rowTransformer, newPostgresMacroEngine(datasource), logger) + timescaledb := datasource.JsonData.Get("timescaledb").MustBool(false) + + return tsdb.NewSqlQueryEndpoint(&config, &rowTransformer, newPostgresMacroEngine(timescaledb), logger) } func generateConnectionString(datasource *models.DataSource) string { From 4f704cec532529542dbc8c1912e666e168d4b36e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 14 Aug 2018 09:18:04 +0200 Subject: [PATCH 53/99] fix: ds_proxy test not initiating header --- pkg/api/pluginproxy/ds_proxy_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/api/pluginproxy/ds_proxy_test.go b/pkg/api/pluginproxy/ds_proxy_test.go index bb553b4d075..9b768c3d32a 100644 --- a/pkg/api/pluginproxy/ds_proxy_test.go +++ b/pkg/api/pluginproxy/ds_proxy_test.go @@ -219,7 +219,7 @@ func TestDSRouteRule(t *testing.T) { proxy := NewDataSourceProxy(ds, plugin, ctx, "/render") requestURL, _ := url.Parse("http://grafana.com/sub") - req := http.Request{URL: requestURL} + req := http.Request{URL: requestURL, Header: http.Header{}} proxy.getDirector()(&req) @@ -244,7 +244,7 @@ func TestDSRouteRule(t *testing.T) { proxy := NewDataSourceProxy(ds, plugin, ctx, "") requestURL, _ := url.Parse("http://grafana.com/sub") - req := http.Request{URL: requestURL} + req := http.Request{URL: requestURL, Header: http.Header{}} proxy.getDirector()(&req) From 766d0bef17fde119ffddbc827177e2c3f4d36fe3 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Tue, 14 Aug 2018 09:19:37 +0200 Subject: [PATCH 54/99] changelog: add notes about closing #10705 [skip ci] --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8af8027508a..7cd75402946 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * **Api**: Delete nonexistent datasource should return 404 [#12313](https://github.com/grafana/grafana/issues/12313), thx [@AustinWinstanley](https://github.com/AustinWinstanley) * **Dashboard**: Fix selecting current dashboard from search should not reload dashboard [#12248](https://github.com/grafana/grafana/issues/12248) +* **Dashboard**: Use uid when linking to dashboards internally in a dashboard [#10705](https://github.com/grafana/grafana/issues/10705) * **Singlestat**: Make colorization of prefix and postfix optional in singlestat [#11892](https://github.com/grafana/grafana/pull/11892), thx [@ApsOps](https://github.com/ApsOps) * **Prometheus**: Fix graph panel bar width issue in aligned prometheus queries [#12379](https://github.com/grafana/grafana/issues/12379) * **Prometheus**: Heatmap - fix unhandled error when some points are missing [#12484](https://github.com/grafana/grafana/issues/12484) @@ -27,7 +28,6 @@ * **Github OAuth**: Allow changes of user info at Github to be synched to Grafana when signing in [#11818](https://github.com/grafana/grafana/issues/11818), thx [@rwaweber](https://github.com/rwaweber) * **Alerting**: Fix diff and percent_diff reducers [#11563](https://github.com/grafana/grafana/issues/11563), thx [@jessetane](https://github.com/jessetane) * **Alerting**: Fix rendering timeout which could cause notifications to not be sent due to rendering timing out [#12151](https://github.com/grafana/grafana/issues/12151) -* **Units**: Polish złoty currency [#12691](https://github.com/grafana/grafana/pull/12691), thx [@mwegrzynek](https://github.com/mwegrzynek) * **Cloudwatch**: Improved error handling [#12489](https://github.com/grafana/grafana/issues/12489), thx [@mtanda](https://github.com/mtanda) * **Cloudwatch**: AppSync metrics and dimensions [#12300](https://github.com/grafana/grafana/issues/12300), thx [@franciscocpg](https://github.com/franciscocpg) * **Cloudwatch**: Direct Connect metrics and dimensions [#12762](https://github.com/grafana/grafana/pulls/12762), thx [@mindriot88](https://github.com/mindriot88) @@ -41,6 +41,7 @@ om/grafana/grafana/issues/12668) * **Elasticsearch**: For alerting/backend, support having index name to the right of pattern in index pattern [#12731](https://github.com/grafana/grafana/issues/12731) * **OAuth**: Fix overriding tls_skip_verify_insecure using environment variable [#12747](https://github.com/grafana/grafana/issues/12747), thx [@jangaraj](https://github.com/jangaraj) * **Units**: Change units to include characters for power of 2 and 3 [#12744](https://github.com/grafana/grafana/pull/12744), thx [@Worty](https://github.com/Worty) +* **Units**: Polish złoty currency [#12691](https://github.com/grafana/grafana/pull/12691), thx [@mwegrzynek](https://github.com/mwegrzynek) * **Graph**: Option to hide series from tooltip [#3341](https://github.com/grafana/grafana/issues/3341), thx [@mtanda](https://github.com/mtanda) * **UI**: Fix iOS home screen "app" icon and Windows 10 app experience [#12752](https://github.com/grafana/grafana/issues/12752), thx [@andig](https://github.com/andig) * **Datasource**: Fix UI issue with secret fields after updating datasource [#11270](https://github.com/grafana/grafana/issues/11270) From e696dc4d5f895d0c17ff3e02ac2c9181d2b234ab Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Tue, 14 Aug 2018 09:28:08 +0200 Subject: [PATCH 55/99] Remove Karma scripts and docs --- .github/CONTRIBUTING.md | 6 ++++- README.md | 12 ++-------- docs/sources/project/building_from_source.md | 8 +++---- package.json | 10 --------- scripts/grunt/default_task.js | 1 - scripts/grunt/options/karma.js | 23 -------------------- 6 files changed, 10 insertions(+), 50 deletions(-) delete mode 100644 scripts/grunt/options/karma.js diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index fe0a1d6c548..f0f4e19bfc3 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -7,7 +7,11 @@ grunt && grunt watch ### Rerun tests on source change ``` -grunt karma:dev +npm jest +``` +or +``` +yarn jest ``` ### Run tests for backend assets before commit diff --git a/README.md b/README.md index d6083bb1504..71fdb04cea6 100644 --- a/README.md +++ b/README.md @@ -59,11 +59,6 @@ Run tests yarn run jest ``` -Run karma tests -```bash -yarn run karma -``` - ### Recompile backend on source change To rebuild on source change. @@ -101,14 +96,11 @@ Execute all frontend tests yarn run test ``` -Writing & watching frontend tests (we have two test runners) +Writing & watching frontend tests - jest for all new tests that do not require browser context (React+more) - Start watcher: `yarn run jest` - - Jest will run all test files that end with the name ".jest.ts" -- karma + mocha is used for testing angularjs components. We do want to migrate these test to jest over time (if possible). - - Start watcher: `yarn run karma` - - Karma+Mocha runs all files that end with the name "_specs.ts". + - Jest will run all test files that end with the name ".test.ts" #### Backend ```bash diff --git a/docs/sources/project/building_from_source.md b/docs/sources/project/building_from_source.md index a0b553594ce..20c177211e3 100644 --- a/docs/sources/project/building_from_source.md +++ b/docs/sources/project/building_from_source.md @@ -90,14 +90,12 @@ You'll also need to run `npm run watch` to watch for changes to the front-end (t - You can run backend Golang tests using "go test ./pkg/...". - Execute all frontend tests with "npm run test" -Writing & watching frontend tests (we have two test runners) +Writing & watching frontend tests - jest for all new tests that do not require browser context (React+more) - Start watcher: `npm run jest` - - Jest will run all test files that end with the name ".jest.ts" -- karma + mocha is used for testing angularjs components. We do want to migrate these test to jest over time (if possible). - - Start watcher: `npm run karma` - - Karma+Mocha runs all files that end with the name "_specs.ts". + - Jest will run all test files that end with the name ".test.ts" + ## Creating optimized release packages diff --git a/package.json b/package.json index 24e23b574df..87615e8273b 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ "grunt-contrib-copy": "~1.0.0", "grunt-contrib-cssmin": "~1.0.2", "grunt-exec": "^1.0.1", - "grunt-karma": "~2.0.0", "grunt-notify": "^0.4.5", "grunt-postcss": "^0.8.0", "grunt-sass": "^2.0.0", @@ -58,14 +57,6 @@ "html-webpack-plugin": "^3.2.0", "husky": "^0.14.3", "jest": "^22.0.4", - "karma": "1.7.0", - "karma-chrome-launcher": "~2.2.0", - "karma-expect": "~1.1.3", - "karma-mocha": "~1.3.0", - "karma-phantomjs-launcher": "1.0.4", - "karma-sinon": "^1.0.5", - "karma-sourcemap-loader": "^0.3.7", - "karma-webpack": "^3.0.0", "lint-staged": "^6.0.0", "load-grunt-tasks": "3.5.2", "mini-css-extract-plugin": "^0.4.0", @@ -112,7 +103,6 @@ "test": "grunt test", "test:coverage": "grunt test --coverage=true", "lint": "tslint -c tslint.json --project tsconfig.json --type-check", - "karma": "grunt karma:dev", "jest": "jest --notify --watch", "api-tests": "jest --notify --watch --config=tests/api/jest.js", "precommit": "lint-staged && grunt precommit" diff --git a/scripts/grunt/default_task.js b/scripts/grunt/default_task.js index efcdcd02963..07519cdd6c8 100644 --- a/scripts/grunt/default_task.js +++ b/scripts/grunt/default_task.js @@ -12,7 +12,6 @@ module.exports = function(grunt) { 'sasslint', 'exec:tslint', "exec:jest", - 'karma:test', 'no-only-tests' ]); diff --git a/scripts/grunt/options/karma.js b/scripts/grunt/options/karma.js deleted file mode 100644 index 9f638d2e36d..00000000000 --- a/scripts/grunt/options/karma.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports = function (config) { - 'use strict'; - - return { - dev: { - configFile: 'karma.conf.js', - singleRun: false, - }, - - debug: { - configFile: 'karma.conf.js', - singleRun: false, - browsers: ['Chrome'], - mime: { - 'text/x-typescript': ['ts', 'tsx'] - }, - }, - - test: { - configFile: 'karma.conf.js', - } - }; -}; From 837388d13e0a0a84c4829edf4eca285321079f5e Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Tue, 14 Aug 2018 09:44:58 +0200 Subject: [PATCH 56/99] Use variable in newPostgresMacroEngine --- pkg/tsdb/postgres/macros_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/tsdb/postgres/macros_test.go b/pkg/tsdb/postgres/macros_test.go index 30a57a7095f..f0c8832dd05 100644 --- a/pkg/tsdb/postgres/macros_test.go +++ b/pkg/tsdb/postgres/macros_test.go @@ -12,8 +12,10 @@ import ( func TestMacroEngine(t *testing.T) { Convey("MacroEngine", t, func() { - engine := newPostgresMacroEngine(false) - engineTS := newPostgresMacroEngine(true) + timescaledbEnabled := false + engine := newPostgresMacroEngine(timescaledbEnabled) + timescaledbEnabled = true + engineTS := newPostgresMacroEngine(timescaledbEnabled) query := &tsdb.Query{} Convey("Given a time range between 2018-04-12 00:00 and 2018-04-12 00:05", func() { From d33019ca6740e55d89119bbf6fce32056cdded3f Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Tue, 14 Aug 2018 10:22:57 +0200 Subject: [PATCH 57/99] document TimescaleDB datasource option --- docs/sources/features/datasources/postgres.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sources/features/datasources/postgres.md b/docs/sources/features/datasources/postgres.md index 2be2db0837b..e8ed742f64f 100644 --- a/docs/sources/features/datasources/postgres.md +++ b/docs/sources/features/datasources/postgres.md @@ -31,6 +31,7 @@ Name | Description *User* | Database user's login/username *Password* | Database user's password *SSL Mode* | This option determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the server. +*TimescaleDB* | With this option enabled Grafana will use TimescaleDB features, e.g. use ```time_bucket``` for grouping by time. ### Database User Permissions (Important!) From a96d97e347ad8a8725ca7f8fbb80271812d7e64c Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Tue, 14 Aug 2018 10:26:08 +0200 Subject: [PATCH 58/99] add version disclaimer for TimescaleDB --- docs/sources/features/datasources/postgres.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/features/datasources/postgres.md b/docs/sources/features/datasources/postgres.md index e8ed742f64f..e2dcf888025 100644 --- a/docs/sources/features/datasources/postgres.md +++ b/docs/sources/features/datasources/postgres.md @@ -31,7 +31,7 @@ Name | Description *User* | Database user's login/username *Password* | Database user's password *SSL Mode* | This option determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the server. -*TimescaleDB* | With this option enabled Grafana will use TimescaleDB features, e.g. use ```time_bucket``` for grouping by time. +*TimescaleDB* | With this option enabled Grafana will use TimescaleDB features, e.g. use ```time_bucket``` for grouping by time (only available in Grafana 5.3+). ### Database User Permissions (Important!) From b70d594c103de35875600cddabe9130468435cb6 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Tue, 14 Aug 2018 10:35:34 +0200 Subject: [PATCH 59/99] changelog: add notes about closing #12598 [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cd75402946..0c397e45ea4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ om/grafana/grafana/issues/12668) * **Plugins**: Convert URL-like text to links in plugins readme [#12843](https://github.com/grafana/grafana/pull/12843), thx [pgiraud](https://github.com/pgiraud) * **Docker**: Make it possible to set a specific plugin url [#12861](https://github.com/grafana/grafana/pull/12861), thx [ClementGautier](https://github.com/ClementGautier) * **Graphite**: Fix for quoting of int function parameters (when using variables) [#11927](https://github.com/grafana/grafana/pull/11927) +* **InfluxDB**: Support timeFilter in query templating for InfluxDB [#12598](https://github.com/grafana/grafana/pull/12598), thx [kichristensen](https://github.com/kichristensen) ### Breaking changes From a65589a5fbeb2fde7e5cc2dd6613fb8bf0355ae5 Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Tue, 14 Aug 2018 10:52:41 +0200 Subject: [PATCH 60/99] Rename test files --- .github/CONTRIBUTING.md | 2 +- jest.config.js | 2 +- karma.conf.js | 40 ------------------- ...leList.jest.tsx => AlertRuleList.test.tsx} | 0 ...t.tsx.snap => AlertRuleList.test.tsx.snap} | 0 ...Field.jest.tsx => PromQueryField.test.tsx} | 0 ...imePicker.jest.tsx => TimePicker.test.tsx} | 0 .../{braces.jest.ts => braces.test.ts} | 0 .../{clear.jest.ts => clear.test.ts} | 0 ...{prometheus.jest.ts => prometheus.test.ts} | 0 ...tings.jest.tsx => FolderSettings.test.tsx} | 0 ...verStats.jest.tsx => ServerStats.test.tsx} | 0 ...est.tsx.snap => ServerStats.test.tsx.snap} | 0 ...eButton.jest.tsx => DeleteButton.test.tsx} | 0 ...ListCTA.jest.tsx => EmptyListCTA.test.tsx} | 0 ...st.tsx.snap => EmptyListCTA.test.tsx.snap} | 0 ...ageHeader.jest.tsx => PageHeader.test.tsx} | 0 ...sions.jest.tsx => AddPermissions.test.tsx} | 0 ...rOption.jest.tsx => PickerOption.test.tsx} | 0 ...eamPicker.jest.tsx => TeamPicker.test.tsx} | 0 ...serPicker.jest.tsx => UserPicker.test.tsx} | 0 ...st.tsx.snap => PickerOption.test.tsx.snap} | 0 ...jest.tsx.snap => TeamPicker.test.tsx.snap} | 0 ...jest.tsx.snap => UserPicker.test.tsx.snap} | 0 .../{Popover.jest.tsx => Popover.test.tsx} | 0 .../{Tooltip.jest.tsx => Tooltip.test.tsx} | 0 ...er.jest.tsx.snap => Popover.test.tsx.snap} | 0 ...ip.jest.tsx.snap => Tooltip.test.tsx.snap} | 0 ...Palette.jest.tsx => ColorPalette.test.tsx} | 0 ...gth.jest.tsx => PasswordStrength.test.tsx} | 0 ...st.tsx.snap => ColorPalette.test.tsx.snap} | 0 ...ackend_srv.jest.ts => backend_srv.test.ts} | 0 .../{datemath.jest.ts => datemath.test.ts} | 0 .../{emitter.jest.ts => emitter.test.ts} | 0 ...ile_export.jest.ts => file_export.test.ts} | 0 .../{flatten.jest.ts => flatten.test.ts} | 0 .../core/specs/{kbn.jest.ts => kbn.test.ts} | 0 ...ion_util.jest.ts => location_util.test.ts} | 0 ...ards.jest.ts => manage_dashboards.test.ts} | 0 ..._switcher.jest.ts => org_switcher.test.ts} | 0 .../{rangeutil.jest.ts => rangeutil.test.ts} | 0 .../specs/{search.jest.ts => search.test.ts} | 0 ...results.jest.ts => search_results.test.ts} | 0 ...{search_srv.jest.ts => search_srv.test.ts} | 0 .../specs/{store.jest.ts => store.test.ts} | 0 ...able_model.jest.ts => table_model.test.ts} | 0 .../specs/{ticks.jest.ts => ticks.test.ts} | 0 ...ime_series.jest.ts => time_series.test.ts} | 0 ....jest.ts => value_select_dropdown.test.ts} | 0 ...apper.jest.ts => threshold_mapper.test.ts} | 0 ...ns_srv.jest.ts => annotations_srv.test.ts} | 0 ....jest.ts => annotations_srv_specs.test.ts} | 0 ...lPanel.jest.tsx => AddPanelPanel.test.tsx} | 0 ...oardRow.jest.tsx => DashboardRow.test.tsx} | 0 ...tracker.jest.ts => change_tracker.test.ts} | 0 ....jest.ts => dashboard_import_ctrl.test.ts} | 0 ...on.jest.ts => dashboard_migration.test.ts} | 0 ..._model.jest.ts => dashboard_model.test.ts} | 0 .../{exporter.jest.ts => exporter.test.ts} | 0 ...tory_ctrl.jest.ts => history_ctrl.test.ts} | 0 ...istory_srv.jest.ts => history_srv.test.ts} | 0 .../specs/{repeat.jest.ts => repeat.test.ts} | 0 ...as_modal.jest.ts => save_as_modal.test.ts} | 0 ...{save_modal.jest.ts => save_modal.test.ts} | 0 ...jest.ts => save_provisioned_modal.test.ts} | 0 .../{time_srv.jest.ts => time_srv.test.ts} | 0 ...tate_srv.jest.ts => viewstate_srv.test.ts} | 0 ...trl.jest.ts => metrics_panel_ctrl.test.ts} | 0 .../{link_srv.jest.ts => link_srv.test.ts} | 0 ...trl.jest.ts => playlist_edit_ctrl.test.ts} | 0 ...rce_srv.jest.ts => datasource_srv.test.ts} | 0 ...ariable.jest.ts => adhoc_variable.test.ts} | 0 ...ditor_ctrl.jest.ts => editor_ctrl.test.ts} | 0 ...ariable.jest.ts => query_variable.test.ts} | 0 ...plate_srv.jest.ts => template_srv.test.ts} | 0 .../{variable.jest.ts => variable.test.ts} | 0 ...iable_srv.jest.ts => variable_srv.test.ts} | 0 ...init.jest.ts => variable_srv_init.test.ts} | 0 ...{datasource.jest.ts => datasource.test.ts} | 0 ...{datasource.jest.ts => datasource.test.ts} | 0 ...ponse.jest.ts => elastic_response.test.ts} | 0 ..._pattern.jest.ts => index_pattern.test.ts} | 0 ..._builder.jest.ts => query_builder.test.ts} | 0 .../{query_def.jest.ts => query_def.test.ts} | 0 ...{datasource.jest.ts => datasource.test.ts} | 0 .../specs/{gfunc.jest.ts => gfunc.test.ts} | 0 ...e_query.jest.ts => graphite_query.test.ts} | 0 .../specs/{lexer.jest.ts => lexer.test.ts} | 0 .../specs/{parser.jest.ts => parser.test.ts} | 0 ...{query_ctrl.jest.ts => query_ctrl.test.ts} | 0 ...lux_query.jest.ts => influx_query.test.ts} | 0 ...x_series.jest.ts => influx_series.test.ts} | 0 ..._builder.jest.ts => query_builder.test.ts} | 0 ...{query_ctrl.jest.ts => query_ctrl.test.ts} | 0 ...{query_part.jest.ts => query_part.test.ts} | 0 ...parser.jest.ts => response_parser.test.ts} | 0 ...{datasource.jest.ts => datasource.test.ts} | 0 ...mer.jest.ts => result_transformer.test.ts} | 0 ...{datasource.jest.ts => datasource.test.ts} | 0 ...{datasource.jest.ts => datasource.test.ts} | 0 ...{datasource.jest.ts => datasource.test.ts} | 0 ...{query_ctrl.jest.ts => query_ctrl.test.ts} | 0 ...{datasource.jest.ts => datasource.test.ts} | 0 .../{completer.jest.ts => completer.test.ts} | 0 ...{datasource.jest.ts => datasource.test.ts} | 0 ...uery.jest.ts => metric_find_query.test.ts} | 0 ...mer.jest.ts => result_transformer.test.ts} | 0 ...lign_yaxes.jest.ts => align_yaxes.test.ts} | 0 ...ocessor.jest.ts => data_processor.test.ts} | 0 .../specs/{graph.jest.ts => graph.test.ts} | 0 ...{graph_ctrl.jest.ts => graph_ctrl.test.ts} | 0 ..._tooltip.jest.ts => graph_tooltip.test.ts} | 0 .../{histogram.jest.ts => histogram.test.ts} | 0 ...l.jest.ts => series_override_ctrl.test.ts} | 0 ...ager.jest.ts => threshold_manager.test.ts} | 0 ...tmap_ctrl.jest.ts => heatmap_ctrl.test.ts} | 0 ...jest.ts => heatmap_data_converter.test.ts} | 0 ...{singlestat.jest.ts => singlestat.test.ts} | 0 ...panel.jest.ts => singlestat_panel.test.ts} | 0 .../{renderer.jest.ts => renderer.test.ts} | 0 ...nsformers.jest.ts => transformers.test.ts} | 0 ...stStore.jest.ts => AlertListStore.test.ts} | 0 .../{NavStore.jest.ts => NavStore.test.ts} | 0 ...Store.jest.ts => PermissionsStore.test.ts} | 0 .../{ViewStore.jest.ts => ViewStore.test.ts} | 0 .../{version_jest.ts => version_test.ts} | 0 126 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 karma.conf.js rename public/app/containers/AlertRuleList/{AlertRuleList.jest.tsx => AlertRuleList.test.tsx} (100%) rename public/app/containers/AlertRuleList/__snapshots__/{AlertRuleList.jest.tsx.snap => AlertRuleList.test.tsx.snap} (100%) rename public/app/containers/Explore/{PromQueryField.jest.tsx => PromQueryField.test.tsx} (100%) rename public/app/containers/Explore/{TimePicker.jest.tsx => TimePicker.test.tsx} (100%) rename public/app/containers/Explore/slate-plugins/{braces.jest.ts => braces.test.ts} (100%) rename public/app/containers/Explore/slate-plugins/{clear.jest.ts => clear.test.ts} (100%) rename public/app/containers/Explore/utils/{prometheus.jest.ts => prometheus.test.ts} (100%) rename public/app/containers/ManageDashboards/{FolderSettings.jest.tsx => FolderSettings.test.tsx} (100%) rename public/app/containers/ServerStats/{ServerStats.jest.tsx => ServerStats.test.tsx} (100%) rename public/app/containers/ServerStats/__snapshots__/{ServerStats.jest.tsx.snap => ServerStats.test.tsx.snap} (100%) rename public/app/core/components/DeleteButton/{DeleteButton.jest.tsx => DeleteButton.test.tsx} (100%) rename public/app/core/components/EmptyListCTA/{EmptyListCTA.jest.tsx => EmptyListCTA.test.tsx} (100%) rename public/app/core/components/EmptyListCTA/__snapshots__/{EmptyListCTA.jest.tsx.snap => EmptyListCTA.test.tsx.snap} (100%) rename public/app/core/components/PageHeader/{PageHeader.jest.tsx => PageHeader.test.tsx} (100%) rename public/app/core/components/Permissions/{AddPermissions.jest.tsx => AddPermissions.test.tsx} (100%) rename public/app/core/components/Picker/{PickerOption.jest.tsx => PickerOption.test.tsx} (100%) rename public/app/core/components/Picker/{TeamPicker.jest.tsx => TeamPicker.test.tsx} (100%) rename public/app/core/components/Picker/{UserPicker.jest.tsx => UserPicker.test.tsx} (100%) rename public/app/core/components/Picker/__snapshots__/{PickerOption.jest.tsx.snap => PickerOption.test.tsx.snap} (100%) rename public/app/core/components/Picker/__snapshots__/{TeamPicker.jest.tsx.snap => TeamPicker.test.tsx.snap} (100%) rename public/app/core/components/Picker/__snapshots__/{UserPicker.jest.tsx.snap => UserPicker.test.tsx.snap} (100%) rename public/app/core/components/Tooltip/{Popover.jest.tsx => Popover.test.tsx} (100%) rename public/app/core/components/Tooltip/{Tooltip.jest.tsx => Tooltip.test.tsx} (100%) rename public/app/core/components/Tooltip/__snapshots__/{Popover.jest.tsx.snap => Popover.test.tsx.snap} (100%) rename public/app/core/components/Tooltip/__snapshots__/{Tooltip.jest.tsx.snap => Tooltip.test.tsx.snap} (100%) rename public/app/core/specs/{ColorPalette.jest.tsx => ColorPalette.test.tsx} (100%) rename public/app/core/specs/{PasswordStrength.jest.tsx => PasswordStrength.test.tsx} (100%) rename public/app/core/specs/__snapshots__/{ColorPalette.jest.tsx.snap => ColorPalette.test.tsx.snap} (100%) rename public/app/core/specs/{backend_srv.jest.ts => backend_srv.test.ts} (100%) rename public/app/core/specs/{datemath.jest.ts => datemath.test.ts} (100%) rename public/app/core/specs/{emitter.jest.ts => emitter.test.ts} (100%) rename public/app/core/specs/{file_export.jest.ts => file_export.test.ts} (100%) rename public/app/core/specs/{flatten.jest.ts => flatten.test.ts} (100%) rename public/app/core/specs/{kbn.jest.ts => kbn.test.ts} (100%) rename public/app/core/specs/{location_util.jest.ts => location_util.test.ts} (100%) rename public/app/core/specs/{manage_dashboards.jest.ts => manage_dashboards.test.ts} (100%) rename public/app/core/specs/{org_switcher.jest.ts => org_switcher.test.ts} (100%) rename public/app/core/specs/{rangeutil.jest.ts => rangeutil.test.ts} (100%) rename public/app/core/specs/{search.jest.ts => search.test.ts} (100%) rename public/app/core/specs/{search_results.jest.ts => search_results.test.ts} (100%) rename public/app/core/specs/{search_srv.jest.ts => search_srv.test.ts} (100%) rename public/app/core/specs/{store.jest.ts => store.test.ts} (100%) rename public/app/core/specs/{table_model.jest.ts => table_model.test.ts} (100%) rename public/app/core/specs/{ticks.jest.ts => ticks.test.ts} (100%) rename public/app/core/specs/{time_series.jest.ts => time_series.test.ts} (100%) rename public/app/core/specs/{value_select_dropdown.jest.ts => value_select_dropdown.test.ts} (100%) rename public/app/features/alerting/specs/{threshold_mapper.jest.ts => threshold_mapper.test.ts} (100%) rename public/app/features/annotations/specs/{annotations_srv.jest.ts => annotations_srv.test.ts} (100%) rename public/app/features/annotations/specs/{annotations_srv_specs.jest.ts => annotations_srv_specs.test.ts} (100%) rename public/app/features/dashboard/specs/{AddPanelPanel.jest.tsx => AddPanelPanel.test.tsx} (100%) rename public/app/features/dashboard/specs/{DashboardRow.jest.tsx => DashboardRow.test.tsx} (100%) rename public/app/features/dashboard/specs/{change_tracker.jest.ts => change_tracker.test.ts} (100%) rename public/app/features/dashboard/specs/{dashboard_import_ctrl.jest.ts => dashboard_import_ctrl.test.ts} (100%) rename public/app/features/dashboard/specs/{dashboard_migration.jest.ts => dashboard_migration.test.ts} (100%) rename public/app/features/dashboard/specs/{dashboard_model.jest.ts => dashboard_model.test.ts} (100%) rename public/app/features/dashboard/specs/{exporter.jest.ts => exporter.test.ts} (100%) rename public/app/features/dashboard/specs/{history_ctrl.jest.ts => history_ctrl.test.ts} (100%) rename public/app/features/dashboard/specs/{history_srv.jest.ts => history_srv.test.ts} (100%) rename public/app/features/dashboard/specs/{repeat.jest.ts => repeat.test.ts} (100%) rename public/app/features/dashboard/specs/{save_as_modal.jest.ts => save_as_modal.test.ts} (100%) rename public/app/features/dashboard/specs/{save_modal.jest.ts => save_modal.test.ts} (100%) rename public/app/features/dashboard/specs/{save_provisioned_modal.jest.ts => save_provisioned_modal.test.ts} (100%) rename public/app/features/dashboard/specs/{time_srv.jest.ts => time_srv.test.ts} (100%) rename public/app/features/dashboard/specs/{viewstate_srv.jest.ts => viewstate_srv.test.ts} (100%) rename public/app/features/panel/specs/{metrics_panel_ctrl.jest.ts => metrics_panel_ctrl.test.ts} (100%) rename public/app/features/panellinks/specs/{link_srv.jest.ts => link_srv.test.ts} (100%) rename public/app/features/playlist/specs/{playlist_edit_ctrl.jest.ts => playlist_edit_ctrl.test.ts} (100%) rename public/app/features/plugins/specs/{datasource_srv.jest.ts => datasource_srv.test.ts} (100%) rename public/app/features/templating/specs/{adhoc_variable.jest.ts => adhoc_variable.test.ts} (100%) rename public/app/features/templating/specs/{editor_ctrl.jest.ts => editor_ctrl.test.ts} (100%) rename public/app/features/templating/specs/{query_variable.jest.ts => query_variable.test.ts} (100%) rename public/app/features/templating/specs/{template_srv.jest.ts => template_srv.test.ts} (100%) rename public/app/features/templating/specs/{variable.jest.ts => variable.test.ts} (100%) rename public/app/features/templating/specs/{variable_srv.jest.ts => variable_srv.test.ts} (100%) rename public/app/features/templating/specs/{variable_srv_init.jest.ts => variable_srv_init.test.ts} (100%) rename public/app/plugins/datasource/cloudwatch/specs/{datasource.jest.ts => datasource.test.ts} (100%) rename public/app/plugins/datasource/elasticsearch/specs/{datasource.jest.ts => datasource.test.ts} (100%) rename public/app/plugins/datasource/elasticsearch/specs/{elastic_response.jest.ts => elastic_response.test.ts} (100%) rename public/app/plugins/datasource/elasticsearch/specs/{index_pattern.jest.ts => index_pattern.test.ts} (100%) rename public/app/plugins/datasource/elasticsearch/specs/{query_builder.jest.ts => query_builder.test.ts} (100%) rename public/app/plugins/datasource/elasticsearch/specs/{query_def.jest.ts => query_def.test.ts} (100%) rename public/app/plugins/datasource/graphite/specs/{datasource.jest.ts => datasource.test.ts} (100%) rename public/app/plugins/datasource/graphite/specs/{gfunc.jest.ts => gfunc.test.ts} (100%) rename public/app/plugins/datasource/graphite/specs/{graphite_query.jest.ts => graphite_query.test.ts} (100%) rename public/app/plugins/datasource/graphite/specs/{lexer.jest.ts => lexer.test.ts} (100%) rename public/app/plugins/datasource/graphite/specs/{parser.jest.ts => parser.test.ts} (100%) rename public/app/plugins/datasource/graphite/specs/{query_ctrl.jest.ts => query_ctrl.test.ts} (100%) rename public/app/plugins/datasource/influxdb/specs/{influx_query.jest.ts => influx_query.test.ts} (100%) rename public/app/plugins/datasource/influxdb/specs/{influx_series.jest.ts => influx_series.test.ts} (100%) rename public/app/plugins/datasource/influxdb/specs/{query_builder.jest.ts => query_builder.test.ts} (100%) rename public/app/plugins/datasource/influxdb/specs/{query_ctrl.jest.ts => query_ctrl.test.ts} (100%) rename public/app/plugins/datasource/influxdb/specs/{query_part.jest.ts => query_part.test.ts} (100%) rename public/app/plugins/datasource/influxdb/specs/{response_parser.jest.ts => response_parser.test.ts} (100%) rename public/app/plugins/datasource/logging/{datasource.jest.ts => datasource.test.ts} (100%) rename public/app/plugins/datasource/logging/{result_transformer.jest.ts => result_transformer.test.ts} (100%) rename public/app/plugins/datasource/mssql/specs/{datasource.jest.ts => datasource.test.ts} (100%) rename public/app/plugins/datasource/mysql/specs/{datasource.jest.ts => datasource.test.ts} (100%) rename public/app/plugins/datasource/opentsdb/specs/{datasource.jest.ts => datasource.test.ts} (100%) rename public/app/plugins/datasource/opentsdb/specs/{query_ctrl.jest.ts => query_ctrl.test.ts} (100%) rename public/app/plugins/datasource/postgres/specs/{datasource.jest.ts => datasource.test.ts} (100%) rename public/app/plugins/datasource/prometheus/specs/{completer.jest.ts => completer.test.ts} (100%) rename public/app/plugins/datasource/prometheus/specs/{datasource.jest.ts => datasource.test.ts} (100%) rename public/app/plugins/datasource/prometheus/specs/{metric_find_query.jest.ts => metric_find_query.test.ts} (100%) rename public/app/plugins/datasource/prometheus/specs/{result_transformer.jest.ts => result_transformer.test.ts} (100%) rename public/app/plugins/panel/graph/specs/{align_yaxes.jest.ts => align_yaxes.test.ts} (100%) rename public/app/plugins/panel/graph/specs/{data_processor.jest.ts => data_processor.test.ts} (100%) rename public/app/plugins/panel/graph/specs/{graph.jest.ts => graph.test.ts} (100%) rename public/app/plugins/panel/graph/specs/{graph_ctrl.jest.ts => graph_ctrl.test.ts} (100%) rename public/app/plugins/panel/graph/specs/{graph_tooltip.jest.ts => graph_tooltip.test.ts} (100%) rename public/app/plugins/panel/graph/specs/{histogram.jest.ts => histogram.test.ts} (100%) rename public/app/plugins/panel/graph/specs/{series_override_ctrl.jest.ts => series_override_ctrl.test.ts} (100%) rename public/app/plugins/panel/graph/specs/{threshold_manager.jest.ts => threshold_manager.test.ts} (100%) rename public/app/plugins/panel/heatmap/specs/{heatmap_ctrl.jest.ts => heatmap_ctrl.test.ts} (100%) rename public/app/plugins/panel/heatmap/specs/{heatmap_data_converter.jest.ts => heatmap_data_converter.test.ts} (100%) rename public/app/plugins/panel/singlestat/specs/{singlestat.jest.ts => singlestat.test.ts} (100%) rename public/app/plugins/panel/singlestat/specs/{singlestat_panel.jest.ts => singlestat_panel.test.ts} (100%) rename public/app/plugins/panel/table/specs/{renderer.jest.ts => renderer.test.ts} (100%) rename public/app/plugins/panel/table/specs/{transformers.jest.ts => transformers.test.ts} (100%) rename public/app/stores/AlertListStore/{AlertListStore.jest.ts => AlertListStore.test.ts} (100%) rename public/app/stores/NavStore/{NavStore.jest.ts => NavStore.test.ts} (100%) rename public/app/stores/PermissionsStore/{PermissionsStore.jest.ts => PermissionsStore.test.ts} (100%) rename public/app/stores/ViewStore/{ViewStore.jest.ts => ViewStore.test.ts} (100%) rename public/test/core/utils/{version_jest.ts => version_test.ts} (100%) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f0f4e19bfc3..14c6c07ab16 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -7,7 +7,7 @@ grunt && grunt watch ### Rerun tests on source change ``` -npm jest +npm run jest ``` or ``` diff --git a/jest.config.js b/jest.config.js index 606465c9840..a5cd3416f75 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,7 +13,7 @@ module.exports = { "roots": [ "/public" ], - "testRegex": "(\\.|/)(jest)\\.(jsx?|tsx?)$", + "testRegex": "(\\.|/)(test)\\.(jsx?|tsx?)$", "moduleFileExtensions": [ "ts", "tsx", diff --git a/karma.conf.js b/karma.conf.js deleted file mode 100644 index 352e8e4e027..00000000000 --- a/karma.conf.js +++ /dev/null @@ -1,40 +0,0 @@ -var webpack = require('webpack'); -var path = require('path'); -var webpackTestConfig = require('./scripts/webpack/webpack.test.js'); - -module.exports = function(config) { - - 'use strict'; - - config.set({ - frameworks: ['mocha', 'expect', 'sinon'], - - // list of files / patterns to load in the browser - files: [ - { pattern: 'public/test/index.ts', watched: false } - ], - - preprocessors: { - 'public/test/index.ts': ['webpack', 'sourcemap'], - }, - - webpack: webpackTestConfig, - webpackMiddleware: { - stats: 'minimal', - }, - - // list of files to exclude - exclude: [], - reporters: ['dots'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, - browsers: ['PhantomJS'], - captureTimeout: 20000, - singleRun: true, - // autoWatchBatchDelay: 1000, - // browserNoActivityTimeout: 60000, - }); - -}; diff --git a/public/app/containers/AlertRuleList/AlertRuleList.jest.tsx b/public/app/containers/AlertRuleList/AlertRuleList.test.tsx similarity index 100% rename from public/app/containers/AlertRuleList/AlertRuleList.jest.tsx rename to public/app/containers/AlertRuleList/AlertRuleList.test.tsx diff --git a/public/app/containers/AlertRuleList/__snapshots__/AlertRuleList.jest.tsx.snap b/public/app/containers/AlertRuleList/__snapshots__/AlertRuleList.test.tsx.snap similarity index 100% rename from public/app/containers/AlertRuleList/__snapshots__/AlertRuleList.jest.tsx.snap rename to public/app/containers/AlertRuleList/__snapshots__/AlertRuleList.test.tsx.snap diff --git a/public/app/containers/Explore/PromQueryField.jest.tsx b/public/app/containers/Explore/PromQueryField.test.tsx similarity index 100% rename from public/app/containers/Explore/PromQueryField.jest.tsx rename to public/app/containers/Explore/PromQueryField.test.tsx diff --git a/public/app/containers/Explore/TimePicker.jest.tsx b/public/app/containers/Explore/TimePicker.test.tsx similarity index 100% rename from public/app/containers/Explore/TimePicker.jest.tsx rename to public/app/containers/Explore/TimePicker.test.tsx diff --git a/public/app/containers/Explore/slate-plugins/braces.jest.ts b/public/app/containers/Explore/slate-plugins/braces.test.ts similarity index 100% rename from public/app/containers/Explore/slate-plugins/braces.jest.ts rename to public/app/containers/Explore/slate-plugins/braces.test.ts diff --git a/public/app/containers/Explore/slate-plugins/clear.jest.ts b/public/app/containers/Explore/slate-plugins/clear.test.ts similarity index 100% rename from public/app/containers/Explore/slate-plugins/clear.jest.ts rename to public/app/containers/Explore/slate-plugins/clear.test.ts diff --git a/public/app/containers/Explore/utils/prometheus.jest.ts b/public/app/containers/Explore/utils/prometheus.test.ts similarity index 100% rename from public/app/containers/Explore/utils/prometheus.jest.ts rename to public/app/containers/Explore/utils/prometheus.test.ts diff --git a/public/app/containers/ManageDashboards/FolderSettings.jest.tsx b/public/app/containers/ManageDashboards/FolderSettings.test.tsx similarity index 100% rename from public/app/containers/ManageDashboards/FolderSettings.jest.tsx rename to public/app/containers/ManageDashboards/FolderSettings.test.tsx diff --git a/public/app/containers/ServerStats/ServerStats.jest.tsx b/public/app/containers/ServerStats/ServerStats.test.tsx similarity index 100% rename from public/app/containers/ServerStats/ServerStats.jest.tsx rename to public/app/containers/ServerStats/ServerStats.test.tsx diff --git a/public/app/containers/ServerStats/__snapshots__/ServerStats.jest.tsx.snap b/public/app/containers/ServerStats/__snapshots__/ServerStats.test.tsx.snap similarity index 100% rename from public/app/containers/ServerStats/__snapshots__/ServerStats.jest.tsx.snap rename to public/app/containers/ServerStats/__snapshots__/ServerStats.test.tsx.snap diff --git a/public/app/core/components/DeleteButton/DeleteButton.jest.tsx b/public/app/core/components/DeleteButton/DeleteButton.test.tsx similarity index 100% rename from public/app/core/components/DeleteButton/DeleteButton.jest.tsx rename to public/app/core/components/DeleteButton/DeleteButton.test.tsx diff --git a/public/app/core/components/EmptyListCTA/EmptyListCTA.jest.tsx b/public/app/core/components/EmptyListCTA/EmptyListCTA.test.tsx similarity index 100% rename from public/app/core/components/EmptyListCTA/EmptyListCTA.jest.tsx rename to public/app/core/components/EmptyListCTA/EmptyListCTA.test.tsx diff --git a/public/app/core/components/EmptyListCTA/__snapshots__/EmptyListCTA.jest.tsx.snap b/public/app/core/components/EmptyListCTA/__snapshots__/EmptyListCTA.test.tsx.snap similarity index 100% rename from public/app/core/components/EmptyListCTA/__snapshots__/EmptyListCTA.jest.tsx.snap rename to public/app/core/components/EmptyListCTA/__snapshots__/EmptyListCTA.test.tsx.snap diff --git a/public/app/core/components/PageHeader/PageHeader.jest.tsx b/public/app/core/components/PageHeader/PageHeader.test.tsx similarity index 100% rename from public/app/core/components/PageHeader/PageHeader.jest.tsx rename to public/app/core/components/PageHeader/PageHeader.test.tsx diff --git a/public/app/core/components/Permissions/AddPermissions.jest.tsx b/public/app/core/components/Permissions/AddPermissions.test.tsx similarity index 100% rename from public/app/core/components/Permissions/AddPermissions.jest.tsx rename to public/app/core/components/Permissions/AddPermissions.test.tsx diff --git a/public/app/core/components/Picker/PickerOption.jest.tsx b/public/app/core/components/Picker/PickerOption.test.tsx similarity index 100% rename from public/app/core/components/Picker/PickerOption.jest.tsx rename to public/app/core/components/Picker/PickerOption.test.tsx diff --git a/public/app/core/components/Picker/TeamPicker.jest.tsx b/public/app/core/components/Picker/TeamPicker.test.tsx similarity index 100% rename from public/app/core/components/Picker/TeamPicker.jest.tsx rename to public/app/core/components/Picker/TeamPicker.test.tsx diff --git a/public/app/core/components/Picker/UserPicker.jest.tsx b/public/app/core/components/Picker/UserPicker.test.tsx similarity index 100% rename from public/app/core/components/Picker/UserPicker.jest.tsx rename to public/app/core/components/Picker/UserPicker.test.tsx diff --git a/public/app/core/components/Picker/__snapshots__/PickerOption.jest.tsx.snap b/public/app/core/components/Picker/__snapshots__/PickerOption.test.tsx.snap similarity index 100% rename from public/app/core/components/Picker/__snapshots__/PickerOption.jest.tsx.snap rename to public/app/core/components/Picker/__snapshots__/PickerOption.test.tsx.snap diff --git a/public/app/core/components/Picker/__snapshots__/TeamPicker.jest.tsx.snap b/public/app/core/components/Picker/__snapshots__/TeamPicker.test.tsx.snap similarity index 100% rename from public/app/core/components/Picker/__snapshots__/TeamPicker.jest.tsx.snap rename to public/app/core/components/Picker/__snapshots__/TeamPicker.test.tsx.snap diff --git a/public/app/core/components/Picker/__snapshots__/UserPicker.jest.tsx.snap b/public/app/core/components/Picker/__snapshots__/UserPicker.test.tsx.snap similarity index 100% rename from public/app/core/components/Picker/__snapshots__/UserPicker.jest.tsx.snap rename to public/app/core/components/Picker/__snapshots__/UserPicker.test.tsx.snap diff --git a/public/app/core/components/Tooltip/Popover.jest.tsx b/public/app/core/components/Tooltip/Popover.test.tsx similarity index 100% rename from public/app/core/components/Tooltip/Popover.jest.tsx rename to public/app/core/components/Tooltip/Popover.test.tsx diff --git a/public/app/core/components/Tooltip/Tooltip.jest.tsx b/public/app/core/components/Tooltip/Tooltip.test.tsx similarity index 100% rename from public/app/core/components/Tooltip/Tooltip.jest.tsx rename to public/app/core/components/Tooltip/Tooltip.test.tsx diff --git a/public/app/core/components/Tooltip/__snapshots__/Popover.jest.tsx.snap b/public/app/core/components/Tooltip/__snapshots__/Popover.test.tsx.snap similarity index 100% rename from public/app/core/components/Tooltip/__snapshots__/Popover.jest.tsx.snap rename to public/app/core/components/Tooltip/__snapshots__/Popover.test.tsx.snap diff --git a/public/app/core/components/Tooltip/__snapshots__/Tooltip.jest.tsx.snap b/public/app/core/components/Tooltip/__snapshots__/Tooltip.test.tsx.snap similarity index 100% rename from public/app/core/components/Tooltip/__snapshots__/Tooltip.jest.tsx.snap rename to public/app/core/components/Tooltip/__snapshots__/Tooltip.test.tsx.snap diff --git a/public/app/core/specs/ColorPalette.jest.tsx b/public/app/core/specs/ColorPalette.test.tsx similarity index 100% rename from public/app/core/specs/ColorPalette.jest.tsx rename to public/app/core/specs/ColorPalette.test.tsx diff --git a/public/app/core/specs/PasswordStrength.jest.tsx b/public/app/core/specs/PasswordStrength.test.tsx similarity index 100% rename from public/app/core/specs/PasswordStrength.jest.tsx rename to public/app/core/specs/PasswordStrength.test.tsx diff --git a/public/app/core/specs/__snapshots__/ColorPalette.jest.tsx.snap b/public/app/core/specs/__snapshots__/ColorPalette.test.tsx.snap similarity index 100% rename from public/app/core/specs/__snapshots__/ColorPalette.jest.tsx.snap rename to public/app/core/specs/__snapshots__/ColorPalette.test.tsx.snap diff --git a/public/app/core/specs/backend_srv.jest.ts b/public/app/core/specs/backend_srv.test.ts similarity index 100% rename from public/app/core/specs/backend_srv.jest.ts rename to public/app/core/specs/backend_srv.test.ts diff --git a/public/app/core/specs/datemath.jest.ts b/public/app/core/specs/datemath.test.ts similarity index 100% rename from public/app/core/specs/datemath.jest.ts rename to public/app/core/specs/datemath.test.ts diff --git a/public/app/core/specs/emitter.jest.ts b/public/app/core/specs/emitter.test.ts similarity index 100% rename from public/app/core/specs/emitter.jest.ts rename to public/app/core/specs/emitter.test.ts diff --git a/public/app/core/specs/file_export.jest.ts b/public/app/core/specs/file_export.test.ts similarity index 100% rename from public/app/core/specs/file_export.jest.ts rename to public/app/core/specs/file_export.test.ts diff --git a/public/app/core/specs/flatten.jest.ts b/public/app/core/specs/flatten.test.ts similarity index 100% rename from public/app/core/specs/flatten.jest.ts rename to public/app/core/specs/flatten.test.ts diff --git a/public/app/core/specs/kbn.jest.ts b/public/app/core/specs/kbn.test.ts similarity index 100% rename from public/app/core/specs/kbn.jest.ts rename to public/app/core/specs/kbn.test.ts diff --git a/public/app/core/specs/location_util.jest.ts b/public/app/core/specs/location_util.test.ts similarity index 100% rename from public/app/core/specs/location_util.jest.ts rename to public/app/core/specs/location_util.test.ts diff --git a/public/app/core/specs/manage_dashboards.jest.ts b/public/app/core/specs/manage_dashboards.test.ts similarity index 100% rename from public/app/core/specs/manage_dashboards.jest.ts rename to public/app/core/specs/manage_dashboards.test.ts diff --git a/public/app/core/specs/org_switcher.jest.ts b/public/app/core/specs/org_switcher.test.ts similarity index 100% rename from public/app/core/specs/org_switcher.jest.ts rename to public/app/core/specs/org_switcher.test.ts diff --git a/public/app/core/specs/rangeutil.jest.ts b/public/app/core/specs/rangeutil.test.ts similarity index 100% rename from public/app/core/specs/rangeutil.jest.ts rename to public/app/core/specs/rangeutil.test.ts diff --git a/public/app/core/specs/search.jest.ts b/public/app/core/specs/search.test.ts similarity index 100% rename from public/app/core/specs/search.jest.ts rename to public/app/core/specs/search.test.ts diff --git a/public/app/core/specs/search_results.jest.ts b/public/app/core/specs/search_results.test.ts similarity index 100% rename from public/app/core/specs/search_results.jest.ts rename to public/app/core/specs/search_results.test.ts diff --git a/public/app/core/specs/search_srv.jest.ts b/public/app/core/specs/search_srv.test.ts similarity index 100% rename from public/app/core/specs/search_srv.jest.ts rename to public/app/core/specs/search_srv.test.ts diff --git a/public/app/core/specs/store.jest.ts b/public/app/core/specs/store.test.ts similarity index 100% rename from public/app/core/specs/store.jest.ts rename to public/app/core/specs/store.test.ts diff --git a/public/app/core/specs/table_model.jest.ts b/public/app/core/specs/table_model.test.ts similarity index 100% rename from public/app/core/specs/table_model.jest.ts rename to public/app/core/specs/table_model.test.ts diff --git a/public/app/core/specs/ticks.jest.ts b/public/app/core/specs/ticks.test.ts similarity index 100% rename from public/app/core/specs/ticks.jest.ts rename to public/app/core/specs/ticks.test.ts diff --git a/public/app/core/specs/time_series.jest.ts b/public/app/core/specs/time_series.test.ts similarity index 100% rename from public/app/core/specs/time_series.jest.ts rename to public/app/core/specs/time_series.test.ts diff --git a/public/app/core/specs/value_select_dropdown.jest.ts b/public/app/core/specs/value_select_dropdown.test.ts similarity index 100% rename from public/app/core/specs/value_select_dropdown.jest.ts rename to public/app/core/specs/value_select_dropdown.test.ts diff --git a/public/app/features/alerting/specs/threshold_mapper.jest.ts b/public/app/features/alerting/specs/threshold_mapper.test.ts similarity index 100% rename from public/app/features/alerting/specs/threshold_mapper.jest.ts rename to public/app/features/alerting/specs/threshold_mapper.test.ts diff --git a/public/app/features/annotations/specs/annotations_srv.jest.ts b/public/app/features/annotations/specs/annotations_srv.test.ts similarity index 100% rename from public/app/features/annotations/specs/annotations_srv.jest.ts rename to public/app/features/annotations/specs/annotations_srv.test.ts diff --git a/public/app/features/annotations/specs/annotations_srv_specs.jest.ts b/public/app/features/annotations/specs/annotations_srv_specs.test.ts similarity index 100% rename from public/app/features/annotations/specs/annotations_srv_specs.jest.ts rename to public/app/features/annotations/specs/annotations_srv_specs.test.ts diff --git a/public/app/features/dashboard/specs/AddPanelPanel.jest.tsx b/public/app/features/dashboard/specs/AddPanelPanel.test.tsx similarity index 100% rename from public/app/features/dashboard/specs/AddPanelPanel.jest.tsx rename to public/app/features/dashboard/specs/AddPanelPanel.test.tsx diff --git a/public/app/features/dashboard/specs/DashboardRow.jest.tsx b/public/app/features/dashboard/specs/DashboardRow.test.tsx similarity index 100% rename from public/app/features/dashboard/specs/DashboardRow.jest.tsx rename to public/app/features/dashboard/specs/DashboardRow.test.tsx diff --git a/public/app/features/dashboard/specs/change_tracker.jest.ts b/public/app/features/dashboard/specs/change_tracker.test.ts similarity index 100% rename from public/app/features/dashboard/specs/change_tracker.jest.ts rename to public/app/features/dashboard/specs/change_tracker.test.ts diff --git a/public/app/features/dashboard/specs/dashboard_import_ctrl.jest.ts b/public/app/features/dashboard/specs/dashboard_import_ctrl.test.ts similarity index 100% rename from public/app/features/dashboard/specs/dashboard_import_ctrl.jest.ts rename to public/app/features/dashboard/specs/dashboard_import_ctrl.test.ts diff --git a/public/app/features/dashboard/specs/dashboard_migration.jest.ts b/public/app/features/dashboard/specs/dashboard_migration.test.ts similarity index 100% rename from public/app/features/dashboard/specs/dashboard_migration.jest.ts rename to public/app/features/dashboard/specs/dashboard_migration.test.ts diff --git a/public/app/features/dashboard/specs/dashboard_model.jest.ts b/public/app/features/dashboard/specs/dashboard_model.test.ts similarity index 100% rename from public/app/features/dashboard/specs/dashboard_model.jest.ts rename to public/app/features/dashboard/specs/dashboard_model.test.ts diff --git a/public/app/features/dashboard/specs/exporter.jest.ts b/public/app/features/dashboard/specs/exporter.test.ts similarity index 100% rename from public/app/features/dashboard/specs/exporter.jest.ts rename to public/app/features/dashboard/specs/exporter.test.ts diff --git a/public/app/features/dashboard/specs/history_ctrl.jest.ts b/public/app/features/dashboard/specs/history_ctrl.test.ts similarity index 100% rename from public/app/features/dashboard/specs/history_ctrl.jest.ts rename to public/app/features/dashboard/specs/history_ctrl.test.ts diff --git a/public/app/features/dashboard/specs/history_srv.jest.ts b/public/app/features/dashboard/specs/history_srv.test.ts similarity index 100% rename from public/app/features/dashboard/specs/history_srv.jest.ts rename to public/app/features/dashboard/specs/history_srv.test.ts diff --git a/public/app/features/dashboard/specs/repeat.jest.ts b/public/app/features/dashboard/specs/repeat.test.ts similarity index 100% rename from public/app/features/dashboard/specs/repeat.jest.ts rename to public/app/features/dashboard/specs/repeat.test.ts diff --git a/public/app/features/dashboard/specs/save_as_modal.jest.ts b/public/app/features/dashboard/specs/save_as_modal.test.ts similarity index 100% rename from public/app/features/dashboard/specs/save_as_modal.jest.ts rename to public/app/features/dashboard/specs/save_as_modal.test.ts diff --git a/public/app/features/dashboard/specs/save_modal.jest.ts b/public/app/features/dashboard/specs/save_modal.test.ts similarity index 100% rename from public/app/features/dashboard/specs/save_modal.jest.ts rename to public/app/features/dashboard/specs/save_modal.test.ts diff --git a/public/app/features/dashboard/specs/save_provisioned_modal.jest.ts b/public/app/features/dashboard/specs/save_provisioned_modal.test.ts similarity index 100% rename from public/app/features/dashboard/specs/save_provisioned_modal.jest.ts rename to public/app/features/dashboard/specs/save_provisioned_modal.test.ts diff --git a/public/app/features/dashboard/specs/time_srv.jest.ts b/public/app/features/dashboard/specs/time_srv.test.ts similarity index 100% rename from public/app/features/dashboard/specs/time_srv.jest.ts rename to public/app/features/dashboard/specs/time_srv.test.ts diff --git a/public/app/features/dashboard/specs/viewstate_srv.jest.ts b/public/app/features/dashboard/specs/viewstate_srv.test.ts similarity index 100% rename from public/app/features/dashboard/specs/viewstate_srv.jest.ts rename to public/app/features/dashboard/specs/viewstate_srv.test.ts diff --git a/public/app/features/panel/specs/metrics_panel_ctrl.jest.ts b/public/app/features/panel/specs/metrics_panel_ctrl.test.ts similarity index 100% rename from public/app/features/panel/specs/metrics_panel_ctrl.jest.ts rename to public/app/features/panel/specs/metrics_panel_ctrl.test.ts diff --git a/public/app/features/panellinks/specs/link_srv.jest.ts b/public/app/features/panellinks/specs/link_srv.test.ts similarity index 100% rename from public/app/features/panellinks/specs/link_srv.jest.ts rename to public/app/features/panellinks/specs/link_srv.test.ts diff --git a/public/app/features/playlist/specs/playlist_edit_ctrl.jest.ts b/public/app/features/playlist/specs/playlist_edit_ctrl.test.ts similarity index 100% rename from public/app/features/playlist/specs/playlist_edit_ctrl.jest.ts rename to public/app/features/playlist/specs/playlist_edit_ctrl.test.ts diff --git a/public/app/features/plugins/specs/datasource_srv.jest.ts b/public/app/features/plugins/specs/datasource_srv.test.ts similarity index 100% rename from public/app/features/plugins/specs/datasource_srv.jest.ts rename to public/app/features/plugins/specs/datasource_srv.test.ts diff --git a/public/app/features/templating/specs/adhoc_variable.jest.ts b/public/app/features/templating/specs/adhoc_variable.test.ts similarity index 100% rename from public/app/features/templating/specs/adhoc_variable.jest.ts rename to public/app/features/templating/specs/adhoc_variable.test.ts diff --git a/public/app/features/templating/specs/editor_ctrl.jest.ts b/public/app/features/templating/specs/editor_ctrl.test.ts similarity index 100% rename from public/app/features/templating/specs/editor_ctrl.jest.ts rename to public/app/features/templating/specs/editor_ctrl.test.ts diff --git a/public/app/features/templating/specs/query_variable.jest.ts b/public/app/features/templating/specs/query_variable.test.ts similarity index 100% rename from public/app/features/templating/specs/query_variable.jest.ts rename to public/app/features/templating/specs/query_variable.test.ts diff --git a/public/app/features/templating/specs/template_srv.jest.ts b/public/app/features/templating/specs/template_srv.test.ts similarity index 100% rename from public/app/features/templating/specs/template_srv.jest.ts rename to public/app/features/templating/specs/template_srv.test.ts diff --git a/public/app/features/templating/specs/variable.jest.ts b/public/app/features/templating/specs/variable.test.ts similarity index 100% rename from public/app/features/templating/specs/variable.jest.ts rename to public/app/features/templating/specs/variable.test.ts diff --git a/public/app/features/templating/specs/variable_srv.jest.ts b/public/app/features/templating/specs/variable_srv.test.ts similarity index 100% rename from public/app/features/templating/specs/variable_srv.jest.ts rename to public/app/features/templating/specs/variable_srv.test.ts diff --git a/public/app/features/templating/specs/variable_srv_init.jest.ts b/public/app/features/templating/specs/variable_srv_init.test.ts similarity index 100% rename from public/app/features/templating/specs/variable_srv_init.jest.ts rename to public/app/features/templating/specs/variable_srv_init.test.ts diff --git a/public/app/plugins/datasource/cloudwatch/specs/datasource.jest.ts b/public/app/plugins/datasource/cloudwatch/specs/datasource.test.ts similarity index 100% rename from public/app/plugins/datasource/cloudwatch/specs/datasource.jest.ts rename to public/app/plugins/datasource/cloudwatch/specs/datasource.test.ts diff --git a/public/app/plugins/datasource/elasticsearch/specs/datasource.jest.ts b/public/app/plugins/datasource/elasticsearch/specs/datasource.test.ts similarity index 100% rename from public/app/plugins/datasource/elasticsearch/specs/datasource.jest.ts rename to public/app/plugins/datasource/elasticsearch/specs/datasource.test.ts diff --git a/public/app/plugins/datasource/elasticsearch/specs/elastic_response.jest.ts b/public/app/plugins/datasource/elasticsearch/specs/elastic_response.test.ts similarity index 100% rename from public/app/plugins/datasource/elasticsearch/specs/elastic_response.jest.ts rename to public/app/plugins/datasource/elasticsearch/specs/elastic_response.test.ts diff --git a/public/app/plugins/datasource/elasticsearch/specs/index_pattern.jest.ts b/public/app/plugins/datasource/elasticsearch/specs/index_pattern.test.ts similarity index 100% rename from public/app/plugins/datasource/elasticsearch/specs/index_pattern.jest.ts rename to public/app/plugins/datasource/elasticsearch/specs/index_pattern.test.ts diff --git a/public/app/plugins/datasource/elasticsearch/specs/query_builder.jest.ts b/public/app/plugins/datasource/elasticsearch/specs/query_builder.test.ts similarity index 100% rename from public/app/plugins/datasource/elasticsearch/specs/query_builder.jest.ts rename to public/app/plugins/datasource/elasticsearch/specs/query_builder.test.ts diff --git a/public/app/plugins/datasource/elasticsearch/specs/query_def.jest.ts b/public/app/plugins/datasource/elasticsearch/specs/query_def.test.ts similarity index 100% rename from public/app/plugins/datasource/elasticsearch/specs/query_def.jest.ts rename to public/app/plugins/datasource/elasticsearch/specs/query_def.test.ts diff --git a/public/app/plugins/datasource/graphite/specs/datasource.jest.ts b/public/app/plugins/datasource/graphite/specs/datasource.test.ts similarity index 100% rename from public/app/plugins/datasource/graphite/specs/datasource.jest.ts rename to public/app/plugins/datasource/graphite/specs/datasource.test.ts diff --git a/public/app/plugins/datasource/graphite/specs/gfunc.jest.ts b/public/app/plugins/datasource/graphite/specs/gfunc.test.ts similarity index 100% rename from public/app/plugins/datasource/graphite/specs/gfunc.jest.ts rename to public/app/plugins/datasource/graphite/specs/gfunc.test.ts diff --git a/public/app/plugins/datasource/graphite/specs/graphite_query.jest.ts b/public/app/plugins/datasource/graphite/specs/graphite_query.test.ts similarity index 100% rename from public/app/plugins/datasource/graphite/specs/graphite_query.jest.ts rename to public/app/plugins/datasource/graphite/specs/graphite_query.test.ts diff --git a/public/app/plugins/datasource/graphite/specs/lexer.jest.ts b/public/app/plugins/datasource/graphite/specs/lexer.test.ts similarity index 100% rename from public/app/plugins/datasource/graphite/specs/lexer.jest.ts rename to public/app/plugins/datasource/graphite/specs/lexer.test.ts diff --git a/public/app/plugins/datasource/graphite/specs/parser.jest.ts b/public/app/plugins/datasource/graphite/specs/parser.test.ts similarity index 100% rename from public/app/plugins/datasource/graphite/specs/parser.jest.ts rename to public/app/plugins/datasource/graphite/specs/parser.test.ts diff --git a/public/app/plugins/datasource/graphite/specs/query_ctrl.jest.ts b/public/app/plugins/datasource/graphite/specs/query_ctrl.test.ts similarity index 100% rename from public/app/plugins/datasource/graphite/specs/query_ctrl.jest.ts rename to public/app/plugins/datasource/graphite/specs/query_ctrl.test.ts diff --git a/public/app/plugins/datasource/influxdb/specs/influx_query.jest.ts b/public/app/plugins/datasource/influxdb/specs/influx_query.test.ts similarity index 100% rename from public/app/plugins/datasource/influxdb/specs/influx_query.jest.ts rename to public/app/plugins/datasource/influxdb/specs/influx_query.test.ts diff --git a/public/app/plugins/datasource/influxdb/specs/influx_series.jest.ts b/public/app/plugins/datasource/influxdb/specs/influx_series.test.ts similarity index 100% rename from public/app/plugins/datasource/influxdb/specs/influx_series.jest.ts rename to public/app/plugins/datasource/influxdb/specs/influx_series.test.ts diff --git a/public/app/plugins/datasource/influxdb/specs/query_builder.jest.ts b/public/app/plugins/datasource/influxdb/specs/query_builder.test.ts similarity index 100% rename from public/app/plugins/datasource/influxdb/specs/query_builder.jest.ts rename to public/app/plugins/datasource/influxdb/specs/query_builder.test.ts diff --git a/public/app/plugins/datasource/influxdb/specs/query_ctrl.jest.ts b/public/app/plugins/datasource/influxdb/specs/query_ctrl.test.ts similarity index 100% rename from public/app/plugins/datasource/influxdb/specs/query_ctrl.jest.ts rename to public/app/plugins/datasource/influxdb/specs/query_ctrl.test.ts diff --git a/public/app/plugins/datasource/influxdb/specs/query_part.jest.ts b/public/app/plugins/datasource/influxdb/specs/query_part.test.ts similarity index 100% rename from public/app/plugins/datasource/influxdb/specs/query_part.jest.ts rename to public/app/plugins/datasource/influxdb/specs/query_part.test.ts diff --git a/public/app/plugins/datasource/influxdb/specs/response_parser.jest.ts b/public/app/plugins/datasource/influxdb/specs/response_parser.test.ts similarity index 100% rename from public/app/plugins/datasource/influxdb/specs/response_parser.jest.ts rename to public/app/plugins/datasource/influxdb/specs/response_parser.test.ts diff --git a/public/app/plugins/datasource/logging/datasource.jest.ts b/public/app/plugins/datasource/logging/datasource.test.ts similarity index 100% rename from public/app/plugins/datasource/logging/datasource.jest.ts rename to public/app/plugins/datasource/logging/datasource.test.ts diff --git a/public/app/plugins/datasource/logging/result_transformer.jest.ts b/public/app/plugins/datasource/logging/result_transformer.test.ts similarity index 100% rename from public/app/plugins/datasource/logging/result_transformer.jest.ts rename to public/app/plugins/datasource/logging/result_transformer.test.ts diff --git a/public/app/plugins/datasource/mssql/specs/datasource.jest.ts b/public/app/plugins/datasource/mssql/specs/datasource.test.ts similarity index 100% rename from public/app/plugins/datasource/mssql/specs/datasource.jest.ts rename to public/app/plugins/datasource/mssql/specs/datasource.test.ts diff --git a/public/app/plugins/datasource/mysql/specs/datasource.jest.ts b/public/app/plugins/datasource/mysql/specs/datasource.test.ts similarity index 100% rename from public/app/plugins/datasource/mysql/specs/datasource.jest.ts rename to public/app/plugins/datasource/mysql/specs/datasource.test.ts diff --git a/public/app/plugins/datasource/opentsdb/specs/datasource.jest.ts b/public/app/plugins/datasource/opentsdb/specs/datasource.test.ts similarity index 100% rename from public/app/plugins/datasource/opentsdb/specs/datasource.jest.ts rename to public/app/plugins/datasource/opentsdb/specs/datasource.test.ts diff --git a/public/app/plugins/datasource/opentsdb/specs/query_ctrl.jest.ts b/public/app/plugins/datasource/opentsdb/specs/query_ctrl.test.ts similarity index 100% rename from public/app/plugins/datasource/opentsdb/specs/query_ctrl.jest.ts rename to public/app/plugins/datasource/opentsdb/specs/query_ctrl.test.ts diff --git a/public/app/plugins/datasource/postgres/specs/datasource.jest.ts b/public/app/plugins/datasource/postgres/specs/datasource.test.ts similarity index 100% rename from public/app/plugins/datasource/postgres/specs/datasource.jest.ts rename to public/app/plugins/datasource/postgres/specs/datasource.test.ts diff --git a/public/app/plugins/datasource/prometheus/specs/completer.jest.ts b/public/app/plugins/datasource/prometheus/specs/completer.test.ts similarity index 100% rename from public/app/plugins/datasource/prometheus/specs/completer.jest.ts rename to public/app/plugins/datasource/prometheus/specs/completer.test.ts diff --git a/public/app/plugins/datasource/prometheus/specs/datasource.jest.ts b/public/app/plugins/datasource/prometheus/specs/datasource.test.ts similarity index 100% rename from public/app/plugins/datasource/prometheus/specs/datasource.jest.ts rename to public/app/plugins/datasource/prometheus/specs/datasource.test.ts diff --git a/public/app/plugins/datasource/prometheus/specs/metric_find_query.jest.ts b/public/app/plugins/datasource/prometheus/specs/metric_find_query.test.ts similarity index 100% rename from public/app/plugins/datasource/prometheus/specs/metric_find_query.jest.ts rename to public/app/plugins/datasource/prometheus/specs/metric_find_query.test.ts diff --git a/public/app/plugins/datasource/prometheus/specs/result_transformer.jest.ts b/public/app/plugins/datasource/prometheus/specs/result_transformer.test.ts similarity index 100% rename from public/app/plugins/datasource/prometheus/specs/result_transformer.jest.ts rename to public/app/plugins/datasource/prometheus/specs/result_transformer.test.ts diff --git a/public/app/plugins/panel/graph/specs/align_yaxes.jest.ts b/public/app/plugins/panel/graph/specs/align_yaxes.test.ts similarity index 100% rename from public/app/plugins/panel/graph/specs/align_yaxes.jest.ts rename to public/app/plugins/panel/graph/specs/align_yaxes.test.ts diff --git a/public/app/plugins/panel/graph/specs/data_processor.jest.ts b/public/app/plugins/panel/graph/specs/data_processor.test.ts similarity index 100% rename from public/app/plugins/panel/graph/specs/data_processor.jest.ts rename to public/app/plugins/panel/graph/specs/data_processor.test.ts diff --git a/public/app/plugins/panel/graph/specs/graph.jest.ts b/public/app/plugins/panel/graph/specs/graph.test.ts similarity index 100% rename from public/app/plugins/panel/graph/specs/graph.jest.ts rename to public/app/plugins/panel/graph/specs/graph.test.ts diff --git a/public/app/plugins/panel/graph/specs/graph_ctrl.jest.ts b/public/app/plugins/panel/graph/specs/graph_ctrl.test.ts similarity index 100% rename from public/app/plugins/panel/graph/specs/graph_ctrl.jest.ts rename to public/app/plugins/panel/graph/specs/graph_ctrl.test.ts diff --git a/public/app/plugins/panel/graph/specs/graph_tooltip.jest.ts b/public/app/plugins/panel/graph/specs/graph_tooltip.test.ts similarity index 100% rename from public/app/plugins/panel/graph/specs/graph_tooltip.jest.ts rename to public/app/plugins/panel/graph/specs/graph_tooltip.test.ts diff --git a/public/app/plugins/panel/graph/specs/histogram.jest.ts b/public/app/plugins/panel/graph/specs/histogram.test.ts similarity index 100% rename from public/app/plugins/panel/graph/specs/histogram.jest.ts rename to public/app/plugins/panel/graph/specs/histogram.test.ts diff --git a/public/app/plugins/panel/graph/specs/series_override_ctrl.jest.ts b/public/app/plugins/panel/graph/specs/series_override_ctrl.test.ts similarity index 100% rename from public/app/plugins/panel/graph/specs/series_override_ctrl.jest.ts rename to public/app/plugins/panel/graph/specs/series_override_ctrl.test.ts diff --git a/public/app/plugins/panel/graph/specs/threshold_manager.jest.ts b/public/app/plugins/panel/graph/specs/threshold_manager.test.ts similarity index 100% rename from public/app/plugins/panel/graph/specs/threshold_manager.jest.ts rename to public/app/plugins/panel/graph/specs/threshold_manager.test.ts diff --git a/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.jest.ts b/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.test.ts similarity index 100% rename from public/app/plugins/panel/heatmap/specs/heatmap_ctrl.jest.ts rename to public/app/plugins/panel/heatmap/specs/heatmap_ctrl.test.ts diff --git a/public/app/plugins/panel/heatmap/specs/heatmap_data_converter.jest.ts b/public/app/plugins/panel/heatmap/specs/heatmap_data_converter.test.ts similarity index 100% rename from public/app/plugins/panel/heatmap/specs/heatmap_data_converter.jest.ts rename to public/app/plugins/panel/heatmap/specs/heatmap_data_converter.test.ts diff --git a/public/app/plugins/panel/singlestat/specs/singlestat.jest.ts b/public/app/plugins/panel/singlestat/specs/singlestat.test.ts similarity index 100% rename from public/app/plugins/panel/singlestat/specs/singlestat.jest.ts rename to public/app/plugins/panel/singlestat/specs/singlestat.test.ts diff --git a/public/app/plugins/panel/singlestat/specs/singlestat_panel.jest.ts b/public/app/plugins/panel/singlestat/specs/singlestat_panel.test.ts similarity index 100% rename from public/app/plugins/panel/singlestat/specs/singlestat_panel.jest.ts rename to public/app/plugins/panel/singlestat/specs/singlestat_panel.test.ts diff --git a/public/app/plugins/panel/table/specs/renderer.jest.ts b/public/app/plugins/panel/table/specs/renderer.test.ts similarity index 100% rename from public/app/plugins/panel/table/specs/renderer.jest.ts rename to public/app/plugins/panel/table/specs/renderer.test.ts diff --git a/public/app/plugins/panel/table/specs/transformers.jest.ts b/public/app/plugins/panel/table/specs/transformers.test.ts similarity index 100% rename from public/app/plugins/panel/table/specs/transformers.jest.ts rename to public/app/plugins/panel/table/specs/transformers.test.ts diff --git a/public/app/stores/AlertListStore/AlertListStore.jest.ts b/public/app/stores/AlertListStore/AlertListStore.test.ts similarity index 100% rename from public/app/stores/AlertListStore/AlertListStore.jest.ts rename to public/app/stores/AlertListStore/AlertListStore.test.ts diff --git a/public/app/stores/NavStore/NavStore.jest.ts b/public/app/stores/NavStore/NavStore.test.ts similarity index 100% rename from public/app/stores/NavStore/NavStore.jest.ts rename to public/app/stores/NavStore/NavStore.test.ts diff --git a/public/app/stores/PermissionsStore/PermissionsStore.jest.ts b/public/app/stores/PermissionsStore/PermissionsStore.test.ts similarity index 100% rename from public/app/stores/PermissionsStore/PermissionsStore.jest.ts rename to public/app/stores/PermissionsStore/PermissionsStore.test.ts diff --git a/public/app/stores/ViewStore/ViewStore.jest.ts b/public/app/stores/ViewStore/ViewStore.test.ts similarity index 100% rename from public/app/stores/ViewStore/ViewStore.jest.ts rename to public/app/stores/ViewStore/ViewStore.test.ts diff --git a/public/test/core/utils/version_jest.ts b/public/test/core/utils/version_test.ts similarity index 100% rename from public/test/core/utils/version_jest.ts rename to public/test/core/utils/version_test.ts From 86a27895415fa28b8850852fdbfb4ab3ff793dca Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Tue, 14 Aug 2018 11:23:55 +0200 Subject: [PATCH 61/99] Remove dependencies --- yarn.lock | 549 ++++-------------------------------------------------- 1 file changed, 33 insertions(+), 516 deletions(-) diff --git a/yarn.lock b/yarn.lock index 89e74828351..c4bd6704839 100644 --- a/yarn.lock +++ b/yarn.lock @@ -422,13 +422,6 @@ abbrev@1, abbrev@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" -accepts@1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.3.tgz#c3ca7434938648c3e0d9c1e328dd68b622c284ca" - dependencies: - mime-types "~2.1.11" - negotiator "0.6.1" - accepts@~1.3.4, accepts@~1.3.5: version "1.3.5" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.5.tgz#eb777df6011723a3b14e8a72c0805c8e86746bd2" @@ -480,10 +473,6 @@ add-dom-event-listener@1.x: dependencies: object-assign "4.x" -after@0.8.2: - version "0.8.2" - resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" - agent-base@4, agent-base@^4.1.0, agent-base@~4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.0.tgz#9838b5c3392b962bad031e6a4c5e1024abec45ce" @@ -769,10 +758,6 @@ array-reduce@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/array-reduce/-/array-reduce-0.0.0.tgz#173899d3ffd1c7d9383e4479525dbe278cab5f2b" -array-slice@^0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/array-slice/-/array-slice-0.2.3.tgz#dd3cfb80ed7973a75117cdac69b0b99ec86186f5" - array-tree-filter@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/array-tree-filter/-/array-tree-filter-1.0.1.tgz#0a8ad1eefd38ce88858632f9cc0423d7634e4d5d" @@ -795,10 +780,6 @@ array-unique@^0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" -arraybuffer.slice@0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz#f33b2159f0532a3f3107a272c0ccfbd1ad2979ca" - arrify@^1.0.0, arrify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" @@ -1520,7 +1501,7 @@ babel-register@^6.26.0, babel-register@^6.9.0: mkdirp "^0.5.1" source-map-support "^0.4.15" -babel-runtime@6.x, babel-runtime@^6.0.0, babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0, babel-runtime@^6.9.2: +babel-runtime@6.x, babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0, babel-runtime@^6.9.2: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" dependencies: @@ -1568,10 +1549,6 @@ babylon@^7.0.0-beta.47: version "7.0.0-beta.47" resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.47.tgz#6d1fa44f0abec41ab7c780481e62fd9aafbdea80" -backo2@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/backo2/-/backo2-1.0.2.tgz#31ab1ac8b129363463e35b3ebb69f4dfcfba7947" - balanced-match@^0.4.2: version "0.4.2" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" @@ -1584,18 +1561,10 @@ baron@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/baron/-/baron-3.0.3.tgz#0f0a08a567062882e130a0ecfd41a46d52103f4a" -base64-arraybuffer@0.1.5: - version "0.1.5" - resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8" - base64-js@^1.0.2: version "1.3.0" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.0.tgz#cab1e6118f051095e58b5281aea8c1cd22bfc0e3" -base64id@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/base64id/-/base64id-1.0.0.tgz#47688cb99bb6804f0e06d3e763b1c32e57d8e6b6" - base@^0.11.1: version "0.11.2" resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" @@ -1622,12 +1591,6 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" -better-assert@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/better-assert/-/better-assert-1.0.2.tgz#40866b9e1b9e0b55b481894311e68faffaebc522" - dependencies: - callsite "1.0.0" - bfj-node4@^5.2.0: version "5.3.1" resolved "https://registry.yarnpkg.com/bfj-node4/-/bfj-node4-5.3.1.tgz#e23d8b27057f1d0214fc561142ad9db998f26830" @@ -1665,17 +1628,13 @@ bl@^1.0.0: readable-stream "^2.3.5" safe-buffer "^5.1.1" -blob@0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.4.tgz#bcf13052ca54463f30f9fc7e95b9a47630a94921" - block-stream@*: version "0.0.9" resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" dependencies: inherits "~2.0.0" -bluebird@^3.3.0, bluebird@^3.5.0, bluebird@^3.5.1, bluebird@~3.5.1: +bluebird@^3.5.0, bluebird@^3.5.1, bluebird@~3.5.1: version "3.5.1" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" @@ -1698,21 +1657,6 @@ body-parser@1.18.2: raw-body "2.3.2" type-is "~1.6.15" -body-parser@^1.16.1: - version "1.18.3" - resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.3.tgz#5b292198ffdd553b3a0f20ded0592b956955c8b4" - dependencies: - bytes "3.0.0" - content-type "~1.0.4" - debug "2.6.9" - depd "~1.1.2" - http-errors "~1.6.3" - iconv-lite "0.4.23" - on-finished "~2.3.0" - qs "6.5.2" - raw-body "2.3.3" - type-is "~1.6.16" - bonjour@^3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/bonjour/-/bonjour-3.5.0.tgz#8e890a183d8ee9a2393b3844c691a42bcf7bc9f5" @@ -1759,12 +1703,6 @@ brace@^0.10.0: dependencies: w3c-blob "0.0.1" -braces@^0.1.2: - version "0.1.5" - resolved "https://registry.yarnpkg.com/braces/-/braces-0.1.5.tgz#c085711085291d8b75fdd74eab0f8597280711e6" - dependencies: - expand-range "^0.1.0" - braces@^1.8.2: version "1.8.5" resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" @@ -2021,10 +1959,6 @@ caller-path@^0.1.0: dependencies: callsites "^0.2.0" -callsite@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" - callsites@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca" @@ -2169,7 +2103,7 @@ cheerio@^1.0.0-rc.2: lodash "^4.15.0" parse5 "^3.0.1" -chokidar@^1.4.1, chokidar@^1.6.0, chokidar@^1.7.0: +chokidar@^1.6.0, chokidar@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" dependencies: @@ -2479,7 +2413,7 @@ colors@1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b" -colors@^1.1.0, colors@^1.1.2: +colors@^1.1.2: version "1.3.0" resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.0.tgz#5f20c9fef6945cb1134260aab33bfbdc8295e04e" @@ -2494,12 +2428,6 @@ columnify@~1.5.4: strip-ansi "^3.0.0" wcwidth "^1.0.0" -combine-lists@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/combine-lists/-/combine-lists-1.0.1.tgz#458c07e09e0d900fc28b70a3fec2dacd1d2cb7f6" - dependencies: - lodash "^4.5.0" - combined-stream@1.0.6, combined-stream@^1.0.5, combined-stream@~1.0.5: version "1.0.6" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" @@ -2538,21 +2466,13 @@ compare-versions@^3.1.0: version "3.2.1" resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-3.2.1.tgz#a49eb7689d4caaf0b6db5220173fd279614000f7" -component-bind@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1" - component-classes@^1.2.5: version "1.2.6" resolved "https://registry.yarnpkg.com/component-classes/-/component-classes-1.2.6.tgz#c642394c3618a4d8b0b8919efccbbd930e5cd691" dependencies: component-indexof "0.0.3" -component-emitter@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.1.2.tgz#296594f2753daa63996d2af08d15a95116c9aec3" - -component-emitter@1.2.1, component-emitter@^1.2.1: +component-emitter@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" @@ -2560,10 +2480,6 @@ component-indexof@0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/component-indexof/-/component-indexof-0.0.3.tgz#11d091312239eb8f32c8f25ae9cb002ffe8d3c24" -component-inherit@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/component-inherit/-/component-inherit-0.0.3.tgz#645fc4adf58b72b649d5cae65135619db26ff143" - compress-commons@^1.2.0: version "1.2.2" resolved "https://registry.yarnpkg.com/compress-commons/-/compress-commons-1.2.2.tgz#524a9f10903f3a813389b0225d27c48bb751890f" @@ -2626,15 +2542,6 @@ connect-history-api-fallback@^1.3.0: version "1.5.0" resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.5.0.tgz#b06873934bc5e344fef611a196a6faae0aee015a" -connect@^3.6.0: - version "3.6.6" - resolved "https://registry.yarnpkg.com/connect/-/connect-3.6.6.tgz#09eff6c55af7236e137135a72574858b6786f524" - dependencies: - debug "2.6.9" - finalhandler "1.1.0" - parseurl "~1.3.2" - utils-merge "1.0.1" - console-browserify@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10" @@ -2699,7 +2606,7 @@ core-js@^1.0.0: version "1.2.7" resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" -core-js@^2.0.0, core-js@^2.2.0, core-js@^2.4.0, core-js@^2.4.1, core-js@^2.5.0: +core-js@^2.0.0, core-js@^2.4.0, core-js@^2.4.1, core-js@^2.5.0: version "2.5.7" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e" @@ -2959,10 +2866,6 @@ currently-unhandled@^0.4.1: dependencies: array-find-index "^1.0.1" -custom-event@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" - cyclist@~0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-0.2.2.tgz#1b33792e11e914a2fd6d6ed6447464444e5fa640" @@ -3241,18 +3144,6 @@ dateformat@~1.0.12: get-stdin "^4.0.1" meow "^3.3.0" -debug@2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" - dependencies: - ms "0.7.1" - -debug@2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.3.3.tgz#40c453e67e6e13c901ddec317af8986cda9eff8c" - dependencies: - ms "0.7.2" - debug@2.6.9, debug@^2.1.1, debug@^2.1.2, debug@^2.1.3, debug@^2.2.0, debug@^2.3.3, debug@^2.6.6, debug@^2.6.8, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -3442,10 +3333,6 @@ dezalgo@^1.0.0, dezalgo@~1.0.3: asap "^2.0.0" wrappy "1" -di@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c" - diff-match-patch@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/diff-match-patch/-/diff-match-patch-1.0.1.tgz#d5f880213d82fbc124d2b95111fb3c033dbad7fa" @@ -3523,15 +3410,6 @@ dom-helpers@^3.3.1: version "3.3.1" resolved "https://registry.yarnpkg.com/dom-helpers/-/dom-helpers-3.3.1.tgz#fc1a4e15ffdf60ddde03a480a9c0fece821dd4a6" -dom-serialize@^2.2.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/dom-serialize/-/dom-serialize-2.2.1.tgz#562ae8999f44be5ea3076f5419dcd59eb43ac95b" - dependencies: - custom-event "~1.0.0" - ent "~2.2.0" - extend "^3.0.0" - void-elements "^2.0.0" - dom-serializer@0, dom-serializer@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.1.0.tgz#073c697546ce0780ce23be4a28e293e40bc30c82" @@ -3703,7 +3581,7 @@ empower@^1.2.3: core-js "^2.0.0" empower-core "^0.6.2" -encodeurl@~1.0.1, encodeurl@~1.0.2: +encodeurl@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" @@ -3719,45 +3597,6 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0: dependencies: once "^1.4.0" -engine.io-client@1.8.3: - version "1.8.3" - resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-1.8.3.tgz#1798ed93451246453d4c6f635d7a201fe940d5ab" - dependencies: - component-emitter "1.2.1" - component-inherit "0.0.3" - debug "2.3.3" - engine.io-parser "1.3.2" - has-cors "1.1.0" - indexof "0.0.1" - parsejson "0.0.3" - parseqs "0.0.5" - parseuri "0.0.5" - ws "1.1.2" - xmlhttprequest-ssl "1.5.3" - yeast "0.1.2" - -engine.io-parser@1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-1.3.2.tgz#937b079f0007d0893ec56d46cb220b8cb435220a" - dependencies: - after "0.8.2" - arraybuffer.slice "0.0.6" - base64-arraybuffer "0.1.5" - blob "0.0.4" - has-binary "0.1.7" - wtf-8 "1.0.0" - -engine.io@1.8.3: - version "1.8.3" - resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-1.8.3.tgz#8de7f97895d20d39b85f88eeee777b2bd42b13d4" - dependencies: - accepts "1.3.3" - base64id "1.0.0" - cookie "0.3.1" - debug "2.3.3" - engine.io-parser "1.3.2" - ws "1.1.2" - enhanced-resolve@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.0.0.tgz#e34a6eaa790f62fccd71d93959f56b2b432db10a" @@ -3766,10 +3605,6 @@ enhanced-resolve@^4.0.0: memory-fs "^0.4.0" tapable "^1.0.0" -ent@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" - entities@^1.1.1, entities@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" @@ -4138,14 +3973,6 @@ exit@^0.1.2, exit@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" -expand-braces@^0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/expand-braces/-/expand-braces-0.1.2.tgz#488b1d1d2451cb3d3a6b192cfc030f44c5855fea" - dependencies: - array-slice "^0.2.3" - array-unique "^0.2.1" - braces "^0.1.2" - expand-brackets@^0.1.4: version "0.1.5" resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" @@ -4164,13 +3991,6 @@ expand-brackets@^2.1.4: snapdragon "^0.8.1" to-regex "^3.0.1" -expand-range@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-0.1.1.tgz#4cb8eda0993ca56fa4f41fc42f3cbb4ccadff044" - dependencies: - is-number "^0.1.1" - repeat-string "^0.2.2" - expand-range@^1.8.1: version "1.8.2" resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" @@ -4187,10 +4007,6 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2: dependencies: homedir-polyfill "^1.0.1" -expect.js@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/expect.js/-/expect.js-0.3.1.tgz#b0a59a0d2eff5437544ebf0ceaa6015841d09b5b" - expect.js@~0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/expect.js/-/expect.js-0.2.0.tgz#1028533d2c1c363f74a6796ff57ec0520ded2be1" @@ -4258,7 +4074,7 @@ extend-shallow@^3.0.0, extend-shallow@^3.0.2: assign-symbols "^1.0.0" is-extendable "^1.0.1" -extend@^3.0.0, extend@~3.0.0, extend@~3.0.1: +extend@~3.0.0, extend@~3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" @@ -4455,18 +4271,6 @@ fill-range@^4.0.0: repeat-string "^1.6.1" to-regex-range "^2.1.0" -finalhandler@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.0.tgz#ce0b6855b45853e791b2fcc680046d88253dd7f5" - dependencies: - debug "2.6.9" - encodeurl "~1.0.1" - escape-html "~1.0.3" - on-finished "~2.3.0" - parseurl "~1.3.2" - statuses "~1.3.1" - unpipe "~1.0.0" - finalhandler@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.1.tgz#eebf4ed840079c83f4249038c9d703008301b105" @@ -4654,12 +4458,6 @@ front-matter@2.1.2: dependencies: js-yaml "^3.4.6" -fs-access@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/fs-access/-/fs-access-1.0.1.tgz#d6a87f262271cefebec30c553407fb995da8777a" - dependencies: - null-check "^1.0.0" - fs-constants@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" @@ -5152,12 +4950,6 @@ grunt-exec@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/grunt-exec/-/grunt-exec-1.0.1.tgz#e5d53a39c5f346901305edee5c87db0f2af999c4" -grunt-karma@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/grunt-karma/-/grunt-karma-2.0.0.tgz#753583d115dfdc055fe57e58f96d6b3c7e612118" - dependencies: - lodash "^3.10.1" - grunt-known-options@~1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/grunt-known-options/-/grunt-known-options-1.1.0.tgz#a4274eeb32fa765da5a7a3b1712617ce3b144149" @@ -5311,20 +5103,10 @@ has-ansi@^2.0.0: dependencies: ansi-regex "^2.0.0" -has-binary@0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/has-binary/-/has-binary-0.1.7.tgz#68e61eb16210c9545a0a5cce06a873912fe1e68c" - dependencies: - isarray "0.0.1" - has-color@~0.1.0: version "0.1.7" resolved "https://registry.yarnpkg.com/has-color/-/has-color-0.1.7.tgz#67144a5260c34fc3cca677d041daf52fe7b78b2f" -has-cors@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/has-cors/-/has-cors-1.1.0.tgz#5e474793f7ea9843d1bb99c23eef49ff126fff39" - has-flag@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" @@ -5583,7 +5365,7 @@ http-errors@1.6.2: setprototypeof "1.0.3" statuses ">= 1.3.1 < 2" -http-errors@1.6.3, http-errors@~1.6.2, http-errors@~1.6.3: +http-errors@~1.6.2: version "1.6.3" resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d" dependencies: @@ -5612,7 +5394,7 @@ http-proxy-middleware@~0.18.0: lodash "^4.17.5" micromatch "^3.1.9" -http-proxy@^1.13.0, http-proxy@^1.16.2: +http-proxy@^1.16.2: version "1.17.0" resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.17.0.tgz#7ad38494658f84605e2f6db4436df410f4e5be9a" dependencies: @@ -5661,7 +5443,7 @@ husky@^0.14.3: normalize-path "^1.0.0" strip-indent "^2.0.0" -iconv-lite@0.4, iconv-lite@0.4.23, iconv-lite@^0.4.17, iconv-lite@^0.4.4, iconv-lite@~0.4.13: +iconv-lite@0.4, iconv-lite@^0.4.17, iconv-lite@^0.4.4, iconv-lite@~0.4.13: version "0.4.23" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63" dependencies: @@ -6057,10 +5839,6 @@ is-number-object@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.3.tgz#f265ab89a9f445034ef6aff15a8f00b00f551799" -is-number@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-0.1.1.tgz#69a7af116963d47206ec9bd9b48a14216f1e3806" - is-number@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" @@ -6229,7 +6007,7 @@ isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" -isbinaryfile@^3.0.0, isbinaryfile@^3.0.2: +isbinaryfile@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-3.0.2.tgz#4a3e974ec0cba9004d3fc6cde7209ea69368a621" @@ -6781,7 +6559,7 @@ json-stringify-safe@~5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" -json3@3.3.2, json3@^3.3.2: +json3@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" @@ -6828,85 +6606,6 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -karma-chrome-launcher@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz#cf1b9d07136cc18fe239327d24654c3dbc368acf" - dependencies: - fs-access "^1.0.0" - which "^1.2.1" - -karma-expect@~1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/karma-expect/-/karma-expect-1.1.3.tgz#c6b0a56ff18903db11af4f098cc6e7cf198ce275" - dependencies: - expect.js "^0.3.1" - -karma-mocha@~1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/karma-mocha/-/karma-mocha-1.3.0.tgz#eeaac7ffc0e201eb63c467440d2b69c7cf3778bf" - dependencies: - minimist "1.2.0" - -karma-phantomjs-launcher@1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/karma-phantomjs-launcher/-/karma-phantomjs-launcher-1.0.4.tgz#d23ca34801bda9863ad318e3bb4bd4062b13acd2" - dependencies: - lodash "^4.0.1" - phantomjs-prebuilt "^2.1.7" - -karma-sinon@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/karma-sinon/-/karma-sinon-1.0.5.tgz#4e3443f2830fdecff624d3747163f1217daa2a9a" - -karma-sourcemap-loader@^0.3.7: - version "0.3.7" - resolved "https://registry.yarnpkg.com/karma-sourcemap-loader/-/karma-sourcemap-loader-0.3.7.tgz#91322c77f8f13d46fed062b042e1009d4c4505d8" - dependencies: - graceful-fs "^4.1.2" - -karma-webpack@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/karma-webpack/-/karma-webpack-3.0.0.tgz#bf009c5b73c667c11c015717e9e520f581317c44" - dependencies: - async "^2.0.0" - babel-runtime "^6.0.0" - loader-utils "^1.0.0" - lodash "^4.0.0" - source-map "^0.5.6" - webpack-dev-middleware "^2.0.6" - -karma@1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/karma/-/karma-1.7.0.tgz#6f7a1a406446fa2e187ec95398698f4cee476269" - dependencies: - bluebird "^3.3.0" - body-parser "^1.16.1" - chokidar "^1.4.1" - colors "^1.1.0" - combine-lists "^1.0.0" - connect "^3.6.0" - core-js "^2.2.0" - di "^0.0.1" - dom-serialize "^2.2.0" - expand-braces "^0.1.1" - glob "^7.1.1" - graceful-fs "^4.1.2" - http-proxy "^1.13.0" - isbinaryfile "^3.0.0" - lodash "^3.8.0" - log4js "^0.6.31" - mime "^1.3.4" - minimatch "^3.0.2" - optimist "^0.6.1" - qjobs "^1.1.4" - range-parser "^1.2.0" - rimraf "^2.6.0" - safe-buffer "^5.0.1" - socket.io "1.7.3" - source-map "^0.5.3" - tmp "0.0.31" - useragent "^2.1.12" - kew@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/kew/-/kew-0.7.0.tgz#79d93d2d33363d6fdd2970b335d9141ad591d79b" @@ -7164,7 +6863,7 @@ loader-runner@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.3.0.tgz#f482aea82d543e07921700d5a46ef26fdac6b8a2" -loader-utils@1.1.0, loader-utils@^1.0.0, loader-utils@^1.0.1, loader-utils@^1.0.2, loader-utils@^1.1.0: +loader-utils@1.1.0, loader-utils@^1.0.1, loader-utils@^1.0.2, loader-utils@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.1.0.tgz#c98aef488bcceda2ffb5e2de646d6a754429f5cd" dependencies: @@ -7320,11 +7019,11 @@ lodash.without@~4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.without/-/lodash.without-4.4.0.tgz#3cd4574a00b67bae373a94b748772640507b7aac" -lodash@^3.10.1, lodash@^3.6.0, lodash@^3.8.0: +lodash@^3.10.1, lodash@^3.6.0: version "3.10.1" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" -lodash@^4.0.0, lodash@^4.0.1, lodash@^4.1.1, lodash@^4.13.1, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.2, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.5.0, lodash@^4.7.0, lodash@^4.8.0, lodash@~4.17.10, lodash@~4.17.5: +lodash@^4.0.0, lodash@^4.1.1, lodash@^4.13.1, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.2, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.7.0, lodash@^4.8.0, lodash@~4.17.10, lodash@~4.17.5: version "4.17.10" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" @@ -7351,13 +7050,6 @@ log-update@^1.0.2: ansi-escapes "^1.0.0" cli-cursor "^1.0.2" -log4js@^0.6.31: - version "0.6.38" - resolved "https://registry.yarnpkg.com/log4js/-/log4js-0.6.38.tgz#2c494116695d6fb25480943d3fc872e662a522fd" - dependencies: - readable-stream "~1.0.2" - semver "~4.3.3" - loglevel@^1.4.1: version "1.6.1" resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.1.tgz#e0fc95133b6ef276cdc8887cdaf24aa6f156f8fa" @@ -7412,7 +7104,7 @@ lowercase-keys@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" -lru-cache@4.1.x, lru-cache@^4.0.1, lru-cache@^4.1.1, lru-cache@^4.1.2, lru-cache@^4.1.3: +lru-cache@^4.0.1, lru-cache@^4.1.1, lru-cache@^4.1.2, lru-cache@^4.1.3: version "4.1.3" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.3.tgz#a1175cf3496dfc8436c156c334b4955992bce69c" dependencies: @@ -7654,7 +7346,7 @@ mime-db@~1.33.0: version "1.33.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.33.0.tgz#a3492050a5cb9b63450541e39d9788d2272783db" -mime-types@^2.1.12, mime-types@~2.1.11, mime-types@~2.1.17, mime-types@~2.1.18, mime-types@~2.1.7: +mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.18, mime-types@~2.1.7: version "2.1.18" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.18.tgz#6f323f60a83d11146f831ff11fd66e2fe5503bb8" dependencies: @@ -7664,10 +7356,6 @@ mime@1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" -mime@^1.3.4: - version "1.6.0" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" - mime@^2.1.0: version "2.3.1" resolved "https://registry.yarnpkg.com/mime/-/mime-2.3.1.tgz#b1621c54d63b97c47d3cfe7f7215f7d64517c369" @@ -7721,14 +7409,14 @@ minimist@1.1.x: version "1.1.3" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.1.3.tgz#3bedfd91a92d39016fcfaa1c681e8faa1a1efda8" -minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" - minimist@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.1.0.tgz#99df657a52574c21c9057497df742790b2b4c0de" +minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + minimist@~0.0.1: version "0.0.10" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" @@ -7867,14 +7555,6 @@ move-concurrently@^1.0.1: rimraf "^2.5.4" run-queue "^1.0.3" -ms@0.7.1: - version "0.7.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" - -ms@0.7.2: - version "0.7.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -8489,10 +8169,6 @@ nth-check@~1.0.1: dependencies: boolbase "~1.0.0" -null-check@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/null-check/-/null-check-1.0.0.tgz#977dffd7176012b9ec30d2a39db5cf72a0439edd" - num2fraction@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/num2fraction/-/num2fraction-1.2.2.tgz#6f682b6a027a4e9ddfa4564cd2589d1d4e669ede" @@ -8509,18 +8185,10 @@ oauth-sign@~0.8.1, oauth-sign@~0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" -object-assign@4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0" - object-assign@4.x, object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" -object-component@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" - object-copy@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" @@ -8659,10 +8327,6 @@ optionator@^0.8.1: type-check "~0.3.2" wordwrap "~1.0.0" -options@>=0.0.5: - version "0.0.6" - resolved "https://registry.yarnpkg.com/options/-/options-0.0.6.tgz#ec22d312806bb53e731773e7cdaefcf1c643128f" - ora@^0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/ora/-/ora-0.2.3.tgz#37527d220adcd53c39b73571d754156d5db657a4" @@ -8710,7 +8374,7 @@ os-locale@^2.0.0: lcid "^1.0.0" mem "^1.1.0" -os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1, os-tmpdir@~1.0.2: +os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -8919,24 +8583,6 @@ parse5@^3.0.1, parse5@^3.0.3: dependencies: "@types/node" "*" -parsejson@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/parsejson/-/parsejson-0.0.3.tgz#ab7e3759f209ece99437973f7d0f1f64ae0e64ab" - dependencies: - better-assert "~1.0.0" - -parseqs@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d" - dependencies: - better-assert "~1.0.0" - -parseuri@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/parseuri/-/parseuri-0.0.5.tgz#80204a50d4dbb779bfdc6ebe2778d90e4bce320a" - dependencies: - better-assert "~1.0.0" - parseurl@~1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" @@ -9032,7 +8678,7 @@ performance-now@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" -phantomjs-prebuilt@^2.1.15, phantomjs-prebuilt@^2.1.7: +phantomjs-prebuilt@^2.1.15: version "2.1.16" resolved "https://registry.yarnpkg.com/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz#efd212a4a3966d3647684ea8ba788549be2aefef" dependencies: @@ -9697,10 +9343,6 @@ q@^1.1.2: version "1.5.1" resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" -qjobs@^1.1.4: - version "1.2.0" - resolved "https://registry.yarnpkg.com/qjobs/-/qjobs-1.2.0.tgz#c45e9c61800bd087ef88d7e256423bdd49e5d071" - qrcode-terminal@^0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/qrcode-terminal/-/qrcode-terminal-0.12.0.tgz#bb5b699ef7f9f0505092a3748be4464fe71b5819" @@ -9709,14 +9351,14 @@ qs@6.5.1: version "6.5.1" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" -qs@6.5.2, qs@~6.5.1: - version "6.5.2" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" - qs@~6.3.0: version "6.3.2" resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.2.tgz#e75bd5f6e268122a2a0e0bda630b2550c166502c" +qs@~6.5.1: + version "6.5.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" + query-string@^4.1.0: version "4.3.4" resolved "https://registry.yarnpkg.com/query-string/-/query-string-4.3.4.tgz#bbb693b9ca915c232515b228b1a02b609043dbeb" @@ -9793,7 +9435,7 @@ randomfill@^1.0.3: randombytes "^2.0.5" safe-buffer "^5.1.0" -range-parser@^1.0.3, range-parser@^1.2.0, range-parser@~1.2.0: +range-parser@^1.0.3, range-parser@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" @@ -9806,15 +9448,6 @@ raw-body@2.3.2: iconv-lite "0.4.19" unpipe "1.0.0" -raw-body@2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.3.tgz#1b324ece6b5706e153855bc1148c65bb7f6ea0c3" - dependencies: - bytes "3.0.0" - http-errors "1.6.3" - iconv-lite "0.4.23" - unpipe "1.0.0" - rc-align@^2.4.0: version "2.4.3" resolved "https://registry.yarnpkg.com/rc-align/-/rc-align-2.4.3.tgz#b9b3c2a6d68adae71a8e1d041cd5e3b2a655f99a" @@ -10101,7 +9734,7 @@ read@1, read@~1.0.1, read@~1.0.7: string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@1.0, readable-stream@~1.0.2: +readable-stream@1.0: version "1.0.34" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" dependencies: @@ -10311,10 +9944,6 @@ repeat-element@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" -repeat-string@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-0.2.2.tgz#c7a8d3236068362059a7e4651fc6884e8b1fb4ae" - repeat-string@^1.5.2, repeat-string@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" @@ -10526,7 +10155,7 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" -rimraf@2, rimraf@^2.2.8, rimraf@^2.4.4, rimraf@^2.5.1, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.0, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@~2.6.2: +rimraf@2, rimraf@^2.2.8, rimraf@^2.4.4, rimraf@^2.5.1, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@~2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" dependencies: @@ -10727,10 +10356,6 @@ semver-diff@^2.0.0: version "5.5.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" -semver@~4.3.3: - version "4.3.6" - resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da" - semver@~5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" @@ -11059,50 +10684,6 @@ sntp@1.x.x: dependencies: hoek "2.x.x" -socket.io-adapter@0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-0.5.0.tgz#cb6d4bb8bec81e1078b99677f9ced0046066bb8b" - dependencies: - debug "2.3.3" - socket.io-parser "2.3.1" - -socket.io-client@1.7.3: - version "1.7.3" - resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-1.7.3.tgz#b30e86aa10d5ef3546601c09cde4765e381da377" - dependencies: - backo2 "1.0.2" - component-bind "1.0.0" - component-emitter "1.2.1" - debug "2.3.3" - engine.io-client "1.8.3" - has-binary "0.1.7" - indexof "0.0.1" - object-component "0.0.3" - parseuri "0.0.5" - socket.io-parser "2.3.1" - to-array "0.1.4" - -socket.io-parser@2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-2.3.1.tgz#dd532025103ce429697326befd64005fcfe5b4a0" - dependencies: - component-emitter "1.1.2" - debug "2.2.0" - isarray "0.0.1" - json3 "3.3.2" - -socket.io@1.7.3: - version "1.7.3" - resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-1.7.3.tgz#b8af9caba00949e568e369f1327ea9be9ea2461b" - dependencies: - debug "2.3.3" - engine.io "1.8.3" - has-binary "0.1.7" - object-assign "4.1.0" - socket.io-adapter "0.5.0" - socket.io-client "1.7.3" - socket.io-parser "2.3.1" - sockjs-client@1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/sockjs-client/-/sockjs-client-1.1.4.tgz#5babe386b775e4cf14e7520911452654016c8b12" @@ -11332,10 +10913,6 @@ static-extend@^0.1.1: version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" -statuses@~1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" - statuses@~1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" @@ -11749,13 +11326,7 @@ title-case@^2.1.0: no-case "^2.2.0" upper-case "^1.0.3" -tmp@0.0.31: - version "0.0.31" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.31.tgz#8f38ab9438e17315e5dbd8b3657e8bfb277ae4a7" - dependencies: - os-tmpdir "~1.0.1" - -tmp@0.0.x, tmp@^0.0.33: +tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" dependencies: @@ -11765,10 +11336,6 @@ tmpl@1.0.x: version "1.0.4" resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1" -to-array@0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/to-array/-/to-array-0.1.4.tgz#17e6c11f73dd4f3d74cda7a4ff3238e9ad9bf890" - to-arraybuffer@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" @@ -12036,10 +11603,6 @@ uid-number@0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" -ultron@1.0.x: - version "1.0.2" - resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.0.2.tgz#ace116ab557cd197386a4e88f4685378c8b2e4fa" - umask@^1.1.0, umask@~1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/umask/-/umask-1.1.0.tgz#f29cebf01df517912bb58ff9c4e50fde8e33320d" @@ -12175,10 +11738,6 @@ urix@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" -url-join@^2.0.2: - version "2.0.5" - resolved "https://registry.yarnpkg.com/url-join/-/url-join-2.0.5.tgz#5af22f18c052a000a48d7b82c5e9c2e2feeda728" - url-join@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/url-join/-/url-join-4.0.0.tgz#4d3340e807d3773bda9991f8305acdcc2a665d2a" @@ -12225,13 +11784,6 @@ user-home@^2.0.0: dependencies: os-homedir "^1.0.0" -useragent@^2.1.12: - version "2.3.0" - resolved "https://registry.yarnpkg.com/useragent/-/useragent-2.3.0.tgz#217f943ad540cb2128658ab23fc960f6a88c9972" - dependencies: - lru-cache "4.1.x" - tmp "0.0.x" - util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" @@ -12344,10 +11896,6 @@ vm-browserify@0.0.4: dependencies: indexof "0.0.1" -void-elements@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" - vue-parser@^1.1.5: version "1.1.6" resolved "https://registry.yarnpkg.com/vue-parser/-/vue-parser-1.1.6.tgz#3063c8431795664ebe429c23b5506899706e6355" @@ -12492,18 +12040,6 @@ webpack-dev-middleware@3.1.3: url-join "^4.0.0" webpack-log "^1.0.1" -webpack-dev-middleware@^2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-2.0.6.tgz#a51692801e8310844ef3e3790e1eacfe52326fd4" - dependencies: - loud-rejection "^1.6.0" - memory-fs "~0.4.1" - mime "^2.1.0" - path-is-absolute "^1.0.0" - range-parser "^1.0.3" - url-join "^2.0.2" - webpack-log "^1.0.1" - webpack-dev-server@^3.1.0: version "3.1.4" resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-3.1.4.tgz#9a08d13c4addd1e3b6d8ace116e86715094ad5b4" @@ -12638,7 +12174,7 @@ which-pm-runs@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/which-pm-runs/-/which-pm-runs-1.0.0.tgz#670b3afbc552e0b55df6b7780ca74615f23ad1cb" -which@1, which@^1.2.1, which@^1.2.10, which@^1.2.12, which@^1.2.14, which@^1.2.4, which@^1.2.9, which@^1.3.0, which@~1.3.0: +which@1, which@^1.2.10, which@^1.2.12, which@^1.2.14, which@^1.2.4, which@^1.2.9, which@^1.3.0, which@~1.3.0: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" dependencies: @@ -12717,13 +12253,6 @@ write@^0.2.1: dependencies: mkdirp "^0.5.1" -ws@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/ws/-/ws-1.1.2.tgz#8a244fa052401e08c9886cf44a85189e1fd4067f" - dependencies: - options ">=0.0.5" - ultron "1.0.x" - ws@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/ws/-/ws-4.1.0.tgz#a979b5d7d4da68bf54efe0408967c324869a7289" @@ -12731,10 +12260,6 @@ ws@^4.0.0: async-limiter "~1.0.0" safe-buffer "~5.1.0" -wtf-8@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/wtf-8/-/wtf-8-1.0.0.tgz#392d8ba2d0f1c34d1ee2d630f15d0efb68e1048a" - xdg-basedir@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4" @@ -12747,10 +12272,6 @@ xml-name-validator@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" -xmlhttprequest-ssl@1.5.3: - version "1.5.3" - resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz#185a888c04eca46c3e4070d99f7b49de3528992d" - xmlhttprequest@1: version "1.8.0" resolved "https://registry.yarnpkg.com/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz#67fe075c5c24fef39f9d65f5f7b7fe75171968fc" @@ -12883,10 +12404,6 @@ yauzl@2.4.1: dependencies: fd-slicer "~1.0.1" -yeast@0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419" - yeoman-environment@^2.0.5, yeoman-environment@^2.1.1: version "2.2.0" resolved "https://registry.yarnpkg.com/yeoman-environment/-/yeoman-environment-2.2.0.tgz#6c0ee93a8d962a9f6dbc5ad4e90ae7ab34875393" From 6225efa50ccdcd1a80fe4deeac2570deffcbac06 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Tue, 14 Aug 2018 11:24:08 +0200 Subject: [PATCH 62/99] docs: update postgres provisioning --- docs/sources/features/datasources/postgres.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sources/features/datasources/postgres.md b/docs/sources/features/datasources/postgres.md index e2dcf888025..4afde5cc6cb 100644 --- a/docs/sources/features/datasources/postgres.md +++ b/docs/sources/features/datasources/postgres.md @@ -290,4 +290,5 @@ datasources: password: "Password!" jsonData: sslmode: "disable" # disable/require/verify-ca/verify-full + timescaledb: false ``` From 3769df7119ca3c26220b37f68804ca03a8b32e52 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Tue, 14 Aug 2018 12:16:46 +0200 Subject: [PATCH 63/99] changelog: add notes about closing #12680 [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c397e45ea4..4890a471ac9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * **Configuration**: Allow auto-assigning users to specific organization (other than Main. Org) [#1823](https://github.com/grafana/grafana/issues/1823) [#12801](https://github.com/grafana/grafana/issues/12801), thx [@gzzo](https://github.com/gzzo) and [@ofosos](https://github.com/ofosos) * **Profile**: List teams that the user is member of in current/active organization [#12476](https://github.com/grafana/grafana/issues/12476) * **LDAP**: Client certificates support [#12805](https://github.com/grafana/grafana/issues/12805), thx [@nyxi](https://github.com/nyxi) +* **Postgres**: TimescaleDB support, e.g. use `time_bucket` for grouping by time when option enabled [#12680](https://github.com/grafana/grafana/pull/12680), thx [svenklemm](https://github.com/svenklemm) ### Minor From a1ed3ae0943fb54c7af4ab156beaf1c883300685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 14 Aug 2018 12:25:19 +0200 Subject: [PATCH 64/99] feat: add auto fit panels to shortcut modal, closes #12768 --- public/app/core/components/help/help.ts | 1 + public/app/core/services/keybindingSrv.ts | 15 +++------------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/public/app/core/components/help/help.ts b/public/app/core/components/help/help.ts index a1d3c34ae5b..eac47b6e0a2 100644 --- a/public/app/core/components/help/help.ts +++ b/public/app/core/components/help/help.ts @@ -25,6 +25,7 @@ export class HelpCtrl { { keys: ['d', 'k'], description: 'Toggle kiosk mode (hides top nav)' }, { keys: ['d', 'E'], description: 'Expand all rows' }, { keys: ['d', 'C'], description: 'Collapse all rows' }, + { keys: ['d', 'a'], description: 'Toggle auto fit panels (experimental feature)' }, { keys: ['mod+o'], description: 'Toggle shared graph crosshair' }, ], 'Focused Panel': [ diff --git a/public/app/core/services/keybindingSrv.ts b/public/app/core/services/keybindingSrv.ts index f740718063c..9d914a94a1c 100644 --- a/public/app/core/services/keybindingSrv.ts +++ b/public/app/core/services/keybindingSrv.ts @@ -15,14 +15,7 @@ export class KeybindingSrv { timepickerOpen = false; /** @ngInject */ - constructor( - private $rootScope, - private $location, - private datasourceSrv, - private timeSrv, - private contextSrv, - private $route - ) { + constructor(private $rootScope, private $location, private datasourceSrv, private timeSrv, private contextSrv) { // clear out all shortcuts on route change $rootScope.$on('$routeChangeSuccess', () => { Mousetrap.reset(); @@ -269,10 +262,8 @@ export class KeybindingSrv { //Autofit panels this.bind('d a', () => { - this.$location.search('autofitpanels', this.$location.search().autofitpanels ? null : true); - //Force reload - - this.$route.reload(); + // this has to be a full page reload + window.location.href = window.location.href + '&autofitpanels'; }); } } From de25a4fe4ed8459c234916d39ce58cbbe5fb6669 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Tue, 14 Aug 2018 12:40:07 +0200 Subject: [PATCH 65/99] docs: update --- .github/CONTRIBUTING.md | 8 ++------ README.md | 11 +++++------ docs/sources/project/building_from_source.md | 13 ++++++------- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 14c6c07ab16..769ba2a519b 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -2,15 +2,11 @@ Follow the setup guide in README.md ### Rebuild frontend assets on source change ``` -grunt && grunt watch +yarn watch ``` ### Rerun tests on source change ``` -npm run jest -``` -or -``` yarn jest ``` @@ -21,6 +17,6 @@ test -z "$(gofmt -s -l . | grep -v -E 'vendor/(github.com|golang.org|gopkg.in)' ### Run tests for frontend assets before commit ``` -npm test +yarn test go test -v ./pkg/... ``` diff --git a/README.md b/README.md index 71fdb04cea6..74fb10c8066 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ To build the assets, rebuild on file change, and serve them by Grafana's webserv ```bash npm install -g yarn yarn install --pure-lockfile -yarn run watch +yarn watch ``` Build the assets, rebuild on file change with Hot Module Replacement (HMR), and serve them by webpack-dev-server (http://localhost:3333): @@ -56,7 +56,7 @@ Note: HMR for Angular is not supported. If you edit files in the Angular part of Run tests ```bash -yarn run jest +yarn jest ``` ### Recompile backend on source change @@ -93,14 +93,13 @@ In your custom.ini uncomment (remove the leading `;`) sign. And set `app_mode = #### Frontend Execute all frontend tests ```bash -yarn run test +yarn test ``` Writing & watching frontend tests -- jest for all new tests that do not require browser context (React+more) - - Start watcher: `yarn run jest` - - Jest will run all test files that end with the name ".test.ts" +- Start watcher: `yarn jest` +- Jest will run all test files that end with the name ".test.ts" #### Backend ```bash diff --git a/docs/sources/project/building_from_source.md b/docs/sources/project/building_from_source.md index 20c177211e3..08673404572 100644 --- a/docs/sources/project/building_from_source.md +++ b/docs/sources/project/building_from_source.md @@ -57,7 +57,7 @@ For this you need nodejs (v.6+). ```bash npm install -g yarn yarn install --pure-lockfile -npm run watch +yarn watch ``` ## Running Grafana Locally @@ -83,18 +83,17 @@ go get github.com/Unknwon/bra bra run ``` -You'll also need to run `npm run watch` to watch for changes to the front-end (typescript, html, sass) +You'll also need to run `yarn watch` to watch for changes to the front-end (typescript, html, sass) ### Running tests -- You can run backend Golang tests using "go test ./pkg/...". -- Execute all frontend tests with "npm run test" +- You can run backend Golang tests using `go test ./pkg/...`. +- Execute all frontend tests with `yarn test` Writing & watching frontend tests -- jest for all new tests that do not require browser context (React+more) - - Start watcher: `npm run jest` - - Jest will run all test files that end with the name ".test.ts" +- Start watcher: `yarn jest` +- Jest will run all test files that end with the name ".test.ts" ## Creating optimized release packages From 332e59d31400f9ce250c45a121de63fc8a53ed62 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Tue, 14 Aug 2018 13:42:18 +0200 Subject: [PATCH 66/99] changelog: add notes about closing #12224 [skip ci] --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4890a471ac9..4bd9cb917d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,10 @@ These are new features that's still being worked on and are in an experimental p * **Dashboard**: Auto fit dashboard panels to optimize space used for current TV / Monitor [#12768](https://github.com/grafana/grafana/issues/12768) +### Tech + +* **Frontend**: Convert all Frontend Karma tests to Jest tests [#12224](https://github.com/grafana/grafana/issues/12224) + # 5.2.2 (2018-07-25) ### Minor From aefcb06ff823c8248f0f1ec03ce2d9578f1ea01d Mon Sep 17 00:00:00 2001 From: Leonard Gram Date: Tue, 14 Aug 2018 10:45:32 +0200 Subject: [PATCH 67/99] build: verifies the rpm packages signatures. Closes #12370 --- .circleci/config.yml | 5 +++++ scripts/build/verify_signed_packages.sh | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100755 scripts/build/verify_signed_packages.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 977121c30ee..c2e4cce9c4b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -147,6 +147,11 @@ jobs: - run: name: sign packages command: './scripts/build/sign_packages.sh' + - run: + name: verify signed packages + command: | + curl https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana > ~/.rpmdb/pubkeys/grafana.key + ./scripts/build/verify_signed_packages.sh dist/*.rpm - run: name: sha-sum packages command: 'go run build.go sha-dist' diff --git a/scripts/build/verify_signed_packages.sh b/scripts/build/verify_signed_packages.sh new file mode 100755 index 00000000000..c3e5b09afc2 --- /dev/null +++ b/scripts/build/verify_signed_packages.sh @@ -0,0 +1,17 @@ +#!/bin/bash +_files=$* + +ALL_SIGNED=0 + +for file in $_files; do + rpm -K "$file" | grep "pgp.*OK" -q + if [[ $? != 0 ]]; then + ALL_SIGNED=1 + echo $file NOT SIGNED + else + echo $file OK + fi +done + + +exit $ALL_SIGNED From 7ec146df9989e407b816b51069c8cf9bd4eb43cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Knecht?= Date: Thu, 15 Feb 2018 19:13:47 +0100 Subject: [PATCH 68/99] social: add GitLab authentication backend GitLab could already be used as an authentication backend by properly configuring `auth.generic_oauth`, but then there was no way to authorize users based on their GitLab group membership. This commit adds a `auth.gitlab` backend, similar to `auth.github`, with an `allowed_groups` option that can be set to a list of groups whose members should be allowed access to Grafana. --- conf/defaults.ini | 12 +++ pkg/models/models.go | 1 + pkg/social/gitlab_oauth.go | 131 +++++++++++++++++++++++++++++++++ pkg/social/social.go | 16 +++- public/app/partials/login.html | 4 + public/sass/_variables.scss | 1 + 6 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 pkg/social/gitlab_oauth.go diff --git a/conf/defaults.ini b/conf/defaults.ini index 99c1537eb95..90fc144c6e0 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -270,6 +270,18 @@ api_url = https://api.github.com/user team_ids = allowed_organizations = +#################################### GitLab Auth ######################### +[auth.gitlab] +enabled = false +allow_sign_up = true +client_id = some_id +client_secret = some_secret +scopes = api +auth_url = https://gitlab.com/oauth/authorize +token_url = https://gitlab.com/oauth/token +api_url = https://gitlab.com/api/v4 +allowed_groups = + #################################### Google Auth ######################### [auth.google] enabled = false diff --git a/pkg/models/models.go b/pkg/models/models.go index c2560021ee1..ba894ae591f 100644 --- a/pkg/models/models.go +++ b/pkg/models/models.go @@ -8,4 +8,5 @@ const ( TWITTER GENERIC GRAFANA_COM + GITLAB ) diff --git a/pkg/social/gitlab_oauth.go b/pkg/social/gitlab_oauth.go new file mode 100644 index 00000000000..22e50b9653a --- /dev/null +++ b/pkg/social/gitlab_oauth.go @@ -0,0 +1,131 @@ +package social + +import ( + "encoding/json" + "fmt" + "net/http" + "regexp" + + "github.com/grafana/grafana/pkg/models" + + "golang.org/x/oauth2" +) + +type SocialGitlab struct { + *SocialBase + allowedDomains []string + allowedGroups []string + apiUrl string + allowSignup bool +} + +var ( + ErrMissingGroupMembership = &Error{"User not a member of one of the required groups"} +) + +func (s *SocialGitlab) Type() int { + return int(models.GITLAB) +} + +func (s *SocialGitlab) IsEmailAllowed(email string) bool { + return isEmailAllowed(email, s.allowedDomains) +} + +func (s *SocialGitlab) IsSignupAllowed() bool { + return s.allowSignup +} + +func (s *SocialGitlab) IsGroupMember(client *http.Client) bool { + if len(s.allowedGroups) == 0 { + return true + } + + for groups, url := s.GetGroups(client, s.apiUrl+"/groups"); groups != nil; groups, url = s.GetGroups(client, url) { + for _, allowedGroup := range s.allowedGroups { + for _, group := range groups { + if group == allowedGroup { + return true + } + } + } + } + + return false +} + +func (s *SocialGitlab) GetGroups(client *http.Client, url string) ([]string, string) { + type Group struct { + FullPath string `json:"full_path"` + } + + var ( + groups []Group + next string + ) + + if url == "" { + return nil, next + } + + response, err := HttpGet(client, url) + if err != nil { + s.log.Error("Error getting groups from GitLab API", "err", err) + return nil, next + } + + if err := json.Unmarshal(response.Body, &groups); err != nil { + s.log.Error("Error parsing JSON from GitLab API", "err", err) + return nil, next + } + + fullPaths := make([]string, len(groups)) + for i, group := range groups { + fullPaths[i] = group.FullPath + } + + if link, ok := response.Headers["Link"]; ok { + pattern := regexp.MustCompile(`<([^>]+)>; rel="next"`) + if matches := pattern.FindStringSubmatch(link[0]); matches != nil { + next = matches[1] + } + } + + return fullPaths, next +} + +func (s *SocialGitlab) UserInfo(client *http.Client, token *oauth2.Token) (*BasicUserInfo, error) { + + var data struct { + Id int + Username string + Email string + Name string + State string + } + + response, err := HttpGet(client, s.apiUrl+"/user") + if err != nil { + return nil, fmt.Errorf("Error getting user info: %s", err) + } + + err = json.Unmarshal(response.Body, &data) + if err != nil { + return nil, fmt.Errorf("Error getting user info: %s", err) + } + + if data.State != "active" { + return nil, fmt.Errorf("User %s is inactive", data.Username) + } + + userInfo := &BasicUserInfo{ + Name: data.Name, + Login: data.Username, + Email: data.Email, + } + + if !s.IsGroupMember(client) { + return nil, ErrMissingGroupMembership + } + + return userInfo, nil +} diff --git a/pkg/social/social.go b/pkg/social/social.go index adbe5a912d9..2be71514629 100644 --- a/pkg/social/social.go +++ b/pkg/social/social.go @@ -55,7 +55,7 @@ func NewOAuthService() { setting.OAuthService = &setting.OAuther{} setting.OAuthService.OAuthInfos = make(map[string]*setting.OAuthInfo) - allOauthes := []string{"github", "google", "generic_oauth", "grafananet", "grafana_com"} + allOauthes := []string{"github", "gitlab", "google", "generic_oauth", "grafananet", "grafana_com"} for _, name := range allOauthes { sec := setting.Raw.Section("auth." + name) @@ -115,6 +115,20 @@ func NewOAuthService() { } } + // GitLab. + if name == "gitlab" { + SocialMap["gitlab"] = &SocialGitlab{ + SocialBase: &SocialBase{ + Config: &config, + log: logger, + }, + allowedDomains: info.AllowedDomains, + apiUrl: info.ApiUrl, + allowSignup: info.AllowSignup, + allowedGroups: util.SplitString(sec.Key("allowed_groups").String()), + } + } + // Google. if name == "google" { SocialMap["google"] = &SocialGoogle{ diff --git a/public/app/partials/login.html b/public/app/partials/login.html index 1919759334b..87b3cada7b5 100644 --- a/public/app/partials/login.html +++ b/public/app/partials/login.html @@ -51,6 +51,10 @@ Sign in with GitHub + - -