diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/EnterpriseApplication.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/EnterpriseApplication.java deleted file mode 100644 index 9fa337a2845..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/EnterpriseApplication.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.application.mgt.common; - -import java.io.Serializable; - -/** - * This class represents the Enterprise ApplicationDTO information. - */ -public class EnterpriseApplication extends AndroidApplication implements Serializable { - - private String url; - private String schedule; - private String packageName; - - private static final long serialVersionUID = 660343716452348222L; - - public String getSchedule() { - return schedule; - } - - public void setSchedule(String schedule) { - this.schedule = schedule; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getPackageName() { - return packageName; - } - - public void setPackageName(String packageName) { - this.packageName = packageName; - } -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ReviewManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ReviewManagerImpl.java index 8c0a41ac6f4..f7eb2d2408c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ReviewManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ReviewManagerImpl.java @@ -224,6 +224,7 @@ public class ReviewManagerImpl implements ReviewManager { review.setCreatedAt(reviewDTO.getCreatedAt()); review.setModifiedAt(reviewDTO.getModifiedAt()); review.setRating(reviewDTO.getRating()); + review.setUsername(reviewDTO.getUsername()); review.setReplies(new ArrayList<>()); return review; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/AndroidApplicationOperationUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/AndroidApplicationOperationUtil.java deleted file mode 100644 index bb1f5d955ae..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/AndroidApplicationOperationUtil.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.application.mgt.core.util; - -import org.wso2.carbon.device.application.mgt.common.AppOperation; -import org.wso2.carbon.device.application.mgt.common.EnterpriseApplication; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; - -public class AndroidApplicationOperationUtil { -// public static Operation installApp(AppOperation appOperation) { -// ProfileOperation operation = new ProfileOperation(); -// operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_INSTALL_APPLICATION); -// operation.setType(Operation.Type.PROFILE); -// switch (appOperation.getApplication().getType()) { -// case "ENTERPRISE"://TODO: fix with ENUM -// EnterpriseApplication enterpriseApplication = new EnterpriseApplication(); -// enterpriseApplication.setType(appOperation.getApplication().toString()); -// enterpriseApplication.setUrl(application.getLocation()); -// enterpriseApplication.setSchedule(appOperation.getScheduledDateTime()); -// enterpriseApplication.setPackageName(appOperation.getApplication().get); -// operation.setPayLoad(enterpriseApplication.toJSON()); -// break; -// case "PUBLIC": -// setOperationForPublicApp(operation, application); -// break; -// case "WEBAPP": -// setOperationForWebApp(operation, application); -// break; -// default: -// String errorMessage = "Invalid application type."; -// throw new DeviceApplicationException(errorMessage); -// } -// return operation; -// } - -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/ReviewManagementAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/ReviewManagementAPI.java index 1776364de33..29ba58fb3ec 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/ReviewManagementAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/ReviewManagementAPI.java @@ -56,7 +56,7 @@ import java.util.List; @SwaggerDefinition( info = @Info( version = "1.0.0", - title = "Store Management Service", + title = "Review Management Service", extensions = { @Extension(properties = { @ExtensionProperty(name = "name", value = "ReviewManagementService"), @@ -86,7 +86,7 @@ import java.util.List; ) @Path("/reviews") -@Api(value = "Review Management") +@Api(value = "Review Management API") @Produces(MediaType.APPLICATION_JSON) public interface ReviewManagementAPI { String SCOPE = "scope"; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/ReviewManagementAdminAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/ReviewManagementAdminAPI.java index df2780fcd1f..765419cf220 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/ReviewManagementAdminAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/ReviewManagementAdminAPI.java @@ -49,7 +49,7 @@ import javax.ws.rs.core.Response; @SwaggerDefinition( info = @Info( version = "1.0.0", - title = "Store Management Admin Service", + title = "Admin Review Management Admin Service", extensions = { @Extension(properties = { @ExtensionProperty(name = "name", value = "ReviewManagementAdminService"), @@ -73,7 +73,7 @@ scopes = { ) @Path("/admin/reviews") -@Api(value = "Review Management") +@Api(value = "Review Management Admin API") @Produces(MediaType.APPLICATION_JSON) public interface ReviewManagementAdminAPI { String SCOPE = "scope"; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/webapp/WEB-INF/cxf-servlet.xml index da9e97cceab..da49a119c7e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -26,6 +26,7 @@ + @@ -55,6 +56,7 @@ + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/package.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/package.json index 5075b4fe035..388f4ef0fdc 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/package.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/package.json @@ -22,12 +22,15 @@ "react-dom": "^16.8.4", "react-highlight-words": "^0.16.0", "react-image-viewer-zoom": "^1.0.36", + "react-infinite-scroller": "^1.2.4", "react-router": "latest", "react-router-config": "^5.0.0", "react-router-dom": "latest", "react-scripts": "2.1.8", "react-star-ratings": "^2.3.0", + "react-virtualized": "^9.21.1", "redux-thunk": "^2.3.0", + "reqwest": "^2.0.5", "storm-react-diagrams": "^5.2.1" }, "devDependencies": { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/images/avatar-2.png b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/images/avatar-2.png new file mode 100644 index 00000000000..9467f5eb764 Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/images/avatar-2.png differ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/images/avatar-3.png b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/images/avatar-3.png new file mode 100644 index 00000000000..f1d980e55ce Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/images/avatar-3.png differ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/images/avatar.png b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/images/avatar.png new file mode 100644 index 00000000000..5fab5dee57d Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/images/avatar.png differ 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 3a87ac38b81..b86bc1516f8 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 @@ -4,6 +4,7 @@ import "../../../App.css"; import ImgViewer from "../../apps/release/images/ImgViewer"; import StarRatings from "react-star-ratings"; import DetailedRating from "./DetailedRating"; +import Reviews from "./review/Reviews"; const {Title, Text, Paragraph} = Typography; class ReleaseView extends React.Component { @@ -52,6 +53,7 @@ class ReleaseView extends React.Component { + ); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.css new file mode 100644 index 00000000000..8678c638919 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.css @@ -0,0 +1,16 @@ +.demo-infinite-container { + overflow: auto; + padding: 8px 24px; +} +.demo-loading-container { + position: absolute; + bottom: 40px; + width: 100%; + text-align: center; +} + +.demo-loading { + position: absolute; + bottom: -40px; + left: 50%; +} \ No newline at end of file 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 new file mode 100644 index 00000000000..5d45e4cbc74 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.js @@ -0,0 +1,127 @@ +import React from "react"; +import {List, message, Avatar, Spin, Button} from 'antd'; +import "./Reviews.css"; + +import InfiniteScroll from 'react-infinite-scroller'; +import SingleReview from "./SingleReview"; +import axios from "axios"; +import config from "../../../../../public/conf/config.json"; + +const limit = 5; + +class Reviews extends React.Component { + state = { + data: [], + loading: false, + hasMore: false, + loadMore: false + }; + + + componentDidMount() { + this.fetchData(0, limit, res => { + this.setState({ + data: res, + }); + }); + } + + fetchData = (offset, limit, callback) => { + const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/" + this.props.uuid+"?offset="+offset+"%26limit="+limit; + axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + ).then(res => { + if (res.status === 200) { + let reviews = res.data.data.data; + callback(reviews); + } + + }).catch(function (error) { + if (error.response.status === 401) { + window.location.href = 'https://localhost:9443/store/login'; + message.warning('Something went wrong'); + } + }); + }; + + handleInfiniteOnLoad = (count) => { + const offset = count*limit; + let data = this.state.data; + this.setState({ + loading: true, + }); + if (data.length > 149) { + this.setState({ + hasMore: false, + loading: false, + }); + return; + } + this.fetchData(offset, limit, res => { + if(res.length>0){ + data = data.concat(res); + this.setState({ + data, + loading: false, + }); + }else { + this.setState({ + hasMore: false, + loading: false + }); + } + }); + }; + + enableLoading = () => { + this.setState({ + hasMore: true, + loadMore: true + }); + }; + + render() { + const review = { + id: 2, + content: "Btw, it was clear to me that I can cancel the 1 year subscription before the free trial week and so I did. Dont understand the negative reviews about that. It has a good collection of excercises, meditations etc. You just answer 5 questions and you get challenges assigned to you. I would have liked something even more personalized. I didnt like the interface. It is a bit messy and difficult to follow your tasks. So, I didnt want to do a full-year subscription. There could be more options.", + rootParentI: -1, + immediateParentId: -1, + createdAt: "Fri, 24 May 2019 17:27:22 IST", + modifiedAt: "Fri, 24 May 2019 17:27:22 IST", + rating: 4, + replies: [] + }; + console.log(this.state.loadMore); + console.log(this.state.data.length); + return ( +
+ + ( + + + + )} + > + {this.state.loading && this.state.hasMore && ( +
+ +
+ )} +
+
+ {!this.state.loadMore && (this.state.data.length >= limit) && (
+ +
)} +
+ ); + } +} + +export default Reviews; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/SingleReview.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/SingleReview.js new file mode 100644 index 00000000000..3834b3ff2e3 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/SingleReview.js @@ -0,0 +1,46 @@ +import React from "react"; +import {Avatar} from "antd"; +import {List,Typography} from "antd"; +import StarRatings from "react-star-ratings"; + +const {Text, Paragraph} = Typography; +const colorList = ['#f0932b','#badc58','#6ab04c','#eb4d4b','#0abde3', '#9b59b6','#3498db','#22a6b3']; + +class SingleReview extends React.Component { + + render() { + const review = this.props.review; + const randomColor = colorList[Math.floor(Math.random() * (colorList.length))]; + const avatarLetter = review.username.charAt(0).toUpperCase(); + const content = ( +
+ + {review.createdAt}
+ {review.content} +
+ ); + + return ( +
+ + {avatarLetter} + + } + title={review.username} + description={content} + /> +
+ ); + } +} + +export default SingleReview; \ No newline at end of file