Commit 280f9bef by Carl Bergquist

Merge pull request #2949 from shoonoise/master

Add option to hide raintank share button

Fixes #2727
parents 1cfa523f b4a2b96e
...@@ -125,6 +125,12 @@ disable_gravatar = false ...@@ -125,6 +125,12 @@ disable_gravatar = false
# data source proxy whitelist (ip_or_domain:port seperated by spaces) # data source proxy whitelist (ip_or_domain:port seperated by spaces)
data_source_proxy_whitelist = data_source_proxy_whitelist =
[snapshots]
# snapshot sharing options
external_enabled = true
external_snapshot_url = https://snapshots-origin.raintank.io
external_snapshot_name = Publish to snapshot.raintank.io
#################################### Users #################################### #################################### Users ####################################
[users] [users]
# disable user signup / registration # disable user signup / registration
......
...@@ -120,6 +120,12 @@ ...@@ -120,6 +120,12 @@
# data source proxy whitelist (ip_or_domain:port seperated by spaces) # data source proxy whitelist (ip_or_domain:port seperated by spaces)
;data_source_proxy_whitelist = ;data_source_proxy_whitelist =
[snapshots]
# snapshot sharing options
;external_enabled = true
;external_snapshot_url = https://snapshots-origin.raintank.io
;external_snapshot_name = Publish to snapshot.raintank.io
#################################### Users #################################### #################################### Users ####################################
[users] [users]
# disable user signup / registration # disable user signup / registration
......
...@@ -65,6 +65,7 @@ func Register(r *macaron.Macaron) { ...@@ -65,6 +65,7 @@ func Register(r *macaron.Macaron) {
r.Post("/api/snapshots/", bind(m.CreateDashboardSnapshotCommand{}), CreateDashboardSnapshot) r.Post("/api/snapshots/", bind(m.CreateDashboardSnapshotCommand{}), CreateDashboardSnapshot)
r.Get("/dashboard/snapshot/*", Index) r.Get("/dashboard/snapshot/*", Index)
r.Get("/api/snapshot/shared-options/", GetSharingOptions)
r.Get("/api/snapshots/:key", GetDashboardSnapshot) r.Get("/api/snapshots/:key", GetDashboardSnapshot)
r.Get("/api/snapshots-delete/:key", DeleteDashboardSnapshot) r.Get("/api/snapshots-delete/:key", DeleteDashboardSnapshot)
......
...@@ -12,6 +12,14 @@ import ( ...@@ -12,6 +12,14 @@ import (
"github.com/grafana/grafana/pkg/util" "github.com/grafana/grafana/pkg/util"
) )
func GetSharingOptions(c *middleware.Context) {
c.JSON(200, util.DynMap{
"externalSnapshotURL": setting.ExternalSnapshotUrl,
"externalSnapshotName": setting.ExternalSnapshotName,
"externalEnabled": setting.ExternalEnabled,
})
}
func CreateDashboardSnapshot(c *middleware.Context, cmd m.CreateDashboardSnapshotCommand) { func CreateDashboardSnapshot(c *middleware.Context, cmd m.CreateDashboardSnapshotCommand) {
if cmd.External { if cmd.External {
// external snapshot ref requires key and delete key // external snapshot ref requires key and delete key
......
...@@ -76,6 +76,11 @@ var ( ...@@ -76,6 +76,11 @@ var (
EmailCodeValidMinutes int EmailCodeValidMinutes int
DataProxyWhiteList map[string]bool DataProxyWhiteList map[string]bool
// Snapshots
ExternalSnapshotUrl string
ExternalSnapshotName string
ExternalEnabled bool
// User settings // User settings
AllowUserSignUp bool AllowUserSignUp bool
AllowUserOrgCreate bool AllowUserOrgCreate bool
...@@ -421,6 +426,12 @@ func NewConfigContext(args *CommandLineArgs) error { ...@@ -421,6 +426,12 @@ func NewConfigContext(args *CommandLineArgs) error {
CookieRememberName = security.Key("cookie_remember_name").String() CookieRememberName = security.Key("cookie_remember_name").String()
DisableGravatar = security.Key("disable_gravatar").MustBool(true) DisableGravatar = security.Key("disable_gravatar").MustBool(true)
// read snapshots settings
snapshots := Cfg.Section("snapshots")
ExternalSnapshotUrl = snapshots.Key("external_snapshot_url").String()
ExternalSnapshotName = snapshots.Key("external_snapshot_name").String()
ExternalEnabled = snapshots.Key("external_enabled").MustBool(true)
// read data source proxy white list // read data source proxy white list
DataProxyWhiteList = make(map[string]bool) DataProxyWhiteList = make(map[string]bool)
for _, hostAndIp := range security.Key("data_source_proxy_whitelist").Strings(" ") { for _, hostAndIp := range security.Key("data_source_proxy_whitelist").Strings(" ") {
......
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
</script> </script>
<script type="text/ng-template" id="shareSnapshot.html"> <script type="text/ng-template" id="shareSnapshot.html">
<div class="ng-cloak" ng-cloak ng-controller="ShareSnapshotCtrl"> <div class="ng-cloak" ng-cloak ng-controller="ShareSnapshotCtrl" ng-init="init()">
<div class="share-modal-big-icon"> <div class="share-modal-big-icon">
<i ng-if="loading" class="fa fa-spinner fa-spin"></i> <i ng-if="loading" class="fa fa-spinner fa-spin"></i>
<i ng-if="!loading" class="gf-icon gf-icon-snap-multi"></i> <i ng-if="!loading" class="gf-icon gf-icon-snap-multi"></i>
...@@ -175,10 +175,9 @@ ...@@ -175,10 +175,9 @@
<i class="fa fa-save"></i> <i class="fa fa-save"></i>
Local Snapshot Local Snapshot
</button> </button>
<button class="btn btn-primary btn-large" ng-if="externalEnabled" ng-click="createSnapshot(true)" ng-disabled="loading">
<button class="btn btn-primary btn-large" ng-click="createSnapshot(true)" ng-disabled="loading">
<i class="fa fa-cloud-upload"></i> <i class="fa fa-cloud-upload"></i>
Publish to snapshot.raintank.io {{sharingButtonText}}
</button> </button>
</div> </div>
......
...@@ -29,7 +29,14 @@ function (angular, _) { ...@@ -29,7 +29,14 @@ function (angular, _) {
{text: 'Public on the web', value: 3}, {text: 'Public on the web', value: 3},
]; ];
$scope.externalUrl = '//snapshots-origin.raintank.io'; $scope.init = function() {
backendSrv.get('/api/snapshot/shared-options').then(function(options) {
$scope.externalUrl = options['externalSnapshotURL'];
$scope.sharingButtonText = options['externalSnapshotName'];
$scope.externalEnabled = options['externalEnabled'];
});
};
$scope.apiUrl = '/api/snapshots'; $scope.apiUrl = '/api/snapshots';
$scope.createSnapshot = function(external) { $scope.createSnapshot = function(external) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment