From c417b9708c415ec0869c6faff883cb8d70fe1e84 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Thu, 22 Aug 2019 20:22:32 +0530 Subject: [PATCH] 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 fb850c9d2c..33bc553aa9 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 a7bc211fae..dc2a247f14 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 6e7aea8eec..0000000000 --- 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 3dbea6b779..0000000000 --- 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 28a761eb7b..0000000000 --- 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 74cad82f97..0000000000 --- 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 dd53397b24..0000000000 --- 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 17a136aac6..0000000000 --- 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 1b4d9c8c2e..0000000000 --- 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 0f39908431..0000000000 --- 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 9b88445486..0000000000 --- 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 ac5a1b8683..0000000000 --- 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 d93eb6c81a..0000000000 --- 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 497e20bd06..0000000000 --- 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 - -