Publisher: added basic redirection to login page if not logged in

merge-requests/77/head
Jayasanka 6 years ago
parent c64cb80507
commit ee80e42e9a

@ -2,6 +2,7 @@ import React from "react";
import "antd/dist/antd.css"; import "antd/dist/antd.css";
import {Table, Divider, Tag, Card, PageHeader, Typography, Avatar,Input, Button, Icon, Row, Col} from "antd"; import {Table, Divider, Tag, Card, PageHeader, Typography, Avatar,Input, Button, Icon, Row, Col} from "antd";
import Highlighter from 'react-highlight-words'; import Highlighter from 'react-highlight-words';
import axios from "axios";
const Paragraph = Typography; const Paragraph = Typography;
const Search = Input.Search; const Search = Input.Search;
@ -65,6 +66,34 @@ class Apps extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.routes = props.routes; this.routes = props.routes;
this.state = {
data: []
};
this.loadData = this.loadData.bind(this);
}
loadData(){
const thisComponent = this;
const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications";
axios.post('https://localhost:9443/api/application-mgt-handler/v1.0/invoke', request
).then(res => {
if(res.status === 200){
thisComponent.setState({
data : []
})
}
}).catch(function (error) {
if(error.status === 401){
window.location = 'https://localhost:9443/publisher/login'
}
});
}
componentDidMount() {
this.loadData();
} }
getColumnSearchProps = (dataIndex) => ({ getColumnSearchProps = (dataIndex) => ({
@ -113,17 +142,17 @@ class Apps extends React.Component {
textToHighlight={text.toString()} textToHighlight={text.toString()}
/> />
), ),
}) });
handleSearch = (selectedKeys, confirm) => { handleSearch = (selectedKeys, confirm) => {
confirm(); confirm();
this.setState({ searchText: selectedKeys[0] }); this.setState({ searchText: selectedKeys[0] });
} };
handleReset = (clearFilters) => { handleReset = (clearFilters) => {
clearFilters(); clearFilters();
this.setState({ searchText: '' }); this.setState({ searchText: '' });
} };
render() { render() {
@ -157,10 +186,10 @@ class Apps extends React.Component {
color = 'green'; color = 'green';
break; break;
case 'removed': case 'removed':
color = 'red' color = 'red';
break; break;
case 'default': case 'default':
color = 'blue' color = 'blue';
} }
return <Tag color={color} key={tag}>{tag.toUpperCase()}</Tag>; return <Tag color={color} key={tag}>{tag.toUpperCase()}</Tag>;
}, },
@ -202,7 +231,7 @@ class Apps extends React.Component {
<Button style={{margin:5}}>Advanced Search</Button> <Button style={{margin:5}}>Advanced Search</Button>
</Col> </Col>
</Row> </Row>
<Table columns={columns} dataSource={data}/> <Table columns={columns} dataSource={this.state.data}/>
</Card> </Card>
</div> </div>

Loading…
Cancel
Save