From 129ff7944e4a2fa2de99fa9d414b013b6d006058 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Tue, 18 Jun 2019 16:31:32 +0530 Subject: [PATCH 1/3] Change api requests in publisher --- .../react-app/public/conf/config.json | 6 +- .../components/apps/list-apps/AppsTable.js | 24 ++++--- .../components/apps/release/ReleaseView.js | 9 +-- .../manage/categories/ManageCategories.js | 25 ++++--- .../react-app/src/pages/Login.js | 12 +++- .../pages/dashboard/apps/release/Release.js | 69 ++++++++++++++----- 6 files changed, 95 insertions(+), 50 deletions(-) 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 8ac3b835777..902c2cdd469 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 @@ -7,10 +7,10 @@ "protocol": "https", "hostname": "localhost", "httpsPort": "9443", - "invokerUri": "/api/application-mgt-handler/v1.0/invoke", - "loginUri": "/api/application-mgt-handler/v1.0/login" + "invokerUri": "/ui-request-handler/invoke/application-mgt-publisher/v1.0", + "loginUri": "/ui-request-handler/login", + "platform": "publisher" }, - "serverUrl": "https://localhost:9443", "defaultPlatformIcons": { "default": { "icon": "mobile", 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 16a6659af8a..57a369965f6 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 @@ -100,22 +100,26 @@ class AppsTable extends React.Component { fetch = (params = {}) => { this.setState({loading: true}); + if(!params.hasOwnProperty("page")){ + params.page = 1; + } + const extraParams = { offset: 10 * (params.page - 1), limit: 10 }; // note: encode with '%26' not '&' - const encodedExtraParams = Object.keys(extraParams).map(key => key + '=' + extraParams[key]).join('%26'); - const parameters = { - method: "post", - 'content-type': "application/json", - payload: JSON.stringify({}), - 'api-endpoint': "/application-mgt-publisher/v1.0/applications?" + encodedExtraParams + const encodedExtraParams = Object.keys(extraParams).map(key => key + '=' + extraParams[key]).join('&'); + const data = { }; - const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); - console.log(request); - axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + console.log(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications?"+encodedExtraParams); + axios.post( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications?"+encodedExtraParams, + data, + { + headers: { 'X-Platform': config.serverConfig.platform } + } ).then(res => { if (res.status === 200) { let apps = []; @@ -136,7 +140,7 @@ class AppsTable extends React.Component { } }).catch((error) => { - if (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 { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/ReleaseView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/ReleaseView.js index effa0d7ec67..4fb34364a38 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/ReleaseView.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/ReleaseView.js @@ -8,7 +8,6 @@ const {Title, Text, Paragraph} = Typography; class ReleaseView extends React.Component { render() { const release = this.props.release; - console.log(release); return (
@@ -19,7 +18,6 @@ class ReleaseView extends React.Component { App Name {release.version}
- {release.description}
@@ -50,12 +48,7 @@ class ReleaseView extends React.Component { - Ant Design, a design language for background applications, is refined by Ant UED Team. Ant - Design, a design language for background applications, is refined by Ant UED Team. Ant Design, - a design language for background applications, is refined by Ant UED Team. Ant Design, a - design language for background applications, is refined by Ant UED Team. Ant Design, a design - language for background applications, is refined by Ant UED Team. Ant Design, a design - language for background applications, is refined by Ant UED Team. + {release.description}
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 9339835363b..140e3e8a116 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 @@ -20,9 +20,11 @@ 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(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request - ).then(res => { + axios.get( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/admin/applications/categories/", + { + headers: { 'X-Platform': config.serverConfig.platform } + }).then(res => { if (res.status === 200) { let categories = JSON.parse(res.data.data); this.setState({ @@ -55,8 +57,11 @@ class ManageCategories extends React.Component { this.setState({ loading: true }); - const request = "method=delete&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories/" + id; - axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.delete( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/admin/applications/categories/"+id, + { + headers: { 'X-Platform': config.serverConfig.platform } + } ).then(res => { if (res.status === 200) { notification["success"]({ @@ -192,10 +197,14 @@ class ManageCategories extends React.Component { loading: true }); - const dataArray = JSON.stringify(tempElements.map(category => category.categoryName)); + const data = 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(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/admin/applications/categories", + data, + { + headers: { 'X-Platform': config.serverConfig.platform } + } ).then(res => { if (res.status === 200) { notification["success"]({ 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 030a43dfe43..48701cf09df 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 @@ -57,9 +57,15 @@ class NormalLoginForm extends React.Component { thisForm.setState({ loading: true }); - console.log('Received values of form: ', values); - let data = "username=" + values.username + "&password=" + values.password + "&platform=publisher"; - axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname+':'+config.serverConfig.httpsPort+config.serverConfig.loginUri, data + const parameters = { + username: values.username, + password: values.password, + platform: "publisher" + }; + + 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 => { 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/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 69e268939b9..dc19a967d6a 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 @@ -1,12 +1,11 @@ import React from "react"; import '../../../../App.css'; -import {PageHeader, Typography, Input, Button, Row, Col, Avatar, Card} from "antd"; -import {connect} from "react-redux"; +import {PageHeader, Typography, Row, Col, message, Card} from "antd"; +import axios from 'axios'; +import config from "../../../../../public/conf/config.json"; import ReleaseView from "../../../../components/apps/release/ReleaseView"; -import {getRelease} from "../../../../js/actions"; import LifeCycle from "../../../../components/apps/release/LifeCycle"; -const Search = Input.Search; const {Title} = Typography; const routes = [ @@ -24,31 +23,67 @@ const routes = [ }, ]; -const mapStateToProps = state => { - return {release: state.release} -}; -const mapDispatchToProps = dispatch => ({ - getRelease: (uuid) => dispatch(getRelease(uuid)) -}); - -class ConnectedRelease extends React.Component { +class Release extends React.Component { routes; constructor(props) { super(props); this.routes = props.routes; - + this.state={ + loading: true, + app: null, + uuid: null + } } componentDidMount() { const {uuid} = this.props.match.params; - this.props.getRelease(uuid); + this.fetchData(uuid); + } + + componentDidUpdate(prevProps, prevState, snapshot) { + if (prevState.uuid !== this.state.uuid) { + const {uuid} = this.props.match.params; + this.fetchData(uuid); + } } + fetchData = (uuid)=>{ + + //send request to the invoker + axios.get( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications/release/"+uuid, + { + headers: { 'X-Platform': config.serverConfig.platform } + } + ).then(res => { + if (res.status === 200) { + let app = res.data.data; + this.setState({ + app: app, + loading: false, + uuid: uuid + }) + } + + }).catch((error) => { + 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'; + } else { + message.error('Something went wrong... :('); + } + + this.setState({loading: false}); + }); + }; + render() { + const {app} = this.state; + const release = app; - const release = this.props.release; if (release == null) { return (
@@ -72,7 +107,7 @@ class ConnectedRelease extends React.Component { - + {/**/} @@ -83,6 +118,4 @@ class ConnectedRelease extends React.Component { } } -const Release = connect(mapStateToProps,mapDispatchToProps)(ConnectedRelease); - export default Release; From b41e0f38d3f99046b7157f8c4c0b195f9405c185 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Tue, 18 Jun 2019 19:58:46 +0530 Subject: [PATCH 2/3] Completed Manage tag component --- .../apps/detailed-rating/DetailedRating.js | 7 +- .../manage/categories/ManageCategories.js | 13 +- .../manage/categories/ManageTags.js | 122 ++++++++++-------- .../react-app/src/components/apps/AppList.js | 2 - 4 files changed, 81 insertions(+), 63 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 18fa46f812d..19766fa499e 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,8 +30,11 @@ 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(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request - ).then(res => { + return axios.get( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/reviews/"+uuid+"/rating", + { + headers: { 'X-Platform': config.serverConfig.platform } + }).then(res => { if (res.status === 200) { let detailedRating = res.data.data; this.setState({ 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 140e3e8a116..204c76460d0 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() { axios.get( - config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/admin/applications/categories/", + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications/categories", { headers: { 'X-Platform': config.serverConfig.platform } }).then(res => { @@ -197,7 +197,7 @@ class ManageCategories extends React.Component { loading: true }); - const data = JSON.stringify(tempElements.map(category => category.categoryName)); + const data = tempElements.map(category => category.categoryName); axios.post( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/admin/applications/categories", @@ -264,8 +264,13 @@ class ManageCategories extends React.Component { loading: true, 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(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + + axios.put( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/admin/applications/categories/rename?from="+currentlyEditingId+"&to="+editingValue, + {}, + { + headers: { 'X-Platform': config.serverConfig.platform } + } ).then(res => { if (res.status === 200) { notification["success"]({ 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 047669ca593..7c10934b710 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 @@ -9,7 +9,7 @@ class ManageTags extends React.Component { state = { loading: false, searchText: '', - categories: [], + tags: [], tempElements: [], inputVisible: false, inputValue: '', @@ -20,13 +20,15 @@ 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(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request - ).then(res => { + axios.get( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications/tags", + { + headers: { 'X-Platform': config.serverConfig.platform } + }).then(res => { if (res.status === 200) { - let categories = JSON.parse(res.data.data); + let tags = JSON.parse(res.data.data); this.setState({ - categories: categories, + tags: tags, loading: false }); } @@ -51,31 +53,34 @@ class ManageTags extends React.Component { }); }; - deleteCategory = (id) => { + deleteTag = (id) => { + this.setState({ loading: true }); - const request = "method=delete&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories/" + id; - axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request - ).then(res => { + + axios.delete( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/admin/applications/tags/"+id, + { + headers: {'X-Platform': config.serverConfig.platform} + }).then(res => { if (res.status === 200) { notification["success"]({ message: "Done!", description: - "Category Removed Successfully!", + "Tag Removed Successfully!", + }); + + const {tags} = this.state; + const remainingElements = tags.filter(function (value) { + return value.tagName !== id; + }); this.setState({ - loading: false + loading: false, + tags: remainingElements }); - // this.setState({ - // categories: [...categories, ...tempElements], - // tempElements: [], - // inputVisible: false, - // inputValue: '', - // loading: false, - // isAddNewVisible: false - // }); } }).catch((error) => { @@ -91,31 +96,31 @@ class ManageTags extends React.Component { }); }; - renderElement = (category) => { - const categoryName = category.tagName; + renderElement = (tag) => { + const tagName = tag.tagName; const tagElem = ( - {categoryName} + {tagName} { - this.openEditModal(categoryName) + this.openEditModal(tagName) }} style={{color: 'rgba(0,0,0,0.45)'}} type="edit"/> { - if (category.isTagDeletable) { - this.deleteCategory(categoryName); + if (tag.isTagDeletable) { + this.deleteTag(tagName); } else { notification["error"]({ - message: 'Cannot delete "' + categoryName + '"', + message: 'Cannot delete "' + tagName + '"', description: - "This category is currently used. Please unassign the category from apps.", + "This tag is currently used. Please unassign the tag from apps.", }); } }} @@ -128,13 +133,13 @@ class ManageTags extends React.Component { ); return ( - + {tagElem} ); }; - renderTempElement = (category) => { + renderTempElement = (tag) => { const {tempElements} = this.state; const tagElem = ( - {category.categoryName} + {tag.tagName} ); return ( - + {tagElem} ); @@ -170,13 +175,13 @@ class ManageTags extends React.Component { }; handleInputConfirm = () => { - const {inputValue, categories} = this.state; + const {inputValue, tags} = this.state; let {tempElements} = this.state; if (inputValue) { - if ((categories.findIndex(i => i.categoryName === inputValue) === -1) && (tempElements.findIndex(i => i.categoryName === inputValue) === -1)) { - tempElements = [...tempElements, {categoryName: inputValue, isTagDeletable: true}]; + if ((tags.findIndex(i => i.tagName === inputValue) === -1) && (tempElements.findIndex(i => i.tagName === inputValue) === -1)) { + tempElements = [...tempElements, {tagName: inputValue, isTagDeletable: true}]; } else { - message.warning('Category already exists'); + message.warning('Tag already exists'); } } @@ -188,25 +193,27 @@ class ManageTags extends React.Component { }; handleSave = () => { - const {tempElements, categories} = this.state; + const {tempElements, tags} = this.state; this.setState({ loading: true }); - const dataArray = JSON.stringify(tempElements.map(category => category.categoryName)); + const data = tempElements.map(tag => tag.tagName); - const request = "method=post&content-type=application/json&payload=" + dataArray + "&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories"; - axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request - ).then(res => { + axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications/tags", + data, + { + headers: { 'X-Platform': config.serverConfig.platform } + }).then(res => { if (res.status === 200) { notification["success"]({ message: "Done!", description: - "New Categories were added successfully", + "New tags were added successfully", }); this.setState({ - categories: [...categories, ...tempElements], + tags: [...tags, ...tempElements], tempElements: [], inputVisible: false, inputValue: '', @@ -250,26 +257,31 @@ class ManageTags extends React.Component { editItem = () => { - const {editingValue, currentlyEditingId, categories} = this.state; + const {editingValue, currentlyEditingId, tags} = this.state; this.setState({ loading: true, 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(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + + axios.put( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications/tags/rename?from="+currentlyEditingId+"&to="+editingValue, + {}, + { + headers: { 'X-Platform': config.serverConfig.platform } + } ).then(res => { if (res.status === 200) { notification["success"]({ message: "Done!", description: - "Category was edited successfully", + "Tag was edited successfully", }); - categories[categories.findIndex(i => i.categoryName === currentlyEditingId)].categoryName = editingValue; + tags[tags.findIndex(i => i.tagName === currentlyEditingId)].tagName = editingValue; this.setState({ - categories: categories, + tags: tags, loading: false, editingValue: null }); @@ -298,8 +310,8 @@ class ManageTags extends React.Component { }; render() { - const {categories, inputVisible, inputValue, tempElements, isAddNewVisible} = this.state; - const categoriesElements = categories.map(this.renderElement); + const {tags, inputVisible, inputValue, tempElements, isAddNewVisible} = this.state; + const tagsElements = tags.map(this.renderElement); const temporaryElements = tempElements.map(this.renderTempElement); return (
@@ -349,7 +361,7 @@ class ManageTags extends React.Component { {!inputVisible && ( - New Category + New Tag )} @@ -386,7 +398,7 @@ class ManageTags extends React.Component { leave={{opacity: 0, width: 0, scale: 0, duration: 200}} appear={false} > - {categoriesElements} + {tagsElements}
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 767843d7107..49d30d8d107 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 @@ -14,9 +14,7 @@ class AppList extends React.Component { } componentDidMount() { - console.log("mounted"); const {deviceType} = this.props; - console.log(this.props); this.props.changeSelectedMenuItem(deviceType); this.fetchData(deviceType); } From 704ef44d0165716e178ca9d45cb5cb2913d93282 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Wed, 19 Jun 2019 00:50:07 +0530 Subject: [PATCH 3/3] Fixed api calls in store --- .../react-app/public/conf/config.json | 21 +++++++++++++------ .../react-app/src/components/apps/AppList.js | 16 ++++++-------- .../react-app/src/pages/Login.js | 11 ++++++++-- .../pages/dashboard/apps/release/Release.js | 6 +++++- 4 files changed, 35 insertions(+), 19 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 6f469f5e029..706fe7cbd7c 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 @@ -7,13 +7,22 @@ "protocol": "https", "hostname": "localhost", "httpsPort": "9443", - "invokerUri": "/api/application-mgt-handler/v1.0/invoke", - "loginUri": "/api/application-mgt-handler/v1.0/login" + "invokerUri": "/ui-request-handler/invoke/application-mgt-store/v1.0", + "loginUri": "/ui-request-handler/login", + "platform": "store" }, - "serverUrl" : "https://localhost:9443", "defaultPlatformIcons": { - "default": "http://www.newdesignfile.com/postpic/2015/08/square-app-icon-blue_77131.png", - "android": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAZlBMVEX///+m2GSt23Gk11+i1lug1le+4pLb7sTu9+Tl89X5/PSk12Ge1VOo2Wef1Vb2+/Dr9t6334TM6Kr8/vrR6rO234Oy3Xq84Y7Y7b+r2m3g8czK56bs9uC94pCx3Xnz+uzU7LjF5Z+YGtzqAAAHSUlEQVR4nO2da5uiIBSAM8BK1Cy7WbMz0///k1s5FeJBcUQOz+55v3aW5R0QuQmzmQPO+2i+K12k9KLczaPN2WmSI7jmMop4lThMMsl4FMn86jDJEZzT6A7L1s6SXEfykWYaRil+1rm5ZcqV4lMwkgdHKY4jeuJK8SV4w0mCY6mkW0VFUFYO0hvPhSulOL65UUuQXxzkbzxlxRxWVFWQVW5fQb8myZh9KfbkOVEFM5cvoFE0FCVQiuvVaRvvK5HWiGofb08rKFCqJRiMoF6KzZwXu00mBOdMybyUjHMhquN30Yhdh1mCd5JMQorJ4niTe9vrsJvm8fwyCViw+fw8FVdH3mH3tuTH1SNeFZShCbZLsdxJ0a/3IymiW8c9cEFNsbpwDrkY4fxSBS7YVIxsiw/8F9JhJ94pDcURBFqCd9TmZoSgg67fZLgoxYBL8E5SjVWUIfVkAMrjaMNjIL1tmBUb3obqM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Kv+ANf/kjfiNBjwAAAAAElFTkSuQmCC" + "default": { + "icon": "mobile", + "color": "#535c68" + }, + "android": { + "icon": "android", + "color": "#7db343" + }, + "ios": { + "icon": "apple", + "color": "#535c68" + } } } 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 49d30d8d107..d04af62794b 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 @@ -36,18 +36,14 @@ class AppList extends React.Component { }else{ payload.deviceType= deviceType; } - const parameters = { - method: "post", - 'content-type': "application/json", - payload: JSON.stringify(payload), - 'api-endpoint': "/application-mgt-store/v1.0/applications/" - }; - - //url-encode parameters - const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); //send request to the invoker - axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.post( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications/", + payload, + { + headers: { 'X-Platform': config.serverConfig.platform } + } ).then(res => { if (res.status === 200) { //todo remove this property check after backend improvement 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 5d016cdeafa..71bae0e7927 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 @@ -57,8 +57,15 @@ class NormalLoginForm extends React.Component { thisForm.setState({ loading: true }); - let data = "username=" + values.username + "&password=" + values.password + "&platform=store"; - axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname+':'+config.serverConfig.httpsPort+config.serverConfig.loginUri, data + const parameters = { + username: values.username, + password: values.password, + platform: "store" + }; + + 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 => { if (res.status === 200) { window.location = res.data.url; 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 d6b3308b490..51c8897d6be 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 @@ -48,7 +48,11 @@ class Release extends React.Component { const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); //send request to the invoker - axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + axios.get( + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications/"+uuid, + { + headers: { 'X-Platform': config.serverConfig.platform } + } ).then(res => { if (res.status === 200) { let app = res.data.data;