-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
184 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,42 @@ | ||
import InstanceSettings from './model/InstanceSettings'; | ||
|
||
/** | ||
* Controller responsible for the configuration ui. | ||
*/ | ||
export class SensuConfigCtrl { | ||
static templateUrl = 'partials/config.html'; | ||
} | ||
|
||
// the current datasource settings | ||
current: InstanceSettings; | ||
|
||
/** @ngInject **/ | ||
constructor($scope) { | ||
const that = this; | ||
$scope.$watch(() => that.current.url, (value) => that.current.jsonData.currentUrl = value); | ||
$scope.$watch(() => that.current.basicAuth, (value) => { | ||
if (value) { | ||
that.current.jsonData.useApiKey = false; | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* When the "Use API Key" option is toggled. | ||
*/ | ||
onUseApiKeyToggle = () => { | ||
const current = this.current; | ||
if (current.jsonData.useApiKey) { | ||
current.basicAuth = false; | ||
this.resetApiKey(); | ||
} | ||
} | ||
|
||
/** | ||
* Resets the currely set API key. | ||
*/ | ||
resetApiKey = () => { | ||
this.current.secureJsonFields.apiKey = false; | ||
this.current.secureJsonData = this.current.secureJsonData || {}; | ||
this.current.secureJsonData.apiKey = ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
export default interface ConfigSettings { | ||
// the datasource url | ||
url: string; | ||
|
||
// whether basic auth is used | ||
basicAuth: boolean; | ||
|
||
// additional data | ||
jsonData: JsonData; | ||
|
||
// additional secured data | ||
secureJsonData: SecureJsonData; | ||
|
||
// map defining which secured data element is set | ||
secureJsonFields: SecureJsonFields; | ||
}; | ||
|
||
export interface JsonData { | ||
// copy of the current datasource url - used for dynamic routing | ||
currentUrl: string; | ||
|
||
// whether an API key should be used | ||
useApiKey: boolean; | ||
}; | ||
|
||
export interface SecureJsonData { | ||
// the specified API key | ||
apiKey?: string; | ||
}; | ||
|
||
export interface SecureJsonFields { | ||
// whether an API key has been stored by Grafana | ||
apiKey?: boolean; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,30 @@ | ||
<datasource-http-settings current="ctrl.current" no-direct-access="true" suggest-url="http://localhost:8080"> | ||
</datasource-http-settings> | ||
</datasource-http-settings> | ||
|
||
<h3 class="page-heading">API Key Auth</h3> | ||
|
||
<div class="gf-form-group"> | ||
<gf-form-switch class="gf-form" label="Use API key authentication" label-class="width-19" switch-class="max-width-6" | ||
checked="ctrl.current.jsonData.useApiKey" on-change="ctrl.onUseApiKeyToggle()"> | ||
</gf-form-switch> | ||
|
||
<div class="gf-form-inline" ng-if="ctrl.current.jsonData.useApiKey && !ctrl.current.secureJsonFields.apiKey"> | ||
<div class="gf-form"> | ||
<span class="gf-form-label width-9">API Key</span> | ||
<input class="gf-form-input width-30" type="text" ng-model="ctrl.current.secureJsonData.apiKey" | ||
placeholder="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" /> | ||
<info-popover mode="right-absolute"> | ||
<p> | ||
Please see the Sensu Go | ||
<a target="_blank" href="https://docs.sensu.io/sensu-go/latest/reference/apikeys/">documentation</a> | ||
for information on how to create an API key. | ||
</p> | ||
</info-popover> | ||
</div> | ||
</div> | ||
<div class="gf-form" ng-if="ctrl.current.jsonData.useApiKey && ctrl.current.secureJsonFields.apiKey"> | ||
<span class="gf-form-label width-9">API Key</span> | ||
<input type="text" class="gf-form-input max-width-12" disabled="disabled" value="configured" /> | ||
<a class="btn btn-secondary gf-form-btn" href="#" ng-click="ctrl.resetApiKey()">reset</a> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters