Add providers to app.

This commit is contained in:
Yang Luo
2020-12-20 23:33:38 +08:00
parent 84c1f2634e
commit b13ec27981
5 changed files with 25 additions and 13 deletions

View File

@ -1,8 +1,11 @@
import React from "react";
import {Button, Card, Col, Input, Row} 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";
const { Option } = Select;
class ApplicationEditPage extends React.Component {
constructor(props) {
@ -11,13 +14,13 @@ class ApplicationEditPage extends React.Component {
classes: props,
applicationName: props.match.params.applicationName,
application: null,
tasks: [],
resources: [],
providers: [],
};
}
componentWillMount() {
this.getApplication();
this.getProviders();
}
getApplication() {
@ -29,6 +32,15 @@ class ApplicationEditPage extends React.Component {
});
}
getProviders() {
ProviderBackend.getProviders("admin")
.then((res) => {
this.setState({
providers: res,
});
});
}
parseApplicationField(key, value) {
// if ([].includes(key)) {
// value = Setting.myParseInt(value);
@ -79,9 +91,15 @@ class ApplicationEditPage extends React.Component {
Providers:
</Col>
<Col span={22} >
<Input value={this.state.application.providers} onChange={e => {
this.updateApplicationField('providers', e.target.value);
}} />
<Select mode="tags" style={{width: '100%'}}
value={this.state.application.providers}
onChange={value => {
this.updateApplicationField('providers', value);
}} >
{
this.state.providers.map((provider, index) => <Option key={index} value={provider.name}>{provider.name}</Option>)
}
</Select>
</Col>
</Row>
</Card>