Add isTriggered to record.

This commit is contained in:
Gucheng Wang
2021-11-07 17:42:41 +08:00
parent e9e0721b34
commit 87e6fb63e1
2 changed files with 37 additions and 8 deletions

View File

@ -33,6 +33,8 @@ type Record struct {
User string `xorm:"varchar(100)" json:"user"` User string `xorm:"varchar(100)" json:"user"`
RequestUri string `xorm:"varchar(1000)" json:"requestUri"` RequestUri string `xorm:"varchar(1000)" json:"requestUri"`
Action string `xorm:"varchar(1000)" json:"action"` Action string `xorm:"varchar(1000)" json:"action"`
IsTriggered bool `json:"isTriggered"`
} }
func NewRecord(ctx *context.Context) *Record { func NewRecord(ctx *context.Context) *Record {

View File

@ -14,7 +14,7 @@
import React from "react"; import React from "react";
import {Link} from "react-router-dom"; import {Link} from "react-router-dom";
import {Table} from 'antd'; import {Switch, Table} from 'antd';
import * as Setting from "./Setting"; import * as Setting from "./Setting";
import * as RecordBackend from "./backend/RecordBackend"; import * as RecordBackend from "./backend/RecordBackend";
import i18next from "i18next"; import i18next from "i18next";
@ -57,6 +57,7 @@ class RecordListPage extends React.Component {
username: "admin", username: "admin",
requestUri: "/api/get-account", requestUri: "/api/get-account",
action: "login", action: "login",
isTriggered: false,
} }
} }
@ -66,28 +67,35 @@ class RecordListPage extends React.Component {
title: i18next.t("general:Name"), title: i18next.t("general:Name"),
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
width: '220px', width: '320px',
sorter: (a, b) => a.name.localeCompare(b.name), sorter: (a, b) => a.name.localeCompare(b.name),
}, },
{ {
title: i18next.t("general:ID"), title: i18next.t("general:ID"),
dataIndex: 'id', dataIndex: 'id',
key: 'id', key: 'id',
width: '100px', width: '90px',
sorter: (a, b) => a.id - b.id, sorter: (a, b) => a.id - b.id,
}, },
{ {
title: i18next.t("general:Client IP"), title: i18next.t("general:Client IP"),
dataIndex: 'clientIp', dataIndex: 'clientIp',
key: 'clientIp', key: 'clientIp',
width: '100px', width: '150px',
sorter: (a, b) => a.clientIp.localeCompare(b.clientIp), sorter: (a, b) => a.clientIp.localeCompare(b.clientIp),
render: (text, record, index) => {
return (
<a target="_blank" rel="noreferrer" href={`https://db-ip.com/${text}`}>
{text}
</a>
)
}
}, },
{ {
title: i18next.t("general:Timestamp"), title: i18next.t("general:Timestamp"),
dataIndex: 'createdTime', dataIndex: 'createdTime',
key: 'createdTime', key: 'createdTime',
width: '120px', width: '180px',
sorter: (a, b) => a.createdTime.localeCompare(b.createdTime), sorter: (a, b) => a.createdTime.localeCompare(b.createdTime),
render: (text, record, index) => { render: (text, record, index) => {
return Setting.getFormattedDate(text); return Setting.getFormattedDate(text);
@ -97,7 +105,7 @@ class RecordListPage extends React.Component {
title: i18next.t("general:Organization"), title: i18next.t("general:Organization"),
dataIndex: 'organization', dataIndex: 'organization',
key: 'organization', key: 'organization',
width: '120px', width: '80px',
sorter: (a, b) => a.organization.localeCompare(b.organization), sorter: (a, b) => a.organization.localeCompare(b.organization),
render: (text, record, index) => { render: (text, record, index) => {
return ( return (
@ -113,24 +121,43 @@ class RecordListPage extends React.Component {
key: 'user', key: 'user',
width: '120px', width: '120px',
sorter: (a, b) => a.user.localeCompare(b.user), sorter: (a, b) => a.user.localeCompare(b.user),
render: (text, record, index) => {
return (
<Link to={`/users/${record.organization}/${record.user}`}>
{text}
</Link>
)
}
}, },
{ {
title: i18next.t("general:Request URI"), title: i18next.t("general:Request URI"),
dataIndex: 'requestUri', dataIndex: 'requestUri',
key: 'requestUri', key: 'requestUri',
width: '250px', // width: '300px',
sorter: (a, b) => a.requestUri.localeCompare(b.requestUri), sorter: (a, b) => a.requestUri.localeCompare(b.requestUri),
}, },
{ {
title: i18next.t("general:Action"), title: i18next.t("general:Action"),
dataIndex: 'action', dataIndex: 'action',
key: 'action', key: 'action',
width: '160px', width: '200px',
sorter: (a, b) => a.action.localeCompare(b.action), sorter: (a, b) => a.action.localeCompare(b.action),
render: (text, record, index) => { render: (text, record, index) => {
return text; return text;
} }
}, },
{
title: i18next.t("record:Is Triggered"),
dataIndex: 'isTriggered',
key: 'isTriggered',
width: '140px',
sorter: (a, b) => a.isTriggered - b.isTriggered,
render: (text, record, index) => {
return (
<Switch disabled checkedChildren="ON" unCheckedChildren="OFF" checked={text} />
)
}
},
]; ];
const paginationProps = { const paginationProps = {