Skip to content

Commit

Permalink
feat(dashboard): 增加大盘删除功能 (#125)
Browse files Browse the repository at this point in the history
issue: #125
  • Loading branch information
aide-cloud committed Apr 27, 2024
1 parent ae1eb68 commit 3b18eaf
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
5 changes: 4 additions & 1 deletion web/src/pages/home/child/AddDashboardModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export const AddDashboardButton: React.FC<AddDashboardButtonProps> = (

const handleOpen = () => setOpen(true)

const handleClose = () => setOpen(false)
const handleClose = () => {
form.resetFields()
setOpen(false)
}

const handleCommit = () => {
form.validateFields().then((values) => {
Expand Down
38 changes: 34 additions & 4 deletions web/src/pages/home/child/ConfigDashboardChart.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import DataForm from '@/components/Data/DataForm/DataForm'
import { Form, Modal } from 'antd'
import { Button, Form, Modal, Space } from 'antd'
import React, { useEffect, useState } from 'react'
import { addDashboardOptions } from '../options'
import { UpdateDashboardRequest } from '@/apis/home/dashboard/types'
Expand Down Expand Up @@ -61,6 +61,19 @@ export const ConfigDashboardChartModal: React.FC<
})
}

const handleDelete = () => {
if (!dashboardId) {
return
}
setLoading(true)
dashboardApi
.deleteDashboard(dashboardId)
.then(() => {
handleOnOk()
})
.finally(() => setLoading(false))
}

useEffect(() => {
if (!open) {
return
Expand All @@ -73,9 +86,26 @@ export const ConfigDashboardChartModal: React.FC<
<Modal
title="配置大盘"
open={open}
onCancel={handleClose}
onOk={handleCommit}
confirmLoading={loading}
footer={
<Space size={8}>
<Button
loading={loading}
danger
type="primary"
onClick={handleDelete}
>
删除大盘
</Button>
<Button onClick={handleClose}>取消</Button>
<Button
loading={loading}
type="primary"
onClick={handleCommit}
>
确定
</Button>
</Space>
}
>
<DataForm
items={addDashboardOptions}
Expand Down

0 comments on commit 3b18eaf

Please sign in to comment.