Browse Source

Refactoring OAuth2

pull/3557/head
Vladyslav_Prykhodko 6 years ago
parent
commit
3816172b2a
  1. 10
      ui-ngx/src/app/modules/home/pages/admin/oauth2-settings.component.html
  2. 20
      ui-ngx/src/app/modules/home/pages/admin/oauth2-settings.component.ts
  3. 79
      ui-ngx/src/assets/locale/locale.constant-en_US.json

10
ui-ngx/src/app/modules/home/pages/admin/oauth2-settings.component.html

@ -37,7 +37,7 @@
<mat-expansion-panel [formGroupName]="i" [expanded]="last">
<mat-expansion-panel-header>
<mat-panel-title fxLayoutAlign="start center">
{{ domain.get('domainName').value ? domain.get('domainName').value : ("admin.new-domain" | translate) }}
{{ domain.get('domainName').value ? domain.get('domainName').value : ("admin.oauth2.new-domain" | translate) }}
</mat-panel-title>
<mat-panel-description fxLayoutAlign="end center">
<button mat-icon-button
@ -211,9 +211,9 @@
</mat-form-field>
<div fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="8px" *ngIf="getProviderName(registration) === 'Custom'">
<mat-form-field fxFlex class="mat-block">
<mat-form-field fxFlex class="mat-block" floatLabel="always">
<mat-label translate>admin.oauth2.login-button-label</mat-label>
<input matInput formControlName="loginButtonLabel" required>
<input matInput formControlName="loginButtonLabel" placeholder="{{ 'admin.oauth2.login-button-label-1' | translate }}" required>
<mat-error
*ngIf="registration.get('loginButtonLabel').hasError('required')">
{{ 'admin.oauth2.login-button-label-required' | translate }}
@ -380,7 +380,7 @@
[disabled]="(isLoading$ | async)"
(click)="addRegistration(domain)"
type="button">
{{'admin.add-provider' | translate}}
{{'admin.oauth2.add-provider' | translate}}
</button>
</div>
</ng-template>
@ -396,7 +396,7 @@
[disabled]="(isLoading$ | async)"
(click)="addDomain()"
type="button">
{{'admin.add-domain' | translate}}
{{'admin.oauth2.add-domain' | translate}}
</button>
<button mat-button mat-raised-button color="primary"
[disabled]="(isLoading$ | async) || oauth2SettingsForm.invalid || !oauth2SettingsForm.dirty"

20
ui-ngx/src/app/modules/home/pages/admin/oauth2-settings.component.ts

