Chore: Prevent loading error from showing too early (#41347)
This commit is contained in:
+39
-34
@@ -74,54 +74,59 @@ export class GrafanaApp {
|
|||||||
this.angularApp = new AngularApp();
|
this.angularApp = new AngularApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
async init() {
|
||||||
initEchoSrv();
|
try {
|
||||||
addClassIfNoOverlayScrollbar();
|
initEchoSrv();
|
||||||
setLocale(config.bootData.user.locale);
|
addClassIfNoOverlayScrollbar();
|
||||||
setWeekStart(config.bootData.user.weekStart);
|
setLocale(config.bootData.user.locale);
|
||||||
setPanelRenderer(PanelRenderer);
|
setWeekStart(config.bootData.user.weekStart);
|
||||||
setTimeZoneResolver(() => config.bootData.user.timezone);
|
setPanelRenderer(PanelRenderer);
|
||||||
// Important that extensions are initialized before store
|
setTimeZoneResolver(() => config.bootData.user.timezone);
|
||||||
initExtensions();
|
// Important that extensions are initialized before store
|
||||||
configureStore();
|
initExtensions();
|
||||||
|
configureStore();
|
||||||
|
|
||||||
standardEditorsRegistry.setInit(getAllOptionEditors);
|
standardEditorsRegistry.setInit(getAllOptionEditors);
|
||||||
standardFieldConfigEditorRegistry.setInit(getStandardFieldConfigs);
|
standardFieldConfigEditorRegistry.setInit(getStandardFieldConfigs);
|
||||||
standardTransformersRegistry.setInit(getStandardTransformers);
|
standardTransformersRegistry.setInit(getStandardTransformers);
|
||||||
variableAdapters.setInit(getDefaultVariableAdapters);
|
variableAdapters.setInit(getDefaultVariableAdapters);
|
||||||
monacoLanguageRegistry.setInit(getDefaultMonacoLanguages);
|
monacoLanguageRegistry.setInit(getDefaultMonacoLanguages);
|
||||||
|
|
||||||
setQueryRunnerFactory(() => new QueryRunner());
|
setQueryRunnerFactory(() => new QueryRunner());
|
||||||
setVariableQueryRunner(new VariableQueryRunner());
|
setVariableQueryRunner(new VariableQueryRunner());
|
||||||
|
|
||||||
locationUtil.initialize({
|
locationUtil.initialize({
|
||||||
config,
|
config,
|
||||||
getTimeRangeForUrl: getTimeSrv().timeRangeForUrl,
|
getTimeRangeForUrl: getTimeSrv().timeRangeForUrl,
|
||||||
getVariablesUrlParams: getVariablesUrlParams,
|
getVariablesUrlParams: getVariablesUrlParams,
|
||||||
});
|
});
|
||||||
|
|
||||||
// intercept anchor clicks and forward it to custom history instead of relying on browser's history
|
// intercept anchor clicks and forward it to custom history instead of relying on browser's history
|
||||||
document.addEventListener('click', interceptLinkClicks);
|
document.addEventListener('click', interceptLinkClicks);
|
||||||
|
|
||||||
// disable tool tip animation
|
// disable tool tip animation
|
||||||
$.fn.tooltip.defaults.animation = false;
|
$.fn.tooltip.defaults.animation = false;
|
||||||
|
|
||||||
this.angularApp.init();
|
this.angularApp.init();
|
||||||
|
|
||||||
// Preload selected app plugins
|
// Preload selected app plugins
|
||||||
const promises = [];
|
const promises: Array<Promise<any>> = [];
|
||||||
for (const modulePath of config.pluginsToPreload) {
|
for (const modulePath of config.pluginsToPreload) {
|
||||||
promises.push(importPluginModule(modulePath));
|
promises.push(importPluginModule(modulePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await Promise.all(promises);
|
||||||
|
|
||||||
Promise.all(promises).then(() => {
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
React.createElement(AppWrapper, {
|
React.createElement(AppWrapper, {
|
||||||
app: this,
|
app: this,
|
||||||
}),
|
}),
|
||||||
document.getElementById('reactRoot')
|
document.getElementById('reactRoot')
|
||||||
);
|
);
|
||||||
});
|
} catch (error: any) {
|
||||||
|
console.error('Failed to start Grafana', error);
|
||||||
|
window.__grafana_load_failed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -1,9 +1,7 @@
|
|||||||
declare let __webpack_public_path__: string;
|
declare let __webpack_public_path__: string;
|
||||||
declare let __webpack_nonce__: string;
|
declare let __webpack_nonce__: string;
|
||||||
|
|
||||||
/**
|
// Check if we are hosting files on cdn and set webpack public path
|
||||||
* Check if we are hosting files on cdn and set webpack public path
|
|
||||||
*/
|
|
||||||
if (window.public_cdn_path) {
|
if (window.public_cdn_path) {
|
||||||
__webpack_public_path__ = window.public_cdn_path;
|
__webpack_public_path__ = window.public_cdn_path;
|
||||||
}
|
}
|
||||||
@@ -16,5 +14,8 @@ if ((window as any).nonce) {
|
|||||||
__webpack_nonce__ = (window as any).nonce;
|
__webpack_nonce__ = (window as any).nonce;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is an indication to the window.onLoad failure check that the app bundle has loaded.
|
||||||
|
window.__grafana_app_bundle_loaded = true;
|
||||||
|
|
||||||
import app from './app';
|
import app from './app';
|
||||||
app.init();
|
app.init();
|
||||||
|
|||||||
Vendored
+2
@@ -1,6 +1,8 @@
|
|||||||
export declare global {
|
export declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
|
__grafana_app_bundle_loaded: boolean;
|
||||||
__grafana_public_path__: string;
|
__grafana_public_path__: string;
|
||||||
|
__grafana_load_failed: () => void;
|
||||||
public_cdn_path: string;
|
public_cdn_path: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
height: 60px;
|
height: 60px;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-size: contain;
|
background-size: contain;
|
||||||
background-image: url("[[.LoadingLogo]]");
|
background-image: url('[[.LoadingLogo]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
.preloader__text {
|
.preloader__text {
|
||||||
@@ -246,29 +246,37 @@
|
|||||||
<div id="reactRoot"></div>
|
<div id="reactRoot"></div>
|
||||||
|
|
||||||
<script nonce="[[.Nonce]]">
|
<script nonce="[[.Nonce]]">
|
||||||
window.grafanaBootData = {
|
window.grafanaBootData = {
|
||||||
user: [[.User]],
|
user: [[.User]],
|
||||||
settings: [[.Settings]],
|
settings: [[.Settings]],
|
||||||
navTree: [[.NavTree]],
|
navTree: [[.NavTree]],
|
||||||
themePaths: {
|
themePaths: {
|
||||||
light: '[[.ContentDeliveryURL]]public/build/grafana.light.<%= compilation.hash %>.css',
|
light: '[[.ContentDeliveryURL]]public/build/grafana.light.<%= compilation.hash %>.css',
|
||||||
dark: '[[.ContentDeliveryURL]]public/build/grafana.dark.<%= compilation.hash %>.css'
|
dark: '[[.ContentDeliveryURL]]public/build/grafana.dark.<%= compilation.hash %>.css'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
window.__grafana_load_failed = function() {
|
||||||
|
var preloader = document.getElementsByClassName("preloader");
|
||||||
|
if (preloader.length) {
|
||||||
|
preloader[0].className = "preloader preloader--done";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// In case the js files fails to load the code below will show an info message.
|
// In case the js files fails to load the code below will show an info message.
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
var preloader = document.getElementsByClassName("preloader");
|
if (window.__grafana_app_bundle_loaded) {
|
||||||
if (preloader.length) {
|
return;
|
||||||
preloader[0].className = "preloader preloader--done";
|
}
|
||||||
}
|
window.__grafana_load_failed();
|
||||||
};
|
};
|
||||||
[[if .ContentDeliveryURL]]
|
|
||||||
window.public_cdn_path = '[[.ContentDeliveryURL]]public/build/';
|
[[if .ContentDeliveryURL]]
|
||||||
[[end]]
|
window.public_cdn_path = '[[.ContentDeliveryURL]]public/build/';
|
||||||
[[if .Nonce]]
|
[[end]]
|
||||||
window.nonce = '[[.Nonce]]';
|
[[if .Nonce]]
|
||||||
[[end]]
|
window.nonce = '[[.Nonce]]';
|
||||||
|
[[end]]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
[[if .GoogleTagManagerId]]
|
[[if .GoogleTagManagerId]]
|
||||||
|
|||||||
Reference in New Issue
Block a user