2019-06-19 11:31:47 -07:00
|
|
|
import extend from 'lodash/extend';
|
2019-10-31 10:48:05 +01:00
|
|
|
import { getTheme } from '@grafana/ui';
|
2020-03-10 08:53:41 +01:00
|
|
|
import { DataSourceInstanceSettings, GrafanaTheme, GrafanaThemeType, PanelPluginMeta } from '@grafana/data';
|
2019-06-19 11:31:47 -07:00
|
|
|
|
|
|
|
|
export interface BuildInfo {
|
|
|
|
|
version: string;
|
|
|
|
|
commit: string;
|
2020-01-17 15:44:12 +01:00
|
|
|
isEnterprise: boolean; // deprecated: use licenseInfo.hasLicense instead
|
2019-06-19 11:31:47 -07:00
|
|
|
env: string;
|
2020-01-27 09:24:44 +01:00
|
|
|
edition: string;
|
2019-06-19 11:31:47 -07:00
|
|
|
latestVersion: string;
|
|
|
|
|
hasUpdate: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-08 23:58:57 -07:00
|
|
|
interface FeatureToggles {
|
|
|
|
|
transformations: boolean;
|
2019-10-30 11:38:28 -07:00
|
|
|
expressions: boolean;
|
2019-12-16 09:18:48 +01:00
|
|
|
newEdit: boolean;
|
2020-04-03 11:24:50 -07:00
|
|
|
meta: boolean; // enterprise
|
2020-03-10 08:53:41 +01:00
|
|
|
newVariables: boolean;
|
2020-03-25 12:25:39 +01:00
|
|
|
tracingIntegration: boolean;
|
2019-09-08 23:58:57 -07:00
|
|
|
}
|
2020-01-17 15:44:12 +01:00
|
|
|
|
|
|
|
|
interface LicenseInfo {
|
|
|
|
|
hasLicense: boolean;
|
|
|
|
|
expiry: number;
|
2020-01-27 09:24:44 +01:00
|
|
|
licenseUrl: string;
|
|
|
|
|
stateInfo: string;
|
2020-01-17 15:44:12 +01:00
|
|
|
}
|
|
|
|
|
|
2019-06-19 11:31:47 -07:00
|
|
|
export class GrafanaBootConfig {
|
|
|
|
|
datasources: { [str: string]: DataSourceInstanceSettings } = {};
|
|
|
|
|
panels: { [key: string]: PanelPluginMeta } = {};
|
2020-02-28 14:32:01 +01:00
|
|
|
minRefreshInterval = '';
|
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 = {
|
|
|
|
|
transformations: false,
|
2019-10-30 11:38:28 -07:00
|
|
|
expressions: false,
|
2019-12-16 09:18:48 +01:00
|
|
|
newEdit: false,
|
2020-01-28 12:00:07 +01:00
|
|
|
meta: false,
|
2020-04-03 09:38:14 +02:00
|
|
|
newVariables: true,
|
2020-03-25 12:25:39 +01:00
|
|
|
tracingIntegration: false,
|
2019-09-08 23:58:57 -07:00
|
|
|
};
|
2020-01-17 15:44:12 +01:00
|
|
|
licenseInfo: LicenseInfo = {} as LicenseInfo;
|
2020-01-30 17:35:32 +01:00
|
|
|
phantomJSRenderer = false;
|
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,
|
|
|
|
|
appSubUrl: '',
|
|
|
|
|
buildInfo: {
|
|
|
|
|
version: 'v1.0',
|
|
|
|
|
commit: '1',
|
|
|
|
|
env: 'production',
|
|
|
|
|
isEnterprise: false,
|
|
|
|
|
},
|
|
|
|
|
viewersCanEdit: false,
|
|
|
|
|
editorsCanAdmin: false,
|
|
|
|
|
disableSanitizeHtml: false,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extend(this, defaults, options);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
export const config = new GrafanaBootConfig(options);
|