mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 22:39:46 +00:00
use dialogservice wrapper
This commit is contained in:
committed by
Aiden McClelland
parent
880aa8040d
commit
5e5aa5d830
@@ -6,12 +6,11 @@ import {
|
|||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
Validators,
|
Validators,
|
||||||
} from '@angular/forms'
|
} from '@angular/forms'
|
||||||
import { i18nPipe } from '@start9labs/shared'
|
import { DialogService, i18nPipe } from '@start9labs/shared'
|
||||||
import { T } from '@start9labs/start-sdk'
|
import { T } from '@start9labs/start-sdk'
|
||||||
import {
|
import {
|
||||||
TuiButton,
|
TuiButton,
|
||||||
TuiDialogContext,
|
TuiDialogContext,
|
||||||
TuiDialogService,
|
|
||||||
TuiError,
|
TuiError,
|
||||||
TuiIcon,
|
TuiIcon,
|
||||||
TuiTextfield,
|
TuiTextfield,
|
||||||
@@ -125,10 +124,9 @@ export interface CifsResult {
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class CifsComponent {
|
export class CifsComponent {
|
||||||
private readonly dialogs = inject(TuiDialogService)
|
private readonly dialogs = inject(DialogService)
|
||||||
private readonly api = inject(ApiService)
|
private readonly api = inject(ApiService)
|
||||||
private readonly context = injectContext<TuiDialogContext<CifsResult>>()
|
private readonly context = injectContext<TuiDialogContext<CifsResult>>()
|
||||||
private readonly i18n = inject(i18nPipe)
|
|
||||||
|
|
||||||
connecting = false
|
connecting = false
|
||||||
|
|
||||||
@@ -183,12 +181,10 @@ export class CifsComponent {
|
|||||||
|
|
||||||
private onFail() {
|
private onFail() {
|
||||||
this.dialogs
|
this.dialogs
|
||||||
.open(
|
.openAlert(
|
||||||
this.i18n.transform(
|
'Unable to connect to network folder. Ensure (1) target computer is connected to LAN, (2) target folder is being shared, and (3) hostname, path, and credentials are accurate.',
|
||||||
'Unable to connect to network folder. Ensure (1) target computer is connected to LAN, (2) target folder is being shared, and (3) hostname, path, and credentials are accurate.',
|
|
||||||
),
|
|
||||||
{
|
{
|
||||||
label: this.i18n.transform('Connection Failed'),
|
label: 'Connection Failed',
|
||||||
size: 's',
|
size: 's',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ import { ChangeDetectorRef, Component, inject } from '@angular/core'
|
|||||||
import { Router } from '@angular/router'
|
import { Router } from '@angular/router'
|
||||||
import { FormsModule } from '@angular/forms'
|
import { FormsModule } from '@angular/forms'
|
||||||
import {
|
import {
|
||||||
|
DialogService,
|
||||||
DiskInfo,
|
DiskInfo,
|
||||||
ErrorService,
|
ErrorService,
|
||||||
|
i18nKey,
|
||||||
i18nPipe,
|
i18nPipe,
|
||||||
LoadingService,
|
LoadingService,
|
||||||
toGuid,
|
toGuid,
|
||||||
@@ -11,18 +13,12 @@ import {
|
|||||||
import { TUI_IS_MOBILE } from '@taiga-ui/cdk'
|
import { TUI_IS_MOBILE } from '@taiga-ui/cdk'
|
||||||
import {
|
import {
|
||||||
TuiButton,
|
TuiButton,
|
||||||
TuiDialogService,
|
|
||||||
TuiIcon,
|
TuiIcon,
|
||||||
TuiLoader,
|
TuiLoader,
|
||||||
TuiTextfield,
|
TuiTextfield,
|
||||||
TuiTitle,
|
TuiTitle,
|
||||||
} from '@taiga-ui/core'
|
} from '@taiga-ui/core'
|
||||||
import {
|
import { TuiDataListWrapper, TuiSelect, TuiTooltip } from '@taiga-ui/kit'
|
||||||
TUI_CONFIRM,
|
|
||||||
TuiDataListWrapper,
|
|
||||||
TuiSelect,
|
|
||||||
TuiTooltip,
|
|
||||||
} from '@taiga-ui/kit'
|
|
||||||
import { TuiCardLarge, TuiHeader } from '@taiga-ui/layout'
|
import { TuiCardLarge, TuiHeader } from '@taiga-ui/layout'
|
||||||
import { PolymorpheusComponent } from '@taiga-ui/polymorpheus'
|
import { PolymorpheusComponent } from '@taiga-ui/polymorpheus'
|
||||||
import { filter } from 'rxjs'
|
import { filter } from 'rxjs'
|
||||||
@@ -171,7 +167,7 @@ import { PreserveOverwriteDialog } from '../components/preserve-overwrite.dialog
|
|||||||
export default class DrivesPage {
|
export default class DrivesPage {
|
||||||
private readonly api = inject(ApiService)
|
private readonly api = inject(ApiService)
|
||||||
private readonly router = inject(Router)
|
private readonly router = inject(Router)
|
||||||
private readonly dialogs = inject(TuiDialogService)
|
private readonly dialogs = inject(DialogService)
|
||||||
private readonly loader = inject(LoadingService)
|
private readonly loader = inject(LoadingService)
|
||||||
private readonly errorService = inject(ErrorService)
|
private readonly errorService = inject(ErrorService)
|
||||||
private readonly stateService = inject(StateService)
|
private readonly stateService = inject(StateService)
|
||||||
@@ -258,12 +254,15 @@ export default class DrivesPage {
|
|||||||
let selectionMade = false
|
let selectionMade = false
|
||||||
|
|
||||||
this.dialogs
|
this.dialogs
|
||||||
.open<boolean>(new PolymorpheusComponent(PreserveOverwriteDialog), {
|
.openComponent<boolean>(
|
||||||
label: this.i18n.transform('StartOS Data Detected'),
|
new PolymorpheusComponent(PreserveOverwriteDialog),
|
||||||
size: 's',
|
{
|
||||||
dismissible: true,
|
label: 'StartOS Data Detected',
|
||||||
closeable: true,
|
size: 's',
|
||||||
})
|
dismissible: true,
|
||||||
|
closeable: true,
|
||||||
|
},
|
||||||
|
)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: preserve => {
|
next: preserve => {
|
||||||
selectionMade = true
|
selectionMade = true
|
||||||
@@ -283,16 +282,16 @@ export default class DrivesPage {
|
|||||||
|
|
||||||
private showOsDriveWarning() {
|
private showOsDriveWarning() {
|
||||||
this.dialogs
|
this.dialogs
|
||||||
.open<boolean>(TUI_CONFIRM, {
|
.openConfirm({
|
||||||
label: this.i18n.transform('Warning'),
|
label: 'Warning',
|
||||||
size: 's',
|
size: 's',
|
||||||
data: {
|
data: {
|
||||||
content: `<ul>
|
content: `<ul>
|
||||||
<li class="g-negative">${this.i18n.transform('Data on the OS drive may be overwritten.')}</li>
|
<li class="g-negative">${this.i18n.transform('Data on the OS drive may be overwritten.')}</li>
|
||||||
<li class="g-positive">${this.i18n.transform('your StartOS data on the data drive will be preserved.')}</li>
|
<li class="g-positive">${this.i18n.transform('your StartOS data on the data drive will be preserved.')}</li>
|
||||||
</ul>`,
|
</ul>` as i18nKey,
|
||||||
yes: this.i18n.transform('Continue'),
|
yes: 'Continue',
|
||||||
no: this.i18n.transform('Cancel'),
|
no: 'Cancel',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.pipe(filter(Boolean))
|
.pipe(filter(Boolean))
|
||||||
@@ -307,13 +306,13 @@ export default class DrivesPage {
|
|||||||
: `<p class="g-negative">${this.i18n.transform('Data on both drives will be overwritten.')}</p>`
|
: `<p class="g-negative">${this.i18n.transform('Data on both drives will be overwritten.')}</p>`
|
||||||
|
|
||||||
this.dialogs
|
this.dialogs
|
||||||
.open<boolean>(TUI_CONFIRM, {
|
.openConfirm({
|
||||||
label: this.i18n.transform('Warning'),
|
label: 'Warning',
|
||||||
size: 's',
|
size: 's',
|
||||||
data: {
|
data: {
|
||||||
content: message,
|
content: message as i18nKey,
|
||||||
yes: this.i18n.transform('Continue'),
|
yes: 'Continue',
|
||||||
no: this.i18n.transform('Cancel'),
|
no: 'Cancel',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.pipe(filter(Boolean))
|
.pipe(filter(Boolean))
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ export default class LoadingPage {
|
|||||||
private readonly loader = inject(LoadingService)
|
private readonly loader = inject(LoadingService)
|
||||||
private readonly dialog = inject(DialogService)
|
private readonly dialog = inject(DialogService)
|
||||||
private readonly router = inject(Router)
|
private readonly router = inject(Router)
|
||||||
private readonly i18n = inject(i18nPipe)
|
|
||||||
|
|
||||||
readonly type = inject(StateService).setupType
|
readonly type = inject(StateService).setupType
|
||||||
readonly progress = toSignal(
|
readonly progress = toSignal(
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { Component, inject } from '@angular/core'
|
import { Component, inject } from '@angular/core'
|
||||||
import { Router } from '@angular/router'
|
import { Router } from '@angular/router'
|
||||||
import { ErrorService, i18nPipe } from '@start9labs/shared'
|
import { DialogService, ErrorService, i18nPipe } from '@start9labs/shared'
|
||||||
import { T } from '@start9labs/start-sdk'
|
import { T } from '@start9labs/start-sdk'
|
||||||
import {
|
import {
|
||||||
TuiButton,
|
TuiButton,
|
||||||
TuiDataList,
|
TuiDataList,
|
||||||
TuiDialogService,
|
|
||||||
TuiDropdown,
|
TuiDropdown,
|
||||||
TuiIcon,
|
TuiIcon,
|
||||||
TuiLoader,
|
TuiLoader,
|
||||||
@@ -123,10 +122,9 @@ import { UnlockPasswordDialog } from '../components/unlock-password.dialog'
|
|||||||
export default class RestorePage {
|
export default class RestorePage {
|
||||||
private readonly api = inject(ApiService)
|
private readonly api = inject(ApiService)
|
||||||
private readonly router = inject(Router)
|
private readonly router = inject(Router)
|
||||||
private readonly dialogs = inject(TuiDialogService)
|
private readonly dialogs = inject(DialogService)
|
||||||
private readonly errorService = inject(ErrorService)
|
private readonly errorService = inject(ErrorService)
|
||||||
private readonly stateService = inject(StateService)
|
private readonly stateService = inject(StateService)
|
||||||
private readonly i18n = inject(i18nPipe)
|
|
||||||
|
|
||||||
loading = true
|
loading = true
|
||||||
open = false
|
open = false
|
||||||
@@ -144,8 +142,8 @@ export default class RestorePage {
|
|||||||
openCifs() {
|
openCifs() {
|
||||||
this.open = false
|
this.open = false
|
||||||
this.dialogs
|
this.dialogs
|
||||||
.open<CifsResult>(CIFS, {
|
.openComponent<CifsResult>(CIFS, {
|
||||||
label: this.i18n.transform('Connect Network Folder'),
|
label: 'Connect Network Folder',
|
||||||
size: 's',
|
size: 's',
|
||||||
})
|
})
|
||||||
.subscribe(result => {
|
.subscribe(result => {
|
||||||
@@ -179,8 +177,8 @@ export default class RestorePage {
|
|||||||
servers: StartOSDiskInfoWithId[],
|
servers: StartOSDiskInfoWithId[],
|
||||||
) {
|
) {
|
||||||
this.dialogs
|
this.dialogs
|
||||||
.open<StartOSDiskInfoWithId | null>(SELECT_NETWORK_BACKUP, {
|
.openComponent<StartOSDiskInfoWithId | null>(SELECT_NETWORK_BACKUP, {
|
||||||
label: this.i18n.transform('Select Network Backup'),
|
label: 'Select Network Backup',
|
||||||
size: 's',
|
size: 's',
|
||||||
data: { servers },
|
data: { servers },
|
||||||
})
|
})
|
||||||
@@ -196,10 +194,13 @@ export default class RestorePage {
|
|||||||
target: { type: 'disk'; logicalname: string } | ({ type: 'cifs' } & T.Cifs),
|
target: { type: 'disk'; logicalname: string } | ({ type: 'cifs' } & T.Cifs),
|
||||||
) {
|
) {
|
||||||
this.dialogs
|
this.dialogs
|
||||||
.open<string | null>(new PolymorpheusComponent(UnlockPasswordDialog), {
|
.openComponent<string | null>(
|
||||||
label: this.i18n.transform('Unlock Backup'),
|
new PolymorpheusComponent(UnlockPasswordDialog),
|
||||||
size: 's',
|
{
|
||||||
})
|
label: 'Unlock Backup',
|
||||||
|
size: 's',
|
||||||
|
},
|
||||||
|
)
|
||||||
.subscribe(password => {
|
.subscribe(password => {
|
||||||
if (password) {
|
if (password) {
|
||||||
this.stateService.recoverySource = {
|
this.stateService.recoverySource = {
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
import { Component, inject } from '@angular/core'
|
import { Component, inject } from '@angular/core'
|
||||||
import { Router } from '@angular/router'
|
import { Router } from '@angular/router'
|
||||||
import { DiskInfo, ErrorService, i18nPipe, toGuid } from '@start9labs/shared'
|
import {
|
||||||
|
DialogService,
|
||||||
|
DiskInfo,
|
||||||
|
ErrorService,
|
||||||
|
i18nPipe,
|
||||||
|
toGuid,
|
||||||
|
} from '@start9labs/shared'
|
||||||
import {
|
import {
|
||||||
TuiButton,
|
TuiButton,
|
||||||
TuiDataList,
|
TuiDataList,
|
||||||
TuiDialogOptions,
|
|
||||||
TuiDialogService,
|
|
||||||
TuiDropdown,
|
TuiDropdown,
|
||||||
TuiIcon,
|
TuiIcon,
|
||||||
TuiLoader,
|
TuiLoader,
|
||||||
TuiTitle,
|
TuiTitle,
|
||||||
} from '@taiga-ui/core'
|
} from '@taiga-ui/core'
|
||||||
import { TUI_CONFIRM, TuiConfirmData } from '@taiga-ui/kit'
|
|
||||||
import { TuiCardLarge, TuiHeader } from '@taiga-ui/layout'
|
import { TuiCardLarge, TuiHeader } from '@taiga-ui/layout'
|
||||||
import { filter } from 'rxjs'
|
import { filter } from 'rxjs'
|
||||||
import { ApiService } from '../services/api.service'
|
import { ApiService } from '../services/api.service'
|
||||||
@@ -111,10 +114,9 @@ import { StateService } from '../services/state.service'
|
|||||||
export default class TransferPage {
|
export default class TransferPage {
|
||||||
private readonly api = inject(ApiService)
|
private readonly api = inject(ApiService)
|
||||||
private readonly router = inject(Router)
|
private readonly router = inject(Router)
|
||||||
private readonly dialogs = inject(TuiDialogService)
|
private readonly dialogs = inject(DialogService)
|
||||||
private readonly errorService = inject(ErrorService)
|
private readonly errorService = inject(ErrorService)
|
||||||
private readonly stateService = inject(StateService)
|
private readonly stateService = inject(StateService)
|
||||||
private readonly i18n = inject(i18nPipe)
|
|
||||||
|
|
||||||
loading = true
|
loading = true
|
||||||
open = false
|
open = false
|
||||||
@@ -132,20 +134,17 @@ export default class TransferPage {
|
|||||||
select(drive: DiskInfo) {
|
select(drive: DiskInfo) {
|
||||||
this.open = false
|
this.open = false
|
||||||
|
|
||||||
const WARNING_OPTIONS: Partial<TuiDialogOptions<TuiConfirmData>> = {
|
|
||||||
label: this.i18n.transform('Warning'),
|
|
||||||
size: 's',
|
|
||||||
data: {
|
|
||||||
content: this.i18n.transform(
|
|
||||||
'After transferring data from this drive, do not attempt to boot into it again as a Start9 Server. This may result in services malfunctioning, data corruption, or loss of funds.',
|
|
||||||
),
|
|
||||||
yes: this.i18n.transform('Continue'),
|
|
||||||
no: this.i18n.transform('Cancel'),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
this.dialogs
|
this.dialogs
|
||||||
.open(TUI_CONFIRM, WARNING_OPTIONS)
|
.openConfirm({
|
||||||
|
label: 'Warning',
|
||||||
|
size: 's',
|
||||||
|
data: {
|
||||||
|
content:
|
||||||
|
'After transferring data from this drive, do not attempt to boot into it again as a Start9 Server. This may result in services malfunctioning, data corruption, or loss of funds.',
|
||||||
|
yes: 'Continue',
|
||||||
|
no: 'Cancel',
|
||||||
|
},
|
||||||
|
})
|
||||||
.pipe(filter(Boolean))
|
.pipe(filter(Boolean))
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
const guid = toGuid(drive)
|
const guid = toGuid(drive)
|
||||||
|
|||||||
Reference in New Issue
Block a user