Commit c997923b by Torkel Ödegaard

Merge branch 'master' of github.com:grafana/grafana

parents e789d0df 732c84c2
...@@ -27,13 +27,17 @@ func runCommand(command func(commandLine CommandLine) error) func(context *cli.C ...@@ -27,13 +27,17 @@ func runCommand(command func(commandLine CommandLine) error) func(context *cli.C
var pluginCommands = []cli.Command{ var pluginCommands = []cli.Command{
{ {
Name: "install", Name: "install",
Usage: "install <plugin id>", Usage: "install <plugin id> <plugin version (optional)>",
Action: runCommand(installCommand), Action: runCommand(installCommand),
}, { }, {
Name: "list-remote", Name: "list-remote",
Usage: "list remote available plugins", Usage: "list remote available plugins",
Action: runCommand(listremoteCommand), Action: runCommand(listremoteCommand),
}, { }, {
Name: "list-versions",
Usage: "list-versions <plugin id>",
Action: runCommand(listversionsCommand),
}, {
Name: "update", Name: "update",
Usage: "update <plugin id>", Usage: "update <plugin id>",
Aliases: []string{"upgrade"}, Aliases: []string{"upgrade"},
......
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
}
...@@ -500,6 +500,19 @@ function($, _, moment) { ...@@ -500,6 +500,19 @@ function($, _, moment) {
kbn.valueFormats.s = function(size, decimals, scaledDecimals) { kbn.valueFormats.s = function(size, decimals, scaledDecimals) {
if (size === null) { return ""; } 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) { if (Math.abs(size) < 60) {
return kbn.toFixed(size, decimals) + " s"; return kbn.toFixed(size, decimals) + " s";
} }
......
...@@ -68,6 +68,11 @@ define([ ...@@ -68,6 +68,11 @@ define([
describeValueFormat('wps', 789000000, 1000000, -1, '789M wps'); describeValueFormat('wps', 789000000, 1000000, -1, '789M wps');
describeValueFormat('iops', 11000000000, 1000000000, -1, '11B iops'); 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', 24, 1, 0, '24 s');
describeValueFormat('s', 246, 1, 0, '4.1 min'); describeValueFormat('s', 246, 1, 0, '4.1 min');
describeValueFormat('s', 24567, 100, 0, '6.82 hour'); describeValueFormat('s', 24567, 100, 0, '6.82 hour');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment