Browse Source

UI: refactoring

pull/10928/head
Artem Dzhereleiko 2 years ago
parent
commit
ef2dc38325
  1. 7
      ui-ngx/src/app/core/http/entity.service.ts
  2. 1
      ui-ngx/src/app/core/http/queue.service.ts
  3. 14
      ui-ngx/src/app/modules/home/components/entity/entity-filter.component.html
  4. 7
      ui-ngx/src/app/modules/home/components/entity/entity-filter.component.ts
  5. 1
      ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts
  6. 9
      ui-ngx/src/app/shared/components/entity/entity-list.component.ts
  7. 1
      ui-ngx/src/app/shared/components/entity/entity-select.component.html
  8. 5
      ui-ngx/src/app/shared/components/entity/entity-select.component.ts
  9. 7
      ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts

7
ui-ngx/src/app/core/http/entity.service.ts

@ -709,7 +709,7 @@ export class EntityService {
}
public prepareAllowedEntityTypesList(allowedEntityTypes: Array<EntityType | AliasEntityType>,
useAliasEntityTypes?: boolean, addQueueStats = false): Array<EntityType | AliasEntityType> {
useAliasEntityTypes?: boolean): Array<EntityType | AliasEntityType> {
const authState = getCurrentAuthState(this.store);
const entityTypes: Array<EntityType | AliasEntityType> = [];
switch (authState.authUser.authority) {
@ -724,13 +724,12 @@ export class EntityService {
entityTypes.push(EntityType.CUSTOMER);
entityTypes.push(EntityType.USER);
entityTypes.push(EntityType.DASHBOARD);
if (addQueueStats) {
entityTypes.push(EntityType.QUEUE_STATS);
}
if (authState.edgesSupportEnabled) {
entityTypes.push(EntityType.EDGE);
}
if (useAliasEntityTypes) {
entityTypes.push(EntityType.QUEUE_STATS);
entityTypes.push(AliasEntityType.CURRENT_CUSTOMER);
entityTypes.push(AliasEntityType.CURRENT_TENANT);
}

1
ui-ngx/src/app/core/http/queue.service.ts

@ -21,7 +21,6 @@ import { Observable } from 'rxjs';
import { QueueInfo, QueueStatisticsInfo, ServiceType } from '@shared/models/queue.models';
import { PageLink } from '@shared/models/page/page-link';
import { PageData } from '@shared/models/page/page-data';
import { Asset } from '@shared/models/asset.models';
import { map } from 'rxjs/operators';
@Injectable({

14
ui-ngx/src/app/modules/home/components/entity/entity-filter.component.html

@ -29,7 +29,7 @@
</mat-form-field>
<section fxLayout="column" [formGroup]="filterFormGroup" [ngSwitch]="entityFilterFormGroup.get('type').value">
<ng-template [ngSwitchCase]="aliasFilterType.singleEntity">
<tb-entity-select required addQueueStats
<tb-entity-select required
useAliasEntityTypes="true"
formControlName="singleEntity">
</tb-entity-select>
@ -37,8 +37,8 @@
<ng-template [ngSwitchCase]="aliasFilterType.entityList">
<tb-entity-type-select required
showLabel
addQueueStats
[allowedEntityTypes]="allowedEntityTypes"
useAliasEntityTypes="true"
[allowedEntityTypes]="listEntityTypes"
formControlName="entityType">
</tb-entity-type-select>
<tb-entity-list required
@ -50,8 +50,8 @@
<ng-template [ngSwitchCase]="aliasFilterType.entityName">
<tb-entity-type-select required
showLabel
addQueueStats
[allowedEntityTypes]="allowedEntityTypes"
useAliasEntityTypes="true"
[allowedEntityTypes]="listEntityTypes"
formControlName="entityType">
</tb-entity-type-select>
<mat-form-field class="mat-block">
@ -67,8 +67,8 @@
<ng-template [ngSwitchCase]="aliasFilterType.entityType">
<tb-entity-type-select required
showLabel
addQueueStats
[allowedEntityTypes]="allowedEntityTypes"
useAliasEntityTypes="true"
[allowedEntityTypes]="listEntityTypes"
formControlName="entityType">
</tb-entity-type-select>
</ng-template>

7
ui-ngx/src/app/modules/home/components/entity/entity-filter.component.ts

@ -50,6 +50,8 @@ export class EntityFilterComponent implements ControlValueAccessor, OnInit, OnDe
aliasFilterTypes: Array<AliasFilterType>;
listEntityTypes: Array<EntityType | AliasEntityType>;
aliasFilterType = AliasFilterType;
aliasFilterTypeTranslations = aliasFilterTypeTranslationMap;
entityType = EntityType;
@ -71,6 +73,11 @@ export class EntityFilterComponent implements ControlValueAccessor, OnInit, OnDe
this.aliasFilterTypes = this.entityService.getAliasFilterTypesByEntityTypes(this.allowedEntityTypes);
this.listEntityTypes = this.entityService.prepareAllowedEntityTypesList(this.allowedEntityTypes, false);
if (!this.allowedEntityTypes?.length || this.allowedEntityTypes.includes(EntityType.QUEUE_STATS)) {
this.listEntityTypes.push(EntityType.QUEUE_STATS);
}
this.entityFilterFormGroup = this.fb.group({
type: [null, [Validators.required]]
});

1
ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts

@ -40,7 +40,6 @@ import { getCurrentAuthUser } from '@core/auth/auth.selectors';
import { Authority } from '@shared/models/authority.enum';
import { getEntityDetailsPageURL, isDefinedAndNotNull, isEqual } from '@core/utils';
import { coerceBoolean } from '@shared/decorators/coercion';
import { QueueStatisticsInfo } from '@shared/models/queue.models';
@Component({
selector: 'tb-entity-autocomplete',

9
ui-ngx/src/app/shared/components/entity/entity-list.component.ts

@ -25,13 +25,7 @@ import {
SimpleChanges,
ViewChild
} from '@angular/core';
import {
ControlValueAccessor,
NG_VALUE_ACCESSOR,
UntypedFormBuilder,
UntypedFormGroup,
Validators
} from '@angular/forms';
import { ControlValueAccessor, UntypedFormBuilder, UntypedFormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
import { Observable } from 'rxjs';
import { filter, map, mergeMap, share, tap } from 'rxjs/operators';
import { Store } from '@ngrx/store';
@ -45,7 +39,6 @@ import { MatAutocomplete } from '@angular/material/autocomplete';
import { MatChipGrid } from '@angular/material/chips';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { SubscriptSizing } from '@angular/material/form-field';
import { QueueStatisticsInfo } from '@shared/models/queue.models';
@Component({
selector: 'tb-entity-list',

1
ui-ngx/src/app/shared/components/entity/entity-select.component.html

@ -22,7 +22,6 @@
[required]="required"
[useAliasEntityTypes]="useAliasEntityTypes"
[allowedEntityTypes]="allowedEntityTypes"
[addQueueStats]="addQueueStats"
formControlName="entityType">
</tb-entity-type-select>
<tb-entity-autocomplete

5
ui-ngx/src/app/shared/components/entity/entity-select.component.ts

@ -24,7 +24,6 @@ import { EntityService } from '@core/http/entity.service';
import { EntityId } from '@shared/models/id/entity-id';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { NULL_UUID } from '@shared/models/id/has-uuid';
import { coerceBoolean } from '@shared/decorators/coercion';
@Component({
selector: 'tb-entity-select',
@ -60,10 +59,6 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte
@Input()
disabled: boolean;
@Input()
@coerceBoolean()
addQueueStats = false;
displayEntityTypeSelect: boolean;
AliasEntityType = AliasEntityType;

7
ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts

@ -22,7 +22,6 @@ import { TranslateService } from '@ngx-translate/core';
import { AliasEntityType, EntityType, entityTypeTranslations } from '@app/shared/models/entity-type.models';
import { EntityService } from '@core/http/entity.service';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { coerceBoolean } from '@shared/decorators/coercion';
@Component({
selector: 'tb-entity-type-select',
@ -49,10 +48,6 @@ export class EntityTypeSelectComponent implements ControlValueAccessor, OnInit,
@Input()
filterAllowedEntityTypes = true;
@Input()
@coerceBoolean()
addQueueStats = false;
private showLabelValue: boolean;
get showLabel(): boolean {
return this.showLabelValue;
@ -96,7 +91,7 @@ export class EntityTypeSelectComponent implements ControlValueAccessor, OnInit,
ngOnInit() {
this.entityTypes = this.filterAllowedEntityTypes ?
this.entityService.prepareAllowedEntityTypesList(this.allowedEntityTypes, this.useAliasEntityTypes, this.addQueueStats) :
this.entityService.prepareAllowedEntityTypesList(this.allowedEntityTypes, this.useAliasEntityTypes) :
this.allowedEntityTypes;
this.entityTypeFormGroup.get('entityType').valueChanges.subscribe(
(value) => {

Loading…
Cancel
Save