Added custom application listing table.

feature/appm-store/pbac
Menaka Jayawardena 7 years ago
parent 7f05b1820c
commit ed2af13836

@ -18,7 +18,7 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import {withRouter} from 'react-router-dom'; import {withRouter} from 'react-router-dom';
import {Button, Col, Row, Table} from 'reactstrap'; import {Button, Col, Row} from 'reactstrap';
import Drawer from '../UIComponents/Drawer/Drawer'; import Drawer from '../UIComponents/Drawer/Drawer';
import ApplicationView from './View/ApplicationView'; import ApplicationView from './View/ApplicationView';
import {FormattedMessage} from 'react-intl'; import {FormattedMessage} from 'react-intl';
@ -96,6 +96,7 @@ class ApplicationListing extends Component {
data_id: "applicationName", data_id: "applicationName",
data_type: "string", data_type: "string",
sortable: true, sortable: true,
locale: "Application.name",
label: "Application Name", label: "Application Name",
sort: this.sortData sort: this.sortData
}, },
@ -103,18 +104,21 @@ class ApplicationListing extends Component {
data_id: "platform", data_id: "platform",
data_type: "image_array", data_type: "image_array",
sortable: false, sortable: false,
locale: "Platform",
label: "Platform" label: "Platform"
}, },
{ {
data_id: "category", data_id: "category",
data_type: "string", data_type: "string",
sortable: false, sortable: false,
locale: "Category",
label: "Category" label: "Category"
}, },
{ {
data_id: "status", data_id: "status",
data_type: "string", data_type: "string",
sortable: false, sortable: false,
locale: "Status",
label: "Status" label: "Status"
}, },
{ {
@ -125,14 +129,12 @@ class ApplicationListing extends Component {
} }
]; ];
componentWillMount() { componentWillMount() {
let getApps = ApplicationMgtApi.getApplications(); let getApps = ApplicationMgtApi.getApplications();
getApps.then(response => { getApps.then(response => {
console.log(response.data.applications); console.log(response);
this.setState({searchedApplications: response.data.applications}); this.setState({searchedApplications: response.data.applications});
// console.log(this.setState({data: response.data}), console.log(this.state));
}).catch(err => { }).catch(err => {
AuthHandler.unauthorizedErrorHandler(err); AuthHandler.unauthorizedErrorHandler(err);
}); });
@ -214,66 +216,46 @@ class ApplicationListing extends Component {
} }
render() { render() {
//TODO: Move this to a data table component.
return ( return (
<div id="application-list" style={this.state.appListStyle}> <div id="application-list" style={this.state.appListStyle}>
<Row> <Row className="app-list-table-header">
<Col xs="3 offset-9"> {this.headers.map(header => {
<div className="platform-link-placeholder"> if (header.data_id === "applicationName") {
<Button><i className="fw fw-settings"></i> return (
<FormattedMessage id="Platforms" defaultMessage="Platforms"/> <Col xs="5"><FormattedMessage id={header.locale} defaultMessage={header.label}/></Col>)
</Button> } else if (header.data_id === "image") {
</div> return (<Col xs="1">{header.label}</Col>)
</Col> }
return (<Col><FormattedMessage id={header.locale} defaultMessage={header.label}/></Col>)
})}
</Row> </Row>
<Row> <hr/>
<Col> {this.state.searchedApplications.map(application => {
<Table striped hover>
<thead>
<tr className="app-list-table-header">
<th></th>
{/* TODO: Remove console.log and add sort method. */}
<th onClick={() => {
console.log("sort")
}}>
<FormattedMessage id="Application.Name" defaultMessage="Application Name"/>
</th>
<th><FormattedMessage id="Category" defaultMessage="Category"/></th>
<th><FormattedMessage id="Platform" defaultMessage="Platform"/></th>
<th><FormattedMessage id="Status" defaultMessage="Status"/></th>
<th></th>
</tr>
</thead>
<tbody>
{this.state.searchedApplications.map(
(application) => {
return ( return (
<tr key={application.uuid} onClick={() => this.onRowClick(application.uuid)}> <Row className="app-table-row" onClick={() => {
<td data={application.uuid}> this.onRowClick(application.uuid)
{/* TODO: Move this styles to css. */} }}>
<Col xs="1">
<img <img
height='50px' className="app-list-icon"
width='50px' src={application.icon}
style={{border: 'solid 1px black', borderRadius: "100%"}}
/> />
</td> </Col>
<td>{application.name}</td> <Col xs="5" className="data-table-row-cell"><strong>{application.name}</strong></Col>
<td>{application.category.name}</td> <Col className="data-table-row-cell">{application.platform.name}</Col>
<td>{application.platform.name}</td> <Col className="data-table-row-cell">{application.category.name}</Col>
<td>{application.currentLifecycle.lifecycleState.name}</td> <Col
<td> className="data-table-row-cell">{application.currentLifecycle.lifecycleState.name}
</Col>
<Col>
<Button id="secondary-button" onClick={() => this.onAppEditClick(application.uuid)}> <Button id="secondary-button" onClick={() => this.onAppEditClick(application.uuid)}>
<i className="fw fw-edit"></i> <i className="fw fw-edit"></i>
</Button> </Button>
</td>
</tr>
)
}
)}
</tbody>
</Table>
</Col> </Col>
</Row> </Row>
)
})}
<Drawer onClose={this.closeDrawer.bind(this)} style={this.state.drawer}> <Drawer onClose={this.closeDrawer.bind(this)} style={this.state.drawer}>
<ApplicationView application={this.state.application}/> <ApplicationView application={this.state.application}/>
</Drawer> </Drawer>

Loading…
Cancel
Save