@ -334,15 +334,19 @@ export class OAuth2SettingsComponent extends PageComponent implements OnInit, Ha
}
private prepareFormValue(formValue: OAuth2Settings[]): OAuth2Settings[]{
formValue.forEach((setting) => {
setting.clientRegistrations.forEach((registration) => {
registration.additionalInfo = JSON.stringify(registration.additionalInfo);
if (registration.id.id === null) {
delete registration.id;
}
});
const prepereValue = [];
formValue.forEach((setting, index) => {
if (this.clientDomains.at(index).dirty) {
setting.clientRegistrations.forEach((registration) => {
registration.additionalInfo = JSON.stringify(registration.additionalInfo);
if (registration.id.id === null) {
delete registration.id;
}
});
prepereValue.push(setting);
}
});
return formValue;
return prepereValue;
}
confirmForm(): FormGroup {

79
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -123,59 +123,60 @@
"domain-name": "Domain name",
"domain-name-unique": "Domain name need to unique for the system.",
"error-verification-url": "A domain name shouldn't contain symbols '/' and ':'. Example: thingsboard.io",
"add-domain": "Add domain",
"new-domain": "New domain",
"add-provider": "Add provider",
"oauth2": {
"oauth2": "OAuth2",
"registration-id": "Registration ID",
"registration-id-required": "Registration ID is required.",
"registration-id-unique": "Registration ID need to unique for the system.",
"client-id": "Client ID",
"client-id-required": "Client ID is required.",
"client-secret": "Client secret",
"client-secret-required": "Client secret is required.",
"access-token-uri": "Access token URI",
"access-token-uri-required": "Access token URI is required.",
"activate-user": "Activate user",
"add-domain": "Add domain",
"add-provider": "Add provider",
"allow-user-creation": "Allow user creation",
"always-fullscreen": "Always fullscreen",
"authorization-uri": "Authorization URI",
"authorization-uri-required": "Authorization URI is required.",
"uri-pattern-error": "Invalid URI format.",
"scope": "Scope",
"redirect-uri-template": "Redirect URI template",
"redirect-uri-template-required": "Redirect URI template is required.",
"jwk-set-uri": "JSON Web Key URI",
"user-info-uri": "User info URI",
"user-info-uri-required": "User info URI is required.",
"client-authentication-method": "Client authentication method",
"user-name-attribute-name": "User name attribute key",
"user-name-attribute-name-required": "User name attribute key is required",
"allow-user-creation": "Allow user creation",
"activate-user": "Activate user",
"type": "Mapper type",
"client-id": "Client ID",
"client-id-required": "Client ID is required.",
"client-secret": "Client secret",
"client-secret-required": "Client secret is required.",
"custom-setting": "Custom settings",
"customer-name-pattern": "Customer name pattern",
"default-dashboard-name": "Default dashboard name",
"delete-domain-text": "Be careful, after the confirmation a domain and all registration data will be unavailable.",
"delete-domain-title": "Are you sure you want to delete the domain '{{domainName}}'?",
"delete-registration-text": "Be careful, after the confirmation a registration data will be unavailable.",
"delete-registration-title": "Are you sure you want to delete the registration '{{name}}'?",
"email-attribute-key": "Email attribute key",
"email-attribute-key-required": "Email attribute key is required.",
"first-name-attribute-key": "First name attribute key",
"general": "General",
"jwk-set-uri": "JSON Web Key URI",
"last-name-attribute-key": "Last name attribute key",
"tenant-name-strategy": "Tenant name strategy",
"login-button-icon": "Login button icon",
"login-button-label": "Provider label",
"login-button-label-1": "Login with $(Provider label)",
"login-button-label-required": "Label is required.",
"login-provider": "Login provider",
"mapper": "Mapper",
"new-domain": "New domain",
"oauth2": "OAuth2",
"redirect-uri-template": "Redirect URI template",
"redirect-uri-template-required": "Redirect URI template is required.",
"registration-id": "Registration ID",
"registration-id-required": "Registration ID is required.",
"registration-id-unique": "Registration ID need to unique for the system.",
"scope": "Scope",
"tenant-name-pattern": "Tenant name pattern",
"tenant-name-pattern-required": "Tenant name pattern is required.",
"customer-name-pattern": "Customer name pattern",
"default-dashboard-name": "Default dashboard name",
"always-fullscreen": "Always fullscreen",
"tenant-name-strategy": "Tenant name strategy",
"type": "Mapper type",
"uri-pattern-error": "Invalid URI format.",
"url": "URL",
"url-required": "URL is required.",
"url-pattern": "Invalid URL format.",
"login-button-label": "Label (Login with ${label})",
"login-button-label-required": "Label is required.",
"login-button-icon": "Login button icon",
"delete-domain-title": "Are you sure you want to delete the domain '{{domainName}}'?",
"delete-domain-text": "Be careful, after the confirmation a domain and all registration data will be unavailable.",
"delete-registration-title": "Are you sure you want to delete the registration '{{name}}'?",
"delete-registration-text": "Be careful, after the confirmation a registration data will be unavailable.",
"login-provider": "Login provider",
"custom-setting": "Custom settings",
"general": "General",
"mapper": "Mapper"
"url-required": "URL is required.",
"user-info-uri": "User info URI",
"user-info-uri-required": "User info URI is required.",
"user-name-attribute-name": "User name attribute key",
"user-name-attribute-name-required": "User name attribute key is required"
}
},
"alarm": {

Loading…
Cancel
Save