From 89e8d9fcdb0bb4f59dae693a24b8413f602111de Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Tue, 14 Jun 2022 20:02:17 +0200 Subject: [PATCH] refactor: ts and composition api on WorkspaceTabNew* components --- src/common/interfaces/antares.ts | 16 +- src/main/main.ts | 2 +- src/renderer/components/BaseSelect.vue | 5 +- src/renderer/components/QueryEditor.vue | 4 +- .../WorkspaceExploreBarMiscContext.vue | 23 +- .../WorkspaceExploreBarMiscFolderContext.vue | 2 +- .../components/WorkspaceTabNewFunction.vue | 347 +++++------ .../components/WorkspaceTabNewRoutine.vue | 342 +++++------ .../components/WorkspaceTabNewScheduler.vue | 369 ++++++----- .../components/WorkspaceTabNewTable.vue | 574 +++++++++--------- .../WorkspaceTabNewTableEmptyState.vue | 16 +- .../components/WorkspaceTabNewTrigger.vue | 399 ++++++------ .../WorkspaceTabNewTriggerFunction.vue | 325 +++++----- .../components/WorkspaceTabNewView.vue | 356 ++++++----- .../components/WorkspaceTabPropsTable.vue | 8 +- .../WorkspaceTabPropsTableFields.vue | 2 +- src/renderer/stores/workspaces.ts | 2 +- 17 files changed, 1321 insertions(+), 1471 deletions(-) diff --git a/src/common/interfaces/antares.ts b/src/common/interfaces/antares.ts index ca684aad..2b80f534 100644 --- a/src/common/interfaces/antares.ts +++ b/src/common/interfaces/antares.ts @@ -93,6 +93,8 @@ export interface TableInfos { } export interface TableField { + // eslint-disable-next-line camelcase + _antares_id?: string; name: string; key: string; type: string; @@ -120,6 +122,8 @@ export interface TableField { } export interface TableIndex { + // eslint-disable-next-line camelcase + _antares_id?: string; name: string; fields: string[]; type: string; @@ -249,14 +253,20 @@ export interface FunctionParam { export interface RoutineInfos { name: string; - type: string; + type?: string; definer: string; - created: string; - updated: string; + created?: string; + sql?: string; + updated?: string; comment?: string; charset?: string; security?: string; + language?: string; + dataAccess?: string; + deterministic?: boolean; parameters?: FunctionParam[]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + returns?: any; } export type FunctionInfos = RoutineInfos diff --git a/src/main/main.ts b/src/main/main.ts index 0f54031e..48d5ecef 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -85,7 +85,7 @@ else { ipcMain.on('refresh-theme-settings', () => { const appTheme = persistentStore.get('application_theme'); - if(isWindows){ + if (isWindows) { mainWindow.setTitleBarOverlay({ color: appTheme === 'dark' ? '#3f3f3f' : '#fff', symbolColor: appTheme === 'dark' ? '#fff' : '#000' diff --git a/src/renderer/components/BaseSelect.vue b/src/renderer/components/BaseSelect.vue index 53265480..9a971a12 100644 --- a/src/renderer/components/BaseSelect.vue +++ b/src/renderer/components/BaseSelect.vue @@ -139,7 +139,7 @@ export default defineComponent({ const hightlightedIndex = ref(0); const isOpen = ref(false); const isMouseDown = ref(false); - const internalValue = ref(props.modelValue || props.value); + const internalValue = ref(props.modelValue !== false ? props.modelValue : props.value); const el = ref(null); const searchInput = ref(null); const optionList = ref(null); @@ -380,7 +380,8 @@ export default defineComponent({ optionList, optionRefs, handleBlurEvent, - handleMouseUpEvent + handleMouseUpEvent, + internalValue }; } }); diff --git a/src/renderer/components/QueryEditor.vue b/src/renderer/components/QueryEditor.vue index 1939baf8..5a07b0d4 100644 --- a/src/renderer/components/QueryEditor.vue +++ b/src/renderer/components/QueryEditor.vue @@ -133,8 +133,8 @@ const mode = computed(() => { case 'mysql': case 'maria': return 'mysql'; - case 'mssql': - return 'sqlserver'; + // case 'mssql': + // return 'sqlserver'; case 'pg': return 'pgsql'; default: diff --git a/src/renderer/components/WorkspaceExploreBarMiscContext.vue b/src/renderer/components/WorkspaceExploreBarMiscContext.vue index 55c9e198..34bfc4f9 100644 --- a/src/renderer/components/WorkspaceExploreBarMiscContext.vue +++ b/src/renderer/components/WorkspaceExploreBarMiscContext.vue @@ -4,7 +4,7 @@ @close-context="closeContext" >
@@ -77,7 +77,7 @@ import Triggers from '@/ipc-api/Triggers'; import Routines from '@/ipc-api/Routines'; import Functions from '@/ipc-api/Functions'; import Schedulers from '@/ipc-api/Schedulers'; -import { EventInfos, FunctionInfos, RoutineInfos, TriggerInfos } from 'common/interfaces/antares'; +import { EventInfos, FunctionInfos, IpcResponse, RoutineInfos, TriggerInfos } from 'common/interfaces/antares'; const { t } = useI18n(); @@ -153,7 +153,7 @@ const closeContext = () => { const deleteMisc = async () => { try { - let res; + let res: IpcResponse; switch (props.selectedMisc.type) { case 'trigger': @@ -163,6 +163,7 @@ const deleteMisc = async () => { trigger: props.selectedMisc.name }); break; + case 'routine': case 'procedure': res = await Routines.dropRoutine({ uid: selectedWorkspace.value, @@ -187,6 +188,8 @@ const deleteMisc = async () => { break; } + console.log(res); + const { status, response } = res; if (status === 'success') { @@ -209,7 +212,7 @@ const deleteMisc = async () => { }; const runElementCheck = () => { - if (props.selectedMisc.type === 'procedure') + if (['procedure', 'routine'].includes(props.selectedMisc.type)) runRoutineCheck(); else if (props.selectedMisc.type === 'function') runFunctionCheck(); @@ -257,9 +260,9 @@ const runRoutine = (params?: string[]) => { case 'pg': sql = `CALL ${localElement.value.name}(${params.join(',')})`; break; - case 'mssql': - sql = `EXEC ${localElement.value.name} ${params.join(',')}`; - break; + // case 'mssql': + // sql = `EXEC ${localElement.value.name} ${params.join(',')}`; + // break; default: sql = `CALL \`${localElement.value.name}\`(${params.join(',')})`; } @@ -310,9 +313,9 @@ const runFunction = (params?: string[]) => { case 'pg': sql = `SELECT ${localElement.value.name}(${params.join(',')})`; break; - case 'mssql': - sql = `SELECT ${localElement.value.name} ${params.join(',')}`; - break; + // case 'mssql': + // sql = `SELECT ${localElement.value.name} ${params.join(',')}`; + // break; default: sql = `SELECT \`${localElement.value.name}\` (${params.join(',')})`; } diff --git a/src/renderer/components/WorkspaceExploreBarMiscFolderContext.vue b/src/renderer/components/WorkspaceExploreBarMiscFolderContext.vue index 6be8d585..723cefd4 100644 --- a/src/renderer/components/WorkspaceExploreBarMiscFolderContext.vue +++ b/src/renderer/components/WorkspaceExploreBarMiscFolderContext.vue @@ -11,7 +11,7 @@ {{ t('message.createNewTrigger') }}
diff --git a/src/renderer/components/WorkspaceTabNewFunction.vue b/src/renderer/components/WorkspaceTabNewFunction.vue index e58c1162..cab3dcb8 100644 --- a/src/renderer/components/WorkspaceTabNewFunction.vue +++ b/src/renderer/components/WorkspaceTabNewFunction.vue @@ -72,8 +72,8 @@
@@ -87,7 +87,7 @@ - diff --git a/src/renderer/components/WorkspaceTabNewRoutine.vue b/src/renderer/components/WorkspaceTabNewRoutine.vue index 1ef4d413..3262a68f 100644 --- a/src/renderer/components/WorkspaceTabNewRoutine.vue +++ b/src/renderer/components/WorkspaceTabNewRoutine.vue @@ -72,8 +72,8 @@ @@ -129,7 +129,6 @@ - diff --git a/src/renderer/components/WorkspaceTabNewScheduler.vue b/src/renderer/components/WorkspaceTabNewScheduler.vue index 9b1df4f1..3e46b63e 100644 --- a/src/renderer/components/WorkspaceTabNewScheduler.vue +++ b/src/renderer/components/WorkspaceTabNewScheduler.vue @@ -11,26 +11,26 @@ @click="saveChanges" > - {{ $t('word.save') }} + {{ t('word.save') }}
-
+
{{ schema }}
@@ -40,7 +40,7 @@
- +
- +
- +
- +