mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
feat: open saved queries in a tab
This commit is contained in:
@ -67,6 +67,17 @@
|
||||
:size="22"
|
||||
/> {{ t('general.undo') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="note.type === 'query'"
|
||||
class="btn btn-link pl-1"
|
||||
@click.stop="$emit('select-query', note.note)"
|
||||
>
|
||||
<BaseIcon
|
||||
icon-name="mdiOpenInApp"
|
||||
class="pr-1"
|
||||
:size="22"
|
||||
/> {{ t('general.select') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="note.type === 'query'"
|
||||
class="btn btn-link pl-1"
|
||||
@ -139,7 +150,8 @@ defineEmits([
|
||||
'select-note',
|
||||
'toggle-note',
|
||||
'archive-note',
|
||||
'restore-note'
|
||||
'restore-note',
|
||||
'select-query'
|
||||
]);
|
||||
|
||||
const noteParagraph: Ref<HTMLDivElement> = ref(null);
|
||||
|
@ -113,6 +113,7 @@
|
||||
@delete-note="deleteNote"
|
||||
@archive-note="archiveNote"
|
||||
@restore-note="restoreNote"
|
||||
@select-query="selectQuery"
|
||||
/>
|
||||
</template>
|
||||
</BaseVirtualScroll>
|
||||
@ -179,13 +180,15 @@ const { t } = useI18n();
|
||||
|
||||
const applicationStore = useApplicationStore();
|
||||
const scratchpadStore = useScratchpadStore();
|
||||
const workspacesStore = useWorkspacesStore();
|
||||
|
||||
const { connectionNotes, selectedTag } = storeToRefs(scratchpadStore);
|
||||
const { changeNotes } = scratchpadStore;
|
||||
const { hideScratchpad } = applicationStore;
|
||||
const { getConnectionName } = useConnectionsStore();
|
||||
const { connections } = storeToRefs(useConnectionsStore());
|
||||
const { getSelected: selectedWorkspace } = storeToRefs(useWorkspacesStore());
|
||||
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
|
||||
const { getWorkspaceTab, getWorkspace, newTab, updateTabContent } = workspacesStore;
|
||||
|
||||
const localConnection = ref(null);
|
||||
const table: Ref<HTMLDivElement> = ref(null);
|
||||
@ -276,6 +279,32 @@ const deleteNote = (uid: string) => {
|
||||
changeNotes(otherNotes);
|
||||
};
|
||||
|
||||
const selectQuery = (query: string) => {
|
||||
const workspace = getWorkspace(selectedWorkspace.value);
|
||||
const selectedTab = getWorkspaceTab(workspace.selectedTab);
|
||||
|
||||
if (selectedTab.type === 'query') {
|
||||
updateTabContent({
|
||||
tab: selectedTab.uid,
|
||||
uid: selectedWorkspace.value,
|
||||
type: 'query',
|
||||
content: query,
|
||||
schema: workspace.breadcrumbs.schema
|
||||
});
|
||||
}
|
||||
else {
|
||||
newTab({
|
||||
uid: selectedWorkspace.value,
|
||||
type: 'query',
|
||||
content: query,
|
||||
autorun: false,
|
||||
schema: workspace.breadcrumbs.schema
|
||||
});
|
||||
}
|
||||
|
||||
hideScratchpad();
|
||||
};
|
||||
|
||||
const closeEditModal = () => {
|
||||
isEditModal.value = false;
|
||||
noteToEdit.value = null;
|
||||
|
@ -345,6 +345,7 @@ watch(query, (val) => {
|
||||
schema: selectedSchema.value,
|
||||
content: val
|
||||
});
|
||||
|
||||
isQuerySaved.value = false;
|
||||
}, 200);
|
||||
});
|
||||
@ -368,6 +369,14 @@ watch(databaseSchemas, () => {
|
||||
selectedSchema.value = null;
|
||||
}, { deep: true });
|
||||
|
||||
watch(() => props.tab.content, () => {
|
||||
query.value = props.tab.content;
|
||||
const editorValue = queryEditor.value.editor.session.getValue();
|
||||
|
||||
if (editorValue !== query.value)// If change not rendered in editor
|
||||
queryEditor.value.editor.session.setValue(query.value);
|
||||
});
|
||||
|
||||
const runQuery = async (query: string) => {
|
||||
if (!query || isQuering.value) return;
|
||||
isQuering.value = true;
|
||||
|
Reference in New Issue
Block a user