Skip to content

Commit

Permalink
fixes missing updater
Browse files Browse the repository at this point in the history
  • Loading branch information
cars10 committed Dec 14, 2024
1 parent bce952e commit bd56e90
Show file tree
Hide file tree
Showing 20 changed files with 260 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.1.2

This version re-adds the automatic updater for the desktop app. Since the update to tauri 2.0
(done in elasticvue `1.1.0`) the automatic updater was missing. You need to manually install a new version of elasticvue
if you are using the desktop app. Sorry for the inconvenience.

## 1.1.1

* truncate long fields in search results table, fixes [#211](https://github.com/cars10/elasticvue/issues/211)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@tauri-apps/plugin-clipboard-manager": "2.0.1",
"@tauri-apps/plugin-dialog": "^2.0.1",
"@tauri-apps/plugin-fs": "^2.0.3",
"@tauri-apps/plugin-process": "~2",
"@tauri-apps/plugin-updater": "^2.0.0",
"codemirror": "^6.0.1",
"idb": "^8.0.0",
Expand Down
11 changes: 11 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ env_logger = "0.11.3"
tauri-plugin-fs = "2"
tauri-plugin-dialog = "2"
tauri-plugin-clipboard-manager = "2"
tauri-plugin-process = "2"

[features]
# by default Tauri runs in production mode
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/capabilities/desktop.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"linux"
],
"permissions": [
"updater:default"
"updater:default",
"process:default"
]
}
4 changes: 3 additions & 1 deletion src-tauri/capabilities/migrated.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
"core:app:allow-app-hide",
"fs:default",
"dialog:default",
"clipboard-manager:default"
"clipboard-manager:default",
"process:default",
"updater:default"
]
}
2 changes: 1 addition & 1 deletion src-tauri/gen/schemas/acl-manifests.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src-tauri/gen/schemas/capabilities.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"desktop-capability":{"identifier":"desktop-capability","description":"","local":true,"permissions":["updater:default"],"platforms":["macOS","windows","linux"]},"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:default","fs:allow-read-file","fs:allow-write-file","fs:allow-read-dir","fs:allow-copy-file","fs:allow-mkdir","fs:allow-remove","fs:allow-remove","fs:allow-rename","fs:allow-exists","core:window:allow-create","core:window:allow-center","core:window:allow-request-user-attention","core:window:allow-set-resizable","core:window:allow-set-maximizable","core:window:allow-set-minimizable","core:window:allow-set-closable","core:window:allow-set-title","core:window:allow-maximize","core:window:allow-unmaximize","core:window:allow-minimize","core:window:allow-unminimize","core:window:allow-show","core:window:allow-hide","core:window:allow-close","core:window:allow-set-decorations","core:window:allow-set-always-on-top","core:window:allow-set-content-protected","core:window:allow-set-size","core:window:allow-set-min-size","core:window:allow-set-max-size","core:window:allow-set-position","core:window:allow-set-fullscreen","core:window:allow-set-focus","core:window:allow-set-icon","core:window:allow-set-skip-taskbar","core:window:allow-set-cursor-grab","core:window:allow-set-cursor-visible","core:window:allow-set-cursor-icon","core:window:allow-set-cursor-position","core:window:allow-set-ignore-cursor-events","core:window:allow-start-dragging","core:webview:allow-print","dialog:allow-open","dialog:allow-save","dialog:allow-message","dialog:allow-ask","dialog:allow-confirm","clipboard-manager:allow-read-text","clipboard-manager:allow-write-text","core:app:allow-app-show","core:app:allow-app-hide","fs:default","dialog:default","clipboard-manager:default"]}}
{"desktop-capability":{"identifier":"desktop-capability","description":"","local":true,"permissions":["updater:default","process:default"],"platforms":["macOS","windows","linux"]},"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:default","fs:allow-read-file","fs:allow-write-file","fs:allow-read-dir","fs:allow-copy-file","fs:allow-mkdir","fs:allow-remove","fs:allow-remove","fs:allow-rename","fs:allow-exists","core:window:allow-create","core:window:allow-center","core:window:allow-request-user-attention","core:window:allow-set-resizable","core:window:allow-set-maximizable","core:window:allow-set-minimizable","core:window:allow-set-closable","core:window:allow-set-title","core:window:allow-maximize","core:window:allow-unmaximize","core:window:allow-minimize","core:window:allow-unminimize","core:window:allow-show","core:window:allow-hide","core:window:allow-close","core:window:allow-set-decorations","core:window:allow-set-always-on-top","core:window:allow-set-content-protected","core:window:allow-set-size","core:window:allow-set-min-size","core:window:allow-set-max-size","core:window:allow-set-position","core:window:allow-set-fullscreen","core:window:allow-set-focus","core:window:allow-set-icon","core:window:allow-set-skip-taskbar","core:window:allow-set-cursor-grab","core:window:allow-set-cursor-visible","core:window:allow-set-cursor-icon","core:window:allow-set-cursor-position","core:window:allow-set-ignore-cursor-events","core:window:allow-start-dragging","core:webview:allow-print","dialog:allow-open","dialog:allow-save","dialog:allow-message","dialog:allow-ask","dialog:allow-confirm","clipboard-manager:allow-read-text","clipboard-manager:allow-write-text","core:app:allow-app-show","core:app:allow-app-hide","fs:default","dialog:default","clipboard-manager:default","process:default","updater:default"]}}
25 changes: 25 additions & 0 deletions src-tauri/gen/schemas/desktop-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4728,6 +4728,31 @@
"type": "string",
"const": "fs:write-files"
},
{
"description": "This permission set configures which\nprocess feeatures are by default exposed.\n\n#### Granted Permissions\n\nThis enables to quit via `allow-exit` and restart via `allow-restart`\nthe application.\n",
"type": "string",
"const": "process:default"
},
{
"description": "Enables the exit command without any pre-configured scope.",
"type": "string",
"const": "process:allow-exit"
},
{
"description": "Enables the restart command without any pre-configured scope.",
"type": "string",
"const": "process:allow-restart"
},
{
"description": "Denies the exit command without any pre-configured scope.",
"type": "string",
"const": "process:deny-exit"
},
{
"description": "Denies the restart command without any pre-configured scope.",
"type": "string",
"const": "process:deny-restart"
},
{
"description": "This permission set configures which kind of\nupdater functions are exposed to the frontend.\n\n#### Granted Permissions\n\nThe full workflow from checking for updates to installing them\nis enabled.\n\n",
"type": "string",
Expand Down
25 changes: 25 additions & 0 deletions src-tauri/gen/schemas/linux-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4728,6 +4728,31 @@
"type": "string",
"const": "fs:write-files"
},
{
"description": "This permission set configures which\nprocess feeatures are by default exposed.\n\n#### Granted Permissions\n\nThis enables to quit via `allow-exit` and restart via `allow-restart`\nthe application.\n",
"type": "string",
"const": "process:default"
},
{
"description": "Enables the exit command without any pre-configured scope.",
"type": "string",
"const": "process:allow-exit"
},
{
"description": "Enables the restart command without any pre-configured scope.",
"type": "string",
"const": "process:allow-restart"
},
{
"description": "Denies the exit command without any pre-configured scope.",
"type": "string",
"const": "process:deny-exit"
},
{
"description": "Denies the restart command without any pre-configured scope.",
"type": "string",
"const": "process:deny-restart"
},
{
"description": "This permission set configures which kind of\nupdater functions are exposed to the frontend.\n\n#### Granted Permissions\n\nThe full workflow from checking for updates to installing them\nis enabled.\n\n",
"type": "string",
Expand Down
25 changes: 25 additions & 0 deletions src-tauri/gen/schemas/macOS-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4728,6 +4728,31 @@
"type": "string",
"const": "fs:write-files"
},
{
"description": "This permission set configures which\nprocess feeatures are by default exposed.\n\n#### Granted Permissions\n\nThis enables to quit via `allow-exit` and restart via `allow-restart`\nthe application.\n",
"type": "string",
"const": "process:default"
},
{
"description": "Enables the exit command without any pre-configured scope.",
"type": "string",
"const": "process:allow-exit"
},
{
"description": "Enables the restart command without any pre-configured scope.",
"type": "string",
"const": "process:allow-restart"
},
{
"description": "Denies the exit command without any pre-configured scope.",
"type": "string",
"const": "process:deny-exit"
},
{
"description": "Denies the restart command without any pre-configured scope.",
"type": "string",
"const": "process:deny-restart"
},
{
"description": "This permission set configures which kind of\nupdater functions are exposed to the frontend.\n\n#### Granted Permissions\n\nThe full workflow from checking for updates to installing them\nis enabled.\n\n",
"type": "string",
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn run() {
let ctx = tauri::generate_context!();

tauri::Builder::default()
.plugin(tauri_plugin_process::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_clipboard_manager::init())
.plugin(tauri_plugin_dialog::init())
Expand Down
2 changes: 2 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<modal-loader />
<alert-snackbar />
<update-check />

<app-footer />
</q-layout>
Expand All @@ -33,6 +34,7 @@
import { useThemeStore } from './store/theme.ts'
import { useConnectionStore } from './store/connection'
import { setAppThemeCss, setupThemeListener } from './helpers/theme.ts'
import UpdateCheck from './components/base/UpdateCheck.vue'
const themeStore = useThemeStore()
const connectionStore = useConnectionStore()
Expand Down
12 changes: 5 additions & 7 deletions src/components/base/AppFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
</div>

<div class="col-md-4 text-center">
<div class="text-subtitle-1">
Elasticvue {{ version }}-{{ VERSION_NAME }} |
<a href="https://github.com/cars10/elasticvue/blob/master/CHANGELOG.md" rel="nofollow" target="_blank"
class="decoration-none">
{{ t('base.app_footer.changelog') }}
</a>
<div>
Elasticvue {{ version }}-{{ VERSION_NAME }}
</div>
<div>
&copy;{{ new Date().getFullYear() }} - Carsten K&ouml;nig
</div>
&copy;{{ new Date().getFullYear() }} - Carsten K&ouml;nig
</div>

<div class="col-md-4 text-right">
Expand Down
56 changes: 56 additions & 0 deletions src/components/base/UpdateCheck.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<q-dialog v-model="dialog" transition-duration="100">
<q-card style="width: 500px">
<q-card-section class="flex justify-between">
<h2 class="text-h6 q-my-none">
{{ t('update_check.heading') }}
</h2>
<q-btn v-if="!downloading && !installing" v-close-popup icon="close" flat round dense />
</q-card-section>

<q-separator />

<q-card-section>
<div v-if="downloading">
{{ t('update_check.downloading', { progress: Math.floor(downloadProgress * 100) }) }}
<q-linear-progress instant-feedback :value="downloadProgress" size="12" class="q-mt-sm" />
</div>
<div v-else-if="installing">
{{ t('update_check.installing') }}
</div>
<div v-else>
{{ t('update_check.update_info', { version: updateInfo.version }) }}
</div>
</q-card-section>

<q-card-section v-if="!downloading && !installing">
<q-btn :label="t('update_check.yes')"
color="positive"
type="submit"
class="q-mr-md"
@click="downloadUpdate" />
<q-btn v-close-popup flat :label="t('defaults.cancel')" />
</q-card-section>
</q-card>
</q-dialog>
</template>

<script setup lang="ts">
import { onMounted } from 'vue'
import { useTranslation } from '../../composables/i18n.ts'
import { useUpdateCheck } from '../../composables/UpdateCheck.ts'
const t = useTranslation()
onMounted(() => checkUpdate())
const {
checkUpdate,
downloadUpdate,
downloading,
downloadProgress,
installing,
updateInfo,
dialog
} = useUpdateCheck()
</script>
64 changes: 64 additions & 0 deletions src/composables/UpdateCheck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Ref, ref } from 'vue'
import { check, Update } from '@tauri-apps/plugin-updater'
import { relaunch } from '@tauri-apps/plugin-process'

type UpdateInfo = {
version: string
}

export const useUpdateCheck = () => {
const dialog = ref(false)
const downloading = ref(false)
const downloadProgress = ref(0)
const installing = ref(false)
const updateInfo: Ref<UpdateInfo | null> = ref(null)
let update: Update | null = null

const checkUpdate = async () => {
update = await check()

if (update) {
updateInfo.value = { version: update.version }
dialog.value = true
} else {
updateInfo.value = null
}
}

const downloadUpdate = async () => {
if (!update) return

let downloaded = 0
let contentLength = 0

downloading.value = true

await update.downloadAndInstall((event) => {
switch (event.event) {
case 'Started':
contentLength = event.data.contentLength || -1
break
case 'Progress':
downloaded += event.data.chunkLength
downloadProgress.value = downloaded / contentLength
break
case 'Finished':
downloading.value = false
installing.value = true
break
}
})

await relaunch()
}

return {
checkUpdate,
downloadUpdate,
dialog,
downloading,
downloadProgress,
installing,
updateInfo
}
}
10 changes: 8 additions & 2 deletions src/locales/cn.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"base": {
"app_footer": {
"homepage": "主页",
"changelog": "变更日志"
"homepage": "主页"
},
"app_header": {
"navigation": {
Expand Down Expand Up @@ -641,6 +640,13 @@
}
}
},
"update_check": {
"downloading": "下载中... {progress}%",
"heading": "一个新的 elasticvue 版本可用。",
"installing": "正在安装更新,请稍候...",
"update_info": "Elasticvue {version} 可用。您现在想安装吗?",
"yes": ""
},
"welcome": {
"import_backup": {
"heading": "导入 elasticvue 的备份"
Expand Down
10 changes: 8 additions & 2 deletions src/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"base": {
"app_footer": {
"homepage": "Homepage",
"changelog": "Changelog"
"homepage": "Homepage"
},
"app_header": {
"navigation": {
Expand Down Expand Up @@ -641,6 +640,13 @@
}
}
},
"update_check": {
"downloading": "Downloading... {progress}%",
"heading": "A new version of elasticvue is available.",
"installing": "Installing update, please wait...",
"update_info": "Elasticvue {version} is available. Do you want to install it now?",
"yes": "Yes"
},
"welcome": {
"import_backup": {
"heading": "Import elasticvue backup"
Expand Down
Loading

0 comments on commit bd56e90

Please sign in to comment.