forked from grafana.jool/grafana-jool
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
3.8 KiB
156 lines
3.8 KiB
import { merge } from 'lodash';
|
|
import {
|
|
BuildInfo,
|
|
createTheme,
|
|
DataSourceInstanceSettings,
|
|
FeatureToggles,
|
|
GrafanaConfig,
|
|
GrafanaTheme,
|
|
GrafanaTheme2,
|
|
LicenseInfo,
|
|
MapLayerOptions,
|
|
PanelPluginMeta,
|
|
PreloadPlugin,
|
|
systemDateFormats,
|
|
SystemDateFormatSettings,
|
|
} from '@grafana/data';
|
|
|
|
export interface AzureSettings {
|
|
cloud?: string;
|
|
managedIdentityEnabled: boolean;
|
|
}
|
|
|
|
export class GrafanaBootConfig implements GrafanaConfig {
|
|
datasources: { [str: string]: DataSourceInstanceSettings } = {};
|
|
panels: { [key: string]: PanelPluginMeta } = {};
|
|
minRefreshInterval = '';
|
|
appUrl = '';
|
|
appSubUrl = '';
|
|
windowTitlePrefix = '';
|
|
buildInfo: BuildInfo = {} as BuildInfo;
|
|
newPanelTitle = '';
|
|
bootData: any;
|
|
externalUserMngLinkUrl = '';
|
|
externalUserMngLinkName = '';
|
|
externalUserMngInfo = '';
|
|
allowOrgCreate = false;
|
|
disableLoginForm = false;
|
|
defaultDatasource = ''; // UID
|
|
alertingEnabled = false;
|
|
alertingErrorOrTimeout = '';
|
|
alertingNoDataOrNullValues = '';
|
|
alertingMinInterval = 1;
|
|
authProxyEnabled = false;
|
|
exploreEnabled = false;
|
|
ldapEnabled = false;
|
|
sigV4AuthEnabled = false;
|
|
samlEnabled = false;
|
|
samlName = '';
|
|
autoAssignOrg = true;
|
|
verifyEmailEnabled = false;
|
|
oauth: any;
|
|
disableUserSignUp = false;
|
|
loginHint: any;
|
|
passwordHint: any;
|
|
loginError: any;
|
|
navTree: any;
|
|
viewersCanEdit = false;
|
|
editorsCanAdmin = false;
|
|
disableSanitizeHtml = false;
|
|
liveEnabled = true;
|
|
theme: GrafanaTheme;
|
|
theme2: GrafanaTheme2;
|
|
pluginsToPreload: PreloadPlugin[] = [];
|
|
featureToggles: FeatureToggles = {
|
|
accesscontrol: false,
|
|
trimDefaults: false,
|
|
tempoServiceGraph: false,
|
|
tempoSearch: false,
|
|
recordedQueries: false,
|
|
newNavigation: false,
|
|
fullRangeLogsVolume: false,
|
|
queryOverLive: false,
|
|
dashboardPreviews: false,
|
|
};
|
|
licenseInfo: LicenseInfo = {} as LicenseInfo;
|
|
rendererAvailable = false;
|
|
rendererVersion = '';
|
|
http2Enabled = false;
|
|
dateFormats?: SystemDateFormatSettings;
|
|
sentry = {
|
|
enabled: false,
|
|
dsn: '',
|
|
customEndpoint: '',
|
|
sampleRate: 1,
|
|
};
|
|
pluginCatalogURL = 'https://grafana.com/grafana/plugins/';
|
|
pluginAdminEnabled = true;
|
|
pluginAdminExternalManageEnabled = false;
|
|
pluginCatalogHiddenPlugins: string[] = [];
|
|
expressionsEnabled = false;
|
|
customTheme?: any;
|
|
awsAllowedAuthProviders: string[] = [];
|
|
awsAssumeRoleEnabled = false;
|
|
azure: AzureSettings = {
|
|
managedIdentityEnabled: false,
|
|
};
|
|
caching = {
|
|
enabled: false,
|
|
};
|
|
geomapDefaultBaseLayerConfig?: MapLayerOptions;
|
|
geomapDisableCustomBaseLayer?: boolean;
|
|
unifiedAlertingEnabled = false;
|
|
applicationInsightsConnectionString?: string;
|
|
applicationInsightsEndpointUrl?: string;
|
|
recordedQueries = {
|
|
enabled: false,
|
|
};
|
|
|
|
constructor(options: GrafanaBootConfig) {
|
|
const mode = options.bootData.user.lightTheme ? 'light' : 'dark';
|
|
this.theme2 = createTheme({ colors: { mode } });
|
|
this.theme = this.theme2.v1;
|
|
|
|
const defaults = {
|
|
datasources: {},
|
|
windowTitlePrefix: 'Grafana - ',
|
|
panels: {},
|
|
newPanelTitle: 'Panel Title',
|
|
playlist_timespan: '1m',
|
|
unsaved_changes_warning: true,
|
|
appUrl: '',
|
|
appSubUrl: '',
|
|
buildInfo: {
|
|
version: 'v1.0',
|
|
commit: '1',
|
|
env: 'production',
|
|
isEnterprise: false,
|
|
},
|
|
viewersCanEdit: false,
|
|
editorsCanAdmin: false,
|
|
disableSanitizeHtml: false,
|
|
};
|
|
|
|
merge(this, defaults, options);
|
|
|
|
if (this.dateFormats) {
|
|
systemDateFormats.update(this.dateFormats);
|
|
}
|
|
}
|
|
}
|
|
|
|
const bootData = (window as any).grafanaBootData || {
|
|
settings: {},
|
|
user: {},
|
|
navTree: [],
|
|
};
|
|
|
|
const options = bootData.settings;
|
|
options.bootData = bootData;
|
|
|
|
/**
|
|
* Use this to access the {@link GrafanaBootConfig} for the current running Grafana instance.
|
|
*
|
|
* @public
|
|
*/
|
|
export const config = new GrafanaBootConfig(options);
|
|
|