This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Config-editor-ui: Application manager (#278)
- Loading branch information
Showing
13 changed files
with
253 additions
and
36 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
8 changes: 8 additions & 0 deletions
8
config-editor/config-editor-ui/src/app/components/admin/admin.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
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
49 changes: 49 additions & 0 deletions
49
.../config-editor-ui/src/app/components/application-dialog/application-dialog.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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<h1 mat-dialog-title>Application Manager</h1> | ||
<mat-form-field [ngStyle]="{display: (applications$ | async)?.length > 1 ? 'block' : 'none'}" | ||
class="filter" appearance="standard"> | ||
<mat-label>Filter</mat-label> | ||
<input matInput (keyup)="applyFilter($event)" placeholder="Ex. siembol" #input> | ||
</mat-form-field> | ||
<div class="container"> | ||
<table mat-table [dataSource]="dataSource"> | ||
<ng-container *ngFor="let column of columns" [matColumnDef]="column.columnDef"> | ||
<th mat-header-cell *matHeaderCellDef> | ||
{{column.header}} | ||
</th> | ||
<td mat-cell *matCellDef="let row"> | ||
{{column.cell(row)}} | ||
</td> | ||
</ng-container> | ||
<ng-container matColumnDef="attributes"> | ||
<th mat-header-cell *matHeaderCellDef></th> | ||
<td mat-cell *matCellDef="let row"> | ||
<button mat-raised-button color="primary" (click)="onViewAttributes(row.attributes[0], attributesViewer)">View attributes</button> | ||
</td> | ||
</ng-container> | ||
<ng-container matColumnDef="restart"> | ||
<th mat-header-cell *matHeaderCellDef></th> | ||
<td mat-cell *matCellDef="let row"> | ||
<button mat-raised-button color="primary" (click)="onRestartApplication(row.topology_name)">Restart</button> | ||
</td> | ||
</ng-container> | ||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> | ||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> | ||
</table> | ||
</div> | ||
<div mat-dialog-actions> | ||
<button mat-raised-button class="button-layout" color="accent" (click)="onClickClose()">CLOSE</button> | ||
</div> | ||
|
||
<ng-template #attributesViewer let-data> | ||
<div class="attributes"> | ||
<re-json-tree | ||
[json]="data" | ||
[prevKey]="'$'" | ||
[copyOnClick]="false" | ||
> | ||
</re-json-tree> | ||
</div> | ||
<div mat-dialog-actions> | ||
<button mat-raised-button class="button-layout" color="accent" (click)="onClickCloseAttributes()">CLOSE</button> | ||
</div> | ||
</ng-template> |
34 changes: 34 additions & 0 deletions
34
.../config-editor-ui/src/app/components/application-dialog/application-dialog.component.scss
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,34 @@ | ||
.container { | ||
font-size: 70%; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: stretch; | ||
padding: 10px 10px; | ||
padding-right: 30px; | ||
max-width: 70vw; | ||
max-height: 70vh; | ||
overflow-y: auto; | ||
} | ||
|
||
.button-layout { | ||
margin-right: 0px; | ||
margin-left: auto; | ||
} | ||
|
||
.mat-header-cell, .mat-cell { | ||
padding: 10px; | ||
} | ||
|
||
.scrollbar { | ||
--scrollbar-thumb-color: #868686; | ||
--scrollbar-thumb-hover-color: #a1a1a1; | ||
} | ||
|
||
.attributes { | ||
max-height: 60vh; | ||
overflow-y: auto; | ||
} | ||
|
||
.filter { | ||
width: 100%; | ||
} |
68 changes: 68 additions & 0 deletions
68
...or/config-editor-ui/src/app/components/application-dialog/application-dialog.component.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,68 @@ | ||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Inject, TemplateRef } from "@angular/core"; | ||
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog"; | ||
import { MatTableDataSource } from "@angular/material/table"; | ||
import { Application, applicationManagerColumns, displayedApplicationManagerColumns } from "@app/model/config-model"; | ||
import { EditorService } from "@app/services/editor.service"; | ||
import { Observable } from "rxjs"; | ||
|
||
@Component({ | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
selector: 're-application-dialog', | ||
styleUrls: ['application-dialog.component.scss'], | ||
templateUrl: 'application-dialog.component.html', | ||
}) | ||
export class ApplicationDialogComponent { | ||
dialogrefAttributes: MatDialogRef<any>; | ||
applications$: Observable<Application[]>; | ||
dataSource: MatTableDataSource<Application>; | ||
columns = applicationManagerColumns; | ||
displayedColumns = displayedApplicationManagerColumns; | ||
|
||
constructor( | ||
private dialogref: MatDialogRef<ApplicationDialogComponent>, | ||
@Inject(MAT_DIALOG_DATA) private data: Observable<Application[]>, | ||
private service: EditorService, | ||
private dialog: MatDialog, | ||
private cd: ChangeDetectorRef | ||
) { | ||
this.applications$ = data; | ||
this.applications$.subscribe(a => { | ||
this.createTable(a); | ||
}) | ||
} | ||
|
||
onClickClose() { | ||
this.dialogref.close(); | ||
} | ||
|
||
onRestartApplication(applicationName: string) { | ||
this.applications$ = this.service.configLoader.restartApplication(applicationName); | ||
this.applications$.subscribe(a => { | ||
this.createTable(a); | ||
}) | ||
} | ||
|
||
onViewAttributes(attributes: string, templateRef: TemplateRef<any>) { | ||
this.dialogrefAttributes = this.dialog.open( | ||
templateRef, | ||
{ | ||
data: JSON.parse(atob(attributes)), | ||
}); | ||
} | ||
|
||
onClickCloseAttributes() { | ||
this.dialogrefAttributes.close(); | ||
} | ||
|
||
applyFilter(event: Event) { | ||
const filterValue = (event.target as HTMLInputElement).value; | ||
this.dataSource.filter = filterValue.trim().toLowerCase(); | ||
} | ||
|
||
private createTable(a: Application[]) { | ||
const filter = this.dataSource?.filter; | ||
this.dataSource = new MatTableDataSource(a); | ||
this.dataSource.filter = filter; | ||
this.cd.markForCheck(); | ||
} | ||
} |
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
Oops, something went wrong.