Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (settings.jsonData && settings.jsonData.timeout) {
this.timeout = parseInt(settings.jsonData.timeout,10) * 1000;
}
let authConfig = undefined;
if (settings.basicAuth) {
// If basic auth is configured, pass the username and password to the client
// This allows the datasource to work in direct mode
// We need the raw username and password, so we decode the token
const token = settings.basicAuth.split(' ')[1];
const decodedToken = atob(token);
const username = decodedToken.split(':')[0];
const password = decodedToken.substring(username.length+1, decodedToken.length);
authConfig = new API.OnmsAuthConfig(username, password);
}
const server = API.OnmsServer.newBuilder(this.url).setName(this.name).setAuth(authConfig).build();
const http = new Rest.GrafanaHTTP(this.backendSrv, server, this.timeout);
this.client = new Client(http);
this.clientWithMetadata = undefined;
}