mirror of https://github.com/Fabio286/antares.git
feat: add copy shortcut and default copy type setting
This commit is contained in:
parent
0e80e823d0
commit
9aca89477f
|
@ -209,6 +209,23 @@
|
|||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group column col-12">
|
||||
<div class="col-5 col-sm-12">
|
||||
<label class="form-label">
|
||||
{{ t('message.defaultCopyType') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-3 col-sm-12">
|
||||
<BaseSelect
|
||||
v-model="defaultCopyType"
|
||||
class="form-select"
|
||||
:options="copyTypes"
|
||||
option-track-by="code"
|
||||
option-label="name"
|
||||
@change="changeDefaultCopyType(defaultCopyType)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -393,6 +410,7 @@ const {
|
|||
autoComplete: selectedAutoComplete,
|
||||
lineWrap: selectedLineWrap,
|
||||
executeSelected: selectedExecuteSelected,
|
||||
defaultCopyType: selectedCopyType,
|
||||
notificationsTimeout,
|
||||
restoreTabs,
|
||||
disableBlur,
|
||||
|
@ -416,7 +434,8 @@ const {
|
|||
changeApplicationTheme,
|
||||
changeEditorTheme,
|
||||
changeEditorFontSize,
|
||||
updateNotificationsTimeout
|
||||
updateNotificationsTimeout,
|
||||
changeDefaultCopyType
|
||||
} = settingsStore;
|
||||
const {
|
||||
hideSettingModal: closeModal,
|
||||
|
@ -432,7 +451,7 @@ const appLogo = require('../images/logo.svg');
|
|||
const darkPreview = require('../images/dark.png');
|
||||
const lightPreview = require('../images/light.png');
|
||||
const exampleQuery = `-- This is an example
|
||||
SELECT
|
||||
SELECT
|
||||
employee.id,
|
||||
employee.first_name,
|
||||
employee.last_name,
|
||||
|
@ -448,6 +467,7 @@ ORDER BY
|
|||
`;
|
||||
|
||||
const localLocale: Ref<AvailableLocale> = ref(null);
|
||||
const defaultCopyType: Ref<string> = ref(null);
|
||||
const localPageSize: Ref<number> = ref(null);
|
||||
const localTimeout: Ref<number> = ref(null);
|
||||
const localEditorTheme: Ref<string> = ref(null);
|
||||
|
@ -511,6 +531,14 @@ const locales = computed(() => {
|
|||
return locales;
|
||||
});
|
||||
|
||||
const copyTypes = computed(() => [
|
||||
{ code: 'cell', name: t('word.cell') },
|
||||
{ code: 'html', name: t('word.table') },
|
||||
{ code: 'json', name: 'JSON' },
|
||||
{ code: 'csv', name: 'CSV' },
|
||||
{ code: 'sql', name: 'SQL insert' }
|
||||
]);
|
||||
|
||||
const hasUpdates = computed(() => ['available', 'downloading', 'downloaded', 'link'].includes(updateStatus.value));
|
||||
|
||||
const workspace = computed(() => {
|
||||
|
@ -570,6 +598,7 @@ const toggleExecuteSelected = () => {
|
|||
};
|
||||
|
||||
localLocale.value = selectedLocale.value;
|
||||
defaultCopyType.value = selectedCopyType.value;
|
||||
localPageSize.value = pageSize.value as number;
|
||||
localTimeout.value = notificationsTimeout.value as number;
|
||||
localEditorTheme.value = editorTheme.value as string;
|
||||
|
|
|
@ -142,7 +142,7 @@ const settingsStore = useSettingsStore();
|
|||
const consoleStore = useConsoleStore();
|
||||
const { getWorkspace } = useWorkspacesStore();
|
||||
|
||||
const { dataTabLimit: pageSize } = storeToRefs(settingsStore);
|
||||
const { dataTabLimit: pageSize, defaultCopyType } = storeToRefs(settingsStore);
|
||||
|
||||
const { consoleHeight } = storeToRefs(consoleStore);
|
||||
|
||||
|
@ -697,6 +697,18 @@ const onKey = async (e: KeyboardEvent) => {
|
|||
if ((e.ctrlKey || e.metaKey) && e.code === 'KeyA' && !e.altKey)
|
||||
selectAllRows(e);
|
||||
|
||||
if ((e.ctrlKey || e.metaKey) && e.code === 'KeyC' && !e.altKey) {
|
||||
const copyType = defaultCopyType.value;
|
||||
if (selectedRows.value.length >= 1) {
|
||||
if (selectedRows.value.length === 1 && copyType === 'cell')
|
||||
await navigator.clipboard.writeText(scrollElement.value.querySelector('.td.selected').innerText);
|
||||
else if (selectedRows.value.length > 1 && copyType === 'cell')
|
||||
copyRow('html');
|
||||
else
|
||||
copyRow(copyType);
|
||||
}
|
||||
}
|
||||
|
||||
// row navigation stuff
|
||||
if (!(e.ctrlKey || e.metaKey) && (e.code.includes('Arrow') || e.code === 'Tab') && sortedResults.value.length > 0 && !e.altKey) {
|
||||
e.preventDefault();
|
||||
|
|
|
@ -333,7 +333,8 @@ export const enUS = {
|
|||
folderName: 'Folder name',
|
||||
deleteFolder: 'Delete folder',
|
||||
editConnectionAppearence: 'Edit connection appearence',
|
||||
executeSelectedQuery: 'Execute selected query'
|
||||
executeSelectedQuery: 'Execute selected query',
|
||||
defaultCopyType: 'Default copy type'
|
||||
},
|
||||
faker: {
|
||||
address: 'Address',
|
||||
|
|
|
@ -333,7 +333,8 @@ export const idID = {
|
|||
folderName: 'Nama folder',
|
||||
deleteFolder: 'Hapus folder',
|
||||
editConnectionAppearence: 'Ubah connection appearence',
|
||||
executeSelectedQuery: 'Eksekusi query yang dipilih'
|
||||
executeSelectedQuery: 'Eksekusi query yang dipilih',
|
||||
defaultCopyType: 'Jenis salin default'
|
||||
},
|
||||
faker: {
|
||||
address: 'Alamat',
|
||||
|
|
|
@ -29,7 +29,8 @@ export const useSettingsStore = defineStore('settings', {
|
|||
restoreTabs: settingsStore.get('restore_tabs', true) as boolean,
|
||||
disableBlur: settingsStore.get('disable_blur', false) as boolean,
|
||||
disableScratchpad: settingsStore.get('disable_scratchpad', false) as boolean,
|
||||
shortcuts: shortcutsStore.get('shortcuts', []) as ShortcutRecord[]
|
||||
shortcuts: shortcutsStore.get('shortcuts', []) as ShortcutRecord[],
|
||||
defaultCopyType: settingsStore.get('default_copy_type', 'cell') as string
|
||||
}),
|
||||
actions: {
|
||||
changeLocale (locale: AvailableLocale) {
|
||||
|
@ -92,6 +93,10 @@ export const useSettingsStore = defineStore('settings', {
|
|||
},
|
||||
updateShortcuts (shortcuts: ShortcutRecord[]) {
|
||||
this.shortcuts = shortcuts;
|
||||
},
|
||||
changeDefaultCopyType (type: string) {
|
||||
this.defaultCopyType = type;
|
||||
settingsStore.set('default_copy_type', this.defaultCopyType);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue