tripnomics_7.5.5/public/app/plugins/datasource/mssql/config_ctrl.ts
venbatechnologies@gmail.com 91fce5c4bf Initial commit
2021-07-05 13:49:40 +05:30

34 lines
1.3 KiB
TypeScript

import {
createChangeHandler,
createResetHandler,
PasswordFieldEnum,
} from '../../../features/datasources/utils/passwordHandlers';
export class MssqlConfigCtrl {
static templateUrl = 'partials/config.html';
current: any;
onPasswordReset: ReturnType<typeof createResetHandler>;
onPasswordChange: ReturnType<typeof createChangeHandler>;
showUserCredentials: boolean;
/** @ngInject */
constructor($scope: any) {
this.current.jsonData.encrypt = this.current.jsonData.encrypt || 'false';
this.current.jsonData.authenticationType = this.current.jsonData.authenticationType || 'SQL Server Authentication';
this.onPasswordReset = createResetHandler(this, PasswordFieldEnum.Password);
this.onPasswordChange = createChangeHandler(this, PasswordFieldEnum.Password);
this.showUserCredentials = this.current.jsonData.authenticationType !== 'Windows Authentication';
}
onAuthenticationTypeChange() {
// This is using the fallback in https://github.com/denisenkom/go-mssqldb to use Windows Auth if login/user id is empty.
if (this.current.jsonData.authenticationType === 'Windows Authentication') {
this.current.user = '';
this.current.password = '';
}
this.showUserCredentials = this.current.jsonData.authenticationType !== 'Windows Authentication';
}
}