From c3708b3096fa88cc8c6b9fdec8bdec671bca9787 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Torkel=20=C3=96degaard?=
Date: Fri, 27 May 2016 16:11:05 +0200
Subject: [PATCH] feat(import): import directly from grafana.net id/url now
works
---
pkg/api/gnetproxy.go | 13 ++++--
public/app/features/dashboard/all.js | 2 +-
.../dashboard/export/export_modal.html | 10 ----
.../dashboard/import/dash_import.html | 46 +++++++++++++------
.../features/dashboard/import/dash_import.ts | 42 ++++++++++++++++-
.../features/dashboard/partials/settings.html | 2 +-
.../dashboard/specs/dash_import_ctrl_specs.ts | 38 ++++++++++++++-
public/sass/components/_gf-form.scss | 4 ++
8 files changed, 123 insertions(+), 34 deletions(-)
diff --git a/pkg/api/gnetproxy.go b/pkg/api/gnetproxy.go
index 344cd3fe926..8425f0e41b7 100644
--- a/pkg/api/gnetproxy.go
+++ b/pkg/api/gnetproxy.go
@@ -5,8 +5,10 @@ import (
"net"
"net/http"
"net/http/httputil"
+ "net/url"
"time"
+ "github.com/Unknwon/log"
"github.com/grafana/grafana/pkg/middleware"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util"
@@ -23,12 +25,15 @@ var gNetProxyTransport = &http.Transport{
}
func ReverseProxyGnetReq(proxyPath string) *httputil.ReverseProxy {
+ url, _ := url.Parse(setting.GrafanaNetUrl)
+
director := func(req *http.Request) {
- req.URL.Scheme = "https"
- req.URL.Host = "grafana.net"
- req.Host = "grafana.net"
+ req.URL.Scheme = url.Scheme
+ req.URL.Host = url.Host
+ req.Host = url.Host
- req.URL.Path = util.JoinUrlFragments(setting.GrafanaNetUrl+"/api", proxyPath)
+ req.URL.Path = util.JoinUrlFragments(url.Path+"/api", proxyPath)
+ log.Info("Url: %v", req.URL.Path)
// clear cookie headers
req.Header.Del("Cookie")
diff --git a/public/app/features/dashboard/all.js b/public/app/features/dashboard/all.js
index 15c765f2281..6aea2efa9f1 100644
--- a/public/app/features/dashboard/all.js
+++ b/public/app/features/dashboard/all.js
@@ -17,7 +17,7 @@ define([
'./importCtrl',
'./impression_store',
'./upload',
- './import/import',
+ './import/dash_import',
'./export/export_modal',
'./dash_list_ctrl',
], function () {});
diff --git a/public/app/features/dashboard/export/export_modal.html b/public/app/features/dashboard/export/export_modal.html
index 7241a210bf5..e890e405020 100644
--- a/public/app/features/dashboard/export/export_modal.html
+++ b/public/app/features/dashboard/export/export_modal.html
@@ -15,16 +15,6 @@
You can share dashboards on Grafana.net
-
-