diff --git a/.gitignore b/.gitignore index 66c6ef49..72ccc477 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ thumbs.db .idea/ .vscode TODO.md -*.txt \ No newline at end of file +*.txt +dev-app-update.yml \ No newline at end of file diff --git a/package.json b/package.json index 8a99e09e..fb82e1d1 100644 --- a/package.json +++ b/package.json @@ -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 ", "build": { "appId": "com.estarium.antares", - "artifactName": "${productName}-${version}-${channel}-${os}_${arch}.${ext}", + "artifactName": "${productName}-${version}-${os}_${arch}.${ext}", "files": [ "static/*" ] diff --git a/src/main/index.js b/src/main/index.js index b87c0cb2..6216a81b 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -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'); -}); diff --git a/src/main/ipc-handlers/index.js b/src/main/ipc-handlers/index.js index 154db989..39f3dd5f 100644 --- a/src/main/ipc-handlers/index.js +++ b/src/main/ipc-handlers/index.js @@ -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(); }; diff --git a/src/main/ipc-handlers/updates.js b/src/main/ipc-handlers/updates.js new file mode 100644 index 00000000..6f6acd90 --- /dev/null +++ b/src/main/ipc-handlers/updates.js @@ -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'; +}; diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 629490d0..9c698af9 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -24,6 +24,7 @@ + + diff --git a/src/renderer/components/WorkspaceQueryTable.vue b/src/renderer/components/WorkspaceQueryTable.vue index 81c43c23..16a0d17b 100644 --- a/src/renderer/components/WorkspaceQueryTable.vue +++ b/src/renderer/components/WorkspaceQueryTable.vue @@ -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': diff --git a/src/renderer/i18n/en-US.js b/src/renderer/i18n/en-US.js index 6fb652ed..741fa3a9 100644 --- a/src/renderer/i18n/en-US.js +++ b/src/renderer/i18n/en-US.js @@ -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: { diff --git a/src/renderer/scss/_data-types.scss b/src/renderer/scss/_data-types.scss index 108af629..a8271da7 100644 --- a/src/renderer/scss/_data-types.scss +++ b/src/renderer/scss/_data-types.scss @@ -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, diff --git a/src/renderer/scss/main.scss b/src/renderer/scss/main.scss index a43e362e..f9a7b15d 100644 --- a/src/renderer/scss/main.scss +++ b/src/renderer/scss/main.scss @@ -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; diff --git a/src/renderer/store/index.js b/src/renderer/store/index.js index a12a8bf8..b92b049d 100644 --- a/src/renderer/store/index.js +++ b/src/renderer/store/index.js @@ -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 + ] }); diff --git a/src/renderer/store/modules/application.store.js b/src/renderer/store/modules/application.store.js index 15b7028f..176b6a58 100644 --- a/src/renderer/store/modules/application.store.js +++ b/src/renderer/store/modules/application.store.js @@ -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: { diff --git a/src/renderer/store/plugins/ipcUpdates.js b/src/renderer/store/plugins/ipcUpdates.js new file mode 100644 index 00000000..422a087d --- /dev/null +++ b/src/renderer/store/plugins/ipcUpdates.js @@ -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'); + }); +};