Skip to content

Commit

Permalink
feat(ui): allow to hide headers (#928)
Browse files Browse the repository at this point in the history
  • Loading branch information
timonback authored Aug 23, 2024
1 parent 604c9d5 commit c31f0e8
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
6 changes: 6 additions & 0 deletions springwolf-ui/src/app/components/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ <h1 class="width-s-hide">{{ title }}</h1>
}}</mat-icon>
Show bindings
</button>
<button mat-menu-item (click)="toggleIsShowHeaders()">
<mat-icon>{{
isShowHeaders ? "check_box" : "check_box_outline_blank"
}}</mat-icon>
Show headers
</button>
</mat-menu>

<mat-slide-toggle
Expand Down
8 changes: 8 additions & 0 deletions springwolf-ui/src/app/components/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { IAssetService } from "../../service/asset.service";
export class HeaderComponent implements OnInit {
isNewUi: boolean = UiService.DEFAULT_NEW_UI;
isShowBindings: boolean = UiService.DEFAULT_SHOW_BINDINGS;
isShowHeaders: boolean = UiService.DEFAULT_SHOW_HEADERS;
title: string = "";

constructor(
Expand All @@ -27,6 +28,9 @@ export class HeaderComponent implements OnInit {
this.uiService.isShowBindings$.subscribe(
(value) => (this.isShowBindings = value)
);
this.uiService.isShowHeaders$.subscribe(
(value) => (this.isShowHeaders = value)
);

this.asyncApiService.getAsyncApi().subscribe((asyncapi) => {
this.title = asyncapi.info.title;
Expand All @@ -40,4 +44,8 @@ export class HeaderComponent implements OnInit {
toggleIsShowBindings() {
this.uiService.toggleIsShowBindings(!this.isShowBindings);
}

toggleIsShowHeaders() {
this.uiService.toggleIsShowHeaders(!this.isShowHeaders);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
</div>
</div>

<mat-divider *ngIf="isShowBindings"></mat-divider>
<div class="row" *ngIf="isShowBindings">
<div class="width-6/12 width-12/12-s">
<h6>Operation Binding</h6>
Expand All @@ -76,7 +75,6 @@ <h6>Operation Binding</h6>
</div>
</div>

<mat-divider *ngIf="isShowBindings"></mat-divider>
<div class="row" *ngIf="isShowBindings">
<div class="width-6/12 width-12/12-s">
<h6>Message Binding</h6>
Expand All @@ -94,8 +92,7 @@ <h6>Message Binding</h6>
</div>
</div>

<mat-divider></mat-divider>
<div class="row">
<div class="row" *ngIf="isShowHeaders">
<div class="width-6/12 width-12/12-s">
<h6>Headers</h6>
<mat-chip-set>
Expand All @@ -112,7 +109,6 @@ <h6>Headers</h6>
</div>
</div>

<mat-divider></mat-divider>
<div class="row">
<div class="width-6/12 width-12/12-s">
<h6>Payload</h6>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class ChannelOperationComponent implements OnInit {
messageBindingExampleString?: string;

isShowBindings: boolean = UiService.DEFAULT_SHOW_BINDINGS;
isShowHeaders: boolean = UiService.DEFAULT_SHOW_HEADERS;
canPublish: boolean = false;

constructor(
Expand Down Expand Up @@ -83,6 +84,9 @@ export class ChannelOperationComponent implements OnInit {
this.uiService.isShowBindings$.subscribe(
(value) => (this.isShowBindings = value)
);
this.uiService.isShowHeaders$.subscribe(
(value) => (this.isShowHeaders = value)
);
}

createBindingExample(binding?: Binding): Example | undefined {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,4 @@
{{ value.multipleOf }}
</span>
</span>

<mat-divider />
</ng-template>
10 changes: 10 additions & 0 deletions springwolf-ui/src/app/service/ui.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { BehaviorSubject } from "rxjs";
export class UiService {
public static readonly DEFAULT_NEW_UI = true;
public static readonly DEFAULT_SHOW_BINDINGS = true;
public static readonly DEFAULT_SHOW_HEADERS = true;

private _isNewUi = new BehaviorSubject<boolean>(UiService.DEFAULT_NEW_UI);
isNewUi$ = this._isNewUi.asObservable();
Expand All @@ -17,11 +18,20 @@ export class UiService {
);
isShowBindings$ = this._isShowBindings.asObservable();

private _isShowHeaders = new BehaviorSubject<boolean>(
UiService.DEFAULT_SHOW_HEADERS
);
isShowHeaders$ = this._isShowHeaders.asObservable();

toggleIsNewUi(value: boolean) {
this._isNewUi.next(value);
}

toggleIsShowBindings(value: boolean) {
this._isShowBindings.next(value);
}

toggleIsShowHeaders(value: boolean) {
this._isShowHeaders.next(value);
}
}

0 comments on commit c31f0e8

Please sign in to comment.