Skip to content

Commit

Permalink
NAS-130786: Enclosure page shouldn't break when there is no enclosure (
Browse files Browse the repository at this point in the history
…#10556)

* NAS-130786: Enclosure page shouldn't break when there is no enclosure

* NAS-130786: PR update

* NAS-130786: PR update

* NAS-130786: PR update

* NAS-130786: PR update
  • Loading branch information
AlexKarpov98 authored Aug 28, 2024
1 parent b5a4f7c commit d0159ca
Show file tree
Hide file tree
Showing 93 changed files with 209 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@

@if (selectedEnclosure()) {
<router-outlet></router-outlet>
} @else {
<ix-empty [conf]="emptyDashboardConf"></ix-empty>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ix-empty {
height: inherit;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import {
mockProvider,
SpectatorRouting,
} from '@ngneat/spectator/jest';
import { MockComponent } from 'ng-mocks';
import { of } from 'rxjs';
import { mockAuth } from 'app/core/testing/utils/mock-auth.utils';
import { mockCall, mockWebSocket } from 'app/core/testing/utils/mock-websocket.utils';
import { DashboardEnclosure } from 'app/interfaces/enclosure.interface';
import { EmptyComponent } from 'app/modules/empty/empty.component';
import {
EnclosureDashboardComponent,
} from 'app/pages/system/enclosure/components/enclosure-dashboard/enclosure-dashboard.component';
Expand All @@ -18,13 +19,12 @@ describe('EnclosureDashboardComponent', () => {
const createComponent = createRoutingFactory({
component: EnclosureDashboardComponent,
shallow: true,
declarations: [
MockComponent(EmptyComponent),
],
componentProviders: [
mockProvider(EnclosureStore, {
selectedEnclosure: () => ({
id: 'enclosure-id',
name: 'M50',
label: 'Current label',
} as DashboardEnclosure),
selectedEnclosure: jest.fn(),
initiate: jest.fn(),
listenForDiskUpdates: jest.fn(() => of()),
selectEnclosure: jest.fn(),
Expand All @@ -43,6 +43,15 @@ describe('EnclosureDashboardComponent', () => {
spectator = createComponent();
});

it('shows empty message when no enclosure is available', () => {
spectator.inject(EnclosureStore, true).selectedEnclosure.mockReturnValueOnce(undefined);

spectator.detectChanges();

const emptyComponent = spectator.query(EmptyComponent);
expect(emptyComponent).toExist();
});

it('initializes store when component is initialized', () => {
expect(spectator.inject(EnclosureStore, true).initiate).toHaveBeenCalled();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import {
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { TranslateService } from '@ngx-translate/core';
import { EmptyType } from 'app/enums/empty-type.enum';
import { EmptyConfig } from 'app/interfaces/empty-config.interface';
import { EnclosureStore } from 'app/pages/system/enclosure/services/enclosure.store';
import { WebSocketService } from 'app/services/ws.service';

Expand All @@ -11,6 +14,7 @@ import { WebSocketService } from 'app/services/ws.service';
selector: 'ix-enclosure-dashboard',
templateUrl: './enclosure-dashboard.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
styleUrls: ['./enclosure-dashboard.component.scss'],
providers: [
EnclosureStore,
],
Expand All @@ -20,10 +24,18 @@ export class EnclosureDashboardComponent {

readonly selectedEnclosure = this.enclosureStore.selectedEnclosure;

emptyDashboardConf: EmptyConfig = {
type: EmptyType.NoPageData,
large: true,
title: this.translate.instant('Enclosure Unavailable'),
message: this.translate.instant('We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.'),
};

constructor(
private enclosureStore: EnclosureStore,
private route: ActivatedRoute,
private ws: WebSocketService,
private translate: TranslateService,
) {
this.enclosureStore.initiate();
this.enclosureStore.listenForDiskUpdates().pipe(untilDestroyed(this)).subscribe();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { DashboardEnclosure } from 'app/interfaces/enclosure.interface';
import { EnclosureSide } from 'app/pages/system/enclosure/utils/supported-enclosures';

export function getDefaultSide(enclosure: DashboardEnclosure): EnclosureSide {
return enclosure.top_loaded ? EnclosureSide.Top : EnclosureSide.Front;
return enclosure?.top_loaded ? EnclosureSide.Top : EnclosureSide.Front;
}
2 changes: 2 additions & 0 deletions src/assets/i18n/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@
"Enclosure Options": "",
"Enclosure Read": "",
"Enclosure Services Controller Electronics": "",
"Enclosure Unavailable": "",
"Enclosure Write": "",
"Encode information in less space than the original data occupies. It is recommended to choose a compression algorithm that balances disk performance with the amount of saved space.<br> <i>LZ4</i> is generally recommended as it maximizes performance and dynamically identifies the best files to compress.<br> <i>GZIP</i> options range from 1 for least compression, best performance, through 9 for maximum compression with greatest performance impact.<br> <i>ZLE</i> is a fast algorithm that only eliminates runs of zeroes.": "",
"Encrypted Datasets": "",
Expand Down Expand Up @@ -4803,6 +4804,7 @@
"Wednesday": "",
"Week(s)": "",
"Weeks": "",
"We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.": "",
"What and When": "",
"What and Where": "",
"When": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@
"Enclosure Options": "",
"Enclosure Read": "",
"Enclosure Services Controller Electronics": "",
"Enclosure Unavailable": "",
"Enclosure Write": "",
"Encode information in less space than the original data occupies. It is recommended to choose a compression algorithm that balances disk performance with the amount of saved space.<br> <i>LZ4</i> is generally recommended as it maximizes performance and dynamically identifies the best files to compress.<br> <i>GZIP</i> options range from 1 for least compression, best performance, through 9 for maximum compression with greatest performance impact.<br> <i>ZLE</i> is a fast algorithm that only eliminates runs of zeroes.": "",
"Encrypted Datasets": "",
Expand Down Expand Up @@ -4803,6 +4804,7 @@
"Wednesday": "",
"Week(s)": "",
"Weeks": "",
"We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.": "",
"What and When": "",
"What and Where": "",
"When": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@
"Enclosure Options": "",
"Enclosure Read": "",
"Enclosure Services Controller Electronics": "",
"Enclosure Unavailable": "",
"Enclosure Write": "",
"Encode information in less space than the original data occupies. It is recommended to choose a compression algorithm that balances disk performance with the amount of saved space.<br> <i>LZ4</i> is generally recommended as it maximizes performance and dynamically identifies the best files to compress.<br> <i>GZIP</i> options range from 1 for least compression, best performance, through 9 for maximum compression with greatest performance impact.<br> <i>ZLE</i> is a fast algorithm that only eliminates runs of zeroes.": "",
"Encrypted Datasets": "",
Expand Down Expand Up @@ -4803,6 +4804,7 @@
"Wednesday": "",
"Week(s)": "",
"Weeks": "",
"We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.": "",
"What and When": "",
"What and Where": "",
"When": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/az.json
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@
"Enclosure Options": "",
"Enclosure Read": "",
"Enclosure Services Controller Electronics": "",
"Enclosure Unavailable": "",
"Enclosure Write": "",
"Encode information in less space than the original data occupies. It is recommended to choose a compression algorithm that balances disk performance with the amount of saved space.<br> <i>LZ4</i> is generally recommended as it maximizes performance and dynamically identifies the best files to compress.<br> <i>GZIP</i> options range from 1 for least compression, best performance, through 9 for maximum compression with greatest performance impact.<br> <i>ZLE</i> is a fast algorithm that only eliminates runs of zeroes.": "",
"Encrypted Datasets": "",
Expand Down Expand Up @@ -4803,6 +4804,7 @@
"Wednesday": "",
"Week(s)": "",
"Weeks": "",
"We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.": "",
"What and When": "",
"What and Where": "",
"When": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/be.json
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@
"Enclosure Options": "",
"Enclosure Read": "",
"Enclosure Services Controller Electronics": "",
"Enclosure Unavailable": "",
"Enclosure Write": "",
"Encode information in less space than the original data occupies. It is recommended to choose a compression algorithm that balances disk performance with the amount of saved space.<br> <i>LZ4</i> is generally recommended as it maximizes performance and dynamically identifies the best files to compress.<br> <i>GZIP</i> options range from 1 for least compression, best performance, through 9 for maximum compression with greatest performance impact.<br> <i>ZLE</i> is a fast algorithm that only eliminates runs of zeroes.": "",
"Encrypted Datasets": "",
Expand Down Expand Up @@ -4803,6 +4804,7 @@
"Wednesday": "",
"Week(s)": "",
"Weeks": "",
"We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.": "",
"What and When": "",
"What and Where": "",
"When": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@
"Enclosure Options": "",
"Enclosure Read": "",
"Enclosure Services Controller Electronics": "",
"Enclosure Unavailable": "",
"Enclosure Write": "",
"Encode information in less space than the original data occupies. It is recommended to choose a compression algorithm that balances disk performance with the amount of saved space.<br> <i>LZ4</i> is generally recommended as it maximizes performance and dynamically identifies the best files to compress.<br> <i>GZIP</i> options range from 1 for least compression, best performance, through 9 for maximum compression with greatest performance impact.<br> <i>ZLE</i> is a fast algorithm that only eliminates runs of zeroes.": "",
"Encrypted Datasets": "",
Expand Down Expand Up @@ -4803,6 +4804,7 @@
"Wednesday": "",
"Week(s)": "",
"Weeks": "",
"We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.": "",
"What and When": "",
"What and Where": "",
"When": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@
"Enclosure Options": "",
"Enclosure Read": "",
"Enclosure Services Controller Electronics": "",
"Enclosure Unavailable": "",
"Enclosure Write": "",
"Encode information in less space than the original data occupies. It is recommended to choose a compression algorithm that balances disk performance with the amount of saved space.<br> <i>LZ4</i> is generally recommended as it maximizes performance and dynamically identifies the best files to compress.<br> <i>GZIP</i> options range from 1 for least compression, best performance, through 9 for maximum compression with greatest performance impact.<br> <i>ZLE</i> is a fast algorithm that only eliminates runs of zeroes.": "",
"Encrypted Datasets": "",
Expand Down Expand Up @@ -4803,6 +4804,7 @@
"Wednesday": "",
"Week(s)": "",
"Weeks": "",
"We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.": "",
"What and When": "",
"What and Where": "",
"When": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/br.json
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@
"Enclosure Options": "",
"Enclosure Read": "",
"Enclosure Services Controller Electronics": "",
"Enclosure Unavailable": "",
"Enclosure Write": "",
"Encode information in less space than the original data occupies. It is recommended to choose a compression algorithm that balances disk performance with the amount of saved space.<br> <i>LZ4</i> is generally recommended as it maximizes performance and dynamically identifies the best files to compress.<br> <i>GZIP</i> options range from 1 for least compression, best performance, through 9 for maximum compression with greatest performance impact.<br> <i>ZLE</i> is a fast algorithm that only eliminates runs of zeroes.": "",
"Encrypted Datasets": "",
Expand Down Expand Up @@ -4803,6 +4804,7 @@
"Wednesday": "",
"Week(s)": "",
"Weeks": "",
"We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.": "",
"What and When": "",
"What and Where": "",
"When": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@
"Enclosure Options": "",
"Enclosure Read": "",
"Enclosure Services Controller Electronics": "",
"Enclosure Unavailable": "",
"Enclosure Write": "",
"Encode information in less space than the original data occupies. It is recommended to choose a compression algorithm that balances disk performance with the amount of saved space.<br> <i>LZ4</i> is generally recommended as it maximizes performance and dynamically identifies the best files to compress.<br> <i>GZIP</i> options range from 1 for least compression, best performance, through 9 for maximum compression with greatest performance impact.<br> <i>ZLE</i> is a fast algorithm that only eliminates runs of zeroes.": "",
"Encrypted Datasets": "",
Expand Down Expand Up @@ -4803,6 +4804,7 @@
"Wednesday": "",
"Week(s)": "",
"Weeks": "",
"We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.": "",
"What and When": "",
"What and Where": "",
"When": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@
"Enclosure Options": "",
"Enclosure Read": "",
"Enclosure Services Controller Electronics": "",
"Enclosure Unavailable": "",
"Enclosure Write": "",
"Encode information in less space than the original data occupies. It is recommended to choose a compression algorithm that balances disk performance with the amount of saved space.<br> <i>LZ4</i> is generally recommended as it maximizes performance and dynamically identifies the best files to compress.<br> <i>GZIP</i> options range from 1 for least compression, best performance, through 9 for maximum compression with greatest performance impact.<br> <i>ZLE</i> is a fast algorithm that only eliminates runs of zeroes.": "",
"Encrypted Datasets": "",
Expand Down Expand Up @@ -4803,6 +4804,7 @@
"Wednesday": "",
"Week(s)": "",
"Weeks": "",
"We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.": "",
"What and When": "",
"What and Where": "",
"When": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,7 @@
"Enclosure Options": "",
"Enclosure Read": "",
"Enclosure Services Controller Electronics": "",
"Enclosure Unavailable": "",
"Enclosure Write": "",
"Encode information in less space than the original data occupies. It is recommended to choose a compression algorithm that balances disk performance with the amount of saved space.<br> <i>LZ4</i> is generally recommended as it maximizes performance and dynamically identifies the best files to compress.<br> <i>GZIP</i> options range from 1 for least compression, best performance, through 9 for maximum compression with greatest performance impact.<br> <i>ZLE</i> is a fast algorithm that only eliminates runs of zeroes.": "",
"Encrypted Datasets": "",
Expand Down Expand Up @@ -4251,6 +4252,7 @@
"Wednesday": "",
"Week(s)": "",
"Weeks": "",
"We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.": "",
"What and When": "",
"What and Where": "",
"When a group is selected, the <i>root</i> user is also limited to the permissions of that group.": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@
"Enclosure Options": "",
"Enclosure Read": "",
"Enclosure Services Controller Electronics": "",
"Enclosure Unavailable": "",
"Enclosure Write": "",
"Encode information in less space than the original data occupies. It is recommended to choose a compression algorithm that balances disk performance with the amount of saved space.<br> <i>LZ4</i> is generally recommended as it maximizes performance and dynamically identifies the best files to compress.<br> <i>GZIP</i> options range from 1 for least compression, best performance, through 9 for maximum compression with greatest performance impact.<br> <i>ZLE</i> is a fast algorithm that only eliminates runs of zeroes.": "",
"Encrypted Datasets": "",
Expand Down Expand Up @@ -4803,6 +4804,7 @@
"Wednesday": "",
"Week(s)": "",
"Weeks": "",
"We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.": "",
"What and When": "",
"What and Where": "",
"When": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@
"Enclosure Options": "",
"Enclosure Read": "",
"Enclosure Services Controller Electronics": "",
"Enclosure Unavailable": "",
"Enclosure Write": "",
"Encode information in less space than the original data occupies. It is recommended to choose a compression algorithm that balances disk performance with the amount of saved space.<br> <i>LZ4</i> is generally recommended as it maximizes performance and dynamically identifies the best files to compress.<br> <i>GZIP</i> options range from 1 for least compression, best performance, through 9 for maximum compression with greatest performance impact.<br> <i>ZLE</i> is a fast algorithm that only eliminates runs of zeroes.": "",
"Encrypted Datasets": "",
Expand Down Expand Up @@ -4803,6 +4804,7 @@
"Wednesday": "",
"Week(s)": "",
"Weeks": "",
"We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.": "",
"What and When": "",
"What and Where": "",
"When": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,7 @@
"Enclosure Options": "",
"Enclosure Read": "",
"Enclosure Services Controller Electronics": "",
"Enclosure Unavailable": "",
"Enclosure Write": "",
"Encode information in less space than the original data occupies. It is recommended to choose a compression algorithm that balances disk performance with the amount of saved space.<br> <i>LZ4</i> is generally recommended as it maximizes performance and dynamically identifies the best files to compress.<br> <i>GZIP</i> options range from 1 for least compression, best performance, through 9 for maximum compression with greatest performance impact.<br> <i>ZLE</i> is a fast algorithm that only eliminates runs of zeroes.": "",
"Encrypted Datasets": "",
Expand Down Expand Up @@ -3467,6 +3468,7 @@
"Webhook URL": "",
"Wednesday": "",
"Week(s)": "",
"We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.": "",
"What and When": "",
"When a group is selected, the <i>root</i> user is also limited to the permissions of that group.": "",
"When a user is selected, the <i>root</i> user is limited to the permissions of that user.": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/dsb.json
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@
"Enclosure Options": "",
"Enclosure Read": "",
"Enclosure Services Controller Electronics": "",
"Enclosure Unavailable": "",
"Enclosure Write": "",
"Encode information in less space than the original data occupies. It is recommended to choose a compression algorithm that balances disk performance with the amount of saved space.<br> <i>LZ4</i> is generally recommended as it maximizes performance and dynamically identifies the best files to compress.<br> <i>GZIP</i> options range from 1 for least compression, best performance, through 9 for maximum compression with greatest performance impact.<br> <i>ZLE</i> is a fast algorithm that only eliminates runs of zeroes.": "",
"Encrypted Datasets": "",
Expand Down Expand Up @@ -4803,6 +4804,7 @@
"Wednesday": "",
"Week(s)": "",
"Weeks": "",
"We’re unable to access the enclosure at the moment. Please ensure it’s connected properly and reload the page.": "",
"What and When": "",
"What and Where": "",
"When": "",
Expand Down
Loading

0 comments on commit d0159ca

Please sign in to comment.