mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
stackdriver: get default project from backend. also ensure default project could be retrieved when authentication type is gce
This commit is contained in:
@@ -221,8 +221,25 @@ export default class StackdriverDatasource {
|
||||
|
||||
async getDefaultProject() {
|
||||
try {
|
||||
await this.queryPromise;
|
||||
return this.projectName;
|
||||
if (!this.projectName) {
|
||||
const { data } = await this.backendSrv.datasourceRequest({
|
||||
url: '/api/tsdb/query',
|
||||
method: 'POST',
|
||||
data: {
|
||||
queries: [
|
||||
{
|
||||
refId: 'defaultProject',
|
||||
type: 'defaultProject',
|
||||
datasourceId: this.id,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
this.projectName = data.results.defaultProject.meta.defaultProject;
|
||||
return this.projectName;
|
||||
} else {
|
||||
return this.projectName;
|
||||
}
|
||||
} catch (error) {
|
||||
let message = 'Projects cannot be fetched: ';
|
||||
message += error.statusText ? error.statusText + ': ' : '';
|
||||
|
||||
Reference in New Issue
Block a user