fix: fix building UI project (#2794)

* fix: fix building UI project

* fix makefile

* inputspec instead of config

---------

Co-authored-by: Matt Hill <mattnine@protonmail.com>
This commit is contained in:
Alex Inkin
2024-12-03 03:44:27 +04:00
committed by GitHub
parent 75e7556bfa
commit 9f640b24b3
54 changed files with 9188 additions and 6748 deletions

View File

@@ -1,8 +1,9 @@
import { Injectable } from '@angular/core'
import { AlertController } from '@ionic/angular'
import { inject, Injectable } from '@angular/core'
import { ErrorService, LoadingService } from '@start9labs/shared'
import { TuiDialogService } from '@taiga-ui/core'
import { PolymorpheusComponent } from '@tinkoff/ng-polymorpheus'
import { TUI_CONFIRM } from '@taiga-ui/kit'
import { PolymorpheusComponent } from '@taiga-ui/polymorpheus'
import { filter } from 'rxjs'
import { ActionSuccessPage } from 'src/app/modals/action-success/action-success.page'
import { ApiService } from 'src/app/services/api/embassy-api.service'
import { FormDialogService } from 'src/app/services/form-dialog.service'
@@ -29,14 +30,11 @@ const allowedStatuses = {
providedIn: 'root',
})
export class ActionService {
constructor(
private readonly api: ApiService,
private readonly dialogs: TuiDialogService,
private readonly alertCtrl: AlertController,
private readonly errorService: ErrorService,
private readonly loader: LoadingService,
private readonly formDialog: FormDialogService,
) {}
private readonly api = inject(ApiService)
private readonly dialogs = inject(TuiDialogService)
private readonly errorService = inject(ErrorService)
private readonly loader = inject(LoadingService)
private readonly formDialog = inject(FormDialogService)
async present(data: PackageActionData) {
const { pkgInfo, actionInfo } = data
@@ -53,25 +51,18 @@ export class ActionService {
})
} else {
if (actionInfo.metadata.warning) {
const alert = await this.alertCtrl.create({
header: 'Warning',
message: actionInfo.metadata.warning,
buttons: [
{
text: 'Cancel',
role: 'cancel',
this.dialogs
.open(TUI_CONFIRM, {
label: 'Warning',
size: 's',
data: {
no: 'Cancel',
yes: 'Run',
content: actionInfo.metadata.warning,
},
{
text: 'Run',
handler: () => {
this.execute(pkgInfo.id, actionInfo.id)
},
cssClass: 'enter-click',
},
],
cssClass: 'alert-warning-message',
})
await alert.present()
})
.pipe(filter(Boolean))
.subscribe(() => this.execute(pkgInfo.id, actionInfo.id))
} else {
this.execute(pkgInfo.id, actionInfo.id)
}
@@ -92,15 +83,18 @@ export class ActionService {
} else {
error = `There is no status for which this action may be run. This is a bug. Please file an issue with the service maintainer.`
}
const alert = await this.alertCtrl.create({
header: 'Forbidden',
message:
this.dialogs
.open(
error ||
`Action "${actionInfo.metadata.name}" can only be executed when service is ${statusesStr}`,
buttons: ['OK'],
cssClass: 'alert-error-message enter-click',
})
await alert.present()
`Action "${actionInfo.metadata.name}" can only be executed when service is ${statusesStr}`,
{
label: 'Forbidden',
size: 's',
},
)
.pipe(filter(Boolean))
.subscribe()
}
}

View File

@@ -5,10 +5,11 @@ import { TuiDialogOptions, TuiDialogService } from '@taiga-ui/core'
import { TuiConfirmData, TUI_CONFIRM } from '@taiga-ui/kit'
import { PatchDB } from 'patch-db-client'
import { defaultIfEmpty, filter, firstValueFrom } from 'rxjs'
import {
ConfigModal,
PackageConfigData,
} from 'src/app/routes/portal/modals/config.component'
// @TODO Alex implement config
// import {
// ConfigModal,
// PackageConfigData,
// } from 'src/app/routes/portal/modals/config.component'
import { ApiService } from 'src/app/services/api/embassy-api.service'
import { FormDialogService } from 'src/app/services/form-dialog.service'
import { DataModel } from 'src/app/services/patch-db/data-model'
@@ -27,10 +28,10 @@ export class ActionsService {
private readonly patch = inject<PatchDB<DataModel>>(PatchDB)
configure(manifest: T.Manifest): void {
this.formDialog.open<PackageConfigData>(ConfigModal, {
label: `${manifest.title} configuration`,
data: { pkgId: manifest.id },
})
// this.formDialog.open<PackageConfigData>(ConfigModal, {
// label: `${manifest.title} configuration`,
// data: { pkgId: manifest.id },
// })
}
async start(manifest: T.Manifest, unmet: boolean): Promise<void> {

View File

@@ -3,7 +3,7 @@ import {
PackageDataEntry,
ServerStatusInfo,
} from 'src/app/services/patch-db/data-model'
import { RR, ServerNotifications } from './api.types'
import { RR, ServerMetrics, ServerNotifications } from './api.types'
import { BTC_ICON, LND_ICON, PROXY_ICON, REGISTRY_ICON } from './api-icons'
import { Log } from '@start9labs/shared'
import { configBuilderToSpec } from 'src/app/utils/configBuilderToSpec'

View File

@@ -2,11 +2,10 @@ import {
DomainInfo,
NetworkStrategy,
} from 'src/app/services/patch-db/data-model'
import { FetchLogsReq, FetchLogsRes } from '@start9labs/shared'
import { config } from '@start9labs/start-sdk'
import { FetchLogsReq, FetchLogsRes, Log } from '@start9labs/shared'
import { Dump } from 'patch-db-client'
import { DataModel } from 'src/app/services/patch-db/data-model'
import { StartOSDiskInfo, LogsRes, ServerLogsReq } from '@start9labs/shared'
import { StartOSDiskInfo } from '@start9labs/shared'
import { IST, T } from '@start9labs/start-sdk'
import { WebSocketSubjectConfig } from 'rxjs/webSocket'
@@ -232,8 +231,7 @@ export module RR {
// email
export type ConfigureEmailReq =
typeof config.constants.customSmtp.validator._TYPE // email.configure
export type ConfigureEmailReq = T.SmtpValue // email.configure
export type ConfigureEmailRes = null
export type TestEmailReq = ConfigureEmailReq & { to: string } // email.test
@@ -328,9 +326,18 @@ export module RR {
export type CreateBackupRes = null
// package
export type GetPackageLogsReq = ServerLogsReq & { id: string } // package.logs
export type GetPackageLogsRes = LogsRes
// @TODO Matt I just copy-pasted those types from minor
export type GetPackageLogsReq = {
id: string
before: boolean
cursor?: string
limit?: number
} // package.logs
export type GetPackageLogsRes = {
entries: Log[]
startCursor?: string
endCursor?: string
}
export type FollowPackageLogsReq = FollowServerLogsReq & { id: string } // package.logs.follow
export type FollowPackageLogsRes = FollowServerLogsRes

View File

@@ -249,7 +249,7 @@ function listValidators(spec: IST.ValueSpecList): ValidatorFn[] {
return validators
}
function fileValidators(spec: CT.ValueSpecFile): ValidatorFn[] {
function fileValidators(spec: IST.ValueSpecFile): ValidatorFn[] {
const validators: ValidatorFn[] = []
if (spec.required) {

View File

@@ -1,6 +1,5 @@
import { BackupJob, ServerNotifications } from '../api/api.types'
import { T } from '@start9labs/start-sdk'
import { config } from '@start9labs/start-sdk'
export type DataModel = {
ui: UIData
@@ -51,7 +50,7 @@ export type ServerInfo = {
pubkey: string
caFingerprint: string
ntpSynced: boolean
smtp: typeof config.constants.customSmtp.validator._TYPE
smtp: T.SmtpValue | null
passwordHash: string
platform: string
arch: string

View File

@@ -11,7 +11,7 @@ import { FormDialogService } from 'src/app/services/form-dialog.service'
import { configBuilderToSpec } from 'src/app/utils/configBuilderToSpec'
import { ApiService } from './api/embassy-api.service'
import { DataModel } from './patch-db/data-model'
import { CB } from '@start9labs/start-sdk'
import { ISB } from '@start9labs/start-sdk'
@Injectable({
providedIn: 'root',
@@ -29,18 +29,19 @@ export class ProxyService {
const network = await firstValueFrom(
this.patch.watch$('serverInfo', 'network'),
)
const config = CB.Config.of({
proxyId: CB.Value.select({
const config = ISB.InputSpec.of({
proxyId: ISB.Value.select({
name: 'Select Proxy',
required: { default: current },
default: current || '',
values: network.proxies
.filter(p => p.type === 'outbound' || p.type === 'inbound-outbound')
.reduce((prev, curr) => {
return {
.reduce<Record<string, string>>(
(prev, curr) => ({
[curr.id]: curr.name,
...prev,
}
}, {}),
}),
{},
),
}),
})

View File

@@ -95,7 +95,7 @@ export class StateService extends Observable<RR.ServerState | null> {
.open('Trying to reach server', {
label: 'State unknown',
autoClose: 0,
status: 'error',
appearance: 'negative',
})
.pipe(
takeUntil(
@@ -106,7 +106,7 @@ export class StateService extends Observable<RR.ServerState | null> {
),
this.alerts.open('Connection restored', {
label: 'Server reached',
status: 'success',
appearance: 'positive',
}),
),
),