Commit 9e3514a9 by Torkel Ödegaard

More small performance tweaks, trying to clean up watcher & scope counts

parent aee3ddd0
/** @scratch /panels/5
* include::panels/text.asciidoc[]
*/
/** @scratch /panels/text/0
* == text
* Status: *Stable*
*
* The text panel is used for displaying static text formated as markdown, sanitized html or as plain
* text.
*
*/
define([
'angular',
'app',
......@@ -23,6 +11,8 @@ function (angular, app, _, require) {
var module = angular.module('grafana.panels.text', []);
app.useModule(module);
var converter;
module.controller('text', function($scope, filterSrv, $sce, panelSrv) {
$scope.panelMeta = {
......@@ -68,15 +58,21 @@ function (angular, app, _, require) {
};
$scope.renderMarkdown = function(content) {
require(['./lib/showdown'], function (Showdown) {
var converter = new Showdown.converter();
var text = content
.replace(/&/g, '&')
.replace(/>/g, '>')
.replace(/</g, '&lt;');
if (converter) {
console.log("markdown render cached");
$scope.updateContent(converter.makeHtml(text));
}
else {
require(['./lib/showdown'], function (Showdown) {
converter = new Showdown.converter();
$scope.updateContent(converter.makeHtml(text));
});
}
};
$scope.updateContent = function(html) {
......
......@@ -15,8 +15,7 @@
<ul class="nav nav-pills timepicker-dropdown">
<li class="dropdown">
<a class="dropdown-toggle timepicker-dropdown" data-toggle="dropdown" href="" bs-tooltip="time.from.date ? (time.from.date | date:'yyyy-MM-dd HH:mm:ss.sss') + ' <br>to<br>' +(time.to.date | date:'yyyy-MM-dd HH:mm:ss.sss') : 'Click to set a time filter'" data-placement="bottom" ng-click="dismiss();">
<a class="dropdown-toggle timepicker-dropdown" data-toggle="dropdown" href="" bs-tooltip="time.tooltip" data-placement="bottom" ng-click="dismiss();">
<span ng-show="filter.time">
<span class="pointer" ng-hide="panel.now">{{time.from.date | date:'MMM d, y HH:mm:ss'}}</span>
<span class="pointer" ng-show="panel.now">{{time.from.date | moment:'ago'}}</span>
......
......@@ -172,10 +172,20 @@ function (angular, app, _, moment, kbn) {
};
var getScopeTimeObj = function(from,to) {
return {
var model = {
from: getTimeObj(from),
to: getTimeObj(to)
to: getTimeObj(to),
};
if (model.from.date) {
model.tooltip = moment(model.from.date).format('YYYY-MM-DD HH:mm:ss') + ' <br>to<br>';
model.tooltip += moment(model.to.date).format('YYYY-MM-DD HH:mm:ss');
}
else {
model.tooltip = 'Click to set time filter';
}
return model;
};
var getTimeObj = function(date) {
......
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