forked from community/device-mgt-core
parent
d188b18bc5
commit
ff7158bf00
@ -1,85 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import {Modal, Typography,List, Avatar} from 'antd';
|
|
||||||
import {connect} from 'react-redux';
|
|
||||||
import {Link} from "react-router-dom";
|
|
||||||
|
|
||||||
// connecting state.releaseView with the component
|
|
||||||
const mapStateToProps = state => {
|
|
||||||
return {releaseView: state.releaseView}
|
|
||||||
};
|
|
||||||
|
|
||||||
const Text = Typography;
|
|
||||||
|
|
||||||
class ConnectedReleaseModal extends React.Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
visible: false,
|
|
||||||
app: null
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
|
||||||
if (nextProps !== this.props) {
|
|
||||||
this.setState({
|
|
||||||
visible: nextProps.releaseView.visible,
|
|
||||||
app: nextProps.releaseView.app
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
showModal = () => {
|
|
||||||
this.setState({
|
|
||||||
visible: true,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
handleOk = (e) => {
|
|
||||||
this.setState({
|
|
||||||
visible: false,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
handleCancel = (e) => {
|
|
||||||
this.setState({
|
|
||||||
visible: false,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
if (this.props.releaseView.app != null) {
|
|
||||||
const app = this.props.releaseView.app;
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Modal
|
|
||||||
title={app.name}
|
|
||||||
visible={this.state.visible}
|
|
||||||
onOk={this.handleOk}
|
|
||||||
onCancel={this.handleCancel}
|
|
||||||
>
|
|
||||||
<p>Some contents...</p>
|
|
||||||
<List
|
|
||||||
itemLayout="horizontal"
|
|
||||||
dataSource={app.applicationReleases}
|
|
||||||
renderItem={release => (
|
|
||||||
<List.Item>
|
|
||||||
<List.Item.Meta
|
|
||||||
avatar={<Avatar src={release.iconPath} />}
|
|
||||||
title={<Link to={"/store/apps/"+release.uuid}>{release.version}</Link>}
|
|
||||||
description={release.description}
|
|
||||||
/>
|
|
||||||
</List.Item>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</Modal>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const ReleaseModal = connect(mapStateToProps, null)(ConnectedReleaseModal);
|
|
||||||
|
|
||||||
export default ReleaseModal;
|
|
@ -1,168 +0,0 @@
|
|||||||
import axios from "axios";
|
|
||||||
import ActionTypes from "../constants/ActionTypes";
|
|
||||||
import config from "../../../public/conf/config.json";
|
|
||||||
|
|
||||||
export const getApps = () => dispatch => {
|
|
||||||
|
|
||||||
const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications";
|
|
||||||
|
|
||||||
return axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
|
|
||||||
).then(res => {
|
|
||||||
if (res.status === 200) {
|
|
||||||
let apps = [];
|
|
||||||
|
|
||||||
if (res.data.data.hasOwnProperty("applications")) {
|
|
||||||
apps = res.data.data.applications;
|
|
||||||
}
|
|
||||||
dispatch({type: ActionTypes.GET_APPS, payload: apps});
|
|
||||||
}
|
|
||||||
|
|
||||||
}).catch(function (error) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getRelease = (uuid) => dispatch => {
|
|
||||||
|
|
||||||
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications/" + uuid;
|
|
||||||
|
|
||||||
return axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
|
|
||||||
).then(res => {
|
|
||||||
if (res.status === 200) {
|
|
||||||
let release = res.data.data.applicationReleases[0];
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.GET_RELEASE,
|
|
||||||
payload: {
|
|
||||||
release: release,
|
|
||||||
releaseLoading: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}).catch(function (error) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
|
|
||||||
}else if(error.response.status===404){
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.GET_RELEASE,
|
|
||||||
payload: {
|
|
||||||
release: null,
|
|
||||||
releaseLoading: false
|
|
||||||
}});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
export const openReleasesModal = (app) => dispatch => {
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.OPEN_RELEASES_MODAL,
|
|
||||||
payload: {
|
|
||||||
app: app
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
export const openLifecycleModal = (nextState) => dispatch => {
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.OPEN_LIFECYCLE_MODAL,
|
|
||||||
payload: {
|
|
||||||
nextState: nextState
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const closeLifecycleModal = () => dispatch => {
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.CLOSE_LIFECYCLE_MODAL
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const setLoading = (stateToLoad) => dispatch => {
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.SET_LOADING_STATE,
|
|
||||||
payload: {
|
|
||||||
stateToLoad: stateToLoad
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getLifecycle = () => dispatch => {
|
|
||||||
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications/lifecycle-config";
|
|
||||||
|
|
||||||
return axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
|
|
||||||
).then(res => {
|
|
||||||
if (res.status === 200) {
|
|
||||||
let lifecycle = res.data.data;
|
|
||||||
dispatch({type: ActionTypes.GET_LIFECYCLE, payload: lifecycle});
|
|
||||||
}
|
|
||||||
|
|
||||||
}).catch(function (error) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const updateLifecycleState = (uuid, nextState, reason) => dispatch => {
|
|
||||||
|
|
||||||
const payload = {
|
|
||||||
action: nextState,
|
|
||||||
reason: reason
|
|
||||||
};
|
|
||||||
|
|
||||||
const request = "method=post&content-type=application/json&payload=" + JSON.stringify(payload) + "&api-endpoint=/application-mgt-store/v1.0/applications/life-cycle/" + uuid;
|
|
||||||
|
|
||||||
|
|
||||||
return axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
|
|
||||||
).then(res => {
|
|
||||||
if (res.status === 201) {
|
|
||||||
let release = res.data.data;
|
|
||||||
dispatch({type: ActionTypes.UPDATE_LIFECYCLE_STATE, payload: release});
|
|
||||||
}else {
|
|
||||||
alert("error");
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.CLOSE_LIFECYCLE_MODAL
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}).catch(function (error) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
|
|
||||||
} else if (error.response.status === 500) {
|
|
||||||
alert("error");
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.CLOSE_LIFECYCLE_MODAL
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getDetailedRating = (uuid) => dispatch => {
|
|
||||||
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 => {
|
|
||||||
if (res.status === 200) {
|
|
||||||
let detailedRating = res.data.data;
|
|
||||||
dispatch({type: ActionTypes.GET_DETAILED_RATING, payload: detailedRating});
|
|
||||||
}
|
|
||||||
|
|
||||||
}).catch(function (error) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
|
|
||||||
} else{
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.GET_DETAILED_RATING, payload: null
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
@ -1,17 +0,0 @@
|
|||||||
import keyMirror from 'keymirror';
|
|
||||||
|
|
||||||
const ActionTypes = keyMirror({
|
|
||||||
LOGIN: null,
|
|
||||||
GET_APPS: null,
|
|
||||||
OPEN_RELEASES_MODAL: null,
|
|
||||||
CLOSE_RELEASES_MODAL: null,
|
|
||||||
GET_RELEASE: null,
|
|
||||||
GET_LIFECYCLE: null,
|
|
||||||
OPEN_LIFECYCLE_MODAL: null,
|
|
||||||
CLOSE_LIFECYCLE_MODAL: null,
|
|
||||||
UPDATE_LIFECYCLE_STATE: null,
|
|
||||||
SET_LOADING_STATE: null,
|
|
||||||
GET_DETAILED_RATING: null
|
|
||||||
});
|
|
||||||
|
|
||||||
export default ActionTypes;
|
|
@ -1,83 +0,0 @@
|
|||||||
import ActionTypes from "../constants/ActionTypes";
|
|
||||||
|
|
||||||
const initialState = {
|
|
||||||
apps: [],
|
|
||||||
releaseView: {
|
|
||||||
visible: false,
|
|
||||||
app: null
|
|
||||||
},
|
|
||||||
release: null,
|
|
||||||
lifecycle: null,
|
|
||||||
lifecycleModal: {
|
|
||||||
visible: false,
|
|
||||||
nextState: null
|
|
||||||
},
|
|
||||||
loadingState: {
|
|
||||||
release: true
|
|
||||||
},
|
|
||||||
detailedRating: null
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
function rootReducer(state = initialState, action) {
|
|
||||||
if (action.type === ActionTypes.GET_APPS) {
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
apps: action.payload
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.OPEN_RELEASES_MODAL) {
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
releaseView: {
|
|
||||||
visible: true,
|
|
||||||
app: action.payload.app
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.GET_RELEASE) {
|
|
||||||
let loadingState = {...state.loadingState};
|
|
||||||
loadingState.release = action.payload.releaseLoading;
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
release: action.payload.release,
|
|
||||||
loadingState: loadingState
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.GET_LIFECYCLE) {
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
lifecycle: action.payload
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.OPEN_LIFECYCLE_MODAL) {
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
lifecycleModal: {
|
|
||||||
visible: true,
|
|
||||||
nextState: action.payload.nextState
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.CLOSE_LIFECYCLE_MODAL) {
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
lifecycleModal: {
|
|
||||||
visible: false,
|
|
||||||
nextState: null
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.UPDATE_LIFECYCLE_STATE) {
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
lifecycleModal: {
|
|
||||||
visible: false,
|
|
||||||
nextState: null,
|
|
||||||
},
|
|
||||||
release: action.payload
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.SET_LOADING_STATE) {
|
|
||||||
let loadingState = {...state.loadingState};
|
|
||||||
loadingState[action.payload.stateToLoad] = true;
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
loadingState: loadingState
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.GET_DETAILED_RATING) {
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
detailedRating: action.payload
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export default rootReducer;
|
|
@ -1,5 +0,0 @@
|
|||||||
import { createStore, applyMiddleware } from "redux";
|
|
||||||
import rootReducer from "../reducers/index";
|
|
||||||
import thunk from "redux-thunk";
|
|
||||||
const store = createStore(rootReducer, applyMiddleware(thunk));
|
|
||||||
export default store;
|
|
Loading…
Reference in new issue