-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c125a3
commit 46cb545
Showing
6 changed files
with
206 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
owner: bluerobotics | ||
repo: cockpit | ||
provider: github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { contextBridge, ipcRenderer } from 'electron' | ||
|
||
contextBridge.exposeInMainWorld('electronAPI', { | ||
onUpdateAvailable: (callback: (info: any) => void) => | ||
ipcRenderer.on('update-available', (_event, info) => callback(info)), | ||
onUpdateDownloaded: (callback: (info: any) => void) => | ||
ipcRenderer.on('update-downloaded', (_event, info) => callback(info)), | ||
downloadUpdate: () => ipcRenderer.send('download-update'), | ||
installUpdate: () => ipcRenderer.send('install-update'), | ||
cancelUpdate: () => ipcRenderer.send('cancel-update'), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<template> | ||
<InteractionDialog | ||
v-model="showUpdateDialog" | ||
:title="dialogTitle" | ||
:message="dialogMessage" | ||
:variant="dialogVariant" | ||
:actions="dialogActions" | ||
/> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import InteractionDialog from '@/components/InteractionDialog.vue' | ||
const showUpdateDialog = ref(false) | ||
const dialogTitle = ref('') | ||
const dialogMessage = ref('') | ||
const dialogVariant = ref<'error' | 'info' | 'success' | 'warning' | 'text-only'>('info') | ||
const dialogActions = ref< | ||
Array<{ | ||
/** | ||
* The text of the button | ||
*/ | ||
text: string | ||
/** | ||
* The action to perform when the button is clicked | ||
*/ | ||
action: () => void | ||
/** | ||
* The color of the button | ||
*/ | ||
color: string | ||
}> | ||
>([]) | ||
/** | ||
* Interface for the electron API exposed through preload | ||
*/ | ||
declare global { | ||
/** | ||
* Extended Window interface with Electron API | ||
*/ | ||
interface Window { | ||
/** | ||
* Electron API for update management | ||
*/ | ||
electronAPI: { | ||
/** | ||
* Register callback for update available event | ||
*/ | ||
onUpdateAvailable: (callback: (info: any) => void) => void | ||
/** | ||
* Register callback for update downloaded event | ||
*/ | ||
onUpdateDownloaded: (callback: (info: any) => void) => void | ||
/** | ||
* Trigger update download | ||
*/ | ||
downloadUpdate: () => void | ||
/** | ||
* Trigger update installation | ||
*/ | ||
installUpdate: () => void | ||
/** | ||
* Cancel ongoing update | ||
*/ | ||
cancelUpdate: () => void | ||
} | ||
} | ||
} | ||
// Listen for update events | ||
window.electronAPI.onUpdateAvailable(() => { | ||
dialogTitle.value = 'Update Available' | ||
dialogMessage.value = 'A new version of the application is available. Would you like to download it now?' | ||
dialogVariant.value = 'info' | ||
dialogActions.value = [ | ||
{ | ||
text: 'Download', | ||
action: () => { | ||
window.electronAPI.downloadUpdate() | ||
showUpdateDialog.value = false | ||
}, | ||
color: 'primary', | ||
}, | ||
{ | ||
text: 'Not Now', | ||
action: () => { | ||
window.electronAPI.cancelUpdate() | ||
showUpdateDialog.value = false | ||
}, | ||
color: 'error', | ||
}, | ||
] | ||
showUpdateDialog.value = true | ||
}) | ||
window.electronAPI.onUpdateDownloaded(() => { | ||
dialogTitle.value = 'Update Ready to Install' | ||
dialogMessage.value = | ||
'The update has been downloaded. Would you like to install it now? The application will restart during installation.' | ||
dialogVariant.value = 'info' | ||
dialogActions.value = [ | ||
{ | ||
text: 'Install Now', | ||
action: () => { | ||
window.electronAPI.installUpdate() | ||
showUpdateDialog.value = false | ||
}, | ||
color: 'primary', | ||
}, | ||
{ | ||
text: 'Later', | ||
action: () => { | ||
showUpdateDialog.value = false | ||
}, | ||
color: 'error', | ||
}, | ||
] | ||
showUpdateDialog.value = true | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters