diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json index 47b11b05c1..8ac3b83577 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json @@ -4,6 +4,7 @@ "value": "lightBaseTheme" }, "serverConfig": { + "protocol": "https", "hostname": "localhost", "httpsPort": "9443", "invokerUri": "/api/application-mgt-handler/v1.0/invoke", 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 5d764c99ea..da83fc878f 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 @@ -30,7 +30,7 @@ class DetailedRating extends React.Component{ getData = (uuid)=>{ const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid+"/rating"; - return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { let detailedRating = res.data.data; @@ -41,7 +41,7 @@ class DetailedRating extends React.Component{ }).catch(function (error) { if (error.response.status === 401) { - window.location.href = 'https://localhost:9443/store/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } }); }; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js index 9095b68b15..89949eb56e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js @@ -120,7 +120,7 @@ class ConnectedAppsTable extends React.Component { const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); console.log(request); - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { let apps = []; @@ -143,7 +143,7 @@ class ConnectedAppsTable extends React.Component { }).catch((error) => { if (error.response.status === 401) { message.error('You are not logged in'); - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.error('Something went wrong... :('); } 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 d1d7ef4157..9339835363 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 @@ -21,7 +21,7 @@ class ManageCategories extends React.Component { componentDidMount() { const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/categories"; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { let categories = JSON.parse(res.data.data); @@ -33,7 +33,7 @@ class ManageCategories extends React.Component { }).catch((error) => { if (error.response.status === 401) { - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); @@ -56,7 +56,7 @@ class ManageCategories extends React.Component { loading: true }); const request = "method=delete&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories/" + id; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { notification["success"]({ @@ -65,23 +65,22 @@ class ManageCategories extends React.Component { "Category Removed Successfully!", }); + const {categories} = this.state; + const remainingElements = categories.filter(function (value) { + return value.categoryName !== id; + + }); + this.setState({ - loading: false + loading: false, + categories: remainingElements }); - // this.setState({ - // categories: [...categories, ...tempElements], - // tempElements: [], - // inputVisible: false, - // inputValue: '', - // loading: false, - // isAddNewVisible: false - // }); } }).catch((error) => { if (error.response.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); } @@ -135,12 +134,12 @@ class ManageCategories extends React.Component { }; renderTempElement = (category) => { - const {tempElements} = this.state; const tagElem = ( { + onClose={e=>{ e.preventDefault(); + const {tempElements} = this.state; const remainingElements = tempElements.filter(function (value) { return value.categoryName !== category.categoryName; @@ -196,7 +195,7 @@ class ManageCategories extends React.Component { const dataArray = JSON.stringify(tempElements.map(category => category.categoryName)); const request = "method=post&content-type=application/json&payload=" + dataArray + "&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories"; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { notification["success"]({ @@ -218,7 +217,7 @@ class ManageCategories extends React.Component { }).catch((error) => { if (error.response.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); } @@ -257,7 +256,7 @@ class ManageCategories extends React.Component { isEditModalVisible: false, }); const request = "method=put&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories/rename?from="+currentlyEditingId+"%26to="+editingValue; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { notification["success"]({ @@ -278,7 +277,7 @@ class ManageCategories extends React.Component { }).catch((error) => { if (error.response.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); } 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 726b9225d2..047669ca59 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 @@ -21,7 +21,7 @@ class ManageTags extends React.Component { componentDidMount() { const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/tags"; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { let categories = JSON.parse(res.data.data); @@ -33,7 +33,7 @@ class ManageTags extends React.Component { }).catch((error) => { if (error.response.status === 401) { - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); @@ -56,7 +56,7 @@ class ManageTags extends React.Component { loading: true }); const request = "method=delete&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories/" + id; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { notification["success"]({ @@ -81,7 +81,7 @@ class ManageTags extends React.Component { }).catch((error) => { if (error.response.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); } @@ -196,7 +196,7 @@ class ManageTags extends React.Component { const dataArray = JSON.stringify(tempElements.map(category => category.categoryName)); const request = "method=post&content-type=application/json&payload=" + dataArray + "&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories"; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { notification["success"]({ @@ -218,7 +218,7 @@ class ManageTags extends React.Component { }).catch((error) => { if (error.response.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); } @@ -257,7 +257,7 @@ class ManageTags extends React.Component { isEditModalVisible: false, }); const request = "method=put&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories?from="+currentlyEditingId+"%26to="+editingValue; - axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { notification["success"]({ @@ -278,7 +278,7 @@ class ManageTags extends React.Component { }).catch((error) => { if (error.response.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else { message.warning('Something went wrong'); } 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 42bfd2c3a9..b26e84c209 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 @@ -6,7 +6,7 @@ export const getApps = () => dispatch => { const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications"; - return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { let apps = []; @@ -19,7 +19,7 @@ export const getApps = () => dispatch => { }).catch(function (error) { if (error.response.status === 401) { - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } }); @@ -29,7 +29,7 @@ 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('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { let release = res.data.data; @@ -38,7 +38,7 @@ export const getRelease = (uuid) => dispatch => { }).catch(function (error) { if (error.response.status === 401) { - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } }); @@ -73,7 +73,7 @@ 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('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { let lifecycle = res.data.data; @@ -82,7 +82,7 @@ export const getLifecycle = () => dispatch => { }).catch(function (error) { if (error.response.status === 401) { - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } }); }; @@ -97,7 +97,7 @@ 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('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request ).then(res => { if (res.status === 201) { let release = res.data.data; @@ -111,7 +111,7 @@ export const updateLifecycleState = (uuid, nextState, reason) => dispatch => { }).catch(function (error) { if (error.response.status === 401) { - window.location.href = 'https://localhost:9443/publisher/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; } else if (error.response.status === 500) { alert("error"); dispatch({ 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 8953e32352..030a43dfe4 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 @@ -59,7 +59,7 @@ class NormalLoginForm extends React.Component { }); console.log('Received values of form: ', values); let data = "username=" + values.username + "&password=" + values.password + "&platform=publisher"; - axios.post('https://'+config.serverConfig.hostname+':'+config.serverConfig.httpsPort+config.serverConfig.loginUri, data + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname+':'+config.serverConfig.httpsPort+config.serverConfig.loginUri, data ).then(res => { if (res.status === 200) { window.location = res.data.url; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js index e32d5fff1b..58f562f14e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js @@ -4,9 +4,9 @@ import {Layout, Menu, Icon} from 'antd'; const {Header, Content, Footer} = Layout; import Logo from "../../../public/images/logo.svg"; -import {Link, NavLink} from "react-router-dom"; +import {BrowserRouter,Switch,Link, NavLink} from "react-router-dom"; import RouteWithSubRoutes from "../../components/RouteWithSubRoutes" -import {Switch, Redirect} from 'react-router' +import {Redirect} from 'react-router' import "../../App.css"; class Dashboard extends React.Component { @@ -41,13 +41,15 @@ class Dashboard extends React.Component { - - - {this.state.routes.map((route) => ( - - ))} + + + + {this.state.routes.map((route) => ( + + ))} - + +