From fcf271e4d29cbfa2835d943c7b223b6fa778bbb8 Mon Sep 17 00:00:00 2001 From: Kaveesha Mihirangi Date: Fri, 13 Dec 2019 08:43:18 +0000 Subject: [PATCH] Generate UI component for profile configuration in Add Policy view using json --- .../src/components/Groups/GroupsTable.js | 8 +- .../src/components/Policies/AddPolicy.js | 34 +- .../components/Policies/ConfigureProfile.js | 526 ++--- .../src/components/Policies/SelectPlatform.js | 148 ++ .../src/components/Policies/configuration.js | 2084 +++++++++++++++++ .../src/pages/Dashboard/Policies/policies.css | 29 + 6 files changed, 2544 insertions(+), 285 deletions(-) create mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Policies/SelectPlatform.js create mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Policies/configuration.js create mode 100644 components/device-mgt/io.entgra.device.mgt.ui/react-app/src/pages/Dashboard/Policies/policies.css diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Groups/GroupsTable.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Groups/GroupsTable.js index cf782973b37..832552001b6 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Groups/GroupsTable.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Groups/GroupsTable.js @@ -119,7 +119,7 @@ class GroupsTable extends React.Component { const pagination = {...this.state.pagination}; this.setState({ loading: false, - data: res.data.data.deviceGroups, + data: res.data.data, pagination, }); } @@ -149,7 +149,7 @@ class GroupsTable extends React.Component { this.setState({ pagination: pager, }); - this.fetch({ + this.fetchGroups({ results: pagination.pageSize, page: pagination.current, sortField: sorter.field, @@ -171,11 +171,13 @@ class GroupsTable extends React.Component { (record.id)} - dataSource={data} + dataSource={data.deviceGroups} pagination={{ ...pagination, size: "small", // position: "top", + total: data.count, + pageSize: 2, showTotal: (total, range) => `showing ${range[0]}-${range[1]} of ${total} groups` // showQuickJumper: true }} diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Policies/AddPolicy.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Policies/AddPolicy.js index 47e88454bad..dbc5d896422 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Policies/AddPolicy.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Policies/AddPolicy.js @@ -3,6 +3,7 @@ import {Button, Form, Row, Col, Card, Steps, Input, message, Modal, notification import axios from "axios"; import {withConfigContext} from "../../context/ConfigContext"; import DeviceType from "../Devices/DeviceType"; +import SelectPlatform from "./SelectPlatform"; import ConfigureProfile from "./ConfigureProfile"; const {Step} = Steps; @@ -23,6 +24,16 @@ class AddPolicy extends React.Component { }) }; + next() { + const current = this.state.current + 1; + this.setState({ current }); + } + + prev() { + const current = this.state.current - 1; + this.setState({ current }); + } + openAddDeviceModal = () =>{ this.setState({ isAddDeviceModalVisible : true, @@ -46,10 +57,9 @@ class AddPolicy extends React.Component { -
- +
@@ -64,8 +74,28 @@ class AddPolicy extends React.Component {
+ +
+ {current > 0 && ( + + )} + {current < 5 && current > 0 && ( + + )} + {current === 5 && ( + + )} +
+ + ); } diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Policies/ConfigureProfile.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Policies/ConfigureProfile.js index 21a2df87eec..0d595b1d8b4 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Policies/ConfigureProfile.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/components/Policies/ConfigureProfile.js @@ -1,302 +1,268 @@ import React from 'react'; -import {Tabs, Row, Col, Switch, Menu,Input, Typography, Form, Checkbox, Select} from "antd"; +import {Tabs, Row, Col, Switch, Menu,Input, Typography, Form, Checkbox, Select, + Tooltip, Icon, Collapse, Alert, Upload, Button,Radio} from "antd"; import {withConfigContext} from "../../context/ConfigContext"; -const { Title } = Typography; +import "../../pages/Dashboard/Policies/policies.css"; +import jsonResponse from "./configuration"; +const { Title, Text, Paragraph } = Typography; const { TabPane } = Tabs; const {Option} = Select; +const {Panel} = Collapse; +const { TextArea } = Input; +const policyConfigurationsList = jsonResponse.PolicyConfigurations; class ConfigureProfile extends React.Component { constructor(props) { super(props); this.config = this.props.context; + this.policies = policyConfigurationsList.androidPolicy.Policy; + this.state = { + isDisplayMain: "none", + activeKeys: [] + } }; - render() { + componentDidMount() { + } + + onChange = (e) =>{ + console.log(`checked = ${e.target.id}`); + }; + + onChecked = (e,i) =>{ + if(e){ + this.setState({ + isDisplayMain: "block", + }); + }else{ + this.setState({ + isDisplayMain: "none", + }); + + } + + }; + + onClickSwitch = (e) =>{ + + }; + + + getPanelItems = (panel)=>{ const { getFieldDecorator } = this.props.form; + return ( + panel.map((item,k)=>{ + switch(item._type){ + case "select": + return( + + {item.Label}  + + + + + } + style={{display: "block"}}> + {getFieldDecorator(`${item._id}`, { + initialValue: `${item.Optional.Option[0]}` + })( + + )} + + ); + case "input": + return( + + {item.Label}  + + + + + } + style={{display: "block"}}> + {getFieldDecorator(`${item._id}`, { + rules: [ + { + pattern: new RegExp(`${item.Optional.rules.regex}`), + message: `${item.Optional.rules.validationMsg}`, + }, + ], + })( + + )} + + ); + case "checkbox": + return( + + {getFieldDecorator(`${item._id}`, { + valuePropName: 'checked', + initialValue: `${item.Optional.checked}`, + })( + + + {item.Label}  + + + + + + )} + + ); + case "textArea": + return( + + {item.Label}  + + + + + } + style={{display: "block"}}> + {getFieldDecorator(`${item._id}`, { + + })( +