Skip to content

Commit

Permalink
feat: scratchpad to save persistent notes
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Apr 3, 2021
1 parent 2806976 commit e349dd5
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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

Expand Down
3 changes: 3 additions & 0 deletions src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<TheFooter />
<TheNotificationsBoard />
<ModalNewConnection v-if="isNewConnModal" />
<TheScratchpad v-if="isScratchpad" />
<ModalSettings v-if="isSettingModal" />
<ModalDiscardChanges v-if="isUnsavedDiscardModal" />
</div>
Expand All @@ -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 () {
Expand All @@ -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'
Expand Down
5 changes: 4 additions & 1 deletion src/renderer/components/BaseTextEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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({
Expand Down
75 changes: 75 additions & 0 deletions src/renderer/components/TheScratchpad.vue
Original file line number Diff line number Diff line change
@@ -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>
3 changes: 2 additions & 1 deletion src/renderer/components/TheSettingBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -94,6 +94,7 @@ export default {
updateConnections: 'connections/updateConnections',
showNewConnModal: 'application/showNewConnModal',
showSettingModal: 'application/showSettingModal',
showScratchpad: 'application/showScratchpad',
selectWorkspace: 'workspaces/selectWorkspace'
}),
contextMenu (event, connection) {
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/i18n/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -18,6 +19,7 @@ export default new Vuex.Store({
modules: {
application,
settings,
scratchpad,
connections,
workspaces,
notifications
Expand Down
14 changes: 14 additions & 0 deletions src/renderer/store/modules/application.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand All @@ -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;
},
Expand All @@ -72,6 +80,12 @@ export default {
},
hideSettingModal ({ commit }) {
commit('HIDE_SETTING_MODAL');
},
showScratchpad ({ commit }) {
commit('SHOW_SCRATCHPAD');
},
hideScratchpad ({ commit }) {
commit('HIDE_SCRATCHPAD');
}
}
};
25 changes: 25 additions & 0 deletions src/renderer/store/modules/scratchpad.store.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
};

0 comments on commit e349dd5

Please sign in to comment.