From e349dd5eaba608591257f2799b830805e4936c27 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Sat, 3 Apr 2021 12:17:40 +0200 Subject: [PATCH] feat: scratchpad to save persistent notes --- README.md | 6 +- src/renderer/App.vue | 3 + src/renderer/components/BaseTextEditor.vue | 5 +- src/renderer/components/TheScratchpad.vue | 75 +++++++++++++++++++ src/renderer/components/TheSettingBar.vue | 3 +- src/renderer/i18n/en-US.js | 3 +- src/renderer/store/index.js | 2 + .../store/modules/application.store.js | 14 ++++ .../store/modules/scratchpad.store.js | 25 +++++++ 9 files changed, 130 insertions(+), 6 deletions(-) create mode 100644 src/renderer/components/TheScratchpad.vue create mode 100644 src/renderer/store/modules/scratchpad.store.js diff --git a/README.md b/README.md index fe7406f9..92d7d9c2 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,8 @@ A modern application created with minimalism and semplicity in mind, with featur - Fake table data filler. - Run queries on multiple tabs. - Query suggestions and auto complete. -- Native dark theme. +- Dark and light theme. +- Scratchpad. - Multi language. - Secure password storage. - Auto updates. @@ -51,7 +52,7 @@ A modern application created with minimalism and semplicity in mind, with featur This is a roadmap with major features will come in near future. - Support for other databases. -- Database tools (variables, process list...). +- Database tools. - SSH tunnel support. - Users management (add/edit/delete). - UI/UX improvements. @@ -60,7 +61,6 @@ This is a roadmap with major features will come in near future. - More keyboard shortcuts. - Query logs console. - Import/export and migration. -- Light theme. ## Troubleshooting diff --git a/src/renderer/App.vue b/src/renderer/App.vue index be7032ae..783699d4 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -16,6 +16,7 @@ + @@ -37,6 +38,7 @@ export default { Workspace: () => import(/* webpackChunkName: "Workspace" */'@/components/Workspace'), ModalNewConnection: () => import(/* webpackChunkName: "ModalNewConnection" */'@/components/ModalNewConnection'), ModalSettings: () => import(/* webpackChunkName: "ModalSettings" */'@/components/ModalSettings'), + TheScratchpad: () => import(/* webpackChunkName: "TheScratchpad" */'@/components/TheScratchpad'), ModalDiscardChanges: () => import(/* webpackChunkName: "ModalDiscardChanges" */'@/components/ModalDiscardChanges') }, data () { @@ -48,6 +50,7 @@ export default { isNewConnModal: 'application/isNewModal', isEditModal: 'application/isEditModal', isSettingModal: 'application/isSettingModal', + isScratchpad: 'application/isScratchpad', connections: 'connections/getConnections', applicationTheme: 'settings/getApplicationTheme', isUnsavedDiscardModal: 'workspaces/isUnsavedDiscardModal' diff --git a/src/renderer/components/BaseTextEditor.vue b/src/renderer/components/BaseTextEditor.vue index 18e02e4b..65df2f04 100644 --- a/src/renderer/components/BaseTextEditor.vue +++ b/src/renderer/components/BaseTextEditor.vue @@ -22,6 +22,7 @@ export default { editorClass: { type: String, default: '' }, autoFocus: { type: Boolean, default: false }, readOnly: { type: Boolean, default: false }, + showLineNumbers: { type: Boolean, default: true }, height: { type: Number, default: 200 } }, data () { @@ -71,7 +72,9 @@ export default { value: this.value, fontSize: '14px', printMargin: false, - readOnly: this.readOnly + readOnly: this.readOnly, + showLineNumbers: this.showLineNumbers, + showGutter: this.showLineNumbers }); this.editor.setOptions({ diff --git a/src/renderer/components/TheScratchpad.vue b/src/renderer/components/TheScratchpad.vue new file mode 100644 index 00000000..97e04e4f --- /dev/null +++ b/src/renderer/components/TheScratchpad.vue @@ -0,0 +1,75 @@ + + + diff --git a/src/renderer/components/TheSettingBar.vue b/src/renderer/components/TheSettingBar.vue index 9ede7950..b9a331d1 100644 --- a/src/renderer/components/TheSettingBar.vue +++ b/src/renderer/components/TheSettingBar.vue @@ -36,7 +36,7 @@
    - @@ -94,6 +94,7 @@ export default { updateConnections: 'connections/updateConnections', showNewConnModal: 'application/showNewConnModal', showSettingModal: 'application/showSettingModal', + showScratchpad: 'application/showScratchpad', selectWorkspace: 'workspaces/selectWorkspace' }), contextMenu (event, connection) { diff --git a/src/renderer/i18n/en-US.js b/src/renderer/i18n/en-US.js index b9c48ec9..18ad5258 100644 --- a/src/renderer/i18n/en-US.js +++ b/src/renderer/i18n/en-US.js @@ -205,7 +205,8 @@ module.exports = { createNewSchema: 'Create new schema', schemaName: 'Schema name', editSchema: 'Edit schema', - deleteSchema: 'Delete schema' + deleteSchema: 'Delete schema', + markdownSupported: 'Markdown supported' }, faker: { address: 'Address', diff --git a/src/renderer/store/index.js b/src/renderer/store/index.js index 7bee55b5..a322ba49 100644 --- a/src/renderer/store/index.js +++ b/src/renderer/store/index.js @@ -5,6 +5,7 @@ import Vuex from 'vuex'; import application from './modules/application.store'; import settings from './modules/settings.store'; +import scratchpad from './modules/scratchpad.store'; import connections from './modules/connections.store'; import workspaces from './modules/workspaces.store'; import notifications from './modules/notifications.store'; @@ -18,6 +19,7 @@ export default new Vuex.Store({ modules: { application, settings, + scratchpad, connections, workspaces, notifications diff --git a/src/renderer/store/modules/application.store.js b/src/renderer/store/modules/application.store.js index 82436550..f210fda1 100644 --- a/src/renderer/store/modules/application.store.js +++ b/src/renderer/store/modules/application.store.js @@ -8,6 +8,7 @@ export default { is_loading: false, is_new_modal: false, is_setting_modal: false, + is_scratchpad: false, selected_setting_tab: 'general', selected_conection: {}, update_status: 'noupdate', // noupdate, available, checking, nocheck, downloading, downloaded, disabled @@ -22,6 +23,7 @@ export default { getSelectedConnection: state => state.selected_conection, isNewModal: state => state.is_new_modal, isSettingModal: state => state.is_setting_modal, + isScratchpad: state => state.is_scratchpad, selectedSettingTab: state => state.selected_setting_tab, getUpdateStatus: state => state.update_status, getDownloadProgress: state => Number(state.download_progress.toFixed(1)) @@ -46,6 +48,12 @@ export default { HIDE_SETTING_MODAL (state) { state.is_setting_modal = false; }, + SHOW_SCRATCHPAD (state) { + state.is_scratchpad = true; + }, + HIDE_SCRATCHPAD (state) { + state.is_scratchpad = false; + }, CHANGE_UPDATE_STATUS (state, status) { state.update_status = status; }, @@ -72,6 +80,12 @@ export default { }, hideSettingModal ({ commit }) { commit('HIDE_SETTING_MODAL'); + }, + showScratchpad ({ commit }) { + commit('SHOW_SCRATCHPAD'); + }, + hideScratchpad ({ commit }) { + commit('HIDE_SCRATCHPAD'); } } }; diff --git a/src/renderer/store/modules/scratchpad.store.js b/src/renderer/store/modules/scratchpad.store.js new file mode 100644 index 00000000..affb32e7 --- /dev/null +++ b/src/renderer/store/modules/scratchpad.store.js @@ -0,0 +1,25 @@ +'use strict'; +import Store from 'electron-store'; +const persistentStore = new Store({ name: 'notes' }); + +export default { + namespaced: true, + strict: true, + state: { + notes: persistentStore.get('notes', '# HOW TO SUPPORT ANTARES\n\n- [ ] Leave a star to Antares [GitHub repo](https://github.com/Fabio286/antares)\n- [ ] Send feedbacks and advices\n- [ ] Report for bugs\n- [ ] If you enjoy, share Antares with friends\n\n# ABOUT SCRATCHPAD\n\nThis is a scratchpad where you can save your **personal notes**. It supports `markdown` format, but you are free to use plain text.\nThis content is just a placeholder, feel free to clear it to make space for your notes.\n') + }, + getters: { + getNotes: state => state.notes + }, + mutations: { + SET_NOTES (state, notes) { + state.notes = notes; + persistentStore.set('notes', state.notes); + } + }, + actions: { + changeNotes ({ commit }, notes) { + commit('SET_NOTES', notes); + } + } +};