feat: scratchpad to save persistent notes

This commit is contained in:
Fabio Di Stasio 2021-04-03 12:17:40 +02:00
parent 280697698e
commit e349dd5eab
9 changed files with 130 additions and 6 deletions

View File

@ -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

View File

@ -16,6 +16,7 @@
<TheFooter />
<TheNotificationsBoard />
<ModalNewConnection v-if="isNewConnModal" />
<TheScratchpad v-if="isScratchpad" />
<ModalSettings v-if="isSettingModal" />
<ModalDiscardChanges v-if="isUnsavedDiscardModal" />
</div>
@ -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'

View File

@ -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({

View File

@ -0,0 +1,75 @@
<template>
<ConfirmModal
:confirm-text="$t('word.update')"
:cancel-text="$t('word.close')"
size="large"
:hide-footer="true"
@hide="hideScratchpad"
>
<template :slot="'header'">
<div class="d-flex">
<i class="mdi mdi-24px mdi-notebook-edit-outline mr-1" /> {{ $t('word.scratchpad') }}
</div>
</template>
<div :slot="'body'">
<div>
<div>
<TextEditor
:value.sync="localNotes"
editor-class="textarea-editor"
mode="markdown"
:auto-focus="true"
:show-line-numbers="false"
/>
</div>
<small class="text-gray">{{ $t('message.markdownSupported') }}</small>
</div>
</div>
</ConfirmModal>
</template>
<script>
import { mapActions, mapGetters } from 'vuex';
import ConfirmModal from '@/components/BaseConfirmModal';
import TextEditor from '@/components/BaseTextEditor';
export default {
name: 'TheScratchpad',
components: {
ConfirmModal,
TextEditor
},
data () {
return {
localNotes: '',
debounceTimeout: null
};
},
computed: {
...mapGetters({
notes: 'scratchpad/getNotes'
})
},
watch: {
localNotes () {
clearTimeout(this.debounceTimeout);
this.debounceTimeout = setTimeout(() => {
this.changeNotes(this.localNotes);
}, 200);
}
},
created () {
this.localNotes = this.notes;
},
methods: {
...mapActions({
hideScratchpad: 'application/hideScratchpad',
changeNotes: 'scratchpad/changeNotes'
}),
hideModal () {
this.$emit('hide');
}
}
};
</script>

View File

@ -36,7 +36,7 @@
<div class="settingbar-bottom-elements">
<ul class="settingbar-elements">
<li class="settingbar-element btn btn-link ex-tooltip">
<li class="settingbar-element btn btn-link ex-tooltip" @click="showScratchpad">
<i class="settingbar-element-icon mdi mdi-24px mdi-notebook-edit-outline text-light" />
<span class="ex-tooltip-content">{{ $t('word.scratchpad') }}</span>
</li>
@ -94,6 +94,7 @@ export default {
updateConnections: 'connections/updateConnections',
showNewConnModal: 'application/showNewConnModal',
showSettingModal: 'application/showSettingModal',
showScratchpad: 'application/showScratchpad',
selectWorkspace: 'workspaces/selectWorkspace'
}),
contextMenu (event, connection) {

View File

@ -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',

View File

@ -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

View File

@ -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');
}
}
};

View File

@ -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);
}
}
};