mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(server side png rendering): added timezone parameter for server side rendering, refactoring PR #7264
This commit is contained in:
@@ -69,15 +69,6 @@
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/ng-template" id="renderImageOptions.html">
|
||||
<div class="gf-form-group">
|
||||
<gf-form-switch class="gf-form"
|
||||
label="Use browser time offset in image" label-class="width-18" switch-class="max-width-6"
|
||||
checked="options.browserTimeOffset" on-change="buildUrl()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/ng-template" id="shareLink.html">
|
||||
<div class="share-modal-header">
|
||||
<div class="share-modal-big-icon">
|
||||
@@ -100,7 +91,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-include src="'renderImageOptions.html'"></div>
|
||||
<div class="gf-form" ng-show="modeSharePanel">
|
||||
<a href="{{imageUrl}}" target="_blank"><i class="fa fa-camera"></i> Direct link rendered image</a>
|
||||
</div>
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
define(['angular',
|
||||
'lodash',
|
||||
'jquery',
|
||||
'moment',
|
||||
'require',
|
||||
'app/core/config',
|
||||
],
|
||||
function (angular, _, $, require, config) {
|
||||
function (angular, _, $, moment, require, config) {
|
||||
'use strict';
|
||||
|
||||
var module = angular.module('grafana.controllers');
|
||||
|
||||
module.controller('ShareModalCtrl', function($scope, $rootScope, $location, $timeout, timeSrv, templateSrv, linkSrv) {
|
||||
|
||||
$scope.options = { forCurrent: true, includeTemplateVars: true, browserTimeOffset: false, theme: 'current' };
|
||||
$scope.options = { forCurrent: true, includeTemplateVars: true, theme: 'current' };
|
||||
$scope.editor = { index: $scope.tabIndex || 0};
|
||||
|
||||
$scope.init = function() {
|
||||
@@ -83,13 +84,7 @@ function (angular, _, $, require, config) {
|
||||
$scope.imageUrl = soloUrl.replace(config.appSubUrl + '/dashboard-solo/', config.appSubUrl + '/render/dashboard-solo/');
|
||||
$scope.imageUrl += '&width=1000';
|
||||
$scope.imageUrl += '&height=500';
|
||||
if ($scope.options.browserTimeOffset) {
|
||||
var offsetMinutes = new Date().getTimezoneOffset(); // Negative if ahead of UTC
|
||||
var sign = offsetMinutes < 0 ? '+' : '-';
|
||||
var hours = ('0' + Math.abs(offsetMinutes) / 60).slice(-2);
|
||||
var minutes = ('0' + Math.abs(offsetMinutes) % 60).slice(-2);
|
||||
$scope.imageUrl += '&timeOffset=' + encodeURIComponent(sign + hours + minutes);
|
||||
}
|
||||
$scope.imageUrl += '&tz=UTC' + encodeURIComponent(moment().format("Z"));
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user