From 2e6e9635c315912a7cee546b66e8a556acb0a778 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sat, 12 Apr 2025 09:53:03 -0600 Subject: [PATCH] fix a few, more to go (#2869) * fix a few, more to go * chore: comments (#2871) * chore: comments * chore: typo * chore: stricter typescript (#2872) * chore: comments * chore: stricter typescript --------- Co-authored-by: Matt Hill * minor styling --------- Co-authored-by: Alex Inkin --- .../src/components/menu/menu.component.scss | 1 - .../initializing/logs-window.component.ts | 2 +- .../unit-conversion/unit-conversion.pipe.ts | 9 +- web/projects/shared/styles/shared.scss | 10 -- web/projects/ui/src/app/app.component.ts | 2 +- web/projects/ui/src/app/app.providers.ts | 2 +- web/projects/ui/src/app/i18n/i18n.service.ts | 2 +- .../app/routes/diagnostic/logs/logs.page.html | 2 +- .../form-multiselect.component.ts | 5 +- .../form/form-select/form-select.component.ts | 3 +- .../form/form-union/form-union.component.html | 2 +- .../form/form-union/form-union.component.ts | 4 +- .../interfaces/clearnet.component.ts | 14 +- .../components/interfaces/interface.utils.ts | 30 ++-- .../components/interfaces/local.component.ts | 2 +- .../components/interfaces/tor.component.ts | 23 ++- .../components/logs/logs-fetch.directive.ts | 2 +- .../components/logs/logs.component.html | 4 +- .../ui/src/app/routes/portal/portal.routes.ts | 4 +- .../portal/routes/logs/logs.component.ts | 15 +- .../components/action-request.component.ts | 22 ++- .../components/action-requests.component.ts | 9 +- .../services/components/controls.component.ts | 17 ++- .../components/dependencies.component.ts | 35 +++++ .../components/health-checks.component.ts | 1 + .../components/interfaces.component.ts | 2 +- .../services/components/status.component.ts | 15 +- .../services/dashboard/controls.component.ts | 9 -- .../services/modals/action-input.component.ts | 4 +- .../routes/services/routes/about.component.ts | 133 ++++++++++-------- .../services/routes/actions.component.ts | 32 ++--- .../services/routes/interface.component.ts | 14 +- .../services/routes/service.component.ts | 43 +++--- .../system/routes/acme/acme.component.ts | 6 +- .../system/routes/backups/backup.component.ts | 4 +- .../system/routes/backups/backup.service.ts | 7 +- .../routes/backups/network.component.ts | 13 +- .../routes/backups/recover.component.ts | 4 +- .../system/routes/general/snek.component.ts | 8 +- .../system/routes/general/update.component.ts | 2 +- .../routes/interfaces/interfaces.component.ts | 2 +- .../routes/sessions/sessions.component.ts | 8 +- .../routes/updates/updates.component.ts | 10 +- .../services/api/embassy-mock-api.service.ts | 22 +-- .../ui/src/app/services/badge.service.ts | 5 +- .../ui/src/app/services/config.service.ts | 17 +-- .../ui/src/app/services/controls.service.ts | 119 ++++++++-------- .../ui/src/app/services/dep-error.service.ts | 19 ++- .../ui/src/app/services/form.service.ts | 22 ++- .../src/app/services/marketplace.service.ts | 23 +-- web/projects/ui/src/app/utils/acme.ts | 7 +- web/projects/ui/src/app/utils/dry-update.ts | 5 +- .../ui/src/app/utils/system-utilities.ts | 4 +- web/projects/ui/src/styles.scss | 1 - web/tsconfig.json | 1 + 55 files changed, 440 insertions(+), 343 deletions(-) diff --git a/web/projects/marketplace/src/components/menu/menu.component.scss b/web/projects/marketplace/src/components/menu/menu.component.scss index d4ab0817f..760aef902 100644 --- a/web/projects/marketplace/src/components/menu/menu.component.scss +++ b/web/projects/marketplace/src/components/menu/menu.component.scss @@ -54,7 +54,6 @@ header { } store-icon { - margin-bottom: 0.75rem; border-radius: 100%; height: 64px; } diff --git a/web/projects/shared/src/components/initializing/logs-window.component.ts b/web/projects/shared/src/components/initializing/logs-window.component.ts index e6279cb07..04f793409 100644 --- a/web/projects/shared/src/components/initializing/logs-window.component.ts +++ b/web/projects/shared/src/components/initializing/logs-window.component.ts @@ -48,6 +48,6 @@ export class LogsWindowComponent { } onBottom(entries: readonly IntersectionObserverEntry[]) { - this.scroll = entries[entries.length - 1].isIntersecting + this.scroll = !!entries[entries.length - 1]?.isIntersecting } } diff --git a/web/projects/shared/src/pipes/unit-conversion/unit-conversion.pipe.ts b/web/projects/shared/src/pipes/unit-conversion/unit-conversion.pipe.ts index afdc48c48..cf149ac8c 100644 --- a/web/projects/shared/src/pipes/unit-conversion/unit-conversion.pipe.ts +++ b/web/projects/shared/src/pipes/unit-conversion/unit-conversion.pipe.ts @@ -25,9 +25,12 @@ export function convertBytes(bytes: number): string { export class DurationToSecondsPipe implements PipeTransform { transform(duration?: string | null): number { if (!duration) return 0 - const [, num, , unit] = - duration.match(/^([0-9]*(\.[0-9]+)?)(ns|µs|ms|s|m|d)$/) || [] - return Number(num) * unitsToSeconds[unit] + + const regex = /^([0-9]*(\.[0-9]+)?)(ns|µs|ms|s|m|d)$/ + const [, num, , unit] = duration.match(regex) || [] + const multiplier = (unit && unitsToSeconds[unit]) || NaN + + return unit ? Number(num) * multiplier : NaN } } diff --git a/web/projects/shared/styles/shared.scss b/web/projects/shared/styles/shared.scss index b4be91ecc..3833f2b0b 100644 --- a/web/projects/shared/styles/shared.scss +++ b/web/projects/shared/styles/shared.scss @@ -294,13 +294,3 @@ a { margin-right: 0.5rem; } } - -h1, -h2, -h3, -h4, -h5, -h6, -hr { - margin: 0; -} diff --git a/web/projects/ui/src/app/app.component.ts b/web/projects/ui/src/app/app.component.ts index d51e3b675..24d7c04c9 100644 --- a/web/projects/ui/src/app/app.component.ts +++ b/web/projects/ui/src/app/app.component.ts @@ -42,7 +42,7 @@ export class AppComponent implements OnInit { ngOnInit() { this.patch.watch$('ui').subscribe(({ name, language }) => { this.title.setTitle(name || 'StartOS') - this.i18n.setLanguage(language) + this.i18n.setLanguage(language || 'english') }) } } diff --git a/web/projects/ui/src/app/app.providers.ts b/web/projects/ui/src/app/app.providers.ts index a6cdf76c3..e73746cb4 100644 --- a/web/projects/ui/src/app/app.providers.ts +++ b/web/projects/ui/src/app/app.providers.ts @@ -114,6 +114,6 @@ export function appInitializer(): () => void { auth.init() localStorage.init() router.initialNavigation() - i18n.setLanguage(i18n.language) + i18n.setLanguage(i18n.language || 'english') } } diff --git a/web/projects/ui/src/app/i18n/i18n.service.ts b/web/projects/ui/src/app/i18n/i18n.service.ts index f40f92b57..85f7d3a83 100644 --- a/web/projects/ui/src/app/i18n/i18n.service.ts +++ b/web/projects/ui/src/app/i18n/i18n.service.ts @@ -13,7 +13,7 @@ export class i18nService extends TuiLanguageSwitcherService { readonly loading = signal(false) - override setLanguage(language: TuiLanguageName): void { + override setLanguage(language: TuiLanguageName = 'english'): void { if (this.language === language) { return } diff --git a/web/projects/ui/src/app/routes/diagnostic/logs/logs.page.html b/web/projects/ui/src/app/routes/diagnostic/logs/logs.page.html index 86a5b7303..df2def9fc 100644 --- a/web/projects/ui/src/app/routes/diagnostic/logs/logs.page.html +++ b/web/projects/ui/src/app/routes/diagnostic/logs/logs.page.html @@ -11,7 +11,7 @@
@if (loading) { diff --git a/web/projects/ui/src/app/routes/portal/components/form/form-multiselect/form-multiselect.component.ts b/web/projects/ui/src/app/routes/portal/components/form/form-multiselect/form-multiselect.component.ts index 9056e1e0f..f0b5a7934 100644 --- a/web/projects/ui/src/app/routes/portal/components/form/form-multiselect/form-multiselect.component.ts +++ b/web/projects/ui/src/app/routes/portal/components/form/form-multiselect/form-multiselect.component.ts @@ -16,7 +16,8 @@ export class FormMultiselectComponent extends Control< private readonly isDisabled = (item: string) => Array.isArray(this.spec.disabled) && - this.spec.disabled.includes(this.inverted[item]) + !!this.inverted[item] && + this.spec.disabled.includes(this.inverted[item]!) private readonly isExceedingLimit = (item: string) => !!this.spec.maxLength && @@ -44,6 +45,6 @@ export class FormMultiselectComponent extends Control< @tuiPure private memoize(value: null | readonly string[]): string[] { - return value?.map(key => this.spec.values[key]) || [] + return value?.map(key => this.spec.values[key] || '') || [] } } diff --git a/web/projects/ui/src/app/routes/portal/components/form/form-select/form-select.component.ts b/web/projects/ui/src/app/routes/portal/components/form/form-select/form-select.component.ts index ac478a4d1..832a12489 100644 --- a/web/projects/ui/src/app/routes/portal/components/form/form-select/form-select.component.ts +++ b/web/projects/ui/src/app/routes/portal/components/form/form-select/form-select.component.ts @@ -14,7 +14,8 @@ export class FormSelectComponent extends Control { readonly disabledItemHandler = (item: string) => Array.isArray(this.spec.disabled) && - this.spec.disabled.includes(this.inverted[item]) + !!this.inverted[item] && + this.spec.disabled.includes(this.inverted[item]!) get disabled(): boolean { return typeof this.spec.disabled === 'string' diff --git a/web/projects/ui/src/app/routes/portal/components/form/form-union/form-union.component.html b/web/projects/ui/src/app/routes/portal/components/form/form-union/form-union.component.html index 1cb5bfe57..513007d65 100644 --- a/web/projects/ui/src/app/routes/portal/components/form/form-union/form-union.component.html +++ b/web/projects/ui/src/app/routes/portal/components/form/form-union/form-union.component.html @@ -6,6 +6,6 @@ diff --git a/web/projects/ui/src/app/routes/portal/components/form/form-union/form-union.component.ts b/web/projects/ui/src/app/routes/portal/components/form/form-union/form-union.component.ts index e8602eeb0..9d889a9fa 100644 --- a/web/projects/ui/src/app/routes/portal/components/form/form-union/form-union.component.ts +++ b/web/projects/ui/src/app/routes/portal/components/form/form-union/form-union.component.ts @@ -38,11 +38,11 @@ export class FormUnionComponent implements OnChanges { @tuiPure onUnion(union: string) { - this.values[this.union] = this.form.control.controls['value'].value + this.values[this.union] = this.form.control.controls['value']?.value this.form.control.setControl( 'value', this.formService.getFormGroup( - union ? this.spec.variants[union].spec : {}, + union ? this.spec.variants[union]?.spec || {} : {}, [], this.values[union], ), 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 13ff087e5..1c7eed0b3 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 @@ -71,22 +71,14 @@ type ClearnetForm = { Make {{ isPublic() ? 'private' : 'public' }} @if (clearnet().length) { - + } @if (clearnet().length) { - +
@for (address of clearnet(); track $index) { - - +
{{ address.label }}{{ address.acme | acme }}{{ address.acme | acme }} {{ address.url | mask }}