@ -90,7 +90,9 @@ class PluginState {
this . grafanaBackend . get < DataExporterAppPluginMeta > ( this . GRAFANA_PLUGIN_SETTINGS_URL ) ;
this . grafanaBackend . get < DataExporterAppPluginMeta > ( this . GRAFANA_PLUGIN_SETTINGS_URL ) ;
static updateGrafanaPluginSettings = async ( data : UpdateGrafanaPluginSettingsProps , enabled = true ) = >
static updateGrafanaPluginSettings = async ( data : UpdateGrafanaPluginSettingsProps , enabled = true ) = >
this . grafanaBackend . post ( this . GRAFANA_PLUGIN_SETTINGS_URL , { . . . data , enabled , pinned : true } ) ;
// @ts-ignore
// for some reason, there is no `options` argument in Grafana's public types for BackendSrv but it exists
this . grafanaBackend . post ( this . GRAFANA_PLUGIN_SETTINGS_URL , { . . . data , enabled , pinned : true } , { showSuccessAlert : false } ) ;
static createGrafanaToken = async ( ) = > {
static createGrafanaToken = async ( ) = > {
const baseUrl = '/api/auth/keys' ;
const baseUrl = '/api/auth/keys' ;
@ -98,14 +100,22 @@ class PluginState {
const existingKey = keys . find ( ( key : { id : number ; name : string ; role : string } ) = > key . name === 'DataExporter' ) ;
const existingKey = keys . find ( ( key : { id : number ; name : string ; role : string } ) = > key . name === 'DataExporter' ) ;
if ( existingKey ) {
if ( existingKey ) {
await this . grafanaBackend . delete ( ` ${ baseUrl } / ${ existingKey . id } ` ) ;
// @ts-ignore
// for some reason, there is no `options` argument in Grafana's public types for BackendSrv but it exists
await this . grafanaBackend . delete ( ` ${ baseUrl } / ${ existingKey . id } ` , undefined , { showSuccessAlert : false } ) ;
}
}
return await this . grafanaBackend . post ( baseUrl , {
return await this . grafanaBackend . post (
baseUrl ,
{
name : 'DataExporter' ,
name : 'DataExporter' ,
role : 'Admin' ,
role : 'Admin' ,
secondsToLive : null ,
secondsToLive : null ,
} ) ;
} ,
// @ts-ignore
// for some reason, there is no `options` argument in Grafana's public types for BackendSrv but it exists
{ showSuccessAlert : false }
) ;
} ;
} ;
static timeout = ( pollCount : number ) = > new Promise ( ( resolve ) = > setTimeout ( resolve , 10 * 2 * * pollCount ) ) ;
static timeout = ( pollCount : number ) = > new Promise ( ( resolve ) = > setTimeout ( resolve , 10 * 2 * * pollCount ) ) ;