fix: db data init and frontend warning

Signed-off-by: WindSpiritSR <simon343riley@gmail.com>
This commit is contained in:
WindSpiritSR
2021-07-16 17:04:16 +08:00
committed by Yang Luo
parent e986d3ab8e
commit a22dfd8954
7 changed files with 53 additions and 43 deletions

View File

@ -20,6 +20,9 @@ func initBuiltInOrganization() {
CreatedTime: util.GetCurrentTime(), CreatedTime: util.GetCurrentTime(),
DisplayName: "Built-in Organization", DisplayName: "Built-in Organization",
WebsiteUrl: "https://example.com", WebsiteUrl: "https://example.com",
Favicon: "https://cdn.casbin.com/static/favicon.ico",
PhonePrefix: "86",
DefaultAvatar: "https://casbin.org/img/casbin.svg",
PasswordType: "plain", PasswordType: "plain",
} }
AddOrganization(organization) AddOrganization(organization)
@ -36,11 +39,13 @@ func initBuiltInUser() {
Name: "admin", Name: "admin",
CreatedTime: util.GetCurrentTime(), CreatedTime: util.GetCurrentTime(),
Id: util.GenerateId(), Id: util.GenerateId(),
Type: "normal-user",
Password: "123", Password: "123",
DisplayName: "Admin", DisplayName: "Admin",
Avatar: "https://casbin.org/img/casbin.svg", Avatar: "https://casbin.org/img/casbin.svg",
Email: "admin@example.com", Email: "admin@example.com",
Phone: "1-12345678", Phone: "12345678910",
Address: []string{},
Affiliation: "Example Inc.", Affiliation: "Example Inc.",
Tag: "staff", Tag: "staff",
IsAdmin: true, IsAdmin: true,

View File

@ -199,7 +199,7 @@ class ProviderTable extends React.Component {
} }
return ( return (
<Table rowKey="index" columns={columns} dataSource={table} size="middle" bordered pagination={false} <Table rowKey="name" columns={columns} dataSource={table} size="middle" bordered pagination={false}
title={() => ( title={() => (
<div> <div>
{this.props.title}&nbsp;&nbsp;&nbsp;&nbsp; {this.props.title}&nbsp;&nbsp;&nbsp;&nbsp;

View File

@ -59,73 +59,73 @@ class RecordListPage extends React.Component {
const columns = [ const columns = [
{ {
title: i18next.t("general:Client ip"), title: i18next.t("general:Client ip"),
dataIndex: 'Record', dataIndex: ['Record', 'clientIp'],
key: 'Record', key: 'id',
width: '120px', width: '120px',
sorter: (a, b) => a.Record.clientIp.localeCompare(b.Record.clientIp), sorter: (a, b) => a.Record.clientIp.localeCompare(b.Record.clientIp),
render: (text, record, index) => { render: (text, record, index) => {
return text.clientIp; return text;
} }
}, },
{ {
title: i18next.t("general:Timestamp"), title: i18next.t("general:Timestamp"),
dataIndex: 'Record', dataIndex: ['Record', 'timestamp'],
key: 'Record', key: 'id',
width: '160px', width: '160px',
sorter: (a, b) => a.Record.timestamp.localeCompare(b.Record.timestamp), sorter: (a, b) => a.Record.timestamp.localeCompare(b.Record.timestamp),
render: (text, record, index) => { render: (text, record, index) => {
return Setting.getFormattedDate(text.timestamp); return Setting.getFormattedDate(text);
} }
}, },
{ {
title: i18next.t("general:Organization"), title: i18next.t("general:Organization"),
dataIndex: 'Record', dataIndex: ['Record', 'organization'],
key: 'Record', key: 'id',
width: '120px', width: '120px',
sorter: (a, b) => a.Record.organization.localeCompare(b.Record.organization), sorter: (a, b) => a.Record.organization.localeCompare(b.Record.organization),
render: (text, record, index) => { render: (text, record, index) => {
return ( return (
<Link to={`/organizations/${text.organization}`}> <Link to={`/organizations/${text}`}>
{text.organization} {text}
</Link> </Link>
) )
} }
}, },
{ {
title: i18next.t("general:Username"), title: i18next.t("general:Username"),
dataIndex: 'Record', dataIndex: ['Record', 'username'],
key: 'Record', key: 'id',
width: '160px', width: '160px',
sorter: (a, b) => a.Record.username.localeCompare(b.Record.username), sorter: (a, b) => a.Record.username.localeCompare(b.Record.username),
render: (text, record, index) => { render: (text, record, index) => {
return text.username; return text;
} }
}, },
{ {
title: i18next.t("general:Request uri"), title: i18next.t("general:Request uri"),
dataIndex: 'Record', dataIndex: ['Record', 'requestUri'],
key: 'Record', key: 'id',
width: '160px', width: '160px',
sorter: (a, b) => a.Record.requestUri.localeCompare(b.Record.requestUri), sorter: (a, b) => a.Record.requestUri.localeCompare(b.Record.requestUri),
render: (text, record, index) => { render: (text, record, index) => {
return text.requestUri; return text;
} }
}, },
{ {
title: i18next.t("general:Action"), title: i18next.t("general:Action"),
dataIndex: 'Record', dataIndex: ['Record', 'action'],
key: 'Record', key: 'id',
width: '160px', width: '160px',
sorter: (a, b) => a.Record.action.localeCompare(b.Record.action), sorter: (a, b) => a.Record.action.localeCompare(b.Record.action),
render: (text, record, index) => { render: (text, record, index) => {
return text.action; return text;
} }
}, },
]; ];
return ( return (
<div> <div>
<Table columns={columns} dataSource={records} rowKey="name" size="middle" bordered pagination={{pageSize: 100}} <Table columns={columns} dataSource={records} rowKey="id" size="middle" bordered pagination={{pageSize: 100}}
title={() => ( title={() => (
<div> <div>
{i18next.t("general:Records")}&nbsp;&nbsp;&nbsp;&nbsp; {i18next.t("general:Records")}&nbsp;&nbsp;&nbsp;&nbsp;

View File

@ -210,7 +210,7 @@ class SignupTable extends React.Component {
]; ];
return ( return (
<Table rowKey="index" columns={columns} dataSource={table} size="middle" bordered pagination={false} <Table rowKey="name" columns={columns} dataSource={table} size="middle" bordered pagination={false}
title={() => ( title={() => (
<div> <div>
{this.props.title}&nbsp;&nbsp;&nbsp;&nbsp; {this.props.title}&nbsp;&nbsp;&nbsp;&nbsp;

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
import React from "react"; import React from "react";
import {Link} from "react-router-dom";
import {Button, Col, Result, Row} from "antd"; import {Button, Col, Result, Row} from "antd";
import * as ApplicationBackend from "../backend/ApplicationBackend"; import * as ApplicationBackend from "../backend/ApplicationBackend";
import * as UserBackend from "../backend/UserBackend"; import * as UserBackend from "../backend/UserBackend";
@ -196,13 +195,11 @@ class PromptPage extends React.Component {
title="Sign Up Error" title="Sign Up Error"
subTitle={"You are unexpected to see this prompt page"} subTitle={"You are unexpected to see this prompt page"}
extra={[ extra={[
<Link onClick={() => { <Button type="primary" key="signin" onClick={() => {
Setting.goToLogin(this, application); Setting.goToLogin(this, application);
}}> }}>
<Button type="primary" key="signin">
Sign In Sign In
</Button> </Button>
</Link>
]} ]}
> >
</Result> </Result>

View File

@ -161,6 +161,7 @@ class SignupPage extends React.Component {
return ( return (
<Form.Item <Form.Item
name="username" name="username"
key="username"
label={i18next.t("signup:Username")} label={i18next.t("signup:Username")}
rules={[ rules={[
{ {
@ -177,6 +178,7 @@ class SignupPage extends React.Component {
return ( return (
<Form.Item <Form.Item
name="name" name="name"
key="name"
label={signupItem.rule === "Personal" ? i18next.t("general:Personal name") : i18next.t("general:Display name")} label={signupItem.rule === "Personal" ? i18next.t("general:Personal name") : i18next.t("general:Display name")}
rules={[ rules={[
{ {
@ -193,6 +195,7 @@ class SignupPage extends React.Component {
return ( return (
<Form.Item <Form.Item
name="affiliation" name="affiliation"
key="affiliation"
label={i18next.t("user:Affiliation")} label={i18next.t("user:Affiliation")}
rules={[ rules={[
{ {
@ -210,6 +213,7 @@ class SignupPage extends React.Component {
<React.Fragment> <React.Fragment>
<Form.Item <Form.Item
name="email" name="email"
key="email"
label={i18next.t("general:Email")} label={i18next.t("general:Email")}
rules={[ rules={[
{ {
@ -233,6 +237,7 @@ class SignupPage extends React.Component {
</Form.Item> </Form.Item>
<Form.Item <Form.Item
name="emailCode" name="emailCode"
key="emailCode"
label={i18next.t("code:Email code")} label={i18next.t("code:Email code")}
rules={[{ rules={[{
required: required, required: required,
@ -253,6 +258,7 @@ class SignupPage extends React.Component {
return ( return (
<Form.Item <Form.Item
name="password" name="password"
key="password"
label={i18next.t("general:Password")} label={i18next.t("general:Password")}
rules={[ rules={[
{ {
@ -269,6 +275,7 @@ class SignupPage extends React.Component {
return ( return (
<Form.Item <Form.Item
name="confirm" name="confirm"
key="confirm"
label={i18next.t("signup:Confirm")} label={i18next.t("signup:Confirm")}
dependencies={['password']} dependencies={['password']}
hasFeedback hasFeedback
@ -296,6 +303,7 @@ class SignupPage extends React.Component {
<React.Fragment> <React.Fragment>
<Form.Item <Form.Item
name="phone" name="phone"
key="phone"
label={i18next.t("general:Phone")} label={i18next.t("general:Phone")}
rules={[ rules={[
{ {
@ -325,6 +333,7 @@ class SignupPage extends React.Component {
</Form.Item> </Form.Item>
<Form.Item <Form.Item
name="phoneCode" name="phoneCode"
key="phoneCode"
label={i18next.t("code:Phone code")} label={i18next.t("code:Phone code")}
rules={[ rules={[
{ {
@ -347,6 +356,7 @@ class SignupPage extends React.Component {
return ( return (
<Form.Item <Form.Item
name="agreement" name="agreement"
key="agreement"
valuePropName="checked" valuePropName="checked"
rules={[ rules={[
{ {
@ -375,13 +385,11 @@ class SignupPage extends React.Component {
title="Sign Up Error" title="Sign Up Error"
subTitle={"The application does not allow to sign up new account"} subTitle={"The application does not allow to sign up new account"}
extra={[ extra={[
<Link onClick={() => { <Button type="primary" key="signin" onClick={() => {
Setting.goToLogin(this, application); Setting.goToLogin(this, application);
}}> }}>
<Button type="primary" key="signin">
Sign In Sign In
</Button> </Button>
</Link>
]} ]}
> >
</Result> </Result>
@ -431,11 +439,11 @@ class SignupPage extends React.Component {
{i18next.t("account:Sign Up")} {i18next.t("account:Sign Up")}
</Button> </Button>
&nbsp;&nbsp;{i18next.t("signup:Have account?")}&nbsp; &nbsp;&nbsp;{i18next.t("signup:Have account?")}&nbsp;
<Link onClick={() => { <a onClick={() => {
Setting.goToLogin(this, application); Setting.goToLogin(this, application);
}}> }}>
{i18next.t("signup:sign in now")} {i18next.t("signup:sign in now")}
</Link> </a>
</Form.Item> </Form.Item>
</Form> </Form>
) )

View File

@ -79,7 +79,7 @@ class HomePage extends React.Component {
{ {
items.map(item => { items.map(item => {
return ( return (
<SingleCard logo={item.logo} link={item.link} title={item.name} desc={item.organizer} time={item.createdTime} isSingle={items.length === 1} /> <SingleCard logo={item.logo} link={item.link} title={item.name} desc={item.organizer} time={item.createdTime} isSingle={items.length === 1} key={item.name} />
) )
}) })
} }