Skip to content

Commit

Permalink
refactor: restructure folders
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Aug 4, 2024
1 parent 2b34cca commit 3bbebc9
Show file tree
Hide file tree
Showing 47 changed files with 365 additions and 381 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { getStore } from '@/store';
import useDataSource from '@/components/core/ds/useDataSource';
import useDatabase from '@/components/core/database/useDatabase';
const store = getStore();
Expand All @@ -10,8 +10,8 @@ const {
confirmDisabled,
confirmLoading,
createEditDialogVisible,
} = useDataSource(store);
defineOptions({ name: 'ClCreateEditDataSourceDialog' });
} = useDatabase(store);
defineOptions({ name: 'ClCreateEditDatabaseDialog' });
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script setup lang="ts">
import { computed } from 'vue';
import {
DATA_SOURCE_CONNECT_TYPE_STANDARD,
DATA_SOURCE_CONNECT_TYPE_URL,
DATA_SOURCE_CONNECT_TYPE_HOSTS,
} from '@/constants/ds';
DATABASE_CONNECT_TYPE_STANDARD,
DATABASE_CONNECT_TYPE_URL,
DATABASE_CONNECT_TYPE_HOSTS,
} from '@/constants/database';
import { translate } from '@/utils';
const props = defineProps<{
dataSource?: DataSource;
dataSource?: Database;
}>();
const emit = defineEmits<{
Expand All @@ -21,19 +21,19 @@ const t = translate;
const data = computed<TagProps>(() => {
const { dataSource } = props;
switch (dataSource?.connect_type) {
case DATA_SOURCE_CONNECT_TYPE_STANDARD:
case DATABASE_CONNECT_TYPE_STANDARD:
return {
label: t('components.ds.connectType.label.standard'),
icon: ['fa', 'sliders'],
type: 'primary',
};
case DATA_SOURCE_CONNECT_TYPE_URL:
case DATABASE_CONNECT_TYPE_URL:
return {
label: t('components.ds.connectType.label.url'),
icon: ['fa', 'at'],
type: 'primary',
};
case DATA_SOURCE_CONNECT_TYPE_HOSTS:
case DATABASE_CONNECT_TYPE_HOSTS:
return {
label: t('components.ds.connectType.label.hosts'),
icon: ['fa', 'diagram-project'],
Expand All @@ -47,7 +47,7 @@ const data = computed<TagProps>(() => {
};
}
});
defineOptions({ name: 'ClDataSourceConnectType' });
defineOptions({ name: 'ClDatabaseConnectType' });
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script setup lang="ts">
import { computed } from 'vue';
import { getStore } from '@/store';
import useDataSource from '@/components/core/ds/useDataSource';
import useDataSourceDetail from '@/views/ds/detail/useDataSourceDetail';
import useDatabase from '@/components/core/database/useDatabase';
import useDatabaseDetail from '@/views/database/detail/useDatabaseDetail';
import {
DATA_SOURCE_CONNECT_TYPE_HOSTS,
DATA_SOURCE_CONNECT_TYPE_STANDARD,
DATA_SOURCE_CONNECT_TYPE_URL,
} from '@/constants/ds';
DATABASE_CONNECT_TYPE_HOSTS,
DATABASE_CONNECT_TYPE_STANDARD,
DATABASE_CONNECT_TYPE_URL,
} from '@/constants/database';
import { translate } from '@/utils';
defineProps<{
Expand All @@ -30,14 +30,14 @@ const {
onHostsAdd,
onHostsDelete,
typeOptions,
} = useDataSource(store);
} = useDatabase(store);
const { activeId } = useDataSourceDetail();
const { activeId } = useDatabaseDetail();
const onChangePassword = () => onChangePasswordFunc(activeId.value);
const isDetail = computed<boolean>(() => !!activeId.value);
defineOptions({ name: 'ClDataSourceForm' });
defineOptions({ name: 'ClDatabaseForm' });
</script>

<template>
Expand Down Expand Up @@ -96,20 +96,20 @@ defineOptions({ name: 'ClDataSourceForm' });
@change="onConnectTypeChange"
>
<el-radio value="standard"
>{{ t('components.ds.connectType.label.standard') }}
>{{ t('components.database.connectType.label.standard') }}
</el-radio>
<el-radio value="url"
>{{ t('components.ds.connectType.label.url') }}
>{{ t('components.database.connectType.label.url') }}
</el-radio>
<el-radio value="hosts"
>{{ t('components.ds.connectType.label.hosts') }}
>{{ t('components.database.connectType.label.hosts') }}
</el-radio>
</el-radio-group>
</cl-form-item>
<!--./Row-->

<!--Row-->
<template v-if="form.connect_type === DATA_SOURCE_CONNECT_TYPE_STANDARD">
<template v-if="form.connect_type === DATABASE_CONNECT_TYPE_STANDARD">
<cl-form-item :span="2" :label="t('components.ds.form.host')" prop="host">
<el-input
v-model="form.host"
Expand All @@ -125,7 +125,7 @@ defineOptions({ name: 'ClDataSourceForm' });
/>
</cl-form-item>
</template>
<template v-else-if="form.connect_type === DATA_SOURCE_CONNECT_TYPE_URL">
<template v-else-if="form.connect_type === DATABASE_CONNECT_TYPE_URL">
<cl-form-item :span="4" :label="t('components.ds.form.url')" prop="url">
<el-input
v-model="form.url"
Expand All @@ -134,7 +134,7 @@ defineOptions({ name: 'ClDataSourceForm' });
/>
</cl-form-item>
</template>
<template v-else-if="form.connect_type === DATA_SOURCE_CONNECT_TYPE_HOSTS">
<template v-else-if="form.connect_type === DATABASE_CONNECT_TYPE_HOSTS">
<cl-form-item
class="hosts-item"
:span="4"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<script setup lang="ts">
import { computed } from 'vue';
import {
DATA_SOURCE_STATUS_OFFLINE,
DATA_SOURCE_STATUS_ONLINE,
} from '@/constants/ds';
DATABASE_STATUS_OFFLINE,
DATABASE_STATUS_ONLINE,
} from '@/constants/database';
import { translate } from '@/utils';
const props = withDefaults(
defineProps<{
status?: DataSourceStatus;
status?: DatabaseStatus;
error?: string;
size?: BasicSize;
}>(),
{
status: DATA_SOURCE_STATUS_ONLINE,
status: DATABASE_STATUS_ONLINE,
}
);
Expand All @@ -26,14 +26,14 @@ const t = translate;
const data = computed<TagProps>(() => {
const { status, error } = props;
switch (status) {
case DATA_SOURCE_STATUS_ONLINE:
case DATABASE_STATUS_ONLINE:
return {
label: t('components.ds.status.label.online'),
tooltip: t('components.ds.status.tooltip.online'),
type: 'success',
icon: ['fa', 'check'],
};
case DATA_SOURCE_STATUS_OFFLINE:
case DATABASE_STATUS_OFFLINE:
return {
label: t('components.ds.status.label.offline'),
tooltip: `${t('components.ds.status.tooltip.offline')}<br><span style="color: #f56c6c">${error}</span>`,
Expand All @@ -49,7 +49,7 @@ const data = computed<TagProps>(() => {
};
}
});
defineOptions({ name: 'ClDataSourceStatus' });
defineOptions({ name: 'ClDatabaseStatus' });
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<script setup lang="ts">
import { computed } from 'vue';
import {
DATA_SOURCE_TYPE_MONGO,
DATA_SOURCE_TYPE_MYSQL,
DATA_SOURCE_TYPE_POSTGRESQL,
DATA_SOURCE_TYPE_MSSQL,
DATA_SOURCE_TYPE_SQLITE,
DATA_SOURCE_TYPE_COCKROACHDB,
DATA_SOURCE_TYPE_ELASTICSEARCH,
DATA_SOURCE_TYPE_KAFKA,
} from '@/constants/ds';
DATABASE_TYPE_MONGO,
DATABASE_TYPE_MYSQL,
DATABASE_TYPE_POSTGRESQL,
DATABASE_TYPE_MSSQL,
DATABASE_TYPE_SQLITE,
DATABASE_TYPE_COCKROACHDB,
DATABASE_TYPE_ELASTICSEARCH,
DATABASE_TYPE_KAFKA,
} from '@/constants/database';
import { translate } from '@/utils';
const props = defineProps<{
dataSource?: DataSource;
dataSource?: Database;
}>();
const emit = defineEmits<{
Expand All @@ -26,49 +26,49 @@ const t = translate;
const data = computed<TagProps>(() => {
const { dataSource } = props;
switch (dataSource?.type) {
case DATA_SOURCE_TYPE_MONGO:
case DATABASE_TYPE_MONGO:
return {
label: t('components.ds.type.mongo'),
type: 'success',
icon: ['fa', 'file-lines'],
};
case DATA_SOURCE_TYPE_ELASTICSEARCH:
case DATABASE_TYPE_ELASTICSEARCH:
return {
label: t('components.ds.type.elasticsearch'),
type: 'success',
icon: ['fa', 'file-lines'],
};
case DATA_SOURCE_TYPE_MYSQL:
case DATABASE_TYPE_MYSQL:
return {
label: t('components.ds.type.mysql'),
type: 'primary',
icon: ['fa', 'table'],
};
case DATA_SOURCE_TYPE_POSTGRESQL:
case DATABASE_TYPE_POSTGRESQL:
return {
label: t('components.ds.type.postgresql'),
type: 'primary',
icon: ['fa', 'table'],
};
case DATA_SOURCE_TYPE_MSSQL:
case DATABASE_TYPE_MSSQL:
return {
label: t('components.ds.type.mssql'),
type: 'primary',
icon: ['fa', 'table'],
};
case DATA_SOURCE_TYPE_SQLITE:
case DATABASE_TYPE_SQLITE:
return {
label: t('components.ds.type.sqlite'),
type: 'primary',
icon: ['fa', 'table'],
};
case DATA_SOURCE_TYPE_COCKROACHDB:
case DATABASE_TYPE_COCKROACHDB:
return {
label: t('components.ds.type.cockroachdb'),
type: 'primary',
icon: ['fa', 'table'],
};
case DATA_SOURCE_TYPE_KAFKA:
case DATABASE_TYPE_KAFKA:
return {
label: t('components.ds.type.kafka'),
type: 'warning',
Expand All @@ -82,7 +82,7 @@ const data = computed<TagProps>(() => {
};
}
});
defineOptions({ name: 'ClDataSourceType' });
defineOptions({ name: 'ClDatabaseType' });
</script>

<template>
Expand Down
Loading

0 comments on commit 3bbebc9

Please sign in to comment.