mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Generate Basic data in payload and Add Restriction policies to forms
This commit is contained in:
parent
69bbd8d512
commit
ed67090e38
@ -48,6 +48,22 @@ class AssignGroups extends React.Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// generate payload by adding Assign Groups
|
||||||
|
onHandleContinue = () => {
|
||||||
|
this.props.form.validateFields((err, values) => {
|
||||||
|
if (!err) {
|
||||||
|
if (!values.users) {
|
||||||
|
delete values.users;
|
||||||
|
}
|
||||||
|
if (values.deviceGroups === 'NONE') {
|
||||||
|
delete values.deviceGroups;
|
||||||
|
}
|
||||||
|
Object.assign(this.props.newPolicyPayload, values);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.props.getNextStep();
|
||||||
|
};
|
||||||
|
|
||||||
getRolesList = () => {
|
getRolesList = () => {
|
||||||
let apiURL =
|
let apiURL =
|
||||||
window.location.origin +
|
window.location.origin +
|
||||||
@ -164,7 +180,9 @@ class AssignGroups extends React.Component {
|
|||||||
style={{ display: 'block' }}
|
style={{ display: 'block' }}
|
||||||
>
|
>
|
||||||
<Form.Item>
|
<Form.Item>
|
||||||
{getFieldDecorator('roles', {})(
|
{getFieldDecorator('roles', {
|
||||||
|
initialValue: 'ANY',
|
||||||
|
})(
|
||||||
<Select
|
<Select
|
||||||
mode="multiple"
|
mode="multiple"
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
@ -203,7 +221,9 @@ class AssignGroups extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Form.Item label={'Select Groups'} style={{ display: 'block' }}>
|
<Form.Item label={'Select Groups'} style={{ display: 'block' }}>
|
||||||
{getFieldDecorator('deviceGroups', {})(
|
{getFieldDecorator('deviceGroups', {
|
||||||
|
initialValue: 'NONE',
|
||||||
|
})(
|
||||||
<Select mode="multiple" style={{ width: '100%' }}>
|
<Select mode="multiple" style={{ width: '100%' }}>
|
||||||
<Option value={'NONE'}>NONE</Option>
|
<Option value={'NONE'}>NONE</Option>
|
||||||
{this.state.groups.map(group => (
|
{this.state.groups.map(group => (
|
||||||
@ -219,7 +239,7 @@ class AssignGroups extends React.Component {
|
|||||||
<Button style={{ marginRight: 8 }} onClick={this.props.getPrevStep}>
|
<Button style={{ marginRight: 8 }} onClick={this.props.getPrevStep}>
|
||||||
Back
|
Back
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="primary" onClick={this.props.getNextStep}>
|
<Button type="primary" onClick={this.onHandleContinue}>
|
||||||
Continue
|
Continue
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -295,6 +295,16 @@ class ConfigureProfile extends React.Component {
|
|||||||
return columns;
|
return columns;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// generate payload by adding policy configurations
|
||||||
|
onHandleContinue = () => {
|
||||||
|
this.props.form.validateFields((err, values) => {
|
||||||
|
if (!err) {
|
||||||
|
console.log(values);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.props.getNextStep();
|
||||||
|
};
|
||||||
|
|
||||||
// generate form items
|
// generate form items
|
||||||
getPanelItems = panel => {
|
getPanelItems = panel => {
|
||||||
const { getFieldDecorator } = this.props.form;
|
const { getFieldDecorator } = this.props.form;
|
||||||
@ -710,9 +720,24 @@ class ConfigureProfile extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div>
|
{panel.hasOwnProperty('panelItem') && (
|
||||||
<Form>{this.getPanelItems(panel.panelItem)}</Form>
|
<div>
|
||||||
</div>
|
<Form>{this.getPanelItems(panel.panelItem)}</Form>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{panel.hasOwnProperty('subFormLists') && (
|
||||||
|
<div>
|
||||||
|
{Object.values(panel.subFormLists).map(
|
||||||
|
(form, i) => {
|
||||||
|
return (
|
||||||
|
<Form key={i}>
|
||||||
|
{this.getPanelItems(form.panelItem)}
|
||||||
|
</Form>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</Collapse.Panel>
|
</Collapse.Panel>
|
||||||
</Collapse>
|
</Collapse>
|
||||||
</div>
|
</div>
|
||||||
@ -727,7 +752,7 @@ class ConfigureProfile extends React.Component {
|
|||||||
<Button style={{ marginRight: 8 }} onClick={this.props.getPrevStep}>
|
<Button style={{ marginRight: 8 }} onClick={this.props.getPrevStep}>
|
||||||
Back
|
Back
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="primary" onClick={this.props.getNextStep}>
|
<Button type="primary" onClick={this.onHandleContinue}>
|
||||||
Continue
|
Continue
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -26,6 +26,23 @@ class PublishDevices extends React.Component {
|
|||||||
this.config = this.props.context;
|
this.config = this.props.context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClickSavePolicy = (event, isPublish) => {
|
||||||
|
this.props.form.validateFields((err, values) => {
|
||||||
|
if (!err) {
|
||||||
|
let policyProfile = Object.assign(this.props.policyProfile, {
|
||||||
|
profileName: values.policyName,
|
||||||
|
});
|
||||||
|
Object.assign(values, { profile: policyProfile });
|
||||||
|
Object.assign(this.props.newPolicyPayload, values);
|
||||||
|
if (isPublish) {
|
||||||
|
Object.assign(this.props.newPolicyPayload, {
|
||||||
|
active: isPublish,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { getFieldDecorator } = this.props.form;
|
const { getFieldDecorator } = this.props.form;
|
||||||
return (
|
return (
|
||||||
@ -51,10 +68,16 @@ class PublishDevices extends React.Component {
|
|||||||
<Button style={{ marginRight: 8 }} onClick={this.props.getPrevStep}>
|
<Button style={{ marginRight: 8 }} onClick={this.props.getPrevStep}>
|
||||||
Back
|
Back
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="primary" style={{ marginRight: 8 }}>
|
<Button
|
||||||
|
type="primary"
|
||||||
|
style={{ marginRight: 8 }}
|
||||||
|
onClick={() => this.onClickSavePolicy(true)}
|
||||||
|
>
|
||||||
Save & Publish
|
Save & Publish
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="primary">Save</Button>
|
<Button type="primary" onClick={this.onClickSavePolicy}>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -19,15 +19,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { Card, Col, Icon, message, notification, Row } from 'antd';
|
import { Card, Col, Icon, message, notification, Row } 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 '../../../../../../../../components/ConfigContext';
|
import { withConfigContext } from '../../../../../../../../components/ConfigContext';
|
||||||
|
|
||||||
class SelectPlatform extends React.Component {
|
class SelectPlatform extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
TimeAgo.addLocale(en);
|
|
||||||
this.config = this.props.context;
|
this.config = this.props.context;
|
||||||
this.state = {
|
this.state = {
|
||||||
data: [],
|
data: [],
|
||||||
@ -41,6 +37,10 @@ class SelectPlatform extends React.Component {
|
|||||||
|
|
||||||
onClickCard = (e, type) => {
|
onClickCard = (e, type) => {
|
||||||
this.props.getPolicyConfigJson(type);
|
this.props.getPolicyConfigJson(type);
|
||||||
|
let deviceType = {
|
||||||
|
deviceType: type,
|
||||||
|
};
|
||||||
|
Object.assign(this.props.policyProfile, deviceType);
|
||||||
};
|
};
|
||||||
|
|
||||||
// fetch data from api
|
// fetch data from api
|
||||||
|
|||||||
@ -44,6 +44,20 @@ class SelectPolicyType extends React.Component {
|
|||||||
this.fetchPolicies();
|
this.fetchPolicies();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// generate payload using Select policy type
|
||||||
|
onHandleContinue = () => {
|
||||||
|
this.props.form.validateFields((err, values) => {
|
||||||
|
if (!err) {
|
||||||
|
if (values.correctiveActions === 'NONE') {
|
||||||
|
values.correctiveActions = [];
|
||||||
|
}
|
||||||
|
Object.assign(this.props.newPolicyPayload, values);
|
||||||
|
}
|
||||||
|
console.log('aaaaaaa');
|
||||||
|
});
|
||||||
|
this.props.getNextStep();
|
||||||
|
};
|
||||||
|
|
||||||
fetchPolicies = () => {
|
fetchPolicies = () => {
|
||||||
let apiUrl =
|
let apiUrl =
|
||||||
window.location.origin +
|
window.location.origin +
|
||||||
@ -142,7 +156,7 @@ class SelectPolicyType extends React.Component {
|
|||||||
<Button style={{ marginRight: 8 }} onClick={this.props.getPrevStep}>
|
<Button style={{ marginRight: 8 }} onClick={this.props.getPrevStep}>
|
||||||
Back
|
Back
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="primary" onClick={this.props.getNextStep}>
|
<Button type="primary" onClick={this.onHandleContinue}>
|
||||||
Continue
|
Continue
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -35,6 +35,8 @@ class AddPolicy extends React.Component {
|
|||||||
currentStepIndex: 0,
|
currentStepIndex: 0,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
policyUIConfigurationsList: [],
|
policyUIConfigurationsList: [],
|
||||||
|
newPolicyPayload: { compliance: 'enforce' },
|
||||||
|
policyProfile: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,6 +109,8 @@ class AddPolicy extends React.Component {
|
|||||||
>
|
>
|
||||||
<SelectPlatform
|
<SelectPlatform
|
||||||
getPolicyConfigJson={this.getPolicyConfigJson}
|
getPolicyConfigJson={this.getPolicyConfigJson}
|
||||||
|
newPolicyPayload={this.state.newPolicyPayload}
|
||||||
|
policyProfile={this.state.policyProfile}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@ -114,6 +118,7 @@ class AddPolicy extends React.Component {
|
|||||||
>
|
>
|
||||||
<ConfigureProfile
|
<ConfigureProfile
|
||||||
policyUIConfigurationsList={policyUIConfigurationsList}
|
policyUIConfigurationsList={policyUIConfigurationsList}
|
||||||
|
policyProfile={this.state.policyProfile}
|
||||||
getPrevStep={this.getPrevStep}
|
getPrevStep={this.getPrevStep}
|
||||||
getNextStep={this.getNextStep}
|
getNextStep={this.getNextStep}
|
||||||
/>
|
/>
|
||||||
@ -122,6 +127,7 @@ class AddPolicy extends React.Component {
|
|||||||
style={{ display: currentStepIndex === 2 ? 'unset' : 'none' }}
|
style={{ display: currentStepIndex === 2 ? 'unset' : 'none' }}
|
||||||
>
|
>
|
||||||
<SelectPolicyType
|
<SelectPolicyType
|
||||||
|
newPolicyPayload={this.state.newPolicyPayload}
|
||||||
getPrevStep={this.getPrevStep}
|
getPrevStep={this.getPrevStep}
|
||||||
getNextStep={this.getNextStep}
|
getNextStep={this.getNextStep}
|
||||||
/>
|
/>
|
||||||
@ -130,6 +136,7 @@ class AddPolicy extends React.Component {
|
|||||||
style={{ display: currentStepIndex === 3 ? 'unset' : 'none' }}
|
style={{ display: currentStepIndex === 3 ? 'unset' : 'none' }}
|
||||||
>
|
>
|
||||||
<AssignGroups
|
<AssignGroups
|
||||||
|
newPolicyPayload={this.state.newPolicyPayload}
|
||||||
getPrevStep={this.getPrevStep}
|
getPrevStep={this.getPrevStep}
|
||||||
getNextStep={this.getNextStep}
|
getNextStep={this.getNextStep}
|
||||||
/>
|
/>
|
||||||
@ -137,7 +144,11 @@ class AddPolicy extends React.Component {
|
|||||||
<div
|
<div
|
||||||
style={{ display: currentStepIndex === 4 ? 'unset' : 'none' }}
|
style={{ display: currentStepIndex === 4 ? 'unset' : 'none' }}
|
||||||
>
|
>
|
||||||
<PublishDevices getPrevStep={this.getPrevStep} />
|
<PublishDevices
|
||||||
|
newPolicyPayload={this.state.newPolicyPayload}
|
||||||
|
policyProfile={this.state.policyProfile}
|
||||||
|
getPrevStep={this.getPrevStep}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
|||||||
@ -67,6 +67,10 @@ public class DataPanel {
|
|||||||
@XmlElement(name = "PanelItem")
|
@XmlElement(name = "PanelItem")
|
||||||
private List<PanelItem> panelItem;
|
private List<PanelItem> panelItem;
|
||||||
|
|
||||||
|
@XmlElementWrapper(name = "SubFormsList")
|
||||||
|
@XmlElement(name = "SubForm")
|
||||||
|
private List<SubFormList> subFormLists;
|
||||||
|
|
||||||
public String getPaneId() {
|
public String getPaneId() {
|
||||||
return panelId;
|
return panelId;
|
||||||
}
|
}
|
||||||
@ -99,4 +103,11 @@ public class DataPanel {
|
|||||||
this.panelItem = panelItem;
|
this.panelItem = panelItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SubFormList> getSubPanelLists() {
|
||||||
|
return subFormLists;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubPanelLists(List<SubFormList> subFormLists) {
|
||||||
|
this.subFormLists = subFormLists;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,24 @@
|
|||||||
|
package org.wso2.carbon.device.mgt.extensions.device.type.template.config;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SubFormList {
|
||||||
|
@XmlAttribute(name = "id", required = true)
|
||||||
|
protected String id;
|
||||||
|
|
||||||
|
@XmlElementWrapper(name = "PanelItems")
|
||||||
|
@XmlElement(name = "PanelItem")
|
||||||
|
private List<PanelItem> panelItem;
|
||||||
|
|
||||||
|
public List<PanelItem> getPanelItemList() {
|
||||||
|
return panelItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPanelItemList(List<PanelItem> panelItem) {
|
||||||
|
this.panelItem = panelItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user