Merge branch 'master' into dashboard_loading_refactoring

Conflicts:
	src/app/partials/dashboard.html
	src/app/partials/dasheditor.html
	src/app/services/graphite/graphiteDatasource.js
This commit is contained in:
Torkel Ödegaard
2014-06-30 09:21:16 +02:00
12 changed files with 109 additions and 110 deletions

View File

@@ -1,5 +1,17 @@
vNext
**New features or improvements**
- Allow [[..]] filter notation in all text panels (markdown/html/text) (Issue #511)
**Changes**
- Use unix epoch for Graphite from/to for absolute time ranges (Closes #536)
**Fixes**
- Fix formatting negative values (PR #545)
# 1.6.1 (2014-06-24)
**New features or improvements**
- Ability to set y min/max for right y-axis (RR #519, Closes #360) - thx @acedrew

View File

@@ -4,7 +4,7 @@
"company": "Coding Instinct AB"
},
"name": "grafana",
"version": "1.6.0",
"version": "1.6.1",
"repository": {
"type": "git",
"url": "http://github.com/torkelo/grafana.git"

View File

@@ -481,23 +481,23 @@ function($, _, moment) {
};
kbn.msFormat = function(size, decimals) {
if (size < 1000) {
if (Math.abs(size) < 1000) {
return size.toFixed(0) + " ms";
}
// Less than 1 min
else if (size < 60000) {
else if (Math.abs(size) < 60000) {
return (size / 1000).toFixed(decimals) + " s";
}
// Less than 1 hour, devide in minutes
else if (size < 3600000) {
else if (Math.abs(size) < 3600000) {
return (size / 60000).toFixed(decimals) + " min";
}
// Less than one day, devide in hours
else if (size < 86400000) {
else if (Math.abs(size) < 86400000) {
return (size / 3600000).toFixed(decimals) + " hour";
}
// Less than one year, devide in days
else if (size < 31536000000) {
else if (Math.abs(size) < 31536000000) {
return (size / 86400000).toFixed(decimals) + " day";
}
@@ -506,23 +506,23 @@ function($, _, moment) {
kbn.sFormat = function(size, decimals) {
// Less than 10 min, use seconds
if (size < 600) {
if (Math.abs(size) < 600) {
return size.toFixed(decimals) + " s";
}
// Less than 1 hour, devide in minutes
else if (size < 3600) {
else if (Math.abs(size) < 3600) {
return (size / 60).toFixed(decimals) + " min";
}
// Less than one day, devide in hours
else if (size < 86400) {
else if (Math.abs(size) < 86400) {
return (size / 3600).toFixed(decimals) + " hour";
}
// Less than one week, devide in days
else if (size < 604800) {
else if (Math.abs(size) < 604800) {
return (size / 86400).toFixed(decimals) + " day";
}
// Less than one year, devide in week
else if (size < 31536000) {
else if (Math.abs(size) < 31536000) {
return (size / 604800).toFixed(decimals) + " week";
}
@@ -530,10 +530,10 @@ function($, _, moment) {
};
kbn.microsFormat = function(size, decimals) {
if (size < 1000) {
if (Math.abs(size) < 1000) {
return size.toFixed(0) + " µs";
}
else if (size < 1000000) {
else if (Math.abs(size) < 1000000) {
return (size / 1000).toFixed(decimals) + " ms";
}
else {
@@ -542,16 +542,16 @@ function($, _, moment) {
};
kbn.nanosFormat = function(size, decimals) {
if (size < 1000) {
if (Math.abs(size) < 1000) {
return size.toFixed(0) + " ns";
}
else if (size < 1000000) {
else if (Math.abs(size) < 1000000) {
return (size / 1000).toFixed(decimals) + " µs";
}
else if (size < 1000000000) {
else if (Math.abs(size) < 1000000000) {
return (size / 1000000).toFixed(decimals) + " ms";
}
else if (size < 60000000000){
else if (Math.abs(size) < 60000000000){
return (size / 1000000000).toFixed(decimals) + " s";
}
else {

View File

@@ -24,7 +24,7 @@
"type": "text",
"loadingEditor": false,
"mode": "markdown",
"content": "####Thank you for trying out Grafana! \n\nGeneral documentation is found in the readme and in the wiki section of the [Github Project](https://github.com/torkelo/grafana). If you encounter any problem or have an idea for an improvement do not hesitate to open a github issue. \n\nTips: \n\n- Ctrl+S saves the current dashboard\n- Ctrl+F Opens the dashboard finder (searches elastic search)\n- Ctrl+H Hide/show row controls \n- Click and drag graph title to move panel (only works when row controls are enabled)\n\nIf you do not see a graph in the panel bellow the browser cannot access your graphite installation. Please make sure that the graphiteUrl property in config.js is correctly set and accessible.",
"content": "####Thank you for trying out Grafana! \n\nGeneral documentation is found in the readme and in the wiki section of the [Github Project](https://github.com/torkelo/grafana). If you encounter any problem or have an idea for an improvement do not hesitate to open a github issue. \n\nTips: \n\n- Ctrl+S saves the current dashboard\n- Ctrl+F Opens the dashboard finder (searches elastic search)\n- Ctrl+H Hide/show row controls \n- Click and drag graph title to move panel (only works when row controls are enabled)\n\nIf you do not see a graph in the panel below the browser cannot access your graphite installation. Please make sure that datasources property in config.js is correctly set and that any urls accessible from your browser.",
"style": {},
"title": "Welcome to Grafana"
}
@@ -41,7 +41,7 @@
{
"span": 12,
"editable": true,
"type": "graphite",
"type": "graph",
"x-axis": true,
"y-axis": true,
"scale": 1,

View File

@@ -1,10 +1,4 @@
<div ng-controller='text' ng-init="init()" style="min-height:{{panel.height || row.height}}" ng-dblclick="openEditor()">
<!--<p ng-style="panel.style" ng-bind-html-unsafe="panel.content | striphtml | newlines"></p>-->
<markdown ng-show="ready && panel.mode == 'markdown'">
{{panel.content}}
</markdown>
<p ng-show="panel.mode == 'text'" ng-style='panel.style' ng-bind-html-unsafe="panel.content | striphtml | newlines">
</p>
<p ng-show="panel.mode == 'html'" ng-bind-html-unsafe="panel.content">
<p ng-bind-html-unsafe="content">
</p>
</div>

View File

@@ -14,7 +14,8 @@ define([
'angular',
'app',
'underscore',
'require'
'require',
'services/filterSrv'
],
function (angular, app, _, require) {
'use strict';
@@ -22,7 +23,7 @@ function (angular, app, _, require) {
var module = angular.module('kibana.panels.text', []);
app.useModule(module);
module.controller('text', function($scope) {
module.controller('text', function($scope, filterSrv) {
$scope.panelMeta = {
description : "A static text panel that can use plain text, markdown, or (sanitized) HTML"
@@ -39,63 +40,58 @@ function (angular, app, _, require) {
$scope.init = function() {
$scope.initBaseController(this, $scope);
$scope.ready = false;
$scope.$on('refresh', $scope.render);
$scope.render();
};
$scope.render = function() {
$scope.$emit('render');
if ($scope.panel.mode === 'markdown') {
$scope.renderMarkdown($scope.panel.content);
}
else if ($scope.panel.mode === 'html') {
$scope.updateContent($scope.panel.content);
}
else if ($scope.panel.mode === 'text') {
$scope.renderText($scope.panel.content);
}
};
$scope.renderText = function(content) {
content = content
.replace(/&/g, '&amp;')
.replace(/>/g, '&gt;')
.replace(/</g, '&lt;')
.replace(/\n/g, '<br/>');
$scope.updateContent(content);
};
$scope.renderMarkdown = function(content) {
require(['./lib/showdown'], function (Showdown) {
var converter = new Showdown.converter();
var text = content
.replace(/&/g, '&amp;')
.replace(/>/g, '&gt;')
.replace(/</g, '&lt;');
$scope.updateContent(converter.makeHtml(text));
});
};
$scope.updateContent = function(html) {
try {
$scope.content = filterSrv.applyTemplateToTarget(html);
if(!$scope.$$phase) {
$scope.$apply();
}
} catch(e) {
}
};
$scope.openEditor = function() {
//$scope.$emit('open-modal','paneleditor');
console.log('scope id', $scope.$id);
};
});
module.directive('markdown', function() {
return {
restrict: 'E',
link: function(scope, element) {
scope.$on('render', function() {
render_panel();
});
function render_panel() {
require(['./lib/showdown'], function (Showdown) {
scope.ready = true;
var converter = new Showdown.converter();
var text = scope.panel.content.replace(/&/g, '&amp;')
.replace(/>/g, '&gt;')
.replace(/</g, '&lt;');
var htmlText = converter.makeHtml(text);
element.html(htmlText);
// For whatever reason, this fixes chrome. I don't like it, I think
// it makes things slow?
if(!scope.$$phase) {
scope.$apply();
}
});
}
render_panel();
}
};
});
module.filter('newlines', function() {
return function (input) {
return input.replace(/\n/g, '<br/>');
};
});
module.filter('striphtml', function () {
return function(text) {
return text
.replace(/&/g, '&amp;')
.replace(/>/g, '&gt;')
.replace(/</g, '&lt;');
};
});
});

View File

@@ -51,32 +51,32 @@
</span>
<ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="drop1">
<li class="dropdown-submenu">
<a href="javascript:void();">Add Panel</a>
<a href="javascript:void(0);">Add Panel</a>
<ul class="dropdown-menu">
<li><a ng-click="add_panel_default('graph')">Graph</li></a>
<li><a ng-click="add_panel_default('text')">Text</li></a>
<li><a ng-click="add_panel_default('graph')">Graph</a></li>
<li><a ng-click="add_panel_default('text')">Text</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a href="javascript:void();">Set height</a>
<a href="javascript:void(0);">Set height</a>
<ul class="dropdown-menu">
<li><a ng-click="set_height('100px')">100 px</li></a>
<li><a ng-click="set_height('150px')">150 px</li></a>
<li><a ng-click="set_height('200px')">200 px</li></a>
<li><a ng-click="set_height('250px')">250 px</li></a>
<li><a ng-click="set_height('300px')">300 px</li></a>
<li><a ng-click="set_height('350px')">350 px</li></a>
<li><a ng-click="set_height('450px')">450 px</li></a>
<li><a ng-click="set_height('500px')">500 px</li></a>
<li><a ng-click="set_height('600px')">600 px</li></a>
<li><a ng-click="set_height('700px')">700 px</li></a>
<li><a ng-click="set_height('100px')">100 px</a></li>
<li><a ng-click="set_height('150px')">150 px</a></li>
<li><a ng-click="set_height('200px')">200 px</a></li>
<li><a ng-click="set_height('250px')">250 px</a></li>
<li><a ng-click="set_height('300px')">300 px</a></li>
<li><a ng-click="set_height('350px')">350 px</a></li>
<li><a ng-click="set_height('450px')">450 px</a></li>
<li><a ng-click="set_height('500px')">500 px</a></li>
<li><a ng-click="set_height('600px')">600 px</a></li>
<li><a ng-click="set_height('700px')">700 px</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a href="javascript:void();">Move</a>
<a href="javascript:void(0);">Move</a>
<ul class="dropdown-menu">
<li><a ng-click="move_row(-1)">Up</li></a>
<li><a ng-click="move_row(1)">Down</li></a>
<li><a ng-click="move_row(-1)">Up</a></li>
<li><a ng-click="move_row(1)">Down</a></li>
</ul>
</li>
<li>

View File

@@ -47,8 +47,9 @@
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-success" ng-click="start();dismiss();"><i class="icon-play"></i> Start</button>
<button type="button" class="btn btn-primary" ng-click="dismiss();"><i class="icon-ban-circle"></i> Cancel</button>
<div class="modal-footer">
<button class="btn btn-success" ng-click="start();dismiss();"><i class="icon-play"></i> Start</button>
<button type="button" class="btn btn-primary" ng-click="dismiss();"><i class="icon-ban-circle"></i> Cancel</button>
</div>
</div>
</div>

View File

@@ -120,3 +120,4 @@
</form>
</div>
</li>
</ul>

View File

@@ -63,6 +63,11 @@ function (_) {
category: categories.Combine,
});
addFuncDef({
name: 'diffSeries',
category: categories.Combine,
});
addFuncDef({
name: 'averageSeries',
shortName: 'avg',

View File

@@ -104,15 +104,7 @@ function (angular, _, $, config, kbn, moment) {
}
}
if (timezone === 'browser') {
date = date.local();
}
if (config.timezoneOffset) {
date = date.zone(config.timezoneOffset);
}
return date.format('HH:mm_YYYYMMDD');
return date.unix();
};
GraphiteDatasource.prototype.metricFindQuery = function(filterSrv, query) {

View File

@@ -33,9 +33,7 @@ function (angular, _, kbn) {
var groupByTags = {};
_.each(queries, function(query) {
_.each(query.tags, function(val, key) {
if (val === "*") {
groupByTags[key] = true;
}
groupByTags[key] = true;
});
});