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
parent ee92a9b7b4
commit bbec117fd6
7 changed files with 53 additions and 43 deletions

View File

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

View File

@ -199,7 +199,7 @@ class ProviderTable extends React.Component {
}
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={() => (
<div>
{this.props.title}&nbsp;&nbsp;&nbsp;&nbsp;

View File

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

View File

@ -210,7 +210,7 @@ class SignupTable extends React.Component {
];
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={() => (
<div>
{this.props.title}&nbsp;&nbsp;&nbsp;&nbsp;

View File

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

View File

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

View File

@ -79,7 +79,7 @@ class HomePage extends React.Component {
{
items.map(item => {
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} />
)
})
}