Skip to content

Commit

Permalink
Fix Health Panel usability issues
Browse files Browse the repository at this point in the history
- Fixed aria-controls on HealthComponentComponent, HealthInfoComponent, HealthInfoComponentComponent, HealthPanelComponent pointing to non-existing id
- Fixed the tabs not having the role tab on its tabs
- Fixed aria-expanded being set to true when collapsed and backwards for HealthPanelComponent & HealthInfoComponent
- Fixed minor alignment issues
  • Loading branch information
alexandrevryghem committed Nov 26, 2023
1 parent 0534722 commit 4873815
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<div *ngFor="let entry of healthInfoComponent | dsObjNgFor" data-test="collapse">
<div *ngIf="entry && !isPlainProperty(entry.value)" class="mb-3 border-bottom">
<div class="w-100 d-flex justify-content-between collapse-toggle" (click)="collapse.toggle()">
<div class="w-100 d-flex gap-3 justify-content-between collapse-toggle" (click)="collapse.toggle()">
<button type="button" class="btn btn-link p-0" (click)="$event.preventDefault()" [attr.aria-expanded]="!collapse.collapsed"
aria-controls="collapseExample">
[attr.aria-controls]="'health-info-component-' + entry.key + '-content'">
{{ entry.key | titlecase }}
</button>
<div class="d-inline-block">
<div class="d-flex my-auto">
<span *ngIf="collapse.collapsed" class="fas fa-chevron-down"></span>
<span *ngIf="!collapse.collapsed" class="fas fa-chevron-up"></span>
</div>
</div>
<div #collapse="ngbCollapse" [ngbCollapse]="isCollapsed">
<div #collapse="ngbCollapse" [id]="'health-info-component-' + entry.key + '-content'" [ngbCollapse]="isCollapsed">
<div class="card border-0">
<div class="card-body">
<ds-health-info-component [healthInfoComponent]="entry.value"
Expand Down
15 changes: 8 additions & 7 deletions src/app/health-page/health-info/health-info.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@
<ngb-accordion #acc="ngbAccordion" [activeIds]="activeId">
<ngb-panel [id]="entry.key" *ngFor="let entry of healthInfoResponse | dsObjNgFor">
<ng-template ngbPanelHeader>
<div class="w-100 d-flex justify-content-between collapse-toggle" ngbPanelToggle (click)="acc.toggle(entry.key)" data-test="info-component">
<button type="button" class="btn btn-link p-0" (click)="$event.preventDefault()" [attr.aria-expanded]="!acc.isExpanded(entry.key)"
aria-controls="collapsePanels">
<div class="w-100 d-flex gap-3 justify-content-between collapse-toggle" ngbPanelToggle (click)="acc.toggle(entry.key)" data-test="info-component">
<button type="button" class="btn btn-link p-0" (click)="$event.preventDefault()" [attr.aria-expanded]="acc.isExpanded(entry.key)"
[attr.aria-controls]="'health-info-' + entry.key + '-content'">
{{ getPanelLabel(entry.key) | titlecase }}
</button>
<div class="text-right d-flex">
<div class="text-right d-flex gap-2">
<ds-health-status [status]="entry.value?.status"></ds-health-status>
<div class="ml-3 d-inline-block">
<div class="d-flex my-auto">
<span *ngIf="acc.isExpanded(entry.key)" class="fas fa-chevron-up fa-fw"></span>
<span *ngIf="!acc.isExpanded(entry.key)" class="fas fa-chevron-down fa-fw"></span>
</div>
</div>
</div>
</ng-template>
<ng-template ngbPanelContent>
<ds-health-info-component [healthInfoComponentName]="entry.key"
[healthInfoComponent]="entry.value"></ds-health-info-component>
<ds-health-info-component [healthInfoComponentName]="entry.key" [healthInfoComponent]="entry.value"
[id]="'health-info-' + entry.key + '-content'">
</ds-health-info-component>
</ng-template>
</ngb-panel>
</ngb-accordion>
Expand Down
6 changes: 3 additions & 3 deletions src/app/health-page/health-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<h2>{{'health-page.heading' | translate}}</h2>
<div *ngIf="(healthResponse | async) && (healthInfoResponse | async)">
<ul ngbNav #nav="ngbNav" [activeId]="'status'" class="nav-tabs">
<li [ngbNavItem]="'status'">
<li [ngbNavItem]="'status'" role="tab">
<a ngbNavLink>{{'health-page.status-tab' | translate}}</a>
<ng-template ngbNavContent>
<div id="status">
<ds-health-panel [healthResponse]="(healthResponse | async)"></ds-health-panel>
</div>
</ng-template>
</li>
<li [ngbNavItem]="'info'">
<li [ngbNavItem]="'info'" role="tab">
<a ngbNavLink>{{'health-page.info-tab' | translate}}</a>
<ng-template ngbNavContent>
<div id="info">
Expand All @@ -21,7 +21,7 @@ <h2>{{'health-page.heading' | translate}}</h2>
</ul>
<div [ngbNavOutlet]="nav" class="mt-2"></div>
</div>
<ds-alert *ngIf="!(healthResponse | async) || !(healthInfoResponse | async)" [type]="'alert-danger'" [content]="'health-page.error.msg'"></ds-alert>
<ds-alert *ngIf="!(healthResponse | async) || !(healthInfoResponse | async)" [type]="AlertType.Error" [content]="'health-page.error.msg'"></ds-alert>
</div>


