2020-04-15 10:54:52 +02:00
|
|
|
import merge from 'lodash/merge';
|
2019-10-31 10:48:05 +01:00
|
|
|
import { getTheme } from '@grafana/ui';
|
2020-04-20 07:37:38 +02:00
|
|
|
import {
|
2020-06-04 13:44:48 +02:00
|
|
|
BuildInfo,
|
2020-04-20 07:37:38 +02:00
|
|
|
DataSourceInstanceSettings,
|
2020-06-04 13:44:48 +02:00
|
|
|
FeatureToggles,
|
|
|
|
|
GrafanaConfig,
|
2020-04-20 07:37:38 +02:00
|
|
|
GrafanaTheme,
|
|
|
|
|
GrafanaThemeType,
|
|
|
|
|
LicenseInfo,
|
2020-06-04 13:44:48 +02:00
|
|
|
PanelPluginMeta,
|
2020-09-07 16:19:33 +02:00
|
|
|
systemDateFormats,
|
|
|
|
|
SystemDateFormatSettings,
|
2020-04-20 07:37:38 +02:00
|
|
|
} from '@grafana/data';
|
2019-06-19 11:31:47 -07:00
|
|
|
|
2020-04-20 07:37:38 +02:00
|
|
|
export class GrafanaBootConfig implements GrafanaConfig {
|
2019-06-19 11:31:47 -07:00
|
|
|
datasources: { [str: string]: DataSourceInstanceSettings } = {};
|
|
|
|
|
panels: { [key: string]: PanelPluginMeta } = {};
|
2020-02-28 14:32:01 +01:00
|
|
|
minRefreshInterval = '';
|
2020-06-16 16:33:44 +03:00
|
|
|
appUrl = '';
|
2019-06-19 11:31:47 -07:00
|
|
|
appSubUrl = '';
|
|
|
|
|
windowTitlePrefix = '';
|
|
|
|
|
buildInfo: BuildInfo = {} as BuildInfo;
|
|
|
|
|
newPanelTitle = '';
|
|
|
|
|
bootData: any;
|
|
|
|
|
externalUserMngLinkUrl = '';
|
|
|
|
|
externalUserMngLinkName = '';
|
|
|
|
|
externalUserMngInfo = '';
|
|
|
|
|
allowOrgCreate = false;
|
|
|
|
|
disableLoginForm = false;
|
|
|
|
|
defaultDatasource = '';
|
|
|
|
|
alertingEnabled = false;
|
|
|
|
|
alertingErrorOrTimeout = '';
|
|
|
|
|
alertingNoDataOrNullValues = '';
|
2020-01-14 11:13:34 +02:00
|
|
|
alertingMinInterval = 1;
|
2019-06-19 11:31:47 -07:00
|
|
|
authProxyEnabled = false;
|
|
|
|
|
exploreEnabled = false;
|
|
|
|
|
ldapEnabled = false;
|
2019-07-05 15:24:52 +02:00
|
|
|
samlEnabled = false;
|
2020-02-17 11:13:13 +01:00
|
|
|
autoAssignOrg = true;
|
|
|
|
|
verifyEmailEnabled = false;
|
2019-06-19 11:31:47 -07:00
|
|
|
oauth: any;
|
|
|
|
|
disableUserSignUp = false;
|
|
|
|
|
loginHint: any;
|
|
|
|
|
passwordHint: any;
|
|
|
|
|
loginError: any;
|
2020-02-13 16:06:45 +01:00
|
|
|
navTree: any;
|
2019-06-19 11:31:47 -07:00
|
|
|
viewersCanEdit = false;
|
|
|
|
|
editorsCanAdmin = false;
|
|
|
|
|
disableSanitizeHtml = false;
|
|
|
|
|
theme: GrafanaTheme;
|
|
|
|
|
pluginsToPreload: string[] = [];
|
2019-09-08 23:58:57 -07:00
|
|
|
featureToggles: FeatureToggles = {
|
2020-07-27 00:26:16 -07:00
|
|
|
live: false,
|
2019-10-30 11:38:28 -07:00
|
|
|
expressions: false,
|
2020-01-28 12:00:07 +01:00
|
|
|
meta: false,
|
2020-06-18 09:37:13 +02:00
|
|
|
datasourceInsights: false,
|
2020-06-18 12:28:41 +03:00
|
|
|
reportGrid: false,
|
2019-09-08 23:58:57 -07:00
|
|
|
};
|
2020-01-17 15:44:12 +01:00
|
|
|
licenseInfo: LicenseInfo = {} as LicenseInfo;
|
2020-04-15 22:17:41 +02:00
|
|
|
rendererAvailable = false;
|
2020-08-20 02:32:10 -07:00
|
|
|
http2Enabled = false;
|
2020-09-07 16:19:33 +02:00
|
|
|
dateFormats?: SystemDateFormatSettings;
|
2019-06-19 11:31:47 -07:00
|
|
|
|
|
|
|
|
constructor(options: GrafanaBootConfig) {
|
|
|
|
|
this.theme = options.bootData.user.lightTheme ? getTheme(GrafanaThemeType.Light) : getTheme(GrafanaThemeType.Dark);
|
|
|
|
|
|
|
|
|
|
const defaults = {
|
|
|
|
|
datasources: {},
|
|
|
|
|
windowTitlePrefix: 'Grafana - ',
|
|
|
|
|
panels: {},
|
|
|
|
|
newPanelTitle: 'Panel Title',
|
|
|
|
|
playlist_timespan: '1m',
|
|
|
|
|
unsaved_changes_warning: true,
|
2020-06-16 16:33:44 +03:00
|
|
|
appUrl: '',
|
2019-06-19 11:31:47 -07:00
|
|
|
appSubUrl: '',
|
|
|
|
|
buildInfo: {
|
|
|
|
|
version: 'v1.0',
|
|
|
|
|
commit: '1',
|
|
|
|
|
env: 'production',
|
|
|
|
|
isEnterprise: false,
|
|
|
|
|
},
|
|
|
|
|
viewersCanEdit: false,
|
|
|
|
|
editorsCanAdmin: false,
|
|
|
|
|
disableSanitizeHtml: false,
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-15 10:54:52 +02:00
|
|
|
merge(this, defaults, options);
|
2020-09-07 16:19:33 +02:00
|
|
|
|
|
|
|
|
if (this.dateFormats) {
|
|
|
|
|
systemDateFormats.update(this.dateFormats);
|
|
|
|
|
}
|
2019-06-19 11:31:47 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bootData = (window as any).grafanaBootData || {
|
|
|
|
|
settings: {},
|
|
|
|
|
user: {},
|
2020-02-13 16:06:45 +01:00
|
|
|
navTree: [],
|
2019-06-19 11:31:47 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const options = bootData.settings;
|
|
|
|
|
options.bootData = bootData;
|
|
|
|
|
|
2020-04-15 10:46:51 +02:00
|
|
|
/**
|
|
|
|
|
* Use this to access the {@link GrafanaBootConfig} for the current running Grafana instance.
|
|
|
|
|
*
|
|
|
|
|
* @public
|
|
|
|
|
*/
|
2019-06-19 11:31:47 -07:00
|
|
|
export const config = new GrafanaBootConfig(options);
|