Skip to content

Commit

Permalink
Merge branch 'origin/master' into 132636/NAS-132636
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Vasilenko committed Dec 11, 2024
2 parents 0a1d273 + a0bc808 commit d957d3f
Show file tree
Hide file tree
Showing 367 changed files with 8,622 additions and 5,281 deletions.
14 changes: 4 additions & 10 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import eslint from "@eslint/js";
import tsEslint from "typescript-eslint";
import angular from "angular-eslint";
import stylistic from "@stylistic/eslint-plugin";
import {fixupConfigRules, fixupPluginRules} from "@eslint/compat";
import { FlatCompat } from "@eslint/eslintrc";
import {dirname} from "node:path";
import {fileURLToPath} from "node:url";
import { fixupPluginRules } from "@eslint/compat";
import rxjsAngular from "eslint-plugin-rxjs-angular";
import angularFileNaming from "eslint-plugin-angular-file-naming";
import importPlugin from "eslint-plugin-import";
Expand All @@ -17,11 +14,7 @@ import { eslintSpec } from "./eslint/eslint-spec.mjs";
import { fixLaterRules } from "./eslint/eslint-ts-rules-fix-later.mjs";
import { ruleOverrides } from "./eslint/eslint-ts-rules-overrides.mjs";
import { extraRules } from "./eslint/eslint-ts-rules-extra.mjs";

const __dirname = dirname(fileURLToPath(import.meta.url));
const compat = new FlatCompat({
baseDirectory: __dirname,
});
import rxjs from "@smarttools/eslint-plugin-rxjs";

