mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
feat: context menu to copy queries from console
This commit is contained in:
@ -583,7 +583,7 @@ watch(queryTabs, (newVal, oldVal) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const addQueryTab = () => {
|
const addQueryTab = () => {
|
||||||
newTab({ uid: props.connection.uid, type: 'query' });
|
newTab({ uid: props.connection.uid, type: 'query', schema: workspace.value.breadcrumbs.schema });
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSelectedTab = () => {
|
const getSelectedTab = () => {
|
||||||
|
@ -22,12 +22,22 @@
|
|||||||
:key="i"
|
:key="i"
|
||||||
class="query-console-log"
|
class="query-console-log"
|
||||||
tabindex="0"
|
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>
|
<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>
|
||||||
</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>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, nextTick, onMounted, ref, Ref, watch } from 'vue';
|
import { computed, nextTick, onMounted, ref, Ref, watch } from 'vue';
|
||||||
@ -35,6 +45,7 @@ import { useI18n } from 'vue-i18n';
|
|||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
import { useConsoleStore } from '@/stores/console';
|
import { useConsoleStore } from '@/stores/console';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
|
import BaseContextMenu from '@/components/BaseContextMenu.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
@ -53,6 +64,9 @@ const queryConsoleBody: Ref<HTMLInputElement> = ref(null);
|
|||||||
const resizer: Ref<HTMLInputElement> = ref(null);
|
const resizer: Ref<HTMLInputElement> = ref(null);
|
||||||
const localHeight = ref(250);
|
const localHeight = ref(250);
|
||||||
const isHover = ref(false);
|
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 resize = (e: MouseEvent) => {
|
||||||
const el = queryConsole.value;
|
const el = queryConsole.value;
|
||||||
@ -72,6 +86,17 @@ const stopResize = () => {
|
|||||||
window.removeEventListener('mouseup', 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 () => {
|
watch(workspaceLogs, async () => {
|
||||||
if (!isHover.value) {
|
if (!isHover.value) {
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
Reference in New Issue
Block a user