diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json
index 3aa97aca334..3029a00c3f7 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json
@@ -18,7 +18,8 @@
"react-highlight-words": "^0.16.0",
"react-router-config": "^5.0.0",
"react-router-dom": "latest",
- "react-scripts": "2.1.8"
+ "react-scripts": "2.1.8",
+ "react-router": "latest"
},
"devDependencies": {
"@babel/core": "^7.0.0",
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js
index 734182829b7..df386140c4d 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js
@@ -13,19 +13,19 @@ import {Provider} from "react-redux";
const routes = [
{
- path: '/publisher/Login',
+ path: '/publisher/login',
component: Login
},
{
- path: '/publisher/dashboard',
+ path: '/publisher',
component: Dashboard,
routes: [
{
- path: '/publisher/dashboard/apps',
+ path: '/publisher/apps',
component: Apps
},
{
- path: '/publisher/dashboard/new-app',
+ path: '/publisher/new-app',
component: AddNewApp
}
]
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js
index d6b1b3fa15f..e49b031118b 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js
@@ -1,9 +1,10 @@
import React from "react";
-import {Typography, Row, Col, Form, Icon, Input, Button, Checkbox,} from 'antd';
+import {Typography, Row, Col, Form, Icon, Input, Button, Checkbox} from 'antd';
import styles from './Login.less';
import axios from 'axios';
const {Title} = Typography;
+const {Text} = Typography;
class Login extends React.Component {
render() {
@@ -35,17 +36,41 @@ class Login extends React.Component {
}
class NormalLoginForm extends React.Component {
+
+ constructor(props) {
+ super(props);
+ this.state = {
+ inValid: false,
+ loading : false
+ };
+ }
+
handleSubmit = (e) => {
+ const thisForm = this;
e.preventDefault();
this.props.form.validateFields((err, values) => {
+ thisForm.setState({
+ inValid: false
+ });
if (!err) {
+ thisForm.setState({
+ loading: true
+ });
console.log('Received values of form: ', values);
- let data = "username="+values.username+"&password="+values.password+"&platform=publisher";
+ let data = "username=" + values.username + "&password=" + values.password + "&platform=publisher";
axios.post('https://localhost:9443/api/application-mgt-handler/v1.0/login', data
- ).then(res => {
- console.log(res);
- console.log(res.data);
- })
+ ).then(res => {
+ if (res.status === 200) {
+ window.location = res.data.url;
+ }
+ }).catch(function (error) {
+ if (error.response.status === 400) {
+ thisForm.setState({
+ inValid: true,
+ loading: false
+ });
+ }
+ });
}
});
@@ -53,6 +78,14 @@ class NormalLoginForm extends React.Component {
render() {
const {getFieldDecorator} = this.props.form;
+ let errorMsg = "";
+ if (this.state.inValid) {
+ errorMsg =