From ee80e42e9a2fff0472083686267aaaf333ec8dbd Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Tue, 23 Apr 2019 22:29:19 +0530 Subject: [PATCH] Publisher: added basic redirection to login page if not logged in --- .../src/pages/dashboard/apps/Apps.js | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js index 3a2994b184..8e4ce3b10d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js @@ -2,6 +2,7 @@ import React from "react"; import "antd/dist/antd.css"; import {Table, Divider, Tag, Card, PageHeader, Typography, Avatar,Input, Button, Icon, Row, Col} from "antd"; import Highlighter from 'react-highlight-words'; +import axios from "axios"; const Paragraph = Typography; const Search = Input.Search; @@ -65,6 +66,34 @@ class Apps extends React.Component { constructor(props) { super(props); 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) => ({ @@ -113,17 +142,17 @@ class Apps extends React.Component { textToHighlight={text.toString()} /> ), - }) + }); handleSearch = (selectedKeys, confirm) => { confirm(); this.setState({ searchText: selectedKeys[0] }); - } + }; handleReset = (clearFilters) => { clearFilters(); this.setState({ searchText: '' }); - } + }; render() { @@ -157,10 +186,10 @@ class Apps extends React.Component { color = 'green'; break; case 'removed': - color = 'red' + color = 'red'; break; case 'default': - color = 'blue' + color = 'blue'; } return {tag.toUpperCase()}; }, @@ -202,7 +231,7 @@ class Apps extends React.Component { - +