Merge branch 'application-mgt-new' into 'application-mgt-new'

Fix API calls in APPM UI

See merge request entgra/carbon-device-mgt!142
feature/appm-store/pbac
Dharmakeerthi Lasantha 5 years ago
commit 915a4cafdd

@ -21,13 +21,14 @@
"react-d3-graph": "^2.0.2", "react-d3-graph": "^2.0.2",
"react-dom": "^16.8.4", "react-dom": "^16.8.4",
"react-highlight-words": "^0.16.0", "react-highlight-words": "^0.16.0",
"react-infinite-scroller": "^1.2.4",
"react-router": "latest", "react-router": "latest",
"react-router-config": "^5.0.0", "react-router-config": "^5.0.0",
"react-router-dom": "latest", "react-router-dom": "latest",
"react-scripts": "2.1.8", "react-scripts": "2.1.8",
"react-star-ratings": "^2.3.0",
"redux-thunk": "^2.3.0", "redux-thunk": "^2.3.0",
"storm-react-diagrams": "^5.2.1", "storm-react-diagrams": "^5.2.1"
"react-star-ratings": "^2.3.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.0.0", "@babel/core": "^7.0.0",

@ -7,7 +7,12 @@
"protocol": "https", "protocol": "https",
"hostname": "localhost", "hostname": "localhost",
"httpsPort": "9443", "httpsPort": "9443",
"invokerUri": "/ui-request-handler/invoke/application-mgt-publisher/v1.0", "invoker": {
"uri": "/ui-request-handler/invoke",
"publisher": "/application-mgt-publisher/v1.0",
"store": "/application-mgt-store/v1.0",
"admin" : ""
},
"loginUri": "/ui-request-handler/login", "loginUri": "/ui-request-handler/login",
"platform": "publisher" "platform": "publisher"
}, },

