Commit 3816172b2ad59736e120ad75861b5ef464af24df

Authored by Vladyslav_Prykhodko
1 parent 556cb5aa

Refactoring OAuth2

@@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
37 <mat-expansion-panel [formGroupName]="i" [expanded]="last"> 37 <mat-expansion-panel [formGroupName]="i" [expanded]="last">
38 <mat-expansion-panel-header> 38 <mat-expansion-panel-header>
39 <mat-panel-title fxLayoutAlign="start center"> 39 <mat-panel-title fxLayoutAlign="start center">
40 - {{ domain.get('domainName').value ? domain.get('domainName').value : ("admin.new-domain" | translate) }} 40 + {{ domain.get('domainName').value ? domain.get('domainName').value : ("admin.oauth2.new-domain" | translate) }}
41 </mat-panel-title> 41 </mat-panel-title>
42 <mat-panel-description fxLayoutAlign="end center"> 42 <mat-panel-description fxLayoutAlign="end center">
43 <button mat-icon-button 43 <button mat-icon-button
@@ -211,9 +211,9 @@ @@ -211,9 +211,9 @@
211 </mat-form-field> 211 </mat-form-field>
212 212
213 <div fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="8px" *ngIf="getProviderName(registration) === 'Custom'"> 213 <div fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="8px" *ngIf="getProviderName(registration) === 'Custom'">
214 - <mat-form-field fxFlex class="mat-block"> 214 + <mat-form-field fxFlex class="mat-block" floatLabel="always">
215 <mat-label translate>admin.oauth2.login-button-label</mat-label> 215 <mat-label translate>admin.oauth2.login-button-label</mat-label>
216 - <input matInput formControlName="loginButtonLabel" required> 216 + <input matInput formControlName="loginButtonLabel" placeholder="{{ 'admin.oauth2.login-button-label-1' | translate }}" required>
217 <mat-error 217 <mat-error
218 *ngIf="registration.get('loginButtonLabel').hasError('required')"> 218 *ngIf="registration.get('loginButtonLabel').hasError('required')">
219 {{ 'admin.oauth2.login-button-label-required' | translate }} 219 {{ 'admin.oauth2.login-button-label-required' | translate }}
@@ -380,7 +380,7 @@ @@ -380,7 +380,7 @@
380 [disabled]="(isLoading$ | async)" 380 [disabled]="(isLoading$ | async)"
381 (click)="addRegistration(domain)" 381 (click)="addRegistration(domain)"
382 type="button"> 382 type="button">
383 - {{'admin.add-provider' | translate}} 383 + {{'admin.oauth2.add-provider' | translate}}
384 </button> 384 </button>
385 </div> 385 </div>
386 </ng-template> 386 </ng-template>
@@ -396,7 +396,7 @@ @@ -396,7 +396,7 @@
396 [disabled]="(isLoading$ | async)" 396 [disabled]="(isLoading$ | async)"
397 (click)="addDomain()" 397 (click)="addDomain()"
398 type="button"> 398 type="button">
399 - {{'admin.add-domain' | translate}} 399 + {{'admin.oauth2.add-domain' | translate}}
400 </button> 400 </button>
401 <button mat-button mat-raised-button color="primary" 401 <button mat-button mat-raised-button color="primary"
402 [disabled]="(isLoading$ | async) || oauth2SettingsForm.invalid || !oauth2SettingsForm.dirty" 402 [disabled]="(isLoading$ | async) || oauth2SettingsForm.invalid || !oauth2SettingsForm.dirty"
@@ -334,15 +334,19 @@ export class OAuth2SettingsComponent extends PageComponent implements OnInit, Ha @@ -334,15 +334,19 @@ export class OAuth2SettingsComponent extends PageComponent implements OnInit, Ha
334 } 334 }
335 335
336 private prepareFormValue(formValue: OAuth2Settings[]): OAuth2Settings[]{ 336 private prepareFormValue(formValue: OAuth2Settings[]): OAuth2Settings[]{
337 - formValue.forEach((setting) => {  
338 - setting.clientRegistrations.forEach((registration) => {  
339 - registration.additionalInfo = JSON.stringify(registration.additionalInfo);  
340 - if (registration.id.id === null) {  
341 - delete registration.id;  
342 - }  
343 - }); 337 + const prepereValue = [];
  338 + formValue.forEach((setting, index) => {
  339 + if (this.clientDomains.at(index).dirty) {
  340 + setting.clientRegistrations.forEach((registration) => {
  341 + registration.additionalInfo = JSON.stringify(registration.additionalInfo);
  342 + if (registration.id.id === null) {
  343 + delete registration.id;
  344 + }
  345 + });
  346 + prepereValue.push(setting);
  347 + }
344 }); 348 });
345 - return formValue; 349 + return prepereValue;
346 } 350 }
347 351
348 confirmForm(): FormGroup { 352 confirmForm(): FormGroup {
@@ -123,59 +123,60 @@ @@ -123,59 +123,60 @@
123 "domain-name": "Domain name", 123 "domain-name": "Domain name",
124 "domain-name-unique": "Domain name need to unique for the system.", 124 "domain-name-unique": "Domain name need to unique for the system.",
125 "error-verification-url": "A domain name shouldn't contain symbols '/' and ':'. Example: thingsboard.io", 125 "error-verification-url": "A domain name shouldn't contain symbols '/' and ':'. Example: thingsboard.io",
126 - "add-domain": "Add domain",  
127 - "new-domain": "New domain",  
128 - "add-provider": "Add provider",  
129 "oauth2": { 126 "oauth2": {
130 - "oauth2": "OAuth2",  
131 - "registration-id": "Registration ID",  
132 - "registration-id-required": "Registration ID is required.",  
133 - "registration-id-unique": "Registration ID need to unique for the system.",  
134 - "client-id": "Client ID",  
135 - "client-id-required": "Client ID is required.",  
136 - "client-secret": "Client secret",  
137 - "client-secret-required": "Client secret is required.",  
138 "access-token-uri": "Access token URI", 127 "access-token-uri": "Access token URI",
139 "access-token-uri-required": "Access token URI is required.", 128 "access-token-uri-required": "Access token URI is required.",
  129 + "activate-user": "Activate user",
  130 + "add-domain": "Add domain",
  131 + "add-provider": "Add provider",
  132 + "allow-user-creation": "Allow user creation",
  133 + "always-fullscreen": "Always fullscreen",
140 "authorization-uri": "Authorization URI", 134 "authorization-uri": "Authorization URI",
141 "authorization-uri-required": "Authorization URI is required.", 135 "authorization-uri-required": "Authorization URI is required.",
142 - "uri-pattern-error": "Invalid URI format.",  
143 - "scope": "Scope",  
144 - "redirect-uri-template": "Redirect URI template",  
145 - "redirect-uri-template-required": "Redirect URI template is required.",  
146 - "jwk-set-uri": "JSON Web Key URI",  
147 - "user-info-uri": "User info URI",  
148 - "user-info-uri-required": "User info URI is required.",  
149 "client-authentication-method": "Client authentication method", 136 "client-authentication-method": "Client authentication method",
150 - "user-name-attribute-name": "User name attribute key",  
151 - "user-name-attribute-name-required": "User name attribute key is required",  
152 - "allow-user-creation": "Allow user creation",  
153 - "activate-user": "Activate user",  
154 - "type": "Mapper type", 137 + "client-id": "Client ID",
  138 + "client-id-required": "Client ID is required.",
  139 + "client-secret": "Client secret",
  140 + "client-secret-required": "Client secret is required.",
  141 + "custom-setting": "Custom settings",
  142 + "customer-name-pattern": "Customer name pattern",
  143 + "default-dashboard-name": "Default dashboard name",
  144 + "delete-domain-text": "Be careful, after the confirmation a domain and all registration data will be unavailable.",
  145 + "delete-domain-title": "Are you sure you want to delete the domain '{{domainName}}'?",
  146 + "delete-registration-text": "Be careful, after the confirmation a registration data will be unavailable.",
  147 + "delete-registration-title": "Are you sure you want to delete the registration '{{name}}'?",
155 "email-attribute-key": "Email attribute key", 148 "email-attribute-key": "Email attribute key",
156 "email-attribute-key-required": "Email attribute key is required.", 149 "email-attribute-key-required": "Email attribute key is required.",
157 "first-name-attribute-key": "First name attribute key", 150 "first-name-attribute-key": "First name attribute key",
  151 + "general": "General",
  152 + "jwk-set-uri": "JSON Web Key URI",
158 "last-name-attribute-key": "Last name attribute key", 153 "last-name-attribute-key": "Last name attribute key",
159 - "tenant-name-strategy": "Tenant name strategy", 154 + "login-button-icon": "Login button icon",
  155 + "login-button-label": "Provider label",
  156 + "login-button-label-1": "Login with $(Provider label)",
  157 + "login-button-label-required": "Label is required.",
  158 + "login-provider": "Login provider",
  159 + "mapper": "Mapper",
  160 + "new-domain": "New domain",
  161 + "oauth2": "OAuth2",
  162 + "redirect-uri-template": "Redirect URI template",
  163 + "redirect-uri-template-required": "Redirect URI template is required.",
  164 + "registration-id": "Registration ID",
  165 + "registration-id-required": "Registration ID is required.",
  166 + "registration-id-unique": "Registration ID need to unique for the system.",
  167 + "scope": "Scope",
160 "tenant-name-pattern": "Tenant name pattern", 168 "tenant-name-pattern": "Tenant name pattern",
161 "tenant-name-pattern-required": "Tenant name pattern is required.", 169 "tenant-name-pattern-required": "Tenant name pattern is required.",
162 - "customer-name-pattern": "Customer name pattern",  
163 - "default-dashboard-name": "Default dashboard name",  
164 - "always-fullscreen": "Always fullscreen", 170 + "tenant-name-strategy": "Tenant name strategy",
  171 + "type": "Mapper type",
  172 + "uri-pattern-error": "Invalid URI format.",
165 "url": "URL", 173 "url": "URL",
166 - "url-required": "URL is required.",  
167 "url-pattern": "Invalid URL format.", 174 "url-pattern": "Invalid URL format.",
168 - "login-button-label": "Label (Login with ${label})",  
169 - "login-button-label-required": "Label is required.",  
170 - "login-button-icon": "Login button icon",  
171 - "delete-domain-title": "Are you sure you want to delete the domain '{{domainName}}'?",  
172 - "delete-domain-text": "Be careful, after the confirmation a domain and all registration data will be unavailable.",  
173 - "delete-registration-title": "Are you sure you want to delete the registration '{{name}}'?",  
174 - "delete-registration-text": "Be careful, after the confirmation a registration data will be unavailable.",  
175 - "login-provider": "Login provider",  
176 - "custom-setting": "Custom settings",  
177 - "general": "General",  
178 - "mapper": "Mapper" 175 + "url-required": "URL is required.",
  176 + "user-info-uri": "User info URI",
  177 + "user-info-uri-required": "User info URI is required.",
  178 + "user-name-attribute-name": "User name attribute key",
  179 + "user-name-attribute-name-required": "User name attribute key is required"
179 } 180 }
180 }, 181 },
181 "alarm": { 182 "alarm": {