|
@@ -5,12 +5,16 @@ export class StackdriverConfigCtrl {
|
|
|
jsonText: string;
|
|
jsonText: string;
|
|
|
validationErrors: string[] = [];
|
|
validationErrors: string[] = [];
|
|
|
inputDataValid: boolean;
|
|
inputDataValid: boolean;
|
|
|
|
|
+ defaultProject: string;
|
|
|
|
|
+ projects: string[];
|
|
|
|
|
+ loadingProjects: boolean;
|
|
|
|
|
|
|
|
/** @ngInject */
|
|
/** @ngInject */
|
|
|
constructor($scope, datasourceSrv) {
|
|
constructor($scope, datasourceSrv) {
|
|
|
this.datasourceSrv = datasourceSrv;
|
|
this.datasourceSrv = datasourceSrv;
|
|
|
this.current.jsonData = this.current.jsonData || {};
|
|
this.current.jsonData = this.current.jsonData || {};
|
|
|
this.current.secureJsonData = this.current.secureJsonData || {};
|
|
this.current.secureJsonData = this.current.secureJsonData || {};
|
|
|
|
|
+ this.projects = [];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
save(jwt) {
|
|
save(jwt) {
|
|
@@ -45,6 +49,7 @@ export class StackdriverConfigCtrl {
|
|
|
this.jsonText = '';
|
|
this.jsonText = '';
|
|
|
if (this.validateJwt(json)) {
|
|
if (this.validateJwt(json)) {
|
|
|
this.save(json);
|
|
this.save(json);
|
|
|
|
|
+ this.displayProjects();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -53,6 +58,7 @@ export class StackdriverConfigCtrl {
|
|
|
const json = JSON.parse(e.originalEvent.clipboardData.getData('text/plain') || this.jsonText);
|
|
const json = JSON.parse(e.originalEvent.clipboardData.getData('text/plain') || this.jsonText);
|
|
|
if (this.validateJwt(json)) {
|
|
if (this.validateJwt(json)) {
|
|
|
this.save(json);
|
|
this.save(json);
|
|
|
|
|
+ this.displayProjects();
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.resetValidationMessages();
|
|
this.resetValidationMessages();
|
|
@@ -65,4 +71,16 @@ export class StackdriverConfigCtrl {
|
|
|
this.inputDataValid = false;
|
|
this.inputDataValid = false;
|
|
|
this.jsonText = '';
|
|
this.jsonText = '';
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ async displayProjects() {
|
|
|
|
|
+ if (this.projects.length === 0) {
|
|
|
|
|
+ this.loadingProjects = true;
|
|
|
|
|
+ const ds = await this.datasourceSrv.loadDatasource(this.current.name);
|
|
|
|
|
+ try {
|
|
|
|
|
+ this.projects = await ds.doRequest(`/cloudresourcemanager/v1/projects`);
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.log(error);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|