mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 18:31:52 +00:00
ability to shutdown after install
This commit is contained in:
@@ -336,12 +336,46 @@ export default class DrivesPage {
|
||||
this.stateService.dataDriveGuid = result.guid
|
||||
this.stateService.attach = result.attach
|
||||
|
||||
if (result.attach) {
|
||||
this.stateService.setupType = 'attach'
|
||||
await this.router.navigate(['/password'])
|
||||
} else {
|
||||
await this.router.navigate(['/home'])
|
||||
}
|
||||
loader.unsubscribe()
|
||||
|
||||
// Show success dialog
|
||||
this.dialogs
|
||||
.openConfirm({
|
||||
label: 'Installation Complete!',
|
||||
size: 's',
|
||||
data: {
|
||||
content: 'StartOS has been installed successfully.',
|
||||
yes: 'Continue to Setup',
|
||||
no: 'Shutdown',
|
||||
},
|
||||
})
|
||||
.subscribe(continueSetup => {
|
||||
if (continueSetup) {
|
||||
this.navigateToNextStep(result.attach)
|
||||
} else {
|
||||
this.shutdownServer()
|
||||
}
|
||||
})
|
||||
} catch (e: any) {
|
||||
loader.unsubscribe()
|
||||
this.errorService.handleError(e)
|
||||
}
|
||||
}
|
||||
|
||||
private async navigateToNextStep(attach: boolean) {
|
||||
if (attach) {
|
||||
this.stateService.setupType = 'attach'
|
||||
await this.router.navigate(['/password'])
|
||||
} else {
|
||||
await this.router.navigate(['/home'])
|
||||
}
|
||||
}
|
||||
|
||||
private async shutdownServer() {
|
||||
const loader = this.loader.open('Beginning shutdown').subscribe()
|
||||
|
||||
try {
|
||||
await this.api.shutdown()
|
||||
} catch (e: any) {
|
||||
this.errorService.handleError(e)
|
||||
} finally {
|
||||
|
||||
@@ -73,7 +73,7 @@ import { SetupCompleteRes } from '../types'
|
||||
>
|
||||
<tui-avatar appearance="secondary" src="@tui.usb" />
|
||||
<div tuiTitle>
|
||||
{{ 'Remove USB Media' | i18n }}
|
||||
{{ 'USB Removed' | i18n }}
|
||||
<div tuiSubtitle>
|
||||
{{
|
||||
'Remove the USB installation media from your server' | i18n
|
||||
|
||||
@@ -46,6 +46,7 @@ export abstract class ApiService {
|
||||
// Completion
|
||||
abstract complete(): Promise<SetupCompleteRes> // setup.complete
|
||||
abstract exit(): Promise<void> // setup.exit
|
||||
abstract shutdown(): Promise<void> // setup.shutdown
|
||||
|
||||
// Logs & Progress
|
||||
abstract initFollowLogs(): Promise<FollowLogsRes> // setup.logs.follow
|
||||
|
||||
@@ -149,6 +149,13 @@ export class LiveApiService extends ApiService {
|
||||
})
|
||||
}
|
||||
|
||||
async shutdown() {
|
||||
await this.rpcRequest<void>({
|
||||
method: 'setup.shutdown',
|
||||
params: {},
|
||||
})
|
||||
}
|
||||
|
||||
async restart() {
|
||||
await this.rpcRequest<void>({
|
||||
method: 'setup.restart',
|
||||
|
||||
@@ -70,13 +70,13 @@ export class MockApiService extends ApiService {
|
||||
this.statusIndex++
|
||||
|
||||
if (this.statusIndex === 1) {
|
||||
// return { status: 'needs-install', keyboard: null }
|
||||
return {
|
||||
status: 'incomplete',
|
||||
attach: false,
|
||||
guid: 'mock-data-guid',
|
||||
keyboard: null,
|
||||
}
|
||||
return { status: 'needs-install', keyboard: null }
|
||||
// return {
|
||||
// status: 'incomplete',
|
||||
// attach: false,
|
||||
// guid: 'mock-data-guid',
|
||||
// keyboard: null,
|
||||
// }
|
||||
}
|
||||
|
||||
if (this.statusIndex > 3) {
|
||||
@@ -187,6 +187,10 @@ export class MockApiService extends ApiService {
|
||||
await pauseFor(500)
|
||||
}
|
||||
|
||||
async shutdown(): Promise<void> {
|
||||
await pauseFor(500)
|
||||
}
|
||||
|
||||
async restart(): Promise<void> {
|
||||
await pauseFor(500)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user