-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Douglas Lima
committed
Jun 1, 2021
1 parent
548154b
commit 90b73a7
Showing
28 changed files
with
496 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/KafkaFlow.Admin.Dashboard/AngularFiles/src/app/callback.pipe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { PipeTransform, Pipe } from '@angular/core'; | ||
|
||
@Pipe({ | ||
name: 'callback', | ||
pure: false | ||
}) | ||
export class CallbackPipe implements PipeTransform { | ||
transform(items: any[], callback: (item: any) => boolean): any { | ||
if (!items || !callback) { | ||
return items; | ||
} | ||
return items.filter(item => callback(item)); | ||
} | ||
} |
145 changes: 79 additions & 66 deletions
145
src/KafkaFlow.Admin.Dashboard/AngularFiles/src/app/consumer/consumer.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,84 @@ | ||
<ngb-alert #successAlert *ngIf="successMessage" type="success" (closed)="successMessage=''"> | ||
<div class="text-center"><b>Success! </b> <span class="text-center">{{ successMessage}}</span></div> | ||
<div class="text-center"><b>Success! </b> <span class="text-center">{{successMessage}}</span></div> | ||
</ngb-alert> | ||
<div class="container" *ngFor="let group of groups | slice: 1 : groups.length"> | ||
<div class="card my-3"> | ||
<div class="card-body"> | ||
<h3>Group Id: {{ group.groupId }}</h3> | ||
<div *ngFor="let consumer of group.consumers"> | ||
<h4>Consumer: {{ consumer.consumerName }}</h4> | ||
<h4>Status: <span [ngClass]="{ | ||
'text-success': consumer.flowStatus == 'Running', | ||
'text-warning': consumer.flowStatus == 'Paused', | ||
'text-danger': consumer.flowStatus == 'NotRunning' | ||
}">{{consumer.flowStatus}}</span></h4> | ||
<h4>Lag: 55</h4> | ||
<h4>Workers: {{consumer.workersCount}}</h4> | ||
<div class="mt-3 mb-3"> | ||
<button class="btn btn-outline-success" type="button" (click)="openResumeModal(group.groupId, consumer.consumerName)" *ngIf="consumer.flowStatus == 'Paused'">Resume</button> | ||
<button class="btn btn-outline-warning ml-2" type="button" (click)="openPauseModal(group.groupId, consumer.consumerName)" *ngIf="consumer.flowStatus == 'Running'">Pause</button> | ||
<button class="btn btn-outline-danger ml-2" type="button" (click)="openRestartModal(group.groupId, consumer.consumerName)">Restart</button> | ||
<button class="btn btn-outline-info ml-2" type="button" (click)="openRewindModal(group.groupId, consumer.consumerName)">Rewind Offset</button> | ||
<button class="btn btn-outline-secondary ml-2" type="button" (click)="openResetModal(group.groupId, consumer.consumerName)">Reset Offset</button> | ||
<button class="btn btn-outline-success ml-2" type="button" (click)="openWorkersCountModal(group.groupId, consumer.consumerName, consumer.workersCount)">Update number of workers</button> | ||
</div> | ||
<ng-template let-partitionAssignment ngFor [ngForOf]="consumer.partitionAssignments"> | ||
<p class="mb-0 font-weight-bold">Topic: {{partitionAssignment.topic}}</p> | ||
<table class="table table-striped table-hover mt-1"> | ||
<thead> | ||
<tr> | ||
<th>Hostname</th> | ||
<th>Partitions</th> | ||
<th>Lag</th> | ||
<th>Status</th> | ||
<th>Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<ng-template [ngIf]="partitionAssignment.pausedPartitions && partitionAssignment.pausedPartitions.length > 0"> | ||
<tr> | ||
<td class="text-left">{{partitionAssignment.hostName}}</td> | ||
<td class="text-left">{{partitionAssignment.pausedPartitions}}</td> | ||
<td class="text-left">0</td> | ||
<td class="text-left"><span class="font-weight-bold text-warning">Paused</span></td> | ||
<td class="text-left"> | ||
<button class="btn btn-sm btn-success" type="button">Resume</button> | ||
<button class="btn btn-sm btn-info ml-1" type="button">Rewind Offset</button> | ||
<button class="btn btn-sm btn-secondary ml-1" type="button">Reset Offset</button> | ||
</td> | ||
</tr> | ||
</ng-template> | ||
<ng-template [ngIf]="partitionAssignment.runningPartitions?.length > 0"> | ||
<tr> | ||
<td class="text-left">{{partitionAssignment.hostName}}</td> | ||
<td class="text-left">{{partitionAssignment.runningPartitions}}</td> | ||
<td class="text-left">0</td> | ||
<td class="text-left"><span class="font-weight-bold text-success">Running</span></td> | ||
<td class="text-left"> | ||
<button class="btn btn-sm btn-warning" type="button">Pause</button> | ||
<button class="btn btn-sm btn-info ml-1" type="button">Rewind Offset</button> | ||
<button class="btn btn-sm btn-secondary ml-1" type="button">Reset Offset</button> | ||
</td> | ||
</tr> | ||
</ng-template> | ||
</tbody> | ||
</table> | ||
</ng-template> | ||
<hr /> | ||
</div> | ||
<div class="container" *ngFor="let group of groups | callback: removeReadonly"> | ||
<div class="card my-3"> | ||
<div class="card-body"> | ||
<h3>Group Id: {{ group.groupId }}</h3> | ||
<div *ngFor="let consumer of group.consumers"> | ||
<h4>Consumer: {{ consumer.consumerName }}</h4> | ||
<h4>Status: <span [ngClass]="{ | ||
'text-success': consumer.status == 'Running', | ||
'text-warning': consumer.status == 'Paused', | ||
'text-danger': consumer.status == 'Not Running' | ||
}">{{consumer.status}}</span></h4> | ||
<!-- <h4>Lag: 55</h4> --> | ||
<h4>Workers: {{consumer.workersCount}}</h4> | ||
<div class="mt-3 mb-3"> | ||
<button class="btn btn-outline-success" type="button" (click)="openResumeModal(group.groupId, consumer.consumerName)" *ngIf="consumer.status == 'Paused'">Resume</button> | ||
<button class="btn btn-outline-warning ml-2" type="button" (click)="openPauseModal(group.groupId, consumer.consumerName)" *ngIf="consumer.status == 'Running'">Pause</button> | ||
<button class="btn btn-outline-danger ml-2" type="button" (click)="openRestartModal(group.groupId, consumer.consumerName)">Restart</button> | ||
<button class="btn btn-outline-info ml-2" type="button" (click)="openRewindModal(group.groupId, consumer.consumerName)">Rewind Offset</button> | ||
<button class="btn btn-outline-secondary ml-2" type="button" (click)="openResetModal(group.groupId, consumer.consumerName)">Reset Offset</button> | ||
<button class="btn btn-outline-success ml-2" type="button" (click)="openWorkersCountModal(group.groupId, consumer.consumerName, consumer.workersCount)">Update number of workers</button> | ||
</div> | ||
<ng-template let-partitionAssignments ngFor [ngForOf]="consumer.partitionAssignments | groupBy:'topic'"> | ||
<p class="mb-0 font-weight-bold">Topic: {{partitionAssignments.key}}</p> | ||
<table class="table table-striped table-hover mt-1"> | ||
<thead> | ||
<tr> | ||
<th>Hostname - consumer instance</th> | ||
<th>Partitions</th> | ||
<!--<th>Lag</th>--> | ||
<th>Status</th> | ||
<th>LastUpdate</th> | ||
<!--<th>Actions</th>--> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<ng-template let-partitionAssignment ngFor [ngForOf]="partitionAssignments.value | sort:'hostName'"> | ||
<ng-template [ngIf]="partitionAssignment.pausedPartitions?.length > 0"> | ||
<tr> | ||
<td class="text-left">{{partitionAssignment.hostName}}</td> | ||
<td class="text-left">{{partitionAssignment.pausedPartitions}}</td> | ||
<!--<td class="text-left">0</td>--> | ||
<td class="text-left"> | ||
<div *ngIf="partitionAssignment.isLost;then consumer_lost else consumer_on"></div> | ||
<ng-template #consumer_lost><span>-</span></ng-template> | ||
<ng-template #consumer_on><span class="font-weight-bold text-warning">Paused</span></ng-template> | ||
</td> | ||
<td class="text-left"><span [ngClass]="partitionAssignment.isLost ? 'text-secondary' : 'text-success'">{{partitionAssignment.lastUpdate | date: "medium"}}</span></td> | ||
<!--<td class="text-left"> | ||
<button class="btn btn-sm btn-success" *ngIf="!partitionAssignment.isLost" type="button" disabled>Resume</button> | ||
<button class="btn btn-sm btn-info ml-1" *ngIf="!partitionAssignment.isLost" type="button" disabled>Rewind</button> | ||
<button class="btn btn-sm btn-secondary ml-1" *ngIf="!partitionAssignment.isLost" type="button" disabled>Reset</button> | ||
</td>--> | ||
</tr> | ||
</ng-template> | ||
<ng-template [ngIf]="partitionAssignment.runningPartitions?.length > 0"> | ||
<tr> | ||
<td class="text-left">{{partitionAssignment.hostName}}</td> | ||
<td class="text-left">{{partitionAssignment.runningPartitions}}</td> | ||
<!--<td class="text-left">0</td>--> | ||
<td class="text-left"> | ||
<div *ngIf="partitionAssignment.isLost;then consumer_lost else consumer_on"></div> | ||
<ng-template #consumer_lost><span>-</span></ng-template> | ||
<ng-template #consumer_on><span class="font-weight-bold text-success">Running</span></ng-template> | ||
</td> | ||
<td class="text-left"><span [ngClass]="partitionAssignment.isLost ? 'text-secondary' : 'text-success'">{{partitionAssignment.lastUpdate | date: "medium"}}</span></td> | ||
<!--<td class="text-left"> | ||
<button class="btn btn-sm btn-warning" type="button" *ngIf="!partitionAssignment.isLost" disabled>Pause</button> | ||
<button class="btn btn-sm btn-info ml-1" type="button" *ngIf="!partitionAssignment.isLost" disabled>Rewind</button> | ||
<button class="btn btn-sm btn-secondary ml-1" type="button" *ngIf="!partitionAssignment.isLost" disabled>Reset</button> | ||
</td>--> | ||
</tr> | ||
</ng-template> | ||
</ng-template> | ||
</tbody> | ||
</table> | ||
</ng-template> | ||
<hr /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/KafkaFlow.Admin.Dashboard/AngularFiles/src/app/group-by.pipe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
|
||
@Pipe({ | ||
name: 'groupBy' | ||
}) | ||
export class GroupByPipe implements PipeTransform { | ||
transform(collection: any[], property: string): any[] { | ||
// prevents the application from breaking if the array of objects doesn't exist yet | ||
if(!collection) { | ||
return null as any; | ||
} | ||
|
||
const groupedCollection = collection.reduce((previous, current)=> { | ||
if(!previous[current[property]]) { | ||
previous[current[property]] = [current]; | ||
} else { | ||
previous[current[property]].push(current); | ||
} | ||
|
||
return previous; | ||
}, {}); | ||
|
||
// this will return an array of objects, each object containing a group of objects | ||
return Object.keys(groupedCollection).map(key => ({ key, value: groupedCollection[key] })); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/KafkaFlow.Admin.Dashboard/AngularFiles/src/app/sort.pipe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Pipe, PipeTransform } from "@angular/core"; | ||
|
||
@Pipe({ | ||
name: "sort" | ||
}) | ||
export class SortPipe implements PipeTransform { | ||
transform(array: any, field: string, order: string = "asc"): any[] { | ||
order = order.toLowerCase(); | ||
if(order!= "asc" && order!= "desc") { | ||
return array; | ||
} | ||
if (!Array.isArray(array)) { | ||
return null as any; | ||
} | ||
array.sort((a: any, b: any) => { | ||
if (a[field] < b[field]) { | ||
return (order == "asc")? -1 : 1; | ||
} else if (a[field] > b[field]) { | ||
return (order == "asc")? 1 : -1; | ||
} else { | ||
return 0; | ||
} | ||
}); | ||
return array; | ||
} | ||
} |
Empty file.
Oops, something went wrong.