From 31856d9895c7f563e5099d3bdaf5caead8b84ed5 Mon Sep 17 00:00:00 2001 From: Alex Inkin Date: Sun, 6 Apr 2025 17:18:01 +0400 Subject: [PATCH] chore: comments (#2863) --- .../src/modals/release-notes.component.ts | 10 +-- .../src/pages/show/about/about.module.ts | 4 +- .../src/components}/markdown.component.ts | 25 +++--- .../markdown/markdown.component.html | 18 ----- .../markdown/markdown.component.module.ts | 22 ------ .../markdown/markdown.component.scss | 18 ----- .../components/markdown/markdown.component.ts | 49 ------------ .../src/pipes/{markdown => }/markdown.pipe.ts | 1 + .../src/pipes/markdown/markdown.module.ts | 8 -- web/projects/shared/src/public-api.ts | 6 +- .../ui/src/app/components/report.component.ts | 64 +++++++-------- .../ui/src/app/i18n/dictionaries/english.ts | 5 -- .../ui/src/app/i18n/dictionaries/spanish.ts | 5 -- .../components/header/header.component.ts | 33 -------- .../interfaces/clearnet.component.ts | 2 +- .../portal/components/uptime.component.ts | 16 +++- .../routes/backups/backups.component.ts | 13 +-- .../routes/backups/modals/backup.component.ts | 6 +- .../backups/modals/history.component.ts | 2 +- .../routes/backups/modals/target.component.ts | 17 ++-- .../portal/routes/metrics/cpu.component.ts | 2 +- .../portal/routes/metrics/memory.component.ts | 2 +- .../routes/metrics/storage.component.ts | 2 +- .../routes/metrics/temperature.component.ts | 1 + .../portal/routes/metrics/time.component.ts | 79 ++++++++++++++++--- .../services/components/actions.component.ts | 14 ++-- .../components/interface.component.ts | 79 ++++++++----------- .../components/interfaces.component.ts | 4 +- .../services/components/status.component.ts | 4 +- .../services/dashboard/service.component.ts | 23 +++++- .../routes/services/routes/about.component.ts | 5 +- .../services/routes/interface.component.ts | 21 ++++- .../portal/routes/services/services.routes.ts | 3 +- .../routes/general/general.component.ts | 32 ++++++-- .../system/routes/general}/snek.component.ts | 2 +- .../system/routes/general}/snek.directive.ts | 14 ++-- .../system/routes/general/sync.component.ts | 29 ------- .../system/routes/general/update.component.ts | 4 +- .../routes/sessions/sessions.component.ts | 3 +- .../system/routes/sessions/table.component.ts | 14 ++-- .../portal/routes/updates/item.component.ts | 72 ++++++----------- .../routes/updates/updates.component.ts | 70 ++++++++-------- .../ui/src/app/services/badge.service.ts | 12 ++- .../src/app/services/notification.service.ts | 9 ++- web/projects/ui/src/styles.scss | 41 +--------- 45 files changed, 362 insertions(+), 503 deletions(-) rename web/projects/{ui/src/app/routes/portal/routes/services/routes => shared/src/components}/markdown.component.ts (56%) delete mode 100644 web/projects/shared/src/components/markdown/markdown.component.html delete mode 100644 web/projects/shared/src/components/markdown/markdown.component.module.ts delete mode 100644 web/projects/shared/src/components/markdown/markdown.component.scss delete mode 100644 web/projects/shared/src/components/markdown/markdown.component.ts rename web/projects/shared/src/pipes/{markdown => }/markdown.pipe.ts (92%) delete mode 100644 web/projects/shared/src/pipes/markdown/markdown.module.ts rename web/projects/ui/src/app/routes/portal/{components/header => routes/system/routes/general}/snek.component.ts (99%) rename web/projects/ui/src/app/routes/portal/{components/header => routes/system/routes/general}/snek.directive.ts (80%) delete mode 100644 web/projects/ui/src/app/routes/portal/routes/system/routes/general/sync.component.ts diff --git a/web/projects/marketplace/src/modals/release-notes.component.ts b/web/projects/marketplace/src/modals/release-notes.component.ts index 4faae4c89..0d1f655db 100644 --- a/web/projects/marketplace/src/modals/release-notes.component.ts +++ b/web/projects/marketplace/src/modals/release-notes.component.ts @@ -1,6 +1,6 @@ import { CommonModule } from '@angular/common' import { ChangeDetectionStrategy, Component, inject } from '@angular/core' -import { Exver, MarkdownPipeModule } from '@start9labs/shared' +import { Exver, MarkdownPipe } from '@start9labs/shared' import { TuiButton, TuiDialogContext, TuiLoader } from '@taiga-ui/core' import { TuiAccordion } from '@taiga-ui/kit' import { injectContext, PolymorpheusComponent } from '@taiga-ui/polymorpheus' @@ -21,13 +21,7 @@ import { MarketplacePkg } from '../../src/types' `, changeDetection: ChangeDetectionStrategy.OnPush, - imports: [ - CommonModule, - TuiButton, - TuiLoader, - TuiAccordion, - MarkdownPipeModule, - ], + imports: [CommonModule, TuiButton, TuiLoader, TuiAccordion, MarkdownPipe], }) export class ReleaseNotesComponent { private readonly exver = inject(Exver) diff --git a/web/projects/marketplace/src/pages/show/about/about.module.ts b/web/projects/marketplace/src/pages/show/about/about.module.ts index 93781313f..c3a5a878a 100644 --- a/web/projects/marketplace/src/pages/show/about/about.module.ts +++ b/web/projects/marketplace/src/pages/show/about/about.module.ts @@ -5,7 +5,7 @@ import { NgModule } from '@angular/core' import { RouterModule } from '@angular/router' import { AboutComponent } from './about.component' import { NgDompurifyModule } from '@tinkoff/ng-dompurify' -import { MarkdownPipeModule, SafeLinksDirective } from '@start9labs/shared' +import { MarkdownPipe, SafeLinksDirective } from '@start9labs/shared' @NgModule({ imports: [ @@ -14,7 +14,7 @@ import { MarkdownPipeModule, SafeLinksDirective } from '@start9labs/shared' TuiTagModule, NgDompurifyModule, SafeLinksDirective, - MarkdownPipeModule, + MarkdownPipe, TuiButton, ], declarations: [AboutComponent], diff --git a/web/projects/ui/src/app/routes/portal/routes/services/routes/markdown.component.ts b/web/projects/shared/src/components/markdown.component.ts similarity index 56% rename from web/projects/ui/src/app/routes/portal/routes/services/routes/markdown.component.ts rename to web/projects/shared/src/components/markdown.component.ts index 7bb0cc420..11962e5bd 100644 --- a/web/projects/ui/src/app/routes/portal/routes/services/routes/markdown.component.ts +++ b/web/projects/shared/src/components/markdown.component.ts @@ -1,14 +1,13 @@ import { ChangeDetectionStrategy, Component, inject } from '@angular/core' import { toSignal } from '@angular/core/rxjs-interop' -import { ActivatedRoute } from '@angular/router' -import { - getErrorMessage, - MarkdownPipeModule, - SafeLinksDirective, -} from '@start9labs/shared' -import { TuiLoader, TuiNotification } from '@taiga-ui/core' +import { ActivatedRoute, Data } from '@angular/router' +import { TuiDialogContext, TuiLoader, TuiNotification } from '@taiga-ui/core' +import { injectContext, PolymorpheusComponent } from '@taiga-ui/polymorpheus' import { NgDompurifyModule } from '@tinkoff/ng-dompurify' import { catchError, ignoreElements, of } from 'rxjs' +import { SafeLinksDirective } from '../directives/safe-links.directive' +import { MarkdownPipe } from '../pipes/markdown.pipe' +import { getErrorMessage } from '../services/error.service' @Component({ template: ` @@ -21,7 +20,7 @@ import { catchError, ignoreElements, of } from 'rxjs' @if (content(); as result) {
} @else { - + } `, changeDetection: ChangeDetectionStrategy.OnPush, @@ -30,13 +29,15 @@ import { catchError, ignoreElements, of } from 'rxjs' imports: [ TuiNotification, TuiLoader, - MarkdownPipeModule, NgDompurifyModule, + MarkdownPipe, SafeLinksDirective, ], }) -export default class ServiceMarkdownRoute { - private readonly data = inject(ActivatedRoute).snapshot.data +export class MarkdownComponent { + private readonly data = + injectContext>({ optional: true })?.data || + inject(ActivatedRoute).snapshot.data readonly content = toSignal(this.data['content']) readonly error = toSignal( @@ -46,3 +47,5 @@ export default class ServiceMarkdownRoute { ), ) } + +export const MARKDOWN = new PolymorpheusComponent(MarkdownComponent) diff --git a/web/projects/shared/src/components/markdown/markdown.component.html b/web/projects/shared/src/components/markdown/markdown.component.html deleted file mode 100644 index b58546737..000000000 --- a/web/projects/shared/src/components/markdown/markdown.component.html +++ /dev/null @@ -1,18 +0,0 @@ - - {{ error }} - - -
- - - - diff --git a/web/projects/shared/src/components/markdown/markdown.component.module.ts b/web/projects/shared/src/components/markdown/markdown.component.module.ts deleted file mode 100644 index 0666dce63..000000000 --- a/web/projects/shared/src/components/markdown/markdown.component.module.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { CommonModule } from '@angular/common' -import { NgModule } from '@angular/core' -import { TuiLoader, TuiNotification } from '@taiga-ui/core' -import { NgDompurifyModule } from '@tinkoff/ng-dompurify' -import { SafeLinksDirective } from '../../directives/safe-links.directive' - -import { MarkdownPipeModule } from '../../pipes/markdown/markdown.module' -import { MarkdownComponent } from './markdown.component' - -@NgModule({ - declarations: [MarkdownComponent], - imports: [ - CommonModule, - MarkdownPipeModule, - SafeLinksDirective, - NgDompurifyModule, - TuiLoader, - TuiNotification, - ], - exports: [MarkdownComponent], -}) -export class MarkdownModule {} diff --git a/web/projects/shared/src/components/markdown/markdown.component.scss b/web/projects/shared/src/components/markdown/markdown.component.scss deleted file mode 100644 index 590950151..000000000 --- a/web/projects/shared/src/components/markdown/markdown.component.scss +++ /dev/null @@ -1,18 +0,0 @@ -.content-padding { - padding: 0 16px 16px 16px; -} - -:host ::ng-deep img { - border-radius: 0 !important; -} - -:host ::ng-deep h1, -:host ::ng-deep h2, -:host ::ng-deep h3, -:host ::ng-deep h4, -:host ::ng-deep h5, -:host ::ng-deep h6, -:host ::ng-deep hr, -:host ::ng-deep p { - margin: revert; -} \ No newline at end of file diff --git a/web/projects/shared/src/components/markdown/markdown.component.ts b/web/projects/shared/src/components/markdown/markdown.component.ts deleted file mode 100644 index 23b4b1a73..000000000 --- a/web/projects/shared/src/components/markdown/markdown.component.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { Component, Inject } from '@angular/core' -import { TuiDialogContext } from '@taiga-ui/core' -import { - POLYMORPHEUS_CONTEXT, - PolymorpheusComponent, -} from '@taiga-ui/polymorpheus' -import { - catchError, - ignoreElements, - share, - defer, - isObservable, - Observable, - of, -} from 'rxjs' - -import { getErrorMessage } from '../../services/error.service' - -@Component({ - selector: 'markdown', - templateUrl: './markdown.component.html', - styleUrls: ['./markdown.component.scss'], -}) -export class MarkdownComponent { - readonly content$ = defer(() => - isObservable(this.context.data.content) - ? this.context.data.content - : of(this.context.data.content), - ).pipe(share()) - - readonly error$ = this.content$.pipe( - ignoreElements(), - catchError(e => of(getErrorMessage(e))), - ) - - constructor( - @Inject(POLYMORPHEUS_CONTEXT) - private readonly context: TuiDialogContext< - void, - { content: string | Observable } - >, - ) {} - - get title(): string { - return this.context.label || '' - } -} - -export const MARKDOWN = new PolymorpheusComponent(MarkdownComponent) diff --git a/web/projects/shared/src/pipes/markdown/markdown.pipe.ts b/web/projects/shared/src/pipes/markdown.pipe.ts similarity index 92% rename from web/projects/shared/src/pipes/markdown/markdown.pipe.ts rename to web/projects/shared/src/pipes/markdown.pipe.ts index bd6bb8630..5b1dd0ffe 100644 --- a/web/projects/shared/src/pipes/markdown/markdown.pipe.ts +++ b/web/projects/shared/src/pipes/markdown.pipe.ts @@ -2,6 +2,7 @@ import { Pipe, PipeTransform } from '@angular/core' import { marked } from 'marked' @Pipe({ + standalone: true, name: 'markdown', }) export class MarkdownPipe implements PipeTransform { diff --git a/web/projects/shared/src/pipes/markdown/markdown.module.ts b/web/projects/shared/src/pipes/markdown/markdown.module.ts deleted file mode 100644 index ca39a43a5..000000000 --- a/web/projects/shared/src/pipes/markdown/markdown.module.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { NgModule } from '@angular/core' -import { MarkdownPipe } from './markdown.pipe' - -@NgModule({ - declarations: [MarkdownPipe], - exports: [MarkdownPipe], -}) -export class MarkdownPipeModule {} diff --git a/web/projects/shared/src/public-api.ts b/web/projects/shared/src/public-api.ts index 0f4b2c84b..dfc2e7e3d 100644 --- a/web/projects/shared/src/public-api.ts +++ b/web/projects/shared/src/public-api.ts @@ -10,11 +10,10 @@ export * from './components/initializing/initializing.component' export * from './components/loading/loading.component' export * from './components/loading/loading.component' export * from './components/loading/loading.service' -export * from './components/markdown/markdown.component' -export * from './components/markdown/markdown.component.module' export * from './components/ticker/ticker.component' export * from './components/ticker/ticker.module' export * from './components/drive.component' +export * from './components/markdown.component' export * from './components/server.component' export * from './directives/drag-scroller.directive' @@ -22,14 +21,13 @@ export * from './directives/safe-links.directive' export * from './pipes/exver/exver.module' export * from './pipes/exver/exver.pipe' -export * from './pipes/markdown/markdown.module' -export * from './pipes/markdown/markdown.pipe' export * from './pipes/shared/shared.module' export * from './pipes/shared/empty.pipe' export * from './pipes/shared/includes.pipe' export * from './pipes/shared/trust.pipe' export * from './pipes/unit-conversion/unit-conversion.module' export * from './pipes/unit-conversion/unit-conversion.pipe' +export * from './pipes/markdown.pipe' export * from './services/copy.service' export * from './services/download-html.service' diff --git a/web/projects/ui/src/app/components/report.component.ts b/web/projects/ui/src/app/components/report.component.ts index df60e4722..e28c37aa2 100644 --- a/web/projects/ui/src/app/components/report.component.ts +++ b/web/projects/ui/src/app/components/report.component.ts @@ -1,55 +1,47 @@ import { CommonModule } from '@angular/common' -import { ChangeDetectionStrategy, Component, inject } from '@angular/core' -import { TuiDialogContext, TuiIcon } from '@taiga-ui/core' -import { - POLYMORPHEUS_CONTEXT, - PolymorpheusComponent, -} from '@taiga-ui/polymorpheus' +import { ChangeDetectionStrategy, Component } from '@angular/core' +import { TuiDialogContext, TuiIcon, TuiTitle } from '@taiga-ui/core' +import { TuiCell } from '@taiga-ui/layout' +import { injectContext, PolymorpheusComponent } from '@taiga-ui/polymorpheus' import { BackupReport } from 'src/app/services/api/api.types' @Component({ template: ` -

