Browse Source

UI: Refactoring, rename locale file

pull/3694/head
Vladyslav_Prykhodko 6 years ago
parent
commit
f32aed7d58
  1. 4
      ui-ngx/src/app/modules/home/components/profile/tenant-profile.component.ts
  2. 244
      ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html
  3. 51
      ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts
  4. 0
      ui-ngx/src/assets/locale/locale.constant-pt_BR.json

4
ui-ngx/src/app/modules/home/components/profile/tenant-profile.component.ts

@ -23,7 +23,7 @@ import {
TenantProfile, TenantProfile,
TenantProfileData, TenantProfileData,
TenantProfileType TenantProfileType
} from '@app/shared/models/tenant.model'; } from '@shared/models/tenant.model';
import { ActionNotificationShow } from '@app/core/notification/notification.actions'; import { ActionNotificationShow } from '@app/core/notification/notification.actions';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models'; import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
@ -73,7 +73,7 @@ export class TenantProfileComponent extends EntityComponent<TenantProfile> {
this.entityForm.patchValue({name: entity.name}); this.entityForm.patchValue({name: entity.name});
this.entityForm.patchValue({isolatedTbCore: entity.isolatedTbCore}); this.entityForm.patchValue({isolatedTbCore: entity.isolatedTbCore});
this.entityForm.patchValue({isolatedTbRuleEngine: entity.isolatedTbRuleEngine}); this.entityForm.patchValue({isolatedTbRuleEngine: entity.isolatedTbRuleEngine});
this.entityForm.patchValue({profileData: !this.isAdd ? entity.profileData: { this.entityForm.patchValue({profileData: !this.isAdd ? entity.profileData : {
configuration: createTenantProfileConfiguration(TenantProfileType.DEFAULT) configuration: createTenantProfileConfiguration(TenantProfileType.DEFAULT)
} as TenantProfileData}); } as TenantProfileData});
this.entityForm.patchValue({description: entity.description}); this.entityForm.patchValue({description: entity.description});

244
ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html

@ -15,127 +15,125 @@
limitations under the License. limitations under the License.
--> -->
<section [formGroup]="defaultTenantProfileConfigurationFormGroup"> <section [formGroup]="defaultTenantProfileConfigurationFormGroup" fxLayout="column">
<section formGroupName="configuration" fxLayout="column"> <mat-form-field class="mat-block">
<mat-form-field class="mat-block"> <mat-label translate>tenant-profile.maximum-devices</mat-label>
<mat-label translate>tenant-profile.maximum-devices</mat-label> <input matInput required min="0" step="1"
<input matInput required min="0" step="1" formControlName="maxDevices"
formControlName="maxDevices" type="number">
type="number"> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxDevices').hasError('required')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxDevices').hasError('required')"> {{ 'tenant-profile.maximum-devices-required' | translate}}
{{ 'tenant-profile.maximum-devices-required' | translate}} </mat-error>
</mat-error> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxDevices').hasError('min')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxDevices').hasError('min')"> {{ 'tenant-profile.maximum-devices-range' | translate}}
{{ 'tenant-profile.maximum-devices-range' | translate}} </mat-error>
</mat-error> </mat-form-field>
</mat-form-field> <mat-form-field class="mat-block">
<mat-form-field class="mat-block"> <mat-label translate>tenant-profile.maximum-assets</mat-label>
<mat-label translate>tenant-profile.maximum-assets</mat-label> <input matInput required min="0" step="1"
<input matInput required min="0" step="1" formControlName="maxAssets"
formControlName="maxAssets" type="number">
type="number"> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxAssets').hasError('required')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxAssets').hasError('required')"> {{ 'tenant-profile.maximum-assets-required' | translate}}
{{ 'tenant-profile.maximum-assets-required' | translate}} </mat-error>
</mat-error> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxAssets').hasError('min')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxAssets').hasError('min')"> {{ 'tenant-profile.maximum-assets-range' | translate}}
{{ 'tenant-profile.maximum-assets-range' | translate}} </mat-error>
</mat-error> </mat-form-field>
</mat-form-field> <mat-form-field class="mat-block">
<mat-form-field class="mat-block"> <mat-label translate>tenant-profile.max-transport-messages</mat-label>
<mat-label translate>tenant-profile.max-transport-messages</mat-label> <input matInput required min="0" step="1"
<input matInput required min="0" step="1" formControlName="maxTransportMessages"
formControlName="maxTransportMessages" type="number">
type="number"> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxTransportMessages').hasError('required')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxTransportMessages').hasError('required')"> {{ 'tenant-profile.max-transport-messages-range' | translate}}
{{ 'tenant-profile.max-transport-messages-range' | translate}} </mat-error>
</mat-error> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxTransportMessages').hasError('min')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxTransportMessages').hasError('min')"> {{ 'tenant-profile.max-transport-messages-required' | translate}}
{{ 'tenant-profile.max-transport-messages-required' | translate}} </mat-error>
</mat-error> </mat-form-field>
</mat-form-field> <mat-form-field class="mat-block">
<mat-form-field class="mat-block"> <mat-label translate>tenant-profile.max-transport-data-points</mat-label>
<mat-label translate>tenant-profile.max-transport-data-points</mat-label> <input matInput required min="0" step="1"
<input matInput required min="0" step="1" formControlName="maxTransportDataPoints"
formControlName="maxTransportDataPoints" type="number">
type="number"> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxTransportDataPoints').hasError('required')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxTransportDataPoints').hasError('required')"> {{ 'tenant-profile.max-transport-data-points-required' | translate}}
{{ 'tenant-profile.max-transport-data-points-required' | translate}} </mat-error>
</mat-error> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxTransportDataPoints').hasError('min')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxTransportDataPoints').hasError('min')"> {{ 'tenant-profile.max-transport-data-points-range' | translate}}
{{ 'tenant-profile.max-transport-data-points-range' | translate}} </mat-error>
</mat-error> </mat-form-field>
</mat-form-field> <mat-form-field class="mat-block">
<mat-form-field class="mat-block"> <mat-label translate>tenant-profile.max-r-e-executions</mat-label>
<mat-label translate>tenant-profile.max-r-e-executions</mat-label> <input matInput required min="0" step="1"
<input matInput required min="0" step="1" formControlName="maxREExecutions"
formControlName="maxREExecutions" type="number">
type="number"> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxREExecutions').hasError('required')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxREExecutions').hasError('required')"> {{ 'tenant-profile.max-r-e-executions-required' | translate}}
{{ 'tenant-profile.max-r-e-executions-required' | translate}} </mat-error>
</mat-error> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxREExecutions').hasError('min')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxREExecutions').hasError('min')"> {{ 'tenant-profile.max-r-e-executions-range' | translate}}
{{ 'tenant-profile.max-r-e-executions-range' | translate}} </mat-error>
</mat-error> </mat-form-field>
</mat-form-field> <mat-form-field class="mat-block">
<mat-form-field class="mat-block"> <mat-label translate>tenant-profile.max-j-s-executions</mat-label>
<mat-label translate>tenant-profile.max-j-s-executions</mat-label> <input matInput required min="0" step="1"
<input matInput required min="0" step="1" formControlName="maxJSExecutions"
formControlName="maxJSExecutions" type="number">
type="number"> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxJSExecutions').hasError('required')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxJSExecutions').hasError('required')"> {{ 'tenant-profile.max-j-s-executions-required' | translate}}
{{ 'tenant-profile.max-j-s-executions-required' | translate}} </mat-error>
</mat-error> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxJSExecutions').hasError('min')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxJSExecutions').hasError('min')"> {{ 'tenant-profile.max-j-s-executions-range' | translate}}
{{ 'tenant-profile.max-j-s-executions-range' | translate}} </mat-error>
</mat-error> </mat-form-field>
</mat-form-field> <mat-form-field class="mat-block">
<mat-form-field class="mat-block"> <mat-label translate>tenant-profile.max-d-p-storage-days</mat-label>
<mat-label translate>tenant-profile.max-d-p-storage-days</mat-label> <input matInput required min="0" step="1"
<input matInput required min="0" step="1" formControlName="maxDPStorageDays"
formControlName="maxDPStorageDays" type="number">
type="number"> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxDPStorageDays').hasError('required')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxDPStorageDays').hasError('required')"> {{ 'tenant-profile.max-d-p-storage-days-required' | translate}}
{{ 'tenant-profile.max-d-p-storage-days-required' | translate}} </mat-error>
</mat-error> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxDPStorageDays').hasError('min')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxDPStorageDays').hasError('min')"> {{ 'tenant-profile.max-d-p-storage-days-range' | translate}}
{{ 'tenant-profile.max-d-p-storage-days-range' | translate}} </mat-error>
</mat-error> </mat-form-field>
</mat-form-field> <mat-form-field class="mat-block">
<mat-form-field class="mat-block"> <mat-label translate>tenant-profile.max-rule-node-executions-per-message</mat-label>
<mat-label translate>tenant-profile.max-rule-node-executions-per-message</mat-label> <input matInput required min="0" step="1"
<input matInput required min="0" step="1" formControlName="maxRuleNodeExecutionsPerMessage"
formControlName="maxRuleNodeExecutionsPerMessage" type="number">
type="number"> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxRuleNodeExecutionsPerMessage').hasError('required')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxRuleNodeExecutionsPerMessage').hasError('required')"> {{ 'tenant-profile.max-rule-node-executions-per-message-required' | translate}}
{{ 'tenant-profile.max-rule-node-executions-per-message-required' | translate}} </mat-error>
</mat-error> <mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxRuleNodeExecutionsPerMessage').hasError('min')">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('configuration.maxRuleNodeExecutionsPerMessage').hasError('min')"> {{ 'tenant-profile.max-rule-node-executions-per-message-range' | translate}}
{{ 'tenant-profile.max-rule-node-executions-per-message-range' | translate}} </mat-error>
</mat-error> </mat-form-field>
</mat-form-field> <mat-form-field class="mat-block">
<mat-form-field class="mat-block"> <mat-label translate>tenant-profile.transport-tenant-msg-rate-limit</mat-label>
<mat-label translate>tenant-profile.transport-tenant-msg-rate-limit</mat-label> <input matInput formControlName="transportTenantMsgRateLimit">
<input matInput formControlName="transportTenantMsgRateLimit"> </mat-form-field>
</mat-form-field> <mat-form-field class="mat-block">
<mat-form-field class="mat-block"> <mat-label translate>tenant-profile.transport-tenant-telemetry-msg-rate-limit</mat-label>
<mat-label translate>tenant-profile.transport-tenant-telemetry-msg-rate-limit</mat-label> <input matInput formControlName="transportTenantTelemetryMsgRateLimit">
<input matInput formControlName="transportTenantTelemetryMsgRateLimit"> </mat-form-field>
</mat-form-field> <mat-form-field class="mat-block">
<mat-form-field class="mat-block"> <mat-label translate>tenant-profile.transport-tenant-telemetry-data-points-rate-limit</mat-label>
<mat-label translate>tenant-profile.transport-tenant-telemetry-data-points-rate-limit</mat-label> <input matInput formControlName="transportTenantTelemetryDataPointsRateLimit">
<input matInput formControlName="transportTenantTelemetryDataPointsRateLimit"> </mat-form-field>
</mat-form-field> <mat-form-field class="mat-block">
<mat-form-field class="mat-block"> <mat-label translate>tenant-profile.transport-device-msg-rate-limit</mat-label>
<mat-label translate>tenant-profile.transport-device-msg-rate-limit</mat-label> <input matInput formControlName="transportDeviceMsgRateLimit">
<input matInput formControlName="transportDeviceMsgRateLimit"> </mat-form-field>
</mat-form-field> <mat-form-field class="mat-block">
<mat-form-field class="mat-block"> <mat-label translate>tenant-profile.transport-device-telemetry-msg-rate-limit</mat-label>
<mat-label translate>tenant-profile.transport-device-telemetry-msg-rate-limit</mat-label> <input matInput formControlName="transportDeviceTelemetryMsgRateLimit">
<input matInput formControlName="transportDeviceTelemetryMsgRateLimit"> </mat-form-field>
</mat-form-field> <mat-form-field class="mat-block">
<mat-form-field class="mat-block"> <mat-label translate>tenant-profile.transport-device-telemetry-data-points-rate-limit</mat-label>
<mat-label translate>tenant-profile.transport-device-telemetry-data-points-rate-limit</mat-label> <input matInput formControlName="transportDeviceTelemetryDataPointsRateLimit">
<input matInput formControlName="transportDeviceTelemetryDataPointsRateLimit"> </mat-form-field>
</mat-form-field>
</section>
</section> </section>

