From a22dfd8954f04999b8310d6073b003b31b9a99a3 Mon Sep 17 00:00:00 2001 From: WindSpiritSR Date: Fri, 16 Jul 2021 17:04:16 +0800 Subject: [PATCH] fix: db data init and frontend warning Signed-off-by: WindSpiritSR --- object/init.go | 19 +++++++++++------- web/src/ProviderTable.js | 2 +- web/src/RecordListPage.js | 40 +++++++++++++++++++------------------- web/src/SignupTable.js | 2 +- web/src/auth/PromptPage.js | 9 +++------ web/src/auth/SignupPage.js | 22 ++++++++++++++------- web/src/basic/HomePage.js | 2 +- 7 files changed, 53 insertions(+), 43 deletions(-) diff --git a/object/init.go b/object/init.go index faa1631c..49c31fde 100644 --- a/object/init.go +++ b/object/init.go @@ -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, diff --git a/web/src/ProviderTable.js b/web/src/ProviderTable.js index 681803e1..5fa984bd 100644 --- a/web/src/ProviderTable.js +++ b/web/src/ProviderTable.js @@ -199,7 +199,7 @@ class ProviderTable extends React.Component { } return ( - (
{this.props.title}     diff --git a/web/src/RecordListPage.js b/web/src/RecordListPage.js index e52c18d8..e91a7722 100644 --- a/web/src/RecordListPage.js +++ b/web/src/RecordListPage.js @@ -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 ( - - {text.organization} + + {text} ) } }, { 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 (
-
(
{i18next.t("general:Records")}     diff --git a/web/src/SignupTable.js b/web/src/SignupTable.js index eaede9da..e8f1c66f 100644 --- a/web/src/SignupTable.js +++ b/web/src/SignupTable.js @@ -210,7 +210,7 @@ class SignupTable extends React.Component { ]; return ( -
(
{this.props.title}     diff --git a/web/src/auth/PromptPage.js b/web/src/auth/PromptPage.js index 6c8b0194..f2cce8fe 100644 --- a/web/src/auth/PromptPage.js +++ b/web/src/auth/PromptPage.js @@ -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={[ - { + - + Sign In + ]} > diff --git a/web/src/auth/SignupPage.js b/web/src/auth/SignupPage.js index fc2cc7cd..c802c867 100644 --- a/web/src/auth/SignupPage.js +++ b/web/src/auth/SignupPage.js @@ -161,6 +161,7 @@ class SignupPage extends React.Component { return ( { + - + Sign In + ]} > @@ -431,11 +439,11 @@ class SignupPage extends React.Component { {i18next.t("account:Sign Up")}   {i18next.t("signup:Have account?")}  - { + { Setting.goToLogin(this, application); }}> {i18next.t("signup:sign in now")} - + ) diff --git a/web/src/basic/HomePage.js b/web/src/basic/HomePage.js index 886ba5a9..6e281b08 100644 --- a/web/src/basic/HomePage.js +++ b/web/src/basic/HomePage.js @@ -79,7 +79,7 @@ class HomePage extends React.Component { { items.map(item => { return ( - + ) }) }