From 39be7cf7d752d6d6dbaf396a8d925d808dccb7bb Mon Sep 17 00:00:00 2001 From: Mark Henderson Date: Wed, 27 Jul 2016 03:41:33 -0400 Subject: [PATCH 1/3] Added grafana-cli command. Added public documentation for specifying plugin version when installing. (#5665) --- pkg/cmd/grafana-cli/commands/commands.go | 6 +++- .../commands/listversions_command.go | 36 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 pkg/cmd/grafana-cli/commands/listversions_command.go diff --git a/pkg/cmd/grafana-cli/commands/commands.go b/pkg/cmd/grafana-cli/commands/commands.go index 3f8826ce8ba..2099a576647 100644 --- a/pkg/cmd/grafana-cli/commands/commands.go +++ b/pkg/cmd/grafana-cli/commands/commands.go @@ -27,12 +27,16 @@ func runCommand(command func(commandLine CommandLine) error) func(context *cli.C var pluginCommands = []cli.Command{ { Name: "install", - Usage: "install ", + Usage: "install ", Action: runCommand(installCommand), }, { Name: "list-remote", Usage: "list remote available plugins", Action: runCommand(listremoteCommand), + }, { + Name: "list-versions", + Usage: "list-versions ", + Action: runCommand(listversionsCommand), }, { Name: "update", Usage: "update ", diff --git a/pkg/cmd/grafana-cli/commands/listversions_command.go b/pkg/cmd/grafana-cli/commands/listversions_command.go new file mode 100644 index 00000000000..95c536e94f0 --- /dev/null +++ b/pkg/cmd/grafana-cli/commands/listversions_command.go @@ -0,0 +1,36 @@ +package commands + +import ( + "errors" + + "github.com/grafana/grafana/pkg/cmd/grafana-cli/logger" + s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services" +) + +func validateVersionInput(c CommandLine) error { + arg := c.Args().First() + if arg == "" { + return errors.New("please specify plugin to list versions for") + } + + return nil +} + +func listversionsCommand(c CommandLine) error { + if err := validateVersionInput(c); err != nil { + return err + } + + pluginToList := c.Args().First() + + plugin, err := s.GetPlugin(pluginToList, c.GlobalString("repo")) + if err != nil { + return err + } + + for _, i := range plugin.Versions { + logger.Infof("%v\n", i.Version) + } + + return nil +} From 732c84c230af5d5d3734c1854083e5025d1f5c17 Mon Sep 17 00:00:00 2001 From: Thib17 Date: Wed, 27 Jul 2016 10:10:01 +0200 Subject: [PATCH 2/3] =?UTF-8?q?Enable=20scaling=20down=20seconds=20unit=20?= =?UTF-8?q?s=20>=20ms=20>=20=C2=B5s=20>=20ns=20(#5642)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/app/core/utils/kbn.js | 13 +++++++++++++ public/test/core/utils/kbn_specs.js | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/public/app/core/utils/kbn.js b/public/app/core/utils/kbn.js index 29cd7c49890..c0d162b0ece 100644 --- a/public/app/core/utils/kbn.js +++ b/public/app/core/utils/kbn.js @@ -500,6 +500,19 @@ function($, _, moment) { kbn.valueFormats.s = function(size, decimals, scaledDecimals) { if (size === null) { return ""; } + // Less than 1 µs, devide in ns + if (Math.abs(size) < 0.000001) { + return kbn.toFixedScaled(size * 1.e9, decimals, scaledDecimals - decimals, -9, " ns"); + } + // Less than 1 ms, devide in µs + if (Math.abs(size) < 0.001) { + return kbn.toFixedScaled(size * 1.e6, decimals, scaledDecimals - decimals, -6, " µs"); + } + // Less than 1 second, devide in ms + if (Math.abs(size) < 1) { + return kbn.toFixedScaled(size * 1.e3, decimals, scaledDecimals - decimals, -3, " ms"); + } + if (Math.abs(size) < 60) { return kbn.toFixed(size, decimals) + " s"; } diff --git a/public/test/core/utils/kbn_specs.js b/public/test/core/utils/kbn_specs.js index e851e9b82f5..959b176b06c 100644 --- a/public/test/core/utils/kbn_specs.js +++ b/public/test/core/utils/kbn_specs.js @@ -68,6 +68,11 @@ define([ describeValueFormat('wps', 789000000, 1000000, -1, '789M wps'); describeValueFormat('iops', 11000000000, 1000000000, -1, '11B iops'); + describeValueFormat('s', 1.23456789e-7, 1e-10, 8, '123.5 ns'); + describeValueFormat('s', 1.23456789e-4, 1e-7, 5, '123.5 µs'); + describeValueFormat('s', 1.23456789e-3, 1e-6, 4, '1.235 ms'); + describeValueFormat('s', 1.23456789e-2, 1e-5, 3, '12.35 ms'); + describeValueFormat('s', 1.23456789e-1, 1e-4, 2, '123.5 ms'); describeValueFormat('s', 24, 1, 0, '24 s'); describeValueFormat('s', 246, 1, 0, '4.1 min'); describeValueFormat('s', 24567, 100, 0, '6.82 hour'); From 89dc3b88d1f8e878a08e485ee8f1eaf0e918abae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 27 Jul 2016 10:20:48 +0200 Subject: [PATCH 3/3] fix(test): fixed failing test caused by recent change --- public/app/features/dashboard/timeSrv.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/features/dashboard/timeSrv.js b/public/app/features/dashboard/timeSrv.js index 2f4668e3667..c6d0b754e85 100644 --- a/public/app/features/dashboard/timeSrv.js +++ b/public/app/features/dashboard/timeSrv.js @@ -13,7 +13,7 @@ define([ module.service('timeSrv', function($rootScope, $timeout, $routeParams, timer) { var self = this; - $rootScope.onAppEvent('zoom-out', function(e, factor) { self.zoomOut(factor); }, $rootScope); + $rootScope.$on('zoom-out', function(e, factor) { self.zoomOut(factor); }); this.init = function(dashboard) { timer.cancel_all();