diff --git a/src/_nav.js b/src/_nav.js index c3f260b1a586..5f802d6144bc 100644 --- a/src/_nav.js +++ b/src/_nav.js @@ -156,6 +156,11 @@ const _nav = [ name: 'Application Approval', to: '/tenant/administration/appapproval', }, + { + component: CNavItem, + name: 'Geo IP Lookup', + to: '/tenant/tools/geoiplookup', + }, { component: CNavItem, name: 'Tenant Lookup', diff --git a/src/routes.js b/src/routes.js index b687ff1e4332..94181b42074f 100644 --- a/src/routes.js +++ b/src/routes.js @@ -17,6 +17,8 @@ const AddGroupTemplates = React.lazy(() => const DeployGroupTemplates = React.lazy(() => import('src/views/identity/administration/DeployGroupTemplate'), ) +const GeoIPLookup = React.lazy(() => import('src/views/tenant/administration/GeoIPLookup')) + const TenantLookup = React.lazy(() => import('src/views/tenant/administration/TenantLookup')) const GroupTemplates = React.lazy(() => import('src/views/identity/administration/GroupTemplates')) @@ -378,6 +380,11 @@ const routes = [ name: 'Tenant Lookup', component: TenantLookup, }, + { + path: '/tenant/tools/geoiplookup', + name: 'Geo IP Lookup', + component: GeoIPLookup, + }, { path: '/tenant/standards/alert-list', name: 'Alert List (Alpha)', component: ListAlerts }, { path: '/endpoint', name: 'Endpoint' }, { path: '/endpoint/applications', name: 'Applications' }, diff --git a/src/views/cipp/CIPPSettings.js b/src/views/cipp/CIPPSettings.js index 59c2d1816872..d4af85fce903 100644 --- a/src/views/cipp/CIPPSettings.js +++ b/src/views/cipp/CIPPSettings.js @@ -1134,7 +1134,7 @@ const NotificationsSettings = () => { ]} /> - + { { value: 'Alert', name: 'Alert' }, { value: 'Error', name: 'Error' }, { value: 'Info', name: 'Info' }, + { value: 'Warn', name: 'Warn' }, ]} /> diff --git a/src/views/tenant/administration/GeoIPLookup.js b/src/views/tenant/administration/GeoIPLookup.js new file mode 100644 index 000000000000..5f346a30861e --- /dev/null +++ b/src/views/tenant/administration/GeoIPLookup.js @@ -0,0 +1,153 @@ +import React, { useEffect, useState } from 'react' +import { + CButton, + CCard, + CCardBody, + CCardHeader, + CCardTitle, + CCol, + CCollapse, + CForm, + CFormInput, + CInputGroup, + CRow, + CSpinner, +} from '@coreui/react' +import useQuery from 'src/hooks/useQuery' +import { Field, Form } from 'react-final-form' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { faBook, faSearch } from '@fortawesome/free-solid-svg-icons' +import { useSelector } from 'react-redux' +import { useNavigate } from 'react-router-dom' +import { useLazyGenericGetRequestQuery } from 'src/store/api/app' +import { CippContentCard } from 'src/components/layout' +import Skeleton from 'react-loading-skeleton' +import { domainsApi } from 'src/store/api/domains' + +const isValidTenantInput = (value) => { + // Check if the input is a valid IPAddress + const ipRegex = new RegExp('^([0-9]{1,3}\\.){3}[0-9]{1,3}$') + return !ipRegex.test(value) +} + +const GeoIPLookup = () => { + let navigate = useNavigate() + const tenant = useSelector((state) => state.app.currentTenant) + let query = useQuery() + const ip = query.get('ip') + const SearchNow = query.get('SearchNow') + const [visibleA, setVisibleA] = useState(true) + const handleSubmit = async (values) => { + setVisibleA(false) + + const shippedValues = { + ip: values.domain, + SearchNow: true, + random: (Math.random() + 1).toString(36).substring(7), + } + var queryString = Object.keys(shippedValues) + .map((key) => key + '=' + shippedValues[key]) + .join('&') + + navigate(`?${queryString}`) + } + const [execGraphRequest, graphrequest] = useLazyGenericGetRequestQuery() + + useEffect(() => { + if (ip) { + execGraphRequest({ + path: 'api/ExecGeoIPLookup', + params: { + IP: ip, + }, + }) + } + }, [execGraphRequest, tenant.defaultDomainName, query, ip]) + + return ( + + + + + + + Geo IP Lookup + + + +
{ + return ( + + + {({ input, meta }) => { + return ( + <> + + + + Check{graphrequest.isFetching && } + + + + ) + }} + + + ) + }} + /> + + + + {ip && ( + + + + +

IP Address

+ {graphrequest.isFetching && } + {ip} +
+ +

Range

+ {graphrequest.isFetching && } + {graphrequest.data?.startaddress} - {graphrequest.data?.endAddress} +
+ +

Owner

+ {graphrequest.isFetching && } + {graphrequest.data?.OrgRef} +
+
+ + +

Subnet Name

+ {graphrequest.isFetching && } + {graphrequest.data?.SubnetName} +
+ +

Geo IP Location

+ {graphrequest.isFetching && } + {graphrequest.data?.location?.countryCode} - {graphrequest.data?.location?.cityName} +
+
+
+
+ )} + + ) +} + +export default GeoIPLookup