diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/AssignGroups/index.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/AssignGroups/index.js
new file mode 100644
index 0000000000..38df0b9605
--- /dev/null
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/AssignGroups/index.js
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2020, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
+ *
+ * Entgra (pvt) Ltd. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+import { withConfigContext } from '../../../../../../../../components/ConfigContext';
+import { Button, Col, Form, message, notification, Radio, Select } from 'antd';
+import axios from 'axios';
+const { Option } = Select;
+
+class AssignGroups extends React.Component {
+ constructor(props) {
+ super(props);
+ this.config = this.props.context;
+ this.userSelector = React.createRef();
+ this.roleSelector = React.createRef();
+ this.state = {
+ roles: [],
+ users: [],
+ groups: [],
+ };
+ }
+ componentDidMount() {
+ this.getRolesList();
+ this.getGroupsList();
+ }
+
+ handleSetUserRoleFormItem = event => {
+ if (event.target.value === 'roleSelector') {
+ this.roleSelector.current.style.cssText = 'display: block;';
+ this.userSelector.current.style.cssText = 'display: none;';
+ } else {
+ this.roleSelector.current.style.cssText = 'display: none;';
+ this.userSelector.current.style.cssText = 'display: block;';
+ }
+ };
+
+ getRolesList = () => {
+ 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) {
+ this.setState({
+ roles: 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.',
+ });
+ }
+ });
+ };
+
+ getUsersList = 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 users = JSON.parse(res.data.data);
+ this.setState({
+ 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.',
+ });
+ }
+ });
+ };
+
+ // fetch data from api
+ getGroupsList = () => {
+ let apiUrl =
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/admin/groups';
+
+ // send request to the invokerss
+ axios
+ .get(apiUrl)
+ .then(res => {
+ if (res.status === 200) {
+ this.setState({
+ groups: res.data.data.deviceGroups,
+ });
+ }
+ })
+ .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 device groups.',
+ });
+ }
+ });
+ };
+
+ render() {
+ const { getFieldDecorator } = this.props.form;
+ return (
+
+
+
+ Set User role(s)
+ Set User(s)
+
+
+
+ {getFieldDecorator('roles', {})(
+
+ Any
+ {this.state.roles.map(role => (
+
+ {role}
+
+ ))}
+ ,
+ )}
+
+
+
+
+ {getFieldDecorator('users', {})(
+
+ {this.state.users.map(user => (
+
+ {user.username}
+
+ ))}
+ ,
+ )}
+
+
+
+
+ {getFieldDecorator('deviceGroups', {})(
+
+ NONE
+ {this.state.groups.map(group => (
+
+ {group.name}
+
+ ))}
+ ,
+ )}
+
+
+
+
+ Back
+
+
+ Continue
+
+
+
+
+ );
+ }
+}
+
+export default withConfigContext(Form.create()(AssignGroups));
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/ConfigureProfile/index.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/ConfigureProfile/index.js
index c28046d100..a17ad5d6a0 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/ConfigureProfile/index.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/ConfigureProfile/index.js
@@ -62,8 +62,6 @@ class ConfigureProfile extends React.Component {
};
}
- componentDidMount() {}
-
// convert time from 24h format to 12h format
timeConverter = time => {
time = time
@@ -673,11 +671,6 @@ class ConfigureProfile extends React.Component {
const { policyUIConfigurationsList } = this.props;
return (
- {/*
*/}
- {/* */}
- {/* {this.getOptionForTimeSelectors(1440, 1410, 30)}*/}
- {/* */}
- {/*
*/}
{policyUIConfigurationsList.map((element, i) => {
return (
@@ -729,6 +722,16 @@ class ConfigureProfile extends React.Component {
);
})}
+
+
+
+ Back
+
+
+ Continue
+
+
+
);
}
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/PublishDevices/index.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/PublishDevices/index.js
new file mode 100644
index 0000000000..8075d5789c
--- /dev/null
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/PublishDevices/index.js
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2020, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
+ *
+ * Entgra (pvt) Ltd. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+import { withConfigContext } from '../../../../../../../../components/ConfigContext';
+import { Button, Col, Form, Input } from 'antd';
+const { TextArea } = Input;
+
+class PublishDevices extends React.Component {
+ constructor(props) {
+ super(props);
+ this.config = this.props.context;
+ }
+
+ render() {
+ const { getFieldDecorator } = this.props.form;
+ return (
+
+
+ {getFieldDecorator('policyName', {
+ rules: [
+ {
+ pattern: new RegExp('^.{1,30}$'),
+ message: 'Should be 1-to-30 characters long',
+ },
+ ],
+ })( )}
+
+
+ {getFieldDecorator('description', {})()}
+
+
+
+
+ Back
+
+
+ Save & Publish
+
+ Save
+
+
+
+ );
+ }
+}
+
+export default withConfigContext(Form.create()(PublishDevices));
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/SelectPlatform/index.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/SelectPlatform/index.js
index eca9ab39e5..4a335dfed1 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/SelectPlatform/index.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/SelectPlatform/index.js
@@ -31,14 +31,12 @@ class SelectPlatform extends React.Component {
this.config = this.props.context;
this.state = {
data: [],
- pagination: {},
loading: false,
- selectedRows: [],
};
}
componentDidMount() {
- this.fetchUsers();
+ this.getDeviceTypes();
}
onClickCard = (e, type) => {
@@ -46,7 +44,7 @@ class SelectPlatform extends React.Component {
};
// fetch data from api
- fetchUsers = (params = {}) => {
+ getDeviceTypes() {
this.setState({ loading: true });
let apiUrl =
@@ -55,16 +53,14 @@ class SelectPlatform extends React.Component {
this.config.serverConfig.invoker.deviceMgt +
'/device-types';
- // send request to the invokerss
+ // send request to the invokers
axios
.get(apiUrl)
.then(res => {
if (res.status === 200) {
- const pagination = { ...this.state.pagination };
this.setState({
loading: false,
data: JSON.parse(res.data.data),
- pagination,
});
}
})
@@ -83,22 +79,7 @@ class SelectPlatform extends React.Component {
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 } = this.state;
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/SelectPolicyType/index.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/SelectPolicyType/index.js
new file mode 100644
index 0000000000..88d2b79134
--- /dev/null
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/SelectPolicyType/index.js
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2020, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
+ *
+ * Entgra (pvt) Ltd. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+import {
+ Button,
+ Col,
+ Form,
+ Icon,
+ message,
+ notification,
+ Radio,
+ Select,
+ Tooltip,
+} from 'antd';
+import { withConfigContext } from '../../../../../../../../components/ConfigContext';
+import axios from 'axios';
+const { Option } = Select;
+
+class SelectPolicyType extends React.Component {
+ constructor(props) {
+ super(props);
+ this.config = this.props.context;
+ this.state = {
+ correctivePoliciesList: [],
+ };
+ }
+
+ componentDidMount() {
+ this.fetchPolicies();
+ }
+
+ fetchPolicies = () => {
+ let apiUrl =
+ window.location.origin +
+ this.config.serverConfig.invoker.uri +
+ this.config.serverConfig.invoker.deviceMgt +
+ '/policies';
+
+ // send request to the invokerss
+ axios
+ .get(apiUrl)
+ .then(res => {
+ if (res.status === 200) {
+ let policies = res.data.data.policies;
+ let correctivePolicies = [];
+ for (let i = 0; i < policies.length; i++) {
+ if (policies[i].policyType === 'CORRECTIVE') {
+ correctivePolicies.push(
+
+ {policies[i].policyName}
+ ,
+ );
+ }
+ }
+ this.setState({
+ correctivePoliciesList: correctivePolicies,
+ });
+ }
+ })
+ .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 policies.',
+ });
+ }
+
+ this.setState({ loading: false });
+ });
+ };
+
+ handlePolicyTypes = event => {
+ if (event.target.value === 'GENERAL') {
+ document.getElementById('generalPolicySubPanel').style.display = 'block';
+ } else {
+ document.getElementById('generalPolicySubPanel').style.display = 'none';
+ }
+ };
+
+ render() {
+ const { getFieldDecorator } = this.props.form;
+ return (
+
+
+ {getFieldDecorator('policyType', {
+ initialValue: 'GENERAL',
+ })(
+
+ General Policy
+ Corrective Policy
+ ,
+ )}
+
+
+
+ Select Corrective Policy
+
+
+
+
+ }
+ >
+ {getFieldDecorator('correctiveActions', {
+ initialValue: 'NONE',
+ })(
+
+ None
+ {this.state.correctivePoliciesList}
+ ,
+ )}
+
+
+
+
+
+ Back
+
+
+ Continue
+
+
+
+
+ );
+ }
+}
+
+export default withConfigContext(Form.create()(SelectPolicyType));
diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/index.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/index.js
index 13217b1262..082aaaec85 100644
--- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/index.js
+++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/index.js
@@ -17,19 +17,13 @@
*/
import React from 'react';
-import {
- Button,
- Form,
- Row,
- Col,
- Card,
- Steps,
- message,
- notification,
-} from 'antd';
+import { Form, Row, Col, Card, Steps, message, notification } from 'antd';
import { withConfigContext } from '../../../../../../components/ConfigContext';
import SelectPlatform from './components/SelectPlatform';
import ConfigureProfile from './components/ConfigureProfile';
+import SelectPolicyType from './components/SelectPolicyType';
+import AssignGroups from './components/AssignGroups';
+import PublishDevices from './components/PublishDevices';
import axios from 'axios';
const { Step } = Steps;
@@ -82,12 +76,12 @@ class AddPolicy extends React.Component {
});
};
- onHandleNext = () => {
+ getNextStep = () => {
const currentStepIndex = this.state.currentStepIndex + 1;
this.setState({ currentStepIndex });
};
- onHandlePrev = () => {
+ getPrevStep = () => {
const currentStepIndex = this.state.currentStepIndex - 1;
this.setState({ currentStepIndex });
};
@@ -104,7 +98,6 @@ class AddPolicy extends React.Component {
-
@@ -121,40 +114,33 @@ class AddPolicy extends React.Component {
>
+ >
+
+
+ >
+
+
-
+ >
+
+
-
-
- {currentStepIndex > 0 && (
- this.onHandlePrev()}
- >
- Previous
-
- )}
- {currentStepIndex > 0 && currentStepIndex < 5 && (
- this.onHandleNext()}>
- Next
-
- )}
- {currentStepIndex === 5 && Done }
-
-
);