From 7304e62f959711414f8e7bfeb1586b720fced94a Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Sat, 13 Feb 2021 01:33:06 +0800 Subject: [PATCH] Add login and account pages. --- object/organization.go | 5 +-- web/src/App.js | 16 ++++--- web/src/ApplicationListPage.js | 4 +- web/src/Face.js | 2 +- web/src/HomePage.js | 18 ++++++++ web/src/account/AccountPage.js | 77 ++++++++++++++++++++++++++++++++++ web/src/account/LoginPage.js | 12 ++++++ 7 files changed, 123 insertions(+), 11 deletions(-) create mode 100644 web/src/HomePage.js create mode 100644 web/src/account/AccountPage.js create mode 100644 web/src/account/LoginPage.js diff --git a/object/organization.go b/object/organization.go index 3e3a274d..cd1c4abf 100644 --- a/object/organization.go +++ b/object/organization.go @@ -24,9 +24,8 @@ type Organization struct { Name string `xorm:"varchar(100) notnull pk" json:"name"` CreatedTime string `xorm:"varchar(100)" json:"createdTime"` - DisplayName string `xorm:"varchar(100)" json:"displayName"` - WebsiteUrl string `xorm:"varchar(100)" json:"websiteUrl"` - Members []string `xorm:"varchar(100)" json:"members"` + DisplayName string `xorm:"varchar(100)" json:"displayName"` + WebsiteUrl string `xorm:"varchar(100)" json:"websiteUrl"` } func GetOrganizations(owner string) []*Organization { diff --git a/web/src/App.js b/web/src/App.js index 8f545805..28e186f5 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -28,6 +28,9 @@ import ProviderEditPage from "./ProviderEditPage"; import ApplicationListPage from "./ApplicationListPage"; import ApplicationEditPage from "./ApplicationEditPage"; import Face from "./Face"; +import AccountPage from "./account/AccountPage"; +import LoginPage from "./account/LoginPage"; +import HomePage from "./HomePage"; const { Header, Footer } = Layout; @@ -175,9 +178,9 @@ class App extends Component { renderMenu() { let res = []; - // if (this.state.account === null || this.state.account === undefined) { - // return []; - // } + if (this.state.account === null || this.state.account === undefined) { + return []; + } res.push( @@ -218,7 +221,7 @@ class App extends Component { return res; } - renderHomeIfLogined(component) { + renderHomeIfLoggedIn(component) { if (this.state.account !== null && this.state.account !== undefined) { return } else { @@ -265,6 +268,9 @@ class App extends Component { + this.renderHomeIfLoggedIn()}/> + this.renderLoginIfNotLoggedIn()}/> + this.renderLoginIfNotLoggedIn()}/> this.renderLoginIfNotLoggedIn()}/> this.renderLoginIfNotLoggedIn()}/> this.renderLoginIfNotLoggedIn()}/> @@ -303,7 +309,7 @@ class App extends Component { if (this.isDoorPages()) { return ( - + this.renderLoginIfNotLoggedIn()}/> ) } diff --git a/web/src/ApplicationListPage.js b/web/src/ApplicationListPage.js index 0dc7a6a8..844ce181 100644 --- a/web/src/ApplicationListPage.js +++ b/web/src/ApplicationListPage.js @@ -73,7 +73,7 @@ class ApplicationListPage extends React.Component { title: 'Name', dataIndex: 'name', key: 'name', - width: '120px', + width: '150px', sorter: (a, b) => a.name.localeCompare(b.name), render: (text, record, index) => { return ( @@ -104,7 +104,7 @@ class ApplicationListPage extends React.Component { title: 'Logo', dataIndex: 'logo', key: 'logo', - width: '100px', + width: '250px', render: (text, record, index) => { return ( diff --git a/web/src/Face.js b/web/src/Face.js index 305cb941..60ec5c94 100644 --- a/web/src/Face.js +++ b/web/src/Face.js @@ -10,7 +10,7 @@ class Face extends React.Component { super(props); this.state = { classes: props, - applicationName: props.match === undefined ? null : props.match.params.applicationName, + applicationName: props.applicationName !== undefined ? props.applicationName : (props.match === undefined ? null : props.match.params.applicationName), application: null, }; } diff --git a/web/src/HomePage.js b/web/src/HomePage.js new file mode 100644 index 00000000..1e30bb09 --- /dev/null +++ b/web/src/HomePage.js @@ -0,0 +1,18 @@ +import React from "react"; + +class HomePage extends React.Component { + constructor(props) { + super(props); + this.state = { + classes: props, + }; + } + + render() { + return ( + "home" + ) + } +} + +export default HomePage; diff --git a/web/src/account/AccountPage.js b/web/src/account/AccountPage.js new file mode 100644 index 00000000..73923e1e --- /dev/null +++ b/web/src/account/AccountPage.js @@ -0,0 +1,77 @@ +import React from "react"; +import {Col, Descriptions, Row} from 'antd'; +import * as AccountBackend from "../backend/AccountBackend"; +import * as Setting from "../Setting"; + +class AccountPage extends React.Component { + constructor(props) { + super(props); + this.state = { + classes: props, + username: props.match.params.username, + user: null, + }; + } + + componentWillMount() { + this.getUser(); + } + + getUser() { + if (this.state.username !== undefined) { + AccountBackend.getUser(this.state.username) + .then((user) => { + this.setState({ + user: user, + }); + }); + } + } + + renderValue(key) { + if (this.props.account === null || this.props.account === undefined) { + return Please sign in first + } else if (this.state.user !== null) { + return this.state.user[key]; + } else { + return this.props.account[key]; + } + } + + renderContent() { + return ( +
+   + + {this.renderValue("name")} + {this.renderValue("owner")} + {Setting.getFormattedDate(this.renderValue("createdTime"))} + {this.renderValue("passwordType")} + {this.renderValue("displayName")} + {this.renderValue("email")} + {this.renderValue("phone")} + +
+ ); + } + + render() { + return ( +
+ + + + + { + this.renderContent() + } + + + + +
+ ) + } +} + +export default AccountPage; diff --git a/web/src/account/LoginPage.js b/web/src/account/LoginPage.js new file mode 100644 index 00000000..a9f3bb53 --- /dev/null +++ b/web/src/account/LoginPage.js @@ -0,0 +1,12 @@ +import React from 'react'; +import Face from "../Face"; + +class LoginPage extends React.Component { + render() { + return ( + + ) + } +} + +export default LoginPage;