Change api requests in publisher

feature/appm-store/pbac
Jayasanka 5 years ago
parent 48c87384f1
commit 129ff7944e

@ -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",

@ -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 {

@ -8,7 +8,6 @@ const {Title, Text, Paragraph} = Typography;
class ReleaseView extends React.Component {
render() {
const release = this.props.release;
console.log(release);
return (
<div>
<div className="release">
@ -19,7 +18,6 @@ class ReleaseView extends React.Component {
<Col xl={10} sm={11} className="release-title">
<Title level={2}>App Name</Title>
<Text>{release.version}</Text><br/>
<Text type="secondary">{release.description}</Text><br/>
</Col>
<Col xl={8} md={10} sm={24} xs={24} style={{float: "right"}}>
<div>
@ -50,12 +48,7 @@ class ReleaseView extends React.Component {
</Row>
<Divider/>
<Paragraph type="secondary" ellipsis={{rows: 3, expandable: true}}>
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}
</Paragraph>
</div>
</div>

@ -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"]({

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

@ -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 (
<div style={{background: '#f0f2f5', padding: 24, minHeight: 780}}>
@ -72,7 +107,7 @@ class ConnectedRelease extends React.Component {
</Col>
<Col lg={8} md={24} style={{padding: 3}}>
<Card lg={8} md={24}>
<LifeCycle currentStatus={release.currentStatus.toUpperCase()}/>
{/*<LifeCycle currentStatus={release.currentStatus.toUpperCase()}/>*/}
</Card>
</Col>
</Row>
@ -83,6 +118,4 @@ class ConnectedRelease extends React.Component {
}
}
const Release = connect(mapStateToProps,mapDispatchToProps)(ConnectedRelease);
export default Release;

Loading…
Cancel
Save