File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -106,11 +106,37 @@ if (process.env.NODE_ENV === 'development') {
106
106
initDevFeatures ( ) ;
107
107
}
108
108
109
+ export declare type FNGrafanaStartupState = {
110
+ isLoading : boolean ;
111
+ isError : boolean ;
112
+ error ?: unknown ;
113
+ isIdeal : boolean ;
114
+ } ;
115
+
116
+ export const DefaultGrafanaStartupState : FNGrafanaStartupState = {
117
+ isLoading : false ,
118
+ isError : false ,
119
+ isIdeal : true ,
120
+ } ;
121
+
122
+ const dispatchFnEvent = ( info : FNGrafanaStartupState = DefaultGrafanaStartupState , ek = 'grafana-startup' ) => {
123
+ window . dispatchEvent (
124
+ new CustomEvent ( ek , {
125
+ detail : info ,
126
+ } )
127
+ ) ;
128
+ } ;
129
+
109
130
export class GrafanaApp {
110
131
context ! : GrafanaContextType ;
111
132
112
133
async init ( ) {
113
134
try {
135
+ dispatchFnEvent ( {
136
+ isIdeal : false ,
137
+ isLoading : true ,
138
+ isError : false ,
139
+ } ) ;
114
140
// Let iframe container know grafana has started loading
115
141
parent . postMessage ( 'GrafanaAppInit' , '*' ) ;
116
142
@@ -224,7 +250,19 @@ export class GrafanaApp {
224
250
keybindings : keybindingsService ,
225
251
config,
226
252
} ;
253
+
254
+ dispatchFnEvent ( {
255
+ isLoading : false ,
256
+ isError : false ,
257
+ isIdeal : false ,
258
+ } ) ;
227
259
} catch ( error ) {
260
+ dispatchFnEvent ( {
261
+ isLoading : false ,
262
+ isError : true ,
263
+ error,
264
+ isIdeal : false ,
265
+ } ) ;
228
266
console . error ( 'Failed to start Grafana' , error ) ;
229
267
window . __grafana_load_failed ( ) ;
230
268
} finally {
You can’t perform that action at this time.
0 commit comments