diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/AppCard.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/AppCard.js deleted file mode 100644 index 2d78b65697..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/AppCard.js +++ /dev/null @@ -1,60 +0,0 @@ -import { - Skeleton, Switch, Card, Icon, Avatar, Typography -} from 'antd'; -import React from "react"; -import config from "../../../public/conf/config.json"; -import {openReleasesModal} from "../../js/actions"; -import {connect} from "react-redux"; - -const { Meta } = Card; -const { Text } = Typography; - -const mapDispatchToProps = dispatch => ({ - openReleasesModal: (app) => dispatch(openReleasesModal(app)) -}); - -class ConnectedAppCard extends React.Component { - - constructor(props){ - super(props); - this.handleReleasesClick = this.handleReleasesClick.bind(this); - } - - handleReleasesClick(){ - this.props.openReleasesModal(this.props.app); - } - - - render() { - const defaultPlatformIcons = config.defaultPlatformIcons; - let icon = defaultPlatformIcons.default; - if(defaultPlatformIcons.hasOwnProperty(this.props.platform)){ - icon = defaultPlatformIcons[this.props.platform]; - } - let descriptionText = this.props.description; - if(descriptionText.length>50){ - descriptionText = descriptionText.substring(0,50)+"..."; - } - const description = ( -
-

{descriptionText}

- {this.props.type} - {this.props.subType} -
- ); - - return ( - , , ]}> - } - title={this.props.name} - description={description} - /> - - ); - } -} - -const AppCard = connect(null,mapDispatchToProps)(ConnectedAppCard); - -export default AppCard; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/AppList.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/AppList.js deleted file mode 100644 index 00f715825f..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/AppList.js +++ /dev/null @@ -1,42 +0,0 @@ -import React from "react"; -import AppCard from "./AppCard"; -import {Col, Row} from "antd"; -import {connect} from "react-redux"; -import {getApps} from "../../js/actions"; - -// connecting state.apps with the component -const mapStateToProps= state => { - return {apps : state.apps} -}; - - -class ConnectedAppList extends React.Component { - constructor(props) { - super(props); - } - componentDidMount() { - this.props.getApps(); - } - - render() { - return ( - - {this.props.apps.map(app => ( - - - - ))} - - ); - } -} - -const AppList = connect(mapStateToProps,{getApps})(ConnectedAppList); - -export default AppList; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js index da83fc878f..18fa46f812 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js @@ -21,8 +21,8 @@ class DetailedRating extends React.Component{ this.getData(this.props.uuid); } - componentDidUpdate(nextProps) { - if (nextProps !== this.props) { + componentDidUpdate(prevProps, prevState) { + if (prevProps.uuid !== this.props.uuid) { this.getData(this.props.uuid); } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js index 89949eb56e..16a6659af8 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js @@ -7,11 +7,6 @@ import config from "../../../../public/conf/config.json"; const {Title} = Typography; -// connecting state.apps with the component -const mapStateToProps = state => { - return {apps: state.apps} -}; - const columns = [ { title: '', @@ -71,7 +66,7 @@ const columns = [ }, ]; -class ConnectedAppsTable extends React.Component { +class AppsTable extends React.Component { constructor(props) { super(props); this.state = { @@ -175,6 +170,4 @@ class ConnectedAppsTable extends React.Component { } } -const AppsTable = connect(mapStateToProps, {getApps})(ConnectedAppsTable); - export default AppsTable; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps-old.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps-old.js deleted file mode 100644 index e24f40a6ea..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps-old.js +++ /dev/null @@ -1,60 +0,0 @@ -import React from "react"; -import "antd/dist/antd.css"; -import {PageHeader, Typography,Input, Button, Row, Col} from "antd"; -import AppList from "../../../components/apps/AppList"; -import ReleaseModal from "../../../components/apps/ReleaseModal"; - -const Search = Input.Search; - -const routes = [ - { - path: 'index', - breadcrumbName: 'Publisher', - }, - { - path: 'first', - breadcrumbName: 'Dashboard', - }, - { - path: 'second', - breadcrumbName: 'Apps', - }, -]; - - -class Apps extends React.Component { - routes; - constructor(props) { - super(props); - this.routes = props.routes; - - } - - render() { - return ( -
- -
- - - console.log(value)} - style={{ width: 200}} - /> - - - - - -
- -
- - ); - } -} - -export default Apps; 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 ac80be19a0..6b4aba3fbd 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 @@ -15,6 +15,7 @@ "axios": "^0.18.0", "d3": "^5.9.2", "dagre": "^0.8.4", + "javascript-time-ago": "^2.0.1", "keymirror": "^0.1.1", "lodash.debounce": "^4.0.8", "rc-viewer": "0.0.9", @@ -30,7 +31,6 @@ "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" }, @@ -65,8 +65,6 @@ "react": "^15.6.2", "react-dom": "^15.6.2", "react-intl": "^2.4.0", - "react-redux": "^7.0.2", - "redux": "^4.0.1", "sass-loader": "^6.0.7", "style-loader": "^0.18.2", "url-loader": "^1.1.2", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/RouteWithSubRoutes.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/RouteWithSubRoutes.js index 41cb84caf8..226db5ff22 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/RouteWithSubRoutes.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/RouteWithSubRoutes.js @@ -9,7 +9,7 @@ class RouteWithSubRoutes extends React.Component{ render() { return( ( - + )}/> ); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppCard.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppCard.js index 091dd984a7..1ef3f3333a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppCard.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppCard.js @@ -1,21 +1,13 @@ -import { - Skeleton, Switch, Card, Icon, Avatar, Typography, Col, Row, Rate -} from 'antd'; +import {Card, Typography, Col, Row} from 'antd'; import React from "react"; -import {openReleasesModal} from "../../js/actions"; -import {connect} from "react-redux"; import {Link} from "react-router-dom"; import "../../App.css"; import StarRatings from 'react-star-ratings'; const {Meta} = Card; -const {Text, Title} = Typography; +const {Text} = Typography; -const mapDispatchToProps = dispatch => ({ - openReleasesModal: (app) => dispatch(openReleasesModal(app)) -}); - -class ConnectedAppCard extends React.Component { +class AppCard extends React.Component { constructor(props) { super(props); @@ -29,11 +21,10 @@ class ConnectedAppCard extends React.Component { render() { const app = this.props.app; const release = this.props.app.applicationReleases[0]; - // console.log(this.props); const description = (
- + icon @@ -66,6 +57,4 @@ class ConnectedAppCard extends React.Component { } } -const AppCard = connect(null, mapDispatchToProps)(ConnectedAppCard); - export default AppCard; \ 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/AppList.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppList.js index e41c30290a..767843d710 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppList.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppList.js @@ -1,31 +1,88 @@ import React from "react"; import AppCard from "./AppCard"; -import {Col, Row} from "antd"; -import {connect} from "react-redux"; -import {getApps} from "../../js/actions"; +import {Col, message, Row} from "antd"; +import axios from "axios"; +import config from "../../../public/conf/config.json"; -// connecting state.apps with the component -const mapStateToProps= state => { - return {apps : state.apps} -}; - - -class ConnectedAppList extends React.Component { +class AppList extends React.Component { constructor(props) { super(props); + this.state = { + apps: [], + loading: false + } } + componentDidMount() { - this.props.getApps(); + console.log("mounted"); + const {deviceType} = this.props; + console.log(this.props); + this.props.changeSelectedMenuItem(deviceType); + this.fetchData(deviceType); } + + componentDidUpdate(prevProps, prevState) { + if (prevProps.deviceType !== this.props.deviceType) { + const {deviceType} = this.props; + this.props.changeSelectedMenuItem(deviceType); + this.fetchData(deviceType); + } + } + + fetchData = (deviceType) => { + + const payload = {}; + if(deviceType==="web-clip"){ + payload.appType= "WEB_CLIP"; + }else{ + payload.deviceType= deviceType; + } + const parameters = { + method: "post", + 'content-type': "application/json", + payload: JSON.stringify(payload), + 'api-endpoint': "/application-mgt-store/v1.0/applications/" + }; + + //url-encode parameters + const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); + + //send request to the invoker + axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + ).then(res => { + if (res.status === 200) { + //todo remove this property check after backend improvement + let apps = (res.data.data.hasOwnProperty("applications")) ? res.data.data.applications : []; + this.setState({ + apps: apps, + loading: false + }) + } + + }).catch((error) => { + if (error.hasOwnProperty("response") && error.response.status === 401) { + //todo display a popup 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 {apps} = this.state; + return ( - {this.props.apps.map(app => ( + {apps.map(app => ( + app={app} + /> ))} @@ -33,6 +90,4 @@ class ConnectedAppList extends React.Component { } } -const AppList = connect(mapStateToProps,{getApps})(ConnectedAppList); - export default AppList; \ 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/ReleaseModal.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/ReleaseModal.js deleted file mode 100644 index 2265aa6d3f..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/ReleaseModal.js +++ /dev/null @@ -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 ( -
- -

Some contents...

- ( - - } - title={{release.version}} - description={release.description} - /> - - )} - /> -
-
- ); - } else { - return null; - } - } -} - -const ReleaseModal = connect(mapStateToProps, null)(ConnectedReleaseModal); - -export default ReleaseModal; \ 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/DetailedRating.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/DetailedRating.js index b5dad1088c..f8dc026b8e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/DetailedRating.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/DetailedRating.js @@ -1,31 +1,52 @@ import React from "react"; import {Row, Typography, Icon} from "antd"; import StarRatings from "react-star-ratings"; +import axios from "axios"; import "./DetailedRating.css"; -import {connect} from "react-redux"; -import {getDetailedRating} from "../../../js/actions"; +import config from "../../../../public/conf/config.json"; const { Text } = Typography; -// connecting state. with the component -const mapStateToProps= state => { - return {detailedRating : state.detailedRating} -}; +class DetailedRating extends React.Component{ -const mapDispatchToProps = dispatch => ({ - getDetailedRating: (uuid) => dispatch(getDetailedRating(uuid)) -}); + constructor(props){ + super(props); + this.state={ + detailedRating: null + } + } + componentDidMount() { + this.getData(this.props.uuid); + } + componentDidUpdate(prevProps, prevState) { + if (prevProps.uuid !== this.props.uuid) { + this.getData(this.props.uuid); + } + } -class ConnectedDetailedRating extends React.Component{ + getData = (uuid)=>{ + const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid+"/rating"; - componentDidMount() { - this.props.getDetailedRating(this.props.uuid); - } + 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; + this.setState({ + detailedRating + }) + } + + }).catch(function (error) { + if (error.response.status === 401) { + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login'; + } + }); + }; render() { - const detailedRating = this.props.detailedRating; + const detailedRating = this.state.detailedRating; console.log(detailedRating); @@ -96,6 +117,5 @@ class ConnectedDetailedRating extends React.Component{ } } -const DetailedRating = connect(mapStateToProps,mapDispatchToProps)(ConnectedDetailedRating); export default DetailedRating; \ 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/ReleaseView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js index d95377e1c9..ea96028b80 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 @@ -89,7 +89,8 @@ class ReleaseView extends React.Component { }; render() { - const release = this.props.release; + const app = this.props.app; + const release = app.applicationReleases[0]; return (
- App Name + {app.name} Version : {release.version}

