2021-01-10 18:30:56 +01:00
|
|
|
<template>
|
2021-07-20 16:59:59 +02:00
|
|
|
<div v-show="isSelected" class="workspace-query-tab column col-12 columns col-gapless">
|
2021-01-10 18:30:56 +01:00
|
|
|
<div class="workspace-query-runner column col-12">
|
|
|
|
<div class="workspace-query-runner-footer">
|
|
|
|
<div class="workspace-query-buttons">
|
|
|
|
<button
|
|
|
|
class="btn btn-primary btn-sm"
|
|
|
|
:disabled="!isChanged"
|
|
|
|
:class="{'loading':isSaving}"
|
|
|
|
@click="saveChanges"
|
|
|
|
>
|
2021-07-09 15:51:02 +02:00
|
|
|
<i class="mdi mdi-24px mdi-content-save mr-1" />
|
2023-08-03 18:28:50 +02:00
|
|
|
<span>{{ t('general.save') }}</span>
|
2021-01-10 18:30:56 +01:00
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
:disabled="!isChanged"
|
|
|
|
class="btn btn-link btn-sm mr-0"
|
2023-08-03 18:28:50 +02:00
|
|
|
:title="t('database.clearChanges')"
|
2021-01-10 18:30:56 +01:00
|
|
|
@click="clearChanges"
|
|
|
|
>
|
2021-07-09 15:51:02 +02:00
|
|
|
<i class="mdi mdi-24px mdi-delete-sweep mr-1" />
|
2023-08-03 18:28:50 +02:00
|
|
|
<span>{{ t('general.clear') }}</span>
|
2021-01-10 18:30:56 +01:00
|
|
|
</button>
|
|
|
|
|
|
|
|
<div class="divider-vert py-3" />
|
|
|
|
|
|
|
|
<button
|
2021-02-25 12:39:50 +01:00
|
|
|
class="btn btn-dark btn-sm"
|
2021-01-10 18:30:56 +01:00
|
|
|
:disabled="isChanged"
|
2021-02-25 12:39:50 +01:00
|
|
|
@click="runFunctionCheck"
|
2021-01-10 18:30:56 +01:00
|
|
|
>
|
2021-07-09 15:51:02 +02:00
|
|
|
<i class="mdi mdi-24px mdi-play mr-1" />
|
2023-08-03 18:28:50 +02:00
|
|
|
<span>{{ t('general.run') }}</span>
|
2021-01-10 18:30:56 +01:00
|
|
|
</button>
|
|
|
|
<button class="btn btn-dark btn-sm" @click="showParamsModal">
|
2021-07-09 15:51:02 +02:00
|
|
|
<i class="mdi mdi-24px mdi-dots-horizontal mr-1" />
|
2023-08-03 18:28:50 +02:00
|
|
|
<span>{{ t('database.parameters') }}</span>
|
2021-01-10 18:30:56 +01:00
|
|
|
</button>
|
|
|
|
</div>
|
2021-07-20 16:59:59 +02:00
|
|
|
<div class="workspace-query-info">
|
2023-08-03 18:28:50 +02:00
|
|
|
<div class="d-flex" :title="t('database.schema')">
|
2021-07-20 16:59:59 +02:00
|
|
|
<i class="mdi mdi-18px mdi-database mr-1" /><b>{{ schema }}</b>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-10 18:30:56 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-10 18:12:13 +02:00
|
|
|
<div class="container">
|
|
|
|
<div class="columns">
|
|
|
|
<div class="column col-auto">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label">
|
2023-08-03 18:28:50 +02:00
|
|
|
{{ t('general.name') }}
|
2021-08-10 18:12:13 +02:00
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
ref="firstInput"
|
|
|
|
v-model="localFunction.name"
|
|
|
|
class="form-input"
|
|
|
|
:class="{'is-error': !isTableNameValid}"
|
|
|
|
type="text"
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-if="customizations.languages" class="column col-auto">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label">
|
2023-08-03 18:28:50 +02:00
|
|
|
{{ t('application.language') }}
|
2021-08-10 18:12:13 +02:00
|
|
|
</label>
|
2022-05-11 23:30:31 +02:00
|
|
|
<BaseSelect
|
|
|
|
v-model="localFunction.language"
|
|
|
|
:options="customizations.languages"
|
|
|
|
class="form-select"
|
|
|
|
/>
|
2021-08-10 18:12:13 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-if="customizations.definer" class="column col-auto">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label">
|
2023-08-03 18:28:50 +02:00
|
|
|
{{ t('database.definer') }}
|
2021-08-10 18:12:13 +02:00
|
|
|
</label>
|
2022-05-11 23:30:31 +02:00
|
|
|
<BaseSelect
|
2021-08-10 18:12:13 +02:00
|
|
|
v-model="localFunction.definer"
|
2023-08-03 18:28:50 +02:00
|
|
|
:options="[{value: '', name:t('database.currentUser')}, ...workspace.users]"
|
2022-06-21 17:54:47 +02:00
|
|
|
:option-label="(user: any) => user.value === '' ? user.name : `${user.name}@${user.host}`"
|
|
|
|
:option-track-by="(user: any) => user.value === '' ? '' : `\`${user.name}\`@\`${user.host}\``"
|
2021-08-10 18:12:13 +02:00
|
|
|
class="form-select"
|
2022-05-11 23:30:31 +02:00
|
|
|
/>
|
2021-08-10 18:12:13 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="column col-auto">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label">
|
2023-08-03 18:28:50 +02:00
|
|
|
{{ t('database.returns') }}
|
2021-08-10 18:12:13 +02:00
|
|
|
</label>
|
|
|
|
<div class="input-group">
|
2022-05-11 23:30:31 +02:00
|
|
|
<BaseSelect
|
2021-08-10 18:12:13 +02:00
|
|
|
v-model="localFunction.returns"
|
|
|
|
class="form-select text-uppercase"
|
2022-06-21 17:54:47 +02:00
|
|
|
:options="[{ name: 'VOID' }, ...(workspace.dataTypes as any)]"
|
2022-05-11 23:30:31 +02:00
|
|
|
group-label="group"
|
|
|
|
group-values="types"
|
|
|
|
option-label="name"
|
|
|
|
option-track-by="name"
|
2021-08-10 18:12:13 +02:00
|
|
|
style="max-width: 150px;"
|
2022-05-11 23:30:31 +02:00
|
|
|
/>
|
2021-08-10 18:12:13 +02:00
|
|
|
<input
|
|
|
|
v-if="customizations.parametersLength"
|
|
|
|
v-model="localFunction.returnsLength"
|
|
|
|
style="max-width: 150px;"
|
|
|
|
class="form-input"
|
|
|
|
type="number"
|
|
|
|
min="0"
|
2023-08-03 18:28:50 +02:00
|
|
|
:placeholder="t('database.length')"
|
2021-08-10 18:12:13 +02:00
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-if="customizations.comment" class="column">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label">
|
2023-08-03 18:28:50 +02:00
|
|
|
{{ t('database.comment') }}
|
2021-08-10 18:12:13 +02:00
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
v-model="localFunction.comment"
|
|
|
|
class="form-input"
|
|
|
|
type="text"
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="column col-auto">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label">
|
2023-08-03 18:28:50 +02:00
|
|
|
{{ t('database.sqlSecurity') }}
|
2021-08-10 18:12:13 +02:00
|
|
|
</label>
|
2022-05-11 23:30:31 +02:00
|
|
|
<BaseSelect
|
|
|
|
v-model="localFunction.security"
|
|
|
|
:options="['DEFINER', 'INVOKER']"
|
|
|
|
class="form-select"
|
|
|
|
/>
|
2021-08-10 18:12:13 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-if="customizations.functionDataAccess" class="column col-auto">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label">
|
2023-08-03 18:28:50 +02:00
|
|
|
{{ t('database.dataAccess') }}
|
2021-08-10 18:12:13 +02:00
|
|
|
</label>
|
2022-05-11 23:30:31 +02:00
|
|
|
<BaseSelect
|
|
|
|
v-model="localFunction.dataAccess"
|
|
|
|
:options="['CONTAINS SQL', 'NO SQL', 'READS SQL DATA', 'MODIFIES SQL DATA']"
|
|
|
|
class="form-select"
|
|
|
|
/>
|
2021-08-10 18:12:13 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-if="customizations.functionDeterministic" class="column col-auto">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label d-invisible">.</label>
|
|
|
|
<label class="form-checkbox form-inline">
|
2023-08-03 18:28:50 +02:00
|
|
|
<input v-model="localFunction.deterministic" type="checkbox"><i class="form-icon" /> {{ t('database.deterministic') }}
|
2021-08-10 18:12:13 +02:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-22 18:27:45 +01:00
|
|
|
<div class="workspace-query-results column col-12 mt-2 p-relative">
|
|
|
|
<BaseLoader v-if="isLoading" />
|
2023-08-03 18:28:50 +02:00
|
|
|
<label class="form-label ml-2">{{ t('database.functionBody') }}</label>
|
2021-01-10 18:30:56 +01:00
|
|
|
<QueryEditor
|
2021-04-14 18:06:20 +02:00
|
|
|
v-show="isSelected"
|
2021-01-10 18:30:56 +01:00
|
|
|
ref="queryEditor"
|
2022-04-21 14:39:24 +02:00
|
|
|
v-model="localFunction.sql"
|
2021-01-10 18:30:56 +01:00
|
|
|
:workspace="workspace"
|
|
|
|
:schema="schema"
|
|
|
|
:height="editorHeight"
|
|
|
|
/>
|
|
|
|
</div>
|
2021-08-12 09:54:13 +02:00
|
|
|
<WorkspaceTabPropsFunctionParamsModal
|
2021-01-10 18:30:56 +01:00
|
|
|
v-if="isParamsModal"
|
|
|
|
:local-parameters="localFunction.parameters"
|
|
|
|
:workspace="workspace"
|
|
|
|
:func="localFunction.name"
|
|
|
|
@hide="hideParamsModal"
|
|
|
|
@parameters-update="parametersUpdate"
|
|
|
|
/>
|
2021-02-25 12:39:50 +01:00
|
|
|
<ModalAskParameters
|
|
|
|
v-if="isAskingParameters"
|
|
|
|
:local-routine="localFunction"
|
2021-04-10 20:38:46 +02:00
|
|
|
:client="workspace.client"
|
2021-02-25 12:39:50 +01:00
|
|
|
@confirm="runFunction"
|
|
|
|
@close="hideAskParamsModal"
|
|
|
|
/>
|
2021-01-10 18:30:56 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-06-21 17:54:47 +02:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { Ace } from 'ace-builds';
|
2023-08-18 15:57:31 +02:00
|
|
|
import { AlterFunctionParams, FunctionInfos, FunctionParam } from 'common/interfaces/antares';
|
2021-02-24 12:46:31 +01:00
|
|
|
import { uidGen } from 'common/libs/uidGen';
|
2023-08-18 15:57:31 +02:00
|
|
|
import { ipcRenderer } from 'electron';
|
|
|
|
import { storeToRefs } from 'pinia';
|
|
|
|
import { Component, computed, onBeforeUnmount, onMounted, onUnmounted, Ref, ref, watch } from 'vue';
|
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
|
2022-06-21 17:54:47 +02:00
|
|
|
import BaseLoader from '@/components/BaseLoader.vue';
|
2023-08-18 15:57:31 +02:00
|
|
|
import BaseSelect from '@/components/BaseSelect.vue';
|
|
|
|
import ModalAskParameters from '@/components/ModalAskParameters.vue';
|
2022-06-21 17:54:47 +02:00
|
|
|
import QueryEditor from '@/components/QueryEditor.vue';
|
|
|
|
import WorkspaceTabPropsFunctionParamsModal from '@/components/WorkspaceTabPropsFunctionParamsModal.vue';
|
2021-01-10 18:30:56 +01:00
|
|
|
import Functions from '@/ipc-api/Functions';
|
2023-08-18 15:57:31 +02:00
|
|
|
import { useConsoleStore } from '@/stores/console';
|
|
|
|
import { useNotificationsStore } from '@/stores/notifications';
|
|
|
|
import { useWorkspacesStore } from '@/stores/workspaces';
|
2021-01-10 18:30:56 +01:00
|
|
|
|
2022-06-21 17:54:47 +02:00
|
|
|
const { t } = useI18n();
|
2021-07-20 16:59:59 +02:00
|
|
|
|
2022-06-21 17:54:47 +02:00
|
|
|
const props = defineProps({
|
|
|
|
tabUid: String,
|
|
|
|
connection: Object,
|
|
|
|
function: String,
|
|
|
|
isSelected: Boolean,
|
|
|
|
schema: String
|
|
|
|
});
|
2021-07-23 10:56:41 +02:00
|
|
|
|
2022-06-21 17:54:47 +02:00
|
|
|
const { addNotification } = useNotificationsStore();
|
|
|
|
const workspacesStore = useWorkspacesStore();
|
2022-07-17 12:36:37 +02:00
|
|
|
const { consoleHeight } = storeToRefs(useConsoleStore());
|
2022-06-21 17:54:47 +02:00
|
|
|
|
|
|
|
const {
|
|
|
|
getWorkspace,
|
|
|
|
refreshStructure,
|
|
|
|
renameTabs,
|
|
|
|
newTab,
|
|
|
|
changeBreadcrumbs,
|
|
|
|
setUnsavedChanges
|
|
|
|
} = workspacesStore;
|
|
|
|
|
|
|
|
const queryEditor: Ref<Component & {editor: Ace.Editor; $el: HTMLElement}> = ref(null);
|
|
|
|
const firstInput: Ref<HTMLInputElement> = ref(null);
|
|
|
|
const isLoading = ref(false);
|
|
|
|
const isSaving = ref(false);
|
|
|
|
const isParamsModal = ref(false);
|
|
|
|
const isAskingParameters = ref(false);
|
|
|
|
const originalFunction: Ref<FunctionInfos> = ref(null);
|
|
|
|
const localFunction: Ref<FunctionInfos> = ref({ name: '', sql: '', definer: null });
|
|
|
|
const lastFunction = ref(null);
|
|
|
|
const sqlProxy = ref('');
|
|
|
|
const editorHeight = ref(300);
|
|
|
|
|
|
|
|
const workspace = computed(() => {
|
|
|
|
return getWorkspace(props.connection.uid);
|
|
|
|
});
|
|
|
|
|
|
|
|
const customizations = computed(() => {
|
|
|
|
return workspace.value.customizations;
|
|
|
|
});
|
|
|
|
|
|
|
|
const isChanged = computed(() => {
|
|
|
|
return JSON.stringify(originalFunction.value) !== JSON.stringify(localFunction.value);
|
|
|
|
});
|
|
|
|
|
|
|
|
const isTableNameValid = computed(() => {
|
|
|
|
return localFunction.value.name !== '';
|
|
|
|
});
|
|
|
|
|
|
|
|
const getFunctionData = async () => {
|
|
|
|
if (!props.function) return;
|
|
|
|
|
|
|
|
isLoading.value = true;
|
|
|
|
localFunction.value = { name: '', sql: '', definer: null };
|
|
|
|
lastFunction.value = props.function;
|
|
|
|
|
|
|
|
const params = {
|
|
|
|
uid: props.connection.uid,
|
|
|
|
schema: props.schema,
|
|
|
|
func: props.function
|
|
|
|
};
|
|
|
|
|
|
|
|
try {
|
|
|
|
const { status, response } = await Functions.getFunctionInformations(params);
|
|
|
|
if (status === 'success') {
|
|
|
|
originalFunction.value = response;
|
|
|
|
|
|
|
|
originalFunction.value.parameters = [...originalFunction.value.parameters.map(param => {
|
|
|
|
param._antares_id = uidGen();
|
|
|
|
return param;
|
|
|
|
})];
|
|
|
|
|
|
|
|
localFunction.value = JSON.parse(JSON.stringify(originalFunction.value));
|
|
|
|
sqlProxy.value = localFunction.value.sql;
|
2021-01-10 18:30:56 +01:00
|
|
|
}
|
2022-06-21 17:54:47 +02:00
|
|
|
else
|
|
|
|
addNotification({ status: 'error', message: response });
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
addNotification({ status: 'error', message: err.stack });
|
|
|
|
}
|
2021-01-10 18:30:56 +01:00
|
|
|
|
2022-06-21 17:54:47 +02:00
|
|
|
resizeQueryEditor();
|
|
|
|
isLoading.value = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
const saveChanges = async () => {
|
|
|
|
if (isSaving.value) return;
|
|
|
|
isSaving.value = true;
|
|
|
|
const params = {
|
|
|
|
uid: props.connection.uid,
|
|
|
|
func: {
|
|
|
|
...localFunction.value,
|
|
|
|
schema: props.schema,
|
|
|
|
oldName: originalFunction.value.name
|
|
|
|
} as AlterFunctionParams
|
|
|
|
};
|
|
|
|
|
|
|
|
try {
|
|
|
|
const { status, response } = await Functions.alterFunction(params);
|
|
|
|
|
|
|
|
if (status === 'success') {
|
|
|
|
const oldName = originalFunction.value.name;
|
2021-01-10 18:30:56 +01:00
|
|
|
|
2022-06-21 17:54:47 +02:00
|
|
|
await refreshStructure(props.connection.uid);
|
|
|
|
|
|
|
|
if (oldName !== localFunction.value.name) {
|
|
|
|
renameTabs({
|
|
|
|
uid: props.connection.uid,
|
|
|
|
schema: props.schema,
|
|
|
|
elementName: oldName,
|
|
|
|
elementNewName: localFunction.value.name,
|
|
|
|
elementType: 'function'
|
|
|
|
});
|
|
|
|
|
|
|
|
changeBreadcrumbs({ schema: props.schema, function: localFunction.value.name });
|
2021-01-10 18:30:56 +01:00
|
|
|
}
|
2021-02-25 12:39:50 +01:00
|
|
|
else
|
2022-06-21 17:54:47 +02:00
|
|
|
getFunctionData();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
addNotification({ status: 'error', message: response });
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
addNotification({ status: 'error', message: err.stack });
|
|
|
|
}
|
2021-02-25 12:39:50 +01:00
|
|
|
|
2022-06-21 17:54:47 +02:00
|
|
|
isSaving.value = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
const clearChanges = () => {
|
|
|
|
localFunction.value = JSON.parse(JSON.stringify(originalFunction.value));
|
|
|
|
queryEditor.value.editor.session.setValue(localFunction.value.sql);
|
|
|
|
};
|
|
|
|
|
|
|
|
const resizeQueryEditor = () => {
|
|
|
|
if (queryEditor.value) {
|
2022-07-17 12:36:37 +02:00
|
|
|
let sizeToSubtract = 0;
|
2022-06-21 17:54:47 +02:00
|
|
|
const footer = document.getElementById('footer');
|
2022-07-17 12:36:37 +02:00
|
|
|
if (footer) sizeToSubtract += footer.offsetHeight;
|
|
|
|
sizeToSubtract += consoleHeight.value;
|
|
|
|
|
|
|
|
const size = window.innerHeight - queryEditor.value.$el.getBoundingClientRect().top - sizeToSubtract;
|
2022-06-21 17:54:47 +02:00
|
|
|
editorHeight.value = size;
|
|
|
|
queryEditor.value.editor.resize();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const parametersUpdate = (parameters: FunctionParam[]) => {
|
|
|
|
localFunction.value = { ...localFunction.value, parameters };
|
|
|
|
};
|
|
|
|
|
|
|
|
const runFunctionCheck = () => {
|
|
|
|
if (localFunction.value.parameters.length)
|
|
|
|
showAskParamsModal();
|
|
|
|
else
|
|
|
|
runFunction();
|
|
|
|
};
|
|
|
|
|
|
|
|
const runFunction = (params?: string[]) => {
|
|
|
|
if (!params) params = [];
|
|
|
|
|
|
|
|
let sql;
|
|
|
|
switch (props.connection.client) { // TODO: move in a better place
|
|
|
|
case 'maria':
|
|
|
|
case 'mysql':
|
|
|
|
sql = `SELECT \`${originalFunction.value.name}\` (${params.join(',')})`;
|
|
|
|
break;
|
|
|
|
case 'pg':
|
|
|
|
sql = `SELECT ${originalFunction.value.name}(${params.join(',')})`;
|
|
|
|
break;
|
|
|
|
case 'mssql':
|
|
|
|
sql = `SELECT ${originalFunction.value.name} ${params.join(',')}`;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sql = `SELECT \`${originalFunction.value.name}\` (${params.join(',')})`;
|
|
|
|
}
|
|
|
|
|
|
|
|
newTab({ uid: props.connection.uid, content: sql, type: 'query', autorun: true });
|
|
|
|
};
|
|
|
|
|
|
|
|
const showParamsModal = () => {
|
|
|
|
isParamsModal.value = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
const hideParamsModal = () => {
|
|
|
|
isParamsModal.value = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
const showAskParamsModal = () => {
|
|
|
|
isAskingParameters.value = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
const hideAskParamsModal = () => {
|
|
|
|
isAskingParameters.value = false;
|
|
|
|
};
|
|
|
|
|
2022-08-17 10:00:23 +02:00
|
|
|
const saveContentListener = () => {
|
|
|
|
const hasModalOpen = !!document.querySelectorAll('.modal.active').length;
|
|
|
|
if (props.isSelected && !hasModalOpen && isChanged.value)
|
|
|
|
saveChanges();
|
2021-01-10 18:30:56 +01:00
|
|
|
};
|
2022-06-21 17:54:47 +02:00
|
|
|
|
|
|
|
watch(() => props.schema, async () => {
|
|
|
|
if (props.isSelected) {
|
|
|
|
await getFunctionData();
|
|
|
|
queryEditor.value.editor.session.setValue(localFunction.value.sql);
|
|
|
|
lastFunction.value = props.function;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
watch(() => props.function, async () => {
|
|
|
|
if (props.isSelected) {
|
|
|
|
await getFunctionData();
|
|
|
|
queryEditor.value.editor.session.setValue(localFunction.value.sql);
|
|
|
|
lastFunction.value = props.function;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
watch(() => props.isSelected, async (val) => {
|
|
|
|
if (val) {
|
|
|
|
changeBreadcrumbs({ schema: props.schema, function: props.function });
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
resizeQueryEditor();
|
|
|
|
}, 200);
|
|
|
|
|
|
|
|
if (lastFunction.value !== props.function)
|
|
|
|
getFunctionData();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
watch(isChanged, (val) => {
|
|
|
|
setUnsavedChanges({ uid: props.connection.uid, tUid: props.tabUid, isChanged: val });
|
|
|
|
});
|
|
|
|
|
2022-07-17 12:36:37 +02:00
|
|
|
watch(consoleHeight, () => {
|
|
|
|
resizeQueryEditor();
|
|
|
|
});
|
|
|
|
|
2022-06-21 17:54:47 +02:00
|
|
|
(async () => {
|
|
|
|
await getFunctionData();
|
|
|
|
queryEditor.value.editor.session.setValue(localFunction.value.sql);
|
|
|
|
})();
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
window.addEventListener('resize', resizeQueryEditor);
|
2022-08-17 10:00:23 +02:00
|
|
|
|
|
|
|
ipcRenderer.on('save-content', saveContentListener);
|
2022-06-21 17:54:47 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
window.removeEventListener('resize', resizeQueryEditor);
|
|
|
|
});
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
2022-08-17 10:00:23 +02:00
|
|
|
ipcRenderer.removeListener('save-content', saveContentListener);
|
2022-06-21 17:54:47 +02:00
|
|
|
});
|
2021-01-10 18:30:56 +01:00
|
|
|
</script>
|