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 77dc59124d..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 @@ -1,25 +1,17 @@ { - "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", "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/public/conf/config.json b/components/device-mgt/io.entgra.device.mgt.ui/react-app/public/conf/config.json index 0d1b5d86f4..43411cf4f8 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 5d8747417f..68f8823e1a 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/apps/release/install/DeviceInstall.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Devices/DevicesTable.js similarity index 68% rename from components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/apps/release/install/DeviceInstall.js rename to components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Devices/DevicesTable.js index 34dfefd362..dc2a247f14 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/Devices/DevicesTable.js @@ -18,26 +18,45 @@ import React from "react"; import axios from "axios"; -import {Button, message, notification, Table, Typography} 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. import en from 'javascript-time-ago/locale/en' -import {withConfigContext} from "../../../../context/ConfigContext"; +import {withConfigContext} from "../../context/ConfigContext"; const {Text} = Typography; + +let config = null; + const columns = [ { title: 'Device', dataIndex: 'name', - fixed: 'left', width: 100, }, { - title: 'Modal', - dataIndex: 'deviceInfo', - key: 'modal', - render: deviceInfo => `${deviceInfo.vendor} ${deviceInfo.deviceModel}` + 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 }, { @@ -48,49 +67,61 @@ const columns = [ // todo add filtering options }, { - title: 'Last Updated', + title: 'Ownership', dataIndex: 'enrolmentInfo', - key: 'dateOfLastUpdate', - render: (data) => { - return (getTimeAgo(data.dateOfLastUpdate)); - } + key: 'ownership', + render: enrolmentInfo => enrolmentInfo.ownership // todo add filtering options }, { title: 'Status', dataIndex: 'enrolmentInfo', key: 'status', - render: enrolmentInfo => enrolmentInfo.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: 'Ownership', + title: 'Last Updated', dataIndex: 'enrolmentInfo', - key: 'ownership', - render: enrolmentInfo => enrolmentInfo.ownership - // todo add filtering options - }, - { - title: 'OS Version', - dataIndex: 'deviceInfo', - key: 'osVersion', - render: deviceInfo => deviceInfo.osVersion + key: 'dateOfLastUpdate', + render: (data) => { + const {dateOfLastUpdate} = data; + const timeAgoString = getTimeAgo(dateOfLastUpdate); + return {timeAgoString}; + } // 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: () => ( + + + + + + ), }, ]; @@ -100,9 +131,10 @@ const getTimeAgo = (time) => { }; -class DeviceInstall extends React.Component { +class DeviceTable extends React.Component { constructor(props) { super(props); + config = this.props.context; TimeAgo.addLocale(en); this.state = { data: [], @@ -118,11 +150,7 @@ class DeviceInstall extends React.Component { this.setState({ selectedRows: selectedRows }) - }, - getCheckboxProps: record => ({ - disabled: record.name === 'Disabled User', // Column configuration not to be checked - name: record.name, - }), + } }; componentDidMount() { @@ -133,19 +161,15 @@ class DeviceInstall extends React.Component { 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 @@ -160,15 +184,13 @@ class DeviceInstall extends React.Component { data: res.data.data.devices, pagination, }); - } }).catch((error) => { - console.log(error); - if (error.hasOwnProperty("status") && error.response.status === 401) { + 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", @@ -197,28 +219,11 @@ class DeviceInstall extends React.Component { }); }; - 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} @@ -234,15 +239,9 @@ class DeviceInstall extends React.Component { rowSelection={this.rowSelection} scroll={{x: 1000}} /> -
- -
); } } -export default withConfigContext(DeviceInstall); \ No newline at end of file +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 deleted file mode 100644 index d18aa40bbf..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 e6e459e3dc..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.store + "/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+ '/store/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 0536e966cf..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.store+"/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+'/store/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 6d55b45361..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.store + "/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+ '/store/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/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 a8af7482c9..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+'/store/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 877fd3a4cb..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+'/store/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 8e592d52cf..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+ '/store/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 ee2b8f65ff..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.store + "/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+ '/store/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 - -