mirror of https://github.com/Fabio286/antares.git
Update system
This commit is contained in:
parent
0d10a93bf8
commit
42e0353393
|
@ -6,3 +6,4 @@ thumbs.db
|
|||
.vscode
|
||||
TODO.md
|
||||
*.txt
|
||||
dev-app-update.yml
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "antares",
|
||||
"productName": "Antares",
|
||||
"version": "0.0.0-alpha",
|
||||
"version": "0.0.1-alpha",
|
||||
"description": "A cross-platform easy to use SQL client.",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/Fabio286/antares.git",
|
||||
|
@ -15,7 +15,7 @@
|
|||
"author": "Fabio Di Stasio <fabio286@gmail.com>",
|
||||
"build": {
|
||||
"appId": "com.estarium.antares",
|
||||
"artifactName": "${productName}-${version}-${channel}-${os}_${arch}.${ext}",
|
||||
"artifactName": "${productName}-${version}-${os}_${arch}.${ext}",
|
||||
"files": [
|
||||
"static/*"
|
||||
]
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import { app, BrowserWindow, nativeImage } from 'electron';
|
||||
import * as path from 'path';
|
||||
import { format as formatUrl } from 'url';
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
|
||||
import ipcHandlers from './ipc-handlers';
|
||||
|
||||
|
@ -68,10 +67,6 @@ function createMainWindow () {
|
|||
// Initialize ipcHandlers
|
||||
ipcHandlers();
|
||||
|
||||
autoUpdater.checkForUpdatesAndNotify();
|
||||
autoUpdater.logger = require('electron-log');
|
||||
autoUpdater.logger.transports.file.level = 'info';
|
||||
|
||||
return window;
|
||||
};
|
||||
|
||||
|
@ -92,21 +87,3 @@ app.on('activate', () => {
|
|||
app.on('ready', () => {
|
||||
mainWindow = createMainWindow();
|
||||
});
|
||||
|
||||
// auto-updater events
|
||||
autoUpdater.on('checking-for-update', () => {
|
||||
});
|
||||
|
||||
autoUpdater.on('update-available', () => {
|
||||
mainWindow.webContents.send('update_available');
|
||||
});
|
||||
|
||||
autoUpdater.on('update-not-available', () => {
|
||||
});
|
||||
|
||||
autoUpdater.on('download-progress', (progressObj) => {
|
||||
});
|
||||
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
mainWindow.webContents.send('update_downloaded');
|
||||
});
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import connection from './connection';
|
||||
import structure from './structure';
|
||||
import updates from './updates';
|
||||
|
||||
const connections = {};
|
||||
|
||||
export default () => {
|
||||
connection(connections);
|
||||
structure(connections);
|
||||
updates();
|
||||
};
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
import { ipcMain } from 'electron';
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
|
||||
let mainWindow;
|
||||
|
||||
export default () => {
|
||||
ipcMain.on('checkForUpdates', event => {
|
||||
mainWindow = event;
|
||||
|
||||
autoUpdater.checkForUpdatesAndNotify().catch(() => {
|
||||
mainWindow.reply('checkFailed');
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on('restartToUpdate', () => {
|
||||
autoUpdater.quitAndInstall();
|
||||
});
|
||||
|
||||
// auto-updater events
|
||||
autoUpdater.on('checking-for-update', () => {
|
||||
mainWindow.reply('checkingForUpdate');
|
||||
});
|
||||
|
||||
autoUpdater.on('update-available', () => {
|
||||
mainWindow.reply('updateAvailable');
|
||||
});
|
||||
|
||||
autoUpdater.on('update-not-available', () => {
|
||||
mainWindow.reply('updateNotAvailable');
|
||||
});
|
||||
|
||||
autoUpdater.on('download-progress', (data) => {
|
||||
mainWindow.reply('downloadProgress', data);
|
||||
});
|
||||
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
mainWindow.reply('updateDownloaded');
|
||||
});
|
||||
|
||||
autoUpdater.logger = require('electron-log');
|
||||
autoUpdater.logger.transports.console.format = '{h}:{i}:{s} {text}';
|
||||
autoUpdater.logger.transports.file.level = 'info';
|
||||
};
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
<script>
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
import { ipcRenderer } from 'electron';
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
|
@ -51,6 +52,9 @@ export default {
|
|||
connections: 'connections/getConnections'
|
||||
})
|
||||
},
|
||||
mounted () {
|
||||
ipcRenderer.send('checkForUpdates');
|
||||
},
|
||||
methods: {
|
||||
...mapActions({
|
||||
showNewConnModal: 'application/showNewConnModal'
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
</div>
|
||||
|
||||
<div v-if="selectedTab === 'update'" class="panel-body py-4">
|
||||
<!-- -->
|
||||
<ModalSettingsUpdate />
|
||||
</div>
|
||||
|
||||
<div v-if="selectedTab === 'about'" class="panel-body py-4">
|
||||
|
@ -101,10 +101,14 @@
|
|||
<script>
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
import localesNames from '@/i18n/supported-locales';
|
||||
import ModalSettingsUpdate from '@/components/ModalSettingsUpdate';
|
||||
const { shell } = require('electron');
|
||||
|
||||
export default {
|
||||
name: 'ModalSettings',
|
||||
components: {
|
||||
ModalSettingsUpdate
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
isUpdate: false,
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
<template>
|
||||
<div class="empty">
|
||||
<div class="empty-icon">
|
||||
<i class="material-icons md-48">system_update_alt</i>
|
||||
</div>
|
||||
<p class="empty-title h5">
|
||||
{{ updateMessage }}
|
||||
</p>
|
||||
<div v-if="updateStatus === 'downloading'">
|
||||
<progress
|
||||
class="progress"
|
||||
:value="downloadPercentage"
|
||||
max="100"
|
||||
/>
|
||||
<p class="empty-subtitle">
|
||||
{{ downloadPercentage }}%
|
||||
</p>
|
||||
</div>
|
||||
<div class="empty-action">
|
||||
<button
|
||||
v-if="['noupdate', 'checking', 'nocheck'].includes(updateStatus)"
|
||||
class="btn btn-primary"
|
||||
:class="{'loading': updateStatus === 'checking'}"
|
||||
@click="checkForUpdates"
|
||||
>
|
||||
{{ $t('message.checkForUpdates') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="updateStatus === 'downloaded'"
|
||||
class="btn btn-primary"
|
||||
@click="restartToUpdate"
|
||||
>
|
||||
{{ $t('message.restartToInstall') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import { ipcRenderer } from 'electron';
|
||||
|
||||
export default {
|
||||
name: 'ModalSettingsUpdate',
|
||||
computed: {
|
||||
...mapGetters({
|
||||
updateStatus: 'application/getUpdateStatus',
|
||||
downloadPercentage: 'application/getDownloadProgress'
|
||||
}),
|
||||
updateMessage () {
|
||||
switch (this.updateStatus) {
|
||||
case 'noupdate':
|
||||
return this.$t('message.noUpdatesAvailable');
|
||||
case 'checking':
|
||||
return this.$t('message.checkingForUpdate');
|
||||
case 'nocheck':
|
||||
return this.$t('message.checkFailure');
|
||||
case 'available':
|
||||
return this.$t('message.updateAvailable');
|
||||
case 'downloading':
|
||||
return this.$t('message.downloadingUpdate');
|
||||
case 'downloaded':
|
||||
return this.$t('message.updateDownloaded');
|
||||
default:
|
||||
return this.updateStatus;
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
checkForUpdates () {
|
||||
ipcRenderer.send('checkForUpdates');
|
||||
},
|
||||
restartToUpdate () {
|
||||
ipcRenderer.send('restartToUpdate');
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.empty{
|
||||
color: $body-font-color;
|
||||
}
|
||||
</style>
|
|
@ -70,10 +70,12 @@ export default {
|
|||
case 'char':
|
||||
case 'varchar':
|
||||
case 'text':
|
||||
case 'mediumtext':
|
||||
return val.substring(0, 128);
|
||||
case 'date':
|
||||
return moment(val).format('YYYY-MM-DD');
|
||||
case 'datetime':
|
||||
case 'timestamp':
|
||||
return moment(val).format('YYYY-MM-DD HH:mm:ss.SSS');
|
||||
case 'blob':
|
||||
case 'mediumblob':
|
||||
|
|
|
@ -43,7 +43,15 @@ module.exports = {
|
|||
deleteConnection: 'Delete connection',
|
||||
deleteConnectionCorfirm: 'Do you confirm the cancellation of',
|
||||
connectionSuccessfullyMade: 'Connection successfully made!',
|
||||
madeWithJS: 'Made with 💛 and JavaScript!'
|
||||
madeWithJS: 'Made with 💛 and JavaScript!',
|
||||
checkForUpdates: 'Check for updates',
|
||||
noUpdatesAvailable: 'No updates available',
|
||||
checkingForUpdate: 'Checking for updates',
|
||||
checkFailure: 'Check failed, please try later',
|
||||
updateAvailable: 'Update available',
|
||||
downloadingUpdate: 'Downloading update',
|
||||
updateDownloaded: 'Update downloaded',
|
||||
restartToInstall: 'Restart Antares to install'
|
||||
},
|
||||
// Date and Time
|
||||
short: {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
"char": seagreen,
|
||||
"varchar": seagreen,
|
||||
"text": seagreen,
|
||||
"mediumtext": seagreen,
|
||||
|
||||
"int": cornflowerblue,
|
||||
"tinyint": cornflowerblue,
|
||||
|
@ -23,6 +24,7 @@
|
|||
"datetime": coral,
|
||||
"date": coral,
|
||||
"time": coral,
|
||||
"timestamp": coral,
|
||||
|
||||
"bit": lightskyblue,
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
@import "mdi-additions";
|
||||
@import "db-icons";
|
||||
@import "~spectre.css/src/spectre";
|
||||
@import "~spectre.css/src/spectre-exp";
|
||||
|
||||
body{
|
||||
user-select: none;
|
||||
|
|
|
@ -10,6 +10,8 @@ import connections from './modules/connections.store';
|
|||
import workspaces from './modules/workspaces.store';
|
||||
import notifications from './modules/notifications.store';
|
||||
|
||||
import ipcUpdates from './plugins/ipcUpdates';
|
||||
|
||||
const vuexLocalStorage = new VuexPersist({
|
||||
key: 'application', // The key to store the state on in the storage provider.
|
||||
storage: window.localStorage,
|
||||
|
@ -30,5 +32,8 @@ export default new Vuex.Store({
|
|||
workspaces,
|
||||
notifications
|
||||
},
|
||||
plugins: [vuexLocalStorage.plugin]
|
||||
plugins: [
|
||||
vuexLocalStorage.plugin,
|
||||
ipcUpdates
|
||||
]
|
||||
});
|
||||
|
|
|
@ -10,7 +10,9 @@ export default {
|
|||
is_edit_modal: false,
|
||||
is_setting_modal: false,
|
||||
selected_setting_tab: 'general',
|
||||
selected_conection: {}
|
||||
selected_conection: {},
|
||||
update_status: 'noupdate', // noupdate, available, checking, nocheck, downloading, downloaded
|
||||
download_progress: 0
|
||||
},
|
||||
getters: {
|
||||
isLoading: state => state.is_loading,
|
||||
|
@ -20,7 +22,9 @@ export default {
|
|||
isNewModal: state => state.is_new_modal,
|
||||
isEditModal: state => state.is_edit_modal,
|
||||
isSettingModal: state => state.is_setting_modal,
|
||||
selectedSettingTab: state => state.selected_setting_tab
|
||||
selectedSettingTab: state => state.selected_setting_tab,
|
||||
getUpdateStatus: state => state.update_status,
|
||||
getDownloadProgress: state => state.download_progress
|
||||
},
|
||||
mutations: {
|
||||
SET_LOADING_STATUS (state, payload) {
|
||||
|
@ -45,6 +49,12 @@ export default {
|
|||
},
|
||||
HIDE_SETTING_MODAL (state) {
|
||||
state.is_setting_modal = false;
|
||||
},
|
||||
CHANGE_UPDATE_STATUS (state, status) {
|
||||
state.update_status = status;
|
||||
},
|
||||
CHANGE_PROGRESS_PERCENTAGE (state, percentage) {
|
||||
state.download_progress = percentage;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
import { ipcRenderer } from 'electron';
|
||||
|
||||
export default store => {
|
||||
ipcRenderer.on('checkingForUpdate', () => {
|
||||
store.commit('application/CHANGE_UPDATE_STATUS', 'checking');
|
||||
});
|
||||
ipcRenderer.on('updateAvailable', () => {
|
||||
store.commit('application/CHANGE_UPDATE_STATUS', 'available');
|
||||
});
|
||||
ipcRenderer.on('updateNotAvailable', () => {
|
||||
store.commit('application/CHANGE_UPDATE_STATUS', 'noupdate');
|
||||
});
|
||||
ipcRenderer.on('checkFailed', () => {
|
||||
store.commit('application/CHANGE_UPDATE_STATUS', 'nocheck');
|
||||
});
|
||||
ipcRenderer.on('downloadProgress', (event, data) => {
|
||||
store.commit('application/CHANGE_UPDATE_STATUS', 'downloading');
|
||||
store.commit('application/CHANGE_PROGRESS_PERCENTAGE', data.percent);
|
||||
});
|
||||
ipcRenderer.on('updateDownloaded', () => {
|
||||
store.commit('application/CHANGE_UPDATE_STATUS', 'downloaded');
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue