diff --git a/public/app/core/angular_wrappers.ts b/public/app/core/angular_wrappers.ts index 9105de82d53..60e292cc24b 100644 --- a/public/app/core/angular_wrappers.ts +++ b/public/app/core/angular_wrappers.ts @@ -9,7 +9,7 @@ import { TagFilter } from './components/TagFilter/TagFilter'; import { SideMenu } from './components/sidemenu/SideMenu'; import { MetricSelect } from './components/Select/MetricSelect'; import AppNotificationList from './components/AppNotifications/AppNotificationList'; -import { ColorPicker, SeriesColorPickerPopoverWithTheme } from '@grafana/ui'; +import { ColorPicker, SeriesColorPickerPopoverWithTheme, SecretFormField } from '@grafana/ui'; import { FunctionEditor } from 'app/plugins/datasource/graphite/FunctionEditor'; export function registerAngularDirectives() { @@ -59,4 +59,11 @@ export function registerAngularDirectives() { ['datasource', { watchDepth: 'reference' }], ['templateSrv', { watchDepth: 'reference' }], ]); + react2AngularDirective('secretFormField', SecretFormField, [ + 'value', + 'isConfigured', + 'inputWidth', + ['onReset', { watchDepth: 'reference', wrapApply: true }], + ['onChange', { watchDepth: 'reference', wrapApply: true }], + ]); } diff --git a/public/app/plugins/datasource/mssql/config_ctrl.ts b/public/app/plugins/datasource/mssql/config_ctrl.ts index c80d657a914..4555e6f67d8 100644 --- a/public/app/plugins/datasource/mssql/config_ctrl.ts +++ b/public/app/plugins/datasource/mssql/config_ctrl.ts @@ -1,3 +1,5 @@ +import { SyntheticEvent } from 'react'; + export class MssqlConfigCtrl { static templateUrl = 'partials/config.html'; @@ -7,4 +9,16 @@ export class MssqlConfigCtrl { constructor($scope) { this.current.jsonData.encrypt = this.current.jsonData.encrypt || 'false'; } + + onPasswordReset = (event: SyntheticEvent) => { + event.preventDefault(); + this.current.secureJsonFields.password = false; + this.current.secureJsonData = this.current.secureJsonData || {}; + this.current.secureJsonData.password = ''; + }; + + onPasswordChange = (event: SyntheticEvent) => { + this.current.secureJsonData = this.current.secureJsonData || {}; + this.current.secureJsonData.password = event.currentTarget.value; + }; } diff --git a/public/app/plugins/datasource/mssql/partials/config.html b/public/app/plugins/datasource/mssql/partials/config.html index f3ac7e87064..6428b45dfe4 100644 --- a/public/app/plugins/datasource/mssql/partials/config.html +++ b/public/app/plugins/datasource/mssql/partials/config.html @@ -17,15 +17,15 @@ User -
- Password - -
-
- Password - - reset -
+
+ +
diff --git a/public/app/plugins/datasource/postgres/config_ctrl.ts b/public/app/plugins/datasource/postgres/config_ctrl.ts index a396b9f9aa4..e547f5697a2 100644 --- a/public/app/plugins/datasource/postgres/config_ctrl.ts +++ b/public/app/plugins/datasource/postgres/config_ctrl.ts @@ -1,4 +1,5 @@ import _ from 'lodash'; +import { SyntheticEvent } from 'react'; export class PostgresConfigCtrl { static templateUrl = 'partials/config.html'; @@ -52,6 +53,18 @@ export class PostgresConfigCtrl { this.showTimescaleDBHelp = !this.showTimescaleDBHelp; } + onPasswordReset = (event: SyntheticEvent) => { + event.preventDefault(); + this.current.secureJsonFields.password = false; + this.current.secureJsonData = this.current.secureJsonData || {}; + this.current.secureJsonData.password = ''; + }; + + onPasswordChange = (event: SyntheticEvent) => { + this.current.secureJsonData = this.current.secureJsonData || {}; + this.current.secureJsonData.password = event.currentTarget.value; + }; + // the value portion is derived from postgres server_version_num/100 postgresVersions = [ { name: '9.3', value: 903 }, diff --git a/public/app/plugins/datasource/postgres/partials/config.html b/public/app/plugins/datasource/postgres/partials/config.html index c0e5a30496d..e7680707672 100644 --- a/public/app/plugins/datasource/postgres/partials/config.html +++ b/public/app/plugins/datasource/postgres/partials/config.html @@ -17,16 +17,17 @@ User
-
- Password - -
-
- Password - - reset +
+
+