-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAS-129884: Improve directory services monitor (#10276)
- Loading branch information
Showing
101 changed files
with
429 additions
and
480 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
import { marker as T } from '@biesbjerg/ngx-translate-extract-marker'; | ||
|
||
export enum DirectoryServiceState { | ||
Disabled = 'DISABLED', | ||
Healthy = 'HEALTHY', | ||
Faulted = 'FAULTED', | ||
Leaving = 'LEAVING', | ||
Joining = 'JOINING', | ||
} | ||
|
||
export const directoryServiceStateLabels = new Map<DirectoryServiceState, string>([ | ||
[DirectoryServiceState.Disabled, T('Disabled')], | ||
[DirectoryServiceState.Healthy, T('Healthy')], | ||
[DirectoryServiceState.Faulted, T('Faulted')], | ||
[DirectoryServiceState.Leaving, T('Leaving')], | ||
[DirectoryServiceState.Joining, T('Joining')], | ||
]); |
85 changes: 38 additions & 47 deletions
85
...y-services-indicator/directory-services-monitor/directory-services-monitor.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,69 +1,60 @@ | ||
<mat-dialog-content class="dir-service-monitor-dialog"> | ||
<div class="header" fxLayout="row" fxLayoutAlign="space-between center"> | ||
<mat-dialog-content class="dialog"> | ||
<div class="header"> | ||
<h3>{{ 'Directory Services' | translate }}</h3> | ||
|
||
<div class="header-actions"> | ||
<!-- TODO: Use subscription instead. Move logic to a common component store/service --> | ||
<button | ||
*ixRequiresRoles="requiredRoles" | ||
mat-icon-button | ||
id="refresh-icon" | ||
ixTest="refresh-directory-services" | ||
[attr.aria-label]="'Refresh' | translate" | ||
(click)="getStatus()" | ||
> | ||
<ix-icon name="refresh"></ix-icon> | ||
</button> | ||
|
||
<button | ||
class="dir-services-monitor-action-button" | ||
mat-icon-button | ||
mat-dialog-close | ||
ixTest="close-directory-services" | ||
[attr.aria-label]="'Close' | translate" | ||
> | ||
<ix-icon name="clear"></ix-icon> | ||
</button> | ||
</div> | ||
</div> | ||
<div *ngIf="isLoading" class="spinner-wrapper"> | ||
<mat-spinner id="dir-service-monitor-spinner" [diameter]="40"></mat-spinner> | ||
</div> | ||
<mat-table | ||
*ngIf="!isLoading" | ||
class="mat-elevation-z8" | ||
[dataSource]="dataSource" | ||
> | ||
<!-- Icon Column --> | ||
<ng-container matColumnDef="icon"> | ||
<mat-header-cell *matHeaderCellDef fxFlex="74px"></mat-header-cell> | ||
<mat-cell *matCellDef="let element" fxFlex="74px"> | ||
<ng-container [ngSwitch]="element.state"> | ||
<ix-icon *ngSwitchCase="DirectoryServiceState.Healthy" name="check_circle" class="state-healthy"></ix-icon> | ||
<ix-icon *ngSwitchCase="DirectoryServiceState.Faulted" name="highlight_off" class="state-faulted"></ix-icon> | ||
<ix-icon *ngSwitchCase="DirectoryServiceState.Leaving" name="arrow_back" class="state-leaving"></ix-icon> | ||
<ix-icon *ngSwitchCase="DirectoryServiceState.Joining" name="arrow_forward" class="state-joining"></ix-icon> | ||
<ix-icon *ngSwitchCase="DirectoryServiceState.Disabled" name="remove_circle" class="state-disabled"></ix-icon> | ||
</ng-container> | ||
</mat-cell> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="name"> | ||
<mat-header-cell *matHeaderCellDef> | ||
{{ 'Name' | translate }} | ||
</mat-header-cell> | ||
<mat-cell *matCellDef="let element">{{ element.name }}</mat-cell> | ||
</ng-container> | ||
@if (isLoading()) { | ||
<div class="spinner-wrapper"> | ||
<mat-spinner id="dir-service-monitor-spinner" [diameter]="40"></mat-spinner> | ||
</div> | ||
} @else { | ||
<a | ||
class="status-row" | ||
[ixTest]="'go-to-directory-services'" | ||
[routerLink]="['/credentials', 'directory-services']" | ||
> | ||
<div>{{ serviceName() }}</div> | ||
<div class="state"> | ||
@switch (state()) { | ||
@case (DirectoryServiceState.Healthy) { | ||
<ix-icon name="check_circle" class="icon state-healthy"></ix-icon> | ||
} | ||
@case (DirectoryServiceState.Faulted) { | ||
<ix-icon name="highlight_off" class="icon state-faulted"></ix-icon> | ||
} | ||
@case (DirectoryServiceState.Leaving) { | ||
<ix-icon name="arrow_back" class="icon state-leaving"></ix-icon> | ||
} | ||
@case (DirectoryServiceState.Joining) { | ||
<ix-icon name="arrow_forward" class="icon state-joining"></ix-icon> | ||
} | ||
@case (DirectoryServiceState.Disabled) { | ||
<ix-icon name="remove_circle" class="icon state-disabled"></ix-icon> | ||
} | ||
} | ||
|
||
<ng-container matColumnDef="state"> | ||
<mat-header-cell *matHeaderCellDef> | ||
{{ 'State' | translate }} | ||
</mat-header-cell> | ||
<mat-cell *matCellDef="let element">{{ element.state }}</mat-cell> | ||
</ng-container> | ||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> | ||
<mat-row | ||
*matRowDef="let row; columns: displayedColumns" | ||
class="table-row clickable" | ||
[ixTest]="row.name" | ||
(click)="goTo(row.id)" | ||
></mat-row> | ||
</mat-table> | ||
{{ state() | mapValue: directoryServiceStateLabels | translate }} | ||
</div> | ||
</a> | ||
} | ||
</mat-dialog-content> |
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
53 changes: 53 additions & 0 deletions
53
...ervices-indicator/directory-services-monitor/directory-services-monitor.component.spec.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,53 @@ | ||
import { HarnessLoader } from '@angular/cdk/testing'; | ||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; | ||
import { createComponentFactory, Spectator } from '@ngneat/spectator/jest'; | ||
import { mockCall, mockWebSocket } from 'app/core/testing/utils/mock-websocket.utils'; | ||
import { DirectoryServiceState } from 'app/enums/directory-service-state.enum'; | ||
import { IxIconHarness } from 'app/modules/ix-icon/ix-icon.harness'; | ||
import { | ||
DirectoryServicesMonitorComponent, | ||
} from 'app/modules/layout/components/topbar/directory-services-indicator/directory-services-monitor/directory-services-monitor.component'; | ||
import { MapValuePipe } from 'app/modules/pipes/map-value/map-value.pipe'; | ||
import { WebSocketService } from 'app/services/ws.service'; | ||
|
||
describe('DirectoryServicesMonitorComponent', () => { | ||
let spectator: Spectator<DirectoryServicesMonitorComponent>; | ||
let loader: HarnessLoader; | ||
const createComponent = createComponentFactory({ | ||
component: DirectoryServicesMonitorComponent, | ||
imports: [ | ||
MapValuePipe, | ||
], | ||
providers: [ | ||
mockWebSocket([ | ||
mockCall('directoryservices.get_state', { | ||
activedirectory: DirectoryServiceState.Disabled, | ||
ldap: DirectoryServiceState.Healthy, | ||
}), | ||
]), | ||
], | ||
}); | ||
|
||
beforeEach(() => { | ||
spectator = createComponent(); | ||
loader = TestbedHarnessEnvironment.loader(spectator.fixture); | ||
}); | ||
|
||
it('loads directory services status on component initialization', () => { | ||
expect(spectator.inject(WebSocketService).call).toHaveBeenCalledWith('directoryservices.get_state'); | ||
}); | ||
|
||
it('shows status of a non-disabled directory service', () => { | ||
expect(spectator.query('.status-row')).toHaveText('LDAP Healthy'); | ||
|
||
const statusIcon = spectator.query('.status-row .icon'); | ||
expect(statusIcon).toHaveClass('state-healthy'); | ||
}); | ||
|
||
it('updates directory services status when refresh button is pressed', async () => { | ||
const refreshButton = await loader.getHarness(IxIconHarness.with({ name: 'refresh' })); | ||
await refreshButton.click(); | ||
|
||
expect(spectator.inject(WebSocketService).call).toHaveBeenLastCalledWith('directoryservices.get_state'); | ||
}); | ||
}); |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.