Geomap: Base layer server configuration (#37041)

pull/37043/head^2
Eunice Kim 4 years ago committed by GitHub
parent ec9a587cbe
commit 3b0d7fc00b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      conf/defaults.ini
  2. 7
      conf/sample.ini
  3. 23
      docs/sources/administration/configuration.md
  4. 3
      packages/grafana-data/src/types/config.ts
  5. 2
      pkg/api/frontendsettings.go
  6. 17
      pkg/setting/setting.go

@ -1011,3 +1011,10 @@ default_timezone = browser
[expressions]
# Enable or disable the expressions functionality.
enabled = true
[geomap]
# Set the default base layer in GeoMaps plugin
default_baselayer =
# Enable or disable loading other base map layers
disable_custom_baselayers = false

@ -991,3 +991,10 @@
[expressions]
# Enable or disable the expressions functionality.
;enabled = true
[geomap]
# Set the default base layer in GeoMaps plugin
;default_baselayer =
# Enable or disable loading other base map layers
;disable_custom_baselayers = false

@ -1672,3 +1672,26 @@ Used as the default time zone for user preferences. Can be either `browser` for
### enabled
Set this to `false` to disable expressions and hide them in the Grafana UI. Default is `true`.
## [geomap]
This section controls the defaults settings for Geomap Plugin.
### default_baselayer
The json config used to define the default base map. Four base map options to choose from are `carto`, `esriXYZTiles`, `xyzTiles`, `standard`.
For example, to set cartoDB light as the default base layer:
```ini
geomap_default_baselayer = `{
"type": "carto",
"config": {
"theme": "light",
"showLabels": true
}
}`
```
### disable_custom_baselayers
Set this to `true` to disable loading other custom base maps and hide them in the Grafana UI. Default is `false`.

@ -3,6 +3,7 @@ import { PanelPluginMeta } from './panel';
import { GrafanaTheme } from './theme';
import { SystemDateFormatSettings } from '../datetime';
import { GrafanaTheme2 } from '../themes';
import { MapLayerOptions } from '../geo/layer';
/**
* Describes the build information that will be available via the Grafana configuration.
@ -125,4 +126,6 @@ export interface GrafanaConfig {
dateFormats?: SystemDateFormatSettings;
sentry: SentryConfig;
customTheme?: any;
geomapDefaultBaseLayer?: MapLayerOptions;
geomapDisableCustomBaseLayer?: boolean;
}

@ -259,6 +259,8 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *models.ReqContext) (map[string]i
"caching": map[string]bool{
"enabled": hs.Cfg.SectionWithEnvOverrides("caching").Key("enabled").MustBool(true),
},
"geomapDefaultBaseLayer": hs.Cfg.DefaultBaseLayer,
"geomapDisableCustomBaseLayer": hs.Cfg.DisableCustomBaseLayers,
}
return jsonObj, nil

@ -5,6 +5,7 @@ package setting
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/http"
@ -400,6 +401,10 @@ type Cfg struct {
// Grafana.com URL
GrafanaComURL string
// Geomap plugin tile server
DefaultBaseLayer map[string]interface{}
DisableCustomBaseLayers bool
}
// IsLiveConfigEnabled returns true if live should be able to save configs to SQL tables
@ -966,6 +971,18 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
ConnStr: connStr,
}
geomapSection := iniFile.Section("geomap")
basemapJSON := valueAsString(geomapSection, "default_baselayer", "")
cfg.DefaultBaseLayer = make(map[string]interface{})
if basemapJSON != "" {
err = json.Unmarshal([]byte(basemapJSON), &cfg.DefaultBaseLayer)
if err != nil {
cfg.Logger.Error(fmt.Sprintf("Error parsing JSON string: %s", err))
cfg.DefaultBaseLayer = nil
}
}
cfg.DisableCustomBaseLayers = geomapSection.Key("disable_custom_baselayers").MustBool(false)
cfg.readDateFormats()
cfg.readSentryConfig()

Loading…
Cancel
Save