diff --git a/.floo b/.floo index 1201c5e93b9..1c2038f98cc 100644 --- a/.floo +++ b/.floo @@ -1,3 +1,3 @@ { - "url": "https://floobits.com/raintank/grafana" -} \ No newline at end of file + "url": "https://floobits.com/raintank/grafana" +} diff --git a/.flooignore b/.flooignore index b300a62c4da..43cddf93bdf 100644 --- a/.flooignore +++ b/.flooignore @@ -5,5 +5,8 @@ *~ extern/ node_modules/ -tmp -vendor/ \ No newline at end of file +tmp/ +data/ +vendor/ +public_gen/ +dist/ diff --git a/CHANGELOG.md b/CHANGELOG.md index e9beca0c761..d37e5ba9e1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,22 @@ -# 3.0.2 Stable (unreleased) +# 3.1.0 + +### Enhancements +* **Singlestat**: Add support for range to text mappings, closes [#1319](https://github.com/grafana/grafana/issues/1319) +* **Graph**: Adds sort order options for graph tooltip, closes [#1189](https://github.com/grafana/grafana/issues/1189) +* **Theme**: Add default theme to config file [#5011](https://github.com/grafana/grafana/pull/5011) + +# 3.0.2 Stable (2016-05-16) * **Templating**: Fixed issue mixing row repeat and panel repeats, fixes [#4988](https://github.com/grafana/grafana/issues/4988) * **Templating**: Fixed issue detecting dependencies in nested variables, fixes [#4987](https://github.com/grafana/grafana/issues/4987), fixes [#4986](https://github.com/grafana/grafana/issues/4986) +* **Graph**: Fixed broken PNG rendering in graph panel, fixes [#5025](https://github.com/grafana/grafana/issues/5025) +* **Graph**: Fixed broken xaxis on graph panel, fixes [#5024](https://github.com/grafana/grafana/issues/5024) + +* **Influxdb**: Fixes crash when hiding middle serie, fixes [#5005](https://github.com/grafana/grafana/issues/5005) # 3.0.1 Stable (2016-05-11) +### Bug fixes * **Templating**: Fixed issue with new data source variable not persisting current selected value, fixes [#4934](https://github.com/grafana/grafana/issues/4934) # 3.0.0-beta7 (2016-05-02) diff --git a/README.md b/README.md index 18a497092f2..6dbfc5388c2 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Graphite, Elasticsearch, OpenTSDB, Prometheus and InfluxDB. - [What's New in Grafana 2.0](http://docs.grafana.org/guides/whats-new-in-v2/) - [What's New in Grafana 2.1](http://docs.grafana.org/guides/whats-new-in-v2-1/) - [What's New in Grafana 2.5](http://docs.grafana.org/guides/whats-new-in-v2-5/) +- [What's New in Grafana 3.0](http://docs.grafana.org/guides/whats-new-in-v3/) ## Features ### Graphite Target Editor diff --git a/conf/defaults.ini b/conf/defaults.ini index f78287619a3..0a4b61fbe78 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -172,6 +172,9 @@ verify_email_enabled = false # Background text for the user field on the login page login_hint = email or username +# Default UI theme ("dark" or "light") +default_theme = dark + #################################### Anonymous Auth ########################## [auth.anonymous] # enable anonymous access diff --git a/conf/sample.ini b/conf/sample.ini index 6a26589d40d..7f358b07199 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -155,6 +155,9 @@ check_for_updates = true # Background text for the user field on the login page ;login_hint = email or username +# Default UI theme ("dark" or "light") +;default_theme = dark + #################################### Anonymous Auth ########################## [auth.anonymous] # enable anonymous access diff --git a/docker/blocks/graphite/fig b/docker/blocks/graphite/fig index 84da45341e1..4268641d32f 100644 --- a/docker/blocks/graphite/fig +++ b/docker/blocks/graphite/fig @@ -8,3 +8,10 @@ graphite: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro +fake-data-gen: + image: grafana/fake-data-gen + net: bridge + environment: + FD_DATASOURCE: graphite + FD_PORT: 2003 + diff --git a/docker/blocks/influxdb/fig b/docker/blocks/influxdb/fig index c537a74b003..0dc69cb6b72 100644 --- a/docker/blocks/influxdb/fig +++ b/docker/blocks/influxdb/fig @@ -4,3 +4,11 @@ influxdb: - "2004:2004" - "8083:8083" - "8086:8086" + +fake-data-gen: + image: grafana/fake-data-gen + net: bridge + environment: + FD_DATASOURCE: influxdb + FD_PORT: 8086 + diff --git a/docker/blocks/opentsdb/fig b/docker/blocks/opentsdb/fig index 34bbf4b854c..705d746a864 100644 --- a/docker/blocks/opentsdb/fig +++ b/docker/blocks/opentsdb/fig @@ -2,4 +2,10 @@ opentsdb: image: opower/opentsdb:latest ports: - "4242:4242" - + +fake-data-gen: + image: grafana/fake-data-gen + net: bridge + environment: + FD_DATASOURCE: opentsdb + diff --git a/docker/blocks/prometheus/fig b/docker/blocks/prometheus/fig index 0880902c9fd..aa00e1b6272 100644 --- a/docker/blocks/prometheus/fig +++ b/docker/blocks/prometheus/fig @@ -1,6 +1,16 @@ prometheus: build: blocks/prometheus + net: bridge ports: - "9090:9090" volumes: - /var/docker/prometheus:/prometheus-data + +fake-data-gen: + image: grafana/fake-data-gen + net: bridge + ports: + - "9091:9091" + environment: + FD_DATASOURCE: prom + diff --git a/docs/sources/datasources/opentsdb.md b/docs/sources/datasources/opentsdb.md index 28d90c19b00..6ef930c0cc0 100644 --- a/docs/sources/datasources/opentsdb.md +++ b/docs/sources/datasources/opentsdb.md @@ -7,10 +7,10 @@ page_keywords: grafana, opentsdb, documentation # OpenTSDB Guide The newest release of Grafana adds additional functionality when using an OpenTSDB Data source. -![](/img/v2/add_OpenTSDB.jpg) +![](/img/v2/add_OpenTSDB.png) -1. Open the side menu by clicking the the Grafana icon in the top header. -2. In the side menu under the `Dashboards` link you should find a link named `Data Sources`. +1. Open the side menu by clicking the the Grafana icon in the top header. +2. In the side menu under the `Dashboards` link you should find a link named `Data Sources`. > NOTE: If this link is missing in the side menu it means that your current user does not have the `Admin` role for the current organization. diff --git a/docs/sources/installation/debian.md b/docs/sources/installation/debian.md index 363cd4dcf7e..1b3957fa684 100644 --- a/docs/sources/installation/debian.md +++ b/docs/sources/installation/debian.md @@ -10,13 +10,13 @@ page_keywords: grafana, installation, debian, ubuntu, guide Description | Download ------------ | ------------- -Stable .deb for Debian-based Linux | [grafana_3.0.1_amd64.deb](https://grafanarel.s3.amazonaws.com/builds/grafana_3.0.1_amd64.deb) +Stable .deb for Debian-based Linux | [grafana_3.0.2-1463383025_amd64.deb](https://grafanarel.s3.amazonaws.com/builds/grafana_3.0.2-1463383025_amd64.deb) ## Install Stable - $ wget https://grafanarel.s3.amazonaws.com/builds/grafana_3.0.1_amd64.deb + $ wget https://grafanarel.s3.amazonaws.com/builds/grafana_3.0.2-1463383025_amd64.deb $ sudo apt-get install -y adduser libfontconfig - $ sudo dpkg -i grafana_3.0.1_amd64.deb + $ sudo dpkg -i grafana_3.0.2-1463383025_amd64.deb ## APT Repository diff --git a/docs/sources/installation/rpm.md b/docs/sources/installation/rpm.md index a49378203c7..af3ae7f8288 100644 --- a/docs/sources/installation/rpm.md +++ b/docs/sources/installation/rpm.md @@ -10,24 +10,24 @@ page_keywords: grafana, installation, centos, fedora, opensuse, redhat, guide Description | Download ------------ | ------------- -Stable .RPM for CentOS / Fedora / OpenSuse / Redhat Linux | [grafana-3.0.1-1.x86_64.rpm](https://grafanarel.s3.amazonaws.com/builds/grafana-3.0.1-1.x86_64.rpm) +Stable .RPM for CentOS / Fedora / OpenSuse / Redhat Linux | [grafana-3.0.2-1463383025.x86_64.rpm](https://grafanarel.s3.amazonaws.com/builds/grafana-3.0.2-1463383025.x86_64.rpm) ## Install Stable Release from package file You can install Grafana using Yum directly. - $ sudo yum install https://grafanarel.s3.amazonaws.com/builds/grafana-3.0.1-1.x86_64.rpm + $ sudo yum install https://grafanarel.s3.amazonaws.com/builds/grafana-3.0.2-1463383025.x86_64.rpm Or install manually using `rpm`. #### On CentOS / Fedora / Redhat: $ sudo yum install initscripts fontconfig - $ sudo rpm -Uvh grafana-3.0.1-1.x86_64.rpm + $ sudo rpm -Uvh grafana-3.0.2-1463383025.x86_64.rpm #### On OpenSuse: - $ sudo rpm -i --nodeps grafana-3.0.1-1.x86_64.rpm + $ sudo rpm -i --nodeps grafana-3.0.2-1463383025.x86_64.rpm ## Install via YUM Repository diff --git a/docs/sources/installation/windows.md b/docs/sources/installation/windows.md index 1d6c5fc76cd..baa13d0350c 100644 --- a/docs/sources/installation/windows.md +++ b/docs/sources/installation/windows.md @@ -10,7 +10,7 @@ page_keywords: grafana, installation, windows guide Description | Download ------------ | ------------- -Stable Zip package for Windows | [grafana.2.6.0.windows-x64.zip](https://grafanarel.s3.amazonaws.com/winbuilds/dist/grafana-2.5.0.windows-x64.zip) +Stable Zip package for Windows | [grafana.3.0.2.windows-x64.zip](https://grafanarel.s3.amazonaws.com/winbuilds/dist/grafana-3.0.2.windows-x64.zip) ## Configure diff --git a/latest.json b/latest.json index 4afdb750b3f..443a440a529 100644 --- a/latest.json +++ b/latest.json @@ -1,4 +1,4 @@ { - "stable": "3.0.1", - "testing": "3.0.1" + "stable": "3.0.2", + "testing": "3.0.2" } diff --git a/package.json b/package.json index b9b87ab6e75..e4bb7adaba0 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "company": "Coding Instinct AB" }, "name": "grafana", - "version": "3.0.2", + "version": "3.1.0", "repository": { "type": "git", "url": "http://github.com/grafana/grafana.git" diff --git a/packaging/deb/default/grafana-server b/packaging/deb/default/grafana-server index cc5ee866f7d..dd06906b903 100644 --- a/packaging/deb/default/grafana-server +++ b/packaging/deb/default/grafana-server @@ -14,6 +14,6 @@ CONF_DIR=/etc/grafana CONF_FILE=/etc/grafana/grafana.ini -RESTART_ON_UPGRADE=true +RESTART_ON_UPGRADE=false PLUGINS_DIR=/var/lib/grafana/plugins diff --git a/packaging/rpm/sysconfig/grafana-server b/packaging/rpm/sysconfig/grafana-server index cc5ee866f7d..dd06906b903 100644 --- a/packaging/rpm/sysconfig/grafana-server +++ b/packaging/rpm/sysconfig/grafana-server @@ -14,6 +14,6 @@ CONF_DIR=/etc/grafana CONF_FILE=/etc/grafana/grafana.ini -RESTART_ON_UPGRADE=true +RESTART_ON_UPGRADE=false PLUGINS_DIR=/var/lib/grafana/plugins diff --git a/pkg/api/frontendsettings.go b/pkg/api/frontendsettings.go index dd84f7827eb..9fcd5e567fb 100644 --- a/pkg/api/frontendsettings.go +++ b/pkg/api/frontendsettings.go @@ -142,6 +142,7 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro "buildstamp": setting.BuildStamp, "latestVersion": plugins.GrafanaLatestVersion, "hasUpdate": plugins.GrafanaHasUpdate, + "env": setting.Env, }, } diff --git a/pkg/cmd/grafana-cli/commands/upgrade_command.go b/pkg/cmd/grafana-cli/commands/upgrade_command.go index b9ca834be6d..e788b3bdfaa 100644 --- a/pkg/cmd/grafana-cli/commands/upgrade_command.go +++ b/pkg/cmd/grafana-cli/commands/upgrade_command.go @@ -1,6 +1,8 @@ package commands import ( + "github.com/fatih/color" + "github.com/grafana/grafana/pkg/cmd/grafana-cli/log" s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services" ) @@ -14,20 +16,17 @@ func upgradeCommand(c CommandLine) error { return err } - remotePlugins, err2 := s.ListAllPlugins(c.GlobalString("repo")) + v, err2 := s.GetPlugin(localPlugin.Id, c.GlobalString("repo")) if err2 != nil { return err2 } - for _, v := range remotePlugins.Plugins { - if localPlugin.Id == v.Id { - if ShouldUpgrade(localPlugin.Info.Version, v) { - s.RemoveInstalledPlugin(pluginsDir, pluginName) - return InstallPlugin(localPlugin.Id, "", c) - } - } + if ShouldUpgrade(localPlugin.Info.Version, v) { + s.RemoveInstalledPlugin(pluginsDir, pluginName) + return InstallPlugin(localPlugin.Id, "", c) } + log.Infof("%s %s is up to date \n", color.GreenString("✔"), localPlugin.Id) return nil } diff --git a/pkg/cmd/grafana-cli/services/services.go b/pkg/cmd/grafana-cli/services/services.go index f0ad460842d..2332511ed89 100644 --- a/pkg/cmd/grafana-cli/services/services.go +++ b/pkg/cmd/grafana-cli/services/services.go @@ -44,7 +44,7 @@ func ReadPlugin(pluginDir, pluginName string) (m.InstalledPlugin, error) { } if res.Id == "" { - return m.InstalledPlugin{}, errors.New("could not read find plugin " + pluginName) + return m.InstalledPlugin{}, errors.New("could not find plugin " + pluginName + " in " + pluginDir) } return res, nil @@ -69,13 +69,21 @@ func RemoveInstalledPlugin(pluginPath, id string) error { } func GetPlugin(pluginId, repoUrl string) (m.Plugin, error) { - resp, _ := ListAllPlugins(repoUrl) + fullUrl := repoUrl + "/repo/" + pluginId - for _, i := range resp.Plugins { - if i.Id == pluginId { - return i, nil - } + res, err := goreq.Request{Uri: fullUrl, MaxRedirects: 3}.Do() + if err != nil { + return m.Plugin{}, err + } + if res.StatusCode != 200 { + return m.Plugin{}, fmt.Errorf("Could not access %s statuscode %v", fullUrl, res.StatusCode) } - return m.Plugin{}, errors.New("could not find plugin named \"" + pluginId + "\"") + var resp m.Plugin + err = res.Body.FromJsonTo(&resp) + if err != nil { + return m.Plugin{}, errors.New("Could not load plugin data") + } + + return resp, nil } diff --git a/pkg/plugins/queries.go b/pkg/plugins/queries.go index b930c9575a3..5ae1825a88f 100644 --- a/pkg/plugins/queries.go +++ b/pkg/plugins/queries.go @@ -24,7 +24,16 @@ func GetPluginSettings(orgId int64) (map[string]*m.PluginSettingInfoDTO, error) } // default to enabled true - opt := &m.PluginSettingInfoDTO{Enabled: true} + opt := &m.PluginSettingInfoDTO{ + PluginId: pluginDef.Id, + OrgId: orgId, + Enabled: true, + } + + // apps are disabled by default + if pluginDef.Type == PluginTypeApp { + opt.Enabled = false + } // if it's included in app check app settings if pluginDef.IncludedInAppId != "" { diff --git a/pkg/services/sqlstore/preferences.go b/pkg/services/sqlstore/preferences.go index d120c485ed3..65609a9c57c 100644 --- a/pkg/services/sqlstore/preferences.go +++ b/pkg/services/sqlstore/preferences.go @@ -5,6 +5,8 @@ import ( "github.com/grafana/grafana/pkg/bus" m "github.com/grafana/grafana/pkg/models" + + "github.com/grafana/grafana/pkg/setting" ) func init() { @@ -26,7 +28,7 @@ func GetPreferencesWithDefaults(query *m.GetPreferencesWithDefaultsQuery) error } res := &m.Preferences{ - Theme: "dark", + Theme: setting.DefaultTheme, Timezone: "browser", HomeDashboardId: 0, } diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 2d1bad945eb..b883a8d995d 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -88,6 +88,7 @@ var ( AutoAssignOrgRole string VerifyEmailEnabled bool LoginHint string + DefaultTheme string // Http auth AdminUser string @@ -454,6 +455,7 @@ func NewConfigContext(args *CommandLineArgs) error { AutoAssignOrgRole = users.Key("auto_assign_org_role").In("Editor", []string{"Editor", "Admin", "Read Only Editor", "Viewer"}) VerifyEmailEnabled = users.Key("verify_email_enabled").MustBool(false) LoginHint = users.Key("login_hint").String() + DefaultTheme = users.Key("default_theme").String() // anonymous access AnonymousEnabled = Cfg.Section("auth.anonymous").Key("enabled").MustBool(false) diff --git a/public/app/app.ts b/public/app/app.ts index 3434814d3b6..6de7181f5a1 100644 --- a/public/app/app.ts +++ b/public/app/app.ts @@ -42,7 +42,9 @@ export class GrafanaApp { app.constant('grafanaVersion', "@grafanaVersion@"); app.config(($locationProvider, $controllerProvider, $compileProvider, $filterProvider, $provide) => { - //$compileProvider.debugInfoEnabled(false); + if (config.buildInfo.env !== 'development') { + $compileProvider.debugInfoEnabled(false); + } this.registerFunctions.controller = $controllerProvider.register; this.registerFunctions.directive = $compileProvider.directive; diff --git a/public/app/core/utils/kbn.js b/public/app/core/utils/kbn.js index 11a544d2708..9d714c34fb3 100644 --- a/public/app/core/utils/kbn.js +++ b/public/app/core/utils/kbn.js @@ -396,6 +396,7 @@ function($, _) { kbn.valueFormats.ev = kbn.formatBuilders.decimalSIPrefix('eV'); kbn.valueFormats.amp = kbn.formatBuilders.decimalSIPrefix('A'); kbn.valueFormats.volt = kbn.formatBuilders.decimalSIPrefix('V'); + kbn.valueFormats.dBm = kbn.formatBuilders.decimalSIPrefix('dBm'); // Temperature kbn.valueFormats.celsius = kbn.formatBuilders.fixedUnit('°C'); @@ -677,6 +678,7 @@ function($, _) { {text: 'electron volt (eV)', value: 'ev' }, {text: 'Ampere (A)', value: 'amp' }, {text: 'Volt (V)', value: 'volt' }, + {text: 'Decibel-milliwatt (dBm)', value: 'dBm' }, ] }, { diff --git a/public/app/features/panel/metrics_ds_selector.ts b/public/app/features/panel/metrics_ds_selector.ts index b281c43048b..c0e1b776062 100644 --- a/public/app/features/panel/metrics_ds_selector.ts +++ b/public/app/features/panel/metrics_ds_selector.ts @@ -10,7 +10,7 @@ var template = `
-
+
- +
- +
+
+ +
+ +
+
diff --git a/public/app/plugins/panel/singlestat/editor.html b/public/app/plugins/panel/singlestat/editor.html index fc3c9f69542..0504277a5e1 100644 --- a/public/app/plugins/panel/singlestat/editor.html +++ b/public/app/plugins/panel/singlestat/editor.html @@ -204,35 +204,3 @@
- -
-
-
-
    -
  • - Value to text mapping -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • - -
  • - - - -
  • - -
