updated
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
define([
|
||||
'./pro/grafanaCtrl',
|
||||
'./pro/sharePanelCtrl',
|
||||
'./dashboardCtrl',
|
||||
'./dashboardNavCtrl',
|
||||
'./row',
|
||||
@@ -15,6 +16,5 @@ define([
|
||||
'./opentsdbTargetCtrl',
|
||||
'./annotationsEditorCtrl',
|
||||
'./templateEditorCtrl',
|
||||
'./sharePanelCtrl',
|
||||
'./jsonEditorCtrl',
|
||||
], function () {});
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
define([
|
||||
'angular',
|
||||
'lodash'
|
||||
],
|
||||
function (angular, _) {
|
||||
'use strict';
|
||||
|
||||
var module = angular.module('grafana.controllers');
|
||||
|
||||
module.controller('SharePanelCtrl', function($scope, $location, $timeout, timeSrv, $element, templateSrv, $routeParams) {
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.editor = { index: 0 };
|
||||
$scope.forCurrent = true;
|
||||
$scope.toPanel = true;
|
||||
$scope.includeTemplateVars = true;
|
||||
|
||||
$scope.buildUrl();
|
||||
};
|
||||
|
||||
$scope.buildUrl = function() {
|
||||
var panelId = $scope.panel.id;
|
||||
var range = timeSrv.timeRange(false);
|
||||
var params = angular.copy($location.search());
|
||||
|
||||
if (_.isString(range.to) && range.to.indexOf('now')) {
|
||||
range = timeSrv.timeRange();
|
||||
}
|
||||
|
||||
params.from = range.from;
|
||||
params.to = range.to;
|
||||
|
||||
if (_.isDate(params.from)) { params.from = params.from.getTime(); }
|
||||
if (_.isDate(params.to)) { params.to = params.to.getTime(); }
|
||||
|
||||
if ($scope.includeTemplateVars) {
|
||||
_.each(templateSrv.variables, function(variable) {
|
||||
params['var-' + variable.name] = variable.current.text;
|
||||
});
|
||||
}
|
||||
else {
|
||||
_.each(templateSrv.variables, function(variable) {
|
||||
delete params['var-' + variable.name];
|
||||
});
|
||||
}
|
||||
|
||||
if (!$scope.forCurrent) {
|
||||
delete params.from;
|
||||
delete params.to;
|
||||
}
|
||||
|
||||
if ($scope.toPanel) {
|
||||
params.panelId = panelId;
|
||||
params.fullscreen = true;
|
||||
} else {
|
||||
delete params.panelId;
|
||||
delete params.fullscreen;
|
||||
}
|
||||
|
||||
var paramsArray = [];
|
||||
_.each(params, function(value, key) {
|
||||
var str = key;
|
||||
if (value !== true) {
|
||||
str += '=' + encodeURIComponent(value);
|
||||
}
|
||||
paramsArray.push(str);
|
||||
});
|
||||
|
||||
var baseUrl = 'http://localhost:3000';
|
||||
$scope.shareUrl = baseUrl + '/dashboard/db/' + $routeParams.id + "?" + paramsArray.join('&') ;
|
||||
$scope.imageUrl = baseUrl + '/render/dashboard/solo/' + $routeParams.id + '?' + paramsArray.join('&') ;
|
||||
|
||||
$timeout(function() {
|
||||
var input = $element.find('[data-share-panel-url]');
|
||||
input.focus();
|
||||
input.select();
|
||||
}, 10);
|
||||
|
||||
};
|
||||
|
||||
$scope.init();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
@@ -25,6 +25,11 @@
|
||||
<div class="editor-row" style="margin-top: 20px;">
|
||||
<input type="text" data-share-panel-url class="input input-fluid" ng-model='shareUrl'></input>
|
||||
</div>
|
||||
|
||||
<div class="editor-row" style="margin-top: 20px;">
|
||||
<a href="{{imageUrl}}" target="_blank">Link to rendered image</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
define([
|
||||
'angular',
|
||||
'jquery',
|
||||
],
|
||||
function (angular) {
|
||||
function (angular, $) {
|
||||
"use strict";
|
||||
|
||||
var module = angular.module('grafana.routes');
|
||||
|
||||
module.config(function($routeProvider) {
|
||||
$routeProvider
|
||||
.when('/dashboard/:id/panel/:panelId', {
|
||||
.when('/dashboard/solo/:id/', {
|
||||
templateUrl: 'app/partials/pro/solo-panel.html',
|
||||
controller : 'SoloPanelCtrl',
|
||||
});
|
||||
});
|
||||
|
||||
module.controller('SoloPanelCtrl', function($scope, $rootScope, datasourceSrv, $routeParams, dashboardSrv, timeSrv) {
|
||||
module.controller('SoloPanelCtrl', function($scope, $rootScope, datasourceSrv, $routeParams, dashboardSrv, timeSrv, $location) {
|
||||
var panelId;
|
||||
|
||||
$scope.init = function() {
|
||||
var db = datasourceSrv.getGrafanaDB();
|
||||
panelId = parseInt($routeParams.panelId);
|
||||
var params = $location.search();
|
||||
panelId = parseInt(params.panelId);
|
||||
|
||||
db.getDashboard($routeParams.id, false)
|
||||
.then(function(dashboardData) {
|
||||
@@ -33,7 +35,7 @@ function (angular) {
|
||||
$scope.dashboard = dashboardSrv.create(dashboardData);
|
||||
$scope.grafana.style = $scope.dashboard.style;
|
||||
$scope.row = {
|
||||
height: '300px',
|
||||
height: $(window).height() + 'px',
|
||||
};
|
||||
$scope.test = "Hej";
|
||||
$scope.$index = 0;
|
||||
|
||||
@@ -9,11 +9,17 @@ define([
|
||||
var ctx = new helpers.ControllerTestContext();
|
||||
var datasource = {};
|
||||
var routeParams = {};
|
||||
var search = {};
|
||||
|
||||
beforeEach(module('grafana.routes'));
|
||||
beforeEach(module('grafana.services'));
|
||||
beforeEach(ctx.providePhase({
|
||||
$routeParams: routeParams,
|
||||
$location: {
|
||||
search: function() {
|
||||
return search;
|
||||
}
|
||||
},
|
||||
datasourceSrv: {
|
||||
getGrafanaDB: sinon.stub().returns(datasource)
|
||||
}
|
||||
@@ -38,7 +44,7 @@ define([
|
||||
};
|
||||
|
||||
routeParams.id = 1;
|
||||
routeParams.panelId = 23;
|
||||
search.panelId = 23;
|
||||
datasource.getDashboard = sinon.stub().returns(ctx.$q.when(dashboard));
|
||||
|
||||
ctx.scope.init();
|
||||
|
||||
Reference in New Issue
Block a user