Commit cf2da5c9b1302cd98f9a60949228381f0c166a89

Authored by Artem Babak
1 parent 91c4affb

Fixed filter edge by type. Added edge to entity-filer/subtype

@@ -14,11 +14,11 @@ @@ -14,11 +14,11 @@
14 /// limitations under the License. 14 /// limitations under the License.
15 /// 15 ///
16 16
17 -import { Component, forwardRef } from '@angular/core';  
18 -import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';  
19 -import { AliasFilterType, EntityAliasFilter } from '@shared/models/alias.models';  
20 -import { AliasEntityType, EntityType, entityTypeTranslations } from '@shared/models/entity-type.models';  
21 -import { TranslateService } from '@ngx-translate/core'; 17 +import {Component, forwardRef} from '@angular/core';
  18 +import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
  19 +import {AliasFilterType, EntityAliasFilter} from '@shared/models/alias.models';
  20 +import {AliasEntityType, EntityType, entityTypeTranslations} from '@shared/models/entity-type.models';
  21 +import {TranslateService} from '@ngx-translate/core';
22 22
23 @Component({ 23 @Component({
24 selector: 'tb-entity-filter-view', 24 selector: 'tb-entity-filter-view',
@@ -101,6 +101,17 @@ export class EntityFilterViewComponent implements ControlValueAccessor { @@ -101,6 +101,17 @@ export class EntityFilterViewComponent implements ControlValueAccessor {
101 {deviceType}); 101 {deviceType});
102 } 102 }
103 break; 103 break;
  104 + case AliasFilterType.edgeType:
  105 + const edgeType = this.filter.edgeType;
  106 + prefix = this.filter.edgeNameFilter;
  107 + if (prefix && prefix.length) {
  108 + this.filterDisplayValue = this.translate.instant('alias.filter-type-edge-type-and-name-description',
  109 + {edgeType, prefix});
  110 + } else {
  111 + this.filterDisplayValue = this.translate.instant('alias.filter-type-edge-type-description',
  112 + {edgeType});
  113 + }
  114 + break;
104 case AliasFilterType.entityViewType: 115 case AliasFilterType.entityViewType:
105 const entityView = this.filter.entityViewType; 116 const entityView = this.filter.entityViewType;
106 prefix = this.filter.entityViewNameFilter; 117 prefix = this.filter.entityViewNameFilter;
@@ -166,6 +177,7 @@ export class EntityFilterViewComponent implements ControlValueAccessor { @@ -166,6 +177,7 @@ export class EntityFilterViewComponent implements ControlValueAccessor {
166 break; 177 break;
167 case AliasFilterType.assetSearchQuery: 178 case AliasFilterType.assetSearchQuery:
168 case AliasFilterType.deviceSearchQuery: 179 case AliasFilterType.deviceSearchQuery:
  180 + case AliasFilterType.edgeSearchQuery:
169 case AliasFilterType.entityViewSearchQuery: 181 case AliasFilterType.entityViewSearchQuery:
170 allEntitiesText = this.translate.instant('alias.all-entities'); 182 allEntitiesText = this.translate.instant('alias.all-entities');
171 anyRelationText = this.translate.instant('alias.any-relation'); 183 anyRelationText = this.translate.instant('alias.any-relation');
@@ -207,6 +219,16 @@ export class EntityFilterViewComponent implements ControlValueAccessor { @@ -207,6 +219,16 @@ export class EntityFilterViewComponent implements ControlValueAccessor {
207 this.filterDisplayValue = this.translate.instant('alias.filter-type-device-search-query-description', 219 this.filterDisplayValue = this.translate.instant('alias.filter-type-device-search-query-description',
208 translationValues 220 translationValues
209 ); 221 );
  222 + } else if (this.filter.type === AliasFilterType.edgeSearchQuery) {
  223 + const edgeTypesQuoted = [];
  224 + this.filter.edgeTypes.forEach((filterEdgeType) => {
  225 + edgeTypesQuoted.push(`'${filterEdgeType}'`);
  226 + });
  227 + const edgeTypesText = edgeTypesQuoted.join(', ');
  228 + translationValues.edgeTypes = edgeTypesText;
  229 + this.filterDisplayValue = this.translate.instant('alias.filter-type-edge-search-query-description',
  230 + translationValues
  231 + );
210 } else if (this.filter.type === AliasFilterType.entityViewSearchQuery) { 232 } else if (this.filter.type === AliasFilterType.entityViewSearchQuery) {
211 const entityViewTypesQuoted = []; 233 const entityViewTypesQuoted = [];
212 this.filter.entityViewTypes.forEach((filterEntityViewType) => { 234 this.filter.entityViewTypes.forEach((filterEntityViewType) => {
@@ -103,6 +103,16 @@ @@ -103,6 +103,16 @@
103 <input matInput formControlName="entityViewNameFilter"> 103 <input matInput formControlName="entityViewNameFilter">
104 </mat-form-field> 104 </mat-form-field>
105 </ng-template> 105 </ng-template>
  106 + <ng-template [ngSwitchCase]="aliasFilterType.edgeType">
  107 + <tb-entity-subtype-autocomplete required
  108 + formControlName="edgeType"
  109 + [entityType]="entityType.EDGE">
  110 + </tb-entity-subtype-autocomplete>
  111 + <mat-form-field class="mat-block">
  112 + <mat-label translate>edge.name-starts-with</mat-label>
  113 + <input matInput formControlName="edgeNameFilter">
  114 + </mat-form-field>
  115 + </ng-template>
106 <ng-template [ngSwitchCase]="aliasFilterType.relationsQuery"> 116 <ng-template [ngSwitchCase]="aliasFilterType.relationsQuery">
107 <section fxLayout="column" id="relationsQueryFilter"> 117 <section fxLayout="column" id="relationsQueryFilter">
108 <label class="tb-small">{{ 'alias.root-entity' | translate }}</label> 118 <label class="tb-small">{{ 'alias.root-entity' | translate }}</label>
@@ -169,6 +179,7 @@ @@ -169,6 +179,7 @@
169 </ng-template> 179 </ng-template>
170 <ng-template [ngSwitchCase]="entityFilterFormGroup.get('type').value === aliasFilterType.assetSearchQuery || 180 <ng-template [ngSwitchCase]="entityFilterFormGroup.get('type').value === aliasFilterType.assetSearchQuery ||
171 entityFilterFormGroup.get('type').value === aliasFilterType.deviceSearchQuery || 181 entityFilterFormGroup.get('type').value === aliasFilterType.deviceSearchQuery ||
  182 + entityFilterFormGroup.get('type').value === aliasFilterType.edgeSearchQuery ||
172 entityFilterFormGroup.get('type').value === aliasFilterType.entityViewSearchQuery ? 183 entityFilterFormGroup.get('type').value === aliasFilterType.entityViewSearchQuery ?
173 entityFilterFormGroup.get('type').value : ''"> 184 entityFilterFormGroup.get('type').value : ''">
174 <label class="tb-small">{{ 'alias.root-entity' | translate }}</label> 185 <label class="tb-small">{{ 'alias.root-entity' | translate }}</label>
@@ -248,6 +259,14 @@ @@ -248,6 +259,14 @@
248 formControlName="deviceTypes"> 259 formControlName="deviceTypes">
249 </tb-entity-subtype-list> 260 </tb-entity-subtype-list>
250 </ng-template> 261 </ng-template>
  262 + <ng-template [ngSwitchCase]="aliasFilterType.edgeSearchQuery">
  263 + <div class="mat-caption tb-required" style="color: rgba(0,0,0,0.57);" translate>edge.edge-types</div>
  264 + <tb-entity-subtype-list
  265 + required
  266 + [entityType]="entityType.EDGE"
  267 + formControlName="edgeTypes">
  268 + </tb-entity-subtype-list>
  269 + </ng-template>
251 <ng-template [ngSwitchCase]="aliasFilterType.entityViewSearchQuery"> 270 <ng-template [ngSwitchCase]="aliasFilterType.entityViewSearchQuery">
252 <div class="mat-caption tb-required" style="color: rgba(0,0,0,0.57);" translate>entity-view.entity-view-types</div> 271 <div class="mat-caption tb-required" style="color: rgba(0,0,0,0.57);" translate>entity-view.entity-view-types</div>
253 <tb-entity-subtype-list 272 <tb-entity-subtype-list
@@ -141,6 +141,12 @@ export class EntityFilterComponent implements ControlValueAccessor, OnInit { @@ -141,6 +141,12 @@ export class EntityFilterComponent implements ControlValueAccessor, OnInit {
141 deviceNameFilter: [filter ? filter.deviceNameFilter : '', []], 141 deviceNameFilter: [filter ? filter.deviceNameFilter : '', []],
142 }); 142 });
143 break; 143 break;
  144 + case AliasFilterType.edgeType:
  145 + this.filterFormGroup = this.fb.group({
  146 + edgeType: [filter ? filter.edgeType : null, [Validators.required]],
  147 + edgeNameFilter: [filter ? filter.edgeNameFilter : '', []],
  148 + });
  149 + break;
144 case AliasFilterType.entityViewType: 150 case AliasFilterType.entityViewType:
145 this.filterFormGroup = this.fb.group({ 151 this.filterFormGroup = this.fb.group({
146 entityViewType: [filter ? filter.entityViewType : null, [Validators.required]], 152 entityViewType: [filter ? filter.entityViewType : null, [Validators.required]],
@@ -150,6 +156,7 @@ export class EntityFilterComponent implements ControlValueAccessor, OnInit { @@ -150,6 +156,7 @@ export class EntityFilterComponent implements ControlValueAccessor, OnInit {
150 case AliasFilterType.relationsQuery: 156 case AliasFilterType.relationsQuery:
151 case AliasFilterType.assetSearchQuery: 157 case AliasFilterType.assetSearchQuery:
152 case AliasFilterType.deviceSearchQuery: 158 case AliasFilterType.deviceSearchQuery:
  159 + case AliasFilterType.edgeSearchQuery:
153 case AliasFilterType.entityViewSearchQuery: 160 case AliasFilterType.entityViewSearchQuery:
154 this.filterFormGroup = this.fb.group({ 161 this.filterFormGroup = this.fb.group({
155 rootStateEntity: [filter ? filter.rootStateEntity : false, []], 162 rootStateEntity: [filter ? filter.rootStateEntity : false, []],
@@ -176,6 +183,9 @@ export class EntityFilterComponent implements ControlValueAccessor, OnInit { @@ -176,6 +183,9 @@ export class EntityFilterComponent implements ControlValueAccessor, OnInit {
176 } else if (type === AliasFilterType.deviceSearchQuery) { 183 } else if (type === AliasFilterType.deviceSearchQuery) {
177 this.filterFormGroup.addControl('deviceTypes', 184 this.filterFormGroup.addControl('deviceTypes',
178 this.fb.control(filter ? filter.deviceTypes : [], [Validators.required])); 185 this.fb.control(filter ? filter.deviceTypes : [], [Validators.required]));
  186 + } else if (type === AliasFilterType.edgeSearchQuery) {
  187 + this.filterFormGroup.addControl('edgeTypes',
  188 + this.fb.control(filter ? filter.edgeTypes : [], [Validators.required]));
179 } else if (type === AliasFilterType.entityViewSearchQuery) { 189 } else if (type === AliasFilterType.entityViewSearchQuery) {
180 this.filterFormGroup.addControl('entityViewTypes', 190 this.filterFormGroup.addControl('entityViewTypes',
181 this.fb.control(filter ? filter.entityViewTypes : [], [Validators.required])); 191 this.fb.control(filter ? filter.entityViewTypes : [], [Validators.required]));
@@ -103,7 +103,8 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI @@ -103,7 +103,8 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
103 resolve(route: ActivatedRouteSnapshot): Observable<EntityTableConfig<EdgeInfo>> { 103 resolve(route: ActivatedRouteSnapshot): Observable<EntityTableConfig<EdgeInfo>> {
104 const routeParams = route.params; 104 const routeParams = route.params;
105 this.config.componentsData = { 105 this.config.componentsData = {
106 - edgeScope: route.data.edgesType 106 + edgeScope: route.data.edgesType,
  107 + edgeType: ''
107 }; 108 };
108 this.customerId = routeParams.customerId; 109 this.customerId = routeParams.customerId;
109 return this.store.pipe(select(selectAuthUser), take(1)).pipe( 110 return this.store.pipe(select(selectAuthUser), take(1)).pipe(
@@ -161,7 +162,7 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI @@ -161,7 +162,7 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
161 configureEntityFunctions(edgeScope: string): void { 162 configureEntityFunctions(edgeScope: string): void {
162 if (edgeScope === 'tenant') { 163 if (edgeScope === 'tenant') {
163 this.config.entitiesFetchFunction = pageLink => 164 this.config.entitiesFetchFunction = pageLink =>
164 - this.edgeService.getTenantEdgeInfos(pageLink); 165 + this.edgeService.getTenantEdgeInfos(pageLink, this.config.componentsData.edgeType);
165 this.config.deleteEntity = id => this.edgeService.deleteEdge(id.id); 166 this.config.deleteEntity = id => this.edgeService.deleteEdge(id.id);
166 } 167 }
167 if (edgeScope === 'customer') { 168 if (edgeScope === 'customer') {
@@ -143,9 +143,10 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit, @@ -143,9 +143,10 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit,
143 break; 143 break;
144 case EntityType.EDGE: 144 case EntityType.EDGE:
145 this.placeholder = this.required ? this.translate.instant('edge.enter-edge-type') 145 this.placeholder = this.required ? this.translate.instant('edge.enter-edge-type')
146 - : this.translate.instant('edge.edge-any-edge'); 146 + : this.translate.instant('edge.any-edge');
147 this.secondaryPlaceholder = '+' + this.translate.instant('edge.edge-type'); 147 this.secondaryPlaceholder = '+' + this.translate.instant('edge.edge-type');
148 this.noSubtypesMathingText = 'edge.no-edge-types-matching'; 148 this.noSubtypesMathingText = 'edge.no-edge-types-matching';
  149 + this.subtypeListEmptyText = 'edge.edge-type-list-empty';
149 this.broadcastSubscription = this.broadcast.on('edgeSaved', () => { 150 this.broadcastSubscription = this.broadcast.on('edgeSaved', () => {
150 this.entitySubtypes = null; 151 this.entitySubtypes = null;
151 }); 152 });
@@ -33,3 +33,4 @@ export * from './tenant-profile-id'; @@ -33,3 +33,4 @@ export * from './tenant-profile-id';
33 export * from './user-id'; 33 export * from './user-id';
34 export * from './widget-type-id'; 34 export * from './widget-type-id';
35 export * from './widgets-bundle-id'; 35 export * from './widgets-bundle-id';
  36 +export * from './edge-id';
@@ -213,6 +213,7 @@ @@ -213,6 +213,7 @@
213 "filter-type-entity-view-type-and-name-description": "Entity Views of type '{{entityView}}' and with name starting with '{{prefix}}'", 213 "filter-type-entity-view-type-and-name-description": "Entity Views of type '{{entityView}}' and with name starting with '{{prefix}}'",
214 "filter-type-edge-type": "Edge type", 214 "filter-type-edge-type": "Edge type",
215 "filter-type-edge-type-description": "Edges of type '{{edgeType}}'", 215 "filter-type-edge-type-description": "Edges of type '{{edgeType}}'",
  216 + "filter-type-edge-type-and-name-description": "Edges of type '{{edgeType}}' and with name starting with '{{prefix}}'",
216 "filter-type-relations-query": "Relations query", 217 "filter-type-relations-query": "Relations query",
217 "filter-type-relations-query-description": "{{entities}} that have {{relationType}} relation {{direction}} {{rootEntity}}", 218 "filter-type-relations-query-description": "{{entities}} that have {{relationType}} relation {{direction}} {{rootEntity}}",
218 "filter-type-asset-search-query": "Asset search query", 219 "filter-type-asset-search-query": "Asset search query",
@@ -1002,7 +1003,9 @@ @@ -1002,7 +1003,9 @@
1002 "selected-edges": "{ count, plural, 1 {1 edge} other {# edges} } selected", 1003 "selected-edges": "{ count, plural, 1 {1 edge} other {# edges} } selected",
1003 "enter-edge-type": "Enter entity view type", 1004 "enter-edge-type": "Enter entity view type",
1004 "any-edge": "Any edge", 1005 "any-edge": "Any edge",
1005 - "no-edge-types-matching": "No edge types matching '{{entitySubtype}}' were found." 1006 + "no-edge-types-matching": "No edge types matching '{{entitySubtype}}' were found.",
  1007 + "edge-type-list-empty": "No device types selected.",
  1008 + "edge-types": "Edge types"
1006 }, 1009 },
1007 "error": { 1010 "error": {
1008 "unable-to-connect": "Unable to connect to the server! Please check your internet connection.", 1011 "unable-to-connect": "Unable to connect to the server! Please check your internet connection.",