feat: 告警设置模块静态完成
parent
c807eb7123
commit
c7db8824ef
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* @Author: zhoux zhouxia@supervision.ltd
|
||||
* @Date: 2023-11-15 15:01:34
|
||||
* @LastEditors: zhoux zhouxia@supervision.ltd
|
||||
* @LastEditTime: 2023-12-20 11:25:15
|
||||
* @FilePath: \general-ai-platform-web\src\components\DictionaryBox\isEnable.tsx
|
||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
*/
|
||||
import { ArrowUpOutlined, DownOutlined } from '@ant-design/icons';
|
||||
|
||||
type AlarmLevelBoxProps = {
|
||||
icon?: 'ArrowUpOutlined' | 'default' | undefined;
|
||||
color?: string;
|
||||
size?: number;
|
||||
};
|
||||
|
||||
const AlarmLevelBox: React.FC<AlarmLevelBoxProps> = (props) => {
|
||||
const { icon, color, size } = props;
|
||||
const finalSize = size || 14;
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: color,
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
width: finalSize,
|
||||
height: finalSize,
|
||||
borderRadius: '50%',
|
||||
color: 'white',
|
||||
fontSize: finalSize * 0.55,
|
||||
}}
|
||||
>
|
||||
{icon === 'ArrowUpOutlined' ? <ArrowUpOutlined /> : <DownOutlined />}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default AlarmLevelBox;
|
@ -0,0 +1,3 @@
|
||||
export const localStorageKeyEnums = {
|
||||
alarmSetting_model_alarmStatusSetting: 'alarmSetting_model_alarmStatusSetting_key',
|
||||
};
|
@ -1,41 +0,0 @@
|
||||
import React from "react";
|
||||
import {Drawer} from "antd";
|
||||
import {ProColumns, ProDescriptions, ProDescriptionsItemProps} from "@ant-design/pro-components";
|
||||
|
||||
export type ColumnDrawProps = {
|
||||
handleDrawer: (id?: any)=>void;
|
||||
isShowDetail: boolean;
|
||||
columns: ProColumns<API.DeviceCategory>[];
|
||||
currentRow: API.DeviceCategory | undefined;
|
||||
};
|
||||
|
||||
|
||||
const ColumnDrawer: React.FC<ColumnDrawProps> = (props) => {
|
||||
|
||||
return (
|
||||
<Drawer
|
||||
width={500}
|
||||
open={props.isShowDetail}
|
||||
onClose={() => {
|
||||
props.handleDrawer();
|
||||
}}
|
||||
closable={true}
|
||||
>
|
||||
{props.currentRow?.id && (
|
||||
<ProDescriptions<API.DeviceCategory>
|
||||
column={2}
|
||||
title={props.currentRow?.id}
|
||||
request={async () => ({
|
||||
data: props.currentRow || {},
|
||||
})}
|
||||
params={{
|
||||
id: props.currentRow?.id,
|
||||
}}
|
||||
columns={props.columns as ProDescriptionsItemProps<API.DeviceCategory>[]}
|
||||
/>
|
||||
)}
|
||||
</Drawer>
|
||||
)
|
||||
}
|
||||
export {ColumnDrawer}
|
||||
|
@ -0,0 +1,78 @@
|
||||
// TODO 改为ts格式
|
||||
/**
|
||||
* Set storage
|
||||
*
|
||||
* @param name
|
||||
* @param content
|
||||
* @param maxAge
|
||||
*/
|
||||
export const setStore = (name, content, maxAge = null) => {
|
||||
if (!global.window || !name) {
|
||||
return
|
||||
}
|
||||
|
||||
if (typeof content !== 'string') {
|
||||
content = JSON.stringify(content)
|
||||
}
|
||||
|
||||
const storage = global.window.localStorage
|
||||
|
||||
storage.setItem(name, content)
|
||||
if (maxAge && !isNaN(parseInt(maxAge))) {
|
||||
const timeout = parseInt(new Date().getTime() / 1000)
|
||||
storage.setItem(`${name}_expire`, timeout + maxAge)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get storage
|
||||
*
|
||||
* @param name
|
||||
* @returns {*}
|
||||
*/
|
||||
export const getStore = name => {
|
||||
if (!global.window || !name) {
|
||||
return
|
||||
}
|
||||
|
||||
const content = window.localStorage.getItem(name)
|
||||
const _expire = window.localStorage.getItem(`${name}_expire`)
|
||||
|
||||
if (_expire) {
|
||||
const now = parseInt(new Date().getTime() / 1000)
|
||||
if (now > _expire) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(content)
|
||||
} catch (e) {
|
||||
return content
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear storage
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
export const clearStore = name => {
|
||||
if (!global.window || !name) {
|
||||
return
|
||||
}
|
||||
|
||||
window.localStorage.removeItem(name)
|
||||
window.localStorage.removeItem(`${name}_expire`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all storage
|
||||
*/
|
||||
export const clearAll = () => {
|
||||
if (!global.window || !name) {
|
||||
return
|
||||
}
|
||||
|
||||
window.localStorage.clear()
|
||||
}
|
Loading…
Reference in New Issue