Skip to content

Commit

Permalink
show property list of correlator
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-c8y committed Feb 25, 2024
1 parent 82b31eb commit f740b42
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 75 deletions.
20 changes: 16 additions & 4 deletions analytics-ui/src/status/engine-status.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,23 @@ <h3>Safe Mode</h3>


<div class="card-header separator">
<h3>CEP Status </h3>
</div>
<div class="inner-scroll_NOT">
<div class="card-block separator_NOT">
<pre class="m-t-16 inner-scroll small">{{cepCtrlStatus | json}}</pre>
<div class="inner-scroll">
<div class="card-block separator">
<!-- <pre class="m-t-16 inner-scroll small">{{cepCtrlStatus | json}}</pre> -->
<!-- <c8y-properties-list
[title]="'Application properties'"
[data]="archiveManifest"
[emptyLabel]="'--'"
[properties]="packageVersionProperties"
>
</c8y-properties-list> -->
<c8y-properties-list *ngIf="(cepCtrlStatusLabels$ | async).length > 0"
[title]="'CEP Engine Status'"
[emptyLabel]="'--'"
[properties]="cepCtrlStatusLabels$ | async"
>
</c8y-properties-list>
</div>
</div>

Expand Down
93 changes: 22 additions & 71 deletions analytics-ui/src/status/engine-status.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Component, OnInit, Output, ViewEncapsulation } from "@angular/core";
import { AlarmService, AlarmStatus, EventService, IAlarm, IEvent, IResultList } from "@c8y/client";
import { Component, OnInit, ViewEncapsulation } from "@angular/core";
import { BsModalRef } from "ngx-bootstrap/modal";
import { BehaviorSubject, Observable, Subject } from "rxjs";
import { shareReplay, switchMap, tap } from "rxjs/operators";
import { AnalyticsService } from "../shared";
import { HumanizePipe, PropertiesListItem, gettext } from "@c8y/ngx-components";
import { IManifest } from "@c8y/client";
import { BehaviorSubject, Subject } from 'rxjs';

@Component({
selector: "engine-status",
Expand All @@ -12,85 +12,36 @@ import { AnalyticsService } from "../shared";
})
export class EngineStatusComponent implements OnInit {
cepId: string;
@Output() closeSubject: Subject<void> = new Subject();
alarms$: Observable<IResultList<IAlarm>>;
events$: Observable<IResultList<IEvent>>;
nextPageAlarm$: BehaviorSubject<any> = new BehaviorSubject({ direction: 0 });
nextPageEvent$: BehaviorSubject<any> = new BehaviorSubject({ direction: 0 });
currentPageAlarm: number = 1;
currentPageEvent: number = 1;
searchString: string;
status: AlarmStatus;
AlarmStatus = AlarmStatus;
isAlarmExpanded: boolean = true;
isEventExpanded: boolean = false;
cepCtrlStatus: any = {};
cepCtrlStatus$: Subject<any> = new Subject<any> ();
cepCtrlStatusLabels$: BehaviorSubject<PropertiesListItem[]> = new BehaviorSubject<PropertiesListItem[]> ([]);


constructor(
private alarmService: AlarmService,
private eventService: EventService,
private analyticsService: AnalyticsService,
public bsModalRef: BsModalRef
) {}

async ngOnInit(): Promise<void> {
const humanize = new HumanizePipe();

this.init();
this.cepId = await this.analyticsService.getCEP_Id();
this.cepCtrlStatus = await this.analyticsService.getCEP_Status();
let filterAlarm: object = {
pageSize: 5,
source: this.cepId,
currentPage: 1,
withTotalPages: true,
};
let filterEvent: object = {
pageSize: 5,
source: this.cepId,
currentPage: 1,
withTotalPages: true,
};
this.alarms$ = this.nextPageAlarm$.pipe(
tap((options) => {
if (options.direction) {
this.currentPageAlarm = this.currentPageAlarm + options.direction;
if (this.currentPageAlarm < 1) this.currentPageAlarm = 1;
filterAlarm["currentPage"] = this.currentPageAlarm;
}
if (options.status) {
filterAlarm["status"] = options.status;
}
}),
switchMap(() => this.alarmService.list(filterAlarm)),
shareReplay()
);
this.events$ = this.nextPageEvent$.pipe(
tap((options) => {
if (options.direction) {
this.currentPageEvent = this.currentPageEvent + options.direction;
if (this.currentPageEvent < 1) this.currentPageEvent = 1;
filterEvent["currentPage"] = this.currentPageEvent;
}
}),
switchMap(() => this.eventService.list(filterEvent)),
shareReplay()
);
this.nextPageAlarm$.next({ direction: 0 });
this.nextPageEvent$.next({ direction: 0 });
const cepCtrlStatus = await this.analyticsService.getCEP_Status();
const cepCtrlStatusLabels = [];
Object.keys(cepCtrlStatus).forEach (key => {
cepCtrlStatusLabels.push ( {
label: humanize.transform(key),
type: 'string',
value: cepCtrlStatus[key]
})
});
this.cepCtrlStatusLabels$.next(cepCtrlStatusLabels);

console.log("Labels:", cepCtrlStatusLabels);
console.log("Objects:", cepCtrlStatus);
}

private async init() {
this.cepId = await this.analyticsService.getCEP_Id();
}

nextPageAlarm(direction: number) {
this.nextPageAlarm$.next({ direction });
}

nextPageEvent(direction: number) {
this.nextPageEvent$.next({ direction });
}

search() {
this.nextPageAlarm$.next({ status:this.status });
}
}

0 comments on commit f740b42

Please sign in to comment.