From cc9e034edd6eb79e45240b5940a5296674a0810f Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Thu, 22 Aug 2019 19:58:22 +0530 Subject: [PATCH 1/2] Add react device-mgt device view page --- .../react-app/package.json | 11 +- .../react-app/public/conf/config.json | 14 +- .../react-app/src/App.js | 4 +- .../src/components/Devices/DevicesTable.js | 262 ++++++++++++++++++ .../react-app/src/components/apps/AppCard.js | 2 +- .../react-app/src/components/apps/AppList.js | 4 +- .../components/apps/release/DetailedRating.js | 4 +- .../components/apps/release/ReleaseView.js | 4 +- .../apps/release/install/DeviceInstall.js | 2 +- .../apps/release/install/GroupInstall.js | 2 +- .../apps/release/install/RoleInstall.js | 2 +- .../apps/release/install/UserInstall.js | 2 +- .../apps/release/review/AddReview.js | 4 +- .../apps/release/review/CurrentUsersReview.js | 4 +- .../components/apps/release/review/Reviews.js | 4 +- .../review/singleReview/SingleReview.js | 4 +- .../singleReview/editReview/EditReview.js | 4 +- .../react-app/src/index.html | 2 +- .../react-app/src/index.js | 16 +- .../react-app/src/pages/Login.js | 4 +- .../src/pages/dashboard/Dashboard.js | 89 +----- .../pages/dashboard/add-new-app/AddNewApp.js | 2 +- .../pages/dashboard/apps/release/Release.js | 6 +- .../src/pages/dashboard/devices/Devices.js | 67 +++++ .../src/pages/dashboard/logout/Logout.js | 2 +- .../react-app/webpack.config.js | 2 +- 26 files changed, 388 insertions(+), 135 deletions(-) create mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Devices/DevicesTable.js create mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/devices/Devices.js diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/package.json b/components/device-mgt/io.entgra.device.mgt.ui/react-app/package.json index 77dc59124d4..fb850c9d2ce 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/package.json +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/package.json @@ -1,17 +1,12 @@ { - "name": "store", + "name": "entgra", "version": "1.0.0", - "description": "WSO2 IoT Server App Store", + "description": "Entgra device management", "main": "App.js", - "proxy": "http://localhost:3001", - "repository": { - "type": "git", - "url": "git://github.com/wso2/carbon-devicemgt" - }, "license": "Apache License 2.0", "dependencies": { "acorn": "^6.2.0", - "antd": "^3.20.1", + "antd": "^3.22.0", "axios": "^0.18.1", "d3": "^5.9.7", "dagre": "^0.8.4", diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/public/conf/config.json b/components/device-mgt/io.entgra.device.mgt.ui/react-app/public/conf/config.json index 0d1b5d86f46..43411cf4f81 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/public/conf/config.json +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/public/conf/config.json @@ -6,21 +6,21 @@ "primaryColor": "rgb(24, 144, 255)" }, "serverConfig": { - "invokerUri": "/ui-request-handler/invoke/application-mgt-store/v1.0", + "invokerUri": "/ui-request-handler/invoke/application-mgt-entgra/v1.0", "invoker": { - "uri": "/store-ui-request-handler/invoke", + "uri": "/entgra-ui-request-handler/invoke", "publisher": "/application-mgt-publisher/v1.0", - "store": "/application-mgt-store/v1.0", + "entgra": "/application-mgt-entgra/v1.0", "admin" : "", "deviceMgt" : "/device-mgt/v1.0" }, - "loginUri": "/store-ui-request-handler/login", - "logoutUri": "/store-ui-request-handler/logout", - "platform": "store" + "loginUri": "/entgra-ui-request-handler/login", + "logoutUri": "/entgra-ui-request-handler/logout", + "platform": "entgra" }, "defaultPlatformIcons": { "default": { - "icon": "global", + "icon": "hdd", "color": "#535c68", "theme": "outlined" }, diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/App.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/App.js index 5d8747417f5..68f8823e1a1 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/App.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/App.js @@ -65,7 +65,7 @@ class App extends React.Component { componentDidMount() { axios.get( - window.location.origin + "/store/public/conf/config.json", + window.location.origin + "/entgra/public/conf/config.json", ).then(res => { console.log(res); this.setState({ @@ -88,7 +88,7 @@ class App extends React.Component {
- + {this.props.routes.map((route) => ( ))} diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Devices/DevicesTable.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Devices/DevicesTable.js new file mode 100644 index 00000000000..a7bc211fae2 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Devices/DevicesTable.js @@ -0,0 +1,262 @@ +/* + * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. + * + * Entgra (pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React from "react"; +import axios from "axios"; +import {Tag, message, notification, Table, Typography, Tooltip, Icon} from "antd"; +import TimeAgo from 'javascript-time-ago' + +// Load locale-specific relative date/time formatting rules. +import en from 'javascript-time-ago/locale/en' +import {withConfigContext} from "../../context/ConfigContext"; + +const {Text} = Typography; + +let config = null; + +const columns = [ + { + title: 'Device', + dataIndex: 'name', + width: 100, + }, + { + title: 'Type', + dataIndex: 'type', + key: 'type', + render: type => { + const defaultPlatformIcons = config.defaultPlatformIcons; + let icon = defaultPlatformIcons.default.icon; + let color = defaultPlatformIcons.default.color; + let theme = defaultPlatformIcons.default.theme; + + if (defaultPlatformIcons.hasOwnProperty(type)) { + icon = defaultPlatformIcons[type].icon; + color = defaultPlatformIcons[type].color; + theme = defaultPlatformIcons[type].theme; + } + + return ( + + + + ); + } + // todo add filtering options + }, + { + title: 'Owner', + dataIndex: 'enrolmentInfo', + key: 'owner', + render: enrolmentInfo => enrolmentInfo.owner + // todo add filtering options + }, + { + title: 'Ownership', + dataIndex: 'enrolmentInfo', + key: 'ownership', + render: enrolmentInfo => enrolmentInfo.ownership + // todo add filtering options + }, + { + title: 'Status', + dataIndex: 'enrolmentInfo', + key: 'status', + render: (enrolmentInfo) => { + const status = enrolmentInfo.status.toLowerCase(); + let color = "#f9ca24"; + switch (status) { + case "active": + color = "#badc58"; + break; + case "created": + color = "#6ab04c"; + break; + case "removed": + color = "#ff7979"; + break; + case "inactive": + color = "#f9ca24"; + break; + case "blocked": + color = "#636e72"; + break; + } + return {status}; + } + // todo add filtering options + }, + { + title: 'Last Updated', + dataIndex: 'enrolmentInfo', + key: 'dateOfLastUpdate', + render: (data) => { + const {dateOfLastUpdate} = data; + const timeAgoString = getTimeAgo(dateOfLastUpdate); + return {timeAgoString}; + } + // 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 DeviceTable extends React.Component { + constructor(props) { + super(props); + config = this.props.context; + 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 = {}) => { + const config = this.props.context; + 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, + requireDeviceInfo: true, + }; + + const encodedExtraParams = Object.keys(extraParams).map(key => key + '=' + extraParams[key]).join('&'); + + //send request to the invoker + axios.get( + window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt + + "/devices?" + encodedExtraParams, + ).then(res => { + if (res.status === 200) { + const pagination = {...this.state.pagination}; + this.setState({ + loading: false, + data: res.data.data.devices, + pagination, + }); + } + + }).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 = window.location.origin + '/entgra/login'; + } else { + notification["error"]({ + message: "There was a problem", + duration: 0, + description: + "Error occurred while trying to load devices.", + }); + } + + 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, + }); + }; + + render() { + const {data, pagination, loading, selectedRows} = this.state; + return ( +
+ 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 withConfigContext(DeviceTable); \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppCard.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppCard.js index d18aa40bbfa..6e7aea8eecb 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppCard.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppCard.js @@ -42,7 +42,7 @@ class AppCard extends React.Component { const description = (
- +
icon diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppList.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppList.js index e6e459e3dc2..3dbea6b779f 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppList.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppList.js @@ -59,7 +59,7 @@ class AppList extends React.Component { }); //send request to the invoker axios.post( - window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/applications/", + window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.entgra + "/applications/", payload, ).then(res => { if (res.status === 200) { @@ -76,7 +76,7 @@ class AppList extends React.Component { if (error.hasOwnProperty("response") && error.response.status === 401) { //todo display a popup with error message.error('You are not logged in'); - window.location.href = window.location.origin+ '/store/login'; + window.location.href = window.location.origin+ '/entgra/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/DetailedRating.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/DetailedRating.js index 0536e966cf9..74cad82f97e 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/DetailedRating.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/DetailedRating.js @@ -52,7 +52,7 @@ class DetailedRating extends React.Component{ const config = this.props.context; return axios.get( - window.location.origin+ config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+uuid+"/"+type+"-rating", + window.location.origin+ config.serverConfig.invoker.uri +config.serverConfig.invoker.entgra+"/reviews/"+uuid+"/"+type+"-rating", ).then(res => { if (res.status === 200) { let detailedRating = res.data.data; @@ -63,7 +63,7 @@ class DetailedRating extends React.Component{ }).catch(function (error) { if (error.response.status === 401) { - window.location.href = window.location.origin+'/store/login'; + window.location.href = window.location.origin+'/entgra/login'; } }); }; diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/ReleaseView.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/ReleaseView.js index 6d55b45361d..dd53397b24b 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/ReleaseView.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/ReleaseView.js @@ -47,7 +47,7 @@ class ReleaseView extends React.Component { this.setState({ loading: true, }); - const url = window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/subscription/" + uuid + "/" + type + "/install"; + const url = window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.entgra + "/subscription/" + uuid + "/" + type + "/install"; axios.post( url, payload, @@ -79,7 +79,7 @@ class ReleaseView extends React.Component { }).catch((error) => { if (error.response.status === 401) { - window.location.href = window.location.origin+ '/store/login'; + window.location.href = window.location.origin+ '/entgra/login'; } else { this.setState({ loading: false, diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/DeviceInstall.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/DeviceInstall.js index 34dfefd362c..0f399084311 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/DeviceInstall.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/DeviceInstall.js @@ -168,7 +168,7 @@ class DeviceInstall extends React.Component { if (error.hasOwnProperty("status") && error.response.status === 401) { //todo display a popop with error message.error('You are not logged in'); - window.location.href = window.location.origin + '/store/login'; + window.location.href = window.location.origin + '/entgra/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/GroupInstall.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/GroupInstall.js index a8af7482c9a..9b884454862 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/GroupInstall.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/GroupInstall.js @@ -67,7 +67,7 @@ class GroupInstall extends React.Component { }).catch((error) => { console.log(error); if (error.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = window.location.origin+'/store/login'; + window.location.href = window.location.origin+'/entgra/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/RoleInstall.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/RoleInstall.js index 877fd3a4cb9..ac5a1b86830 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/RoleInstall.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/RoleInstall.js @@ -67,7 +67,7 @@ class RoleInstall extends React.Component { }).catch((error) => { console.log(error); if (error.hasOwnProperty("status") && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = window.location.origin+'/store/login'; + window.location.href = window.location.origin+'/entgra/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/UserInstall.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/UserInstall.js index 8e592d52cf5..d93eb6c81a7 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/UserInstall.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/UserInstall.js @@ -69,7 +69,7 @@ class UserInstall extends React.Component { }).catch((error) => { if (error.response.hasOwnProperty(status) && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = window.location.origin+ '/store/login'; + window.location.href = window.location.origin+ '/entgra/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/AddReview.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/AddReview.js index ee2b8f65ffa..497e20bd06c 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/AddReview.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/AddReview.js @@ -72,7 +72,7 @@ class AddReview extends React.Component { }; axios.post( - window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/" + uuid, + window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.entgra + "/reviews/" + uuid, payload, ).then(res => { if (res.status === 201) { @@ -104,7 +104,7 @@ class AddReview extends React.Component { }).catch((error) => { if (error.response.status === 401) { - window.location.href = window.location.origin+ '/store/login'; + window.location.href = window.location.origin+ '/entgra/login'; } else { this.setState({ loading: false, diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js index ed1f14711c4..2a901327bf5 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js @@ -44,7 +44,7 @@ class CurrentUsersReview extends React.Component { const config = this.props.context; axios.get( - window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/app/user/" + uuid, + window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.entgra + "/reviews/app/user/" + uuid, ).then(res => { if (res.status === 200) { const data = res.data.data.data; @@ -54,7 +54,7 @@ class CurrentUsersReview extends React.Component { }).catch((error) => { if (error.response.hasOwnProperty(status) && error.response.status === 401) { message.error('You are not logged in'); - window.location.href = window.location.origin+ '/store/login'; + window.location.href = window.location.origin+ '/entgra/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/Reviews.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/Reviews.js index ca0e84567c5..82429f6eed8 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/Reviews.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/Reviews.js @@ -50,7 +50,7 @@ class Reviews extends React.Component { const config = this.props.context; axios.get( - window.location.origin+ config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+type+"/"+uuid, + window.location.origin+ config.serverConfig.invoker.uri +config.serverConfig.invoker.entgra+"/reviews/"+type+"/"+uuid, { headers: {'X-Platform': config.serverConfig.platform} }).then(res => { @@ -61,7 +61,7 @@ class Reviews extends React.Component { }).catch(function (error) { if (error.response.status === 401) { - window.location.href = window.location.origin+ '/store/login'; + window.location.href = window.location.origin+ '/entgra/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js index 29f44b1a685..227def4664a 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js @@ -58,7 +58,7 @@ class SingleReview extends React.Component { const {id} = this.state.review; const config = this.props.context; - let url =window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store; + let url =window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.entgra; // call as an admin api if the review is not a personal review if (!this.props.isPersonalReview) { @@ -80,7 +80,7 @@ class SingleReview extends React.Component { }).catch((error) => { console.log(error); if (error.hasOwnProperty("response") && error.response.status === 401) { - window.location.href = window.location.origin+ '/store/login'; + window.location.href = window.location.origin+ '/entgra/login'; } else { notification["error"]({ message: "There was a problem", diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js index f18bac5079b..5a541f758f8 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js @@ -86,7 +86,7 @@ class EditReview extends React.Component { }; axios.put( - window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/" + uuid+"/"+id, + window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.entgra + "/reviews/" + uuid+"/"+id, payload, ).then(res => { if (res.status === 200) { @@ -117,7 +117,7 @@ class EditReview extends React.Component { }).catch((error) => { console.log(error); if (error.hasOwnProperty("response") && error.response.status === 401) { - window.location.href = window.location.origin+ '/store/login'; + window.location.href = window.location.origin+ '/entgra/login'; } else { this.setState({ loading: false, diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/index.html b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/index.html index 8f254050f24..f2d81b221cc 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/index.html +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/index.html @@ -20,7 +20,7 @@ - Entgra App Store + Entgra Device Management
\ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/index.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/index.js index 480ffce5af6..c8e24e74729 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/index.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/index.js @@ -22,30 +22,24 @@ import * as serviceWorker from './serviceWorker'; import App from "./App"; import Login from "./pages/Login"; import Dashboard from "./pages/dashboard/Dashboard"; -import Apps from "./pages/dashboard/apps/Apps"; -import Release from "./pages/dashboard/apps/release/Release"; import './index.css'; +import Devices from "./pages/dashboard/devices/Devices"; const routes = [ { - path: '/store/login', + path: '/entgra/login', exact: true, component: Login }, { - path: '/store', + path: '/entgra', exact: false, component: Dashboard, routes: [ { - path: '/store/:deviceType', - component: Apps, + path: '/entgra/devices', + component: Devices, exact: true - }, - { - path: '/store/:deviceType/apps/:uuid', - exact: true, - component: Release } ] } diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Login.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Login.js index 5aed47a3b41..19bbf40a27e 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Login.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Login.js @@ -93,7 +93,7 @@ class NormalLoginForm extends React.Component { const parameters = { username: values.username, password: values.password, - platform: "store" + platform: "entgra" }; const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); @@ -101,7 +101,7 @@ class NormalLoginForm extends React.Component { axios.post(window.location.origin+ config.serverConfig.loginUri, request ).then(res => { if (res.status === 200) { - window.location = window.location.origin+ "/store"; + window.location = window.location.origin+ "/entgra"; } }).catch(function (error) { if (error.response.status === 400) { diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/Dashboard.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/Dashboard.js index c7b8c475751..6ba16644bb7 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/Dashboard.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/Dashboard.js @@ -18,18 +18,17 @@ import React from "react"; import {Layout, Menu, Icon} from 'antd'; - -const {Header, Content, Footer} = Layout; -import {Link} from "react-router-dom"; -import RouteWithSubRoutes from "../../components/RouteWithSubRoutes"; -import {Switch} from 'react-router'; -import axios from "axios"; +import {Switch, Link} from "react-router-dom"; +import RouteWithSubRoutes from "../../components/RouteWithSubRoutes" +import {Redirect} from 'react-router' import "../../App.css"; import {withConfigContext} from "../../context/ConfigContext"; import Logout from "./logout/Logout"; +const {Header, Content, Footer} = Layout; const {SubMenu} = Menu; + class Dashboard extends React.Component { constructor(props) { super(props); @@ -41,50 +40,7 @@ class Dashboard extends React.Component { this.logo = this.props.context.theme.logo; } - componentDidMount() { - this.getDeviceTypes(); - } - - getDeviceTypes = () => { - const config = this.props.context; - axios.get( - window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt + "/device-types" - ).then(res => { - if (res.status === 200) { - const deviceTypes = JSON.parse(res.data.data); - this.setState({ - deviceTypes, - loading: false, - }); - } - - }).catch((error) => { - if (error.hasOwnProperty("response") && error.response.status === 401) { - window.location.href = window.location.origin + '/store/login'; - } else { - notification["error"]({ - message: "There was a problem", - duration: 0, - description: - "Error occurred while trying to load device types.", - }); - } - this.setState({ - loading: false - }); - }); - }; - - changeSelectedMenuItem = (key) => { - this.setState({ - selectedKeys: [key] - }) - }; - render() { - const config = this.props.context; - const {selectedKeys, deviceTypes} = this.state; - return (
@@ -95,31 +51,10 @@ class Dashboard extends React.Component { - { - deviceTypes.map((deviceType) => { - const platform = deviceType.name; - const defaultPlatformIcons = config.defaultPlatformIcons; - let icon = defaultPlatformIcons.default.icon; - let theme = defaultPlatformIcons.default.theme; - if (defaultPlatformIcons.hasOwnProperty(platform)) { - icon = defaultPlatformIcons[platform].icon; - theme = defaultPlatformIcons[platform].theme; - } - return ( - - - - {platform} - - - ); - }) - } - Web - Clips + Devices + + - + + {this.state.routes.map((route) => ( - + ))} - -
©2019 entgra.io diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/add-new-app/AddNewApp.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/add-new-app/AddNewApp.js index fbf94498138..0c794c8e0e0 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/add-new-app/AddNewApp.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/add-new-app/AddNewApp.js @@ -48,7 +48,7 @@ const Dragger = Upload.Dragger; const routes = [ { path: 'index', - breadcrumbName: 'store', + breadcrumbName: 'entgra', }, { path: 'first', diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/apps/release/Release.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/apps/release/Release.js index b1eb744b221..1b7ea7867e1 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/apps/release/Release.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/apps/release/Release.js @@ -58,7 +58,7 @@ class Release extends React.Component { //send request to the invoker axios.get( - window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/applications/" + uuid, + window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.entgra + "/applications/" + uuid, ).then(res => { if (res.status === 200) { let app = res.data.data; @@ -75,7 +75,7 @@ class Release extends React.Component { if (error.hasOwnProperty("response") && error.response.status === 401) { //todo display a popop with error message.error('You are not logged in'); - window.location.href = window.location.origin + '/store/login'; + window.location.href = window.location.origin + '/entgra/login'; } else { notification["error"]({ message: "There was a problem", @@ -110,7 +110,7 @@ class Release extends React.Component {
- {deviceType + " apps"} + {deviceType + " apps"} {appName} diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/devices/Devices.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/devices/Devices.js new file mode 100644 index 00000000000..9ca14d0c638 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/devices/Devices.js @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. + * + * Entgra (pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React from "react"; +import { + PageHeader, + Typography, + Breadcrumb, + Icon, + Card +} from "antd"; +import {Link} from "react-router-dom"; +import DeviceTable from "../../../components/Devices/DevicesTable"; + +const {Paragraph} = Typography; + +class Devices extends React.Component { + routes; + + constructor(props) { + super(props); + this.routes = props.routes; + + } + + render() { + return ( +
+ + + + Home + + Devices + +
+

Devices

+ Lorem ipsum dolor sit amet, est similique constituto at, quot inermis id mel, an + illud incorrupte nam. +
+
+
+
+ +
+
+
+ ); + } +} + +export default Devices; diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/logout/Logout.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/logout/Logout.js index 35068cc581b..3a011b9169c 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/logout/Logout.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/logout/Logout.js @@ -49,7 +49,7 @@ class Logout extends React.Component { ).then(res => { //if the api call status is correct then user will logout and then it goes to login page if (res.status === 200) { - window.location = window.location.origin + "/store/login"; + window.location = window.location.origin + "/entgra/login"; } }).catch(function (error) { diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/webpack.config.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/webpack.config.js index 2f3874ea211..116b83d79fb 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/webpack.config.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/webpack.config.js @@ -23,7 +23,7 @@ const configurations = require("./public/conf/config.json"); const config = { devtool: "source-map", output: { - publicPath: '/store/' + publicPath: '/entgra/' }, watch: false, resolve: { From c417b9708c415ec0869c6faff883cb8d70fe1e84 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Thu, 22 Aug 2019 20:22:32 +0530 Subject: [PATCH 2/2] Add react device-mgt device view page --- .../react-app/package.json | 3 - .../src/components/Devices/DevicesTable.js | 41 +- .../react-app/src/components/apps/AppCard.js | 78 ---- .../react-app/src/components/apps/AppList.js | 120 ------ .../apps/release/DetailedRating.css | 90 ----- .../components/apps/release/DetailedRating.js | 140 ------- .../components/apps/release/ReleaseView.js | 171 --------- .../apps/release/images/ImgViewer.js | 63 ---- .../apps/release/install/AppInstallModal.js | 62 --- .../apps/release/install/DeviceInstall.js | 248 ------------ .../apps/release/install/GroupInstall.js | 133 ------- .../apps/release/install/RoleInstall.js | 133 ------- .../apps/release/install/UserInstall.js | 133 ------- .../apps/release/review/AddReview.js | 181 --------- .../apps/release/review/CurrentUsersReview.js | 128 ------- .../apps/release/review/Reviews.css | 34 -- .../components/apps/release/review/Reviews.js | 155 -------- .../review/singleReview/SingleReview.css | 44 --- .../review/singleReview/SingleReview.js | 152 -------- .../singleReview/editReview/EditReview.css | 27 -- .../singleReview/editReview/EditReview.js | 191 ---------- .../react-app/src/index.js | 16 +- .../{dashboard => Dashboard}/Dashboard.js | 6 +- .../devices => Dashboard/Devices}/Devices.js | 2 +- .../react-app/src/pages/Dashboard/Geo/Geo.js | 65 ++++ .../logout => Dashboard/Logout}/Logout.js | 0 .../src/pages/Dashboard/Reports/Reports.js | 65 ++++ .../pages/dashboard/add-new-app/AddNewApp.js | 353 ------------------ .../pages/dashboard/add-new-app/IconImg.js | 84 ----- .../src/pages/dashboard/add-new-app/Step1.js | 170 --------- .../src/pages/dashboard/add-new-app/Step2.js | 29 -- .../src/pages/dashboard/add-new-app/Step3.js | 29 -- .../pages/dashboard/add-new-app/Style.less | 22 -- .../add-new-app/UploadScreenshots.js | 67 ---- .../add-new-app/components/AddTagModal.js | 67 ---- .../src/pages/dashboard/apps/Apps.js | 45 --- .../pages/dashboard/apps/release/Release.js | 131 ------- 37 files changed, 162 insertions(+), 3316 deletions(-) delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppCard.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppList.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/DetailedRating.css delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/DetailedRating.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/ReleaseView.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/images/ImgViewer.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/AppInstallModal.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/DeviceInstall.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/GroupInstall.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/RoleInstall.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/UserInstall.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/AddReview.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/Reviews.css delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/Reviews.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.css delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.css delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js rename components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/{dashboard => Dashboard}/Dashboard.js (88%) rename components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/{dashboard/devices => Dashboard/Devices}/Devices.js (96%) create mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Geo/Geo.js rename components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/{dashboard/logout => Dashboard/Logout}/Logout.js (100%) create mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Reports/Reports.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/add-new-app/AddNewApp.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/add-new-app/IconImg.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/add-new-app/Step1.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/add-new-app/Step2.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/add-new-app/Step3.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/add-new-app/Style.less delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/add-new-app/UploadScreenshots.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/add-new-app/components/AddTagModal.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/apps/Apps.js delete mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/dashboard/apps/release/Release.js diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/package.json b/components/device-mgt/io.entgra.device.mgt.ui/react-app/package.json index fb850c9d2ce..33bc553aa93 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/package.json +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/package.json @@ -8,13 +8,10 @@ "acorn": "^6.2.0", "antd": "^3.22.0", "axios": "^0.18.1", - "d3": "^5.9.7", - "dagre": "^0.8.4", "javascript-time-ago": "^2.0.1", "keymirror": "^0.1.1", "lodash.debounce": "^4.0.8", "rc-viewer": "0.0.9", - "react-d3-graph": "^2.1.0", "react-highlight-words": "^0.16.0", "react-image-viewer-zoom": "^1.0.36", "react-infinite-scroller": "^1.2.4", diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Devices/DevicesTable.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Devices/DevicesTable.js index a7bc211fae2..dc2a247f14d 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Devices/DevicesTable.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Devices/DevicesTable.js @@ -18,7 +18,7 @@ import React from "react"; import axios from "axios"; -import {Tag, message, notification, Table, Typography, Tooltip, Icon} from "antd"; +import {Tag, message, notification, Table, Typography, Tooltip, Icon, Divider} from "antd"; import TimeAgo from 'javascript-time-ago' // Load locale-specific relative date/time formatting rules. @@ -112,28 +112,17 @@ const columns = [ } // 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 - // }, + { + title: 'Action', + key: 'action', + render: () => ( + + + + + + ), + }, ]; const getTimeAgo = (time) => { @@ -161,11 +150,7 @@ class DeviceTable extends React.Component { this.setState({ selectedRows: selectedRows }) - }, - getCheckboxProps: record => ({ - disabled: record.name === 'Disabled User', // Column configuration not to be checked - name: record.name, - }), + } }; componentDidMount() { diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppCard.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppCard.js deleted file mode 100644 index 6e7aea8eecb..00000000000 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppCard.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import {Card, Typography, Col, Row} from 'antd'; -import React from "react"; -import {Link} from "react-router-dom"; -import "../../App.css"; -import StarRatings from 'react-star-ratings'; - -const {Meta} = Card; -const {Text} = Typography; - -class AppCard extends React.Component { - - constructor(props) { - super(props); - this.handleReleasesClick = this.handleReleasesClick.bind(this); - } - - handleReleasesClick() { - this.props.openReleasesModal(this.props.app); - } - - render() { - const app = this.props.app; - const release = this.props.app.applicationReleases[0]; - - const description = ( -
- - -
- icon - {/**/} - - - {app.name}
- {app.deviceType}
- - - - - - ); - - return ( - - - - ); - } -} - -export default AppCard; \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppList.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppList.js deleted file mode 100644 index 3dbea6b779f..00000000000 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/AppList.js +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React from "react"; -import AppCard from "./AppCard"; -import {Col, message, notification, Row, Result, Skeleton} from "antd"; -import axios from "axios"; -import {withConfigContext} from "../../context/ConfigContext"; - -class AppList extends React.Component { - constructor(props) { - super(props); - this.state = { - apps: [], - loading: true - } - } - - componentDidMount() { - const {deviceType} = 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 config = this.props.context; - const payload = {}; - if (deviceType === "web-clip") { - payload.appType = "WEB_CLIP"; - } else { - payload.deviceType = deviceType; - } - this.setState({ - loading: true - }); - //send request to the invoker - axios.post( - window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.entgra + "/applications/", - payload, - ).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) => { - console.log(error.response); - if (error.hasOwnProperty("response") && error.response.status === 401) { - //todo display a popup with error - message.error('You are not logged in'); - window.location.href = window.location.origin+ '/entgra/login'; - } else { - notification["error"]({ - message: "There was a problem", - duration: 0, - description: - "Error occurred while trying to load apps.", - }); - } - - this.setState({loading: false}); - }); - }; - - render() { - const {apps,loading} = this.state; - - return ( - - - {apps.length === 0 && ( - Back Home} - /> - )} - {apps.map(app => ( - - - - ))} - - - ); - } -} - -export default withConfigContext(AppList); \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/DetailedRating.css b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/DetailedRating.css deleted file mode 100644 index 28a761eb7b4..00000000000 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/DetailedRating.css +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -.d-rating .numeric-data{ - box-sizing: border-box; - display: inline-block; - padding: 20px 0 20px 0; - vertical-align: top; - text-align: center; - width: 30%; -} - -.d-rating .bar-containers{ - box-sizing: border-box; - display: inline-block; - padding: 20px 20px 20px 30px; - vertical-align: top; - width: 70%; -} - -.d-rating .bar-containers .bar-container{ - color: #737373; - font-weight: 400; - height: 20px; - margin-bottom: 4px; - position: relative; - width: 100%; -} - -.d-rating .bar-containers .bar-container .number{ - font-size: 11px; - left: -16px; - letter-spacing: 1px; - position: absolute; -} - -.d-rating .bar-containers .bar-container .bar{ - transition: width .25s ease; - display: inline-block; - height: 100%; - opacity: .8; - border-radius: 5px; -} - -.bar-container .rate-5{ - background: #57bb8a; -} - -.bar-container .rate-4{ - background: #9ace6a; -} - -.bar-container .rate-3{ - background: #ffcf02; -} - -.bar-container .rate-2{ - background: #ff9f02; -} - -.bar-container .rate-1{ - background: #ff6f31; -} - -.d-rating .numeric-data .rate{ - color: #333; - font-size: 64px; - font-weight: 100; - line-height: 64px; - padding-bottom: 6px; -} - -.d-rating .numeric-data .people-count{ - padding-top: 6px; -} \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/DetailedRating.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/DetailedRating.js deleted file mode 100644 index 74cad82f97e..00000000000 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/DetailedRating.js +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React from "react"; -import {Row, Typography, Icon} from "antd"; -import StarRatings from "react-star-ratings"; -import "./DetailedRating.css"; -import axios from "axios"; -import {withConfigContext} from "../../../context/ConfigContext"; - -const { Text } = Typography; - - -class DetailedRating extends React.Component{ - - constructor(props){ - super(props); - this.state={ - detailedRating: null - } - } - - componentDidMount() { - const {type,uuid} = this.props; - this.getData(type,uuid); - } - - componentDidUpdate(prevProps, prevState) { - if (prevProps.uuid !== this.props.uuid) { - const {type,uuid} = this.props; - this.getData(type,uuid); - } - } - - - getData = (type, uuid)=>{ - const config = this.props.context; - - return axios.get( - window.location.origin+ config.serverConfig.invoker.uri +config.serverConfig.invoker.entgra+"/reviews/"+uuid+"/"+type+"-rating", - ).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 = window.location.origin+'/entgra/login'; - } - }); - }; - - render() { - const detailedRating = this.state.detailedRating; - - if(detailedRating ==null){ - return null; - } - - const totalCount = detailedRating.noOfUsers; - const ratingVariety = detailedRating.ratingVariety; - - const ratingArray = []; - - for (let [key, value] of Object.entries(ratingVariety)) { - ratingArray.push(value); - } - - const maximumRating = Math.max(...ratingArray); - - const ratingBarPercentages = [0,0,0,0,0]; - - if(maximumRating>0){ - for(let i = 0; i<5; i++){ - ratingBarPercentages[i] = (ratingVariety[(i+1).toString()])/maximumRating*100; - } - } - - return ( - -
-
{detailedRating.ratingValue.toFixed(1)}
- -
- {totalCount} total -
-
-
- 5 - -
-
- 4 - -
-
- 3 - -
-
- 2 - -
-
- 1 - -
-
-
- ); - } -} - - -export default withConfigContext(DetailedRating); \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/ReleaseView.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/ReleaseView.js deleted file mode 100644 index dd53397b24b..00000000000 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/ReleaseView.js +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React from "react"; -import {Divider, Row, Col, Typography, Button, Rate, notification} from "antd"; -import "../../../App.css"; -import ImgViewer from "../../apps/release/images/ImgViewer"; -import StarRatings from "react-star-ratings"; -import DetailedRating from "./DetailedRating"; -import Reviews from "./review/Reviews"; -import axios from "axios"; -import AppInstallModal from "./install/AppInstallModal"; -import CurrentUsersReview from "./review/CurrentUsersReview"; -import {withConfigContext} from "../../../context/ConfigContext"; - -const {Title, Text, Paragraph} = Typography; - -class ReleaseView extends React.Component { - constructor(props) { - super(props); - this.state = { - loading: false, - appInstallModalVisible: false - } - } - - installApp = (type, payload) => { - const config = this.props.context; - const release = this.props.app.applicationReleases[0]; - const {uuid} = release; - - this.setState({ - loading: true, - }); - const url = window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.entgra + "/subscription/" + uuid + "/" + type + "/install"; - axios.post( - url, - payload, - { - headers: {'X-Platform': config.serverConfig.platform} - } - ).then(res => { - if (res.status === 200) { - this.setState({ - loading: false, - appInstallModalVisible: false - }); - notification["success"]({ - message: 'Done!', - description: - 'App installed triggered.', - }); - } else { - this.setState({ - loading: false - }); - notification["error"]({ - message: "There was a problem", - duration: 0, - description: - "Error occurred while installing app", - }); - } - - }).catch((error) => { - if (error.response.status === 401) { - window.location.href = window.location.origin+ '/entgra/login'; - } else { - this.setState({ - loading: false, - visible: false - }); - notification["error"]({ - message: "There was a problem", - duration: 0, - description: - "Error occurred while installing the app.", - }); - } - }); - }; - - showAppInstallModal = () => { - this.setState({ - appInstallModalVisible: true - }); - }; - - closeAppInstallModal = () => { - this.setState({ - appInstallModalVisible: false - }); - }; - - render() { - const {app,deviceType} = this.props; - const release = app.applicationReleases[0]; - return ( -
- -
- -
- icon - - - {app.name} - Version : {release.version}

- - - -
- - - -
- - - - - - - - - {release.description} - - - - - REVIEWS - - - - - - - - - ); - } -} - -export default withConfigContext(ReleaseView); \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/images/ImgViewer.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/images/ImgViewer.js deleted file mode 100644 index 17a136aac69..00000000000 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/images/ImgViewer.js +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React, {Component} from 'react'; -import RcViewer from 'rc-viewer'; -import {Col} from "antd"; - -class ImgViewer extends Component { - render() { - const options = { - title: false, - toolbar: { - zoomIn: 0, - zoomOut: 0, - oneToOne: 0, - reset: 0, - prev: 1, - play: { - show: 0 - }, - next: 1, - rotateLeft: 0, - rotateRight: 0, - flipHorizontal: 0, - flipVertical: 0 - }, - rotatable: false, - transition: false, - movable : false - }; - return ( -
- - {this.props.images.map((screenshotUrl) => { - return ( -
- - - ) - })} - - - ); - - } -} - -export default ImgViewer; \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/AppInstallModal.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/AppInstallModal.js deleted file mode 100644 index 1b4d9c8c2ed..00000000000 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/AppInstallModal.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React from "react"; -import {Modal, Tabs} from "antd"; -import UserInstall from "./UserInstall"; -import GroupInstall from "./GroupInstall"; -import RoleInstall from "./RoleInstall"; -import DeviceInstall from "./DeviceInstall"; - -const { TabPane } = Tabs; - -class AppInstallModal extends React.Component{ - state={ - data:[] - }; - render() { - const {deviceType} = this.props; - return ( -
- - - - - - - - - - - - - - - - -
- ); - } -} - -export default AppInstallModal; \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/DeviceInstall.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/DeviceInstall.js deleted file mode 100644 index 0f399084311..00000000000 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/DeviceInstall.js +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React from "react"; -import axios from "axios"; -import {Button, message, notification, 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' -import {withConfigContext} from "../../../../context/ConfigContext"; - -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 = {}) => { - const config = this.props.context; - this.setState({loading: true}); - const {deviceType} = this.props; - // get current page - const currentPage = (params.hasOwnProperty("page")) ? params.page : 1; - - const extraParams = { - offset: 10 * (currentPage - 1), //calculate the offset - limit: 10, - status: "ACTIVE", - requireDeviceInfo: true, - type: deviceType - }; - - // note: encode with '%26' not '&' - const encodedExtraParams = Object.keys(extraParams).map(key => key + '=' + extraParams[key]).join('&'); - - //send request to the invoker - axios.get( - window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt + - "/devices?" + encodedExtraParams, - ).then(res => { - if (res.status === 200) { - const pagination = {...this.state.pagination}; - this.setState({ - loading: false, - data: res.data.data.devices, - pagination, - }); - - } - - }).catch((error) => { - console.log(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 = window.location.origin + '/entgra/login'; - } else { - notification["error"]({ - message: "There was a problem", - duration: 0, - description: - "Error occurred while trying to load devices.", - }); - } - - 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({ - id: device.deviceIdentifier, - type: device.type - }); - }); - this.props.onInstall("devices", 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 withConfigContext(DeviceInstall); \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/GroupInstall.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/GroupInstall.js deleted file mode 100644 index 9b884454862..00000000000 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/GroupInstall.js +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React from "react"; -import {Typography, Select, Spin, message, notification, Button} from "antd"; -import debounce from 'lodash.debounce'; -import axios from "axios"; -import {withConfigContext} from "../../../../context/ConfigContext"; - -const {Text} = Typography; -const {Option} = Select; - - -class GroupInstall extends React.Component { - - constructor(props) { - super(props); - this.lastFetchId = 0; - this.fetchUser = debounce(this.fetchUser, 800); - } - - state = { - data: [], - value: [], - fetching: false, - }; - - fetchUser = value => { - this.lastFetchId += 1; - const fetchId = this.lastFetchId; - const config = this.props.context; - this.setState({data: [], fetching: true}); - - axios.post( - window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/groups?name=" + value, - - ).then(res => { - if (res.status === 200) { - if (fetchId !== this.lastFetchId) { - // for fetch callback order - return; - } - - const data = res.data.data.deviceGroups.map(group => ({ - text: group.name, - value: group.name, - })); - - this.setState({data, fetching: false}); - } - - }).catch((error) => { console.log(error); - if (error.hasOwnProperty("status") && error.response.status === 401) { - message.error('You are not logged in'); - window.location.href = window.location.origin+'/entgra/login'; - } else { - notification["error"]({ - message: "There was a problem", - duration: 0, - description: - "Error occurred while trying to load groups.", - }); - } - - this.setState({fetching: false}); - }); - }; - - handleChange = value => { - this.setState({ - value, - data: [], - fetching: false, - }); - }; - - install = () =>{ - const {value} = this.state; - const data = []; - value.map(val=>{ - data.push(val.key); - }); - this.props.onInstall("group",data); - }; - - render() { - - const {fetching, data, value} = this.state; - - return ( -
- 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. -
-
- -
- -
-
- ); - } -} - -export default withConfigContext(GroupInstall); \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/RoleInstall.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/RoleInstall.js deleted file mode 100644 index ac5a1b86830..00000000000 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/RoleInstall.js +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React from "react"; -import {Typography, Select, Spin, message, notification, Button} from "antd"; -import debounce from 'lodash.debounce'; -import axios from "axios"; -import {withConfigContext} from "../../../../context/ConfigContext"; - -const {Text} = Typography; -const {Option} = Select; - - -class RoleInstall extends React.Component { - - constructor(props) { - super(props); - this.lastFetchId = 0; - this.fetchUser = debounce(this.fetchUser, 800); - } - - state = { - data: [], - value: [], - fetching: false, - }; - - fetchUser = value => { - const config = this.props.context; - this.lastFetchId += 1; - const fetchId = this.lastFetchId; - this.setState({data: [], fetching: true}); - - axios.get( - window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/roles?filter=" + value, - - ).then(res => { - if (res.status === 200) { - if (fetchId !== this.lastFetchId) { - // for fetch callback order - return; - } - - const data = res.data.data.roles.map(role => ({ - text: role, - value: role, - })); - - this.setState({data, fetching: false}); - } - - }).catch((error) => { console.log(error); - if (error.hasOwnProperty("status") && error.response.status === 401) { - message.error('You are not logged in'); - window.location.href = window.location.origin+'/entgra/login'; - } else { - notification["error"]({ - message: "There was a problem", - duration: 0, - description: - "Error occurred while trying to load roles.", - }); - } - - this.setState({fetching: false}); - }); - }; - - handleChange = value => { - this.setState({ - value, - data: [], - fetching: false, - }); - }; - - install = () =>{ - const {value} = this.state; - const data = []; - value.map(val=>{ - data.push(val.key); - }); - this.props.onInstall("role",data); - }; - - render() { - - const {fetching, data, value} = this.state; - - return ( -
- Start installing the application for one or more roles by entering the corresponding role name. Select install to automatically start downloading the application for the respective user role/roles. -
-
- -
- -
-
- ); - } -} - -export default withConfigContext(RoleInstall); \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/UserInstall.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/UserInstall.js deleted file mode 100644 index d93eb6c81a7..00000000000 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/UserInstall.js +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React from "react"; -import {Typography, Select, Spin, message, notification, Button} from "antd"; -import debounce from 'lodash.debounce'; -import axios from "axios"; -import {withConfigContext} from "../../../../context/ConfigContext"; - -const {Text} = Typography; -const {Option} = Select; - - -class UserInstall extends React.Component { - - constructor(props) { - super(props); - this.lastFetchId = 0; - this.fetchUser = debounce(this.fetchUser, 800); - } - - state = { - data: [], - value: [], - fetching: false, - }; - - fetchUser = value => { - const config = this.props.context; - this.lastFetchId += 1; - const fetchId = this.lastFetchId; - this.setState({data: [], fetching: true}); - - - //send request to the invoker - axios.get( - window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/users/search?username=" + value, - - ).then(res => { - if (res.status === 200) { - if (fetchId !== this.lastFetchId) { - // for fetch callback order - return; - } - - const data = res.data.data.users.map(user => ({ - text: user.username, - value: user.username, - })); - - this.setState({data, fetching: false}); - } - - }).catch((error) => { - if (error.response.hasOwnProperty(status) && error.response.status === 401) { - message.error('You are not logged in'); - window.location.href = window.location.origin+ '/entgra/login'; - } else { - notification["error"]({ - message: "There was a problem", - duration: 0, - description: - "Error occurred while trying to load users.", - }); - } - - this.setState({fetching: false}); - }); - }; - - handleChange = value => { - this.setState({ - value, - data: [], - fetching: false, - }); - }; - - install = () => { - const {value} = this.state; - const data = []; - value.map(val => { - data.push(val.key); - }); - this.props.onInstall("user", data); - }; - - render() { - const {fetching, data, value} = 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. -

Select users

- -
- -
-
- ); - } -} - -export default withConfigContext(UserInstall); \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/AddReview.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/AddReview.js deleted file mode 100644 index 497e20bd06c..00000000000 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/review/AddReview.js +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React from "react"; -import {Drawer, Button, Icon, Row, Col, Typography, Divider, Input, Spin, notification} from 'antd'; -import StarRatings from "react-star-ratings"; -import axios from "axios"; -import {withConfigContext} from "../../../../context/ConfigContext"; - -const {Title} = Typography; -const {TextArea} = Input; - -class AddReview extends React.Component { - state = { - visible: false, - content: '', - rating: 0, - loading: false - }; - - showDrawer = () => { - this.setState({ - visible: true, - content: '', - rating: 0, - loading: false - }); - }; - - onClose = () => { - this.setState({ - visible: false, - - }); - }; - changeRating = (newRating, name) => { - this.setState({ - rating: newRating - }); - }; - - onChange = (e) => { - this.setState({content: e.target.value}) - }; - - onSubmit = () => { - const config = this.props.context; - const {content, rating} = this.state; - const {uuid} = this.props; - this.setState({ - loading: true - }); - - const payload = { - content: content, - rating: rating - }; - - axios.post( - window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.entgra + "/reviews/" + uuid, - payload, - ).then(res => { - if (res.status === 201) { - this.setState({ - loading: false, - visible: false - }); - notification["success"]({ - message: 'Done!', - description: - 'Your review has been posted successfully.', - }); - - setTimeout(() => { - window.location.href = uuid; - }, 2000) - } else { - this.setState({ - loading: false, - visible: false - }); - notification["error"]({ - message: "There was a problem", - duration: 0, - description: - "We are unable to add your review right now.", - }); - } - - }).catch((error) => { - if (error.response.status === 401) { - window.location.href = window.location.origin+ '/entgra/login'; - } else { - this.setState({ - loading: false, - visible: false - }); - notification["error"]({ - message: "There was a problem", - duration: 0, - description: - "We are unable to add your review right now.", - }); - } - }); - - - }; - - render() { - return ( -
- - - - - -
- - Add review - -