-
-
-
- Home
-
- Report
-
-
-
Summary of enrollments
-
-
- Android
- IOS
- Windows
-
- Generate Report
-
-
+ tempParamObj.status = chartValue;
-
-
+ this.setState({ paramsObject: tempParamObj });
+ console.log(this.state.paramsObject);
+ };
-
-
-
+ render() {
+ const { reportData } = this.props.location;
-
-
-
-
-
-
-
+ const params = { ...this.state.paramsObject };
+ return (
+
+
+
+
+
+ Home
+
+
+ Report
+
+
+
Summary of enrollments
+
+
+ Android
+ IOS
+ Windows
+
+
+ Generate Report
+
- );
- }
+
+
+
+
+
+
+
+
+
+
+ );
+ }
}
export default withConfigContext(DeviceStatusReport);
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Templates/EnrollmentTypeReport.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Templates/EnrollmentTypeReport.js
index 595aa8856e..740127a959 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Templates/EnrollmentTypeReport.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Templates/EnrollmentTypeReport.js
@@ -16,118 +16,88 @@
* under the License.
*/
-import React from "react";
-import {
- PageHeader,
- Typography,
- Breadcrumb,
- Icon,
- Tag,
- Radio, Select, Button, Card,
- Row, Col, message, notification
-} from "antd";
-
-import {Link} from "react-router-dom";
-import PoliciesTable from "../../../components/Policies/PoliciesTable";
-import DevicesTable from "../../../components/Devices/DevicesTable";
-import DateRangePicker from "../../../components/Reports/DateRangePicker";
-import ReportDeviceTable from "../../../components/Devices/ReportDevicesTable";
-import PieChart from "../../../components/Reports/Widgets/PieChart";
-import axios from "axios";
-import CountWidget from "../../../components/Reports/Widgets/CountWidget";
-import {withConfigContext} from "../../../context/ConfigContext";
-const {Paragraph} = Typography;
-const { CheckableTag } = Tag;
-
-const { Option } = Select;
-let config = null;
+import React from 'react';
+import { PageHeader, Breadcrumb, Icon, Card } from 'antd';
+import { Link } from 'react-router-dom';
+import ReportDeviceTable from '../../../components/Devices/ReportDevicesTable';
+import PieChart from '../../../components/Reports/Widgets/PieChart';
+import { withConfigContext } from '../../../context/ConfigContext';
class EnrollmentTypeReport extends React.Component {
- routes;
+ routes;
- constructor(props) {
- super(props);
- this.routes = props.routes;
- config = this.props.context;
- const { reportData } = this.props.location;
- this.state = {
- paramsObject:{
- from:reportData.duration[0],
- to:reportData.duration[1]
- }
- };
-
-
- console.log(reportData.duration);
- }
-
- setParam = (tempParamObj, type, value) => {
- if(type==="status"){
- tempParamObj.status = value;
- if(tempParamObj.status) {
- delete tempParamObj.status;
- }
- } else if(type=="ownership"){
- tempParamObj.ownership = value;
- if(value=="ALL" && tempParamObj.ownership) {
- delete tempParamObj.ownership;
- }
- }
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ const { reportData } = this.props.location;
+ this.state = {
+ paramsObject: {
+ from: reportData.duration[0],
+ to: reportData.duration[1],
+ },
};
- onClickPieChart = (value) => {
- const chartValue = value.data.point.item;
- let tempParamObj = this.state.paramsObject;
+ console.log(reportData.duration);
+ }
- console.log(chartValue)
+ onClickPieChart = value => {
+ const chartValue = value.data.point.item;
+ let tempParamObj = this.state.paramsObject;
- tempParamObj.ownership = chartValue;
-
- this.setState({paramsObject:tempParamObj});
- };
+ console.log(chartValue);
- render() {
- const { reportData } = this.props.location;
+ tempParamObj.ownership = chartValue;
- const params = {...this.state.paramsObject};
- return (
-
-
-
-
- Home
-
- Report
-
-
-
Summary of enrollments
+ this.setState({ paramsObject: tempParamObj });
+ };
-
+ render() {
+ const { reportData } = this.props.location;
-
-
+ const params = { ...this.state.paramsObject };
+ return (
+
+
+
+
+
+ Home
+
+
+ Report
+
+
+
Summary of enrollments
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
- }
+
+
+
+
+
+
+ );
+ }
}
export default withConfigContext(EnrollmentTypeReport);
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Templates/EnrollmentsVsUnenrollmentsReport.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Templates/EnrollmentsVsUnenrollmentsReport.js
index b6ab7c2935..e1ff8c337e 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Templates/EnrollmentsVsUnenrollmentsReport.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Templates/EnrollmentsVsUnenrollmentsReport.js
@@ -16,157 +16,111 @@
* under the License.
*/
-import React from "react";
-import {
- PageHeader,
- Typography,
- Breadcrumb,
- Icon,
- Tag,
- Radio, Select, Button, Card,
- Row, Col, message, notification
-} from "antd";
-
-import {Link, Redirect} from "react-router-dom";
-import PoliciesTable from "../../../components/Policies/PoliciesTable";
-import DevicesTable from "../../../components/Devices/DevicesTable";
-import DateRangePicker from "../../../components/Reports/DateRangePicker";
-import ReportDeviceTable from "../../../components/Devices/ReportDevicesTable";
-import PieChart from "../../../components/Reports/Widgets/PieChart";
-import axios from "axios";
-import CountWidget from "../../../components/Reports/Widgets/CountWidget";
-import {withConfigContext} from "../../../context/ConfigContext";
-const {Paragraph} = Typography;
-const { CheckableTag } = Tag;
-
-const { Option } = Select;
-let config = null;
+import React from 'react';
+import { PageHeader, Breadcrumb, Icon, Card } from 'antd';
+import { Link, Redirect } from 'react-router-dom';
+import ReportDeviceTable from '../../../components/Devices/ReportDevicesTable';
+import PieChart from '../../../components/Reports/Widgets/PieChart';
+import { withConfigContext } from '../../../context/ConfigContext';
class EnrollmentsVsUnenrollmentsReport extends React.Component {
- routes;
+ routes;
- constructor(props) {
- super(props);
- this.routes = props.routes;
- config = this.props.context;
- const { reportData } = this.props.location;
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ const { reportData } = this.props.location;
- this.state = {
- paramsObject:{
- from:reportData? reportData.duration[0]: "2019-01-01",
- to:reportData? reportData.duration[1]: "2019-01-01"
- },
- redirect: false
- };
+ this.state = {
+ paramsObject: {
+ from: reportData ? reportData.duration[0] : '2019-01-01',
+ to: reportData ? reportData.duration[1] : '2019-01-01',
+ },
+ redirect: false,
+ };
- this.redirectToHome();
- console.log(this.state.paramsObject);
+ this.redirectToHome();
+ console.log(this.state.paramsObject);
+ }
+
+ redirectToHome = () => {
+ return
;
+ };
+
+ onClickPieChart = value => {
+ const chartValue = value.data.point.item;
+ let tempParamObj = this.state.paramsObject;
+
+ console.log(chartValue);
+
+ if (chartValue === 'Enrollments') {
+ tempParamObj.status = 'ACTIVE&status=INACTIVE';
+ } else {
+ tempParamObj.status = 'REMOVED';
}
- setParam = (tempParamObj, type, value) => {
- if(type==="status"){
- tempParamObj.status = value;
- if(tempParamObj.status) {
- delete tempParamObj.status;
- }
- } else if(type=="ownership"){
- tempParamObj.ownership = value;
- if(value=="ALL" && tempParamObj.ownership) {
- delete tempParamObj.ownership;
- }
- }
+ this.setState({ paramsObject: tempParamObj });
+ };
+
+ render() {
+ const { reportData } = this.props.location;
+
+ console.log('======');
+ console.log(reportData);
+ console.log('======');
+
+ let reportDataClone = {
+ params: ['ACTIVE'],
+ duration: ['2020-01-01', '2020-01-01'],
};
- redirectToHome = () => {
- return
- };
+ const params = { ...this.state.paramsObject };
+ return (
+
+
+ {!reportData ? (
+
+ ) : (
+
+
+
+
+ Home
+
+
+ Report
+
+
+
Summary of enrollments
+
- setRedirect = (reportData) => {
- if(!reportData){
- this.setState({
- redirect: true
- })
- }
- };
+
- renderRedirect = () => {
- if (this.state.redirect) {
- return
- }
- }
-
- onClickPieChart = (value) => {
- const chartValue = value.data.point.item;
- let tempParamObj = this.state.paramsObject;
-
- console.log(chartValue)
-
- // tempParamObj.status = chartValue;
-
- if(chartValue==="Enrollments"){
- tempParamObj.status = "ACTIVE&status=INACTIVE"
- }else{
- tempParamObj.status = "REMOVED"
- }
-
-
- this.setState({paramsObject:tempParamObj});
- };
-
- render() {
- const { reportData } = this.props.location;
-
- console.log("======")
- console.log(reportData)
- console.log("======")
-
- let reportDataClone = {
- params: ["ACTIVE"],
- duration: ["2020-01-01","2020-01-01"]
- };
-
- const params = {...this.state.paramsObject};
- return (
-
-
-
{!reportData ? (
-
- ) : (
-
-
-
- Home
-
- Report
-
-
-
Summary of enrollments
-
-
-
-
-
-
-
-
-
-
- )}
-
- );
- }
+
+
+
+
+ )}
+
+
+ );
+ }
}
export default withConfigContext(EnrollmentsVsUnenrollmentsReport);
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Widgets/CountWidget.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Widgets/CountWidget.js
index f1854f8737..d27a74f995 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Widgets/CountWidget.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Widgets/CountWidget.js
@@ -1,63 +1,47 @@
-import React from "react";
+import React from 'react';
-import {Card, Col, Icon} from "antd";
-import {Link} from "react-router-dom";
+import { Card, Col } from 'antd';
class CountWidget extends React.Component {
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ this.state = {
+ statArray: [],
+ };
+ }
- constructor(props) {
- super(props);
- this.routes = props.routes;
- this.state = {
- statArray:[]
- }
- }
+ componentDidMount() {
+ this.setState({ statArray: this.props.statArray });
+ console.log('$$$$');
+ console.log(this.props.statArray);
+ }
- componentDidMount() {
- this.setState({statArray:this.props.statArray})
- console.log("$$$$")
- console.log(this.props.statArray)
- }
+ render() {
+ const { statArray } = this.state;
+ let card = statArray.map(data => (
+
+
+
+
+ {data.item}
+
+
{data.count}
+ {/*
{data.duration}
*/}
+ {/*
*/}
+
+
+
+ ));
- render() {
- const countObj = [
- {item:"All",count:100},
- {item:"Enrolled",count:80},
- {item:"Unenrolled",count:20}];
-
- const { statArray } = this.state;
-
- let card = statArray.map((data) =>
- //
- //
- // {data.item} Devices: {data.count}
- //
- //
-
-
-
-
-
{data.item}
-
{data.count}
- {/*
{data.duration}
*/}
- {/*
*/}
-
-
-
- )
-
- return(
-
- {card}
-
-
- )
- }
+ return
{card}
;
+ }
}
-export default CountWidget;
\ No newline at end of file
+export default CountWidget;
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Widgets/PieChart.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Widgets/PieChart.js
index f66eac10b7..263af782c6 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Widgets/PieChart.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Reports/Widgets/PieChart.js
@@ -1,322 +1,342 @@
-import React from "react";
+import React from 'react';
import {
- G2,
- Chart,
- Geom,
- Axis,
- Tooltip,
- Coord,
- Label,
- Legend,
- View,
- Guide,
- Shape,
- Facet,
- Util
-} from "bizcharts";
-import DataSet from "@antv/data-set";
-import axios from "axios";
-import {message, notification} from "antd";
-import {withConfigContext} from "../../../context/ConfigContext";
+ Chart,
+ Geom,
+ Axis,
+ Tooltip,
+ Coord,
+ Label,
+ Legend,
+ Guide,
+} from 'bizcharts';
+import DataSet from '@antv/data-set';
+import axios from 'axios';
+import { message, notification } from 'antd';
+import { withConfigContext } from '../../../context/ConfigContext';
let config = null;
class PieChart extends React.Component {
+ constructor(props) {
+ super(props);
+ config = this.props.context;
+ this.state = {
+ loading: true,
+ statArray: [],
+ };
+ }
- constructor(props) {
- super(props);
- config = this.props.context;
- this.state = {
- loading:true,
- statArray:[]
- };
+ componentDidMount() {
+ const { reportData } = this.props;
+ let params = {
+ status: reportData.params[0],
+ from: reportData.duration[0],
+ to: reportData.duration[1],
+ };
+ const urlSet = {
+ paramsList: reportData.params,
+ duration: reportData.duration,
+ };
+
+ console.log(urlSet);
+
+ if (reportData.params[0] === 'Enrollments') {
+ this.getEnrollmentsVsUnenrollmentsCount(params, urlSet);
+ } else if (reportData.params[0] === 'BYOD') {
+ this.getEnrollmentTypeCount(params, urlSet);
+ } else {
+ this.getCount(params, urlSet);
}
+ }
- componentDidMount() {
- let { statArray } = this.state;
- const { reportData } = this.props;
- let params = {
- status: reportData.params[0],
- from: reportData.duration[0],
- to: reportData.duration[1]
- };
+ clicked = () => {
+ console.log('Clicked...!!');
+ };
- const urlSet = {
- paramsList:reportData.params,
- duration:reportData.duration
- };
+ onChartChange = data => {
+ this.props.onClickPieChart(data);
+ };
- console.log(urlSet)
+ statArray = [];
- if(reportData.params[0]==="Enrollments"){
- this.getEnrollmentsVsUnenrollmentsCount(params, urlSet)
- }else if(reportData.params[0]==="BYOD"){
- this.getEnrollmentTypeCount(params, urlSet);
- }else{
- this.getCount(params, urlSet);
+ // Call count APIs and get count for given parameters, then create data object to build pie chart
+ getCount = (params, urlSet) => {
+ this.setState({ loading: true });
+
+ let { statArray } = this.state;
+
+ console.log(urlSet);
+
+ const urlArray = [];
+
+ urlSet.paramsList.map(data => {
+ const paramsObj = {
+ status: data,
+ from: urlSet.duration[0],
+ to: urlSet.duration[1],
+ };
+ // console.log(paramsObj)
+ const encodedExtraParams = Object.keys(paramsObj)
+ .map(key => key + '=' + paramsObj[key])
+ .join('&');
+ const apiUrl =
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.deviceMgt +
+ '/reports/devices/count?' +
+ encodedExtraParams;
+
+ urlArray.push(axios.get(apiUrl, data));
+ });
+
+ console.log(urlArray);
+
+ axios
+ .all(urlArray)
+ .then(res => {
+ res.map(response => {
+ if (response.status === 200) {
+ let countData = {
+ item: response.config[0],
+ // eslint-disable-next-line radix
+ count: parseInt(response.data.data),
+ };
+ statArray.push(countData);
+ }
+ });
+ this.setState({ statArray });
+ })
+ .catch(error => {
+ if (error.hasOwnProperty('response') && error.response.status === 401) {
+ // todo display a popup with error
+ message.error('You are not logged in');
+ window.location.href = window.location.origin + '/entgra/login';
+ } else {
+ notification.error({
+ message: 'There was a problem',
+ duration: 0,
+ description: 'Error occurred while trying to get device count.',
+ });
}
- }
+ });
+ };
- clicked = () => {
- console.log("Clicked...!!")
+ // Call count APIs and get count for given parameters, then create data object to build pie chart
+ getEnrollmentsVsUnenrollmentsCount = (params, urlSet) => {
+ this.setState({ loading: true });
+
+ let { statArray } = this.state;
+
+ console.log(urlSet);
+
+ const urlArray = [];
+
+ urlSet.paramsList.map(data => {
+ const paramsObj = {
+ from: urlSet.duration[0],
+ to: urlSet.duration[1],
+ };
+ const encodedExtraParams = Object.keys(paramsObj)
+ .map(key => key + '=' + paramsObj[key])
+ .join('&');
+
+ let apiUrl;
+ if (data === 'Enrollments') {
+ apiUrl =
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.deviceMgt +
+ '/reports/devices/count?status=ACTIVE&status=INACTIVE&' +
+ encodedExtraParams;
+ } else {
+ apiUrl =
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.deviceMgt +
+ '/reports/devices/count?status=REMOVED&' +
+ encodedExtraParams;
+ }
+
+ urlArray.push(axios.get(apiUrl, data));
+ });
+
+ console.log(urlArray);
+
+ axios
+ .all(urlArray)
+ .then(res => {
+ res.map(response => {
+ if (response.status === 200) {
+ let countData = {
+ item: response.config[0],
+ // eslint-disable-next-line radix
+ count: parseInt(response.data.data),
+ };
+ statArray.push(countData);
+ }
+ });
+ this.setState({ statArray });
+ })
+ .catch(error => {
+ if (error.hasOwnProperty('response') && error.response.status === 401) {
+ // todo display a popup with error
+ message.error('You are not logged in');
+ window.location.href = window.location.origin + '/entgra/login';
+ } else {
+ notification.error({
+ message: 'There was a problem',
+ duration: 0,
+ description: 'Error occurred while trying to get device count.',
+ });
+ }
+ });
+ };
+
+ // Call count APIs and get count for given parameters, then create data object to build pie chart
+ getEnrollmentTypeCount = (params, urlSet) => {
+ this.setState({ loading: true });
+
+ let { statArray } = this.state;
+
+ console.log(urlSet);
+
+ const urlArray = [];
+
+ urlSet.paramsList.map(data => {
+ const paramsObj = {
+ ownership: data,
+ from: urlSet.duration[0],
+ to: urlSet.duration[1],
+ };
+ const encodedExtraParams = Object.keys(paramsObj)
+ .map(key => key + '=' + paramsObj[key])
+ .join('&');
+ const apiUrl =
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.deviceMgt +
+ '/reports/devices/count?' +
+ encodedExtraParams;
+
+ urlArray.push(axios.get(apiUrl, data));
+ });
+
+ console.log(urlArray);
+
+ axios
+ .all(urlArray)
+ .then(res => {
+ res.map(response => {
+ if (response.status === 200) {
+ let countData = {
+ item: response.config[0],
+ // eslint-disable-next-line radix
+ count: parseInt(response.data.data),
+ };
+ statArray.push(countData);
+ }
+ });
+ this.setState({ statArray });
+ })
+ .catch(error => {
+ if (error.hasOwnProperty('response') && error.response.status === 401) {
+ // todo display a popup with error
+ message.error('You are not logged in');
+ window.location.href = window.location.origin + '/entgra/login';
+ } else {
+ notification.error({
+ message: 'There was a problem',
+ duration: 0,
+ description: 'Error occurred while trying to get device count.',
+ });
+ }
+ });
+ };
+
+ render() {
+ const { DataView } = DataSet;
+ const { Html } = Guide;
+ const { statArray } = this.state;
+
+ const dv = new DataView();
+ dv.source(statArray).transform({
+ type: 'percent',
+ field: 'count',
+ dimension: 'item',
+ as: 'percent',
+ });
+ const cols = {
+ percent: {
+ formatter: val => {
+ val = val * 100 + '%';
+ return val;
+ },
+ },
};
- onChartChange = (data) => {
- this.props.onClickPieChart(data);
- };
-
- statArray = [];
-
- //Call count APIs and get count for given parameters, then create data object to build pie chart
- getCount = (params, urlSet) => {
-
- this.setState({loading: true});
-
- let { statArray } = this.state;
-
- console.log(urlSet);
-
- const urlArray = [];
-
- urlSet.paramsList.map((data) => {
- const paramsObj = {
- status:data,
- from:urlSet.duration[0],
- to:urlSet.duration[1]
- }
- // console.log(paramsObj)
- const encodedExtraParams = Object.keys(paramsObj)
- .map(key => key + '=' + paramsObj[key]).join('&');
- const apiUrl = window.location.origin + config.serverConfig.invoker.uri +
- config.serverConfig.invoker.deviceMgt +
- "/reports/devices/count?" + encodedExtraParams;
-
- urlArray.push(axios.get(apiUrl, data));
- });
-
- console.log(urlArray)
-
-
- axios.all(urlArray).then(res => {
-
- res.map((response) => {
- if(response.status === 200){
- let countData = {item:response.config[0], count:parseInt(response.data.data)}
- statArray.push(countData);
- }
- })
- this.setState({statArray})
- }).catch((error) => {
- if (error.hasOwnProperty("response") && error.response.status === 401) {
- //todo display a popup with error
- message.error('You are not logged in');
- window.location.href = window.location.origin + '/entgra/login';
- } else {
- notification["error"]({
- message: "There was a problem",
- duration: 0,
- description:"Error occurred while trying to get device count.",
- });
- }
- });
- };
-
- //Call count APIs and get count for given parameters, then create data object to build pie chart
- getEnrollmentsVsUnenrollmentsCount = (params, urlSet) => {
-
- this.setState({loading: true});
-
- let { statArray } = this.state;
-
- console.log(urlSet);
-
- const urlArray = [];
-
- urlSet.paramsList.map((data) => {
- const paramsObj = {
- from:urlSet.duration[0],
- to:urlSet.duration[1]
- }
- const encodedExtraParams = Object.keys(paramsObj)
- .map(key => key + '=' + paramsObj[key]).join('&');
-
- let apiUrl;
- if(data==="Enrollments"){
- apiUrl = window.location.origin + config.serverConfig.invoker.uri +
- config.serverConfig.invoker.deviceMgt +
- "/reports/devices/count?status=ACTIVE&status=INACTIVE&" + encodedExtraParams;
- }else{
- apiUrl = window.location.origin + config.serverConfig.invoker.uri +
- config.serverConfig.invoker.deviceMgt +
- "/reports/devices/count?status=REMOVED&" + encodedExtraParams;
- }
-
- urlArray.push(axios.get(apiUrl, data));
- });
-
- console.log(urlArray)
-
-
- axios.all(urlArray).then(res => {
- res.map((response) => {
- if(response.status === 200){
- let countData = {item:response.config[0], count:parseInt(response.data.data)}
- statArray.push(countData);
- }
- })
- this.setState({statArray})
- }).catch((error) => {
- if (error.hasOwnProperty("response") && error.response.status === 401) {
- //todo display a popup with error
- message.error('You are not logged in');
- window.location.href = window.location.origin + '/entgra/login';
- } else {
- notification["error"]({
- message: "There was a problem",
- duration: 0,
- description:"Error occurred while trying to get device count.",
- });
- }
- });
- };
-
- //Call count APIs and get count for given parameters, then create data object to build pie chart
- getEnrollmentTypeCount = (params, urlSet) => {
-
- this.setState({loading: true});
-
- let { statArray } = this.state;
-
- console.log(urlSet);
-
- const urlArray = [];
-
- urlSet.paramsList.map((data) => {
- const paramsObj = {
- ownership:data,
- from:urlSet.duration[0],
- to:urlSet.duration[1]
- }
- const encodedExtraParams = Object.keys(paramsObj)
- .map(key => key + '=' + paramsObj[key]).join('&');
- const apiUrl = window.location.origin + config.serverConfig.invoker.uri +
- config.serverConfig.invoker.deviceMgt +
- "/reports/devices/count?" + encodedExtraParams;
-
- urlArray.push(axios.get(apiUrl, data));
- });
-
- console.log(urlArray)
-
-
- axios.all(urlArray).then(res => {
- res.map((response) => {
- if(response.status === 200){
- let countData = {item:response.config[0], count:parseInt(response.data.data)}
- statArray.push(countData);
- }
- })
- this.setState({statArray})
- }).catch((error) => {
- if (error.hasOwnProperty("response") && error.response.status === 401) {
- //todo display a popup with error
- message.error('You are not logged in');
- window.location.href = window.location.origin + '/entgra/login';
- } else {
- notification["error"]({
- message: "There was a problem",
- duration: 0,
- description:"Error occurred while trying to get device count.",
- });
- }
- });
- };
-
- render() {
- const { DataView } = DataSet;
- const { Html } = Guide;
- const { statArray , loading} = this.state;
-
- const dv = new DataView();
- dv.source(statArray).transform({
- type: "percent",
- field: "count",
- dimension: "item",
- as: "percent"
- });
- const cols = {
- percent: {
- formatter: val => {
- val = val * 100 + "%";
- return val;
- }
- }
- };
-
- return (
-
-
-
-
-
-
-
-
-
-
- {
- percent = percent * 100 + "%";
- return {
- name: item,
- value: percent
- };
- }
- ]}
- style={{
- lineWidth: 1,
- stroke: "#fff"
- }}
- >
- {
- return item.point.item + ": " + val;
- }}/>
-
-
-
-
-
- );
- }
+ return (
+
+
+
+
+
+
+
+
+
+
+ {
+ percent = percent * 100 + '%';
+ return {
+ name: item,
+ value: percent,
+ };
+ },
+ ]}
+ style={{
+ lineWidth: 1,
+ stroke: '#fff',
+ }}
+ >
+ {
+ return item.point.item + ': ' + val;
+ }}
+ />
+
+
+
+
+ );
+ }
}
-export default withConfigContext(PieChart);
\ No newline at end of file
+export default withConfigContext(PieChart);
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Roles/AddRole.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Roles/AddRole.js
index c23ad420e7..f04f3b533e 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Roles/AddRole.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Roles/AddRole.js
@@ -1,340 +1,392 @@
import React from 'react';
-import {Button, Form, Input, message, Modal, notification, Select, Tree} from "antd";
-import {withConfigContext} from "../../context/ConfigContext";
-import axios from "axios";
+import {
+ Button,
+ Form,
+ Input,
+ message,
+ Modal,
+ notification,
+ Select,
+ Tree,
+} from 'antd';
+import { withConfigContext } from '../../context/ConfigContext';
+import axios from 'axios';
-const {Option} = Select;
-const {TreeNode} = Tree;
+const { Option } = Select;
+const { TreeNode } = Tree;
class AddRole extends React.Component {
+ constructor(props) {
+ super(props);
+ this.config = this.props.context;
+ this.expandKeys = [];
+ this.state = {
+ isAddRoleModalVisible: false,
+ isAddPermissionModalVisible: false,
+ roleName: '',
+ users: [],
+ nodeList: [],
+ expandedKeys: [],
+ autoExpandParent: true,
+ checkedKeys: [],
+ isNodeList: false,
+ };
+ }
- constructor(props) {
- super(props);
- this.config = this.props.context;
- this.expandKeys = [];
- this.state = {
+ openAddModal = () => {
+ this.setState({
+ isAddRoleModalVisible: true,
+ });
+ };
+
+ onCancelHandler = e => {
+ this.setState({
+ isAddRoleModalVisible: false,
+ isAddPermissionModalVisible: false,
+ });
+ };
+
+ getCheckedPermissionsList = data => {
+ data.forEach(item => {
+ if (item !== null) {
+ this.expandKeys.push(item.resourcePath);
+ this.getCheckedPermissionsList(item.nodeList);
+ } else {
+ return null;
+ }
+ });
+ };
+
+ onAddRole = e => {
+ this.props.form.validateFields((err, values) => {
+ if (!err) {
+ this.onConfirmAddRole(values);
+ }
+ console.log(values);
+ });
+ };
+
+ onExpand = expandedKeys => {
+ this.setState({
+ expandedKeys,
+ autoExpandParent: false,
+ });
+ };
+
+ onCheck = checkedKeys => {
+ this.setState({ checkedKeys });
+ };
+
+ onConfirmAddRole = value => {
+ const roleData = {
+ roleName: value.roleName,
+ users: value.users,
+ };
+ this.setState({
+ roleName: value.roleName,
+ });
+ axios
+ .post(
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/roles',
+ roleData,
+ { headers: { 'Content-Type': 'application-json' } },
+ )
+ .then(res => {
+ if (res.status === 201) {
+ this.props.fetchUsers();
+ this.setState({
isAddRoleModalVisible: false,
- isAddPermissionModalVisible: false,
- roleName: '',
- users: [],
- nodeList: [],
- expandedKeys: [],
- autoExpandParent: true,
- checkedKeys: [],
- isNodeList: false,
+ isAddPermissionModalVisible: true,
+ });
+ notification.success({
+ message: 'Done',
+ duration: 4,
+ description: 'Successfully added the role.',
+ });
+ this.loadPermissionList();
}
- }
+ })
+ .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 add role.',
+ });
+ }
+ });
+ };
- openAddModal = () => {
- this.setState({
- isAddRoleModalVisible: true
- });
+ renderTreeNodes = data => {
+ return data.map(item => {
+ if (item !== null) {
+ if (item.hasOwnProperty('nodeList')) {
+ return (
+
+ {this.renderTreeNodes(item.nodeList)}
+
+ );
+ }
+ return
;
+ }
+
+ // eslint-disable-next-line react/jsx-key
+ return
;
+ });
+ };
+
+ onAssignPermissions = () => {
+ const roleData = {
+ roleName: this.state.roleName,
+ permissions: this.state.checkedKeys,
};
-
- onCancelHandler = e => {
- this.setState({
- isAddRoleModalVisible: false,
+ axios
+ .put(
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/roles/' +
+ this.state.roleName,
+ roleData,
+ { headers: { 'Content-Type': 'application-json' } },
+ )
+ .then(res => {
+ if (res.status === 200) {
+ this.props.fetchUsers();
+ notification.success({
+ message: 'Done',
+ duration: 4,
+ description: 'Successfully Updated the Permissions.',
+ });
+ this.setState({
isAddPermissionModalVisible: false,
- });
- };
+ });
+ }
+ })
+ .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 add permissions.',
+ });
+ }
+ });
+ };
- getCheckedPermissionsList = (data) =>{
- data.forEach(item => {
- if (item !== null) {
- this.expandKeys.push(item.resourcePath);
- this.getCheckedPermissionsList(item.nodeList);
- }else{
- return null;
- }
- });
- };
+ loadPermissionList = () => {
+ let apiURL =
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/roles/' +
+ this.state.roleName +
+ '/permissions';
- onAddRole = e => {
- this.props.form.validateFields((err, values) => {
- if (!err) {
- this.onConfirmAddRole(values);
- }
- console.log(values);
- });
- };
+ axios
+ .get(apiURL)
+ .then(res => {
+ if (res.status === 200) {
+ this.getCheckedPermissionsList(res.data.data.nodeList);
+ this.setState({
+ nodeList: res.data.data.nodeList,
+ isNodeList: true,
+ expandedKeys: this.expandKeys,
+ });
+ }
+ })
+ .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 permission.',
+ });
+ }
+ });
+ };
- onExpand = expandedKeys => {
- this.setState({
- expandedKeys,
- autoExpandParent: false,
- });
- };
+ loadUsersList = value => {
+ let apiURL =
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/users/search/usernames?filter=' +
+ value +
+ '&domain=Primary';
+ axios
+ .get(apiURL)
+ .then(res => {
+ if (res.status === 200) {
+ let user = JSON.parse(res.data.data);
+ let users = [];
+ for (let i = 0; i < user.length; i++) {
+ users.push(
+
{user[i].username} ,
+ );
+ }
+ this.setState({
+ users: users,
+ });
+ }
+ })
+ .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 users.',
+ });
+ }
+ });
+ };
- onCheck = checkedKeys => {
- this.setState({checkedKeys});
- };
-
- onConfirmAddRole = (value) => {
- const roleData = {
- roleName: value.roleName,
- users: value.users,
- };
- this.setState({
- roleName: value.roleName,
- });
- axios.post(
- window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt +
- "/roles",
- roleData,
- {headers: {'Content-Type': 'application-json'}}
- ).then(res => {
- if (res.status === 201) {
- this.props.fetchUsers();
- this.setState({
- isAddRoleModalVisible: false,
- isAddPermissionModalVisible: true,
-
- });
- notification["success"]({
- message: "Done",
- duration: 4,
- description:
- "Successfully added the role.",
- });
- this.loadPermissionList();
- }
- }).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 add role.",
- });
- }
- });
- };
-
- renderTreeNodes = (data) => {
- return data.map(item => {
- if (item !== null) {
- if (item.hasOwnProperty("nodeList")) {
- return (
-
- {this.renderTreeNodes(item.nodeList)}
-
- );
- }
- return
;
- }
- else{
- return
;
- }
- });
- };
-
- onAssignPermissions = () =>{
- const roleData = {
- roleName : this.state.roleName,
- permissions : this.state.checkedKeys
- };
- axios.put(
- window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt +
- "/roles/"+ this.state.roleName,
- roleData,
- {headers: {'Content-Type' : 'application-json'}}
- ).then(res => {
- if (res.status === 200) {
- this.props.fetchUsers();
- notification["success"]({
- message: "Done",
- duration: 4,
- description:
- "Successfully Updated the Permissions.",
- });
- this.setState({
- isAddPermissionModalVisible : false
- });
- }
- }).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 add permissions.",
- });
- }
- });
- };
-
- loadPermissionList = () => {
- let apiURL = window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt + "/roles/" + this.state.roleName + "/permissions";
-
- axios.get(apiURL).then(res => {
- if (res.status === 200) {
- this.getCheckedPermissionsList(res.data.data.nodeList);
- this.setState({
- nodeList: res.data.data.nodeList,
- isNodeList: true,
- expandedKeys : this.expandKeys
- });
-
- }
- }).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 permission.",
- });
- }
- })
- };
-
- loadUsersList = (value) => {
- let apiURL = window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt + "/users/search/usernames?filter=" + value + "&domain=Primary";
- axios.get(apiURL).then(res => {
- if (res.status === 200) {
- let user = JSON.parse(res.data.data);
- let users = [];
- for (let i = 0; i < user.length; i++) {
- users.push(
{user[i].username} );
- }
- this.setState({
- users: users
- });
-
- }
- }).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 users.",
- });
- }
- })
- };
-
- render() {
- const {getFieldDecorator} = this.props.form;
- return (
-
-
-
- Add Role
-
-
-
-
- Cancel
- ,
-
- Add Role
- ,
- ]}>
-
-
Create new user on IoT Server.
-
- {getFieldDecorator('userStoreDomain', {
- initialValue: 'PRIMARY'
- })(
-
- PRIMARY
-
- )}
-
-
- {getFieldDecorator('roleName', {
- rules: [
- {
- pattern: new RegExp("^(((?!(\\@|\\/|\\s)).){3,})*$"),
- message: 'Role name should be in minimum 3 characters long and not ' +
- 'include any whitespaces or @ or /',
- },
- {
- required: true,
- message: 'This field is required.',
- },
-
- ],
- })( )}
-
-
- {getFieldDecorator('users', {})(
- {this.state.users}
- )}
-
-
-
-
-
-
-
- Cancel
- ,
-
- Assign
- ,
- ]}>
-
-
- {(this.state.isNodeList) && (
-
- {this.renderTreeNodes(this.state.nodeList)}
-
- )}
-
-
-
-
+ render() {
+ const { getFieldDecorator } = this.props.form;
+ return (
+
+
+
+ Add Role
+
+
+
+
+ Cancel
+ ,
+
+ Add Role
+ ,
+ ]}
+ >
+
+
Create new user on IoT Server.
+
+ {getFieldDecorator('userStoreDomain', {
+ initialValue: 'PRIMARY',
+ })(
+
+ PRIMARY
+ ,
+ )}
+
+
+ {getFieldDecorator('roleName', {
+ rules: [
+ {
+ pattern: new RegExp('^(((?!(\\@|\\/|\\s)).){3,})*$'),
+ message:
+ 'Role name should be in minimum 3 characters long and not ' +
+ 'include any whitespaces or @ or /',
+ },
+ {
+ required: true,
+ message: 'This field is required.',
+ },
+ ],
+ })( )}
+
+
+ {getFieldDecorator('users', {})(
+
+ {this.state.users}
+ ,
+ )}
+
+
- );
- }
+
+
+
+
+ Cancel
+ ,
+
+ Assign
+ ,
+ ]}
+ >
+
+
+ {this.state.isNodeList && (
+
+ {this.renderTreeNodes(this.state.nodeList)}
+
+ )}
+
+
+
+
+
+ );
+ }
}
-export default withConfigContext(Form.create({name: 'add-role'})(AddRole))
\ No newline at end of file
+export default withConfigContext(Form.create({ name: 'add-role' })(AddRole));
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Roles/RoleAction.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Roles/RoleAction.js
index e2fd901f05..a9f5a62818 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Roles/RoleAction.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Roles/RoleAction.js
@@ -1,428 +1,489 @@
import React from 'react';
import {
- Button,
- Divider,
- Form,
- Icon,
- Input,
- message,
- Modal,
- notification,
- Popconfirm,
- Select,
- Tooltip, Tree,
- Typography
-} from "antd";
-import axios from "axios";
-import {withConfigContext} from "../../context/ConfigContext";
+ Button,
+ Divider,
+ Form,
+ Icon,
+ Input,
+ message,
+ Modal,
+ notification,
+ Popconfirm,
+ Select,
+ Tooltip,
+ Tree,
+ Typography,
+} from 'antd';
+import axios from 'axios';
+import { withConfigContext } from '../../context/ConfigContext';
const { Option } = Select;
-const {Text} = Typography;
+const { Text } = Typography;
const { TreeNode } = Tree;
class RoleAction extends React.Component {
- constructor(props) {
- super(props);
- this.config = this.props.context;
- this.selected = [];
- this.expandKeys = [];
- this.state = {
- roleData: [],
- nodeList : [],
- isNodeList: false,
- users : [],
+ constructor(props) {
+ super(props);
+ this.config = this.props.context;
+ this.selected = [];
+ this.expandKeys = [];
+ this.state = {
+ roleData: [],
+ nodeList: [],
+ isNodeList: false,
+ users: [],
+ isEditRoleModalVisible: false,
+ isEditPermissionModalVisible: false,
+ expandedKeys: [],
+ autoExpandParent: true,
+ checkedKeys: [],
+ };
+ }
+
+ openEditRoleModal = () => {
+ let apiUrl =
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/roles/' +
+ this.props.data;
+
+ axios
+ .get(apiUrl)
+ .then(res => {
+ if (res.status === 200) {
+ this.setState({
+ roleData: res.data.data,
+ isEditRoleModalVisible: true,
+ });
+ }
+ })
+ .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 role.',
+ });
+ }
+ });
+ };
+
+ openEditPermissionModal = () => {
+ this.loadPermissionList();
+ this.setState({
+ isEditPermissionModalVisible: true,
+ });
+ };
+
+ loadPermissionList = () => {
+ let apiURL =
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/roles/' +
+ this.props.data +
+ '/permissions';
+
+ axios
+ .get(apiURL)
+ .then(res => {
+ if (res.status === 200) {
+ this.getCheckedPermissions(res.data.data.nodeList);
+ this.setState({
+ nodeList: res.data.data.nodeList,
+ isNodeList: true,
+ checkedKeys: this.selected,
+ expandedKeys: this.expandKeys,
+ });
+ }
+ })
+ .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 permission.',
+ });
+ }
+ });
+ };
+
+ getCheckedPermissions = data => {
+ data.forEach(item => {
+ if (item !== null) {
+ this.expandKeys.push(item.resourcePath);
+ if (item.isSelected) {
+ this.selected.push(item.resourcePath);
+ }
+ this.getCheckedPermissions(item.nodeList);
+ } else {
+ return null;
+ }
+ });
+ };
+
+ onExpand = expandedKeys => {
+ this.setState({
+ expandedKeys,
+ autoExpandParent: false,
+ });
+ };
+
+ onCheck = checkedKeys => {
+ this.setState({ checkedKeys });
+ };
+
+ renderTreeNodes = data => {
+ return data.map(item => {
+ if (item !== null) {
+ if (item.hasOwnProperty('nodeList')) {
+ return (
+
+ {this.renderTreeNodes(item.nodeList)}
+
+ );
+ }
+ return
;
+ }
+ // eslint-disable-next-line react/jsx-key
+ return
;
+ });
+ };
+
+ onUpdateRole = e => {
+ this.props.form.validateFields((err, values) => {
+ if (!err) {
+ this.onConfirmUpdateRole(values);
+ }
+ console.log(values);
+ });
+ };
+
+ onCancelHandler = e => {
+ this.setState({
+ isEditRoleModalVisible: false,
+ isEditPermissionModalVisible: false,
+ });
+ };
+
+ onConfirmUpdateRole = value => {
+ const roleData = {
+ roleName: value.roleName,
+ users: value.users,
+ };
+ axios
+ .put(
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/roles/' +
+ this.props.data,
+ roleData,
+ { headers: { 'Content-Type': 'application-json' } },
+ )
+ .then(res => {
+ if (res.status === 200) {
+ this.props.fetchUsers();
+ this.setState({
isEditRoleModalVisible: false,
+ });
+ notification.success({
+ message: 'Done',
+ duration: 4,
+ description: 'Successfully Updated the role.',
+ });
+ }
+ })
+ .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 add role.',
+ });
+ }
+ });
+ };
+
+ onAssignPermission = () => {
+ const roleData = {
+ roleName: this.props.data,
+ permissions: this.state.checkedKeys,
+ };
+ axios
+ .put(
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/roles/' +
+ this.props.data,
+ roleData,
+ { headers: { 'Content-Type': 'application-json' } },
+ )
+ .then(res => {
+ if (res.status === 200) {
+ this.props.fetchUsers();
+ notification.success({
+ message: 'Done',
+ duration: 4,
+ description: 'Successfully Updated the Permissions.',
+ });
+ this.setState({
isEditPermissionModalVisible: false,
- expandedKeys: [],
- autoExpandParent: true,
- checkedKeys: [],
- };
- }
+ });
+ }
+ })
+ .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 add permissions.',
+ });
+ }
+ });
+ };
- openEditRoleModal = () =>{
- let apiUrl = window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt +
- "/roles/"+ this.props.data;
+ loadUsersList = value => {
+ let apiURL =
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/users/search/usernames?filter=' +
+ value +
+ '&domain=Primary';
+ axios
+ .get(apiURL)
+ .then(res => {
+ if (res.status === 200) {
+ let user = JSON.parse(res.data.data);
+ let users = [];
+ for (let i = 0; i < user.length; i++) {
+ users.push(
+
{user[i].username} ,
+ );
+ }
+ this.setState({
+ users: users,
+ });
+ }
+ })
+ .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 users.',
+ });
+ }
+ });
+ };
- axios.get(apiUrl).then(res => {
- if (res.status === 200) {
- this.setState({
- roleData : res.data.data,
- isEditRoleModalVisible: true,
- });
- }
+ onDeleteRole = () => {
+ axios
+ .delete(
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/roles/' +
+ this.props.data,
+ { headers: { 'Content-Type': 'application/json' } },
+ )
+ .then(res => {
+ if (res.status === 200) {
+ this.props.fetchUsers();
+ notification.success({
+ message: 'Done',
+ duration: 4,
+ description: 'Successfully deleted the Role.',
+ });
+ }
+ })
+ .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 delete role.',
+ });
+ }
+ });
+ };
- }).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 role.",
- });
- }
- });
- };
+ render() {
+ const isAdminRole = this.props.data === 'admin';
+ const { getFieldDecorator } = this.props.form;
+ return (
+
+
- openEditPermissionModal =()=>{
- this.loadPermissionList();
- this.setState({
- isEditPermissionModalVisible: true,
- });
- };
-
- loadPermissionList = () => {
- let apiURL = window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt + "/roles/"+this.props.data+"/permissions";
-
- axios.get(apiURL).then(res => {
- if (res.status === 200) {
- this.getCheckedPermissions(res.data.data.nodeList);
- this.setState({
- nodeList : res.data.data.nodeList,
- isNodeList: true,
- checkedKeys : this.selected,
- expandedKeys : this.expandKeys
- });
- }
- }).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 permission.",
- });
- }
- })
- };
-
- getCheckedPermissions = (data) =>{
- data.forEach(item => {
- if (item !== null) {
- this.expandKeys.push(item.resourcePath);
- if (item.isSelected) {
- this.selected.push(item.resourcePath);
- }
- this.getCheckedPermissions(item.nodeList);
- }else{
- return null;
- }
- });
- };
-
- onExpand = expandedKeys => {
- this.setState({
- expandedKeys,
- autoExpandParent: false,
- });
- };
-
- onCheck = checkedKeys => {
- this.setState({checkedKeys});
- };
-
- renderTreeNodes = (data) => {
- return data.map(item => {
- if (item !== null) {
- if (item.hasOwnProperty("nodeList")) {
- return (
-
- {this.renderTreeNodes(item.nodeList)}
-
- );
- }
- return
;
- } else{
- return
;
- }
- });
- };
-
- onUpdateRole = e => {
- this.props.form.validateFields((err, values) => {
- if (!err) {
- this.onConfirmUpdateRole(values);
- }
- console.log(values);
- });
- };
-
- onCancelHandler = e =>{
- this.setState({
- isEditRoleModalVisible: false,
- isEditPermissionModalVisible:false,
- })
- };
-
- onConfirmUpdateRole = (value) =>{
- const roleData = {
- roleName : value.roleName,
- users : value.users,
- };
- axios.put(
- window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt +
- "/roles/"+ this.props.data,
- roleData,
- {headers: {'Content-Type' : 'application-json'}}
- ).then(res => {
- if (res.status === 200) {
- this.props.fetchUsers();
- this.setState({
- isEditRoleModalVisible: false,
- });
- notification["success"]({
- message: "Done",
- duration: 4,
- description:
- "Successfully Updated the role.",
- });
- }
- }).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 add role.",
- });
- }
- });
- };
-
- onAssignPermission = () =>{
- const roleData = {
- roleName : this.props.data,
- permissions : this.state.checkedKeys
- };
- axios.put(
- window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt +
- "/roles/"+ this.props.data,
- roleData,
- {headers: {'Content-Type' : 'application-json'}}
- ).then(res => {
- if (res.status === 200) {
- this.props.fetchUsers();
- notification["success"]({
- message: "Done",
- duration: 4,
- description:
- "Successfully Updated the Permissions.",
- });
- this.setState({
- isEditPermissionModalVisible : false
- });
- }
- }).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 add permissions.",
- });
- }
- });
- };
-
- loadUsersList = (value) => {
- let apiURL = window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt + "/users/search/usernames?filter="+value+"&domain=Primary";
- axios.get(apiURL).then(res => {
- if (res.status === 200) {
- let user = JSON.parse(res.data.data);
- let users = [];
- for(let i=0; i
{user[i].username});
- }
- this.setState({
- users : users
- });
-
- }
- }).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 users.",
- });
- }
- })
- };
-
- onDeleteRole = () => {
- axios.delete(
- window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt +
- "/roles/" + this.props.data,
- {headers: {'Content-Type': 'application/json'}}
-
- ).then(res => {
- if (res.status === 200) {
- this.props.fetchUsers();
- notification["success"]({
- message: "Done",
- duration: 4,
- description:
- "Successfully deleted the Role.",
- });
- }
- }).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 delete role.",
- });
- }
- });
- };
-
- render() {
- const isAdminRole = this.props.data ==="admin";
- const { getFieldDecorator } = this.props.form;
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Cancel
- ,
-
- Add Role
- ,
- ]}>
-
-
Create new user on IoT Server.
-
- {getFieldDecorator('userStoreDomain', {
- initialValue : 'PRIMARY'
- })(
-
- PRIMARY
-
- )}
-
-
- {getFieldDecorator('roleName', {
- initialValue: this.state.roleData.roleName,
- rules: [
- {
- pattern : new RegExp("^(((?!(\\@|\\/|\\s)).){3,})*$"),
- message: 'Role name should be in minimum 3 characters long and not ' +
- 'include any whitespaces or @ or /',
- },
- {
- required: true,
- message: 'This field is required.',
- },
-
- ],
- })( )}
-
-
- {getFieldDecorator('users', {
- initialValue: this.state.roleData.users,
- })(
- {this.state.users}
- )}
-
-
-
-
-
-
-
- Cancel
- ,
-
- Assign
- ,
- ]}
- bodyStyle={{overflowY:"scroll", maxHeight:'500px', marginLeft:'10px'}}>
-
- {(this.state.isNodeList) &&(
-
- {this.renderTreeNodes(this.state.nodeList)}
-
- )}
-
-
-
+
+
+ Cancel
+ ,
+
+ Add Role
+ ,
+ ]}
+ >
+
+
Create new user on IoT Server.
+
+ {getFieldDecorator('userStoreDomain', {
+ initialValue: 'PRIMARY',
+ })(
+
+ PRIMARY
+ ,
+ )}
+
+
+ {getFieldDecorator('roleName', {
+ initialValue: this.state.roleData.roleName,
+ rules: [
+ {
+ pattern: new RegExp('^(((?!(\\@|\\/|\\s)).){3,})*$'),
+ message:
+ 'Role name should be in minimum 3 characters long and not ' +
+ 'include any whitespaces or @ or /',
+ },
+ {
+ required: true,
+ message: 'This field is required.',
+ },
+ ],
+ })( )}
+
+
+ {getFieldDecorator('users', {
+ initialValue: this.state.roleData.users,
+ })(
+
+ {this.state.users}
+ ,
+ )}
+
+
- );
- }
+
+
+
+
+ Cancel
+ ,
+
+ Assign
+ ,
+ ]}
+ bodyStyle={{
+ overflowY: 'scroll',
+ maxHeight: '500px',
+ marginLeft: '10px',
+ }}
+ >
+
+ {this.state.isNodeList && (
+
+ {this.renderTreeNodes(this.state.nodeList)}
+
+ )}
+
+
+
+
+ );
+ }
}
-export default withConfigContext(Form.create({name: 'role-actions'})(RoleAction));
\ No newline at end of file
+export default withConfigContext(
+ Form.create({ name: 'role-actions' })(RoleAction),
+);
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Roles/RolesTable.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Roles/RolesTable.js
index 4939792e11..66db1eff54 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Roles/RolesTable.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Roles/RolesTable.js
@@ -16,243 +16,251 @@
* under the License.
*/
-import React from "react";
-import axios from "axios";
-import {
- Button,
- message,
- Modal,
- notification,
- Table, List
-} from "antd";
-import TimeAgo from 'javascript-time-ago'
+import React from 'react';
+import axios from 'axios';
+import { Button, message, Modal, notification, Table, List } 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 AddRole from "./AddRole";
-import RoleAction from "./RoleAction";
-import Filter from "../Utils/Filter/Filter";
+import en from 'javascript-time-ago/locale/en';
+import { withConfigContext } from '../../context/ConfigContext';
+import AddRole from './AddRole';
+import RoleAction from './RoleAction';
+import Filter from '../Utils/Filter/Filter';
const searchFields = [
- {
- name: 'filter',
- placeholder: 'Name'
- }
+ {
+ name: 'filter',
+ placeholder: 'Name',
+ },
];
-
class RolesTable extends React.Component {
- constructor(props) {
- super(props);
- this.config = this.props.context;
- TimeAgo.addLocale(en);
- this.state = {
- data: [],
- pagination: {},
- loading: false,
- selectedRows: [],
- userData: [],
- users : [],
- isEditRoleModalVisible: false,
- isUserListModalVisible :false,
- };
- }
+ constructor(props) {
+ super(props);
+ this.config = this.props.context;
+ TimeAgo.addLocale(en);
+ this.state = {
+ data: [],
+ pagination: {},
+ loading: false,
+ selectedRows: [],
+ userData: [],
+ users: [],
+ isEditRoleModalVisible: false,
+ isUserListModalVisible: false,
+ };
+ }
- rowSelection = {
- onChange: (selectedRowKeys, selectedRows) => {
- this.setState({
- selectedRows: selectedRows
- })
+ rowSelection = {
+ onChange: (selectedRowKeys, selectedRows) => {
+ this.setState({
+ selectedRows: selectedRows,
+ });
+ },
+ };
+
+ componentDidMount() {
+ this.fetchUsers();
+ }
+
+ openUserListModal = event => {
+ let apiUrl =
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/roles/' +
+ event;
+
+ // send request to the invokerss
+ axios
+ .get(apiUrl)
+ .then(res => {
+ if (res.status === 200) {
+ this.setState({
+ userData: res.data.data.users,
+ isUserListModalVisible: true,
+ });
}
+ })
+ .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 users.',
+ });
+ }
+ });
+ };
+
+ handleOk = e => {
+ this.setState({
+ isUserListModalVisible: false,
+ });
+ };
+
+ handleCancel = e => {
+ this.setState({
+ isUserListModalVisible: false,
+ });
+ };
+
+ // fetch data from api
+ fetchUsers = (params = {}, filters = {}) => {
+ // 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,
+ ...filters,
};
- componentDidMount() {
- this.fetchUsers();
- }
+ const encodedExtraParams = Object.keys(extraParams)
+ .map(key => key + '=' + extraParams[key])
+ .join('&');
- openUserListModal = (event) => {
- let apiUrl = window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt +
- "/roles/"+ event;
+ let apiUrl =
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/roles?' +
+ encodedExtraParams;
- //send request to the invokerss
- axios.get(apiUrl).then(res => {
- if (res.status === 200) {
- this.setState({
- userData : res.data.data.users,
- isUserListModalVisible: true,
- });
- }
+ // send request to the invokerss
+ axios
+ .get(apiUrl)
+ .then(res => {
+ if (res.status === 200) {
+ const pagination = { ...this.state.pagination };
+ this.setState({
+ loading: false,
+ data: res.data.data.roles,
+ 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 users.',
+ });
+ }
- }).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 users.",
- });
- }
- });
- };
+ this.setState({ loading: false });
+ });
+ };
- handleOk = e => {
- this.setState({
- isUserListModalVisible: 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,
+ });
+ };
- handleCancel = e => {
- this.setState({
- isUserListModalVisible: false,
- });
- };
-
- //fetch data from api
- fetchUsers = (params = {}, filters={}) => {
- // 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,
- ...filters
- };
-
- const encodedExtraParams = Object.keys(extraParams)
- .map(key => key + '=' + extraParams[key]).join('&');
-
- let apiUrl = window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt +
- "/roles?" + encodedExtraParams;
-
- //send request to the invokerss
- axios.get(apiUrl).then(res => {
- if (res.status === 200) {
- const pagination = {...this.state.pagination};
- this.setState({
- loading: false,
- data: res.data.data.roles,
- 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 users.",
- });
- }
-
- 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;
- const columns = [
- {
- title: 'Role Name',
- dataIndex: '',
- key: "role",
- width: "60%",
- },
- {
- title: 'View',
- dataIndex: '',
- key: 'users',
- render: (id, row) =>
- this.openUserListModal(row)}>Users
-
- },
- {
- title: 'Action',
- dataIndex: 'id',
- key: 'action',
- render: (id, row) => (
-
-
-
- ),
- },
-
- ];
- return (
+ render() {
+ const { data, pagination, loading } = this.state;
+ const columns = [
+ {
+ title: 'Role Name',
+ dataIndex: '',
+ key: 'role',
+ width: '60%',
+ },
+ {
+ title: 'View',
+ dataIndex: '',
+ key: 'users',
+ render: (id, row) => (
+ this.openUserListModal(row)}
+ >
+ Users
+
+ ),
+ },
+ {
+ title: 'Action',
+ dataIndex: 'id',
+ key: 'action',
+ render: (id, row) => (
+
+
+
+ ),
+ },
+ ];
+ return (
+
+
+
+
+
+
+
record}
+ dataSource={data}
+ pagination={{
+ ...pagination,
+ size: 'small',
+ // position: "top",
+ showTotal: (total, range) =>
+ `showing ${range[0]}-${range[1]} of ${total} groups`,
+ // showQuickJumper: true
+ }}
+ loading={loading}
+ onChange={this.handleTableChange}
+ rowSelection={this.rowSelection}
+ />
+
+
+
-
-
-
-
-
-
(record)}
- dataSource={data}
- pagination={{
- ...pagination,
- size: "small",
- // position: "top",
- showTotal: (total, range) => `showing ${range[0]}-${range[1]} of ${total} groups`
- // showQuickJumper: true
- }}
- loading={loading}
- onChange={this.handleTableChange}
- rowSelection={this.rowSelection}
- />
-
-
+ {item} }
+ />
-
- );
- }
+
+
+
+ );
+ }
}
export default withConfigContext(RolesTable);
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/RouteWithSubRoutes.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/RouteWithSubRoutes.js
index f57ec331b0..0f255e852f 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/RouteWithSubRoutes.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/RouteWithSubRoutes.js
@@ -17,21 +17,28 @@
*/
import React from 'react';
-import {Route} from 'react-router-dom';
-class RouteWithSubRoutes extends React.Component{
- props;
- constructor(props){
- super(props);
- this.props = props;
- }
- render() {
- return(
- (
-
- )}/>
- );
- }
-
+import { Route } from 'react-router-dom';
+class RouteWithSubRoutes extends React.Component {
+ props;
+ constructor(props) {
+ super(props);
+ this.props = props;
+ }
+ render() {
+ return (
+ (
+
+ )}
+ />
+ );
+ }
}
-export default RouteWithSubRoutes;
\ No newline at end of file
+export default RouteWithSubRoutes;
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/AddUser.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/AddUser.js
index 9c02db791e..2492f2e1e0 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/AddUser.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/AddUser.js
@@ -1,215 +1,245 @@
import React from 'react';
-import {Button, Form, Select, Input, message, Modal, notification, Typography} from "antd";
-import axios from "axios";
-import {withConfigContext} from "../../context/ConfigContext";
+import {
+ Button,
+ Form,
+ Select,
+ Input,
+ message,
+ Modal,
+ notification,
+} from 'antd';
+import axios from 'axios';
+import { withConfigContext } from '../../context/ConfigContext';
const { Option } = Select;
-const {Text} = Typography;
class AddUser extends React.Component {
+ constructor(props) {
+ super(props);
+ this.config = this.props.context;
+ this.state = {
+ isModalVisible: false,
+ roles: [],
+ };
+ }
- constructor(props) {
- super(props);
- this.config = this.props.context;
- this.state = {
+ componentDidMount() {
+ this.getRole();
+ }
+
+ openAddModal = () => {
+ this.setState({
+ isModalVisible: true,
+ });
+ };
+
+ onSubmitHandler = e => {
+ this.props.form.validateFields((err, values) => {
+ if (!err) {
+ this.onConfirmAddUser(values);
+ }
+ });
+ };
+
+ onConfirmAddUser = value => {
+ const userData = {
+ username: value.userStoreDomain + '/' + value.userName,
+ firstname: value.firstName,
+ lastname: value.lastName,
+ emailAddress: value.email,
+ roles: value.userRoles,
+ };
+ axios
+ .post(
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/users',
+ userData,
+ { headers: { 'Content-Type': 'application-json' } },
+ )
+ .then(res => {
+ if (res.status === 201) {
+ this.props.fetchUsers();
+ this.setState({
isModalVisible: false,
- roles : []
+ });
+ notification.success({
+ message: 'Done',
+ duration: 4,
+ description: 'Successfully added the user.',
+ });
}
- }
+ })
+ .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 add user.',
+ });
+ }
+ });
+ };
- componentDidMount() {
- this.getRole();
- }
+ onCancelHandler = e => {
+ this.setState({
+ isModalVisible: false,
+ });
+ };
- openAddModal = () => {
- this.setState({
- isModalVisible:true
- });
- };
+ getRole = () => {
+ let apiURL =
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/roles?user-store=PRIMARY&limit=100';
- onSubmitHandler = e => {
- this.props.form.validateFields((err, values) => {
- if (!err) {
- this.onConfirmAddUser(values);
- }
- });
- };
+ axios
+ .get(apiURL)
+ .then(res => {
+ if (res.status === 200) {
+ const roles = [];
+ for (let i = 0; i < res.data.data.roles.length; i++) {
+ roles.push(
+
+ {res.data.data.roles[i]}
+ ,
+ );
+ }
+ this.setState({
+ roles: roles,
+ });
+ }
+ })
+ .catch(error => {
+ if (error.hasOwnProperty('response') && error.response.status === 401) {
+ // todo display a popop with error
- onConfirmAddUser = (value) =>{
- const userData = {
- username : value.userStoreDomain +"/"+value.userName,
- firstname : value.firstName,
- lastname : value.lastName,
- emailAddress : value.email,
- roles : value.userRoles
- };
- axios.post(
- window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt +
- "/users",
- userData,
- {headers: {'Content-Type' : 'application-json'}}
- ).then(res => {
- if (res.status === 201) {
- this.props.fetchUsers();
- this.setState({
- isModalVisible: false,
- });
- notification["success"]({
- message: "Done",
- duration: 4,
- description:
- "Successfully added the user.",
- });
- }
- }).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 add user.",
- });
- }
- });
- };
+ 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.',
+ });
+ }
+ });
+ };
- onCancelHandler = e => {
- this.setState({
- isModalVisible: false,
- });
- };
-
- getRole = () => {
- let apiURL = window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt + "/roles?user-store=PRIMARY&limit=100";
-
- axios.get(apiURL).then(res => {
- if (res.status === 200) {
- const roles = [];
- for(let i=0; i{res.data.data.roles[i]});
- }
- this.setState({
- roles : roles
- })
- }
- }).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 roles.",
- });
- }
- })
- };
-
- render() {
- const { getFieldDecorator } = this.props.form;
- return (
-
-
-
- Add User
-
-
-
-
- Cancel
- ,
-
- Submit
- ,
- ]}>
-
-
Create new user on IoT Server.
-
- {getFieldDecorator('userStoreDomain', {
- initialValue : 'PRIMARY'
- })(
-
- PRIMARY
-
- )}
-
-
- {getFieldDecorator('userName', {
- rules: [
- {
- required: true,
- message: 'This field is required. Username should be at least 3 characters long with no white spaces.',
- },
- ],
- })( )}
-
-
- {getFieldDecorator('firstName', {
- rules: [
- {
- required: true,
- message: 'This field is required',
- },
- ],
- })( )}
-
-
- {getFieldDecorator('lastName', {
- rules: [
- {
- required: true,
- message: 'This field is required',
- },
- ],
- })( )}
-
-
- {getFieldDecorator('email', {
- rules: [
- {
- type: 'email',
- message: 'Invalid Email Address',
- },
- {
- required: true,
- message: 'This field is required',
- },
- ],
- })( )}
-
-
- {getFieldDecorator('userRoles', {
- })(
- {this.state.roles}
- )}
-
-
-
-
-
+ render() {
+ const { getFieldDecorator } = this.props.form;
+ return (
+
+
+
+ Add User
+
+
+
+
+ Cancel
+ ,
+
+ Submit
+ ,
+ ]}
+ >
+
+
Create new user on IoT Server.
+
+ {getFieldDecorator('userStoreDomain', {
+ initialValue: 'PRIMARY',
+ })(
+
+ PRIMARY
+ ,
+ )}
+
+
+ {getFieldDecorator('userName', {
+ rules: [
+ {
+ required: true,
+ message:
+ 'This field is required. Username should be at least 3 characters long with no white spaces.',
+ },
+ ],
+ })( )}
+
+
+ {getFieldDecorator('firstName', {
+ rules: [
+ {
+ required: true,
+ message: 'This field is required',
+ },
+ ],
+ })( )}
+
+
+ {getFieldDecorator('lastName', {
+ rules: [
+ {
+ required: true,
+ message: 'This field is required',
+ },
+ ],
+ })( )}
+
+
+ {getFieldDecorator('email', {
+ rules: [
+ {
+ type: 'email',
+ message: 'Invalid Email Address',
+ },
+ {
+ required: true,
+ message: 'This field is required',
+ },
+ ],
+ })( )}
+
+
+ {getFieldDecorator('userRoles', {})(
+
+ {this.state.roles}
+ ,
+ )}
+
+
- );
- }
+
+
+
+ );
+ }
}
-export default withConfigContext(Form.create({name: 'add-user'})(AddUser))
\ No newline at end of file
+export default withConfigContext(Form.create({ name: 'add-user' })(AddUser));
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/UserActions.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/UserActions.js
index 7236e657b5..6204933260 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/UserActions.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/UserActions.js
@@ -1,423 +1,472 @@
import React from 'react';
import {
- Button,
- Divider,
- Form,
- Icon,
- Input,
- message,
- Modal,
- notification,
- Popconfirm,
- Select,
- Tooltip,
- Typography } from "antd";
-import axios from "axios";
-import {withConfigContext} from "../../context/ConfigContext";
+ Button,
+ Divider,
+ Form,
+ Icon,
+ Input,
+ message,
+ Modal,
+ notification,
+ Popconfirm,
+ Select,
+ Tooltip,
+ Typography,
+} from 'antd';
+import axios from 'axios';
+import { withConfigContext } from '../../context/ConfigContext';
const { Option } = Select;
-const {Text} = Typography;
+const { Text } = Typography;
class UserActions extends React.Component {
- constructor(props) {
- super(props);
- this.config = this.props.context;
- this.state = {
- isEditModalVisible: false,
- isResetPasswordModalVisible: false,
- rolesData: [],
- }
+ constructor(props) {
+ super(props);
+ this.config = this.props.context;
+ this.state = {
+ isEditModalVisible: false,
+ isResetPasswordModalVisible: false,
+ rolesData: [],
+ };
+ }
+ openEditModal = () => {
+ this.setState({
+ isEditModalVisible: true,
+ });
+ this.fetchRoles(this.props.data.username);
+ };
+ openPasswordResetModal = () => {
+ this.setState({
+ isResetPasswordModalVisible: true,
+ });
+ };
+
+ onCancelHandler = () => {
+ this.setState({
+ isEditModalVisible: false,
+ isResetPasswordModalVisible: false,
+ });
+ };
+
+ compareToFirstPassword = (rule, value, callback) => {
+ if (value && value !== this.props.form.getFieldValue('password')) {
+ callback("New password doesn't match the confirmation.");
+ } else {
+ callback();
}
- openEditModal = () =>{
- this.setState({
- isEditModalVisible: true,
- });
- this.fetchRoles(this.props.data.username);
+ };
- };
- openPasswordResetModal = () =>{
- this.setState({
- isResetPasswordModalVisible: true,
- })
- };
+ onSavePassword = () => {
+ this.props.form.validateFields(
+ ['password', 'confirmPassword'],
+ (err, values) => {
+ if (!err) {
+ this.onResetPassword(values);
+ }
+ },
+ );
+ };
- onCancelHandler = () =>{
- this.setState({
- isEditModalVisible: false,
+ onResetPassword = value => {
+ const password = {
+ newPassword: value.password,
+ };
+ axios
+ .post(
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/admin/users/' +
+ this.props.data.username +
+ '/credentials',
+ password,
+ { headers: { 'Content-Type': 'application-json' } },
+ )
+ .then(res => {
+ if (res.status === 200) {
+ this.props.fetchUsers();
+ this.setState({
isResetPasswordModalVisible: false,
- })
- };
-
- compareToFirstPassword = (rule, value, callback) => {
- if (value && value !== this.props.form.getFieldValue('password')) {
- callback('New password doesn\'t match the confirmation.');
+ });
+ notification.success({
+ message: 'Done',
+ duration: 4,
+ description: 'Successfully reset the password',
+ });
+ }
+ })
+ .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 {
- callback();
+ notification.error({
+ message: 'There was a problem',
+ duration: 0,
+ description: 'Error occurred while trying to reset password.',
+ });
}
+ });
+ };
+
+ componentDidMount() {
+ this.getRole();
+ }
+
+ getRole = () => {
+ let apiURL =
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/roles?user-store=PRIMARY&limit=100';
+
+ axios
+ .get(apiURL)
+ .then(res => {
+ if (res.status === 200) {
+ const roles = [];
+ for (let i = 0; i < res.data.data.roles.length; i++) {
+ roles.push(
+
+ {res.data.data.roles[i]}
+ ,
+ );
+ }
+ this.setState({
+ roles: roles,
+ });
+ }
+ })
+ .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 roles.',
+ });
+ }
+ });
+ };
+
+ onConfirmDeleteUser = () => {
+ axios
+ .delete(
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/users/' +
+ this.props.data.username,
+ { headers: { 'Content-Type': 'application/json' } },
+ )
+ .then(res => {
+ if (res.status === 200) {
+ this.props.fetchUsers();
+ notification.success({
+ message: 'Done',
+ duration: 4,
+ description: 'Successfully deleted the user.',
+ });
+ }
+ })
+ .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 delete user.',
+ });
+ }
+ });
+ };
+
+ fetchRoles = username => {
+ let apiUrl =
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/users/' +
+ username +
+ '/roles';
+
+ axios
+ .get(apiUrl)
+ .then(res => {
+ if (res.status === 200) {
+ this.setState({
+ rolesData: res.data.data.roles,
+ });
+ }
+ })
+ .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 roles.',
+ });
+ }
+ });
+ };
+
+ handleEditOk = e => {
+ this.props.form.validateFields(
+ [
+ 'userStoreDomain',
+ 'userName',
+ 'firstName',
+ 'lastName',
+ 'email',
+ 'userRoles',
+ ],
+ (err, values) => {
+ if (!err) {
+ this.onUpdateUser(values);
+ }
+ },
+ );
+ };
+
+ onUpdateUser = value => {
+ const userData = {
+ username: value.userStoreDomain + '/' + value.userName,
+ firstname: value.firstName,
+ lastname: value.lastName,
+ emailAddress: value.email,
+ roles: value.userRoles,
};
+ axios
+ .put(
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/users/' +
+ this.props.data.username,
+ userData,
+ { headers: { 'Content-Type': 'application-json' } },
+ )
+ .then(res => {
+ if (res.status === 200) {
+ this.props.fetchUsers();
+ this.setState({
+ isEditModalVisible: false,
+ });
+ notification.success({
+ message: 'Done',
+ duration: 4,
+ description: 'Successfully updated the user.',
+ });
+ }
+ })
+ .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 update user.',
+ });
+ }
+ });
+ };
- onSavePassword = () => {
- this.props.form.validateFields((['password', 'confirmPassword']),(err, values) => {
- if (!err) {
- this.onResetPassword(values);
- }
- });
- };
+ render() {
+ const isAdminUser = this.props.data.username === 'admin';
+ const { getFieldDecorator } = this.props.form;
+ return (
+
+
- onResetPassword = (value) =>{
- const password = {
- newPassword : value.password,
- };
- axios.post(
- window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt +
- "/admin/users/"+this.props.data.username+"/credentials",
- password,
- {headers: {'Content-Type' : 'application-json'}}
- ).then(res => {
- if (res.status === 200) {
- this.props.fetchUsers();
- this.setState({
- isResetPasswordModalVisible: false,
- });
- notification["success"]({
- message: "Done",
- duration: 4,
- description:
- "Successfully reset the password",
- });
- }
- }).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 reset password.",
- });
- }
- });
-
- };
-
- componentDidMount() {
- this.getRole();
- }
-
- getRole = () => {
- let apiURL = window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt + "/roles?user-store=PRIMARY&limit=100";
-
- axios.get(apiURL).then(res => {
- if (res.status === 200) {
- const roles = [];
- for(let i=0; i
{res.data.data.roles[i]});
- }
- this.setState({
- roles : roles
- })
- }
- }).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 roles.",
- });
- }
- })
- };
-
- onConfirmDeleteUser = () => {
- axios.delete(
- window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt +
- "/users/" + this.props.data.username,
- {headers: {'Content-Type': 'application/json'}}
-
- ).then(res => {
- if (res.status === 200) {
- this.props.fetchUsers();
- notification["success"]({
- message: "Done",
- duration: 4,
- description:
- "Successfully deleted the user.",
- });
- }
- }).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 delete user.",
- });
- }
- });
- };
-
- fetchRoles = (username) => {
- let apiUrl = window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt +
- "/users/" + username + "/roles";
-
- axios.get(apiUrl).then(res => {
- if (res.status === 200) {
- this.setState({
- rolesData: res.data.data.roles,
- });
- }
-
- }).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 roles.",
- });
- }
- });
- };
-
- handleEditOk = e =>{
- this.props.form.validateFields((['userStoreDomain', 'userName', 'firstName', 'lastName' , 'email', 'userRoles']),(err, values) => {
- if (!err) {
- this.onUpdateUser(values);
- }
- });
- };
-
- onUpdateUser = (value) =>{
- const userData = {
- username : value.userStoreDomain +"/"+value.userName,
- firstname : value.firstName,
- lastname : value.lastName,
- emailAddress : value.email,
- roles : value.userRoles
- };
- axios.put(
- window.location.origin + this.config.serverConfig.invoker.uri +
- this.config.serverConfig.invoker.deviceMgt +
- "/users/"+ this.props.data.username,
- userData,
- {headers: {'Content-Type' : 'application-json'}}
- ).then(res => {
- if (res.status === 200) {
- this.props.fetchUsers();
- this.setState({
- isEditModalVisible: false,
- });
- notification["success"]({
- message: "Done",
- duration: 4,
- description:
- "Successfully updated the user.",
- });
- }
- }).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 update user.",
- });
- }
- });
- };
-
- render() {
- const isAdminUser = this.props.data.username ==="admin";
- const { getFieldDecorator } = this.props.form;
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Cancel
- ,
-
- Save
- ,
- ]}>
-
-
- {getFieldDecorator(
- 'password',
- {
- rules: [
- {
- required: true,
- message: 'This field is required',
- },
- ],
- })( )}
-
-
- {getFieldDecorator(
- 'confirmPassword',
- {
- rules: [
- {
- required: true,
- message: 'This field is required',
- },
- {
- validator: this.compareToFirstPassword,
- },
- ],
- })( )}
-
-
-
-
-
-
-
-
- Cancel
- ,
-
- Update
- ,
- ]}>
-
-
Create new user on IoT Server.
-
- {getFieldDecorator('userStoreDomain', {
- initialValue : 'PRIMARY'
- })(
-
- PRIMARY
-
- )}
-
-
- {getFieldDecorator('userName', {
- initialValue: this.props.data.username,
- rules: [
- {
- required: true,
- message: 'This field is required. Username should be at least 3 characters long with no white spaces.',
- },
- ],
- })( )}
-
-
- {getFieldDecorator('firstName', {
- initialValue: this.props.data.firstname,
- rules: [
- {
- required: true,
- message: 'This field is required',
- },
- ],
- })( )}
-
-
- {getFieldDecorator('lastName', {
- initialValue: this.props.data.lastname,
- rules: [
- {
- required: true,
- message: 'This field is required',
- },
- ],
- })( )}
-
-
- {getFieldDecorator('email', {
- initialValue: this.props.data.emailAddress,
- rules: [
- {
- type: 'email',
- message: 'Invalid Email Address',
- },
- {
- required: true,
- message: 'This field is required',
- },
- ],
- })( )}
-
-
- {getFieldDecorator('userRoles', {
- initialValue: this.state.rolesData,
- })(
- {this.state.roles}
- )}
-
-
-
-
-
+
+
+ Cancel
+ ,
+
+ Save
+ ,
+ ]}
+ >
+
+
+ {getFieldDecorator('password', {
+ rules: [
+ {
+ required: true,
+ message: 'This field is required',
+ },
+ ],
+ })( )}
+
+
+ {getFieldDecorator('confirmPassword', {
+ rules: [
+ {
+ required: true,
+ message: 'This field is required',
+ },
+ {
+ validator: this.compareToFirstPassword,
+ },
+ ],
+ })( )}
+
+
- );
- }
+
+
+
+
+
+ Cancel
+ ,
+
+ Update
+ ,
+ ]}
+ >
+
+
Create new user on IoT Server.
+
+ {getFieldDecorator('userStoreDomain', {
+ initialValue: 'PRIMARY',
+ })(
+
+ PRIMARY
+ ,
+ )}
+
+
+ {getFieldDecorator('userName', {
+ initialValue: this.props.data.username,
+ rules: [
+ {
+ required: true,
+ message:
+ 'This field is required. Username should be at least 3 characters long with no white spaces.',
+ },
+ ],
+ })( )}
+
+
+ {getFieldDecorator('firstName', {
+ initialValue: this.props.data.firstname,
+ rules: [
+ {
+ required: true,
+ message: 'This field is required',
+ },
+ ],
+ })( )}
+
+
+ {getFieldDecorator('lastName', {
+ initialValue: this.props.data.lastname,
+ rules: [
+ {
+ required: true,
+ message: 'This field is required',
+ },
+ ],
+ })( )}
+
+
+ {getFieldDecorator('email', {
+ initialValue: this.props.data.emailAddress,
+ rules: [
+ {
+ type: 'email',
+ message: 'Invalid Email Address',
+ },
+ {
+ required: true,
+ message: 'This field is required',
+ },
+ ],
+ })( )}
+
+
+ {getFieldDecorator('userRoles', {
+ initialValue: this.state.rolesData,
+ })(
+
+ {this.state.roles}
+ ,
+ )}
+
+
+
+
+
+
+ );
+ }
}
-export default withConfigContext(Form.create({name: 'user-actions'})(UserActions));
\ No newline at end of file
+export default withConfigContext(
+ Form.create({ name: 'user-actions' })(UserActions),
+);
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/UsersDevices.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/UsersDevices.js
index eca727ac9a..dbf593abdb 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/UsersDevices.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/UsersDevices.js
@@ -16,233 +16,245 @@
* under the License.
*/
-import React from "react";
-import axios from "axios";
-import {Icon, message, notification, Table, Tag, Tooltip, Typography} from "antd";
-import TimeAgo from 'javascript-time-ago'
+import React from 'react';
+import axios from 'axios';
+import { Icon, message, notification, Table, Tag, Tooltip } 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;
+import en from 'javascript-time-ago/locale/en';
+import { withConfigContext } from '../../context/ConfigContext';
let config = null;
-let apiUrl;
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;
+ {
+ title: 'Device',
+ dataIndex: 'name',
+ width: 100,
+ },
+ {
+ title: 'Type',
+ dataIndex: 'type',
+ key: 'type',
+ // eslint-disable-next-line react/display-name
+ 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;
- }
+ if (defaultPlatformIcons.hasOwnProperty(type)) {
+ icon = defaultPlatformIcons[type].icon;
+ color = defaultPlatformIcons[type].color;
+ theme = defaultPlatformIcons[type].theme;
+ }
- return (
-
-
-
- );
- }
- // todo add filtering options
+ return (
+
+
+
+ );
},
- {
- title: 'Owner',
- dataIndex: 'enrolmentInfo',
- key: 'owner',
- render: enrolmentInfo => enrolmentInfo.owner
- // todo add filtering options
+ // todo add filtering options
+ },
+ {
+ title: 'Owner',
+ dataIndex: 'enrolmentInfo',
+ key: 'owner',
+ render: enrolmentInfo => enrolmentInfo.owner,
+ // todo add filtering options
+ },
+ {
+ title: 'Ownership',
+ dataIndex: 'enrolmentInfo',
+ key: 'ownership',
+ width: 100,
+ render: enrolmentInfo => enrolmentInfo.ownership,
+ // todo add filtering options
+ },
+ {
+ title: 'Status',
+ dataIndex: 'enrolmentInfo',
+ width: 100,
+ key: 'status',
+ // eslint-disable-next-line react/display-name
+ 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} ;
},
- {
- title: 'Ownership',
- dataIndex: 'enrolmentInfo',
- key: 'ownership',
- width: 100,
- render: enrolmentInfo => enrolmentInfo.ownership
- // todo add filtering options
+ // todo add filtering options
+ },
+ {
+ title: 'Last Updated',
+ dataIndex: 'enrolmentInfo',
+ key: 'dateOfLastUpdate',
+ // eslint-disable-next-line react/display-name
+ render: data => {
+ const { dateOfLastUpdate } = data;
+ const timeAgoString = getTimeAgo(dateOfLastUpdate);
+ return (
+
+ {timeAgoString}
+
+ );
},
- {
- title: 'Status',
- dataIndex: 'enrolmentInfo',
- width: 100,
- 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
- }
+ // todo add filtering options
+ },
];
-const getTimeAgo = (time) => {
- const timeAgo = new TimeAgo('en-US');
- return timeAgo.format(time);
+const getTimeAgo = time => {
+ const timeAgo = new TimeAgo('en-US');
+ return timeAgo.format(time);
};
class UsersDevices extends React.Component {
- constructor(props) {
- super(props);
- config = this.props.context;
- TimeAgo.addLocale(en);
- this.state = {
- data: [],
- pagination: {},
+ constructor(props) {
+ super(props);
+ config = this.props.context;
+ TimeAgo.addLocale(en);
+ this.state = {
+ data: [],
+ pagination: {},
+ loading: false,
+ selectedRows: [],
+ };
+ }
+
+ rowSelection = {
+ onChange: (selectedRowKeys, selectedRows) => {
+ this.setState({
+ selectedRows: selectedRows,
+ });
+ },
+ };
+
+ componentDidMount() {
+ this.fetch();
+ }
+
+ // Rerender component when parameters change
+ componentDidUpdate(prevProps, prevState, snapshot) {
+ if (prevProps.user !== this.props.user) {
+ 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,
+ user: this.props.user,
+ 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,
- selectedRows: []
- };
- }
-
- rowSelection = {
- onChange: (selectedRowKeys, selectedRows) => {
- this.setState({
- selectedRows: selectedRows
- })
+ data: res.data.data.devices,
+ pagination,
+ });
}
- };
-
- componentDidMount() {
- this.fetch();
- }
-
- //Rerender component when parameters change
- componentDidUpdate(prevProps, prevState, snapshot) {
- if(prevProps.user !== this.props.user){
- this.fetch();
+ })
+ .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.',
+ });
}
- }
- //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;
+ this.setState({ loading: false });
+ });
+ };
- const extraParams = {
- offset: 10 * (currentPage - 1), //calculate the offset
- limit: 10,
- user: this.props.user,
- requireDeviceInfo: true,
- };
+ 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,
+ });
+ };
- 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 + record.enrolmentInfo.owner + record.enrolmentInfo.ownership)}
- dataSource={data}
- showHeader={false}
- size="small"
- 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}
- />
-
- );
- }
+ render() {
+ const { data, pagination, loading } = this.state;
+ return (
+
+
+ record.deviceIdentifier +
+ record.enrolmentInfo.owner +
+ record.enrolmentInfo.ownership
+ }
+ dataSource={data}
+ showHeader={false}
+ size="small"
+ 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}
+ />
+
+ );
+ }
}
-export default withConfigContext(UsersDevices);
\ No newline at end of file
+export default withConfigContext(UsersDevices);
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/UsersTable.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/UsersTable.js
index 2400495948..e05c46d38f 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/UsersTable.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Users/UsersTable.js
@@ -16,305 +16,322 @@
* under the License.
*/
-import React from "react";
-import axios from "axios";
-import {Button, Collapse, Icon, List, message, Modal, notification, Table, Tabs, Typography} from "antd";
-import TimeAgo from 'javascript-time-ago'
+import React from 'react';
+import axios from 'axios';
+import { Button, List, message, Modal, notification, Table } 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 UsersDevices from "./UsersDevices";
-import AddUser from "./AddUser";
-import UserActions from "./UserActions";
-import Filter from "../Utils/Filter/Filter";
+import en from 'javascript-time-ago/locale/en';
+import { withConfigContext } from '../../context/ConfigContext';
+import UsersDevices from './UsersDevices';
+import AddUser from './AddUser';
+import UserActions from './UserActions';
+import Filter from '../Utils/Filter/Filter';
const ButtonGroup = Button.Group;
-const {Text} = Typography;
-let config = null;
let apiUrl;
const searchFields = [
- {
- name: 'username',
- placeholder: 'Username'
- },
- {
- name: 'firstName',
- placeholder: 'First Name'
- },
- {
- name: 'lastName',
- placeholder: 'Last Name'
- },
- {
- name: 'emailAddress',
- placeholder: 'Email Address'
- },
+ {
+ name: 'username',
+ placeholder: 'Username',
+ },
+ {
+ name: 'firstName',
+ placeholder: 'First Name',
+ },
+ {
+ name: 'lastName',
+ placeholder: 'Last Name',
+ },
+ {
+ name: 'emailAddress',
+ placeholder: 'Email Address',
+ },
];
class UsersTable extends React.Component {
- constructor(props) {
- super(props);
- config = this.props.context;
- TimeAgo.addLocale(en);
- this.state = {
- data: [],
- pagination: {},
+ constructor(props) {
+ super(props);
+ TimeAgo.addLocale(en);
+ this.state = {
+ data: [],
+ pagination: {},
+ loading: false,
+ selectedRows: [],
+ rolesModalVisible: false,
+ devicesModalVisible: false,
+ rolesData: [],
+ user: '',
+ };
+ }
+
+ rowSelection = {
+ onChange: (selectedRowKeys, selectedRows) => {
+ this.setState({
+ selectedRows: selectedRows,
+ });
+ },
+ };
+
+ componentDidMount() {
+ this.fetchUsers();
+ }
+
+ // fetch data from api
+ fetchUsers = (params = {}, filters = {}) => {
+ 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,
+ ...filters,
+ };
+
+ const encodedExtraParams = Object.keys(extraParams)
+ .map(key => key + '=' + extraParams[key])
+ .join('&');
+
+ apiUrl =
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.deviceMgt +
+ '/users/search?' +
+ encodedExtraParams;
+
+ // send request to the invokerss
+ axios
+ .get(apiUrl)
+ .then(res => {
+ if (res.status === 200) {
+ const pagination = { ...this.state.pagination };
+ this.setState({
loading: false,
- selectedRows: [],
- rolesModalVisible: false,
- devicesModalVisible: false,
- rolesData: [],
- user:''
- };
- }
+ data: res.data.data.users,
+ pagination,
+ });
- rowSelection = {
- onChange: (selectedRowKeys, selectedRows) => {
- this.setState({
- selectedRows: selectedRows
- })
+ console.log(res.data.data);
+ }
+ })
+ .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 users.',
+ });
}
- };
- componentDidMount() {
- this.fetchUsers();
- }
+ this.setState({ loading: false });
+ });
+ };
- //fetch data from api
- fetchUsers = (params = {}, filters = {}) => {
- const config = this.props.context;
- this.setState({loading: true});
+ fetchRoles = username => {
+ const config = this.props.context;
- // get current page
- const currentPage = (params.hasOwnProperty("page")) ? params.page : 1;
+ this.setState({
+ rolesModalVisible: true,
+ user: username,
+ });
- const extraParams = {
- offset: 10 * (currentPage - 1), //calculate the offset
- limit: 10,
- ...filters
- };
+ apiUrl =
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.deviceMgt +
+ '/users/' +
+ username +
+ '/roles';
- const encodedExtraParams = Object.keys(extraParams)
- .map(key => key + '=' + extraParams[key]).join('&');
+ axios
+ .get(apiUrl)
+ .then(res => {
+ if (res.status === 200) {
+ this.setState({
+ rolesData: res.data.data.roles,
+ });
+ }
+ })
+ .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 roles.',
+ });
+ }
- apiUrl = window.location.origin + config.serverConfig.invoker.uri +
- config.serverConfig.invoker.deviceMgt +
- "/users/search?" + encodedExtraParams;
+ this.setState({ loading: false });
+ });
+ };
- //send request to the invokerss
- axios.get(apiUrl).then(res => {
- if (res.status === 200) {
- const pagination = {...this.state.pagination};
- this.setState({
- loading: false,
- data: res.data.data.users,
- pagination,
- });
+ 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,
+ });
+ };
- console.log(res.data.data)
- }
+ handleOk = e => {
+ this.setState({
+ rolesModalVisible: false,
+ devicesModalVisible: false,
+ });
+ };
- }).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 users.",
- });
- }
+ handleCancel = e => {
+ this.setState({
+ rolesModalVisible: false,
+ devicesModalVisible: false,
+ });
+ };
- this.setState({loading: false});
- });
- };
+ openDeviceListModal = e => {
+ this.setState({
+ devicesModalVisible: true,
+ });
+ };
- fetchRoles = (username) => {
- const config = this.props.context;
-
- this.setState({
- rolesModalVisible: true,
- user: username
- });
-
- apiUrl = window.location.origin + config.serverConfig.invoker.uri +
- config.serverConfig.invoker.deviceMgt +
- "/users/" + username + "/roles";
-
- axios.get(apiUrl).then(res => {
- if (res.status === 200) {
- this.setState({
- rolesData: res.data.data.roles,
- });
- }
-
- }).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 roles.",
- });
- }
-
- 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,
- });
- };
-
- handleOk = e => {
- this.setState({
- rolesModalVisible: false,
- devicesModalVisible: false
- });
- };
-
- handleCancel = e => {
- this.setState({
- rolesModalVisible: false,
- devicesModalVisible: false
- });
- };
-
- openDeviceListModal = e =>{
- this.setState({
- devicesModalVisible: true,
- })
- };
-
- render() {
- const {data, pagination, loading, selectedRows} = this.state;
- const { Panel } = Collapse;
- const { TabPane } = Tabs;
- const columns = [
- {
- title: 'User Name',
- dataIndex: 'username',
- key: "username",
- },
- {
- title: 'First Name',
- dataIndex: 'firstname',
- key: 'firstname',
- },
- {
- title: 'Last Name',
- dataIndex: 'lastname',
- key: 'lastname',
- },
- {
- title: 'Email',
- dataIndex: 'emailAddress',
- key: 'emailAddress',
- },
- {
- title: 'View',
- dataIndex: 'username',
- key: 'roles',
- render: (username) =>
-
- this.fetchRoles(username)}>Roles
- Devices
-
- },
- {
- title: 'Action',
- dataIndex: 'id',
- key: 'action',
- render: (id, row) => (
-
-
-
- ),
- },
-
- ];
- return (
+ render() {
+ const { data, pagination, loading } = this.state;
+ const columns = [
+ {
+ title: 'User Name',
+ dataIndex: 'username',
+ key: 'username',
+ },
+ {
+ title: 'First Name',
+ dataIndex: 'firstname',
+ key: 'firstname',
+ },
+ {
+ title: 'Last Name',
+ dataIndex: 'lastname',
+ key: 'lastname',
+ },
+ {
+ title: 'Email',
+ dataIndex: 'emailAddress',
+ key: 'emailAddress',
+ },
+ {
+ title: 'View',
+ dataIndex: 'username',
+ key: 'roles',
+ render: username => (
+
+ this.fetchRoles(username)}
+ >
+ Roles
+
+
+ Devices
+
+
+ ),
+ },
+ {
+ title: 'Action',
+ dataIndex: 'id',
+ key: 'action',
+ render: (id, row) => (
+
+
+
+ ),
+ },
+ ];
+ return (
+
+
+
+
+
+
+
record.username}
+ dataSource={data}
+ pagination={{
+ ...pagination,
+ size: 'small',
+ // position: "top",
+ showTotal: (total, range) =>
+ `showing ${range[0]}-${range[1]} of ${total} groups`,
+ // showQuickJumper: true
+ }}
+ loading={loading}
+ onChange={this.handleTableChange}
+ rowSelection={this.rowSelection}
+ />
+
+
+
-
-
-
-
-
-
(record.username)}
- dataSource={data}
- pagination={{
- ...pagination,
- size: "small",
- // position: "top",
- showTotal: (total, range) => `showing ${range[0]}-${range[1]} of ${total} groups`
- // showQuickJumper: true
- }}
- loading={loading}
- onChange={this.handleTableChange}
- rowSelection={this.rowSelection}
- />
-
-
-
-
+ {item} }
+ />
- );
- }
+
+
+
+
+
+ );
+ }
}
export default withConfigContext(UsersTable);
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Utils/Filter/Filter.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Utils/Filter/Filter.js
index 40b331c39a..44a148ea41 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Utils/Filter/Filter.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Utils/Filter/Filter.js
@@ -1,41 +1,38 @@
-import React from "react";
+import React from 'react';
-import {Form, Icon, Input, Button} from 'antd';
-
-const hasErrors = (fieldsError) => {
- return Object.keys(fieldsError).some(field => fieldsError[field]);
-};
+import { Form, Input, Button } from 'antd';
class HorizontalLoginForm extends React.Component {
- handleSubmit = e => {
- e.preventDefault();
- this.props.form.validateFields((err, values) => {
- if (!err) {
- Object.keys(values).forEach(key => values[key] === undefined && delete values[key]);
- this.props.callback({},values);
- }
- });
- };
-
- render() {
- const {getFieldDecorator} = this.props.form;
-
-
- return (
-
- {getFieldDecorator(field.name)(
- ,
- )}
-
- ))}
-
-
-
-
+ handleSubmit = e => {
+ e.preventDefault();
+ this.props.form.validateFields((err, values) => {
+ if (!err) {
+ Object.keys(values).forEach(
+ key => values[key] === undefined && delete values[key],
);
- }
+ this.props.callback({}, values);
+ }
+ });
+ };
+
+ render() {
+ const { getFieldDecorator } = this.props.form;
+
+ return (
+
+ {getFieldDecorator(field.name)(
+ ,
+ )}
+
+ ))}
+
+
+
+
+ );
+ }
}
-export default Form.create({name: 'horizontal_login'})(HorizontalLoginForm);
+export default Form.create({ name: 'horizontal_login' })(HorizontalLoginForm);
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/context/ConfigContext.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/context/ConfigContext.js
index ea680a4cc5..e79fea42fd 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/context/ConfigContext.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/context/ConfigContext.js
@@ -16,19 +16,19 @@
* under the License.
*/
-import React from "react";
+import React from 'react';
const ConfigContext = React.createContext();
export const withConfigContext = Component => {
- return props => (
-
- {context => {
- return ;
- }}
-
- );
+ // eslint-disable-next-line react/display-name
+ return props => (
+
+ {context => {
+ return ;
+ }}
+
+ );
};
export default ConfigContext;
-
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 2f9c0179d3..066f770975 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
@@ -19,119 +19,117 @@
import React from 'react';
import ReactDOM from 'react-dom';
import * as serviceWorker from './serviceWorker';
-import App from "./App";
-import Login from "./pages/Login";
-import Dashboard from "./pages/Dashboard/Dashboard";
+import App from './App';
+import Login from './pages/Login';
+import Dashboard from './pages/Dashboard/Dashboard';
import './index.css';
-import Devices from "./pages/Dashboard/Devices/Devices";
-import Reports from "./pages/Dashboard/Reports/Reports";
-import Geo from "./pages/Dashboard/Geo/Geo";
-import Groups from "./pages/Dashboard/Groups/Groups";
-import Users from "./pages/Dashboard/Users/Users";
-import Policies from "./pages/Dashboard/Policies/Policies";
-import Roles from "./pages/Dashboard/Roles/Roles";
-import DeviceTypes from "./pages/Dashboard/DeviceTypes/DeviceTypes";
-import DeviceEnroll from "./pages/Dashboard/Devices/DeviceEnroll";
-import AddNewPolicy from "./pages/Dashboard/Policies/AddNewPolicy";
-import Certificates from "./pages/Dashboard/Configurations/Certificates/Certificates";
-import ReportDurationItemList from "./pages/Dashboard/Reports/ReportDurationItemList";
-import EnrollmentsVsUnenrollmentsReport from "./components/Reports/Templates/EnrollmentsVsUnenrollmentsReport";
-import EnrollmentTypeReport from "./components/Reports/Templates/EnrollmentTypeReport";
+import Devices from './pages/Dashboard/Devices/Devices';
+import Reports from './pages/Dashboard/Reports/Reports';
+import Geo from './pages/Dashboard/Geo/Geo';
+import Groups from './pages/Dashboard/Groups/Groups';
+import Users from './pages/Dashboard/Users/Users';
+import Policies from './pages/Dashboard/Policies/Policies';
+import Roles from './pages/Dashboard/Roles/Roles';
+import DeviceTypes from './pages/Dashboard/DeviceTypes/DeviceTypes';
+import DeviceEnroll from './pages/Dashboard/Devices/DeviceEnroll';
+import AddNewPolicy from './pages/Dashboard/Policies/AddNewPolicy';
+import Certificates from './pages/Dashboard/Configurations/Certificates/Certificates';
+import ReportDurationItemList from './pages/Dashboard/Reports/ReportDurationItemList';
+import EnrollmentsVsUnenrollmentsReport from './components/Reports/Templates/EnrollmentsVsUnenrollmentsReport';
+import EnrollmentTypeReport from './components/Reports/Templates/EnrollmentTypeReport';
+import DeviceStatusReport from './components/Reports/Templates/DeviceStatusReport';
const routes = [
- {
- path: '/entgra/login',
+ {
+ path: '/entgra/login',
+ exact: true,
+ component: Login,
+ },
+ {
+ path: '/entgra',
+ exact: false,
+ component: Dashboard,
+ routes: [
+ {
+ path: '/entgra/devices',
+ component: Devices,
exact: true,
- component: Login
- },
- {
- path: '/entgra',
- exact: false,
- component: Dashboard,
- routes: [
- {
- path: '/entgra/devices',
- component: Devices,
- exact: true
- },
- {
- path: '/entgra/devices/enroll',
- component: DeviceEnroll,
- exact: true
- },
- {
- path: '/entgra/geo',
- component: Geo,
- exact: true
- },
- {
- path: '/entgra/reports',
- component: Reports,
- exact: true
- },
- {
- path: '/entgra/groups',
- component: Groups,
- exact: true
- },
- {
- path: '/entgra/users',
- component: Users,
- exact: true
- },
- {
- path: '/entgra/policies',
- component: Policies,
- exact: true
- },
- {
- path: '/entgra/policy/add',
- component: AddNewPolicy,
- exact: true
- },
- {
- path: '/entgra/roles',
- component: Roles,
- exact: true
- },
- {
- path: '/entgra/devicetypes',
- component: DeviceTypes,
- exact: true
- },
- {
- path: '/entgra/certificates',
- component: Certificates,
- exact: true
- },
- {
- path: '/entgra/reportList',
- component: ReportDurationItemList,
- exact: true
- },
- {
- path: '/entgra/enrollmentsvsunenrollments',
- component: EnrollmentsVsUnenrollmentsReport,
- exact: true
- },
- {
- path: '/entgra/enrollmenttype',
- component: EnrollmentTypeReport,
- exact: true
- },
- {
- path: '/entgra/devicestatus',
- component: DeviceStatusReport,
- exact: true
- }
- ]
- }
+ },
+ {
+ path: '/entgra/devices/enroll',
+ component: DeviceEnroll,
+ exact: true,
+ },
+ {
+ path: '/entgra/geo',
+ component: Geo,
+ exact: true,
+ },
+ {
+ path: '/entgra/reports',
+ component: Reports,
+ exact: true,
+ },
+ {
+ path: '/entgra/groups',
+ component: Groups,
+ exact: true,
+ },
+ {
+ path: '/entgra/users',
+ component: Users,
+ exact: true,
+ },
+ {
+ path: '/entgra/policies',
+ component: Policies,
+ exact: true,
+ },
+ {
+ path: '/entgra/policy/add',
+ component: AddNewPolicy,
+ exact: true,
+ },
+ {
+ path: '/entgra/roles',
+ component: Roles,
+ exact: true,
+ },
+ {
+ path: '/entgra/devicetypes',
+ component: DeviceTypes,
+ exact: true,
+ },
+ {
+ path: '/entgra/certificates',
+ component: Certificates,
+ exact: true,
+ },
+ {
+ path: '/entgra/reportList',
+ component: ReportDurationItemList,
+ exact: true,
+ },
+ {
+ path: '/entgra/enrollmentsvsunenrollments',
+ component: EnrollmentsVsUnenrollmentsReport,
+ exact: true,
+ },
+ {
+ path: '/entgra/enrollmenttype',
+ component: EnrollmentTypeReport,
+ exact: true,
+ },
+ {
+ path: '/entgra/devicestatus',
+ component: DeviceStatusReport,
+ exact: true,
+ },
+ ],
+ },
];
-
-ReactDOM.render(
- ,
- document.getElementById('root'));
+ReactDOM.render( , document.getElementById('root'));
// If you want your app e and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Configurations/Certificates/Certificates.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Configurations/Certificates/Certificates.js
index 6b06ef7eb5..2e636e860b 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Configurations/Certificates/Certificates.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Configurations/Certificates/Certificates.js
@@ -16,52 +16,48 @@
* under the License.
*/
-import React from "react";
-import {
- PageHeader,
- Typography,
- Breadcrumb,
- Icon,
-} from "antd";
-import {Link} from "react-router-dom";
-import DeviceTable from "../../../../components/Devices/DevicesTable";
-import CertificateTable from "../../../../components/Configurations/Certificates/CertificateTable";
+import React from 'react';
+import { PageHeader, Typography, Breadcrumb, Icon } from 'antd';
+import { Link } from 'react-router-dom';
+import CertificateTable from '../../../../components/Configurations/Certificates/CertificateTable';
-const {Paragraph} = Typography;
+const { Paragraph } = Typography;
class Certificates extends React.Component {
- routes;
+ routes;
- constructor(props) {
- super(props);
- this.routes = props.routes;
- }
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ }
- render() {
- return (
-
-
-
-
- Home
-
- Configurations
- Certificates
-
-
-
Certificates
-
Certificate configurations
-
-
-
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Configurations
+ Certificates
+
+
+
Certificates
+
Certificate configurations
+
+
+
+
+
+
+
+ );
+ }
}
export default Certificates;
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 acd3a9df1c..ec413b1c2a 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
@@ -16,193 +16,197 @@
* under the License.
*/
-import React from "react";
-import {Layout, Menu, Icon} from 'antd';
-import {Switch, Link} from "react-router-dom";
-import RouteWithSubRoutes from "../../components/RouteWithSubRoutes"
-import {Redirect} from 'react-router'
-import "./Dashboard.css";
-import {withConfigContext} from "../../context/ConfigContext";
-import Logout from "./Logout/Logout";
+import React from 'react';
+import { Layout, Menu, Icon } from 'antd';
+import { Switch, Link } from 'react-router-dom';
+import RouteWithSubRoutes from '../../components/RouteWithSubRoutes';
+import { Redirect } from 'react-router';
+import './Dashboard.css';
+import { withConfigContext } from '../../context/ConfigContext';
+import Logout from './Logout/Logout';
-const {Header, Content, Footer, Sider} = Layout;
-const {SubMenu} = Menu;
+const { Header, Content, Footer } = Layout;
+const { SubMenu } = Menu;
class Dashboard extends React.Component {
- constructor(props) {
- super(props);
+ constructor(props) {
+ super(props);
- const mobileWidth = (window.innerWidth<=768 ? '0' : '80');
+ const mobileWidth = window.innerWidth <= 768 ? '0' : '80';
- this.state = {
- routes: props.routes,
- selectedKeys: [],
- deviceTypes: [],
- isNavBarCollapsed: false,
- mobileWidth
- };
- this.logo = this.props.context.theme.logo;
- this.config = this.props.context;
- }
-
- toggle = () => {
- console.log(this.config)
- this.setState({
- isNavBarCollapsed: !this.state.isNavBarCollapsed,
- });
+ this.state = {
+ routes: props.routes,
+ selectedKeys: [],
+ deviceTypes: [],
+ isNavBarCollapsed: false,
+ mobileWidth,
};
+ this.logo = this.props.context.theme.logo;
+ this.config = this.props.context;
+ }
- render() {
- return (
-
-
-
-
-
-
-
+ toggle = () => {
+ console.log(this.config);
+ this.setState({
+ isNavBarCollapsed: !this.state.isNavBarCollapsed,
+ });
+ };
-
-
-
- Devices
- }
- >
-
-
- View
-
-
-
-
- Enroll
-
-
-
-
-
- Geo
- }
- >
-
-
- Single Device View
-
-
-
-
- Device Group View
-
-
-
-
-
-
- Reports
-
-
-
-
-
- Groups
-
-
-
-
-
- Users
-
-
-
-
- Policies
- }
- >
-
-
- View
-
-
-
-
- Add New Policy
-
-
-
-
-
-
- Roles
-
-
-
-
-
- Device Types
-
-
-
-
- Configurations
- }
- >
-
-
- Certificates
-
-
-
-
-
-
-
- {this.config.user}
- }>
-
-
+ render() {
+ return (
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+ Devices
+
+ }
+ >
+
+
+ View
+
+
+
+
+ Enroll
+
+
+
+
+
+ Geo
+
+ }
+ >
+
+
+ Single Device View
+
+
+
+
+ Device Group View
+
+
+
+
+
+
+ Reports
+
+
+
+
+
+ Groups
+
+
+
+
+
+ Users
+
+
+
+
+ Policies
+
+ }
+ >
+
+
+ View
+
+
+
+
+ Add New Policy
+
+
+
+
+
+
+ Roles
+
+
+
+
+
+ Device Types
+
+
+
+
+ Configurations
+
+ }
+ >
+
+
+ Certificates
+
+
+
+
+
+
+ {this.config.user}
+
+ }
+ >
+
+
+
+
-
-
-
- {this.state.routes.map((route) => (
-
- ))}
-
-
+
+
+
+ {this.state.routes.map(route => (
+
+ ))}
+
+
-
-
-
-
-
- );
- }
+
+
+
+
+ );
+ }
}
export default withConfigContext(Dashboard);
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/DeviceTypes/DeviceTypes.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/DeviceTypes/DeviceTypes.js
index de9625bcc1..08e43f1254 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/DeviceTypes/DeviceTypes.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/DeviceTypes/DeviceTypes.js
@@ -16,50 +16,47 @@
* under the License.
*/
-import React from "react";
-import {
- PageHeader,
- Typography,
- Breadcrumb,
- Icon
-} from "antd";
-import {Link} from "react-router-dom";
-import DeviceTypesTable from "../../../components/DeviceTypes/DeviceTypesTable";
+import React from 'react';
+import { PageHeader, Typography, Breadcrumb, Icon } from 'antd';
+import { Link } from 'react-router-dom';
+import DeviceTypesTable from '../../../components/DeviceTypes/DeviceTypesTable';
-const {Paragraph} = Typography;
+const { Paragraph } = Typography;
class DeviceTypes extends React.Component {
- routes;
+ routes;
- constructor(props) {
- super(props);
- this.routes = props.routes;
- }
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ }
- render() {
- return (
-
-
-
-
- Home
-
- Device Types
-
-
-
Device Types
-
All device types for device management.
-
-
-
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Device Types
+
+
+
Device Types
+
All device types for device management.
+
+
+
+
+
+
+
+ );
+ }
}
export default DeviceTypes;
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Devices/DeviceEnroll.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Devices/DeviceEnroll.js
index 9d21aeda79..e33873ed8a 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Devices/DeviceEnroll.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Devices/DeviceEnroll.js
@@ -1,50 +1,47 @@
import React from 'react';
-import {
- PageHeader,
- Typography,
- Breadcrumb,
- Icon,
- Button, Select
-} from "antd";
-import {Link} from "react-router-dom";
-import AddDevice from "../../../components/Devices/AddDevice";
+import { PageHeader, Typography, Breadcrumb, Icon } from 'antd';
+import { Link } from 'react-router-dom';
+import AddDevice from '../../../components/Devices/AddDevice';
-const {Paragraph} = Typography;
+const { Paragraph } = Typography;
class DeviceEnroll extends React.Component {
- routes;
+ routes;
- constructor(props) {
- super(props);
- this.routes = props.routes;
- }
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ }
- render() {
- return (
-
-
-
-
- Home
-
- Devices
- Enroll Device
-
-
-
Devices
-
All enrolled devices
-
-
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+
+ Devices
+
+ Enroll Device
+
+
+
Devices
+
All enrolled devices
+
+
+
+
+
+ );
+ }
}
-export default DeviceEnroll;
\ No newline at end of file
+export default DeviceEnroll;
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
index 3adf87207c..5b22b10802 100644
--- 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
@@ -16,51 +16,47 @@
* under the License.
*/
-import React from "react";
-import {
- PageHeader,
- Typography,
- Breadcrumb,
- Icon,
- Button, Select
-} from "antd";
-import {Link} from "react-router-dom";
-import DeviceTable from "../../../components/Devices/DevicesTable";
+import React from 'react';
+import { PageHeader, Typography, Breadcrumb, Icon } from 'antd';
+import { Link } from 'react-router-dom';
+import DeviceTable from '../../../components/Devices/DevicesTable';
-const {Paragraph} = Typography;
+const { Paragraph } = Typography;
class Devices extends React.Component {
- routes;
+ routes;
- constructor(props) {
- super(props);
- this.routes = props.routes;
- }
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ }
- render() {
- return (
-
-
-
-
- Home
-
- Devices
-
-
-
Devices
-
All enrolled devices
-
-
-
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Devices
+
+
+
Devices
+
All enrolled devices
+
+
+
+
+
+
+
+ );
+ }
}
export default Devices;
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Geo/Geo.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Geo/Geo.js
index f40df4ffc3..501aee429d 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Geo/Geo.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Geo/Geo.js
@@ -16,49 +16,51 @@
* under the License.
*/
-import React from "react";
-import {
- PageHeader,
- Typography,
- Breadcrumb,
- Icon,
- Card
-} from "antd";
-import {Link} from "react-router-dom";
-import GeoDashboard from "../../../components/Geo/geo-dashboard/GeoDashboard";
+import React from 'react';
+import { PageHeader, Typography, Breadcrumb, Icon } from 'antd';
+import { Link } from 'react-router-dom';
+import GeoDashboard from '../../../components/Geo/geo-dashboard/GeoDashboard';
-const {Paragraph} = Typography;
+const { Paragraph } = Typography;
class Geo extends React.Component {
- routes;
+ routes;
- constructor(props) {
- super(props);
- this.routes = props.routes;
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ }
- }
-
- render() {
- return (
-
-
-
-
- Home
-
- Geo
-
-
-
Geo
-
Geo Location Service
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Geo
+
+
+
Geo
+
Geo Location Service
+
+
+
+
+
+
+ );
+ }
}
export default Geo;
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Groups/Groups.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Groups/Groups.js
index 7f588e1d94..2da536e691 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Groups/Groups.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Groups/Groups.js
@@ -16,47 +16,44 @@
* under the License.
*/
-import React from "react";
-import {
- PageHeader,
- Typography,
- Breadcrumb,
- Icon
-} from "antd";
-import {Link} from "react-router-dom";
-import GroupsTable from "../../../components/Groups/GroupsTable";
+import React from 'react';
+import { PageHeader, Typography, Breadcrumb, Icon } from 'antd';
+import { Link } from 'react-router-dom';
+import GroupsTable from '../../../components/Groups/GroupsTable';
-const {Paragraph} = Typography;
+const { Paragraph } = Typography;
class Groups extends React.Component {
- routes;
+ routes;
- constructor(props) {
- super(props);
- this.routes = props.routes;
- }
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ }
- render() {
- return (
-
-
-
-
- Home
-
- Groups
-
-
-
Groups
-
All device groups.
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Groups
+
+
+
Groups
+
All device groups.
+
+
+
+
+
+
+ );
+ }
}
export default Groups;
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 3a011b9169..68171c447e 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
@@ -16,65 +16,66 @@
* under the License.
*/
-import React from "react";
-import {notification, Menu, Icon} from 'antd';
+import React from 'react';
+import { notification, Menu, Icon } from 'antd';
import axios from 'axios';
-import {withConfigContext} from "../../../context/ConfigContext";
+import { withConfigContext } from '../../../context/ConfigContext';
/*
This class for call the logout api by sending request
*/
class Logout extends React.Component {
-
- constructor(props) {
- super(props);
- this.state = {
- inValid: false,
- loading: false
- };
- }
- /*
+ constructor(props) {
+ super(props);
+ this.state = {
+ inValid: false,
+ loading: false,
+ };
+ }
+ /*
This function call the logout api when the request is success
*/
- handleSubmit = () => {
+ handleSubmit = () => {
+ const thisForm = this;
+ const config = this.props.context;
- const thisForm = this;
- const config = this.props.context;
+ thisForm.setState({
+ inValid: false,
+ });
- thisForm.setState({
- inValid: false
- });
+ axios
+ .post(window.location.origin + config.serverConfig.logoutUri)
+ .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 + '/entgra/login';
+ }
+ })
+ .catch(function(error) {
+ if (error.hasOwnProperty('response') && error.response.status === 400) {
+ thisForm.setState({
+ inValid: true,
+ });
+ } else {
+ notification.error({
+ message: 'There was a problem',
+ duration: 0,
+ description: 'Error occurred while trying to logout.',
+ });
+ }
+ });
+ };
- axios.post(window.location.origin + config.serverConfig.logoutUri
- ).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 + "/entgra/login";
- }
- }).catch(function (error) {
-
- if (error.hasOwnProperty("response") && error.response.status === 400) {
- thisForm.setState({
- inValid: true
- });
- } else {
- notification["error"]({
- message: "There was a problem",
- duration: 0,
- description:
- "Error occurred while trying to logout.",
- });
- }
- });
- };
-
- render() {
- return (
-
- Logout
-
- );
- }
+ render() {
+ return (
+
+
+
+ Logout
+
+
+ );
+ }
}
export default withConfigContext(Logout);
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Policies/AddNewPolicy.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Policies/AddNewPolicy.js
index 980c7bf647..96d149478a 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Policies/AddNewPolicy.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Policies/AddNewPolicy.js
@@ -16,50 +16,47 @@
* under the License.
*/
-import React from "react";
-import {
- PageHeader,
- Typography,
- Breadcrumb,
- Icon
-} from "antd";
-import {Link} from "react-router-dom";
-import AddPolicy from "../../../components/Policies/AddPolicy";
+import React from 'react';
+import { PageHeader, Typography, Breadcrumb, Icon } from 'antd';
+import { Link } from 'react-router-dom';
+import AddPolicy from '../../../components/Policies/AddPolicy';
-const {Paragraph} = Typography;
+const { Paragraph } = Typography;
class AddNewPolicy extends React.Component {
- routes;
+ routes;
- constructor(props) {
- super(props);
- this.routes = props.routes;
- }
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ }
- render() {
- return (
-
-
-
-
- Home
-
- Policies
-
-
-
Policies
-
Create new policy on IoT Server.
-
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Policies
+
+
+
Policies
+
Create new policy on IoT Server.
+
+
+
+
+
+ );
+ }
}
export default AddNewPolicy;
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Policies/Policies.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Policies/Policies.js
index 66286a2014..738a6a1630 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Policies/Policies.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Policies/Policies.js
@@ -16,50 +16,47 @@
* under the License.
*/
-import React from "react";
-import {
- PageHeader,
- Typography,
- Breadcrumb,
- Icon
-} from "antd";
-import {Link} from "react-router-dom";
-import PoliciesTable from "../../../components/Policies/PoliciesTable";
+import React from 'react';
+import { PageHeader, Typography, Breadcrumb, Icon } from 'antd';
+import { Link } from 'react-router-dom';
+import PoliciesTable from '../../../components/Policies/PoliciesTable';
-const {Paragraph} = Typography;
+const { Paragraph } = Typography;
class Policies extends React.Component {
- routes;
+ routes;
- constructor(props) {
- super(props);
- this.routes = props.routes;
- }
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ }
- render() {
- return (
-
-
-
-
- Home
-
- Policies
-
-
-
Policies
-
All policies for device management
-
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Policies
+
+
+
Policies
+
All policies for device management
+
+
+
+
+
+ );
+ }
}
export default Policies;
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Reports/ReportDurationItemList.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Reports/ReportDurationItemList.js
index 13804d845e..36ef714646 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Reports/ReportDurationItemList.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Reports/ReportDurationItemList.js
@@ -16,137 +16,181 @@
* under the License.
*/
-import React from "react";
-import {
- Icon,
- Col,
- Row, Select,
- Radio, Card,
- Button
-} from "antd";
+import React from 'react';
+import { Icon, Col, Row, Card } from 'antd';
-import {Link} from "react-router-dom";
-import moment from "moment";
-
-
-const { Option } = Select;
+import { Link } from 'react-router-dom';
+import moment from 'moment';
class ReportDurationItemList extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ reportParams: ['ACTIVE', 'INACTIVE', 'REMOVED'],
+ enrollmentsVsUnenrollmentsParams: ['Enrollments', 'Unenrollments'],
+ enrollmentTypeParams: ['BYOD', 'COPE'],
+ };
+ }
- constructor(props) {
- super(props);
- this.state = {
- reportParams:["ACTIVE","INACTIVE","REMOVED"],
- enrollmentsVsUnenrollmentsParams:["Enrollments", "Unenrollments"],
- enrollmentTypeParams:["BYOD", "COPE"]
- }
- }
+ durationItemArray = [
+ {
+ name: 'Daily Report',
+ description: 'Enrollments of today',
+ duration: [
+ moment().format('YYYY-MM-DD'),
+ moment()
+ .add(1, 'days')
+ .format('YYYY-MM-DD'),
+ ],
+ },
+ {
+ name: 'Weekly Report',
+ description: 'Enrollments of last 7 days',
+ duration: [
+ moment()
+ .subtract(6, 'days')
+ .format('YYYY-MM-DD'),
+ moment()
+ .add(1, 'days')
+ .format('YYYY-MM-DD'),
+ ],
+ },
+ {
+ name: 'Monthly Report',
+ description: 'Enrollments of last month',
+ duration: [
+ moment()
+ .subtract(29, 'days')
+ .format('YYYY-MM-DD'),
+ moment()
+ .add(1, 'days')
+ .format('YYYY-MM-DD'),
+ ],
+ },
+ ];
- durationItemArray = [
- {name:"Daily Report", description:"Enrollments of today", duration:[moment().format('YYYY-MM-DD'), moment().add(1, 'days').format('YYYY-MM-DD')]},
- {name:"Weekly Report", description:"Enrollments of last 7 days", duration:[moment().subtract(6, 'days').format('YYYY-MM-DD'), moment().add(1, 'days').format('YYYY-MM-DD')]},
- {name:"Monthly Report", description:"Enrollments of last month", duration:[moment().subtract(29, 'days').format('YYYY-MM-DD'), moment().add(1, 'days').format('YYYY-MM-DD')]}]
-
-
- render(){
-
- let itemStatus = this.durationItemArray.map((data) =>
-
-
-
-
-
-
-
{data.name}
-
{data.description}
- {/*
{data.duration}
*/}
-
-
-
-
- );
-
- let itemEnrollmentsVsUnenrollments = this.durationItemArray.map((data) =>
-
-
-
-
-
-
-
{data.name}
-
{data.description}
-
-
-
-
- );
-
- let itemEnrollmentType = this.durationItemArray.map((data) =>
-
-
-
-
-
-
-
{data.name}
-
{data.description}
-
-
-
-
- );
- return(
-
-
-
- {itemStatus}
-
-
-
-
-
- {itemEnrollmentsVsUnenrollments}
-
-
-
-
-
- {itemEnrollmentType}
-
-
+ render() {
+ let itemStatus = this.durationItemArray.map(data => (
+
+
+
+
+
+
+ {data.name}
+
+
{data.description}
+ {/*
{data.duration}
*/}
- )
- }
+
+
+
+ ));
+
+ let itemEnrollmentsVsUnenrollments = this.durationItemArray.map(data => (
+
+
+
+
+
+
+ {data.name}
+
+
{data.description}
+
+
+
+
+ ));
+
+ let itemEnrollmentType = this.durationItemArray.map(data => (
+
+
+
+
+
+
+ {data.name}
+
+
{data.description}
+
+
+
+
+ ));
+ return (
+
+
+ {itemStatus}
+
+
+
+ {itemEnrollmentsVsUnenrollments}
+
+
+
+ {itemEnrollmentType}
+
+
+ );
+ }
}
-export default ReportDurationItemList;
\ No newline at end of file
+export default ReportDurationItemList;
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Reports/Reports.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Reports/Reports.js
index 17abf992f7..8f2eac48b6 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Reports/Reports.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Reports/Reports.js
@@ -16,80 +16,69 @@
* under the License.
*/
-import React from "react";
-import {
- PageHeader,
- Typography,
- Breadcrumb,
- Icon
-} from "antd";
-import {Link} from "react-router-dom";
-import ReportDurationItemList from "./ReportDurationItemList";
-
-const {Paragraph} = Typography;
+import React from 'react';
+import { PageHeader, Breadcrumb, Icon } from 'antd';
+import { Link } from 'react-router-dom';
+import ReportDurationItemList from './ReportDurationItemList';
class Reports extends React.Component {
- routes;
+ routes;
- constructor(props) {
- super(props);
- this.routes = props.routes;
- this.state = {
- paramsObject:{},
- }
- }
- //Get modified value from datepicker and set it to paramsObject
- updateDurationValue = (modifiedFromDate,modifiedToDate) => {
- let tempParamObj = this.state.paramsObject;
- tempParamObj.from = modifiedFromDate;
- tempParamObj.to = modifiedToDate;
- this.setState({paramsObject:tempParamObj});
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ this.state = {
+ paramsObject: {},
};
+ }
+ // Get modified value from datepicker and set it to paramsObject
+ updateDurationValue = (modifiedFromDate, modifiedToDate) => {
+ let tempParamObj = this.state.paramsObject;
+ tempParamObj.from = modifiedFromDate;
+ tempParamObj.to = modifiedToDate;
+ this.setState({ paramsObject: tempParamObj });
+ };
- //Get modified value from filters and set it to paramsObject
- updateFiltersValue = (modifiedValue,filterType) => {
- let tempParamObj = this.state.paramsObject;
- if(filterType=="Device Status"){
- tempParamObj.status = modifiedValue;
- if(modifiedValue=="ALL" && tempParamObj.status){
- delete tempParamObj.status;
- }
- }else{
- tempParamObj.ownership = modifiedValue;
- if(modifiedValue=="ALL" && tempParamObj.ownership){
- delete tempParamObj.ownership;
- }
- }
- this.setState({paramsObject:tempParamObj});
- };
-
- render() {
- //Arrays for filters
- const statusObj = ['ALL','ACTIVE','INACTIVE','REMOVED'];
- const ownershipObj = ['ALL','BYOD','COPE'];
-
- const params = {...this.state.paramsObject};
-
- return (
-
-
-
-
- Home
-
- Reports
-
-
-
Reports
-
-
-
-
-
-
-
- );
+ // Get modified value from filters and set it to paramsObject
+ updateFiltersValue = (modifiedValue, filterType) => {
+ let tempParamObj = this.state.paramsObject;
+ if (filterType == 'Device Status') {
+ tempParamObj.status = modifiedValue;
+ if (modifiedValue == 'ALL' && tempParamObj.status) {
+ delete tempParamObj.status;
+ }
+ } else {
+ tempParamObj.ownership = modifiedValue;
+ if (modifiedValue == 'ALL' && tempParamObj.ownership) {
+ delete tempParamObj.ownership;
+ }
}
+ this.setState({ paramsObject: tempParamObj });
+ };
+
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Reports
+
+
+
Reports
+
+
+
+
+
+ );
+ }
}
export default Reports;
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Roles/Roles.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Roles/Roles.js
index 25e64fc5d7..27b62efec8 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Roles/Roles.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Roles/Roles.js
@@ -16,47 +16,44 @@
* under the License.
*/
-import React from "react";
-import {
- PageHeader,
- Typography,
- Breadcrumb,
- Icon
-} from "antd";
-import {Link} from "react-router-dom";
-import RolesTable from "../../../components/Roles/RolesTable";
+import React from 'react';
+import { PageHeader, Typography, Breadcrumb, Icon } from 'antd';
+import { Link } from 'react-router-dom';
+import RolesTable from '../../../components/Roles/RolesTable';
-const {Paragraph} = Typography;
+const { Paragraph } = Typography;
class Roles extends React.Component {
- routes;
+ routes;
- constructor(props) {
- super(props);
- this.routes = props.routes;
- }
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ }
- render() {
- return (
-
-
-
-
- Home
-
- Roles
-
-
-
Roles
-
All user roles
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Roles
+
+
+
Roles
+
All user roles
+
+
+
+
+
+
+ );
+ }
}
export default Roles;
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Users/Users.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Users/Users.js
index c1f545e675..bd4fada853 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Users/Users.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Users/Users.js
@@ -16,48 +16,45 @@
* under the License.
*/
-import React from "react";
-import {
- PageHeader,
- Typography,
- Breadcrumb,
- Icon
-} from "antd";
-import {Link} from "react-router-dom";
-import UsersTable from "../../../components/Users/UsersTable";
+import React from 'react';
+import { PageHeader, Typography, Breadcrumb, Icon } from 'antd';
+import { Link } from 'react-router-dom';
+import UsersTable from '../../../components/Users/UsersTable';
-const {Paragraph} = Typography;
+const { Paragraph } = Typography;
class Users extends React.Component {
- routes;
+ routes;
- constructor(props) {
- super(props);
- this.routes = props.routes;
- }
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ }
- render() {
- return (
-
-
-
-
- Home
-
- Users
-
-
-
Users
-
All users for device management.
-
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Users
+
+
+
Users
+
All users for device management.
+
+
+
+
+
+ );
+ }
}
export default Users;
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 8ecd514fd4..2c174429dd 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
@@ -16,161 +16,180 @@
* under the License.
*/
-import React from "react";
-import {Typography, Row, Col, Form, Icon, Input, Button, Checkbox} from 'antd';
+import React from 'react';
+import {
+ Typography,
+ Row,
+ Col,
+ Form,
+ Icon,
+ Input,
+ Button,
+ Checkbox,
+} from 'antd';
import './Login.css';
import axios from 'axios';
-import {withConfigContext} from "../context/ConfigContext";
+import { withConfigContext } from '../context/ConfigContext';
-const {Title} = Typography;
-const {Text} = Typography;
+const { Title } = Typography;
+const { Text } = Typography;
class Login extends React.Component {
- render() {
- const config = this.props.context;
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Login
-
-
-
-
-
-
-
-
-
-
-
-
- );
- }
+ render() {
+ const config = this.props.context;
+ return (
+
+
+
+
+
+
+
+
+
+
+
+ Login
+
+
+
+
+
+
+
+
+ );
+ }
}
class NormalLoginForm extends React.Component {
-
- constructor(props) {
- super(props);
- this.state = {
- inValid: false,
- loading: false
- };
- }
-
- handleSubmit = (e) => {
- const thisForm = this;
- const config = this.props.context;
- console.log(config);
-
- e.preventDefault();
- this.props.form.validateFields((err, values) => {
- thisForm.setState({
- inValid: false
- });
- if (!err) {
- thisForm.setState({
- loading: true
- });
- const parameters = {
- username: values.username,
- password: values.password,
- platform: "entgra"
- };
-
- const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&');
-
- axios.post(window.location.origin+ config.serverConfig.loginUri, request
- ).then(res => {
- if (res.status === 200) {
- let redirectUrl = window.location.origin + "/entgra";
- const searchParams = new URLSearchParams(window.location.search);
- if (searchParams.has("redirect")) {
- redirectUrl = searchParams.get("redirect");
- }
- window.location = redirectUrl;
- }
- }).catch(function (error) {
- if (error.response.status === 400) {
- thisForm.setState({
- inValid: true,
- loading: false
- });
- }
- });
- }
-
- });
+ constructor(props) {
+ super(props);
+ this.state = {
+ inValid: false,
+ loading: false,
};
+ }
- render() {
- const {getFieldDecorator} = this.props.form;
- let errorMsg = "";
- if (this.state.inValid) {
- errorMsg =
Invalid Login Details ;
- }
- let loading = "";
- if (this.state.loading) {
- loading =
Loading.. ;
- }
- return (
-
- {getFieldDecorator('username', {
- rules: [{required: true, message: 'Please input your username!'}],
- })(
- }
- placeholder="Username"/>
- )}
-
-
- {getFieldDecorator('password', {
- rules: [{required: true, message: 'Please input your Password!'}],
- })(
- } type="password"
- placeholder="Password"/>
- )}
-
- {loading}
- {errorMsg}
-
- {getFieldDecorator('remember', {
- valuePropName: 'checked',
- initialValue: true,
- })(
- Remember me
- )}
-
- Forgot password
-
- Log in
-
-
-
- );
+ handleSubmit = e => {
+ const thisForm = this;
+ const config = this.props.context;
+ console.log(config);
+
+ e.preventDefault();
+ this.props.form.validateFields((err, values) => {
+ thisForm.setState({
+ inValid: false,
+ });
+ if (!err) {
+ thisForm.setState({
+ loading: true,
+ });
+ const parameters = {
+ username: values.username,
+ password: values.password,
+ platform: 'entgra',
+ };
+
+ const request = Object.keys(parameters)
+ .map(key => key + '=' + parameters[key])
+ .join('&');
+
+ axios
+ .post(window.location.origin + config.serverConfig.loginUri, request)
+ .then(res => {
+ if (res.status === 200) {
+ let redirectUrl = window.location.origin + '/entgra';
+ const searchParams = new URLSearchParams(window.location.search);
+ if (searchParams.has('redirect')) {
+ redirectUrl = searchParams.get('redirect');
+ }
+ window.location = redirectUrl;
+ }
+ })
+ .catch(function(error) {
+ if (error.response.status === 400) {
+ thisForm.setState({
+ inValid: true,
+ loading: false,
+ });
+ }
+ });
+ }
+ });
+ };
+
+ render() {
+ const { getFieldDecorator } = this.props.form;
+ let errorMsg = '';
+ if (this.state.inValid) {
+ errorMsg =
Invalid Login Details ;
}
+ let loading = '';
+ if (this.state.loading) {
+ loading =
Loading.. ;
+ }
+ return (
+
+ {getFieldDecorator('username', {
+ rules: [{ required: true, message: 'Please input your username!' }],
+ })(
+ }
+ placeholder="Username"
+ />,
+ )}
+
+
+ {getFieldDecorator('password', {
+ rules: [{ required: true, message: 'Please input your Password!' }],
+ })(
+ }
+ type="password"
+ placeholder="Password"
+ />,
+ )}
+
+ {loading}
+ {errorMsg}
+
+ {getFieldDecorator('remember', {
+ valuePropName: 'checked',
+ initialValue: true,
+ })(Remember me )}
+
+
+ Forgot password
+
+
+ Log in
+
+
+
+ );
+ }
}
-const WrappedNormalLoginForm = withConfigContext(Form.create({name: 'normal_login'})(NormalLoginForm));
+const WrappedNormalLoginForm = withConfigContext(
+ Form.create({ name: 'normal_login' })(NormalLoginForm),
+);
export default withConfigContext(Login);
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/serviceWorker.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/serviceWorker.js
index 249177c0b0..da52a982ac 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/serviceWorker.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/serviceWorker.js
@@ -34,8 +34,8 @@ const isLocalhost = Boolean(
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
- /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
- )
+ /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,
+ ),
);
export function register(config) {
@@ -61,7 +61,7 @@ export function register(config) {
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
- 'worker. To learn more, visit https://bit.ly/CRA-PWA'
+ 'worker. To learn more, visit https://bit.ly/CRA-PWA',
);
});
} else {
@@ -89,7 +89,7 @@ function registerValidSW(swUrl, config) {
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
- 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
+ 'tabs for this page are closed. See https://bit.ly/CRA-PWA.',
);
// Execute callback
@@ -139,7 +139,7 @@ function checkValidServiceWorker(swUrl, config) {
})
.catch(() => {
console.log(
- 'No internet connection found. App is running in offline mode.'
+ 'No internet connection found. App is running in offline mode.',
);
});
}
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 1634ada184..23dcee5927 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
@@ -16,119 +16,119 @@
* under the License.
*/
var path = require('path');
-const HtmlWebPackPlugin = require("html-webpack-plugin");
-const MiniCssExtractPlugin = require("mini-css-extract-plugin");
-const configurations = require("./public/conf/config.json");
+const HtmlWebPackPlugin = require('html-webpack-plugin');
+const MiniCssExtractPlugin = require('mini-css-extract-plugin');
+const configurations = require('./public/conf/config.json');
const config = {
- devtool: "source-map",
- output: {
- publicPath: '/entgra/'
+ devtool: 'source-map',
+ output: {
+ publicPath: '/entgra/',
+ },
+ watch: false,
+ resolve: {
+ alias: {
+ AppData: path.resolve(__dirname, 'source/src/app/common/'),
+ AppComponents: path.resolve(__dirname, 'source/src/app/components/'),
},
- watch: false,
- resolve: {
- alias: {
- AppData: path.resolve(__dirname, 'source/src/app/common/'),
- AppComponents: path.resolve(__dirname, 'source/src/app/components/')
- },
- extensions: ['.jsx', '.js', '.ttf', '.woff', '.woff2', '.svg']
- },
- module: {
- rules: [
- {
- test: /\.(js|jsx)$/,
- exclude: /node_modules/,
- use: [
- {
- loader: 'babel-loader'
- }
- ]
+ extensions: ['.jsx', '.js', '.ttf', '.woff', '.woff2', '.svg'],
+ },
+ module: {
+ rules: [
+ {
+ test: /\.(js|jsx)$/,
+ exclude: /node_modules/,
+ use: [
+ {
+ loader: 'babel-loader',
+ },
+ ],
+ },
+ {
+ test: /\.html$/,
+ use: [
+ {
+ loader: 'html-loader',
+ options: { minimize: true },
+ },
+ ],
+ },
+ {
+ test: /\.css$/,
+ use: [MiniCssExtractPlugin.loader, 'css-loader'],
+ },
+ {
+ test: /\.scss$/,
+ use: [
+ MiniCssExtractPlugin.loader,
+ 'css-loader',
+ 'postcss-loader',
+ 'sass-loader',
+ ],
+ },
+ {
+ test: /\.scss$/,
+ use: ['style-loader', 'scss-loader'],
+ },
+ {
+ test: /\.less$/,
+ use: [
+ {
+ loader: 'style-loader',
+ },
+ {
+ loader: 'css-loader',
+ },
+ {
+ loader: 'less-loader',
+ options: {
+ modifyVars: {
+ 'primary-color': configurations.theme.primaryColor,
+ 'link-color': configurations.theme.primaryColor,
+ },
+ javascriptEnabled: true,
},
- {
- test: /\.html$/,
- use: [
- {
- loader: "html-loader",
- options: { minimize: true }
- }
- ]
+ },
+ ],
+ },
+ {
+ test: /\.(woff|woff2|eot|ttf|svg)$/,
+ loader: 'url-loader?limit=100000',
+ },
+ {
+ test: /\.(png|jpe?g)/i,
+ use: [
+ {
+ loader: 'url-loader',
+ options: {
+ name: './img/[name].[ext]',
+ limit: 10000,
},
- {
- test: /\.css$/,
- use: [MiniCssExtractPlugin.loader, "css-loader"]
- },
- {
- test: /\.scss$/,
- use: [
- MiniCssExtractPlugin.loader,
- "css-loader",
- "postcss-loader",
- "sass-loader"
- ]
- },
- {
- test: /\.scss$/,
- use: [ 'style-loader', 'scss-loader' ]
- },
- {
- test: /\.less$/,
- use: [
- {
- loader: "style-loader"
- },
- {
- loader: "css-loader",
- },
- {
- loader: "less-loader",
- options: {
- modifyVars: {
- 'primary-color': configurations.theme.primaryColor,
- 'link-color': configurations.theme.primaryColor,
- },
- javascriptEnabled: true,
- },
- }
- ]
- },
- {
- test: /\.(woff|woff2|eot|ttf|svg)$/,
- loader: 'url-loader?limit=100000',
- },
- {
- test: /\.(png|jpe?g)/i,
- use: [
- {
- loader: "url-loader",
- options: {
- name: "./img/[name].[ext]",
- limit: 10000
- }
- },
- {
- loader: "img-loader"
- }
- ]
- }
- ]
- },
- plugins: [
- new HtmlWebPackPlugin({
- template: "./src/index.html",
- filename: "./index.html"
- }),
- new MiniCssExtractPlugin({
- filename: "[name].css",
- chunkFilename: "[id].css"
- })
+ },
+ {
+ loader: 'img-loader',
+ },
+ ],
+ },
],
- externals: {
- 'Config': JSON.stringify(require('./public/conf/config.json'))
- }
+ },
+ plugins: [
+ new HtmlWebPackPlugin({
+ template: './src/index.html',
+ filename: './index.html',
+ }),
+ new MiniCssExtractPlugin({
+ filename: '[name].css',
+ chunkFilename: '[id].css',
+ }),
+ ],
+ externals: {
+ Config: JSON.stringify(require('./public/conf/config.json')),
+ },
};
-if (process.env.NODE_ENV === "development") {
- config.watch = true;
+if (process.env.NODE_ENV === 'development') {
+ config.watch = true;
}
module.exports = config;