From 1712792d87945127981492f9b722d2f9afc4d679 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Fri, 3 May 2019 15:41:17 +0530 Subject: [PATCH] display release --- .../components/apps/release/ReleaseView.js | 33 ++++++++++++++ .../react-app/src/js/actions/index.js | 23 +++++++++- .../react-app/src/js/constants/ActionTypes.js | 3 +- .../react-app/src/js/reducers/index.js | 8 +++- .../pages/dashboard/apps/release/Release.js | 43 +++++++++++++------ 5 files changed, 94 insertions(+), 16 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/ReleaseView.js 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 new file mode 100644 index 0000000000..8e0953c9c3 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/ReleaseView.js @@ -0,0 +1,33 @@ +import React from "react"; +import {Avatar, Row, Col, Typography} from "antd"; + +const {Title, Text} = Typography; + +class ReleaseView extends React.Component { + render() { + const release = this.props.release; + return ( +
+ + + + + + App Name + {release.version}
+ {release.description} + +
+
+ + + + + +
+ ); + } +} + +export default ReleaseView; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js index ba225caf32..de94675a26 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js @@ -4,7 +4,6 @@ import config from "../../../public/conf/config.json"; export const getApps = () => dispatch => { - const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications"; return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request @@ -26,6 +25,28 @@ export const getApps = () => dispatch => { }); +}; + +export const getRelease = (uuid) => dispatch => { + + const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/release/"+uuid; + + return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + ).then(res => { + if (res.status === 200) { + let release = res.data.data; + + console.log(res.data); + dispatch({type: ActionTypes.GET_RELEASE, payload: release}); + } + + }).catch(function (error) { + if (error.response.status === 401) { + window.location.href = 'https://localhost:9443/publisher/login'; + } + }); + + }; export const openReleasesModal = (app) => dispatch => { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/ActionTypes.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/ActionTypes.js index 036e0e595f..211bd739a4 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/ActionTypes.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/ActionTypes.js @@ -9,7 +9,8 @@ const ActionTypes = keyMirror({ LOGIN: null, GET_APPS: null, OPEN_RELEASES_MODAL: null, - CLOSE_RELEASES_MODAL: null + CLOSE_RELEASES_MODAL: null, + GET_RELEASE: null }); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js index 51db6d4e50..5a9b379657 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js @@ -5,7 +5,8 @@ const initialState = { releaseView: { visible: false, app: null - } + }, + release: null }; function rootReducer(state = initialState, action) { @@ -20,6 +21,11 @@ function rootReducer(state = initialState, action) { app: action.payload.app } }); + }else if(action.type === ActionTypes.GET_RELEASE){ + return Object.assign({}, state, { + release: action.payload + }); + } return state; } 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 d497aed19d..aad15ec595 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,9 +1,11 @@ import React from "react"; -import "antd/dist/antd.css"; -import {PageHeader, Typography, Input, Button, Row, Col} from "antd"; - +import {PageHeader, Typography, Input, Button, Row, Col, Avatar, Card} from "antd"; +import {connect} from "react-redux"; +import ReleaseView from "../../../../components/apps/release/ReleaseView"; +import {getRelease} from "../../../../js/actions"; const Search = Input.Search; +const {Title} = Typography; const routes = [ { @@ -20,8 +22,15 @@ const routes = [ }, ]; +const mapStateToProps = state => { + return {release: state.release} +}; + +const mapDispatchToProps = dispatch => ({ + getRelease: (uuid) => dispatch(getRelease(uuid)) +}); -class Release extends React.Component { +class ConnectedRelease extends React.Component { routes; constructor(props) { @@ -31,11 +40,20 @@ class Release extends React.Component { } componentDidMount() { - + const {uuid} = this.props.match.params; + this.props.getRelease(uuid); } render() { - const {uuid} = this.props.match.params; + + const release = this.props.release; + if (release == null) { + return ( +
+ No Releases Found +
+ ); + } return (
- - console.log(value)} - style={{width: 200}} - /> - + + + +
@@ -60,4 +75,6 @@ class Release extends React.Component { } } +const Release = connect(mapStateToProps,mapDispatchToProps)(ConnectedRelease); + export default Release;