From 151ca7d5757bfd94b59fd031af99407a2966c930 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Thu, 25 Jul 2019 20:24:19 +0530 Subject: [PATCH] Remove origin from configuration file in APPM store --- .../react-app/public/conf/config.json | 3 --- .../react-app/src/components/apps/AppList.js | 4 ++-- .../src/components/apps/release/DetailedRating.js | 4 ++-- .../react-app/src/components/apps/release/ReleaseView.js | 4 ++-- .../src/components/apps/release/install/DeviceInstall.js | 4 ++-- .../src/components/apps/release/install/GroupInstall.js | 4 ++-- .../src/components/apps/release/install/RoleInstall.js | 4 ++-- .../src/components/apps/release/install/UserInstall.js | 4 ++-- .../src/components/apps/release/review/AddReview.js | 4 ++-- .../components/apps/release/review/CurrentUsersReview.js | 4 ++-- .../src/components/apps/release/review/Reviews.js | 4 ++-- .../apps/release/review/singleReview/SingleReview.js | 5 ++--- .../release/review/singleReview/editReview/EditReview.js | 4 ++-- .../react-app/src/pages/Login.js | 8 +++++--- .../react-app/src/pages/dashboard/apps/release/Release.js | 4 ++-- 15 files changed, 31 insertions(+), 33 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/conf/config.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/conf/config.json index ac90b4874d..3fab34b8b4 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/conf/config.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/conf/config.json @@ -6,9 +6,6 @@ "primaryColor": "rgb(24, 144, 255)" }, "serverConfig": { - "protocol": "https", - "hostname": "localhost", - "httpsPort": "9443", "invokerUri": "/ui-request-handler/invoke/application-mgt-store/v1.0", "invoker": { "uri": "/store-ui-request-handler/invoke", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppList.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppList.js index 02b41ade68..fe2732e2a4 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppList.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppList.js @@ -41,7 +41,7 @@ class AppList extends React.Component { }); //send request to the invoker axios.post( - config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/applications/", + window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/applications/", payload, ).then(res => { if (res.status === 200) { @@ -58,7 +58,7 @@ class AppList extends React.Component { if (error.hasOwnProperty("response") && error.response.status === 401) { //todo display a popup with error message.error('You are not logged in'); - window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login'; + window.location.href = window.location.origin+ '/store/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/DetailedRating.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/DetailedRating.js index f06b8b4793..08d290f37c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/DetailedRating.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/DetailedRating.js @@ -33,7 +33,7 @@ class DetailedRating extends React.Component{ const config = this.props.context; return axios.get( - config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+uuid+"/"+type+"-rating", + window.location.origin+ config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+uuid+"/"+type+"-rating", ).then(res => { if (res.status === 200) { let detailedRating = res.data.data; @@ -44,7 +44,7 @@ class DetailedRating extends React.Component{ }).catch(function (error) { if (error.response.status === 401) { - window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; + window.location.href = window.location.origin+'/publisher/login'; } }); }; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js index 8ae2867966..516ac367e4 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js @@ -29,7 +29,7 @@ class ReleaseView extends React.Component { this.setState({ loading: true, }); - const url = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/subscription/" + uuid + "/" + type + "/install"; + const url = window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/subscription/" + uuid + "/" + type + "/install"; axios.post( url, payload, @@ -61,7 +61,7 @@ class ReleaseView extends React.Component { }).catch((error) => { if (error.response.status === 401) { - window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login'; + window.location.href = window.location.origin+ '/store/login'; } else { this.setState({ loading: false, diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js index 7a804b6171..b1c13a6919 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js @@ -131,7 +131,7 @@ class DeviceInstall 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.deviceMgt+"/devices?" + encodedExtraParams, + window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/devices?" + encodedExtraParams, ).then(res => { if (res.status === 200) { @@ -148,7 +148,7 @@ class DeviceInstall extends React.Component { if (error.hasOwnProperty("status") && error.response.status === 401) { //todo display a popop with error message.error('You are not logged in'); - window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login'; + window.location.href = window.location.origin+ '/store/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/GroupInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/GroupInstall.js index 83ea7f7cba..7840e4f2f4 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/GroupInstall.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/GroupInstall.js @@ -29,7 +29,7 @@ class GroupInstall extends React.Component { this.setState({data: [], fetching: true}); axios.post( - config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/groups?name=" + value, + window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/groups?name=" + value, ).then(res => { if (res.status === 200) { @@ -49,7 +49,7 @@ class GroupInstall extends React.Component { }).catch((error) => { console.log(error); if (error.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login'; + window.location.href = window.location.origin+'/store/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleInstall.js index 617634b868..8f0db4bae1 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleInstall.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleInstall.js @@ -29,7 +29,7 @@ class RoleInstall extends React.Component { this.setState({data: [], fetching: true}); axios.get( - config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/roles?filter=" + value, + window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/roles?filter=" + value, ).then(res => { if (res.status === 200) { @@ -49,7 +49,7 @@ class RoleInstall extends React.Component { }).catch((error) => { console.log(error); if (error.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login'; + window.location.href = window.location.origin+'/store/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js index ec139d9071..418dfc995b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js @@ -31,7 +31,7 @@ class UserInstall 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.deviceMgt+"/users/search?username=" + value, + window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/users/search?username=" + value, ).then(res => { if (res.status === 200) { @@ -51,7 +51,7 @@ class UserInstall extends React.Component { }).catch((error) => { if (error.response.hasOwnProperty(status) && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login'; + window.location.href = window.location.origin+ '/store/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/AddReview.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/AddReview.js index f6939dfab9..9cdf163f2d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/AddReview.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/AddReview.js @@ -54,7 +54,7 @@ class AddReview extends React.Component { }; axios.post( - config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/" + uuid, + window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/" + uuid, payload, ).then(res => { if (res.status === 201) { @@ -86,7 +86,7 @@ class AddReview extends React.Component { }).catch((error) => { if (error.response.status === 401) { - window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login'; + window.location.href = window.location.origin+ '/store/login'; } else { this.setState({ loading: false, diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js index 14ef0409a6..81ed85fdbe 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js @@ -26,7 +26,7 @@ class CurrentUsersReview extends React.Component { const config = this.props.context; axios.get( - config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/app/user/" + uuid, + window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/app/user/" + uuid, ).then(res => { if (res.status === 200) { const data = res.data.data.data; @@ -36,7 +36,7 @@ class CurrentUsersReview extends React.Component { }).catch((error) => { if (error.response.hasOwnProperty(status) && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login'; + window.location.href = window.location.origin+ '/store/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.js index 3d00216e15..2d42469b86 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.js @@ -32,7 +32,7 @@ class Reviews extends React.Component { const config = this.props.context; axios.get( - config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+type+"/"+uuid, + window.location.origin+ config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+type+"/"+uuid, { headers: {'X-Platform': config.serverConfig.platform} }).then(res => { @@ -43,7 +43,7 @@ class Reviews extends React.Component { }).catch(function (error) { if (error.response.status === 401) { - window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login'; + window.location.href = window.location.origin+ '/store/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js index 0d9622817e..2dabd2a901 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js @@ -40,8 +40,7 @@ class SingleReview extends React.Component { const {id} = this.state.review; const config = this.props.context; - let url = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + - config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store; + let url =window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store; // call as an admin api if the review is not a personal review if (!this.props.isPersonalReview) { @@ -63,7 +62,7 @@ class SingleReview extends React.Component { }).catch((error) => { console.log(error); if (error.hasOwnProperty("response") && error.response.status === 401) { - window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login'; + window.location.href = window.location.origin+ '/store/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js index b382d3e8ec..52cebd7075 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js @@ -68,7 +68,7 @@ class EditReview extends React.Component { }; axios.put( - config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/" + uuid+"/"+id, + window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/" + uuid+"/"+id, payload, ).then(res => { if (res.status === 200) { @@ -99,7 +99,7 @@ class EditReview extends React.Component { }).catch((error) => { console.log(error); if (error.hasOwnProperty("response") && error.response.status === 401) { - window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login'; + window.location.href = window.location.origin+ '/store/login'; } else { this.setState({ loading: false, diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/Login.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/Login.js index 8cd95b5249..a2eb653697 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/Login.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/Login.js @@ -9,6 +9,7 @@ const {Text} = Typography; class Login extends React.Component { render() { + const config = this.props.context; return (
@@ -60,6 +61,7 @@ class NormalLoginForm extends React.Component { handleSubmit = (e) => { const thisForm = this; const config = this.props.context; + console.log(config); e.preventDefault(); this.props.form.validateFields((err, values) => { @@ -78,10 +80,10 @@ 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 + axios.post(window.location.origin+ config.serverConfig.loginUri, request ).then(res => { if (res.status === 200) { - window.location = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + "/store"; + window.location = window.location.origin+ "/store"; } }).catch(function (error) { if (error.response.status === 400) { @@ -146,6 +148,6 @@ class NormalLoginForm extends React.Component { } } -const WrappedNormalLoginForm = Form.create({name: 'normal_login'})(NormalLoginForm); +const WrappedNormalLoginForm = withConfigContext(Form.create({name: 'normal_login'})(NormalLoginForm)); export default withConfigContext(Login); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js index 296d319c4d..7989ba6827 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js @@ -40,7 +40,7 @@ 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.store+"/applications/"+uuid, + window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store+"/applications/"+uuid, ).then(res => { if (res.status === 200) { @@ -57,7 +57,7 @@ class Release extends React.Component { if (error.hasOwnProperty("response") && error.response.status === 401) { //todo display a popop with error message.error('You are not logged in'); - window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login'; + window.location.href = window.location.origin+ '/store/login'; } else { notification["error"]({ message: "There was a problem",