Skip to content

Commit

Permalink
Merged in authentication_policy (pull request ant-design#26)
Browse files Browse the repository at this point in the history
Authentication policy

Approved-by: Sandeep Gandham
  • Loading branch information
Chanikya66 authored and Sandeep Gandham committed May 6, 2022
2 parents 3b7d42b + 657724e commit 878c7ad
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 52 deletions.
4 changes: 2 additions & 2 deletions src/components/Layout/Sider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ function AppSider() {
<Menu.Item key="policies" >Authentication</Menu.Item>
<Menu.Item key="dashboard">Dashboard</Menu.Item>
{/* <Menu.Item key="config">Configuration</Menu.Item> */}
<Menu.Item key="activityLogs" >Activity Logs</Menu.Item>
<Menu.Item key="mechanism">Mechanism</Menu.Item>
<Menu.Item key="users">Users</Menu.Item>
<Menu.Item key="activityLogs" >Activity Logs</Menu.Item>
<Menu.Item key="groups">Groups</Menu.Item>
<Menu.Item key="users">Users</Menu.Item>
<Menu.Item key="settings" >Settings</Menu.Item>
</Menu>
</Sider>
Expand Down
60 changes: 30 additions & 30 deletions src/components/Mechanism/Mechanisms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,10 @@ import ApiUrls from '../../ApiUtils';
export default function Mechanisms() {

const inActivateColumns = [
{
title: 'Sort',
dataIndex: 'sort',
width: '10%',
// render: (text: any, record: { mechanism_id: any; }) => (
// <Button onClick={() => reOrderMechanisms(record.mechanism_id, 1)}>
// Sort
// </Button>
// )
render: () => <DragHandle />,
},
{
title: 'Mechanism Name',
dataIndex: 'mechanism_name',
width: '50%'
width: '40%'
},
{
title: 'Actions',
Expand All @@ -44,7 +33,7 @@ export default function Mechanisms() {
title: 'Status',
dataIndex: 'activate',
width: '20%',
render: (text: any, record: { mechanism_id: any; }) => (
render: (text: any, record: { mechanism_id: any; default: any }) => (
<Button onClick={() => activateMechanism(record.mechanism_id)}>
Activate
</Button>
Expand All @@ -58,18 +47,25 @@ export default function Mechanisms() {
dataIndex: 'sort',
width: '10%',
className: 'drag-visible',
render: () => <DragHandle />,
render: (text: any, record: { default: any }) => (
record.default === false ? <DragHandle /> : <></>
)
},
{
title: 'Order',
dataIndex: 'mechanism_order',
width: '10%'
},
{
title: 'Mechanism Name',
dataIndex: 'mechanism_name',
width: '50%'
width: '40%'
},
{
title: 'Actions',
dataIndex: 'actions',
width: '20%',
render: (text: any, record: { mechanism_id: any; }) => (
render: (text: any, record: { mechanism_id: any }) => (
<Button onClick={() => getMechanismDetails(record.mechanism_id)}>
View
</Button>
Expand All @@ -79,10 +75,11 @@ export default function Mechanisms() {
title: 'Status',
dataIndex: 'inactivate',
width: '20%',
render: (text: any, record: { mechanism_id: any; }) => (
<Button onClick={() => inActivateMechanism(record.mechanism_id)}>
Inactivate
</Button>
render: (text: any, record: { mechanism_id: any; default: any }) => (
record.default === false ?
<Button onClick={() => inActivateMechanism(record.mechanism_id)}>
Inactivate
</Button> : <></>
)
}
];
Expand Down Expand Up @@ -134,7 +131,9 @@ export default function Mechanisms() {
key: i + 1,
mechanism_name: data[i].name,
mechanism_id: data[i].uid,
index: activeCounter + 1
default: data[i].default,
index: activeCounter + 1,
mechanism_order: data[i].order
}
activeCounter = activeCounter + 1
activeArray.push(obj);
Expand All @@ -144,7 +143,8 @@ export default function Mechanisms() {
key: i + 1,
mechanism_name: data[i].name,
mechanism_id: data[i].uid,
index: inActiveCounter + 1
index: inActiveCounter + 1,
mechanism_order: data[i].order
}
inActiveCounter = inActiveCounter + 1
inActiveArray.push(obj);
Expand All @@ -166,7 +166,7 @@ export default function Mechanisms() {
function inActivateMechanism(uid: string) {
ApiService.get(ApiUrls.inActivateMechanism(uid))
.then(data => window.location.reload())
.catch(error => {})
.catch(error => { })
}

function reOrderMechanisms(uid: string, order: number) {
Expand All @@ -177,7 +177,7 @@ export default function Mechanisms() {
ApiService.post(ApiUrls.reOrderMechanisms, data)
.then(data => {
console.log(data)
// window.location.reload()
window.location.reload()
})
}

Expand All @@ -201,16 +201,16 @@ export default function Mechanisms() {
const SortableBody = SortableContainer(props => <tbody {...props} />);

const onSortEnd = ({ oldIndex, newIndex }) => {
if (oldIndex !== newIndex) {
if (oldIndex !== newIndex && newIndex != activeMechanisms.length - 1) {
const newData = arrayMoveImmutable([].concat(activeMechanisms), oldIndex, newIndex).filter(
el => !!el,
);
console.log('Sorted items: ', newData);
setActiveMechanisms(newData);
//@ts-ignore
console.log(newData[newIndex].mechanism_id, newData.length - newIndex);
console.log(newData[newIndex].mechanism_id, newData.length - newIndex - 1);
//@ts-ignore
reOrderMechanisms(newData[newIndex].mechanism_id, newData.length - newIndex);
reOrderMechanisms(newData[newIndex].mechanism_id, newData.length - newIndex - 1);
}
};

Expand All @@ -225,7 +225,7 @@ export default function Mechanisms() {

const DraggableBodyRow = ({ className, style, ...restProps }) => {
const index = activeMechanisms.findIndex(x => x.index === restProps['data-row-key']);
return <SortableItem index={index} {...restProps}/>;
return <SortableItem index={index} {...restProps} />;
};

return (
Expand Down Expand Up @@ -256,7 +256,7 @@ export default function Mechanisms() {
borderBottom: 'none', padding: '10px 10px 10px 25px', backgroundColor: '#f5f5f6'
}}
>
<h4>ACTIVE MECHANISMS</h4>
<h4>ACTIVE</h4>
</div>

<Table
Expand All @@ -280,7 +280,7 @@ export default function Mechanisms() {
borderBottom: 'none', padding: '10px 10px 10px 25px', backgroundColor: '#f5f5f6'
}}
>
<h4>INACTIVE MECHANISMS</h4>
<h4>INACTIVE</h4>
</div>
<Table
style={{ border: '1px solid #D7D7DC' }}
Expand Down
13 changes: 4 additions & 9 deletions src/components/Mechanism/mechanism.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, Input, Radio, Select, Skeleton } from "antd";
import { useEffect, useState } from "react";
import { useEffect, useRef, useState } from "react";
import { MechanismType } from "../../models/Data.models";

import './Mechanism.css'
Expand All @@ -22,7 +22,7 @@ function Mechanism(props: any) {
const [groupNames, setGroupNames]: any = useState([]);
const [groupUids, setGroupUids]: any = useState([]);
const [groupsChange, setGroupsChange]: any = useState([]);
const [value, setValue] = useState(displayDetails?.challenge_factors[1].factor);
const [value, setValue] = useState("NONE");

useEffect(() => {
ApiService.get(ApiUrls.groups)
Expand Down Expand Up @@ -115,10 +115,6 @@ function Mechanism(props: any) {
}
}
})
console.log(array);
if(editData.challenge_factors[0].factor === "NONE"){
editData.challenge_factors[1].factor = "NONE"
}
}

function createMechanism() {
Expand Down Expand Up @@ -266,7 +262,7 @@ function Mechanism(props: any) {
<h6 className="m-0 font-weight-bold text-gray-900 text-lg" style={{ float: 'left', padding: '2px 5px' }}>Challenge 1</h6>
</div>
<div className="card-body">
<Radio.Group defaultValue={disabledFactors !== disabledFactors1 ? displayDetails?.challenge_factors[0].factor : ""}
<Radio.Group value={disabledFactors !== disabledFactors1 ? displayDetails?.challenge_factors[0].factor : ""}
disabled={!isEdit}
onChange={(e) => {
editData.challenge_factors[0].factor = e.target.value
Expand All @@ -275,7 +271,6 @@ function Mechanism(props: any) {
disabledFactors.pop();
editData.challenge_factors[1].factor = "NONE"
setValue("NONE")
setRender(!render)
}
}}
>
Expand All @@ -301,7 +296,7 @@ function Mechanism(props: any) {
</div>
<div className="card-body">
<div>
<Radio.Group defaultValue={displayDetails.name !== "" ? displayDetails?.challenge_factors[0].factor === "NONE" ? value : value : ""}
<Radio.Group value={displayDetails.name !== "" ? editData?.challenge_factors[0].factor === "NONE" ? value : displayDetails?.challenge_factors[1].factor : ""}
disabled={displayDetails.challenge_factors[0].factor === "NONE" || !isEdit}
onChange={(e) => {
editData.challenge_factors[1].factor = e.target.value
Expand Down
4 changes: 2 additions & 2 deletions src/components/Policies/passwordPolicy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const PasswordPolicy = (props: any) => {
}

function createPasswordPolicy() {
ApiService.put(ApiUrls.addPolicy, passwordEditData)
ApiService.post(ApiUrls.addPolicy, passwordEditData)
.then(data => {
console.log(data);
})
Expand All @@ -87,7 +87,7 @@ export const PasswordPolicy = (props: any) => {
}

function updatePasswordPolicy() {
ApiService.post(ApiUrls.policy(passwordDisplayData.uid), passwordEditData)
ApiService.put(ApiUrls.policy(passwordDisplayData.uid), passwordEditData)
.then(data => {
setPasswordDisplayData({ ...passwordEditData });
})
Expand Down
2 changes: 1 addition & 1 deletion src/components/Settings/Settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

.row-container {
display: grid;
grid-template-columns: 40% 60%;
grid-template-columns: 20% 80%;
grid-row-gap: 15px;
}

Expand Down
36 changes: 28 additions & 8 deletions src/components/Settings/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { Skeleton } from 'antd';
import { useEffect, useState } from 'react';

import './Settings.css'

import { ClientConfiguration } from '../../models/Data.models';

function Settings() {
const [clientId, setClientId] = useState("");
const [issuer, setIssuer] = useState("");
const [accountId, setAccountId] = useState("");
const [loading, setLoading] = useState(true);
const domain = localStorage.getItem('domain');

useEffect(() => {
fetch('https://credenti-portal-api.credenti.xyz/client/info',
fetch('https://credenti-portal-api.credenti.xyz/client/info',
{
method: 'POST',
headers: {
Expand All @@ -20,25 +23,42 @@ function Settings() {
"domain": domain
})
})
.then(response => response.json())
.then(response => response.json())
.then((data: ClientConfiguration) => {
setLoading(false);
setClientId(data.portal_oidc_client_id);
setAccountId(data.uid);
setIssuer(data.issuer_url);
}).catch((error) => {
console.log(error);
})
}, []);

return (
<>
<div><h2>Settings</h2></div>
<Skeleton loading={loading}>
<div>
Client_id: {clientId}
</div>
<div>
Issuer: {issuer}
<div className="content-container rounded-grey-border">
<div className="row-container">
<div>
Account_id:
</div>
<div>
{accountId}
</div>
<div>
Client_id:
</div>
<div>
{clientId}
</div>
<div>
Issuer:
</div>
<div>
{issuer}
</div>
</div>
</div>
</Skeleton>
</>
Expand Down

0 comments on commit 878c7ad

Please sign in to comment.