Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions client/src/ui/BitbakeCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,22 @@ async function runTaskCommand (bitbakeWorkspace: BitbakeWorkspace, bitBakeProjec

export let isToasterStarted = false

function openToasterBrowser (): void {
const DEFAULT_TOASTER_PORT = 8000
const url = `http://localhost:${DEFAULT_TOASTER_PORT}`
void vscode.env.openExternal(vscode.Uri.parse(url)).then(success => {
if (!success) {
void vscode.window.showErrorMessage(`Failed to open URL ${url}`)
}
})
}

async function startToasterInBrowser (bitbakeDriver: BitbakeDriver): Promise<void> {
if (isToasterStarted) {
void vscode.window.showInformationMessage('Toaster is already started')
openToasterBrowser();
clientNotificationManager.showToasterStarted()
return
}
const DEFAULT_TOASTER_PORT = 8000
const command = `nohup bash -c "${bitbakeDriver.composeToasterCommand('start')}"`
const process = await runBitbakeTerminalCustomCommand(bitbakeDriver, command, 'Toaster')
process.onExit((e) => {
Expand All @@ -229,12 +239,8 @@ async function startToasterInBrowser (bitbakeDriver: BitbakeDriver): Promise<voi
return
}
isToasterStarted = true
const url = `http://localhost:${DEFAULT_TOASTER_PORT}`
void vscode.env.openExternal(vscode.Uri.parse(url)).then(success => {
if (!success) {
void vscode.window.showErrorMessage(`Failed to open URL ${url}`)
}
})
openToasterBrowser()
clientNotificationManager.showToasterStarted()
})
}

Expand Down
18 changes: 18 additions & 0 deletions client/src/ui/ClientNotificationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,24 @@ You can configure the sources' workspace to use the Yocto SDK for cross-compilat
})
}

showToasterStarted (): void {
void window.showInformationMessage(
'Toaster has been started and opened in your browser. Stop it with the "BitBake: Stop Toaster" command.',
'Re-open browser',
'Stop Toaster',
'Close'
)
.then((item) => {
if (item === 'Re-open browser') {
void commands.executeCommand('bitbake.start-toaster-in-browser')
} else if (item === 'Stop Toaster') {
void commands.executeCommand('bitbake.stop-toaster')
}
}, (reason) => {
logger.warn('Could not show toaster started dialog: ' + reason)
})
}

private neverShowAgain (method: string): Thenable<void> {
if (this._memento === undefined) {
throw new Error('ClientNotificationManager Memento not set')
Expand Down
Loading