Skip to content

Commit

Permalink
added type for filter parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-c8y committed Sep 30, 2024
1 parent 65d2bc5 commit b196580
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<select
class="form-control"
style="width: 180px"
[(ngModel)]="filterStatusLog.eventType"
name="eventType"
[(ngModel)]="filterStatusLog.type"
name="type"
>
<option [value]="'ALL'">ALL types</option>
<option [value]="StatusEventTypes.STATUS_CONNECTOR_EVENT_TYPE">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ export class ConnectorStatusComponent implements OnInit {
specifications: ConnectorSpecification[] = [];
configurations$: Observable<ConnectorConfiguration[]> = new Observable();
statusLogs$: Observable<any[]>;
statusLogs: any[] = [];
private readonly ALL: string = 'ALL';
filterStatusLog = {
// eventType: StatusEventTypes.STATUS_CONNECTOR_EVENT_TYPE,
eventType: 'ALL',
connectorIdent: 'ALL'
connectorIdent: this.ALL,
connectorName: 'EMPTY',
status: ConnectorStatus.UNKNOWN,
type: StatusEventTypes.ALL,
message: '_RESET_'
};
StatusEventTypes = StatusEventTypes;

Expand All @@ -65,7 +67,6 @@ export class ConnectorStatusComponent implements OnInit {
async ngOnInit() {
// console.log('Running version', this.version);
this.feature = await this.sharedService.getFeatures();
await this.connectorStatusService.startConnectorStatusLogs();
this.configurations$ =
this.connectorConfigurationService.getConnectorConfigurationsWithLiveStatus();
this.statusLogs$ = this.connectorStatusService.getStatusLogs();
Expand Down
31 changes: 17 additions & 14 deletions dynamic-mapping-ui/src/shared/connector-status.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
StatusEventTypes
} from '../shared';

import { BehaviorSubject, from, merge, Observable, Subscription } from 'rxjs';
import { BehaviorSubject, from, merge, Observable } from 'rxjs';
import { filter, map, scan, shareReplay, switchMap, tap } from 'rxjs/operators';
import {
EventRealtimeService,
Expand All @@ -47,24 +47,23 @@ export class ConnectorStatusService {
this.eventRealtimeService = new EventRealtimeService(
inject(RealtimeSubjectService)
);
this.startConnectorStatusLogs();
}
private eventRealtimeService: EventRealtimeService;

private _agentId: string;
private readonly ALL = 'ALL';
private readonly ALL: string = 'ALL';

private filterStatusLog = {
eventType: this.ALL,
connectorIdent: this.ALL
};
private readonly RESET = {
connectorIdent: 'EMPTY',
connectorIdent: this.ALL,
connectorName: 'EMPTY',
status: ConnectorStatus.UNKNOWN,
type: StatusEventTypes.ALL,
message: '_RESET_'
};

private filterStatusLog = this.RESET;

private triggerLogs$: BehaviorSubject<ConnectorStatusEvent[]> =
new BehaviorSubject([this.RESET]);

Expand All @@ -83,8 +82,12 @@ export class ConnectorStatusService {
}

updateStatusLogs(filter: any) {
this.triggerLogs$.next([this.RESET]);
this.filterStatusLog = filter;
const updatedFilter = {
...this.RESET,
...filter
};
this.filterStatusLog = updatedFilter;
this.triggerLogs$.next([updatedFilter]);
}

async initConnectorLogsRealtime() {
Expand All @@ -97,14 +100,14 @@ export class ConnectorStatusService {
// );
const filteredConnectorStatus$ = this.triggerLogs$.pipe(
tap((x) => console.log('TriggerLogs In', x)),
switchMap(() => {
switchMap((x) => {
const filter = {
pageSize: 5,
withTotalPages: false,
source: this._agentId
};
if (this.filterStatusLog.eventType !== this.ALL) {
filter['type'] = this.filterStatusLog.eventType;
if (x[0]?.type !== this.ALL) {
filter['type'] = x[0]?.type;
}
return this.eventService.list(filter);
}),
Expand Down Expand Up @@ -164,9 +167,9 @@ export class ConnectorStatusService {
return e[CONNECTOR_FRAGMENT];
}),
filter((e) =>
this.filterStatusLog.eventType == this.ALL
this.filterStatusLog.type == this.ALL
? true
: e['type'] == this.filterStatusLog.eventType
: e['type'] == this.filterStatusLog.type
),
filter((e) =>
this.filterStatusLog.connectorIdent == this.ALL
Expand Down

0 comments on commit b196580

Please sign in to comment.