mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 07:34:04 -08:00
Merge pull request #434 from brian-brazil/graphlink
Fix regression from 5e8d57bec1
This commit is contained in:
commit
6cd29eec48
|
@ -159,6 +159,6 @@ func TableLinkForExpression(expr string) string {
|
|||
// GraphLinkForExpression creates an escaped relative link to the graph view of
|
||||
// the provided expression.
|
||||
func GraphLinkForExpression(expr string) string {
|
||||
urlData := url.QueryEscape(fmt.Sprintf(`[{"expr":%q}]`, expr))
|
||||
urlData := url.QueryEscape(fmt.Sprintf(`[{"expr":%q,"tab":0}]`, expr))
|
||||
return fmt.Sprintf("/graph#%s", strings.Replace(urlData, "+", "%20", -1))
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ func TestTemplateExpansion(t *testing.T) {
|
|||
{
|
||||
// graphLink.
|
||||
text: "{{ graphLink \"up\" }}",
|
||||
output: "/graph#%5B%7B%22expr%22%3A%22up%22%7D%5D",
|
||||
output: "/graph#%5B%7B%22expr%22%3A%22up%22%2C%22tab%22%3A0%7D%5D",
|
||||
},
|
||||
{
|
||||
// tableLink.
|
||||
|
|
|
@ -58,7 +58,9 @@ Prometheus.Graph.prototype.initialize = function() {
|
|||
self.options["id"] = self.id;
|
||||
self.options["range_input"] = self.options["range_input"] || "1h";
|
||||
self.options["stacked_checked"] = self.options["stacked"] ? "checked" : "";
|
||||
self.options["tab"] = self.options["tab"] || 1;
|
||||
if (self.options["tab"] === undefined) {
|
||||
self.options["tab"] = 1;
|
||||
}
|
||||
|
||||
// Draw graph controls and container from Handlebars template.
|
||||
|
||||
|
@ -78,13 +80,13 @@ Prometheus.Graph.prototype.initialize = function() {
|
|||
self.consoleTab = graphWrapper.find(".console");
|
||||
self.graphTab = graphWrapper.find(".graph_container");
|
||||
self.tabs = graphWrapper.find(".tabs");
|
||||
self.tab = $(self.tabs.find("> div")[self.options["tab"]]); // active tab
|
||||
self.tab = $(self.tabs.find("> div")[self.options["tab"]]); // active tab
|
||||
|
||||
self.tabs.tabs({
|
||||
active: self.options["tab"],
|
||||
activate: function(e, ui) {
|
||||
storeGraphOptionsInUrl();
|
||||
self.tab = ui.newPanel
|
||||
self.tab = ui.newPanel;
|
||||
if (self.tab.hasClass("reload")) { // reload if flagged with class "reload"
|
||||
self.submitQuery();
|
||||
}
|
||||
|
|
|
@ -577,7 +577,7 @@ PromConsole._chooseNameFunction = function(data) {
|
|||
PromConsole._graphsToSlashGraphURL = function(exprs) {
|
||||
var data = [];
|
||||
for (var i = 0; i < exprs.length; ++i) {
|
||||
data.push({'expr' : exprs[i]});
|
||||
data.push({'expr': exprs[i], 'tab': 0});
|
||||
}
|
||||
return '/graph#' + encodeURIComponent(JSON.stringify(data));
|
||||
|
||||
|
|
Loading…
Reference in a new issue