mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-17 04:00:48 +01:00
feat: context menu to copy queries from console
This commit is contained in:
parent
44647f5b55
commit
c21bd6075c
@ -583,7 +583,7 @@ watch(queryTabs, (newVal, oldVal) => {
|
||||
});
|
||||
|
||||
const addQueryTab = () => {
|
||||
newTab({ uid: props.connection.uid, type: 'query' });
|
||||
newTab({ uid: props.connection.uid, type: 'query', schema: workspace.value.breadcrumbs.schema });
|
||||
};
|
||||
|
||||
const getSelectedTab = () => {
|
||||
|
@ -22,12 +22,22 @@
|
||||
:key="i"
|
||||
class="query-console-log"
|
||||
tabindex="0"
|
||||
@contextmenu.prevent="contextMenu($event, wLog)"
|
||||
>
|
||||
<span class="type-datetime">{{ moment(wLog.date).format('YYYY-MM-DD HH:mm:ss') }}</span>: <span class="type-string">{{ wLog.sql }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<BaseContextMenu
|
||||
v-if="isContext"
|
||||
:context-event="contextEvent"
|
||||
@close-context="isContext = false"
|
||||
>
|
||||
<div class="context-element" @click="copyQuery">
|
||||
<span class="d-flex"><i class="mdi mdi-18px mdi-content-copy text-light pr-1" /> {{ $t('word.copy') }}</span>
|
||||
</div>
|
||||
</BaseContextMenu>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted, ref, Ref, watch } from 'vue';
|
||||
@ -35,6 +45,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import * as moment from 'moment';
|
||||
import { useConsoleStore } from '@/stores/console';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import BaseContextMenu from '@/components/BaseContextMenu.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@ -53,6 +64,9 @@ const queryConsoleBody: Ref<HTMLInputElement> = ref(null);
|
||||
const resizer: Ref<HTMLInputElement> = ref(null);
|
||||
const localHeight = ref(250);
|
||||
const isHover = ref(false);
|
||||
const isContext = ref(false);
|
||||
const contextQuery: Ref<string> = ref(null);
|
||||
const contextEvent: Ref<MouseEvent> = ref(null);
|
||||
|
||||
const resize = (e: MouseEvent) => {
|
||||
const el = queryConsole.value;
|
||||
@ -72,6 +86,17 @@ const stopResize = () => {
|
||||
window.removeEventListener('mouseup', stopResize);
|
||||
};
|
||||
|
||||
const contextMenu = (event: MouseEvent, wLog: {date: Date; sql: string}) => {
|
||||
contextEvent.value = event;
|
||||
contextQuery.value = wLog.sql;
|
||||
isContext.value = true;
|
||||
};
|
||||
|
||||
const copyQuery = () => {
|
||||
navigator.clipboard.writeText(contextQuery.value);
|
||||
isContext.value = false;
|
||||
};
|
||||
|
||||
watch(workspaceLogs, async () => {
|
||||
if (!isHover.value) {
|
||||
await nextTick();
|
||||
|
Loading…
x
Reference in New Issue
Block a user