From aa2e64e1603dfc7487ac48d0eaba2c7f00ce10cd Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Tue, 9 Oct 2018 16:06:59 +0200 Subject: [PATCH] stackdriver: improve ui for toggling authentication type --- .../datasource/stackdriver/config_ctrl.ts | 12 ++++++- .../stackdriver/partials/config.html | 31 +++++++++++-------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/public/app/plugins/datasource/stackdriver/config_ctrl.ts b/public/app/plugins/datasource/stackdriver/config_ctrl.ts index d3847562156..13dba26ba86 100644 --- a/public/app/plugins/datasource/stackdriver/config_ctrl.ts +++ b/public/app/plugins/datasource/stackdriver/config_ctrl.ts @@ -5,13 +5,23 @@ export class StackdriverConfigCtrl { jsonText: string; validationErrors: string[] = []; inputDataValid: boolean; + authenticationTypes: any[]; + defaultAuthenticationType: string; /** @ngInject */ constructor(datasourceSrv) { + this.defaultAuthenticationType = 'jwt'; this.datasourceSrv = datasourceSrv; this.current.jsonData = this.current.jsonData || {}; + this.current.jsonData.authenticationType = this.current.jsonData.authenticationType + ? this.current.jsonData.authenticationType + : this.defaultAuthenticationType; this.current.secureJsonData = this.current.secureJsonData || {}; this.current.secureJsonFields = this.current.secureJsonFields || {}; + this.authenticationTypes = [ + { key: this.defaultAuthenticationType, value: 'Google JWT File' }, + { key: 'gce', value: 'Use GCE default Authentication' }, + ]; } save(jwt) { @@ -67,7 +77,7 @@ export class StackdriverConfigCtrl { this.inputDataValid = false; this.jsonText = ''; - this.current.jsonData = {}; + this.current.jsonData = Object.assign({}, { authenticationType: this.current.jsonData.authenticationType }); this.current.secureJsonData = {}; this.current.secureJsonFields = {}; } diff --git a/public/app/plugins/datasource/stackdriver/partials/config.html b/public/app/plugins/datasource/stackdriver/partials/config.html index 6fd52a898f5..0cc08a3e9d8 100644 --- a/public/app/plugins/datasource/stackdriver/partials/config.html +++ b/public/app/plugins/datasource/stackdriver/partials/config.html @@ -31,10 +31,16 @@ contents will be encrypted and saved in the Grafana database. - +
+
+ Authentication Type +
+ +
+
+
-
+
@@ -55,23 +61,23 @@
-
+
Uploaded Key Details
- Project + Project
- Client Email + Client Email
- Token URI + Token URI
- Private Key + Private Key
@@ -84,9 +90,8 @@
-

Do not forget to save your changes after uploading a file.

+

Do not forget to - -

- Do not forget to save your changes after uploading a file. -
+

+ Verify GCE automatic authentication by clicking Save & Test