diff --git a/dashboard/src/Layout/TrasaTheme.tsx b/dashboard/src/Layout/TrasaTheme.tsx index d7b72815..bc6d4bcd 100644 --- a/dashboard/src/Layout/TrasaTheme.tsx +++ b/dashboard/src/Layout/TrasaTheme.tsx @@ -47,13 +47,13 @@ let theme = createMuiTheme({ letterSpacing: 0.5, padding: 12, }, - // p: { - // fontWeight: 700, - // fontSize: 14, - // letterSpacing: 0.5, - // color: '#404854', - // padding: 12, - // }, + subtitle1: { + fontWeight: 600, + fontSize: 16, + letterSpacing: 0.5, + color: '#404854', + }, + button: { textTransform: 'none', fontFamily: 'Open Sans, Rajdhani', diff --git a/dashboard/src/pages/Monitor/Session/LiveSessions.tsx b/dashboard/src/pages/Monitor/Session/LiveSessions.tsx index 3263c6db..cfb81446 100644 --- a/dashboard/src/pages/Monitor/Session/LiveSessions.tsx +++ b/dashboard/src/pages/Monitor/Session/LiveSessions.tsx @@ -8,7 +8,7 @@ import MUIDataTable, { } from 'mui-datatables'; import React, { useEffect, useState } from 'react'; import Constants from '../../../Constants'; -import { LogtableV2Theme } from '../../../utils/styles/themes'; +import { MuiDataTableTheme } from '../../../utils/styles/themes'; const useStyles = makeStyles((theme) => ({ mainContent: { @@ -278,7 +278,7 @@ export default function LiveSessionTable() { return (
- + { - return (value); + return value; }, }, }, @@ -503,17 +503,17 @@ export function LogTableV2(props: logtableProps) { if (tableMeta.rowData[4] === 'ssh') { window.open( `/monitor/sessions/view#type=ssh&year=${d.year()}&month=${month}&day=${d.date()}&sessionID=${value}`, - '_blank' + '_blank', ); } else if (tableMeta.rowData[4] === 'db') { window.open( `/monitor/sessions/view#type=db&year=${d.year()}&month=${month}&day=${d.date()}&sessionID=${value}`, - '_blank' + '_blank', ); } else if (tableMeta.rowData[4] === 'guac-ssh') { window.open( `/monitor/sessions/view#type=guac-ssh&year=${d.year()}&month=${month}&day=${d.date()}&sessionID=${value}`, - '_blank' + '_blank', ); } else if ( tableMeta.rowData[4] === 'guac-rdp' || @@ -521,22 +521,22 @@ export function LogTableV2(props: logtableProps) { ) { window.open( `/monitor/sessions/view#type=guac&year=${d.year()}&month=${month}&day=${d.date()}&sessionID=${value}`, - '_blank' + '_blank', ); } else if (tableMeta.rowData[4] === 'guac-vnc') { window.open( `/monitor/sessions/view#type=guac&year=${d.year()}&month=${month}&day=${d.date()}&sessionID=${value}`, - '_blank' + '_blank', ); } else if (tableMeta.rowData[4] === 'guac-vnc') { window.open( `/monitor/sessions/view#type=guac&year=${d.year()}&month=${month}&day=${d.date()}&sessionID=${value}`, - '_blank' + '_blank', ); } else if (tableMeta.rowData[4] === 'http') { window.open( `/monitor/sessions/view#type=http&year=${d.year()}&month=${month}&day=${d.date()}&sessionID=${value}`, - '_blank' + '_blank', ); } }} @@ -640,7 +640,7 @@ export function LogTableV2(props: logtableProps) {
- + { // export default withStyles(styles)(Overview) export default withRouter(SessionLog); - - - - - - - // {() => { // // console.log(tableMeta.rowData[4]) diff --git a/dashboard/src/pages/My/MyServices.tsx b/dashboard/src/pages/My/MyServices.tsx index 4e52b9cc..4c2c9d4d 100644 --- a/dashboard/src/pages/My/MyServices.tsx +++ b/dashboard/src/pages/My/MyServices.tsx @@ -30,6 +30,7 @@ import SshIcon from '../../assets/ssh.png'; import Constants from '../../Constants'; import ProgressHOC from '../../utils/Components/Progressbar'; import NewConnDlg from './NewConn'; +import Typography from '@material-ui/core/Typography'; const useStyles = makeStyles((theme) => ({ root: { @@ -39,129 +40,14 @@ const useStyles = makeStyles((theme) => ({ paper: { backgroundColor: '#fdfdfd', - // backgroundColor: '#00001aff', //'#E0E0E0', 'rgba(10,34,52,1)' // #011019 - // minWidth: 400, - // minHeight: 300, + padding: theme.spacing(2), textAlign: 'center', color: theme.palette.text.secondary, }, - card: { - // maxWidth: 250, - // // width: 50, - // padding: theme.spacing(5), - - marginLeft: 20, - height: 200, - }, - button: { - backgroundColor: '#000080', - }, - buttonSpace: { - flexgrow: 1, - justifyContent: 'space-between', - }, - Servicebutton: { - color: 'white', - backgroundColor: '#000080', // '#0A2053', // '#0000CD', - }, - requestButton: { - color: 'white', - backgroundColor: '#000080', - }, - // form - formControl: { - margin: theme.spacing(1), - }, - inputLabelFocused: { - color: purple[500], - }, - inputInkbar: { - '&:after': { - backgroundColor: purple[500], - }, - }, - textFieldRoot: { - padding: 1, - 'label + &': { - marginTop: theme.spacing(3), - }, - }, - - textFieldInput: { - borderRadius: 4, - backgroundColor: theme.palette.common.white, - border: '1px solid #ced4da', - fontSize: 16, - padding: '10px 12px', - width: 'calc(100% - 4px)', - transition: theme.transitions.create(['border-color', 'box-shadow']), - '&:focus': { - borderColor: '#80bdff', - boxShadow: '0 0 0 0.2rem rgba(0,123,255,.25)', - }, - }, - textFieldInputBig: { - borderRadius: 4, - backgroundColor: theme.palette.common.white, - border: '1px solid #ced4da', - fontSize: 16, - // padding: '10px 100px', - // width: 'calc(100% - 4px)', - transition: theme.transitions.create(['border-color', 'box-shadow']), - '&:focus': { - borderColor: '#80bdff', - boxShadow: '0 0 0 0.2rem rgba(0,123,255,.25)', - }, - }, - textFieldFormLabel: { - fontSize: 18, - }, - buttonProgress: { - color: green[500], - position: 'absolute', - top: '50%', - left: '50%', - marginTop: -12, - marginLeft: -12, - }, - successText: { - fontSize: 15, - color: 'green', - }, - errorText: { - fontSize: 15, - color: 'red', - }, - fab: { - margin: theme.spacing(2), - }, - fab2: { - margin: theme.spacing(2), - }, - users: { - margin: theme.spacing(2), - }, - dividerInset: { - margin: `5px 0 0 ${theme.spacing(9)}px`, - }, - servicesDemiter: { - marginBottom: 20, - }, - lightTooltip: { - backgroundColor: theme.palette.common.white, - color: 'rgba(0, 0, 0, 0.87)', - boxShadow: theme.shadows[1], - fontSize: 11, - }, extendedIcon: { marginRight: '10px', }, - ServiceName: { - color: 'black', - fontSize: '12px', - fontFamily: 'Open Sans, Rajdhani', - }, searchRoot: { marginLeft: '35%', padding: '2px 4px', @@ -176,10 +62,22 @@ const useStyles = makeStyles((theme) => ({ iconButton: { padding: 10, }, - divider: { - width: 1, - height: 28, - margin: 4, + servicesDemiter: { + marginBottom: 20, + }, + lightTooltip: { + backgroundColor: theme.palette.common.white, + color: 'rgba(0, 0, 0, 0.87)', + boxShadow: theme.shadows[1], + fontSize: 11, + }, + + buttonSpace: { + flexgrow: 1, + justifyContent: 'space-between', + }, + formControl: { + margin: theme.spacing(1), }, })); @@ -195,8 +93,6 @@ export default function MyservicesList() { const [selectedServiceIndex, setSelectedServiceIndex] = useState(0); const [admins, setAdmins] = useState([]); - - const handleNewconDlgState = () => { setNewconDlgOpen(!newconDlgOpen); }; @@ -245,21 +141,14 @@ export default function MyservicesList() { } }; - // handleClose = () => { - // setState({ open: false, menuOpen: false }); - // }; - useEffect(() => { const url = `${Constants.TRASA_HOSTNAME}/api/v1/my/services`; axios .get(url) .then((response) => { - console.log(response.data); setUser(response.data.User); setAssignedservices(response.data?.data?.[0]?.myServices); - console.log(response.data?.data?.[0]?.myServices) - // setState({ user: response.data.User, services: response.data.UserService }); }) .catch((error) => { console.error(error); @@ -287,15 +176,6 @@ export default function MyservicesList() { setReqOpen(false); }; - const sendAccessRequest = () => { - axios - .post(`${Constants.TRASA_HOSTNAME}/api/v1/my/services/adhoc/request`) - .then((response) => {}) - .catch((error) => { - console.error(error); - }); - }; - const searchService = (e: any) => { setQuery(e.target.value); }; @@ -316,7 +196,7 @@ export default function MyservicesList() { ); return (
- @@ -330,11 +210,6 @@ export default function MyservicesList() { placeholder="Search services by name or hostname" inputProps={{ 'aria-label': 'Search service s' }} /> - - {/* */} - {/* */} - {/* */} - {/* */}
-
{value.serviceName}
+ + {' '} + {value.serviceName}{' '} +

@@ -411,13 +289,14 @@ export default function MyservicesList() { ) : ( )}
@@ -441,7 +320,6 @@ export default function MyservicesList() { horizontal: 'left', }} > - {services[selectedServiceIndex] && services[selectedServiceIndex].usernames.map((v: string) => ( ))} - @@ -510,6 +387,7 @@ const returnServiceIcon = (val: any) => { type RequestAccessProps = { serviceID: string; + serviceName: string; handleRequestDialogueClose: () => void; reqOpen: boolean; admins: any[]; @@ -538,8 +416,6 @@ function RequestAccess(props: RequestAccessProps) { setProgress(false); if (response.data.status === 'success') { } - - // console.log(response.data); }) .catch((error) => { console.log(error); @@ -555,11 +431,13 @@ function RequestAccess(props: RequestAccessProps) { fullWidth maxWidth="sm" > - Request Access to this Service. + + Request Access to {props.serviceName} + -

Select admin

+ Select admin
@@ -567,11 +445,7 @@ function RequestAccess(props: RequestAccessProps) { name="requesteeID" onChange={handleChange} value={data.requesteeID} - inputProps={{ - name: 'requesteeID', - id: 'requesteeID', - classes: {}, - }} + variant="outlined" > {props.admins.map((user: any) => ( {`${user.firstName} ${user.lastName}`} @@ -583,7 +457,7 @@ function RequestAccess(props: RequestAccessProps) { -

Specify your intent for acces

+ Specify your intent for access
({ borderBottom: `1px solid ${theme.palette.divider}`, margin: 0, padding: theme.spacing(2), + fontSize: 24, }, closeButton: { position: 'absolute', diff --git a/dashboard/src/pages/Policies/AccessPolicies/index.tsx b/dashboard/src/pages/Policies/AccessPolicies/index.tsx index 87a64f62..169135aa 100644 --- a/dashboard/src/pages/Policies/AccessPolicies/index.tsx +++ b/dashboard/src/pages/Policies/AccessPolicies/index.tsx @@ -99,7 +99,7 @@ export default function Policies() { const req = { policyID: [policy.policyID] }; axios - .post(`${Constants.TRASA_HOSTNAME}/api/v1/groups/policy/delete`, req) + .post(`${Constants.TRASA_HOSTNAME}/api/v1/policy/delete`, req) .then(() => { window.location.reload(); }) @@ -110,7 +110,7 @@ export default function Policies() { const getAllPolicies = () => { axios - .get(`${Constants.TRASA_HOSTNAME}/api/v1/groups/policy/all`) + .get(`${Constants.TRASA_HOSTNAME}/api/v1/policy/all`) .then((response) => { // this.setState({allUsers: response.data}) const resp = response.data.data[0]; diff --git a/dashboard/src/pages/Policies/AccessPolicies/newCreatePolicy.tsx b/dashboard/src/pages/Policies/AccessPolicies/newCreatePolicy.tsx index e8a484de..c9570184 100644 --- a/dashboard/src/pages/Policies/AccessPolicies/newCreatePolicy.tsx +++ b/dashboard/src/pages/Policies/AccessPolicies/newCreatePolicy.tsx @@ -409,8 +409,8 @@ export default function CreatePolicy(props: createPolicyProps) { }; const url = props.update - ? `${Constants.TRASA_HOSTNAME}/api/v1/groups/policy/update` - : `${Constants.TRASA_HOSTNAME}/api/v1/groups/policy/create`; + ? `${Constants.TRASA_HOSTNAME}/api/v1/policy/update` + : `${Constants.TRASA_HOSTNAME}/api/v1/policy/create`; axios.post(url, basicPolicy).then((r) => { setLoading(false); diff --git a/dashboard/src/pages/Policies/AdhocAccess/AdhocRequest/GrantOrDenyAccess.tsx b/dashboard/src/pages/Policies/AdhocAccess/AdhocRequest/GrantOrDenyAccess.tsx new file mode 100644 index 00000000..95e5bb60 --- /dev/null +++ b/dashboard/src/pages/Policies/AdhocAccess/AdhocRequest/GrantOrDenyAccess.tsx @@ -0,0 +1,124 @@ +import DateFnsUtils from '@date-io/date-fns'; +import { makeStyles } from '@material-ui/core'; +import Button from '@material-ui/core/Button'; +import Dialog from '@material-ui/core/Dialog'; +import DialogActions from '@material-ui/core/DialogActions'; +import DialogContent from '@material-ui/core/DialogContent'; +import DialogTitle from '@material-ui/core/DialogTitle'; +import Grid from '@material-ui/core/Grid'; +import Typography from '@material-ui/core/Typography'; +import axios from 'axios'; +import 'date-fns'; +import { MuiPickersUtilsProvider, TimePicker } from 'material-ui-pickers'; +import React, { useState } from 'react'; +import ProgressHOC from '../../../../utils/Components/Progressbar'; +import Constants from '../../../../Constants'; + +const useStyles = makeStyles(() => ({ + rejectButton: { + background: 'maroon', + }, +})); + +type grantOrDenyAccessprops = { + reqID: string; + reqText: string; + //serviceID: string; + handleRequestDialogueClose: () => void; + deleteElement: (key: string) => void; + adhocReqDlgState: boolean; +}; + +export default function GrantOrDenyAccess(props: grantOrDenyAccessprops) { + const classes = useStyles(); + const [selectedTime, setSelectedTime] = useState(new Date()); + const [loader, setLoader] = useState(false); + + const handleSubmit = (name: string) => (e: React.MouseEvent) => { + setLoader(true); + const req = { + reqID: props.reqID, + authorizedPeriod: selectedTime.getTime(), + // serviceID: props.serviceID, + isAuthorized: false, + }; + + if (name !== 'reject') { + req.isAuthorized = true; + } + + axios + .post(`${Constants.TRASA_HOSTNAME}/api/v1/policy/adhoc/respond`, req) + .then((response) => { + setLoader(false); + + props.handleRequestDialogueClose(); + if (response.data.status === 'success') { + props.deleteElement(props.reqID); + } + }) + .catch((error) => { + console.log(error); + }); + }; + + const handleDateChange = (time: any) => { + setSelectedTime(time); + }; + + return ( +
+ + + Grant or Revoke Access to this app. + + + + + Requested reason for access: {' '} + {props.reqText} + + + Grant access to selected time: + + + + + {/* */} + + {/* */} + + + + + + {loader ? : ''} + + + + + +
+ ); +} diff --git a/dashboard/src/pages/Policies/AdhocAccess/AdhocRequest/index.tsx b/dashboard/src/pages/Policies/AdhocAccess/AdhocRequest/index.tsx new file mode 100644 index 00000000..d5af0c53 --- /dev/null +++ b/dashboard/src/pages/Policies/AdhocAccess/AdhocRequest/index.tsx @@ -0,0 +1,183 @@ +import { makeStyles, MuiThemeProvider } from '@material-ui/core'; +import Button from '@material-ui/core/Button'; +import Paper from '@material-ui/core/Paper'; +import axios from 'axios'; +import 'date-fns'; +import MUIDataTable, { + MUIDataTableColumn, + MUIDataTableMeta, + MUIDataTableOptions, +} from 'mui-datatables'; +import React, { useEffect, useState } from 'react'; +import Constants from '../../../../Constants'; +import GrantOrDenyAccess from './GrantOrDenyAccess'; +import { MuiDataTableTheme } from '../../../../utils/styles/themes'; + +const useStyles = makeStyles((theme) => ({ + paper: { + maxWidth: 1500, + margin: 'auto', + marginTop: 50, + overflow: 'hidden', + padding: theme.spacing(2), + }, + contentWrapper: { + margin: '40px 16px', + }, +})); + +export default function AccessRequests() { + const [users, setUsers] = useState>([]); + const [reqDlgOpen, setReqDlgOpen] = useState(false); + const [reqID, setReqID] = useState(''); + const [reqText, setReqtext] = useState(''); + const [haveData, setHaveData] = useState(false); + const [serviceID, setserviceID] = useState(''); + + useEffect(() => { + axios + .get(Constants.TRASA_HOSTNAME + '/api/v1/policy/adhoc/requests/my') + .then((response) => { + let data = response.data.data[0]; + if (data != null) { + let dataArr = []; + dataArr = data.map(function (n: any) { + let date = new Date(n.reqTime * 1000); + return [ + n.reqID, + n.requesterEmail, + n.serviceName, + date.toDateString(), + n.reqID + ':-:' + n.requestTxt, + ]; + }); + setUsers(dataArr); + setHaveData(true); + } + }) + .catch((error) => { + console.log(error); + }); + }, []); + + const deleteElement = (reqID: string) => { + let u = users; + + for (let i = 0; i <= u.length; i++) { + if (u[i].includes(reqID)) { + u.splice(i, 1); + setUsers(u); + } + } + }; + + const handleRequestDialogueOpen = (reqID: string, tableMeta: any) => { + let reqData = reqID.split(':-:'); + setReqDlgOpen(true); + setReqID(reqData[0]); + setReqtext(reqData[1]); + //setserviceID(tableMeta.rowData[2]); + }; + + const handleRequestDialogueClose = () => { + setReqDlgOpen(false); + }; + + const classes = useStyles(); + + const columns = [ + { + name: 'requestID', + options: { + filter: true, + display: false, + customBodyRender: (value: any) => { + return value; + }, + }, + }, + { + name: 'Requested By', + options: { + filter: true, + customBodyRender: (value: any) => { + return value; + }, + }, + }, + { + name: 'Service Name', + options: { + filter: true, + customBodyRender: (value: any) => { + return value; + }, + }, + }, + { + name: 'Requested On', + options: { + filter: true, + customBodyRender: (value: any) => { + return value; + }, + }, + }, + { + name: 'View Detail', + options: { + filter: false, + customBodyRender: ( + value: any, + tableMeta: MUIDataTableMeta, + updateValue: (value: string) => void, + ) => { + return ( + + ); + }, + }, + }, + ]; + + return ( +
+ {haveData ? ( + + {' '} + + + ) : ( + +

You dont have any active adhoc request to approve.

+
+ )} + +
+ ); +} + +const options = { + filter: true, + responsive: 'scrollMaxHeight', + selectableRows: 'none', + count: 5, +}; diff --git a/dashboard/src/pages/Policies/AdhocAccess/AdhocRequestHistory/ViewAdhocSession.tsx b/dashboard/src/pages/Policies/AdhocAccess/AdhocRequestHistory/ViewAdhocSession.tsx new file mode 100644 index 00000000..ae608628 --- /dev/null +++ b/dashboard/src/pages/Policies/AdhocAccess/AdhocRequestHistory/ViewAdhocSession.tsx @@ -0,0 +1,141 @@ +import Button from '@material-ui/core/Button'; +import Dialog from '@material-ui/core/Dialog'; +import DialogActions from '@material-ui/core/DialogActions'; +import DialogContent from '@material-ui/core/DialogContent'; +import DialogTitle from '@material-ui/core/DialogTitle'; +import Grid from '@material-ui/core/Grid'; +import Typography from '@material-ui/core/Typography'; +import 'date-fns'; +import Moment from 'moment'; +import React from 'react'; + +type viewAdhocSessionProps = { + reqText: string; + sessionID: string; + serviceType: string; + orgID: string; + handleRequestDialogueClose: () => void; + viewAdhocSessionDlgState: boolean; + localeAuthorizedOn: string; + localeAuthorizedPeriod: string; + timestamp: string; +}; + +export default function ViewAdhocSession(props: viewAdhocSessionProps) { + return ( +
+ + Adhoc Session + + + + Requested reason for access:{' '} + {props.reqText} + + + Sanctioned on: {' '} + {props.localeAuthorizedOn} + + + Authorized Till on:{' '} + {props.localeAuthorizedPeriod} + + + User Sessions: + + + + + + + + +
+ ); +} + +const ViewSession = (props: any) => { + const sessionArr = props.sessionID.split(','); + + const d = Moment.unix(props.timestamp); + + return ( +
+ + {sessionArr.map((session: any, i: number) => + props.serviceType === 'ssh' || + props.serviceType === 'ssh' || + props.serviceType === 'rdp' || + props.serviceType === 'vnc' || + props.serviceType === 'http' ? ( + + {` ( ${i + 1} ) `} + {' '} + + ) : ( + + {` ( ${i + 1} ) `} + {' '} + + ), + )} + +
+ ); +}; diff --git a/dashboard/src/pages/Policies/AdhocAccess/AdhocRequestHistory/index.tsx b/dashboard/src/pages/Policies/AdhocAccess/AdhocRequestHistory/index.tsx new file mode 100644 index 00000000..6ccf3a00 --- /dev/null +++ b/dashboard/src/pages/Policies/AdhocAccess/AdhocRequestHistory/index.tsx @@ -0,0 +1,231 @@ +import Button from '@material-ui/core/Button'; +import Paper from '@material-ui/core/Paper'; +import { makeStyles, MuiThemeProvider } from '@material-ui/core/styles'; +import axios from 'axios'; +import 'date-fns'; +import MUIDataTable, { + MUIDataTableColumn, + MUIDataTableMeta, + MUIDataTableOptions, +} from 'mui-datatables'; +import React, { useEffect, useState } from 'react'; +import Constants from '../../../../Constants'; +import ViewAdhocSession from './ViewAdhocSession'; + +import { MuiDataTableTheme } from '../../../../utils/styles/themes'; + +const useStyles = makeStyles((theme) => ({ + paper: { + maxWidth: 1500, + margin: 'auto', + marginTop: 50, + overflow: 'hidden', + padding: theme.spacing(2), + }, + contentWrapper: { + margin: '40px 16px', + }, +})); + +type adhocProps = { + orgID: string; +}; + +export default function AdhocRequestHistory(props: adhocProps) { + const [requestHistory, setRequestHistory] = useState([]); + const [reqDlgOpen, setReqDlgOpen] = useState(false); + const [reqID, setReqID] = useState(''); + const [reqText, setReqtext] = useState(''); + const [haveData, setHaveData] = useState(false); + const [sessionID, setSessionID] = useState(''); + const [serviceType, setServiceType] = useState(''); + const [localeAuthorizedOn, setlocaleAuthorizedOn] = useState(''); + const [localeAuthorizedPeriod, setlocaleAuthorizedPeriod] = useState(''); + const [timestamp, setTimestamp] = useState(''); + + useEffect(() => { + axios + .get(Constants.TRASA_HOSTNAME + '/api/v1/policy/adhoc/requests/all') + .then((response) => { + //console.log(response.data); + let data = response.data.data[0]; + if (data != null) { + let dataArr = []; + + dataArr = data.map(function (n: any) { + let reqDate = new Date(n.reqTime * 1000); + let localeAuthorizedOn = 'not authorized'; + if (n.authorizedOn > 0) { + let authorizedOn = new Date(n.authorizedOn * 1000); + localeAuthorizedOn = authorizedOn.toString(); + } + + let localeAuthorizedPeriod = 'not authorized'; + + if (n.isAuthorized) { + let authorizedPeriod = new Date(n.authorizedPeriod); + localeAuthorizedPeriod = authorizedPeriod.toString(); + } + + return [ + n.requesterEmail, + n.requesteeEmail, + n.isAuthorized ? 'granted' : 'rejected', + n.requestTxt, + n.serviceID, + reqDate.toString(), + n.reqID + + ':-:' + + n.requestTxt + + ':-:' + + n.sessionID + + ':-:' + + localeAuthorizedOn + + ':-:' + + localeAuthorizedPeriod + + ':-:' + + n.authorizedOn + + ':-:' + + n.serviceType, + ]; + }); + setRequestHistory(dataArr); + setHaveData(true); + } + }) + .catch((error) => { + console.log(error); + }); + }, []); + + const handleRequestDialogueOpen = (reqID: string) => { + let reqData = reqID.split(':-:'); + + setReqDlgOpen(true); + setReqID(reqData[0]); + setReqtext(reqData[1]); + setSessionID(reqData[2]); + setServiceType(reqData[6]); + setlocaleAuthorizedOn(reqData[3]); + setlocaleAuthorizedPeriod(reqData[4]); + setTimestamp(reqData[5]); + }; + + const handleRequestDialogueClose = () => { + setReqDlgOpen(false); + }; + + const classes = useStyles(); + + const columns = [ + { + name: 'Requested By', + options: { + filter: true, + customBodyRender: (value: any) => { + return value; + }, + }, + }, + { + name: 'Sanctioned By', + options: { + filter: true, + customBodyRender: (value: any) => { + return value; + }, + }, + }, + { + name: 'Status', + options: { + filter: true, + customBodyRender: (value: any) => { + return value; + }, + }, + }, + { + name: 'Access Reason', + options: { + filter: true, + display: false, + customBodyRender: (value: any) => { + return value; + }, + }, + }, + { + name: 'Service Name', + options: { + filter: true, + customBodyRender: (value: any) => { + return value; + }, + }, + }, + { + name: 'Requested On', + options: { + filter: true, + customBodyRender: (value: any) => { + return value; + }, + }, + }, + { + name: 'View Detail', + options: { + filter: false, + customBodyRender: (value: any) => { + return ( + + ); + }, + }, + }, + ]; + + return ( +
+ {haveData ? ( + + {' '} + + + ) : ( + +

There is no adhoc access history to show.

+
+ )} + + +
+ ); +} + +const options = { + filter: true, + responsive: 'scrollMaxHeight', +}; diff --git a/dashboard/src/pages/Policies/AdhocAccess/index.tsx b/dashboard/src/pages/Policies/AdhocAccess/index.tsx new file mode 100644 index 00000000..8bba0826 --- /dev/null +++ b/dashboard/src/pages/Policies/AdhocAccess/index.tsx @@ -0,0 +1,29 @@ +import axios from 'axios'; +import React, { useState, useEffect } from 'react'; +import Constants from '../../../Constants'; +import AccessRequests from './AdhocRequest'; +import AccessRequestHistory from './AdhocRequestHistory'; + +export default function AdocAccess() { + const [orgID, setOrgID] = useState(''); + + useEffect(() => { + axios + .get(Constants.TRASA_HOSTNAME + '/api/v1/my') + .then((response) => { + if (response.data.status === 'success') { + setOrgID(response.data.data[0].Org.ID); + } + }) + .catch((error) => { + console.log(error); + }); + }, []); + + return ( +
+ + +
+ ); +} diff --git a/dashboard/src/pages/Policies/index.tsx b/dashboard/src/pages/Policies/index.tsx index 2267341b..97e3f2fa 100644 --- a/dashboard/src/pages/Policies/index.tsx +++ b/dashboard/src/pages/Policies/index.tsx @@ -5,6 +5,7 @@ import Headers from '../../Layout/HeaderAndContent'; import AccessPolicies from './AccessPolicies'; import SecurityRules from './SecurityRules'; +import AdhocAccess from './AdhocAccess'; function PolicyView() { return ( @@ -12,8 +13,8 @@ function PolicyView() { , ]} + tabHeaders={['Adhoc Access', 'Access Policies', 'Security Rules']} + Components={[, , ]} />
@@ -24,7 +25,6 @@ const Policies = () => { return ( - ); }; diff --git a/dashboard/src/pages/Services/AccessMap/index.tsx b/dashboard/src/pages/Services/AccessMap/index.tsx index a9c7e71b..43b75963 100644 --- a/dashboard/src/pages/Services/AccessMap/index.tsx +++ b/dashboard/src/pages/Services/AccessMap/index.tsx @@ -121,7 +121,7 @@ export default function Appuser(props: any) { const fetchPolicies = () => { axios - .get(`${Constants.TRASA_HOSTNAME}/api/v1/groups/policy/all`) + .get(`${Constants.TRASA_HOSTNAME}/api/v1/policy/all`) .then((response) => { // this.setState({allUsers: response.data}) const resp = response.data.data[0]; @@ -205,13 +205,23 @@ export default function Appuser(props: any) { - - diff --git a/dashboard/src/pages/Services/GlobalServicesSetting/DynamicAccess.tsx b/dashboard/src/pages/Services/GlobalServicesSetting/DynamicAccess.tsx index 83f4bf6e..9e9b0b23 100644 --- a/dashboard/src/pages/Services/GlobalServicesSetting/DynamicAccess.tsx +++ b/dashboard/src/pages/Services/GlobalServicesSetting/DynamicAccess.tsx @@ -20,8 +20,8 @@ import MenuItem from '@material-ui/core/MenuItem'; import Button from '@material-ui/core/Button'; import ProgressHOC from '../../../utils/Components/Progressbar'; import Constants from '../../../Constants'; -import DynamicAccessRulesTable from "./DynamicAccessRulesTable"; -import {Option} from "react-multi-select-component/dist/lib/interfaces"; +import DynamicAccessRulesTable from './DynamicAccessRulesTable'; +import { Option } from 'react-multi-select-component/dist/lib/interfaces'; const useStyles = makeStyles((theme) => ({ root: { @@ -78,9 +78,7 @@ export default function DynamicAccess(props: any) { const [allPolicies, setAllPolicies] = React.useState([]); const [allRules, setAllRules] = React.useState([]); - const handleGroupsSelect = (groups: any) => { - if (groups.length > 1) { const last = groups[groups.length - 1]; groups = [last]; @@ -97,19 +95,11 @@ export default function DynamicAccess(props: any) { setState({ ...state, policy: pol }); }; - - React.useEffect(() => { axios.get(`${Constants.TRASA_HOSTNAME}/api/v1/accessmap/dynamic`).then((r) => { - const data = r?.data?.data?.[0]; const dataArr = data.map(function (n: any) { - - return [ - n.groupName, - n.policyName, - n.ruleID, - ]; + return [n.groupName, n.policyName, n.ruleID]; }); setAllRules(dataArr); @@ -122,7 +112,7 @@ export default function DynamicAccess(props: any) { })); setAllGroups(groups); }); - axios.get(`${Constants.TRASA_HOSTNAME}/api/v1/groups/policy/all`).then((r) => { + axios.get(`${Constants.TRASA_HOSTNAME}/api/v1/policy/all`).then((r) => { const policies = r.data?.data?.[0].map((g: any) => ({ label: g.policyName, id: g.policyID, @@ -133,11 +123,10 @@ export default function DynamicAccess(props: any) { }, []); React.useEffect(() => { - setState({ - ...state, - status: props.settings?.status, - }); - + setState({ + ...state, + status: props.settings?.status, + }); }, [props.settings]); const [reqStatus, setReqStatus] = useState(false); @@ -147,7 +136,7 @@ export default function DynamicAccess(props: any) { setState({ ...state, [event.target.name]: event.target.checked }); const data = { - status: event.target.checked , + status: event.target.checked, }; axios .post(`${Constants.TRASA_HOSTNAME}/api/v1/system/settings/dynamicaccess/update`, data) @@ -159,56 +148,45 @@ export default function DynamicAccess(props: any) { }); } - function addRule(event:any) { + function addRule(event: any) { const data = { groupName: state.userGroups?.[0].id, policyID: state.policy?.[0]?.id, - } - axios.post(`${Constants.TRASA_HOSTNAME}/api/v1/accessmap/dynamic/create`,data).then((r) => { - if(r.data.status=="success"){ + }; + axios.post(`${Constants.TRASA_HOSTNAME}/api/v1/accessmap/dynamic/create`, data).then((r) => { + if (r.data.status == 'success') { const data = r?.data?.data?.[0]; const dataArr = data.map(function (n: any) { - - return [ - n.groupName, - n.policyName, - n.ruleID, - ]; + return [n.groupName, n.policyName, n.ruleID]; }); - setAllRules(dataArr) + setAllRules(dataArr); } - }) - } + }); + } - function deleteRule(ruleID:string) { + function deleteRule(ruleID: string) { const data = { - ruleID:ruleID - } - - axios.post(`${Constants.TRASA_HOSTNAME}/api/v1/accessmap/dynamic/delete`,data).then((r) => { - if(r.data.status=="success"){ - const data = r?.data?.data?.[0]; - const dataArr = data.map(function (n: any) { - - return [ - n.groupName, - n.policyName, - n.ruleID, - ]; - }); - setAllRules(dataArr) - } - }) + ruleID: ruleID, + }; - } + axios.post(`${Constants.TRASA_HOSTNAME}/api/v1/accessmap/dynamic/delete`, data).then((r) => { + if (r.data.status == 'success') { + const data = r?.data?.data?.[0]; + const dataArr = data.map(function (n: any) { + return [n.groupName, n.policyName, n.ruleID]; + }); + setAllRules(dataArr); + } + }); + } - const valueRenderer=(label: string)=>(selected:Option[], options:Option[]) =>{ - if(selected && selected.length==1){ - return selected[0].label - }else { - return label + const valueRenderer = (label: string) => (selected: Option[], options: Option[]) => { + if (selected && selected.length == 1) { + return selected[0].label; + } else { + return label; } - } + }; return (
@@ -263,43 +241,35 @@ export default function DynamicAccess(props: any) { + + + + - - - - - - - - - - + + + - + - - - + {/* */} diff --git a/dashboard/src/pages/Services/Groups/GroupPage/AssignedUserGroupsPage.tsx b/dashboard/src/pages/Services/Groups/GroupPage/AssignedUserGroupsPage.tsx index 7351e2b4..c8cbbb8f 100644 --- a/dashboard/src/pages/Services/Groups/GroupPage/AssignedUserGroupsPage.tsx +++ b/dashboard/src/pages/Services/Groups/GroupPage/AssignedUserGroupsPage.tsx @@ -33,7 +33,7 @@ export default function AssignedUserGroup(props: any) { const fetchPolicies = () => { axios - .get(`${Constants.TRASA_HOSTNAME}/api/v1/groups/policy/all`) + .get(`${Constants.TRASA_HOSTNAME}/api/v1/policy/all`) .then((response) => { // this.setState({allUsers: response.data}) const resp = response.data.data[0]; @@ -52,7 +52,7 @@ export default function AssignedUserGroup(props: any) { return (