Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#877] apply formatting and linting to pipelines module #1054

Merged
merged 2 commits into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ui/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ src/app/login
src/app/notifications
src/app/NS
src/app/pipeline-details
src/app/pipelines
src/scss
1 change: 0 additions & 1 deletion ui/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ src/app/login
src/app/notifications
src/app/NS
src/app/pipeline-details
src/app/pipelines
src/scss
18 changes: 10 additions & 8 deletions ui/src/app/pipelines/category-already-in-pipeline.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ import { Pipe, PipeTransform } from '@angular/core';
import { Pipeline } from '@streampipes/platform-services';

@Pipe({
name: 'categoryAlreadyInPipelineFilter',
pure: false
name: 'categoryAlreadyInPipelineFilter',
pure: false,
})
export class CategoryAlreadyInPipelinePipe implements PipeTransform {

transform(pipelines: Pipeline[], categoryId: string): any {
return pipelines.filter(pipeline => {
return !pipeline.pipelineCategories || !(pipeline.pipelineCategories.some(pc => pc === categoryId));
});
}
transform(pipelines: Pipeline[], categoryId: string): any {
return pipelines.filter(pipeline => {
return (
!pipeline.pipelineCategories ||
!pipeline.pipelineCategories.some(pc => pc === categoryId)
);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

import { ActivatedRoute } from '@angular/router';
import {
AdapterMonitoringService,
FunctionDefinition,
FunctionsService,
PipelineElementService,
SpDataStream
AdapterMonitoringService,
FunctionDefinition,
FunctionsService,
PipelineElementService,
SpDataStream,
} from '@streampipes/platform-services';
import { Directive } from '@angular/core';
import { Observable, zip } from 'rxjs';
Expand All @@ -31,57 +31,77 @@ import { SpPipelineRoutes } from '../../pipelines.routes';

@Directive()
export abstract class AbstractFunctionDetailsDirective {
public activeFunction: FunctionDefinition;

public activeFunction: FunctionDefinition;
contentReady = false;
tabs = [];
streamNames: Record<string, string> = {};

contentReady = false;
tabs = [];
streamNames: Record<string, string> = {};
constructor(
private route: ActivatedRoute,
protected functionsService: FunctionsService,
private pipelineElementService: PipelineElementService,
private adapterMonitoringService: AdapterMonitoringService,
private breadcrumbService: SpBreadcrumbService,
) {}

constructor(private route: ActivatedRoute,
protected functionsService: FunctionsService,
private pipelineElementService: PipelineElementService,
private adapterMonitoringService: AdapterMonitoringService,
private breadcrumbService: SpBreadcrumbService) {
}
onInit() {
const functionId = this.route.snapshot.params.functionId;
this.breadcrumbService.updateBreadcrumb([
SpPipelineRoutes.BASE,
{ label: functionId },
{ label: this.getBreadcrumbLabel() },
]);
this.tabs = [
{
itemId: 'metrics',
itemTitle: 'Metrics',
itemLink: ['pipelines', 'functions', functionId, 'metrics'],
},
{
itemId: 'logs',
itemTitle: 'Logs',
itemLink: ['pipelines', 'functions', functionId, 'logs'],
},
];
this.loadFunctions(functionId);
}

onInit() {
const functionId = this.route.snapshot.params.functionId;
this.breadcrumbService.updateBreadcrumb([SpPipelineRoutes.BASE, {label: functionId}, {label: this.getBreadcrumbLabel()}]);
this.tabs = [
{itemId: 'metrics', itemTitle: 'Metrics', itemLink: ['pipelines', 'functions', functionId, 'metrics']},
{itemId: 'logs', itemTitle: 'Logs', itemLink: ['pipelines', 'functions', functionId, 'logs']}
]
this.loadFunctions(functionId);
}
loadFunctions(functionId: string) {
this.functionsService.getActiveFunctions().subscribe(functions => {
this.activeFunction = functions.find(
f => f.functionId.id === functionId,
);
this.loadStreams(this.activeFunction.consumedStreams);
});
}

loadFunctions(functionId: string) {
this.functionsService.getActiveFunctions().subscribe(functions => {
this.activeFunction = functions.find(f => f.functionId.id === functionId);
this.loadStreams(this.activeFunction.consumedStreams);
})
}
loadStreams(relatedStreams: string[]) {
this.streamNames = {};
const observables = this.getStreamObservables(relatedStreams);
zip(...observables).subscribe(streams => {
streams.forEach(
stream => (this.streamNames[stream.elementId] = stream.name),
);
this.afterFunctionLoaded();
});
}

loadStreams(relatedStreams: string[]) {
this.streamNames = {};
const observables = this.getStreamObservables(relatedStreams);
zip(...observables).subscribe(streams => {
streams.forEach(stream => this.streamNames[stream.elementId] = stream.name);
this.afterFunctionLoaded();
})
}
getStreamObservables(relatedStreams: string[]): Observable<SpDataStream>[] {
return relatedStreams.map(s =>
this.pipelineElementService.getDataStreamByElementId(s),
);
}

getStreamObservables(relatedStreams: string[]): Observable<SpDataStream>[] {
return relatedStreams.map(s => this.pipelineElementService.getDataStreamByElementId(s));
}
triggerUpdate() {
this.adapterMonitoringService
.triggerMonitoringUpdate()
.subscribe(() => {
this.afterFunctionLoaded();
});
}

triggerUpdate() {
this.adapterMonitoringService.triggerMonitoringUpdate().subscribe(() => {
this.afterFunctionLoaded();
});
}
abstract afterFunctionLoaded(): void;

abstract afterFunctionLoaded(): void;

abstract getBreadcrumbLabel(): string;
abstract getBreadcrumbLabel(): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,31 @@
~
-->

<sp-basic-nav-tabs [spNavigationItems]="tabs"
[activeLink]="'logs'"
[showBackLink]="true"
[backLinkTarget]="['pipelines']">
<div nav fxFlex="100" fxLayout="row" fxLayoutAlign="end center">
<button mat-button
<sp-basic-nav-tabs
[spNavigationItems]="tabs"
[activeLink]="'logs'"
[showBackLink]="true"
[backLinkTarget]="['pipelines']"
>
<div nav fxFlex="100" fxLayout="row" fxLayoutAlign="end center">
<button
mat-button
mat-icon-button
color="accent"
class="mr-10"
matTooltip="Refresh"
(click)="triggerUpdate()">
<i class="material-icons">refresh</i>
</button>
</div>
<div fxFlex="100" fxLayout="column" *ngIf="activeFunction && contentReady">
<sp-simple-logs [elementName]="activeFunction.functionId.id" [logs]="logs"
fxFlex="100"
fxLayout="column">
</sp-simple-logs>
</div>


(click)="triggerUpdate()"
>
<i class="material-icons">refresh</i>
</button>
</div>
<div fxFlex="100" fxLayout="column" *ngIf="activeFunction && contentReady">
<sp-simple-logs
[elementName]="activeFunction.functionId.id"
[logs]="logs"
fxFlex="100"
fxLayout="column"
>
</sp-simple-logs>
</div>
</sp-basic-nav-tabs>
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,34 @@ import { AbstractFunctionDetailsDirective } from '../abstract-function-details.d
import { SpLogEntry } from '@streampipes/platform-services';

@Component({
selector: 'sp-functions-logs',
templateUrl: './functions-logs.component.html',
styleUrls: []
selector: 'sp-functions-logs',
templateUrl: './functions-logs.component.html',
styleUrls: [],
})
export class SpFunctionsLogsComponent extends AbstractFunctionDetailsDirective implements OnInit {

logs: SpLogEntry[] = [];

ngOnInit(): void {
super.onInit();
}

afterFunctionLoaded(): void {
this.loadLogs();
}

loadLogs(): void {
this.functionsService.getFunctionLogs(this.activeFunction.functionId.id).subscribe(logs => {
this.logs = logs;
this.contentReady = true;
});
}

getBreadcrumbLabel(): string {
return 'Logs';
}

export class SpFunctionsLogsComponent
extends AbstractFunctionDetailsDirective
implements OnInit
{
logs: SpLogEntry[] = [];

ngOnInit(): void {
super.onInit();
}

afterFunctionLoaded(): void {
this.loadLogs();
}

loadLogs(): void {
this.functionsService
.getFunctionLogs(this.activeFunction.functionId.id)
.subscribe(logs => {
this.logs = logs;
this.contentReady = true;
});
}

getBreadcrumbLabel(): string {
return 'Logs';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,34 @@
~
-->

<sp-basic-nav-tabs [spNavigationItems]="tabs"
[activeLink]="'metrics'"
[showBackLink]="true"
[backLinkTarget]="['pipelines']">
<div nav fxFlex="100" fxLayout="row" fxLayoutAlign="end center">
<button mat-button
<sp-basic-nav-tabs
[spNavigationItems]="tabs"
[activeLink]="'metrics'"
[showBackLink]="true"
[backLinkTarget]="['pipelines']"
>
<div nav fxFlex="100" fxLayout="row" fxLayoutAlign="end center">
<button
mat-button
mat-icon-button
color="accent"
class="mr-10"
matTooltip="Refresh"
(click)="triggerUpdate()">
<i class="material-icons">refresh</i>
</button>
</div>
<div fxFlex="100" fxLayout="column" *ngIf="activeFunction && contentReady">
<div *ngFor="let messagesIn of metrics.messagesIn | keyvalue">
<sp-simple-metrics [elementName]="streamNames[messagesIn.key]"
lastPublishedLabel="Last consumed message"
statusValueLabel="Consumed messages"
[lastTimestamp]="messagesIn.value.lastTimestamp"
[statusValue]="messagesIn.value.counter">
</sp-simple-metrics>
(click)="triggerUpdate()"
>
<i class="material-icons">refresh</i>
</button>
</div>
<div fxFlex="100" fxLayout="column" *ngIf="activeFunction && contentReady">
<div *ngFor="let messagesIn of metrics.messagesIn | keyvalue">
<sp-simple-metrics
[elementName]="streamNames[messagesIn.key]"
lastPublishedLabel="Last consumed message"
statusValueLabel="Consumed messages"
[lastTimestamp]="messagesIn.value.lastTimestamp"
[statusValue]="messagesIn.value.counter"
>
</sp-simple-metrics>
</div>
</div>
</div>


</sp-basic-nav-tabs>
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,34 @@ import { AbstractFunctionDetailsDirective } from '../abstract-function-details.d
import { SpMetricsEntry } from '@streampipes/platform-services';

@Component({
selector: 'sp-functions-metrics',
templateUrl: './functions-metrics.component.html',
styleUrls: []
selector: 'sp-functions-metrics',
templateUrl: './functions-metrics.component.html',
styleUrls: [],
})
export class SpFunctionsMetricsComponent extends AbstractFunctionDetailsDirective implements OnInit {
export class SpFunctionsMetricsComponent
extends AbstractFunctionDetailsDirective
implements OnInit
{
metrics: SpMetricsEntry;

metrics: SpMetricsEntry;
ngOnInit(): void {
super.onInit();
}

ngOnInit(): void {
super.onInit();
}
afterFunctionLoaded(): void {
this.loadMetrics();
}

afterFunctionLoaded(): void {
this.loadMetrics();
}
loadMetrics() {
this.functionsService
.getFunctionMetrics(this.activeFunction.functionId.id)
.subscribe(metrics => {
this.metrics = metrics;
this.contentReady = true;
});
}

loadMetrics() {
this.functionsService.getFunctionMetrics(this.activeFunction.functionId.id).subscribe(metrics => {
this.metrics = metrics;
this.contentReady = true;
})
}

getBreadcrumbLabel(): string {
return 'Metrics';
}
getBreadcrumbLabel(): string {
return 'Metrics';
}
}
Loading