Merge branch 'develop' into template_var_multi_select

This commit is contained in:
Torkel Ödegaard 2015-03-19 15:17:00 -04:00
commit 0d817e0664
5 changed files with 21 additions and 16 deletions

View File

@ -14,6 +14,7 @@ var (
ErrDashboardVersionMismatch = errors.New("The dashboard has been changed by someone else") ErrDashboardVersionMismatch = errors.New("The dashboard has been changed by someone else")
) )
// Dashboard model
type Dashboard struct { type Dashboard struct {
Id int64 Id int64
Slug string Slug string
@ -27,6 +28,7 @@ type Dashboard struct {
Data map[string]interface{} Data map[string]interface{}
} }
// NewDashboard creates a new dashboard
func NewDashboard(title string) *Dashboard { func NewDashboard(title string) *Dashboard {
dash := &Dashboard{} dash := &Dashboard{}
dash.Data = make(map[string]interface{}) dash.Data = make(map[string]interface{})
@ -36,6 +38,7 @@ func NewDashboard(title string) *Dashboard {
return dash return dash
} }
// GetTags turns the tags in data json into go string array
func (dash *Dashboard) GetTags() []string { func (dash *Dashboard) GetTags() []string {
jsonTags := dash.Data["tags"] jsonTags := dash.Data["tags"]
if jsonTags == nil { if jsonTags == nil {
@ -50,6 +53,7 @@ func (dash *Dashboard) GetTags() []string {
return b return b
} }
// GetDashboardModel turns the command into the savable model
func (cmd *SaveDashboardCommand) GetDashboardModel() *Dashboard { func (cmd *SaveDashboardCommand) GetDashboardModel() *Dashboard {
dash := &Dashboard{} dash := &Dashboard{}
dash.Data = cmd.Dashboard dash.Data = cmd.Dashboard
@ -63,15 +67,19 @@ func (cmd *SaveDashboardCommand) GetDashboardModel() *Dashboard {
if dash.Data["version"] != nil { if dash.Data["version"] != nil {
dash.Version = int(dash.Data["version"].(float64)) dash.Version = int(dash.Data["version"].(float64))
} }
} else {
dash.Data["version"] = 0
} }
return dash return dash
} }
// GetString a
func (dash *Dashboard) GetString(prop string) string { func (dash *Dashboard) GetString(prop string) string {
return dash.Data[prop].(string) return dash.Data[prop].(string)
} }
// UpdateSlug updates the slug
func (dash *Dashboard) UpdateSlug() { func (dash *Dashboard) UpdateSlug() {
title := strings.ToLower(dash.Data["title"].(string)) title := strings.ToLower(dash.Data["title"].(string))
re := regexp.MustCompile("[^\\w ]+") re := regexp.MustCompile("[^\\w ]+")

View File

@ -34,7 +34,7 @@
Scale type Scale type
</li> </li>
<li> <li>
<select class="input-small tight-form-input" style="width: 113px" ng-model="panel.grid.leftScale" ng-options="v as k for (k, v) in scaleTypes" ng-change="render()"></select> <select class="input-small tight-form-input" style="width: 113px" ng-model="panel.grid.leftLogBase" ng-options="v as k for (k, v) in logScales" ng-change="render()"></select>
</li> </li>
<li class="tight-form-item"> <li class="tight-form-item">
Label Label
@ -79,7 +79,7 @@
Scale type Scale type
</li> </li>
<li> <li>
<select class="input-small tight-form-input" style="width: 113px" ng-model="panel.grid.rightScale" ng-options="v as k for (k, v) in scaleTypes" ng-change="render()"></select> <select class="input-small tight-form-input" style="width: 113px" ng-model="panel.grid.rightLogBase" ng-options="v as k for (k, v) in logScales" ng-change="render()"></select>
</li> </li>
<li class="tight-form-item"> <li class="tight-form-item">
Label Label

View File

@ -351,7 +351,7 @@ function (angular, $, kbn, moment, _, GraphTooltip) {
show: scope.panel['y-axis'], show: scope.panel['y-axis'],
min: scope.panel.grid.leftMin, min: scope.panel.grid.leftMin,
index: 1, index: 1,
scale: scope.panel.grid.leftScale, logBase: scope.panel.grid.leftLogBase,
max: scope.panel.percentage && scope.panel.stack ? 100 : scope.panel.grid.leftMax, max: scope.panel.percentage && scope.panel.stack ? 100 : scope.panel.grid.leftMax,
}; };
@ -360,7 +360,7 @@ function (angular, $, kbn, moment, _, GraphTooltip) {
if (_.findWhere(data, {yaxis: 2})) { if (_.findWhere(data, {yaxis: 2})) {
var secondY = _.clone(defaults); var secondY = _.clone(defaults);
secondY.index = 2, secondY.index = 2,
secondY.scale = scope.panel.grid.rightScale; secondY.logBase = scope.panel.grid.rightLogBase;
secondY.position = 'right'; secondY.position = 'right';
secondY.min = scope.panel.grid.rightMin; secondY.min = scope.panel.grid.rightMin;
secondY.max = scope.panel.percentage && scope.panel.stack ? 100 : scope.panel.grid.rightMax; secondY.max = scope.panel.percentage && scope.panel.stack ? 100 : scope.panel.grid.rightMax;
@ -375,7 +375,7 @@ function (angular, $, kbn, moment, _, GraphTooltip) {
} }
function applyLogScale(axis, data) { function applyLogScale(axis, data) {
if (axis.scale !== 2) { if (axis.logBase !== 10) {
return; return;
} }
@ -393,22 +393,23 @@ function (angular, $, kbn, moment, _, GraphTooltip) {
} }
if (max === null) { if (max === null) {
max = 10000000000; max = Number.MAX_VALUE;
} }
} }
axis.ticks = [0, 1]; axis.min = axis.min !== null ? axis.min : 1;
axis.ticks = [1];
var tick = 1; var tick = 1;
while (true) { while (true) {
tick = tick*10; tick = tick * axis.logBase;
axis.ticks.push(tick); axis.ticks.push(tick);
if (tick > max) { if (tick > max) {
break; break;
} }
} }
axis.transform = function(v) { return Math.log(v+0.1); }; axis.transform = function(v) { return Math.log(v+0.001); };
axis.inverseTransform = function (v) { return Math.pow(10,v); }; axis.inverseTransform = function (v) { return Math.pow(10,v); };
} }

View File

@ -53,12 +53,12 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) {
y_formats : ['short', 'short'], y_formats : ['short', 'short'],
// grid options // grid options
grid : { grid : {
leftScale: 1, leftLogBase: 1,
leftMax: null, leftMax: null,
rightMax: null, rightMax: null,
leftMin: null, leftMin: null,
rightMin: null, rightMin: null,
rightScale: 1, rightLogBase: 1,
threshold1: null, threshold1: null,
threshold2: null, threshold2: null,
threshold1Color: 'rgba(216, 200, 27, 0.27)', threshold1Color: 'rgba(216, 200, 27, 0.27)',
@ -116,7 +116,7 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) {
_.defaults($scope.panel.grid, _d.grid); _.defaults($scope.panel.grid, _d.grid);
_.defaults($scope.panel.legend, _d.legend); _.defaults($scope.panel.legend, _d.legend);
$scope.scaleTypes = {'linear': 1, 'log (base 10)': 2}; $scope.logScales = {'linear': 1, 'log (base 10)': 10};
$scope.hiddenSeries = {}; $scope.hiddenSeries = {};
$scope.seriesList = []; $scope.seriesList = [];

View File

@ -5,10 +5,6 @@
background: @grafanaTargetBackground; background: @grafanaTargetBackground;
width: 100%; width: 100%;
.dropdown {
padding: 0; margin: 0;
}
&:last-child, &.last { &:last-child, &.last {
border-bottom: 1px solid @grafanaTargetBorder; border-bottom: 1px solid @grafanaTargetBorder;
} }