export default tsEslint.config(
{
Expand All @@ -48,6 +41,7 @@ export default tsEslint.config(
},
plugins: {
unicorn,
rxjs,
"rxjs-angular": fixupPluginRules(rxjsAngular),
"angular-file-naming": fixupPluginRules(angularFileNaming),
"unused-imports": unusedImports,
Expand All @@ -68,7 +62,7 @@ export default tsEslint.config(
}),
importPlugin.flatConfigs.recommended,
sonarjs.configs.recommended,
...fixupConfigRules(compat.extends('plugin:rxjs/recommended')),
rxjs.configs.recommended,
],
rules: {
...ruleOverrides,
Expand Down
6 changes: 3 additions & 3 deletions eslint/eslint-ts-rules-extra.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import airbnbVariables from "eslint-config-airbnb-base/rules/variables";
*/
export const extraRules = {
// RxJS
"rxjs/no-unsafe-takeuntil": ["error", {
"@smarttools/rxjs/no-unsafe-takeuntil": ["error", {
"alias": ["untilDestroyed"]
}],
"rxjs-angular/prefer-takeuntil": ["error", {
Expand All @@ -16,14 +16,14 @@ export const extraRules = {
"checkDecorators": ["Component"],
"checkDestroy": false
}],
"rxjs/finnish": ["error", {
"@smarttools/rxjs/finnish": ["error", {
"parameters": true,
"properties": false, // TODO: Should be true, hard to implement now.
"variables": true,
"functions": false,
"methods": false,
}],
"rxjs/prefer-observer": ["error"],
"@smarttools/rxjs/prefer-observer": ["error"],

// Angular
"@angular-eslint/use-lifecycle-interface": ["error"],
Expand Down
3 changes: 1 addition & 2 deletions eslint/eslint-ts-rules-fix-later.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ export const fixLaterRules = {
"@typescript-eslint/no-dynamic-delete": ["off"],
"@typescript-eslint/class-literal-property-style": ["off"],
"no-prototype-builtins": ["off"],
"rxjs/no-implicit-any-catch": ["off"],
"rxjs/no-nested-subscribe": ["off"],
"@smarttools/rxjs/no-nested-subscribe": ["off"],

"sonarjs/prefer-nullish-coalescing": ["off"],
"sonarjs/deprecation": ["off"],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"@sentry/angular": "5.30.0",
"@sentry/utils": "~7.42.0",
"@shopify/eslint-plugin": "~46.0.0",
"@smarttools/eslint-plugin-rxjs": "~1.0.7",
"@stylistic/eslint-plugin": "~2.9.0",
"@types/cheerio": "~0.22.35",
"@types/d3": "~7.4.3",
Expand Down Expand Up @@ -147,7 +148,6 @@
"eslint-plugin-angular-test-ids": "~1.0.6",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "~28.8.3",
"eslint-plugin-rxjs": "^5.0.3",
"eslint-plugin-rxjs-angular": "^2.0.1",
"eslint-plugin-sonarjs": "~2.0.3",
"eslint-plugin-unicorn": "^56.0.0",
Expand Down
4 changes: 2 additions & 2 deletions proxy.config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"target": "http://_REMOTE_",
"secure": false,
"changeOrigin": true,
"pathRewrite": {"^/_upload" : "http://_REMOTE_:6000/_upload"},
"pathRewrite": {"^/_upload" : "http://_REMOTE_/_upload"},
"loglevel": "debug"
},
"/_download": {
"target": "http://_REMOTE_",
"secure": false,
"changeOrigin": true,
"pathRewrite": {"^/_download" : "http://_REMOTE_:6000/_download"},
"pathRewrite": {"^/_download" : "http://_REMOTE_/_download"},
"loglevel": "debug"
}
}
3 changes: 3 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { WINDOW } from 'app/helpers/window.helper';
import { AuthService } from 'app/services/auth/auth.service';
import { DetectBrowserService } from 'app/services/detect-browser.service';
import { LayoutService } from 'app/services/layout.service';
import { PingService } from 'app/services/websocket/ping.service';

@UntilDestroy()
@Component({
Expand All @@ -26,6 +27,7 @@ export class AppComponent implements OnInit {
private authService: AuthService,
private detectBrowser: DetectBrowserService,
private layoutService: LayoutService,
private pingService: PingService,
@Inject(WINDOW) private window: Window,
) {
this.authService.isAuthenticated$.pipe(untilDestroyed(this)).subscribe((isAuthenticated) => {
Expand All @@ -52,6 +54,7 @@ export class AppComponent implements OnInit {
}
}
});
this.pingService.setupPing();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/guards/translations-loaded.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class TranslationsLoadedGuard {
return waitForTranslations$.pipe(
timeout(this.maxLanguageLoadingTime),
map(() => true),
catchError((error) => {
catchError((error: unknown) => {
console.error('Error loading translations: ', error);
return of(true);
}),
Expand Down
8 changes: 6 additions & 2 deletions src/app/core/guards/websocket-connection.guard.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Injectable } from '@angular/core';
import { Inject, Injectable } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Router } from '@angular/router';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { TranslateService } from '@ngx-translate/core';
import { WINDOW } from 'app/helpers/window.helper';
import { DialogService } from 'app/modules/dialog/dialog.service';
import { WebSocketHandlerService } from 'app/services/websocket/websocket-handler.service';

Expand All @@ -16,6 +17,7 @@ export class WebSocketConnectionGuard {
private matDialog: MatDialog,
private dialogService: DialogService,
private translate: TranslateService,
@Inject(WINDOW) private window: Window,
) {
this.wsManager.isClosed$.pipe(untilDestroyed(this)).subscribe((isClosed) => {
if (isClosed) {
Expand All @@ -37,7 +39,9 @@ export class WebSocketConnectionGuard {
private resetUi(): void {
this.closeAllDialogs();
if (!this.wsManager.isSystemShuttingDown) {
this.router.navigate(['/signin']);
// manually preserve query params
const params = new URLSearchParams(this.window.location.search);
this.router.navigate(['/signin'], { queryParams: Object.fromEntries(params) });
}
}

Expand Down
14 changes: 8 additions & 6 deletions src/app/core/testing/classes/mock-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import {
ApiJobParams,
ApiJobResponse,
} from 'app/interfaces/api/api-job-directory.interface';
import { ApiEvent } from 'app/interfaces/api-message.interface';
import { ApiEventTyped } from 'app/interfaces/api-message.interface';
import { Job } from 'app/interfaces/job.interface';
import { ApiService } from 'app/services/websocket/api.service';
import { SubscriptionManagerService } from 'app/services/websocket/subscription-manager.service';
import { WebSocketHandlerService } from 'app/services/websocket/websocket-handler.service';

/**
Expand All @@ -41,14 +42,15 @@ const anyArgument = when((_: ApiJobParams<ApiJobMethod>) => true);
*/
@Injectable()
export class MockApiService extends ApiService {
private subscribeStream$ = new Subject<ApiEvent>();
private subscribeStream$ = new Subject<ApiEventTyped>();
private jobIdCounter = 1;

constructor(
protected override wsHandler: WebSocketHandlerService,
protected override translate: TranslateService,
wsHandler: WebSocketHandlerService,
subscriptionManager: SubscriptionManagerService,
translate: TranslateService,
) {
super(wsHandler, translate);
super(wsHandler, subscriptionManager, translate);

this.call = jest.fn();
this.job = jest.fn();
Expand Down Expand Up @@ -127,7 +129,7 @@ export class MockApiService extends ApiService {
this.jobIdCounter += 1;
}

emitSubscribeEvent(event: ApiEvent): void {
emitSubscribeEvent(event: ApiEventTyped): void {
this.subscribeStream$.next(event);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MockEnclosureGenerator } from 'app/core/testing/mock-enclosure/mock-enc
import { ApiCallMethod, ApiCallParams, ApiCallResponse } from 'app/interfaces/api/api-call-directory.interface';
import { SystemInfo } from 'app/interfaces/system-info.interface';
import { ApiService } from 'app/services/websocket/api.service';
import { SubscriptionManagerService } from 'app/services/websocket/subscription-manager.service';
import { WebSocketHandlerService } from 'app/services/websocket/websocket-handler.service';

@Injectable({
Expand All @@ -19,9 +20,10 @@ export class MockEnclosureApiService extends ApiService {

constructor(
wsManager: WebSocketHandlerService,
subscriptionManager: SubscriptionManagerService,
translate: TranslateService,
) {
super(wsManager, translate);
super(wsManager, subscriptionManager, translate);

console.warn('MockEnclosureApiService is in effect. Some calls will be mocked');
}
Expand Down
1 change: 1 addition & 0 deletions src/app/core/testing/utils/empty-auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export class EmptyAuthService {
logout = getMissingInjectionErrorFactory(AuthService.name);
refreshUser = getMissingInjectionErrorFactory(AuthService.name);
loginWithToken = getMissingInjectionErrorFactory(AuthService.name);
setQueryToken = getMissingInjectionErrorFactory(AuthService.name);
}
9 changes: 7 additions & 2 deletions src/app/core/testing/utils/mock-api.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ApiCallMethod } from 'app/interfaces/api/api-call-directory.interface';
import { ApiJobDirectory, ApiJobMethod } from 'app/interfaces/api/api-job-directory.interface';
import { Job } from 'app/interfaces/job.interface';
import { ApiService } from 'app/services/websocket/api.service';
import { SubscriptionManagerService } from 'app/services/websocket/subscription-manager.service';
import { WebSocketHandlerService } from 'app/services/websocket/websocket-handler.service';

/**
Expand Down Expand Up @@ -47,8 +48,12 @@ export function mockApi(
return [
{
provide: ApiService,
useFactory: (wsHandler: WebSocketHandlerService, translate: TranslateService) => {
const mockApiService = new MockApiService(wsHandler, translate);
useFactory: (
wsHandler: WebSocketHandlerService,
translate: TranslateService,
) => {
const subscriptionManager = {} as SubscriptionManagerService;
const mockApiService = new MockApiService(wsHandler, subscriptionManager, translate);
(mockResponses || []).forEach((mockResponse) => {
if (mockResponse.type === MockApiResponseType.Call) {
mockApiService.mockCall(mockResponse.method, mockResponse.response);
Expand Down
7 changes: 0 additions & 7 deletions src/app/enums/api-error-name.enum.ts

This file was deleted.

21 changes: 0 additions & 21 deletions src/app/enums/api-message-type.enum.ts

This file was deleted.

36 changes: 36 additions & 0 deletions src/app/enums/api.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export enum ApiErrorName {
NotAuthenticated = 'ENOTAUTHENTICATED',
NoAccess = 'EACCES',
NoMemory = 'ENOMEM',
AlreadyExists = 'EEXIST',
Again = 'EAGAIN',
Validation = 'EINVAL',
}

export const apiErrorNames = new Map<ApiErrorName, string>([
[ApiErrorName.NotAuthenticated, 'Not Authenticated'],
[ApiErrorName.NoAccess, 'Access Error'],
[ApiErrorName.NoMemory, 'No Memory'],
[ApiErrorName.AlreadyExists, 'Already Exists'],
[ApiErrorName.Again, 'Try Again'],
[ApiErrorName.Validation, 'Validation Error'],
]);

export enum JsonRpcErrorCode {
InvalidRequest = -32600,
MethodNotFound = -32601,
InvalidParams = -32602,
InternalError = -32603,
TooManyConcurrentCalls = -32000,
CallError = -32001,
}

export enum CollectionChangeType {
Changed = 'changed',
Added = 'added',
Removed = 'removed',
}

export enum ShellMessageType {
Connected = 'connected',
}
6 changes: 6 additions & 0 deletions src/app/enums/iscsi.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ export const iscsiExtentUseforMap = new Map([
[IscsiExtentUsefor.Legacyos, T('Legacy OS: Extent block size 512b, TPC enabled, no Xen compat mode, SSD speed')],
[IscsiExtentUsefor.Modernos, T('Modern OS: Extent block size 4k, TPC enabled, no Xen compat mode, SSD speed')],
]);

export const iscsiTargetModeNames = new Map<IscsiTargetMode, string>([
[IscsiTargetMode.Iscsi, T('iSCSI')],
[IscsiTargetMode.Fc, T('Fibre Channel')],
[IscsiTargetMode.Both, T('Both')],
]);
2 changes: 1 addition & 1 deletion src/app/enums/response-error-type.enum.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export enum ResponseErrorType {
export enum JobExceptionType {
Validation = 'VALIDATION',
}
Loading

0 comments on commit d957d3f

Please sign in to comment.