#
vincentlu
昨天 f7543a1cc6c89ea03c0d6a0591526baf10d7934b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import * as React from 'react';
import { Labeled, useTranslate } from 'react-admin';
import { Box, Grid, Typography, Card, CardContent, TextField } from '@mui/material';
import { format } from 'date-fns';
import { getDirectionLabel } from './direction';
 
const IntegrationRecordDetail = (props) => {
    const { integration } = props;
    if (!integration) return null;
    const translate = useTranslate();
 
    const formatTimestamp = (timestamp) => {
        if (!timestamp) return '';
        try {
            return format(new Date(Number(timestamp)), 'yyyy-MM-dd HH:mm:ss');
        } catch (e) {
            return timestamp;
        }
    };
 
    return (
        <Box width={{ xs: '100vw', sm: 400 }} mt={{ xs: 2, sm: 1 }}>
            <Card>
                <CardContent>
                    <Grid container rowSpacing={1} mb={1}>
                        <Grid item xs={6}>
                            <Labeled label="table.field.integrationRecord.uuid">
                                <Typography variant="body2" flexWrap="nowrap">
                                    {integration.uuid || ''}
                                </Typography>
                            </Labeled>
                        </Grid>
                        <Grid item xs={6}>
                            <Labeled label="table.field.integrationRecord.namespace">
                                <Typography variant="body2" flexWrap="nowrap">
                                    {integration.namespace || ''}
                                </Typography>
                            </Labeled>
                        </Grid>
                        <Grid item xs={6}>
                            <Labeled label="table.field.integrationRecord.url">
                                <Typography variant="body2" flexWrap="nowrap">
                                    {integration.url || ''}
                                </Typography>
                            </Labeled>
                        </Grid>
                        <Grid item xs={6}>
                            <Labeled label="table.field.integrationRecord.appkey">
                                <Typography variant="body2" flexWrap="nowrap">
                                    {integration.appkey || ''}
                                </Typography>
                            </Labeled>
                        </Grid>
                        <Grid item xs={6}>
                            <Labeled label="table.field.integrationRecord.caller">
                                <Typography variant="body2" flexWrap="nowrap">
                                    {integration.caller || ''}
                                </Typography>
                            </Labeled>
                        </Grid>
                        <Grid item xs={6}>
                            <Labeled label="table.field.integrationRecord.direction">
                                <Typography variant="body2" flexWrap="nowrap">
                                    {getDirectionLabel(translate, integration.direction)}
                                </Typography>
                            </Labeled>
                        </Grid>
                        <Grid item xs={6}>
                            <Labeled label="table.field.integrationRecord.timestamp">
                                <Typography variant="body2" flexWrap="nowrap">
                                    {formatTimestamp(integration.timestamp)}
                                </Typography>
                            </Labeled>
                        </Grid>
                        <Grid item xs={6}>
                            <Labeled label="table.field.integrationRecord.clientIp">
                                <Typography variant="body2" flexWrap="nowrap">
                                    {integration.clientIp || ''}
                                </Typography>
                            </Labeled>
                        </Grid>
                        <Grid item xs={6}>
                            <Labeled label="table.field.integrationRecord.result">
                                <Typography variant="body2" flexWrap="nowrap">
                                    {integration.result$ || ''}
                                </Typography>
                            </Labeled>
                        </Grid>
                        <Grid item xs={6}>
                            <Labeled label="table.field.integrationRecord.costMs">
                                <Typography variant="body2" flexWrap="nowrap">
                                    {integration.costMs ?? ''}
                                </Typography>
                            </Labeled>
                        </Grid>
                        <Grid item xs={6}>
                            <Labeled label="table.field.integrationRecord.err">
                                <Typography variant="body2" flexWrap="nowrap">
                                    {integration.err || ''}
                                </Typography>
                            </Labeled>
                        </Grid>
                    </Grid>
                    <Grid container rowSpacing={2}>
                        <Grid item xs={12}>
                            <TextField
                                label="Request"
                                value={integration.request || ''}
                                maxRows={15}
                                multiline
                                fullWidth
                                InputProps={{ readOnly: true }}
                            />
                        </Grid>
                        <Grid item xs={12}>
                            <TextField
                                label="Response"
                                value={integration.response || ''}
                                maxRows={15}
                                multiline
                                fullWidth
                                InputProps={{ readOnly: true }}
                            />
                        </Grid>
                    </Grid>
                </CardContent>
            </Card>
        </Box>
    );
};
 
export default IntegrationRecordDetail;