瀏覽代碼

feat(device): status->metadata log

Lind 4 年之前
父節點
當前提交
e9e99dc328

+ 42 - 0
src/pages/device/Instance/Detail/MetadataLog/Event/index.tsx

@@ -0,0 +1,42 @@
+import ProTable from '@jetlinks/pro-table';
+import { service } from '@/pages/device/Instance';
+import encodeQuery from '@/utils/encodeQuery';
+import { Drawer } from 'antd';
+import { useParams } from 'umi';
+import type { EventMetadata } from '@/pages/device/Product/typings';
+import columns from '@/pages/device/Instance/Detail/MetadataLog/columns';
+
+interface Props {
+  visible: boolean;
+  close: () => void;
+  data: Partial<EventMetadata>;
+}
+
+const EventLog = (props: Props) => {
+  const params = useParams<{ id: string }>();
+  const { data, visible, close } = props;
+
+  return (
+    <Drawer title={data.name} visible={visible} onClose={() => close()} width="45vw">
+      <ProTable
+        size="small"
+        toolBarRender={false}
+        request={async (param) =>
+          service.getPropertyData(
+            params.id,
+            encodeQuery({
+              ...param,
+              terms: { property: data.id },
+              sorts: { timestamp: 'desc' },
+            }),
+          )
+        }
+        pagination={{
+          pageSize: 15,
+        }}
+        columns={columns}
+      />
+    </Drawer>
+  );
+};
+export default EventLog;

+ 23 - 0
src/pages/device/Instance/Detail/MetadataLog/columns.ts

@@ -0,0 +1,23 @@
+import type { ProColumns } from '@jetlinks/pro-table';
+import moment from 'moment';
+
+const columns: ProColumns<MetadataLogData>[] = [
+  {
+    dataIndex: 'index',
+    valueType: 'indexBorder',
+    width: 48,
+  },
+  {
+    dataIndex: 'timestamp',
+    title: '时间',
+    sorter: true,
+    width: 200,
+    renderText: (text: string) => moment(text).format('YYYY-MM-DD HH:mm:ss'),
+  },
+  {
+    dataIndex: 'formatValue',
+    title: '数据',
+    copyable: true,
+  },
+];
+export default columns;

+ 4 - 0
src/pages/device/Instance/Detail/MetadataLog/index.d.ts

@@ -0,0 +1,4 @@
+type MetadataLogData = {
+  data: string;
+  date: string;
+};