-
-
-
-
diff --git a/public/app/plugins/panel/singlestat/mappings.html b/public/app/plugins/panel/singlestat/mappings.html new file mode 100644 index 00000000000..8dd1c94768e --- /dev/null +++ b/public/app/plugins/panel/singlestat/mappings.html @@ -0,0 +1,58 @@ +
+
+
+ + Type + +
+ +
+
+
+
+
+
Set value mappings
+
+
+ + + + + + + + +
+ +
+ +
+
+
+
+
Set range mappings
+
+
+ + + + From + + To + + Text + +
+ +
+ +
+
+
diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index 9fa3e8e39c6..de272478fbc 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -35,6 +35,14 @@ class SingleStatCtrl extends MetricsPanelCtrl { valueMaps: [ { value: 'null', op: '=', text: 'N/A' } ], + mappingTypes: [ + {name: 'value to text', value: 1}, + {name: 'range to text', value: 2}, + ], + rangeMaps: [ + { from: 'null', to: 'null', text: 'N/A' } + ], + mappingType: 1, nullPointMode: 'connected', valueName: 'avg', prefixFontSize: '50%', @@ -73,6 +81,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { onInitEditMode() { this.fontSizes = ['20%', '30%','50%','70%','80%','100%', '110%', '120%', '150%', '170%', '200%']; this.addEditorTab('Options', 'public/app/plugins/panel/singlestat/editor.html', 2); + this.addEditorTab('Value Mappings', 'public/app/plugins/panel/singlestat/mappings.html', 3); this.unitFormats = kbn.getUnitFormats(); } @@ -192,23 +201,45 @@ class SingleStatCtrl extends MetricsPanelCtrl { } } - // check value to text mappings - for (var i = 0; i < this.panel.valueMaps.length; i++) { - var map = this.panel.valueMaps[i]; - // special null case - if (map.value === 'null') { - if (data.value === null || data.value === void 0) { + // check value to text mappings if its enabled + if (this.panel.mappingType === 1) { + for (var i = 0; i < this.panel.valueMaps.length; i++) { + var map = this.panel.valueMaps[i]; + // special null case + if (map.value === 'null') { + if (data.value === null || data.value === void 0) { + data.valueFormated = map.text; + return; + } + continue; + } + + // value/number to text mapping + var value = parseFloat(map.value); + if (value === data.valueRounded) { data.valueFormated = map.text; return; } - continue; } + } else if (this.panel.mappingType === 2) { + for (var i = 0; i < this.panel.rangeMaps.length; i++) { + var map = this.panel.rangeMaps[i]; + // special null case + if (map.from === 'null' && map.to === 'null') { + if (data.value === null || data.value === void 0) { + data.valueFormated = map.text; + return; + } + continue; + } - // value/number to text mapping - var value = parseFloat(map.value); - if (value === data.valueRounded) { - data.valueFormated = map.text; - return; + // value/number to range mapping + var from = parseFloat(map.from); + var to = parseFloat(map.to); + if (to >= data.valueRounded && from <= data.valueRounded) { + data.valueFormated = map.text; + return; + } } } @@ -227,6 +258,16 @@ class SingleStatCtrl extends MetricsPanelCtrl { this.panel.valueMaps.push({value: '', op: '=', text: '' }); } + removeRangeMap(rangeMap) { + var index = _.indexOf(this.panel.rangeMaps, rangeMap); + this.panel.rangeMaps.splice(index, 1); + this.render(); + }; + + addRangeMap() { + this.panel.rangeMaps.push({from: '', to: '', text: ''}); + } + link(scope, elem, attrs, ctrl) { var $location = this.$location; var linkSrv = this.linkSrv; diff --git a/public/app/plugins/panel/singlestat/specs/singlestat-specs.ts b/public/app/plugins/panel/singlestat/specs/singlestat-specs.ts index dc85454b64a..3d6c565443b 100644 --- a/public/app/plugins/panel/singlestat/specs/singlestat-specs.ts +++ b/public/app/plugins/panel/singlestat/specs/singlestat-specs.ts @@ -84,4 +84,29 @@ describe('SingleStatCtrl', function() { expect(ctx.data.valueFormated).to.be('OK'); }); }); + + singleStatScenario('When range to text mapping is specifiedfor first range', function(ctx) { + ctx.setup(function() { + ctx.datapoints = [[41,50]]; + ctx.ctrl.panel.mappingType = 2; + ctx.ctrl.panel.rangeMaps = [{from: '10', to: '50', text: 'OK'},{from: '51', to: '100', text: 'NOT OK'}]; + }); + + it('Should replace value with text OK', function() { + expect(ctx.data.valueFormated).to.be('OK'); + }); + }); + + singleStatScenario('When range to text mapping is specified for other ranges', function(ctx) { + ctx.setup(function() { + ctx.datapoints = [[65,75]]; + ctx.ctrl.panel.mappingType = 2; + ctx.ctrl.panel.rangeMaps = [{from: '10', to: '50', text: 'OK'},{from: '51', to: '100', text: 'NOT OK'}]; + }); + + it('Should replace value with text NOT OK', function() { + expect(ctx.data.valueFormated).to.be('NOT OK'); + }); + }); + });