@ -15,7 +15,6 @@ class App extends React.Component {
} }
render() { render() {
console.log(this.routes);
return ( return (
<Router> <Router>
<div> <div>

@ -18,20 +18,22 @@ class DetailedRating extends React.Component{
} }
componentDidMount() { componentDidMount() {
this.getData(this.props.uuid); const {type,uuid} = this.props;
this.getData(type,uuid);
} }
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
if (prevProps.uuid !== this.props.uuid) { if (prevProps.uuid !== this.props.uuid) {
this.getData(this.props.uuid); const {type,uuid} = this.props;
this.getData(type,uuid);
} }
} }
getData = (uuid)=>{ getData = (type, uuid)=>{
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid+"/rating"; console.log();
return axios.get( return axios.get(
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/reviews/"+uuid+"/rating", config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+uuid+"/"+type+"-rating",
{ {
headers: { 'X-Platform': config.serverConfig.platform } headers: { 'X-Platform': config.serverConfig.platform }
}).then(res => { }).then(res => {
@ -52,7 +54,6 @@ class DetailedRating extends React.Component{
render() { render() {
const detailedRating = this.state.detailedRating; const detailedRating = this.state.detailedRating;
console.log(detailedRating);
if(detailedRating ==null){ if(detailedRating ==null){
return null; return null;
@ -77,7 +78,6 @@ class DetailedRating extends React.Component{
} }
} }
console.log(ratingBarPercentages);
return ( return (
<Row className="d-rating"> <Row className="d-rating">

@ -12,7 +12,6 @@ class AppDetailsDrawer extends React.Component {
if (app == null) { if (app == null) {
return null; return null;
} }
console.log(app);
return ( return (
<div> <div>
@ -85,7 +84,7 @@ class AppDetailsDrawer extends React.Component {
/> />
<Divider dashed={true}/> <Divider dashed={true}/>
<DetailedRating uuid={app.applicationReleases[0].uuid}/> <DetailedRating type="app" uuid={app.applicationReleases[0].uuid}/>
</Drawer> </Drawer>
</div> </div>
); );

@ -113,9 +113,8 @@ class AppsTable extends React.Component {
const data = { const data = {
}; };
console.log(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications?"+encodedExtraParams); axios.post(
axios.post( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/applications?"+encodedExtraParams,
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications?"+encodedExtraParams,
data, data,
{ {
headers: { 'X-Platform': config.serverConfig.platform } headers: { 'X-Platform': config.serverConfig.platform }
@ -152,7 +151,6 @@ class AppsTable extends React.Component {
}; };
render() { render() {
console.log("rendered");
return ( return (
<Table <Table

@ -26,7 +26,6 @@ class ConnectedListApps extends React.Component {
//handler to show app drawer //handler to show app drawer
showDrawer = (app) => { showDrawer = (app) => {
console.log(app);
this.setState({ this.setState({
isDrawerVisible: true, isDrawerVisible: true,
selectedApp: app selectedApp: app
@ -56,7 +55,7 @@ class ConnectedListApps extends React.Component {
<Col span={18} style={{textAlign: "right"}}> <Col span={18} style={{textAlign: "right"}}>
<Search <Search
placeholder="input search text" placeholder="input search text"
onSearch={value => console.log(value)} // onSearch={value => console.log(value)}
style={{width: 200}} style={{width: 200}}
/> />
</Col> </Col>

@ -62,8 +62,6 @@ class ConnectedLifecycleModal extends React.Component {
handleSubmit = event => { handleSubmit = event => {
this.setState({ loading: true }); this.setState({ loading: true });
event.preventDefault(); event.preventDefault();
console.log(this.reason);
console.log("uuid", this.props.uuid);
this.props.updateLifecycleState(this.props.uuid, this.props.nextState, this.reason.state.value) this.props.updateLifecycleState(this.props.uuid, this.props.nextState, this.reason.state.value)
}; };

@ -1,13 +1,20 @@
import React from "react"; import React from "react";
import {Divider, Row, Col, Typography, Button} from "antd"; import {Divider, Row, Col, Typography, Button, Drawer} from "antd";
import StarRatings from "react-star-ratings";
import Reviews from "./review/Reviews";
import "../../../App.css"; import "../../../App.css";
import config from "../../../../public/conf/config.json"; import config from "../../../../public/conf/config.json";
import DetailedRating from "../detailed-rating/DetailedRating";
const {Title, Text, Paragraph} = Typography; const {Title, Text, Paragraph} = Typography;
class ReleaseView extends React.Component { class ReleaseView extends React.Component {
render() { render() {
const release = this.props.release; const app = this.props.app;
const release = (app !== null) ? app.applicationReleases[0] : null;
if(release == null){
return null;
}
return ( return (
<div> <div>
<div className="release"> <div className="release">
@ -16,8 +23,16 @@ class ReleaseView extends React.Component {
<img src={release.iconPath} alt="icon"/> <img src={release.iconPath} alt="icon"/>
</Col> </Col>
<Col xl={10} sm={11} className="release-title"> <Col xl={10} sm={11} className="release-title">
<Title level={2}>App Name</Title> <Title level={2}>{app.name}</Title>
<Text>{release.version}</Text><br/> <Text>Version : {release.version}</Text><br/><br/>
<StarRatings
rating={release.rating}
starRatedColor="#777"
starDimension="20px"
starSpacing="2px"
numberOfStars={5}
name='rating'
/>
</Col> </Col>
<Col xl={8} md={10} sm={24} xs={24} style={{float: "right"}}> <Col xl={8} md={10} sm={24} xs={24} style={{float: "right"}}>
<div> <div>
@ -28,7 +43,7 @@ class ReleaseView extends React.Component {
icon="shop" icon="shop"
disabled={release.currentStatus !== "PUBLISHED"} disabled={release.currentStatus !== "PUBLISHED"}
onClick={() => { onClick={() => {
window.open("https://"+ config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+"/store/apps/"+release.uuid) window.open("https://"+ config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+"/store/"+app.deviceType+"/apps/"+release.uuid)
}}> }}>
Open in store Open in store
</Button> </Button>
@ -50,6 +65,14 @@ class ReleaseView extends React.Component {
<Paragraph type="secondary" ellipsis={{rows: 3, expandable: true}}> <Paragraph type="secondary" ellipsis={{rows: 3, expandable: true}}>
{release.description} {release.description}
</Paragraph> </Paragraph>
<Divider/>
<Text>REVIEWS</Text>
<Row>
<Col lg={18}>
<DetailedRating type="release" uuid={release.uuid}/>
</Col>
</Row>
<Reviews type="release" uuid={release.uuid}/>
</div> </div>
</div> </div>
); );

@ -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%;
}

@ -0,0 +1,122 @@
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 {uuid, type} = this.props;
axios.get(
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+type+"/"+uuid,
{
headers: {'X-Platform': config.serverConfig.platform}
}).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 = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login';
} else {
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() {
return (
<div className="demo-infinite-container">
<InfiniteScroll
initialLoad={false}
pageStart={0}
loadMore={this.handleInfiniteOnLoad}
hasMore={!this.state.loading && this.state.hasMore}
useWindow={true}
>
<List
dataSource={this.state.data}
renderItem={item => (
<List.Item key={item.id}>
<SingleReview review={item}/>
</List.Item>
)}
>
{this.state.loading && this.state.hasMore && (
<div className="demo-loading-container">
<Spin/>
</div>
)}
</List>
</InfiniteScroll>
{!this.state.loadMore && (this.state.data.length >= limit) && (<div style={{textAlign: "center"}}>
<Button type="dashed" htmlType="button" onClick={this.enableLoading}>Read All Reviews</Button>
</div>)}
</div>
);
}
}
export default Reviews;

@ -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 = (
<div style={{marginTop: -5}}>
<StarRatings
rating={review.rating}
starRatedColor="#777"
starDimension = "12px"
starSpacing = "2px"
numberOfStars={5}
name='rating'
/>
<Text style={{fontSize: 12, color: "#aaa"}} type="secondary"> {review.createdAt}</Text><br/>
<Paragraph ellipsis={{ rows: 3, expandable: true }} style={{color: "#777"}}>{review.content}</Paragraph>
</div>
);
return (
<div>
<List.Item.Meta
avatar={
<Avatar style={{ backgroundColor: randomColor, verticalAlign: 'middle' }} size="large">
{avatarLetter}
</Avatar>
}
title={review.username}
description={content}
/>
</div>
);
}
}
export default SingleReview;

@ -92,7 +92,7 @@ function connectNodes(nodeFrom, nodeTo) {
} }
function f() { function f() {
console.log(1); // console.log(1);
} }
export default LifeCycleGraph; export default LifeCycleGraph;

@ -21,7 +21,7 @@ class ManageCategories extends React.Component {
componentDidMount() { componentDidMount() {
axios.get( axios.get(
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications/categories", config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/applications/categories",
{ {
headers: { 'X-Platform': config.serverConfig.platform } headers: { 'X-Platform': config.serverConfig.platform }
}).then(res => { }).then(res => {
@ -58,7 +58,7 @@ class ManageCategories extends React.Component {
loading: true loading: true
}); });
axios.delete( axios.delete(
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/admin/applications/categories/"+id, config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/admin/applications/categories/"+id,
{ {
headers: { 'X-Platform': config.serverConfig.platform } headers: { 'X-Platform': config.serverConfig.platform }
} }
@ -200,7 +200,7 @@ class ManageCategories extends React.Component {
const data = tempElements.map(category => category.categoryName); const data = tempElements.map(category => category.categoryName);
axios.post( axios.post(
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.invoker.uri +config.serverConfig.invoker.publisher+"/admin/applications/categories",
data, data,
{ {
headers: { 'X-Platform': config.serverConfig.platform } headers: { 'X-Platform': config.serverConfig.platform }
@ -241,7 +241,6 @@ class ManageCategories extends React.Component {
saveInputRef = input => (this.input = input); saveInputRef = input => (this.input = input);
closeEditModal = e => { closeEditModal = e => {
console.log(e);
this.setState({ this.setState({
isEditModalVisible: false, isEditModalVisible: false,
currentlyEditingId: null currentlyEditingId: null
@ -266,7 +265,7 @@ class ManageCategories extends React.Component {
}); });
axios.put( axios.put(
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/admin/applications/categories/rename?from="+currentlyEditingId+"&to="+editingValue, config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/admin/applications/categories/rename?from="+currentlyEditingId+"&to="+editingValue,
{}, {},
{ {
headers: { 'X-Platform': config.serverConfig.platform } headers: { 'X-Platform': config.serverConfig.platform }

@ -21,7 +21,7 @@ class ManageTags extends React.Component {
componentDidMount() { componentDidMount() {
axios.get( axios.get(
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications/tags", config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/applications/tags",
{ {
headers: { 'X-Platform': config.serverConfig.platform } headers: { 'X-Platform': config.serverConfig.platform }
}).then(res => { }).then(res => {
@ -60,7 +60,7 @@ class ManageTags extends React.Component {
}); });
axios.delete( axios.delete(
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/admin/applications/tags/"+id, config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/admin/applications/tags/"+id,
{ {
headers: {'X-Platform': config.serverConfig.platform} headers: {'X-Platform': config.serverConfig.platform}
}).then(res => { }).then(res => {
@ -200,7 +200,7 @@ class ManageTags extends React.Component {
const data = tempElements.map(tag => tag.tagName); const data = tempElements.map(tag => tag.tagName);
axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications/tags", axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/applications/tags",
data, data,
{ {
headers: { 'X-Platform': config.serverConfig.platform } headers: { 'X-Platform': config.serverConfig.platform }
@ -240,7 +240,6 @@ class ManageTags extends React.Component {
saveInputRef = input => (this.input = input); saveInputRef = input => (this.input = input);
closeEditModal = e => { closeEditModal = e => {
console.log(e);
this.setState({ this.setState({
isEditModalVisible: false, isEditModalVisible: false,
currentlyEditingId: null currentlyEditingId: null
@ -265,7 +264,7 @@ class ManageTags extends React.Component {
}); });
axios.put( axios.put(
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications/tags/rename?from="+currentlyEditingId+"&to="+editingValue, config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/applications/tags/rename?from="+currentlyEditingId+"&to="+editingValue,
{}, {},
{ {
headers: { 'X-Platform': config.serverConfig.platform } headers: { 'X-Platform': config.serverConfig.platform }

@ -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"; const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications";
return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let apps = []; let apps = [];
@ -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; const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/release/" + uuid;
return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let release = res.data.data; let release = res.data.data;
@ -73,7 +73,7 @@ export const closeLifecycleModal = () => dispatch => {
export const getLifecycle = () => dispatch => { export const getLifecycle = () => dispatch => {
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/lifecycle-config"; const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/lifecycle-config";
return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let lifecycle = res.data.data; let lifecycle = res.data.data;
@ -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; const request = "method=post&content-type=application/json&payload=" + JSON.stringify(payload) + "&api-endpoint=/application-mgt-publisher/v1.0/applications/life-cycle/" + uuid;
return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher, request
).then(res => { ).then(res => {
if (res.status === 201) { if (res.status === 201) {
let release = res.data.data; let release = res.data.data;

@ -98,7 +98,6 @@ class EditableTagGroup extends React.Component {
handleClose = (removedTag) => { handleClose = (removedTag) => {
const tags = this.state.tags.filter(tag => tag !== removedTag); const tags = this.state.tags.filter(tag => tag !== removedTag);
console.log(tags);
this.setState({tags}); this.setState({tags});
} }

@ -2,7 +2,6 @@ import React from "react"
class Step3 extends React.Component { class Step3 extends React.Component {
render() { render() {
console.log("hhhoohh");
return ( return (
<p>tttoooeeee</p> <p>tttoooeeee</p>
); );

@ -41,7 +41,7 @@ class Apps extends React.Component {
<Col span={6} offset={18}> <Col span={6} offset={18}>
<Search <Search
placeholder="search" placeholder="search"
onSearch={value => console.log(value)} // onSearch={value => console.log(value)}
style={{ width: 200}} style={{ width: 200}}
/> />
<Button style={{margin:5}}>Advanced Search</Button> <Button style={{margin:5}}>Advanced Search</Button>

@ -30,7 +30,7 @@ class Release extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.routes = props.routes; this.routes = props.routes;
this.state={ this.state = {
loading: true, loading: true,
app: null, app: null,
uuid: null uuid: null
@ -49,13 +49,13 @@ class Release extends React.Component {
} }
} }
fetchData = (uuid)=>{ fetchData = (uuid) => {
//send request to the invoker //send request to the invoker
axios.get( axios.get(
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications/release/"+uuid, config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/release/"+ uuid,
{ {
headers: { 'X-Platform': config.serverConfig.platform } headers: {'X-Platform': config.serverConfig.platform}
} }
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
@ -82,12 +82,11 @@ class Release extends React.Component {
render() { render() {
const {app} = this.state; const {app} = this.state;
const release = app;
if (release == null) { if (app == null) {
return ( return (
<div style={{background: '#f0f2f5', padding: 24, minHeight: 780}}> <div style={{background: '#f0f2f5', padding: 24, minHeight: 780}}>
<Title level={3}>No Releases Found</Title> <Title level={3}>No Apps Found</Title>
</div> </div>
); );
} }
@ -95,14 +94,11 @@ class Release extends React.Component {
//todo remove uppercase //todo remove uppercase
return ( return (
<div> <div>
<PageHeader
breadcrumb={{routes}}
/>
<div className="main-container"> <div className="main-container">
<Row style={{padding: 10}}> <Row style={{padding: 10}}>
<Col lg={16} md={24} style={{padding: 3}}> <Col lg={16} md={24} style={{padding: 3}}>
<Card> <Card>
<ReleaseView release={release}/> <ReleaseView app={app}/>
</Card> </Card>
</Col> </Col>
<Col lg={8} md={24} style={{padding: 3}}> <Col lg={8} md={24} style={{padding: 3}}>

@ -8,6 +8,12 @@
"hostname": "localhost", "hostname": "localhost",
"httpsPort": "9443", "httpsPort": "9443",
"invokerUri": "/ui-request-handler/invoke/application-mgt-store/v1.0", "invokerUri": "/ui-request-handler/invoke/application-mgt-store/v1.0",
"invoker": {
"uri": "/ui-request-handler/invoke",
"publisher": "/application-mgt-publisher/v1.0",
"store": "/application-mgt-store/v1.0",
"admin" : ""
},
"loginUri": "/ui-request-handler/login", "loginUri": "/ui-request-handler/login",
"platform": "store" "platform": "store"
}, },

@ -37,9 +37,11 @@ class AppList extends React.Component {
payload.deviceType= deviceType; payload.deviceType= deviceType;
} }
console.log("b",config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store+"/applications/");
//send request to the invoker //send request to the invoker
axios.post( axios.post(
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications/", config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store+"/applications/",
payload, payload,
{ {
headers: { 'X-Platform': config.serverConfig.platform } headers: { 'X-Platform': config.serverConfig.platform }
@ -54,7 +56,7 @@ class AppList extends React.Component {
}) })
} }
}).catch((error) => { }).catch((error) => { console.log(error.response);
if (error.hasOwnProperty("response") && error.response.status === 401) { if (error.hasOwnProperty("response") && error.response.status === 401) {
//todo display a popup with error //todo display a popup with error
message.error('You are not logged in'); message.error('You are not logged in');

@ -1,12 +1,13 @@
import React from "react"; import React from "react";
import {Row, Typography, Icon} from "antd"; import {Row, Typography, Icon} from "antd";
import StarRatings from "react-star-ratings"; import StarRatings from "react-star-ratings";
import axios from "axios";
import "./DetailedRating.css"; import "./DetailedRating.css";
import config from "../../../../public/conf/config.json"; import config from "../../../../public/conf/config.json";
import axios from "axios";
const { Text } = Typography; const { Text } = Typography;
class DetailedRating extends React.Component{ class DetailedRating extends React.Component{
constructor(props){ constructor(props){
@ -17,20 +18,24 @@ class DetailedRating extends React.Component{
} }
componentDidMount() { componentDidMount() {
this.getData(this.props.uuid); const {type,uuid} = this.props;
this.getData(type,uuid);
} }
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
if (prevProps.uuid !== this.props.uuid) { if (prevProps.uuid !== this.props.uuid) {
this.getData(this.props.uuid); const {type,uuid} = this.props;
this.getData(type,uuid);
} }
} }
getData = (uuid)=>{ getData = (type, 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 return axios.get(
).then(res => { config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+uuid+"/"+type+"-rating",
{
headers: { 'X-Platform': config.serverConfig.platform }
}).then(res => {
if (res.status === 200) { if (res.status === 200) {
let detailedRating = res.data.data; let detailedRating = res.data.data;
this.setState({ this.setState({
@ -48,8 +53,6 @@ class DetailedRating extends React.Component{
render() { render() {
const detailedRating = this.state.detailedRating; const detailedRating = this.state.detailedRating;
console.log(detailedRating);
if(detailedRating ==null){ if(detailedRating ==null){
return null; return null;
} }
@ -73,8 +76,6 @@ class DetailedRating extends React.Component{
} }
} }
console.log(ratingBarPercentages);
return ( return (
<Row className="d-rating"> <Row className="d-rating">
<div className="numeric-data"> <div className="numeric-data">

@ -21,14 +21,14 @@ class ReleaseView extends React.Component {
} }
} }
installApp = (type,payload) => { installApp = (type, payload) => {
const {uuid} = this.props.release; const {uuid} = this.props.release;
const parameters = { const parameters = {
method: "post", method: "post",
'content-type': "application/json", 'content-type': "application/json",
payload: JSON.stringify(payload), payload: JSON.stringify(payload),
'api-endpoint': "/application-mgt-store/v1.0/subscription/install/" + uuid + "/"+type+"/install" 'api-endpoint': "/application-mgt-store/v1.0/subscription/install/" + uuid + "/" + type + "/install"
}; };
const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&');
@ -36,7 +36,7 @@ class ReleaseView extends React.Component {
loading: true, loading: true,
}); });
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.invoker.uri + config.serverConfig.invoker.store, request
).then(res => { ).then(res => {
if (res.status === 201) { if (res.status === 201) {
this.setState({ this.setState({
@ -60,8 +60,9 @@ class ReleaseView extends React.Component {
} }
}).catch((error) => { }).catch((error) => {
console.log(error);
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login';
} else { } else {
this.setState({ this.setState({
loading: false, loading: false,
@ -133,13 +134,13 @@ class ReleaseView extends React.Component {
<Text>REVIEWS</Text> <Text>REVIEWS</Text>
<Row> <Row>
<Col lg={18}> <Col lg={18}>
<DetailedRating uuid={release.uuid}/> <DetailedRating type="app" uuid={release.uuid}/>
</Col> </Col>
<Col lg={6}> <Col lg={6}>
<AddReview uuid={release.uuid}/> <AddReview uuid={release.uuid}/>
</Col> </Col>
</Row> </Row>
<Reviews uuid={release.uuid}/> <Reviews type="app" uuid={release.uuid}/>
</div> </div>
</div> </div>
); );

@ -21,7 +21,7 @@ class AppInstallModal extends React.Component{
onCancel={this.props.onClose} onCancel={this.props.onClose}
footer={null} footer={null}
> >
<Tabs defaultActiveKey="1" onChange={()=>{console.log("changed");}}> <Tabs defaultActiveKey="1">
<TabPane tab="User" key="1"> <TabPane tab="User" key="1">
<UserInstall onInstall={this.props.onInstall}/> <UserInstall onInstall={this.props.onInstall}/>
</TabPane> </TabPane>

@ -95,7 +95,7 @@ class DeviceInstall extends React.Component {
rowSelection = { rowSelection = {
onChange: (selectedRowKeys, selectedRows) => { onChange: (selectedRowKeys, selectedRows) => {
console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows); // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
this.setState({ this.setState({
selectedRows: selectedRows selectedRows: selectedRows
}) })
@ -138,11 +138,10 @@ class DeviceInstall extends React.Component {
const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&');
//send request to the invoker //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.invoker.uri + config.serverConfig.invoker.store, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
const pagination = {...this.state.pagination}; const pagination = {...this.state.pagination};
console.log(res.data.data.devices);
this.setState({ this.setState({
loading: false, loading: false,
data: res.data.data.devices, data: res.data.data.devices,
@ -151,7 +150,7 @@ class DeviceInstall extends React.Component {
} }
}).catch((error) => { }).catch((error) => { console.log(error);
if (error.hasOwnProperty("status") && error.response.status === 401) { if (error.hasOwnProperty("status") && error.response.status === 401) {
//todo display a popop with error //todo display a popop with error
message.error('You are not logged in'); message.error('You are not logged in');

@ -35,9 +35,7 @@ class GroupInstall extends React.Component {
'api-endpoint': "/device-mgt/v1.0/admin/groups?name=" + value 'api-endpoint': "/device-mgt/v1.0/admin/groups?name=" + value
}; };
const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store, request
console.log(request);
axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
if (fetchId !== this.lastFetchId) { if (fetchId !== this.lastFetchId) {
@ -45,8 +43,6 @@ class GroupInstall extends React.Component {
return; return;
} }
console.log(res.data.data);
const data = res.data.data.deviceGroups.map(group => ({ const data = res.data.data.deviceGroups.map(group => ({
text: group.name, text: group.name,
value: group.name, value: group.name,
@ -55,7 +51,7 @@ class GroupInstall extends React.Component {
this.setState({data, fetching: false}); this.setState({data, fetching: false});
} }
}).catch((error) => { }).catch((error) => { console.log(error);
if (error.hasOwnProperty("status") && error.response.status === 401) { if (error.hasOwnProperty("status") && error.response.status === 401) {
message.error('You are not logged in'); message.error('You are not logged in');
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';

@ -35,9 +35,7 @@ class RoleInstall extends React.Component {
'api-endpoint': "/device-mgt/v1.0/roles?filter=" + value 'api-endpoint': "/device-mgt/v1.0/roles?filter=" + value
}; };
const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store, request
console.log(request);
axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
if (fetchId !== this.lastFetchId) { if (fetchId !== this.lastFetchId) {
@ -45,8 +43,6 @@ class RoleInstall extends React.Component {
return; return;
} }
console.log(res.data.data);
const data = res.data.data.roles.map(role => ({ const data = res.data.data.roles.map(role => ({
text: role, text: role,
value: role, value: role,
@ -55,7 +51,7 @@ class RoleInstall extends React.Component {
this.setState({data, fetching: false}); this.setState({data, fetching: false});
} }
}).catch((error) => { }).catch((error) => { console.log(error);
if (error.hasOwnProperty("status") && error.response.status === 401) { if (error.hasOwnProperty("status") && error.response.status === 401) {
message.error('You are not logged in'); message.error('You are not logged in');
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';

@ -23,22 +23,17 @@ class UserInstall extends React.Component {
}; };
fetchUser = value => { fetchUser = value => {
console.log('fetching user', value);
this.lastFetchId += 1; this.lastFetchId += 1;
const fetchId = this.lastFetchId; const fetchId = this.lastFetchId;
this.setState({data: [], fetching: true}); this.setState({data: [], fetching: true});
const parameters = { //send request to the invoker
method: "get", axios.get(
'content-type': "application/json", config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store+"/device-mgt/v1.0/users/search?username=" + value,
payload: "{}", {
'api-endpoint': "/device-mgt/v1.0/users/search?username=" + value headers: { 'X-Platform': config.serverConfig.platform }
}; }
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
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
if (fetchId !== this.lastFetchId) { if (fetchId !== this.lastFetchId) {
@ -46,8 +41,6 @@ class UserInstall extends React.Component {
return; return;
} }
console.log(res.data.data);
const data = res.data.data.users.map(user => ({ const data = res.data.data.users.map(user => ({
text: user.username, text: user.username,
value: user.username, value: user.username,

@ -54,8 +54,12 @@ class AddReview extends React.Component {
const request = "method=post&content-type=application/json&payload="+JSON.stringify(payload)+"&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid; const request = "method=post&content-type=application/json&payload="+JSON.stringify(payload)+"&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid;
axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request axios.post(
).then(res => { config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+uuid,
payload,
{
headers: { 'X-Platform': config.serverConfig.platform }
}).then(res => {
if (res.status === 201) { if (res.status === 201) {
this.setState({ this.setState({
loading: false, loading: false,

@ -27,9 +27,14 @@ class Reviews extends React.Component {
} }
fetchData = (offset, limit, callback) => { 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(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request const {uuid, type} = this.props;
).then(res => {
axios.get(
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+type+"/"+uuid,
{
headers: {'X-Platform': config.serverConfig.platform}
}).then(res => {
if (res.status === 200) { if (res.status === 200) {
let reviews = res.data.data.data; let reviews = res.data.data.data;
callback(reviews); callback(reviews);

@ -19,7 +19,6 @@ class Dashboard extends React.Component {
} }
changeSelectedMenuItem = (key) =>{ changeSelectedMenuItem = (key) =>{
console.log("called", key);
this.setState({ this.setState({
selectedKeys: [key] selectedKeys: [key]
}) })
@ -27,7 +26,6 @@ class Dashboard extends React.Component {
render() { render() {
const {selectedKeys} = this.state; const {selectedKeys} = this.state;
console.log(selectedKeys);
return ( return (
<div> <div>
<Layout className="layout"> <Layout className="layout">

@ -28,7 +28,6 @@ class Release extends React.Component {
} }
componentDidUpdate(prevProps, prevState, snapshot) { componentDidUpdate(prevProps, prevState, snapshot) {
console.log(prevState);
if (prevState.uuid !== this.state.uuid) { if (prevState.uuid !== this.state.uuid) {
const {uuid,deviceType} = this.props.match.params; const {uuid,deviceType} = this.props.match.params;
this.fetchData(uuid); this.fetchData(uuid);
@ -37,19 +36,9 @@ class Release extends React.Component {
} }
fetchData = (uuid)=>{ fetchData = (uuid)=>{
const parameters = {
method: "get",
'content-type': "application/json",
payload: "{}",
'api-endpoint': "/application-mgt-store/v1.0/applications/" + uuid
};
//url-encode parameters
const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&');
//send request to the invoker //send request to the invoker
axios.get( axios.get(
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri+"/applications/"+uuid, config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store+"/applications/"+uuid,
{ {
headers: { 'X-Platform': config.serverConfig.platform } headers: { 'X-Platform': config.serverConfig.platform }
} }
@ -57,8 +46,6 @@ class Release extends React.Component {
if (res.status === 200) { if (res.status === 200) {
let app = res.data.data; let app = res.data.data;
console.log(app);
this.setState({ this.setState({
app: app, app: app,
loading: false, loading: false,
@ -66,7 +53,7 @@ class Release extends React.Component {
}) })
} }
}).catch((error) => { }).catch((error) => { console.log(error);
if (error.hasOwnProperty("response") && error.response.status === 401) { if (error.hasOwnProperty("response") && error.response.status === 401) {
//todo display a popop with error //todo display a popop with error
message.error('You are not logged in'); message.error('You are not logged in');

Loading…
Cancel
Save