51
ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts

@ -19,11 +19,7 @@ import { ControlValueAccessor, FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Valida
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '@app/core/core.state'; import { AppState } from '@app/core/core.state';
import { coerceBooleanProperty } from '@angular/cdk/coercion'; import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { import { DefaultTenantProfileConfiguration, TenantProfileConfiguration } from '@shared/models/tenant.model';
DefaultTenantProfileConfiguration,
TenantProfileConfiguration,
TenantProfileType
} from '@shared/models/tenant.model';
import { isDefinedAndNotNull } from '@core/utils'; import { isDefinedAndNotNull } from '@core/utils';
@Component({ @Component({
@ -56,6 +52,25 @@ export class DefaultTenantProfileConfigurationComponent implements ControlValueA
constructor(private store: Store<AppState>, constructor(private store: Store<AppState>,
private fb: FormBuilder) { private fb: FormBuilder) {
this.defaultTenantProfileConfigurationFormGroup = this.fb.group({
maxDevices: [null, [Validators.required, Validators.min(0)]],
maxAssets: [null, [Validators.required, Validators.min(0)]],
transportTenantMsgRateLimit: [null, []],
transportTenantTelemetryMsgRateLimit: [null, []],
transportTenantTelemetryDataPointsRateLimit: [null, []],
transportDeviceMsgRateLimit: [null, []],
transportDeviceTelemetryMsgRateLimit: [null, []],
transportDeviceTelemetryDataPointsRateLimit: [null, []],
maxTransportMessages: [null, [Validators.required, Validators.min(0)]],
maxTransportDataPoints: [null, [Validators.required, Validators.min(0)]],
maxREExecutions: [null, [Validators.required, Validators.min(0)]],
maxJSExecutions: [null, [Validators.required, Validators.min(0)]],
maxDPStorageDays: [null, [Validators.required, Validators.min(0)]],
maxRuleNodeExecutionsPerMessage: [null, [Validators.required, Validators.min(0)]]
});
this.defaultTenantProfileConfigurationFormGroup.valueChanges.subscribe(() => {
this.updateModel();
});
} }
registerOnChange(fn: any): void { registerOnChange(fn: any): void {
@ -66,27 +81,6 @@ export class DefaultTenantProfileConfigurationComponent implements ControlValueA
} }
ngOnInit() { ngOnInit() {
this.defaultTenantProfileConfigurationFormGroup = this.fb.group({
configuration: this.fb.group({
maxDevices: [null, [Validators.required, Validators.min(0)]],
maxAssets: [null, [Validators.required, Validators.min(0)]],
transportTenantMsgRateLimit: [null, []],
transportTenantTelemetryMsgRateLimit: [null, []],
transportTenantTelemetryDataPointsRateLimit: [null, []],
transportDeviceMsgRateLimit: [null, []],
transportDeviceTelemetryMsgRateLimit: [null, []],
transportDeviceTelemetryDataPointsRateLimit: [null, []],
maxTransportMessages: [null, [Validators.required, Validators.min(0)]],
maxTransportDataPoints: [null, [Validators.required, Validators.min(0)]],
maxREExecutions: [null, [Validators.required, Validators.min(0)]],
maxJSExecutions: [null, [Validators.required, Validators.min(0)]],
maxDPStorageDays: [null, [Validators.required, Validators.min(0)]],
maxRuleNodeExecutionsPerMessage: [null, [Validators.required, Validators.min(0)]]
})
});
this.defaultTenantProfileConfigurationFormGroup.valueChanges.subscribe(() => {
this.updateModel();
});
} }
setDisabledState(isDisabled: boolean): void { setDisabledState(isDisabled: boolean): void {
@ -100,15 +94,14 @@ export class DefaultTenantProfileConfigurationComponent implements ControlValueA
writeValue(value: DefaultTenantProfileConfiguration | null): void { writeValue(value: DefaultTenantProfileConfiguration | null): void {
if (isDefinedAndNotNull(value)) { if (isDefinedAndNotNull(value)) {
this.defaultTenantProfileConfigurationFormGroup.patchValue({configuration: value}, {emitEvent: false}); this.defaultTenantProfileConfigurationFormGroup.patchValue(value, {emitEvent: false});
} }
} }
private updateModel() { private updateModel() {
let configuration: TenantProfileConfiguration = null; let configuration: TenantProfileConfiguration = null;
if (this.defaultTenantProfileConfigurationFormGroup.valid) { if (this.defaultTenantProfileConfigurationFormGroup.valid) {
configuration = this.defaultTenantProfileConfigurationFormGroup.getRawValue().configuration; configuration = this.defaultTenantProfileConfigurationFormGroup.getRawValue();
configuration.type = TenantProfileType.DEFAULT;
} }
this.propagateChange(configuration); this.propagateChange(configuration);
} }

0
ui-ngx/src/assets/locale/locale.constant-pl_BR.json → ui-ngx/src/assets/locale/locale.constant-pt_BR.json

Loading…
Cancel
Save