diff --git a/dolphinscheduler-ui-next/src/components/card/index.tsx b/dolphinscheduler-ui-next/src/components/card/index.tsx index daaea821a9..70ebb9ad59 100644 --- a/dolphinscheduler-ui-next/src/components/card/index.tsx +++ b/dolphinscheduler-ui-next/src/components/card/index.tsx @@ -22,6 +22,10 @@ const headerStyle = { borderBottom: '1px solid var(--border-color)', } +const contentStyle = { + padding: '8px 10px', +} + const props = { title: String as PropType, } @@ -32,7 +36,12 @@ const Card = defineComponent({ render() { const { title, $slots } = this return ( - + {$slots} ) diff --git a/dolphinscheduler-ui-next/src/components/chart/index.ts b/dolphinscheduler-ui-next/src/components/chart/index.ts index a2ff6018f7..231171a82e 100644 --- a/dolphinscheduler-ui-next/src/components/chart/index.ts +++ b/dolphinscheduler-ui-next/src/components/chart/index.ts @@ -33,6 +33,8 @@ function initChart( const globalProperties = getCurrentInstance()?.appContext.config.globalProperties + option['backgroundColor'] = '' + const init = () => { chart = globalProperties?.echarts.init( domRef.value, diff --git a/dolphinscheduler-ui-next/src/components/chart/modules/Bar.tsx b/dolphinscheduler-ui-next/src/components/chart/modules/Bar.tsx index 417336f49a..d0c7e09271 100644 --- a/dolphinscheduler-ui-next/src/components/chart/modules/Bar.tsx +++ b/dolphinscheduler-ui-next/src/components/chart/modules/Bar.tsx @@ -28,12 +28,20 @@ const props = { type: [String, Number] as PropType, default: '100%', }, + xAxisData: { + type: Array as PropType>, + default: () => [], + }, + seriesData: { + type: Array as PropType>, + default: () => [], + }, } const BarChart = defineComponent({ name: 'BarChart', props, - setup() { + setup(props) { const barChartRef: Ref = ref(null) const option = { @@ -53,7 +61,7 @@ const BarChart = defineComponent({ xAxis: [ { type: 'category', - data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], + data: props.xAxisData, axisTick: { alignWithLabel: true, }, @@ -66,10 +74,9 @@ const BarChart = defineComponent({ ], series: [ { - name: 'Direct', type: 'bar', barWidth: '60%', - data: [10, 52, 200, 334, 390, 330, 220], + data: props.seriesData, }, ], } diff --git a/dolphinscheduler-ui-next/src/locales/modules/en_US.ts b/dolphinscheduler-ui-next/src/locales/modules/en_US.ts index 5b52520ac9..c6e5cf2168 100644 --- a/dolphinscheduler-ui-next/src/locales/modules/en_US.ts +++ b/dolphinscheduler-ui-next/src/locales/modules/en_US.ts @@ -68,9 +68,18 @@ const menu = { token_manage: 'Token Manage', } +const home = { + task_state_statistics: 'Task State Statistics', + process_state_statistics: 'Process State Statistics', + process_definition_statistics: 'Process Definition Statistics', + number: 'Number', + state: 'State', +} + export default { login, theme, profile, menu, + home, } diff --git a/dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts b/dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts index d04610e697..86661fd3aa 100644 --- a/dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts +++ b/dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts @@ -68,9 +68,18 @@ const menu = { token_manage: '令牌管理', } +const home = { + task_state_statistics: '任务状态统计', + process_state_statistics: '流程状态统计', + process_definition_statistics: '流程定义统计', + number: '数量', + state: '状态', +} + export default { login, theme, profile, menu, + home, } diff --git a/dolphinscheduler-ui-next/src/service/modules/projects-analysis/types.ts b/dolphinscheduler-ui-next/src/service/modules/projects-analysis/types.ts index 30a21c53db..71333f9adf 100644 --- a/dolphinscheduler-ui-next/src/service/modules/projects-analysis/types.ts +++ b/dolphinscheduler-ui-next/src/service/modules/projects-analysis/types.ts @@ -24,4 +24,15 @@ interface StateReq extends CodeReq { startDate?: string } -export { CodeReq, StateReq } +interface UserList { + userName: string + userId: number + count: number +} + +interface ProcessDefinitionRes { + count: number + userList: UserList[] +} + +export { CodeReq, StateReq, ProcessDefinitionRes } diff --git a/dolphinscheduler-ui-next/src/views/home/index.module.scss b/dolphinscheduler-ui-next/src/views/home/index.module.scss index 3e7c6c26f5..3221050814 100644 --- a/dolphinscheduler-ui-next/src/views/home/index.module.scss +++ b/dolphinscheduler-ui-next/src/views/home/index.module.scss @@ -14,3 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +.card-table { + display: flex; + justify-content: space-between; +} diff --git a/dolphinscheduler-ui-next/src/views/home/index.tsx b/dolphinscheduler-ui-next/src/views/home/index.tsx index 2f3b0476df..62d89d83f0 100644 --- a/dolphinscheduler-ui-next/src/views/home/index.tsx +++ b/dolphinscheduler-ui-next/src/views/home/index.tsx @@ -16,20 +16,76 @@ */ import { defineComponent } from 'vue' +import { NGrid, NGi, NDataTable } from 'naive-ui' +import { useI18n } from 'vue-i18n' +import { useTable } from './use-table' +import { useProcessDefinition } from './use-process-definition' import Card from '@/components/card' import PieChart from '@/components/chart/modules/Pie' -import GaugeChart from '@/components/chart/modules/Gauge' import BarChart from '@/components/chart/modules/Bar' +import styles from './index.module.scss' +import type { ProcessDefinitionRes } from '@/service/modules/projects-analysis/types' export default defineComponent({ name: 'home', - setup() {}, + setup() { + const { t } = useI18n() + const { getProcessDefinition, formatProcessDefinition } = + useProcessDefinition() + const processDefinition = getProcessDefinition() + + return { t, processDefinition, formatProcessDefinition } + }, render() { + const { columnsRef } = useTable() + const { t, processDefinition, formatProcessDefinition } = this + const chartData = + Object.keys(processDefinition).length > 0 && + formatProcessDefinition(processDefinition as ProcessDefinitionRes) + return (
- {{ default: () => }} - {{ default: () => }} - {{ default: () => }} + + + + {{ + default: () => ( +
+ + +
+ ), + }} +
+
+ + + {{ + default: () => ( +
+ + +
+ ), + }} +
+
+
+ + + + {{ + default: () => + chartData && ( + + ), + }} + + +
) }, diff --git a/dolphinscheduler-ui-next/src/views/home/use-process-definition.ts b/dolphinscheduler-ui-next/src/views/home/use-process-definition.ts new file mode 100644 index 0000000000..cc97464548 --- /dev/null +++ b/dolphinscheduler-ui-next/src/views/home/use-process-definition.ts @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { useAsyncState } from '@vueuse/core' +import { countDefinitionByUser } from '@/service/modules/projects-analysis' +import type { ProcessDefinitionRes } from '@/service/modules/projects-analysis/types' + +export function useProcessDefinition() { + const getProcessDefinition = () => { + const { state } = useAsyncState( + countDefinitionByUser({ projectCode: 0 }), + {} + ) + return state + } + + const formatProcessDefinition = (data: ProcessDefinitionRes) => { + const xAxisData: Array = data.userList.map((item) => item.userName) + const seriesData: Array = data.userList.map((item) => item.count) + + return { xAxisData, seriesData } + } + + return { getProcessDefinition, formatProcessDefinition } +} diff --git a/dolphinscheduler-ui-next/src/views/home/use-process-state.ts b/dolphinscheduler-ui-next/src/views/home/use-process-state.ts new file mode 100644 index 0000000000..3e7c6c26f5 --- /dev/null +++ b/dolphinscheduler-ui-next/src/views/home/use-process-state.ts @@ -0,0 +1,16 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/dolphinscheduler-ui-next/src/views/home/use-table.ts b/dolphinscheduler-ui-next/src/views/home/use-table.ts new file mode 100644 index 0000000000..81bdc6ab82 --- /dev/null +++ b/dolphinscheduler-ui-next/src/views/home/use-table.ts @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { useI18n } from 'vue-i18n' +import type { TableColumns } from 'naive-ui/es/data-table/src/interface' + +export function useTable() { + const { t } = useI18n() + + const columnsRef: TableColumns = [ + { title: '#', key: '#' }, + { title: t('home.number'), key: 'number' }, + { title: t('home.state'), key: 'state' }, + ] + + return { + columnsRef, + } +} diff --git a/dolphinscheduler-ui-next/src/views/home/use-task-state.ts b/dolphinscheduler-ui-next/src/views/home/use-task-state.ts new file mode 100644 index 0000000000..3e7c6c26f5 --- /dev/null +++ b/dolphinscheduler-ui-next/src/views/home/use-task-state.ts @@ -0,0 +1,16 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */