From a5f75df99a5847a2862de01069f099e666a71703 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Fri, 12 Jul 2019 14:47:20 +0530 Subject: [PATCH] Change error messages in publisher --- .../apps/detailed-rating/DetailedRating.js | 6 +- .../AppDetailsDrawer/AppDetailsDrawer.js | 64 ++++++++----------- .../src/components/apps/list-apps/Filters.js | 34 ++++------ .../apps/list-apps/appsTable/AppsTable.js | 4 +- .../apps/release/lifeCycle/LifeCycle.js | 20 +++--- .../components/apps/release/review/Reviews.js | 10 ++- .../manage/categories/ManageCategories.js | 14 ++-- .../manage/categories/ManageTags.js | 22 +++---- .../src/components/new-app/AddNewAppForm.js | 22 +++---- .../react-app/src/js/actions/index.js | 28 +++++--- .../react-app/src/pages/Login.js | 24 +++---- .../pages/dashboard/apps/release/Release.js | 5 +- 12 files changed, 119 insertions(+), 134 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js index d7a4056c30..4854bb7dc2 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js @@ -1,5 +1,5 @@ import React from "react"; -import {Row, Typography, Icon} from "antd"; +import {Row, Typography, Icon, message} from "antd"; import StarRatings from "react-star-ratings"; import "./DetailedRating.css"; import config from "../../../../public/conf/config.json"; @@ -41,8 +41,10 @@ class DetailedRating extends React.Component{ } }).catch(function (error) { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; + } else { + message.error('Something went wrong while trying to load rating for the release... :('); } }); }; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppDetailsDrawer/AppDetailsDrawer.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppDetailsDrawer/AppDetailsDrawer.js index d9eed2d699..15ccc40718 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppDetailsDrawer/AppDetailsDrawer.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppDetailsDrawer/AppDetailsDrawer.js @@ -92,10 +92,8 @@ class AppDetailsDrawer extends React.Component { getCategories = () => { axios.get( - config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/categories", - { - headers: {'X-Platform': config.serverConfig.platform} - }).then(res => { + config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/categories" + ).then(res => { if (res.status === 200) { const categories = JSON.parse(res.data.data); @@ -115,10 +113,10 @@ class AppDetailsDrawer extends React.Component { } }).catch((error) => { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; } else { - message.warning('Something went wrong'); + message.warning('Something went wrong while trying to load app details... :('); } this.setState({ @@ -129,10 +127,8 @@ class AppDetailsDrawer extends React.Component { getTags = () => { axios.get( - config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/tags", - { - headers: {'X-Platform': config.serverConfig.platform} - }).then(res => { + config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/tags" + ).then(res => { if (res.status === 200) { const tags = JSON.parse(res.data.data); @@ -152,10 +148,10 @@ class AppDetailsDrawer extends React.Component { } }).catch((error) => { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; } else { - message.warning('Something went wrong'); + message.warning('Something went wrong when trying to load tags.'); } this.setState({ @@ -172,14 +168,12 @@ class AppDetailsDrawer extends React.Component { const data = {name: name}; axios.put( config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/" + id, - data, - { - headers: {'X-Platform': config.serverConfig.platform} - } + data ).then(res => { if (res.status === 200) { notification["success"]({ - message: 'Saved!' + message: 'Saved!', + description: 'App name updated successfully!' }); this.setState({ loading: false, @@ -192,7 +186,7 @@ class AppDetailsDrawer extends React.Component { message.error('You are not logged in'); window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; } else { - message.error('Something went wrong... :('); + message.error('Something went wrong when trying to save the app name... :('); } this.setState({loading: false}); @@ -231,7 +225,6 @@ class AppDetailsDrawer extends React.Component { }); }; - // handle description change handleCategoryChange = (temporaryCategories) => { this.setState({temporaryCategories}) @@ -250,14 +243,12 @@ class AppDetailsDrawer extends React.Component { const data = {categories: temporaryCategories}; axios.put( config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/" + id, - data, - { - headers: {'X-Platform': config.serverConfig.platform} - } + data ).then(res => { if (res.status === 200) { notification["success"]({ - message: 'Saved!' + message: 'Saved!', + description: 'App categories updated successfully!' }); this.setState({ loading: false, @@ -271,7 +262,7 @@ class AppDetailsDrawer extends React.Component { message.error('You are not logged in'); window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; } else { - message.error('Something went wrong... :('); + message.error('Something went wrong when trying to updating categories'); } this.setState({loading: false}); @@ -297,7 +288,7 @@ class AppDetailsDrawer extends React.Component { this.setState({temporaryTags}) }; - // change app categories + // change app tags handleTagsSave = () => { const {id} = this.props.app; const {temporaryTags, tags} = this.state; @@ -311,14 +302,12 @@ class AppDetailsDrawer extends React.Component { const data = {tags: temporaryTags}; axios.put( config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/" + id, - data, - { - headers: {'X-Platform': config.serverConfig.platform} - } + data ).then(res => { if (res.status === 200) { notification["success"]({ - message: 'Saved!' + message: 'Saved!', + description: 'App tags updated successfully!' }); this.setState({ loading: false, @@ -331,7 +320,7 @@ class AppDetailsDrawer extends React.Component { message.error('You are not logged in'); window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; } else { - message.error('Something went wrong... :('); + message.error('Something went wrong when trying to update tags'); } this.setState({loading: false}); @@ -349,14 +338,12 @@ class AppDetailsDrawer extends React.Component { const data = {description: temporaryDescription}; axios.put( config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/" + id, - data, - { - headers: {'X-Platform': config.serverConfig.platform} - } + data ).then(res => { if (res.status === 200) { notification["success"]({ - message: 'Saved!' + message: 'Saved!', + description: 'App description updated successfully!' }); this.setState({ loading: false, @@ -526,7 +513,8 @@ class AppDetailsDrawer extends React.Component { { categories.map(category => { return ( - + {category} ); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/Filters.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/Filters.js index 0160917564..818072ee20 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/Filters.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/Filters.js @@ -1,10 +1,10 @@ import React from "react"; -import {Avatar, Card, Col, Row, Table, Typography, Input, Divider, Icon, Select, Button, Form, message, Radio} from "antd"; +import {Card, Col, Row,Typography, Input, Divider, Icon, Select, Button, Form, message, Radio} from "antd"; import axios from "axios"; import config from "../../../../public/conf/config.json"; const {Option} = Select; -const {Title, Text} = Typography; +const {Title} = Typography; class FiltersForm extends React.Component { @@ -49,10 +49,8 @@ class FiltersForm extends React.Component { getCategories = () => { axios.get( - config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/categories", - { - headers: {'X-Platform': config.serverConfig.platform} - }).then(res => { + config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/categories" + ).then(res => { if (res.status === 200) { let categories = JSON.parse(res.data.data); this.setState({ @@ -62,10 +60,10 @@ class FiltersForm extends React.Component { } }).catch((error) => { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; } else { - message.warning('Something went wrong'); + message.warning('Something went wrong while trying to load categories... :('); } this.setState({ @@ -76,10 +74,8 @@ class FiltersForm extends React.Component { getTags = () => { axios.get( - config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/tags", - { - headers: {'X-Platform': config.serverConfig.platform} - }).then(res => { + config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/tags" + ).then(res => { if (res.status === 200) { let tags = JSON.parse(res.data.data); this.setState({ @@ -89,10 +85,10 @@ class FiltersForm extends React.Component { } }).catch((error) => { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; } else { - message.warning('Something went wrong'); + message.warning('Something went wrong when trying to load tags'); } this.setState({ @@ -104,10 +100,8 @@ class FiltersForm extends React.Component { getDeviceTypes = () => { axios.get( - config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt + "/device-types", - { - headers: {'X-Platform': config.serverConfig.platform} - }).then(res => { + config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt + "/device-types" + ).then(res => { if (res.status === 200) { const deviceTypes = JSON.parse(res.data.data); this.setState({ @@ -117,10 +111,10 @@ class FiltersForm extends React.Component { } }).catch((error) => { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; } else { - message.warning('Something went wrong'); + message.warning('Something went wrong when trying to load device types'); } this.setState({ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/appsTable/AppsTable.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/appsTable/AppsTable.js index 033c05cd85..d62cc350e9 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/appsTable/AppsTable.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/appsTable/AppsTable.js @@ -1,5 +1,5 @@ import React from "react"; -import {Avatar, Card, Col, Row, Table, Typography, Tag, Icon, message} from "antd"; +import {Avatar, Table, Tag, Icon, message} from "antd"; import axios from "axios"; import pSBC from 'shade-blend-color'; import config from "../../../../../public/conf/config.json"; @@ -155,7 +155,7 @@ class AppsTable extends React.Component { message.error('You are not logged in'); window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { - message.error('Something went wrong... :('); + message.error('Something went wrong while trying to load apps... :('); } this.setState({loading: false}); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/lifeCycle/LifeCycle.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/lifeCycle/LifeCycle.js index 1d5fbcb427..c419d29271 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/lifeCycle/LifeCycle.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/lifeCycle/LifeCycle.js @@ -55,10 +55,9 @@ class LifeCycle extends React.Component { fetchData = () => { - axios.get(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/lifecycle-config", - { - headers: {'X-Platform': config.serverConfig.platform} - }).then(res => { + axios.get( + config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/lifecycle-config" + ).then(res => { if (res.status === 200) { const lifecycle = res.data.data; this.setState({ @@ -69,6 +68,8 @@ class LifeCycle extends React.Component { }).catch(function (error) { if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; + } else { + message.error('Something went wrong when trying to load lifecycle configuration'); } }); }; @@ -105,11 +106,10 @@ class LifeCycle extends React.Component { isConfirmButtonLoading: true, }); - axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/life-cycle/" + uuid, - data, - { - headers: {'X-Platform': config.serverConfig.platform} - }).then(res => { + axios.post( + config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/life-cycle/" + uuid, + data + ).then(res => { if (res.status === 201) { this.setState({ isReasonModalVisible: false, @@ -133,7 +133,7 @@ class LifeCycle extends React.Component { notification["error"]({ message: "Error", description: - "Something went wrong", + "Something went wrong when trying to add lifecycle", }); } this.setState({ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/review/Reviews.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/review/Reviews.js index 743be28680..19b508cc21 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/review/Reviews.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/review/Reviews.js @@ -31,20 +31,18 @@ class Reviews extends React.Component { const {uuid, type} = this.props; axios.get( - config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/admin/reviews/"+type+"/"+uuid, - { - headers: {'X-Platform': config.serverConfig.platform} - }).then(res => { + config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/admin/reviews/" + type + "/" + uuid + ).then(res => { if (res.status === 200) { let reviews = res.data.data.data; callback(reviews); } }).catch(function (error) { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; } else { - message.warning('Something went wrong'); + message.warning('Something went wrong when trying to load reviews'); } }); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageCategories.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageCategories.js index 6edc414cbc..3711368638 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageCategories.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageCategories.js @@ -33,7 +33,7 @@ class ManageCategories extends React.Component { } }).catch((error) => { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); @@ -80,11 +80,11 @@ class ManageCategories extends React.Component { } }).catch((error) => { - if (error.response.hasOwnProperty("status") && error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { message.error('You are not logged in'); window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { - message.warning('Something went wrong'); + message.warning('Something went wrong when trying to load categories'); } this.setState({ loading: false @@ -219,11 +219,11 @@ class ManageCategories extends React.Component { } }).catch((error) => { - if (error.response.hasOwnProperty("status") && error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { message.error('You are not logged in'); window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { - message.warning('Something went wrong'); + message.warning('Something went wrong when trying to add categories'); } this.setState({ loading: false @@ -281,11 +281,11 @@ class ManageCategories extends React.Component { } }).catch((error) => { - if (error.response.hasOwnProperty("status") && error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { message.error('You are not logged in'); window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { - message.warning('Something went wrong'); + message.warning('Something went wrong when trying to delete the category'); } this.setState({ loading: false, diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageTags.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageTags.js index e2a7e14993..e3c1595082 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageTags.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageTags.js @@ -32,10 +32,10 @@ class ManageTags extends React.Component { } }).catch((error) => { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { - message.warning('Something went wrong'); + message.warning('Something went wrong when trying to load tags'); } this.setState({ @@ -58,10 +58,8 @@ class ManageTags extends React.Component { }); axios.delete( - config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/admin/applications/tags/"+id, - { - headers: {'X-Platform': config.serverConfig.platform} - }).then(res => { + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/admin/applications/tags/"+id + ).then(res => { if (res.status === 200) { notification["success"]({ message: "Done!", @@ -82,11 +80,11 @@ class ManageTags extends React.Component { } }).catch((error) => { - if (error.response.hasOwnProperty("status") && error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { message.error('You are not logged in'); window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { - message.warning('Something went wrong'); + message.warning('Something went wrong when trying to delete the tag'); } this.setState({ loading: false @@ -219,11 +217,11 @@ class ManageTags extends React.Component { } }).catch((error) => { - if (error.response.hasOwnProperty("status") && error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { message.error('You are not logged in'); window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { - message.warning('Something went wrong'); + message.warning('Something went wrong when trying to delete tag'); } this.setState({ loading: false @@ -281,11 +279,11 @@ class ManageTags extends React.Component { } }).catch((error) => { - if (error.response.hasOwnProperty("status") && error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { message.error('You are not logged in'); window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { - message.warning('Something went wrong'); + message.warning('Something went wrong when trying to edit tag'); } this.setState({ loading: false, diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/AddNewAppForm.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/AddNewAppForm.js index 74856e99b8..95887548e0 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/AddNewAppForm.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/AddNewAppForm.js @@ -54,10 +54,8 @@ class AddNewAppFormComponent extends React.Component { getCategories = () => { axios.get( - config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/categories", - { - headers: {'X-Platform': config.serverConfig.platform} - }).then(res => { + config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/categories" + ).then(res => { if (res.status === 200) { let categories = JSON.parse(res.data.data); this.setState({ @@ -67,10 +65,10 @@ class AddNewAppFormComponent extends React.Component { } }).catch((error) => { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; } else { - message.warning('Something went wrong'); + message.warning('Something went wrong when trying to load categories'); } this.setState({ @@ -81,10 +79,8 @@ class AddNewAppFormComponent extends React.Component { getTags = () => { axios.get( - config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/tags", - { - headers: {'X-Platform': config.serverConfig.platform} - }).then(res => { + config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/tags" + ).then(res => { if (res.status === 200) { let tags = JSON.parse(res.data.data); this.setState({ @@ -94,10 +90,10 @@ class AddNewAppFormComponent extends React.Component { } }).catch((error) => { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; } else { - message.warning('Something went wrong'); + message.warning('Something went wrong when trying to load tags'); } this.setState({ @@ -209,7 +205,7 @@ class AddNewAppFormComponent extends React.Component { } }).catch((error) => { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; } else { notification["error"]({ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js index 79690cc148..f810921f45 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js @@ -1,12 +1,15 @@ import axios from "axios"; import ActionTypes from "../constants/ActionTypes"; import config from "../../../public/conf/config.json"; +import {message} from "antd"; export const getApps = () => dispatch => { const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications"; - return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher, request + return axios.post( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher, + request ).then(res => { if (res.status === 200) { let apps = []; @@ -18,8 +21,10 @@ export const getApps = () => dispatch => { } }).catch(function (error) { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; + } else { + message.error('Something went wrong when trying to load applications... :('); } }); @@ -29,7 +34,8 @@ export const getRelease = (uuid) => dispatch => { const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/release/" + uuid; - return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher, request + return axios.post( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher, request ).then(res => { if (res.status === 200) { let release = res.data.data; @@ -37,8 +43,10 @@ export const getRelease = (uuid) => dispatch => { } }).catch(function (error) { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; + } else { + message.error('Something went wrong... :('); } }); @@ -73,7 +81,8 @@ export const closeLifecycleModal = () => dispatch => { export const getLifecycle = () => dispatch => { const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/lifecycle-config"; - return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher, request + return axios.post( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher, request ).then(res => { if (res.status === 200) { let lifecycle = res.data.data; @@ -81,8 +90,10 @@ export const getLifecycle = () => dispatch => { } }).catch(function (error) { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; + } else { + message.error('Something went wrong... :('); } }); }; @@ -97,7 +108,8 @@ export const updateLifecycleState = (uuid, nextState, reason) => dispatch => { const request = "method=post&content-type=application/json&payload=" + JSON.stringify(payload) + "&api-endpoint=/application-mgt-publisher/v1.0/applications/life-cycle/" + uuid; - return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher, request + return axios.post( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher, request ).then(res => { if (res.status === 201) { let release = res.data.data; @@ -110,7 +122,7 @@ export const updateLifecycleState = (uuid, nextState, reason) => dispatch => { } }).catch(function (error) { - if (error.response.status === 401) { + if (error.hasOwnProperty("response") && error.response.status === 401) { window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else if (error.response.status === 500) { alert("error"); 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 c13c1d9827..cc7782747f 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,5 +1,5 @@ import React from "react"; -import {Typography, Row, Col, Form, Icon, Input, Button, Checkbox} from 'antd'; +import {Typography, Row, Col, Form, Icon, Input, Button, Checkbox, message} from 'antd'; import './Login.css'; import axios from 'axios'; import config from "../../public/conf/config.json"; @@ -12,14 +12,11 @@ class Login extends React.Component { render() { return (
-
+
- @@ -35,7 +32,6 @@ class Login extends React.Component { Login - @@ -80,17 +76,21 @@ class NormalLoginForm extends React.Component { const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.loginUri, request - ).then(res => { + ).then(res=>{ if (res.status === 200) { window.location = res.data.url; } }).catch(function (error) { - if (error.response.status === 400) { + if (error.hasOwnProperty("response") && error.response.status === 400) { thisForm.setState({ - inValid: true, - loading: false + inValid: true }); + } else { + message.error('Something went wrong when trying to login... :('); } + thisForm.setState({ + loading: false + }); }); } @@ -111,7 +111,7 @@ class NormalLoginForm extends React.Component {
{getFieldDecorator('username', { - rules: [{required: true, message: 'Please input your username!'}], + rules: [{required: true, message: 'Please enter your username'}], })( } placeholder="Username"/> @@ -119,7 +119,7 @@ class NormalLoginForm extends React.Component { {getFieldDecorator('password', { - rules: [{required: true, message: 'Please input your Password!'}], + rules: [{required: true, message: 'Please enter your password'}], })( } type="password" diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/release/Release.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/release/Release.js index 5f88170483..1fa7e5656e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/release/Release.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/release/Release.js @@ -47,9 +47,6 @@ class Release extends React.Component { //send request to the invoker axios.get( config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/release/"+ uuid, - { - headers: {'X-Platform': config.serverConfig.platform} - } ).then(res => { if (res.status === 200) { const app = res.data.data; @@ -70,7 +67,7 @@ class Release extends React.Component { message.error('You are not logged in'); window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; } else { - message.error('Something went wrong... :('); + message.error('Something went wrong when trying to load the release... :('); } this.setState({loading: false});