@@ -17,12 +21,12 @@ class AppInstallModal extends React.Component{ onCancel={this.props.onClose} footer={null} > - + {console.log("changed");}}> - Device install + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js new file mode 100644 index 0000000000..c1c7a5f2e5 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js @@ -0,0 +1,225 @@ +import React from "react"; +import axios from "axios"; +import config from "../../../../../public/conf/config.json"; +import {Button, message, Table, Typography} from "antd"; +import TimeAgo from 'javascript-time-ago' + +// Load locale-specific relative date/time formatting rules. +import en from 'javascript-time-ago/locale/en' +const {Text} = Typography; +const columns = [ + { + title: 'Device', + dataIndex: 'name', + fixed: 'left', + width: 100, + }, + { + title: 'Modal', + dataIndex: 'deviceInfo', + key:'modal', + render: deviceInfo => `${deviceInfo.vendor} ${deviceInfo.deviceModel}` + // todo add filtering options + }, + { + title: 'Owner', + dataIndex: 'enrolmentInfo', + key: 'owner', + render: enrolmentInfo => enrolmentInfo.owner + // todo add filtering options + }, + { + title: 'Last Updated', + dataIndex: 'enrolmentInfo', + key: 'dateOfLastUpdate', + render: (data) => { + return (getTimeAgo(data.dateOfLastUpdate)); + } + // todo add filtering options + }, + { + title: 'Status', + dataIndex: 'enrolmentInfo', + key: 'status', + render: enrolmentInfo => enrolmentInfo.status + // todo add filtering options + }, + { + title: 'Ownership', + dataIndex: 'enrolmentInfo', + key: 'ownership', + render: enrolmentInfo => enrolmentInfo.ownership + // todo add filtering options + }, + { + title: 'OS Version', + dataIndex: 'deviceInfo', + key:'osVersion', + render: deviceInfo => deviceInfo.osVersion + // todo add filtering options + }, + { + title: 'IMEI', + dataIndex: 'properties', + key:'imei', + render: properties => { + let imei = "not-found"; + for (let i = 0; i < properties.length; i++) { + if(properties[i].name==="IMEI"){ + imei = properties[i].value; + } + } + return imei; + } + // todo add filtering options + }, +]; + +const getTimeAgo = (time) => { + const timeAgo = new TimeAgo('en-US'); + return timeAgo.format(time); +}; + + +class DeviceInstall extends React.Component { + constructor(props) { + super(props); + TimeAgo.addLocale(en); + this.state = { + data: [], + pagination: {}, + loading: false, + selectedRows:[] + }; + } + + rowSelection = { + onChange: (selectedRowKeys, selectedRows) => { + console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows); + this.setState({ + selectedRows: selectedRows + }) + }, + getCheckboxProps: record => ({ + disabled: record.name === 'Disabled User', // Column configuration not to be checked + name: record.name, + }), + }; + + componentDidMount() { + this.fetch(); + } + + //fetch data from api + fetch = (params = {}) => { + this.setState({loading: true}); + + // get current page + const currentPage = (params.hasOwnProperty("page")) ? params.page : 1; + + const extraParams = { + offset: 10 * (currentPage - 1), //calculate the offset + limit: 10, + status: "INACTIVE", + requireDeviceInfo: true + }; + + // note: encode with '%26' not '&' + const encodedExtraParams = Object.keys(extraParams).map(key => key + '=' + extraParams[key]).join('%26'); + + const parameters = { + method: "get", + 'content-type': "application/json", + payload: "{}", + 'api-endpoint': "/device-mgt/v1.0/devices?" + encodedExtraParams + }; + + //url-encode parameters + const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); + + //send request to the invoker + axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + ).then(res => { + if (res.status === 200) { + const pagination = {...this.state.pagination}; + console.log(res.data.data.devices); + this.setState({ + loading: false, + data: res.data.data.devices, + pagination, + }); + + } + + }).catch((error) => { + if (error.hasOwnProperty("status") && 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}); + }); + }; + + handleTableChange = (pagination, filters, sorter) => { + const pager = {...this.state.pagination}; + pager.current = pagination.current; + this.setState({ + pagination: pager, + }); + this.fetch({ + results: pagination.pageSize, + page: pagination.current, + sortField: sorter.field, + sortOrder: sorter.order, + ...filters, + }); + }; + + install = () => { + const {selectedRows} = this.state; + const payload = []; + selectedRows.map(device => { + payload.push({ + deviceIdentifier: device.deviceIdentifier, + type: device.type + }); + }); + this.props.onInstall("device", payload); + }; + + + render() { + const {data,pagination,loading,selectedRows} = this.state; + return ( +
+ Start installing the application for one or more users by entering the corresponding user name. Select install to automatically start downloading the application for the respective user/users. + record.deviceIdentifier} + dataSource={data} + pagination={{ + ...pagination, + size: "small", + // position: "top", + showTotal: (total, range) => `showing ${range[0]}-${range[1]} of ${total} devices` + // showQuickJumper: true + }} + loading={loading} + onChange={this.handleTableChange} + rowSelection={this.rowSelection} + scroll={{x: 1000}} + /> +
+ +
+ + ); + } +} + +export default DeviceInstall; \ 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/install/GroupInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/GroupInstall.js index e57374f91f..535fefec22 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/GroupInstall.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/GroupInstall.js @@ -90,8 +90,7 @@ class GroupInstall extends React.Component { return (
- Lorem ipsum dolor sit amet, ne tation labores quo, errem facilisis expetendis vel in. Ut choro - decore ubique sed, + Start installing the application for one or more groups by entering the corresponding group name. Select install to automatically start downloading the application for the respective device group/ groups.

- +
); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js index 27ee3b8382..74d12b048a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js @@ -86,13 +86,11 @@ class UserInstall extends React.Component { }; render() { - const {fetching, data, value} = this.state; return (
- Lorem ipsum dolor sit amet, ne tation labores quo, errem facilisis expetendis vel in. Ut choro - decore ubique sed, + Start installing the application for one or more users by entering the corresponding user name. Select install to automatically start downloading the application for the respective user/users.

Select users

} + } placeholder="Username"/> )} @@ -100,7 +100,7 @@ class NormalLoginForm extends React.Component { {getFieldDecorator('password', { rules: [{required: true, message: 'Please input your Password!'}], })( - } type="password" placeholder="Password"/> )} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/Dashboard.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/Dashboard.js index da92c72a2d..458adf8d94 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/Dashboard.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/Dashboard.js @@ -13,11 +13,21 @@ class Dashboard extends React.Component { constructor(props) { super(props); this.state = { - routes: props.routes + routes: props.routes, + selectedKeys : [] } } + changeSelectedMenuItem = (key) =>{ + console.log("called", key); + this.setState({ + selectedKeys: [key] + }) + }; + render() { + const {selectedKeys} = this.state; + console.log(selectedKeys); return (
@@ -28,23 +38,21 @@ class Dashboard extends React.Component { - Apps - Apps - Add New - App + Android + iOS + Web Clips - + {this.state.routes.map((route) => ( - + ))} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/Apps.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/Apps.js index 90e68ed1d0..cb9ab7720a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/Apps.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/Apps.js @@ -1,26 +1,6 @@ import React from "react"; import "antd/dist/antd.css"; -import {PageHeader, Typography,Input, Button, Row, Col} from "antd"; import AppList from "../../../components/apps/AppList"; -import ReleaseModal from "../../../components/apps/ReleaseModal"; - -const Search = Input.Search; - -const routes = [ - { - path: 'index', - breadcrumbName: 'store', - }, - { - path: 'first', - breadcrumbName: 'Dashboard', - }, - { - path: 'second', - breadcrumbName: 'Apps', - }, -]; - class Apps extends React.Component { routes; @@ -30,25 +10,13 @@ class Apps extends React.Component { } + render() { + const {deviceType} = this.props.match.params; return (
-
- -
- console.log(value)} - style={{ width: 200}} - /> - - - - - + {deviceType!==null && } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js index 27afea477e..d6b3308b49 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js @@ -1,73 +1,98 @@ import React from "react"; import '../../../../App.css'; -import {Skeleton, Typography, Row, Col, Card} from "antd"; -import {connect} from "react-redux"; +import {Skeleton, Typography, Row, Col, Card, message} from "antd"; import ReleaseView from "../../../../components/apps/release/ReleaseView"; -import {getRelease, setLoading} from "../../../../js/actions"; +import axios from "axios"; +import config from "../../../../../public/conf/config.json"; const {Title} = Typography; -const routes = [ - { - path: 'index', - breadcrumbName: 'store', - }, - { - path: 'first', - breadcrumbName: 'Dashboard', - }, - { - path: 'second', - breadcrumbName: 'Apps', - }, -]; - -const mapStateToProps = state => { - return { - release: state.release, - releaseLoading: state.loadingState.release - } -}; - -const mapDispatchToProps = dispatch => ({ - getRelease: (uuid) => dispatch(getRelease(uuid)), - setLoading: (stateToLoad) => dispatch(setLoading(stateToLoad)) -}); - -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.setLoading("release"); - this.props.getRelease(uuid); + const {uuid, deviceType} = this.props.match.params; + this.fetchData(uuid); + this.props.changeSelectedMenuItem(deviceType); } - render() { + componentDidUpdate(prevProps, prevState, snapshot) { + console.log(prevState); + if (prevState.uuid !== this.state.uuid) { + const {uuid,deviceType} = this.props.match.params; + this.fetchData(uuid); + this.props.changeSelectedMenuItem(deviceType); + } + } + + 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 + axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + ).then(res => { + if (res.status === 200) { + let app = res.data.data; + + console.log(app); + + 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}); + }); + }; - const release = this.props.release; + render() { + const {app, loading} = this.state; let content = No Releases Found; - if (release != null) { - content = ; + if (app != null && app.applicationReleases.length!==0) { + content = ; } return ( -
+
- + {content} @@ -76,29 +101,8 @@ class ConnectedRelease extends React.Component { ); - - - // //todo remove uppercase - // return ( - //
- //
- // - //
- // - // - // - // - // - // - // - // - // - // - // - // ); } } -const Release = connect(mapStateToProps, mapDispatchToProps)(ConnectedRelease); export default Release;