2020-10-01 15:08:35 +02:00
|
|
|
<template>
|
|
|
|
<BaseContextMenu
|
|
|
|
:context-event="contextEvent"
|
|
|
|
@close-context="closeContext"
|
|
|
|
>
|
2020-11-16 17:16:39 +01:00
|
|
|
<div class="context-element">
|
2020-10-01 15:08:35 +02:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-plus text-light pr-1" /> {{ $t('word.add') }}</span>
|
|
|
|
<i class="mdi mdi-18px mdi-chevron-right text-light pl-1" />
|
2020-12-01 16:48:20 +01:00
|
|
|
<div class="context-submenu">
|
2021-03-16 18:42:03 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.tableAdd"
|
|
|
|
class="context-element"
|
2021-08-13 16:50:59 +02:00
|
|
|
@click="openCreateTableTab"
|
2021-03-16 18:42:03 +01:00
|
|
|
>
|
2020-12-01 16:48:20 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-table text-light pr-1" /> {{ $t('word.table') }}</span>
|
|
|
|
</div>
|
2021-03-16 18:42:03 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.viewAdd"
|
|
|
|
class="context-element"
|
2021-08-18 17:28:41 +02:00
|
|
|
@click="openCreateViewTab"
|
2021-03-16 18:42:03 +01:00
|
|
|
>
|
2020-12-26 15:37:34 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-table-eye text-light pr-1" /> {{ $t('word.view') }}</span>
|
|
|
|
</div>
|
2021-03-16 18:42:03 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.triggerAdd"
|
|
|
|
class="context-element"
|
2021-09-02 18:08:23 +02:00
|
|
|
@click="openCreateTriggerTab"
|
2021-03-16 18:42:03 +01:00
|
|
|
>
|
2020-12-31 19:55:02 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-table-cog text-light pr-1" /> {{ $tc('word.trigger', 1) }}</span>
|
2020-12-26 15:37:34 +01:00
|
|
|
</div>
|
2021-03-16 18:42:03 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.routineAdd"
|
|
|
|
class="context-element"
|
2021-09-06 17:29:34 +02:00
|
|
|
@click="openCreateRoutineTab"
|
2021-03-16 18:42:03 +01:00
|
|
|
>
|
2021-01-05 17:25:18 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-sync-circle pr-1" /> {{ $tc('word.storedRoutine', 1) }}</span>
|
2020-12-26 15:37:34 +01:00
|
|
|
</div>
|
2021-03-16 18:42:03 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.functionAdd"
|
|
|
|
class="context-element"
|
2021-09-07 18:20:45 +02:00
|
|
|
@click="openCreateFunctionTab"
|
2021-03-16 18:42:03 +01:00
|
|
|
>
|
2021-01-05 17:25:18 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-arrow-right-bold-box pr-1" /> {{ $tc('word.function', 1) }}</span>
|
|
|
|
</div>
|
2021-07-03 11:29:14 +02:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.triggerFunctionAdd"
|
|
|
|
class="context-element"
|
2021-09-11 10:24:21 +02:00
|
|
|
@click="openCreateTriggerFunctionTab"
|
2021-07-03 11:29:14 +02:00
|
|
|
>
|
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-cog-clockwise pr-1" /> {{ $tc('word.triggerFunction', 1) }}</span>
|
|
|
|
</div>
|
2021-03-16 18:42:03 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.schedulerAdd"
|
|
|
|
class="context-element"
|
2021-09-10 18:23:32 +02:00
|
|
|
@click="openCreateSchedulerTab"
|
2021-03-16 18:42:03 +01:00
|
|
|
>
|
2020-12-31 19:55:02 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-calendar-clock text-light pr-1" /> {{ $tc('word.scheduler', 1) }}</span>
|
2020-12-26 15:37:34 +01:00
|
|
|
</div>
|
2020-12-01 16:48:20 +01:00
|
|
|
</div>
|
2020-11-16 17:16:39 +01:00
|
|
|
</div>
|
2021-10-29 12:58:37 +02:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.schemaExport"
|
|
|
|
class="context-element"
|
|
|
|
@click="showExportSchemaModal"
|
|
|
|
>
|
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-database-arrow-down text-light pr-1" /> {{ $t('word.export') }}</span>
|
|
|
|
</div>
|
2021-12-28 15:30:07 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.schemaImport"
|
|
|
|
class="context-element"
|
|
|
|
@click="initImport"
|
|
|
|
>
|
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-database-arrow-up text-light pr-1" /> {{ $t('word.import') }}</span>
|
|
|
|
</div>
|
2021-03-16 18:42:03 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.schemaEdit"
|
|
|
|
class="context-element"
|
|
|
|
@click="showEditModal"
|
|
|
|
>
|
2020-12-03 16:15:10 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-database-edit text-light pr-1" /> {{ $t('word.edit') }}</span>
|
2020-10-01 15:08:35 +02:00
|
|
|
</div>
|
2022-02-16 09:14:46 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.schemaDrop"
|
|
|
|
class="context-element"
|
|
|
|
@click="showDeleteModal"
|
|
|
|
>
|
2020-12-03 16:15:10 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-database-remove text-light pr-1" /> {{ $t('word.delete') }}</span>
|
2020-10-01 15:08:35 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<ConfirmModal
|
2020-10-03 12:11:42 +02:00
|
|
|
v-if="isDeleteModal"
|
2021-03-16 18:42:03 +01:00
|
|
|
@confirm="deleteSchema"
|
2020-10-03 12:11:42 +02:00
|
|
|
@hide="hideDeleteModal"
|
2020-10-01 15:08:35 +02:00
|
|
|
>
|
2022-02-16 09:14:46 +01:00
|
|
|
<template #header>
|
2020-10-01 15:08:35 +02:00
|
|
|
<div class="d-flex">
|
2021-06-13 11:16:21 +02:00
|
|
|
<i class="mdi mdi-24px mdi-database-remove mr-1" />
|
|
|
|
<span class="cut-text">{{ $t('message.deleteSchema') }}</span>
|
2020-10-01 15:08:35 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
2022-02-16 09:14:46 +01:00
|
|
|
<template #body>
|
2020-10-01 15:08:35 +02:00
|
|
|
<div class="mb-2">
|
2021-07-14 18:15:13 +02:00
|
|
|
{{ $t('message.deleteCorfirm') }} "<b>{{ selectedSchema }}</b>"?
|
2020-10-01 15:08:35 +02:00
|
|
|
</div>
|
2022-02-16 09:14:46 +01:00
|
|
|
</template>
|
2020-10-01 15:08:35 +02:00
|
|
|
</ConfirmModal>
|
2021-03-17 11:15:14 +01:00
|
|
|
<ModalEditSchema
|
2020-10-03 12:11:42 +02:00
|
|
|
v-if="isEditModal"
|
2021-07-14 18:15:13 +02:00
|
|
|
:selected-schema="selectedSchema"
|
2020-10-03 12:11:42 +02:00
|
|
|
@close="hideEditModal"
|
|
|
|
/>
|
2021-10-29 12:58:37 +02:00
|
|
|
<ModalExportSchema
|
|
|
|
v-if="isExportSchemaModal"
|
|
|
|
:selected-schema="selectedSchema"
|
|
|
|
@close="hideExportSchemaModal"
|
|
|
|
/>
|
2021-12-28 15:30:07 +01:00
|
|
|
<ModalImportSchema
|
|
|
|
v-if="isImportSchemaModal"
|
|
|
|
ref="importModalRef"
|
|
|
|
:selected-schema="selectedSchema"
|
|
|
|
@close="hideImportSchemaModal"
|
|
|
|
/>
|
2020-10-01 15:08:35 +02:00
|
|
|
</BaseContextMenu>
|
|
|
|
</template>
|
|
|
|
|
2022-06-09 20:08:32 +02:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { Component, computed, nextTick, Ref, ref } from 'vue';
|
|
|
|
import { storeToRefs } from 'pinia';
|
2022-04-30 00:47:37 +02:00
|
|
|
import { useNotificationsStore } from '@/stores/notifications';
|
|
|
|
import { useWorkspacesStore } from '@/stores/workspaces';
|
2022-06-09 20:08:32 +02:00
|
|
|
import BaseContextMenu from '@/components/BaseContextMenu.vue';
|
|
|
|
import ConfirmModal from '@/components/BaseConfirmModal.vue';
|
|
|
|
import ModalEditSchema from '@/components/ModalEditSchema.vue';
|
|
|
|
import ModalExportSchema from '@/components/ModalExportSchema.vue';
|
|
|
|
import ModalImportSchema from '@/components/ModalImportSchema.vue';
|
2021-03-17 11:15:14 +01:00
|
|
|
import Schema from '@/ipc-api/Schema';
|
2021-12-28 15:30:07 +01:00
|
|
|
import Application from '@/ipc-api/Application';
|
2020-10-01 15:08:35 +02:00
|
|
|
|
2022-06-09 20:08:32 +02:00
|
|
|
const props = defineProps({
|
|
|
|
contextEvent: MouseEvent,
|
|
|
|
selectedSchema: String
|
|
|
|
});
|
2022-04-30 00:47:37 +02:00
|
|
|
|
2022-06-09 20:08:32 +02:00
|
|
|
const emit = defineEmits([
|
|
|
|
'open-create-table-tab',
|
|
|
|
'open-create-view-tab',
|
|
|
|
'open-create-trigger-tab',
|
|
|
|
'open-create-routine-tab',
|
|
|
|
'open-create-function-tab',
|
|
|
|
'open-create-trigger-function-tab',
|
|
|
|
'open-create-scheduler-tab',
|
|
|
|
'close-context',
|
|
|
|
'reload'
|
|
|
|
]);
|
2022-04-30 00:47:37 +02:00
|
|
|
|
2022-06-09 20:08:32 +02:00
|
|
|
const { addNotification } = useNotificationsStore();
|
|
|
|
const workspacesStore = useWorkspacesStore();
|
2022-04-30 00:47:37 +02:00
|
|
|
|
2022-06-09 20:08:32 +02:00
|
|
|
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
|
|
|
|
|
|
|
|
const {
|
|
|
|
getWorkspace,
|
|
|
|
changeBreadcrumbs
|
|
|
|
} = workspacesStore;
|
|
|
|
|
|
|
|
const importModalRef: Ref<Component & {startImport: (file: string) => void}> = ref(null);
|
|
|
|
const isDeleteModal = ref(false);
|
|
|
|
const isEditModal = ref(false);
|
|
|
|
const isExportSchemaModal = ref(false);
|
|
|
|
const isImportSchemaModal = ref(false);
|
|
|
|
|
|
|
|
const workspace = computed(() => getWorkspace(selectedWorkspace.value));
|
|
|
|
|
|
|
|
const openCreateTableTab = () => {
|
|
|
|
emit('open-create-table-tab');
|
|
|
|
};
|
|
|
|
|
|
|
|
const openCreateViewTab = () => {
|
|
|
|
emit('open-create-view-tab');
|
|
|
|
};
|
|
|
|
|
|
|
|
const openCreateTriggerTab = () => {
|
|
|
|
emit('open-create-trigger-tab');
|
|
|
|
};
|
|
|
|
|
|
|
|
const openCreateRoutineTab = () => {
|
|
|
|
emit('open-create-routine-tab');
|
|
|
|
};
|
|
|
|
|
|
|
|
const openCreateFunctionTab = () => {
|
|
|
|
emit('open-create-function-tab');
|
|
|
|
};
|
|
|
|
|
|
|
|
const openCreateTriggerFunctionTab = () => {
|
|
|
|
emit('open-create-trigger-function-tab');
|
|
|
|
};
|
|
|
|
|
|
|
|
const openCreateSchedulerTab = () => {
|
|
|
|
emit('open-create-scheduler-tab');
|
|
|
|
};
|
|
|
|
|
|
|
|
const showDeleteModal = () => {
|
|
|
|
isDeleteModal.value = true;
|
|
|
|
};
|
2020-10-01 15:08:35 +02:00
|
|
|
|
2022-06-09 20:08:32 +02:00
|
|
|
const hideDeleteModal = () => {
|
|
|
|
isDeleteModal.value = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
const showEditModal = () => {
|
|
|
|
isEditModal.value = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
const hideEditModal = () => {
|
|
|
|
isEditModal.value = false;
|
|
|
|
closeContext();
|
|
|
|
};
|
|
|
|
|
|
|
|
const showExportSchemaModal = () => {
|
|
|
|
isExportSchemaModal.value = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
const hideExportSchemaModal = () => {
|
|
|
|
isExportSchemaModal.value = false;
|
|
|
|
closeContext();
|
|
|
|
};
|
|
|
|
|
|
|
|
const showImportSchemaModal = () => {
|
|
|
|
isImportSchemaModal.value = true;
|
|
|
|
};
|
2020-12-03 16:15:10 +01:00
|
|
|
|
2022-06-09 20:08:32 +02:00
|
|
|
const hideImportSchemaModal = () => {
|
|
|
|
isImportSchemaModal.value = false;
|
|
|
|
closeContext();
|
|
|
|
};
|
|
|
|
|
|
|
|
const initImport = async () => {
|
|
|
|
const result = await Application.showOpenDialog({ properties: ['openFile'], filters: [{ name: 'SQL', extensions: ['sql'] }] });
|
|
|
|
if (result && !result.canceled) {
|
|
|
|
const file = result.filePaths[0];
|
|
|
|
showImportSchemaModal();
|
|
|
|
await nextTick();
|
|
|
|
importModalRef.value.startImport(file);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const closeContext = () => {
|
|
|
|
emit('close-context');
|
|
|
|
};
|
|
|
|
|
|
|
|
const deleteSchema = async () => {
|
|
|
|
try {
|
|
|
|
const { status, response } = await Schema.deleteSchema({
|
|
|
|
uid: selectedWorkspace.value,
|
|
|
|
database: props.selectedSchema
|
|
|
|
});
|
|
|
|
|
|
|
|
if (status === 'success') {
|
|
|
|
if (props.selectedSchema === workspace.value.breadcrumbs.schema)
|
|
|
|
changeBreadcrumbs({ schema: null });
|
|
|
|
|
|
|
|
closeContext();
|
|
|
|
emit('reload');
|
2020-10-01 15:08:35 +02:00
|
|
|
}
|
2022-06-09 20:08:32 +02:00
|
|
|
else
|
|
|
|
addNotification({ status: 'error', message: response });
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
addNotification({ status: 'error', message: err.stack });
|
2020-10-01 15:08:35 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
2022-06-09 20:08:32 +02:00
|
|
|
|
2020-12-26 15:37:34 +01:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.context-submenu {
|
|
|
|
min-width: 150px !important;
|
|
|
|
}
|
|
|
|
</style>
|