Commit aa2e64e1 by Erik Sundell

stackdriver: improve ui for toggling authentication type

parent 0b82fda4
...@@ -5,13 +5,23 @@ export class StackdriverConfigCtrl { ...@@ -5,13 +5,23 @@ export class StackdriverConfigCtrl {
jsonText: string; jsonText: string;
validationErrors: string[] = []; validationErrors: string[] = [];
inputDataValid: boolean; inputDataValid: boolean;
authenticationTypes: any[];
defaultAuthenticationType: string;
/** @ngInject */ /** @ngInject */
constructor(datasourceSrv) { constructor(datasourceSrv) {
this.defaultAuthenticationType = 'jwt';
this.datasourceSrv = datasourceSrv; this.datasourceSrv = datasourceSrv;
this.current.jsonData = this.current.jsonData || {}; 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.secureJsonData = this.current.secureJsonData || {};
this.current.secureJsonFields = this.current.secureJsonFields || {}; this.current.secureJsonFields = this.current.secureJsonFields || {};
this.authenticationTypes = [
{ key: this.defaultAuthenticationType, value: 'Google JWT File' },
{ key: 'gce', value: 'Use GCE default Authentication' },
];
} }
save(jwt) { save(jwt) {
...@@ -67,7 +77,7 @@ export class StackdriverConfigCtrl { ...@@ -67,7 +77,7 @@ export class StackdriverConfigCtrl {
this.inputDataValid = false; this.inputDataValid = false;
this.jsonText = ''; this.jsonText = '';
this.current.jsonData = {}; this.current.jsonData = Object.assign({}, { authenticationType: this.current.jsonData.authenticationType });
this.current.secureJsonData = {}; this.current.secureJsonData = {};
this.current.secureJsonFields = {}; this.current.secureJsonFields = {};
} }
......
...@@ -31,10 +31,16 @@ ...@@ -31,10 +31,16 @@
contents will be encrypted and saved in the Grafana database.</info-popover> contents will be encrypted and saved in the Grafana database.</info-popover>
</div> </div>
<gf-form-switch class="gf-form" label="Use GCE default Authentication" checked="ctrl.current.jsonData.gceAutomaticAuthentication" <div class="gf-form-inline">
switch-class="max-width-4" label-class="width-16"></gf-form-switch> <div class="gf-form max-width-30">
<span class="gf-form-label width-10">Authentication Type</span>
<div class="gf-form-select-wrapper max-width-24">
<select class="gf-form-input" ng-model="ctrl.current.jsonData.authenticationType" ng-options="f.key as f.value for f in ctrl.authenticationTypes"></select>
</div>
</div>
</div>
<div ng-if="!ctrl.current.jsonData.clientEmail && !ctrl.inputDataValid"> <div ng-if="ctrl.current.jsonData.authenticationType === ctrl.defaultAuthenticationType && !ctrl.current.jsonData.clientEmail && !ctrl.inputDataValid">
<div class="gf-form-group" ng-if="!ctrl.inputDataValid"> <div class="gf-form-group" ng-if="!ctrl.inputDataValid">
<div class="gf-form"> <div class="gf-form">
<form> <form>
...@@ -55,23 +61,23 @@ ...@@ -55,23 +61,23 @@
</div> </div>
</div> </div>
<div class="gf-form-group" ng-if="ctrl.inputDataValid || ctrl.current.jsonData.clientEmail"> <div class="gf-form-group" ng-if="ctrl.current.jsonData.authenticationType === ctrl.defaultAuthenticationType && (ctrl.inputDataValid || ctrl.current.jsonData.clientEmail)">
<h6>Uploaded Key Details</h6> <h6>Uploaded Key Details</h6>
<div class="gf-form"> <div class="gf-form">
<span class="gf-form-label width-9">Project</span> <span class="gf-form-label width-10">Project</span>
<input class="gf-form-input width-40" disabled type="text" ng-model="ctrl.current.jsonData.defaultProject" /> <input class="gf-form-input width-40" disabled type="text" ng-model="ctrl.current.jsonData.defaultProject" />
</div> </div>
<div class="gf-form"> <div class="gf-form">
<span class="gf-form-label width-9">Client Email</span> <span class="gf-form-label width-10">Client Email</span>
<input class="gf-form-input width-40" disabled type="text" ng-model="ctrl.current.jsonData.clientEmail" /> <input class="gf-form-input width-40" disabled type="text" ng-model="ctrl.current.jsonData.clientEmail" />
</div> </div>
<div class="gf-form"> <div class="gf-form">
<span class="gf-form-label width-9">Token URI</span> <span class="gf-form-label width-10">Token URI</span>
<input class="gf-form-input width-40" disabled type="text" ng-model='ctrl.current.jsonData.tokenUri' /> <input class="gf-form-input width-40" disabled type="text" ng-model='ctrl.current.jsonData.tokenUri' />
</div> </div>
<div class="gf-form" ng-if="ctrl.current.secureJsonFields.privateKey"> <div class="gf-form" ng-if="ctrl.current.secureJsonFields.privateKey">
<span class="gf-form-label width-9">Private Key</span> <span class="gf-form-label width-10">Private Key</span>
<input type="text" class="gf-form-input max-width-12" disabled="disabled" value="configured"> <input type="text" class="gf-form-input max-width-12" disabled="disabled" value="configured">
</div> </div>
...@@ -84,9 +90,8 @@ ...@@ -84,9 +90,8 @@
</div> </div>
</div> </div>
<p class="gf-form-label" ng-hide="ctrl.current.secureJsonFields.privateKey"><i class="fa fa-save"></i> Do not forget to save your changes after uploading a file.</p> <p class="gf-form-label" ng-hide="ctrl.current.secureJsonFields.privateKey || ctrl.current.jsonData.authenticationType !== ctrl.defaultAuthenticationType"><i
class="fa fa-save"></i> Do not forget to
<p class="gf-form-label" ng-show="ctrl.current.jsonData.authenticationType !== ctrl.defaultAuthenticationType"><i class="fa fa-save"></i>
<div class="grafana-info-box" ng-hide="ctrl.current.secureJsonFields.privateKey"> Verify GCE automatic authentication by clicking Save & Test</p>
Do not forget to save your changes after uploading a file.
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment