Add door page.

This commit is contained in:
Yang Luo 2021-02-11 16:43:30 +08:00
parent 1483d08df7
commit 09ffe69382
3 changed files with 48 additions and 2 deletions

View File

@ -27,6 +27,7 @@ import ProviderListPage from "./ProviderListPage";
import ProviderEditPage from "./ProviderEditPage"; import ProviderEditPage from "./ProviderEditPage";
import ApplicationListPage from "./ApplicationListPage"; import ApplicationListPage from "./ApplicationListPage";
import ApplicationEditPage from "./ApplicationEditPage"; import ApplicationEditPage from "./ApplicationEditPage";
import Face from "./Face";
const { Header, Footer } = Layout; const { Header, Footer } = Layout;
@ -308,7 +309,19 @@ class App extends Component {
) )
} }
isDoorPages() {
return window.location.pathname.startsWith('/doors/');
}
render() { render() {
if (this.isDoorPages()) {
return (
<Switch>
<Route exact path="/doors/:applicationName" component={Face}/>
</Switch>
)
}
return ( return (
<div id="parent-area"> <div id="parent-area">
<BackTop /> <BackTop />

View File

@ -135,6 +135,13 @@ class ApplicationEditPage extends React.Component {
Face Preview: Face Preview:
</Col> </Col>
<Col span={22} > <Col span={22} >
<a style={{marginBottom: '10px'}} target="_blank" href={`/doors/${this.state.application.name}`}>
{
`${window.location.host}/doors/${this.state.application.name}`
}
</a>
<br/>
<br/>
<div style={{width: "500px", height: "600px", border: "1px solid rgb(217,217,217)"}}> <div style={{width: "500px", height: "600px", border: "1px solid rgb(217,217,217)"}}>
<Face application={this.state.application} /> <Face application={this.state.application} />
</div> </div>

View File

@ -1,15 +1,39 @@
import React from "react"; import React from "react";
import {Button, Checkbox, Col, Form, Input, Row} from "antd"; import {Button, Checkbox, Col, Form, Input, Row} from "antd";
import {LockOutlined, UserOutlined} from "@ant-design/icons"; import {LockOutlined, UserOutlined} from "@ant-design/icons";
import * as ApplicationBackend from "./backend/ApplicationBackend";
class Face extends React.Component { class Face extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
classes: props, classes: props,
applicationName: props.match === undefined ? null : props.match.params.applicationName,
application: null,
}; };
} }
componentWillMount() {
this.getApplication();
}
getApplication() {
ApplicationBackend.getApplication("admin", this.state.applicationName)
.then((application) => {
this.setState({
application: application,
});
});
}
getApplicationObj() {
if (this.props.application !== undefined) {
return this.props.application;
} else {
return this.state.application;
}
}
renderForm() { renderForm() {
return ( return (
<Form <Form
@ -64,13 +88,15 @@ class Face extends React.Component {
} }
render() { render() {
const application = this.getApplicationObj();
return ( return (
<Row> <Row>
<Col span={24} style={{display: "flex", justifyContent: "center"}} > <Col span={24} style={{display: "flex", justifyContent: "center"}} >
<div style={{marginTop: "80px", textAlign: "center"}}> <div style={{marginTop: "80px", textAlign: "center"}}>
<img src={this.props.application.logo} alt={this.props.application.displayName} style={{marginBottom: '50px'}}/> <img src={application?.logo} alt={application?.displayName} style={{marginBottom: '50px'}}/>
{ {
this.renderForm(this.props.application) this.renderForm(application)
} }
</div> </div>
</Col> </Col>