Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get link to result #1100

Closed
wants to merge 11 commits into from
9 changes: 9 additions & 0 deletions src/app/filters/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ define([
};
});

module.filter('shareLink', function($location, filterSrv) {
return function(event) {
var from = new Date(Date.parse(event._source["@timestamp"])-60000);
var to = new Date(Date.parse(event._source["@timestamp"])+60000);
var text=event._id;
return($location.absUrl().replace(/(\?.*)?$/,'?from='+from.toISOString()+'&to='+to.toISOString()+'&query=_id:'+text));
};
});

module.filter('gistid', function() {
var gist_pattern = /(\d{5,})|([a-z0-9]{10,})|(gist.github.com(\/*.*)\/[a-z0-9]{5,}\/*$)/;
return function(input) {
Expand Down
5 changes: 3 additions & 2 deletions src/app/panels/table/module.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@
View:
<a class="link" ng-class="{'strong':event.kibana.view == 'table'}" ng-click="event.kibana.view = 'table'">Table</a> /
<a class="link" ng-class="{'strong':event.kibana.view == 'json'}" ng-click="event.kibana.view = 'json'">JSON</a> /
<a class="link" ng-class="{'strong':event.kibana.view == 'raw'}" ng-click="event.kibana.view = 'raw'">Raw</a>
<a class="link" ng-class="{'strong':event.kibana.view == 'raw'}" ng-click="event.kibana.view = 'raw'">Raw</a> /
<a class="link" ng-href="{{event | shareLink}}">Share</a>
<i class="link pull-right icon-chevron-up" ng-click="toggle_details(event)"></i>
</span>
<table class='table table-bordered table-condensed table-details' ng-switch-when="table">
Expand Down Expand Up @@ -174,4 +175,4 @@
</div>
</div>
</div>
</div>
</div>
14 changes: 14 additions & 0 deletions src/app/services/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,20 @@ function (angular, $, kbn, _, config, moment, Modernizr) {

var renderTemplate = function(json,params) {
var _r;
var _json;
if(!json.match('ARGS\.(to|from|style|query)')) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't make changes to dashboards that are already doing things with to/from/style/query.

try {
_json = angular.fromJson(json);
_json.style = "{{ARGS.style || '" + _json.style + "'}}";
_json.services.filter.list[0].to = "{{ARGS.to || '" + _json.services.filter.list[0].to + "'}}";
_json.services.filter.list[0].from = "{{ARGS.from || '" + _json.services.filter.list[0].from + "'}}";
_json.services.query.list[0].query = "{{ARGS.query || '" + _json.services.query.list[0].query + "'}}";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the dashboard doesn't already reference ARGS for to/from/style/query, it is safe to add dynamic support for those URL args.

json=angular.toJson(_json);
} catch(e) {
_json = false;
}
}

_.templateSettings = {interpolate : /\{\{(.+?)\}\}/g};
var template = _.template(json);
var rendered = template({ARGS:params});
Expand Down