Completed: {{ timestamp | date: 'medium' }}

-
-
+

Completed: {{ data.createdAt | date: 'medium' }}

+
+
System data -
{{ system.result }}
+
{{ system.result }}
-
-
- {{ pkg.key }} -
- {{ pkg.value.error ? 'Failed: ' + pkg.value.error : 'Succeeded' }} + @for (pkg of data.content.packages | keyvalue; track $index) { +
+
+ {{ pkg.key }} +
+ {{ pkg.value.error ? 'Failed: ' + pkg.value.error : 'Succeeded' }} +
+
- -
+ } `, changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, - imports: [CommonModule, TuiIcon], + imports: [CommonModule, TuiIcon, TuiCell, TuiTitle], }) export class BackupsReportModal { - private readonly context = - inject< - TuiDialogContext - >(POLYMORPHEUS_CONTEXT) + readonly data = + injectContext< + TuiDialogContext + >().data readonly system = this.getSystem() - get report(): BackupReport { - return this.context.data.content - } - - get timestamp(): string { - return this.context.data.timestamp - } - getColor(error: unknown) { return error ? 'var(--tui-text-negative)' : 'var(--tui-text-positive)' } @@ -59,7 +51,7 @@ export class BackupsReportModal { } private getSystem() { - if (!this.report.server.attempted) { + if (!this.data.content.server.attempted) { return { result: 'Not Attempted', icon: '@tui.minus', @@ -67,9 +59,9 @@ export class BackupsReportModal { } } - if (this.report.server.error) { + if (this.data.content.server.error) { return { - result: `Failed: ${this.report.server.error}`, + result: `Failed: ${this.data.content.server.error}`, icon: '@tui.circle-minus', color: 'var(--tui-text-negative)', } diff --git a/web/projects/ui/src/app/i18n/dictionaries/english.ts b/web/projects/ui/src/app/i18n/dictionaries/english.ts index 79e6da6e0..04ebe9fac 100644 --- a/web/projects/ui/src/app/i18n/dictionaries/english.ts +++ b/web/projects/ui/src/app/i18n/dictionaries/english.ts @@ -44,11 +44,6 @@ export default { check: 'Check for updates', }, }, - sync: { - title: 'Clock sync failure', - subtitle: - 'This will cause connectivity issues. To resolve it, refer to the', - }, }, }, } diff --git a/web/projects/ui/src/app/i18n/dictionaries/spanish.ts b/web/projects/ui/src/app/i18n/dictionaries/spanish.ts index 334ebfe80..a92abf211 100644 --- a/web/projects/ui/src/app/i18n/dictionaries/spanish.ts +++ b/web/projects/ui/src/app/i18n/dictionaries/spanish.ts @@ -46,11 +46,6 @@ export default { check: 'Buscar actualizaciones', }, }, - sync: { - title: 'Fallo en la sincronización del reloj', - subtitle: - 'Esto causará problemas de conectividad. Para resolverlo, consulta la', - }, }, }, } satisfies i18n diff --git a/web/projects/ui/src/app/routes/portal/components/header/header.component.ts b/web/projects/ui/src/app/routes/portal/components/header/header.component.ts index 4278a5c2b..aa44c1bec 100644 --- a/web/projects/ui/src/app/routes/portal/components/header/header.component.ts +++ b/web/projects/ui/src/app/routes/portal/components/header/header.component.ts @@ -6,13 +6,9 @@ import { viewChild, ViewContainerRef, } from '@angular/core' -import { toSignal } from '@angular/core/rxjs-interop' -import { PatchDB } from 'patch-db-client' -import { DataModel } from 'src/app/services/patch-db/data-model' import { TitleService } from 'src/app/services/title.service' import { HeaderMenuComponent } from './menu.component' import { HeaderNavigationComponent } from './navigation.component' -import { HeaderSnekDirective } from './snek.directive' import { HeaderStatusComponent } from './status.component' @Component({ @@ -21,12 +17,6 @@ import { HeaderStatusComponent } from './status.component'
- Play Snake
@@ -105,19 +95,6 @@ import { HeaderStatusComponent } from './status.component' } } - .snek { - @include center-top(); - @include transition(opacity); - right: 2rem; - width: 1rem; - opacity: 0.2; - cursor: pointer; - - &:hover { - opacity: 1; - } - } - :host-context(tui-root._mobile) { .item_center::before { left: -2rem; @@ -144,7 +121,6 @@ import { HeaderStatusComponent } from './status.component' imports: [ HeaderStatusComponent, HeaderNavigationComponent, - HeaderSnekDirective, HeaderMenuComponent, ], }) @@ -152,15 +128,6 @@ export class HeaderComponent implements OnInit { private readonly title = inject(TitleService) readonly vcr = viewChild.required('vcr', { read: ViewContainerRef }) - readonly snekScore = toSignal( - inject>(PatchDB).watch$( - 'ui', - 'gaming', - 'snake', - 'highScore', - ), - { initialValue: 0 }, - ) ngOnInit() { this.title.register(this.vcr()) diff --git a/web/projects/ui/src/app/routes/portal/components/interfaces/clearnet.component.ts b/web/projects/ui/src/app/routes/portal/components/interfaces/clearnet.component.ts index ce9981dde..13ff087e5 100644 --- a/web/projects/ui/src/app/routes/portal/components/interfaces/clearnet.component.ts +++ b/web/projects/ui/src/app/routes/portal/components/interfaces/clearnet.component.ts @@ -63,7 +63,7 @@ type ClearnetForm = { } @@ -27,7 +28,7 @@ import { BackupsRestoreService } from './services/restore.service' host: { class: 'g-page' }, changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, - imports: [BackupsUpcomingComponent, TuiIcon], + imports: [BackupsUpcomingComponent, TuiIcon, TuiCell, TuiTitle], }) export default class BackupsComponent { private readonly dialogs = inject(TuiDialogService) diff --git a/web/projects/ui/src/app/routes/portal/routes/backups/modals/backup.component.ts b/web/projects/ui/src/app/routes/portal/routes/backups/modals/backup.component.ts index 56b355eda..58308851f 100644 --- a/web/projects/ui/src/app/routes/portal/routes/backups/modals/backup.component.ts +++ b/web/projects/ui/src/app/routes/portal/routes/backups/modals/backup.component.ts @@ -31,10 +31,8 @@ interface Package { @if (pkgs) { @for (pkg of pkgs; track $index) {