3 changes: 3 additions & 0 deletions src/app/health-page/health-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { take } from 'rxjs/operators';

import { HealthService } from './health.service';
import { HealthInfoResponse, HealthResponse } from './models/health-component.model';
import { AlertType } from '../shared/alert/alert-type';

@Component({
selector: 'ds-health-page',
Expand Down Expand Up @@ -33,6 +34,8 @@ export class HealthPageComponent implements OnInit {
*/
healthInfoResponseInitialised: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);

readonly AlertType = AlertType;

constructor(private healthDataService: HealthService) {
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<ng-container *ngIf="healthComponent?.components">
<div *ngFor="let entry of healthComponent?.components | dsObjNgFor" class="mb-3 border-bottom" data-test="collapse">
<div class="w-100 d-flex justify-content-between collapse-toggle" (click)="collapse.toggle()">
<div class="w-100 d-flex gap-3 justify-content-between collapse-toggle" (click)="collapse.toggle()">
<button type="button" class="btn btn-link p-0" (click)="$event.preventDefault()" [attr.aria-expanded]="!collapse.collapsed"
aria-controls="collapseExample">
[attr.aria-controls]="'health-component-' + entry.key + 'content'">
{{ entry.key | titlecase }}
</button>
<div class="d-inline-block">
<div class="d-flex my-auto">
<span *ngIf="collapse.collapsed" class="fas fa-chevron-down"></span>
<span *ngIf="!collapse.collapsed" class="fas fa-chevron-up"></span>
</div>
</div>
<div #collapse="ngbCollapse" [ngbCollapse]="isCollapsed">
<div #collapse="ngbCollapse" [id]="'health-component-' + entry.key + 'content'" [ngbCollapse]="isCollapsed">
<div class="card border-0">
<div class="card-body">
<ds-health-component [healthComponent]="entry.value"
Expand Down
21 changes: 12 additions & 9 deletions src/app/health-page/health-panel/health-panel.component.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
<p class="h4">{{'health-page.status' | translate}} : <ds-health-status [status]="healthResponse.status"></ds-health-status></p>
<p class="h4">
{{'health-page.status' | translate}}:
<ds-health-status [status]="healthResponse.status" class="d-inline-flex"></ds-health-status>
</p>
<ngb-accordion #acc="ngbAccordion" [activeIds]="activeId">
<ngb-panel [id]="entry.key" *ngFor="let entry of healthResponse.components | dsObjNgFor">
<ng-template ngbPanelHeader>
<div class="w-100 d-flex justify-content-between collapse-toggle" ngbPanelToggle (click)="acc.toggle(entry.key)" data-test="component">
<button type="button" class="btn btn-link p-0" (click)="$event.preventDefault()" [attr.aria-expanded]="!acc.isExpanded(entry.key)"
aria-controls="collapsePanels">
<div class="w-100 d-flex gap-3 justify-content-between collapse-toggle" ngbPanelToggle (click)="acc.toggle(entry.key)" data-test="component">
<button type="button" class="btn btn-link p-0" (click)="$event.preventDefault()" [attr.aria-expanded]="acc.isExpanded(entry.key)"
[attr.aria-controls]="'health-panel-' + entry.key + '-content'">
{{ getPanelLabel(entry.key) | titlecase }}
</button>
<div class="text-right d-flex">
<div class="text-right d-flex gap-2">
<ds-health-status [status]="entry.value?.status"></ds-health-status>
<div class="ml-3 d-inline-block">
<div class="d-flex my-auto">
<span *ngIf="acc.isExpanded(entry.key)" class="fas fa-chevron-up fa-fw"></span>
<span *ngIf="!acc.isExpanded(entry.key)" class="fas fa-chevron-down fa-fw"></span>
</div>
</div>
</div>
</ng-template>
<ng-template ngbPanelContent>
<ds-health-component [healthComponent]="entry.value" [healthComponentName]="entry.key"></ds-health-component>
<ds-health-component [healthComponent]="entry.value" [healthComponentName]="entry.key"
[id]="'health-panel-' + entry.key + '-content'">
</ds-health-component>
</ng-template>
</ngb-panel>
</ngb-accordion>


Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<ng-container [ngSwitch]="status">
<i *ngSwitchCase="HealthStatus.UP"
class="fa fa-check-circle text-success ml-2 mt-1"
class="fa fa-check-circle text-success my-auto"
ngbTooltip="{{'health-page.status.ok.info' | translate}}" container="body" ></i>
<i *ngSwitchCase="HealthStatus.UP_WITH_ISSUES"
class="fa fa-exclamation-triangle text-warning ml-2 mt-1"
class="fa fa-exclamation-triangle text-warning my-auto"
ngbTooltip="{{'health-page.status.warning.info' | translate}}" container="body"></i>
<i *ngSwitchCase="HealthStatus.DOWN"
class="fa fa-times-circle text-danger ml-2 mt-1"
class="fa fa-times-circle text-danger my-auto"
ngbTooltip="{{'health-page.status.error.info' | translate}}" container="body"></i>

</ng-container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:host {
display: flex;
}

0 comments on commit 4873815

Please sign in to comment.