|
|
@@ -1,4 +1,4 @@
|
|
|
-import { Button, Descriptions, message, Popconfirm, Space, Tooltip } from 'antd';
|
|
|
+import { Descriptions, message, Space, Tooltip } from 'antd';
|
|
|
import { InstanceModel, service } from '@/pages/device/Instance';
|
|
|
import { useEffect, useState } from 'react';
|
|
|
import type { ConfigMetadata } from '@/pages/device/Product/typings';
|
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
UndoOutlined,
|
|
|
} from '@ant-design/icons';
|
|
|
import Edit from './Edit';
|
|
|
+import { PermissionButton } from '@/components';
|
|
|
|
|
|
const Config = () => {
|
|
|
const params = useParams<{ id: string }>();
|
|
|
@@ -26,6 +27,7 @@ const Config = () => {
|
|
|
|
|
|
const [metadata, setMetadata] = useState<ConfigMetadata[]>([]);
|
|
|
const [visible, setVisible] = useState<boolean>(false);
|
|
|
+ const { permission } = PermissionButton.usePermission('device/Instance');
|
|
|
|
|
|
const id = InstanceModel.detail?.id || params?.id;
|
|
|
|
|
|
@@ -83,7 +85,8 @@ const Config = () => {
|
|
|
<div style={{ display: 'flex', marginBottom: 20 }}>
|
|
|
<div style={{ fontSize: 16, fontWeight: 700 }}>配置</div>
|
|
|
<Space>
|
|
|
- <Button
|
|
|
+ <PermissionButton
|
|
|
+ isPermission={permission.update}
|
|
|
type="link"
|
|
|
onClick={async () => {
|
|
|
setVisible(true);
|
|
|
@@ -91,48 +94,52 @@ const Config = () => {
|
|
|
>
|
|
|
<EditOutlined />
|
|
|
编辑
|
|
|
- </Button>
|
|
|
+ </PermissionButton>
|
|
|
{InstanceModel.detail.state?.value !== 'notActive' && (
|
|
|
- <Popconfirm
|
|
|
- title="确认重新应用该配置?"
|
|
|
- onConfirm={async () => {
|
|
|
- const resp = await service.deployDevice(id || '');
|
|
|
- if (resp.status === 200) {
|
|
|
- message.success('操作成功');
|
|
|
- getDetail();
|
|
|
- }
|
|
|
+ <PermissionButton
|
|
|
+ popConfirm={{
|
|
|
+ title: '确认重新应用该配置?',
|
|
|
+ onConfirm: async () => {
|
|
|
+ const resp = await service.deployDevice(id || '');
|
|
|
+ if (resp.status === 200) {
|
|
|
+ message.success('操作成功');
|
|
|
+ getDetail();
|
|
|
+ }
|
|
|
+ },
|
|
|
}}
|
|
|
+ isPermission={permission.update}
|
|
|
+ type="link"
|
|
|
>
|
|
|
- <Button type="link">
|
|
|
- <CheckOutlined />
|
|
|
- 应用配置
|
|
|
- </Button>
|
|
|
+ <CheckOutlined />
|
|
|
+ 应用配置
|
|
|
<Tooltip title="修改配置后需重新应用后才能生效。">
|
|
|
<QuestionCircleOutlined />
|
|
|
</Tooltip>
|
|
|
- </Popconfirm>
|
|
|
+ </PermissionButton>
|
|
|
)}
|
|
|
{InstanceModel.detail?.aloneConfiguration && (
|
|
|
- <Popconfirm
|
|
|
- title="确认恢复默认配置?"
|
|
|
- onConfirm={async () => {
|
|
|
- const resp = await service.configurationReset(id || '');
|
|
|
- if (resp.status === 200) {
|
|
|
- message.success('恢复默认配置成功');
|
|
|
- getDetail();
|
|
|
- }
|
|
|
+ <PermissionButton
|
|
|
+ popConfirm={{
|
|
|
+ title: '确认恢复默认配置?',
|
|
|
+ onConfirm: async () => {
|
|
|
+ const resp = await service.configurationReset(id || '');
|
|
|
+ if (resp.status === 200) {
|
|
|
+ message.success('恢复默认配置成功');
|
|
|
+ getDetail();
|
|
|
+ }
|
|
|
+ },
|
|
|
}}
|
|
|
+ type="link"
|
|
|
+ isPermission={permission.update}
|
|
|
>
|
|
|
- <Button type="link">
|
|
|
- <UndoOutlined />
|
|
|
- 恢复默认
|
|
|
- </Button>
|
|
|
+ <UndoOutlined />
|
|
|
+ 恢复默认
|
|
|
<Tooltip
|
|
|
title={`该设备单独编辑过配置信息,点击此将恢复成默认的配置信息,请谨慎操作。`}
|
|
|
>
|
|
|
<QuestionCircleOutlined />
|
|
|
</Tooltip>
|
|
|
- </Popconfirm>
|
|
|
+ </PermissionButton>
|
|
|
)}
|
|
|
</Space>
|
|
|
</div>
|