Add Organization to Application.

This commit is contained in:
Yang Luo
2021-02-11 23:51:29 +08:00
parent 3ea58a0cdc
commit 8790e95147
3 changed files with 45 additions and 5 deletions

View File

@ -1,9 +1,10 @@
import React from "react";
import {AutoComplete, Button, Card, Col, Input, Row, Select} from 'antd';
import {Button, Card, Col, Input, Row, Select} from 'antd';
import {LinkOutlined} from "@ant-design/icons";
import * as ApplicationBackend from "./backend/ApplicationBackend";
import * as Setting from "./Setting";
import * as ProviderBackend from "./backend/ProviderBackend";
import * as OrganizationBackend from "./backend/OrganizationBackend";
import Face from "./Face";
const { Option } = Select;
@ -15,12 +16,14 @@ class ApplicationEditPage extends React.Component {
classes: props,
applicationName: props.match.params.applicationName,
application: null,
organizations: [],
providers: [],
};
}
componentWillMount() {
this.getApplication();
this.getOrganizations();
this.getProviders();
}
@ -33,6 +36,15 @@ class ApplicationEditPage extends React.Component {
});
}
getOrganizations() {
OrganizationBackend.getOrganizations("admin")
.then((res) => {
this.setState({
organizations: res,
});
});
}
getProviders() {
ProviderBackend.getProviders("admin")
.then((res) => {
@ -114,6 +126,18 @@ class ApplicationEditPage extends React.Component {
</Row>
</Col>
</Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={2}>
Organization:
</Col>
<Col span={22} >
<Select virtual={false} style={{width: '100%'}} value={this.state.application.organization} onChange={(value => {this.updateApplicationField('organization', value);})}>
{
this.state.organizations.map((organization, index) => <Option key={index} value={organization.name}>{organization.name}</Option>)
}
</Select>
</Col>
</Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={2}>
Providers:

View File

@ -2,6 +2,8 @@ import React from "react";
import {Button, Checkbox, Col, Form, Input, Row} from "antd";
import {LockOutlined, UserOutlined} from "@ant-design/icons";
import * as ApplicationBackend from "./backend/ApplicationBackend";
import * as AccountBackend from "./backend/AccountBackend";
import * as Setting from "./Setting";
class Face extends React.Component {
constructor(props) {
@ -34,12 +36,25 @@ class Face extends React.Component {
}
}
onFinish(values) {
AccountBackend.login(values)
.then((res) => {
if (res.status === 'ok') {
this.props.onLogined();
Setting.showMessage("success", `Logged in successfully`);
Setting.goToLink("/");
} else {
Setting.showMessage("error", `Log in failed${res.msg}`);
}
});
};
renderForm() {
return (
<Form
name="normal_login"
initialValues={{ remember: true }}
// onFinish={this.onFinish.bind(this)}
onFinish={this.onFinish.bind(this)}
style={{width: "250px"}}
size="large"
>