Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Refactor access logs #292

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ad2d331
feat: access logs addition in frontend
sukuna28 Jul 9, 2024
1285131
fix: access logs - is login successful > title change, filter clear b…
sukuna28 Jul 15, 2024
938db49
feat(accesslogs): zango related changes
deepaksuresh2411 Jun 27, 2024
6a8e4b5
feat(accesslogs): zango related changes
deepaksuresh2411 Jun 27, 2024
3336a40
add: app_panel build and bug fixes
shahharsh176 Jul 1, 2024
79cd211
templatenotfound and failure attempt not saved fixed
deepakdinesh1123 Jul 9, 2024
390561a
accesslog working
deepakdinesh1123 Jul 9, 2024
0aa1ba2
feat: access logs addition in frontend
sukuna28 Jul 9, 2024
0447498
access log templates moved
deepakdinesh1123 Jul 10, 2024
589e5db
phone number handled
deepakdinesh1123 Jul 11, 2024
f6edf53
regex used to check email and phone
deepakdinesh1123 Jul 11, 2024
12dd687
session expire update fixed
deepakdinesh1123 Jul 11, 2024
8eefc60
platform login error message and accesslog default settings added
deepakdinesh1123 Jul 12, 2024
f6e0280
username field added, build updated
deepakdinesh1123 Jul 16, 2024
60f74b9
platform login error message updated
deepakdinesh1123 Jul 16, 2024
9c44dd0
user_id search added and login_attempt filter fixed
deepakdinesh1123 Jul 16, 2024
dc750e4
ip address, role and attempt type search added
deepakdinesh1123 Jul 16, 2024
c0781df
user_id search fixed
deepakdinesh1123 Jul 16, 2024
8f592fc
fe accesslogs code clean up
sukuna28 Jul 16, 2024
76e17d8
chore: access logs table refactoring
sukuna28 Jul 17, 2024
d28c15c
Merge remote-tracking branch 'origin/main' into chore/accesslogs-fe-c…
sukuna28 Jul 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/src/zango/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,4 @@
'REMOTE_ADDR',
'HTTP_X_FORWARDED_FOR',
'HTTP_X_REAL_IP',
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ export default function AppAccessLogs() {
};

makeApiCall();
}, [rerenderPage]);
}, [rerenderPage, appAccessLogsTableData]);

if (!appAccessLogsTableData) {
return null;
}

return (
<>
Expand Down
356 changes: 356 additions & 0 deletions frontend/src/pages/appAccessLogs/components/Table/columns.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,356 @@
import { createColumnHelper } from '@tanstack/react-table';
import { find } from 'lodash';
import TableDateRangeFilter from '../../../../components/Table/TableDateRangeFilter';
import TableDropdownFilter from '../../../../components/Table/TableDropdownFilter';
import { handleColumnSearch } from '../../../../utils/table';
function columns({ debounceSearch, localTableData, tableData }) {
const columnHelper = createColumnHelper();

const columnsData = [
columnHelper.accessor((row) => row.id, {
id: 'id',
header: () => (
<div className="flex h-full items-start justify-start border-b-[4px] border-[#F0F3F4] py-[12px] pl-[32px] pr-[20px] text-start">
<span className="min-w-max font-lato text-[11px] font-bold uppercase leading-[16px] tracking-[0.6px] text-[#6C747D]">
Id
</span>
</div>
),
cell: (info) => {
return (
<div className="flex h-full flex-col gap-[8px] border-b border-[#F0F3F4] py-[14px] pl-[32px] pr-[20px]">
<span className="text-start font-lato text-[14px] font-normal capitalize leading-[20px] tracking-[0.2px]">
{info.getValue()}
</span>
</div>
);
},
}),
columnHelper.accessor((row) => row.user, {
id: 'user',
header: () => (
<div className="flex h-full items-start justify-start border-b-[4px] border-[#F0F3F4] px-[20px] py-[12px] text-start">
<span className="min-w-max font-lato text-[11px] font-bold uppercase leading-[16px] tracking-[0.6px] text-[#6C747D]">
User
</span>
</div>
),
cell: (info) => (
<div className="flex h-full flex-col border-b border-[#F0F3F4] px-[20px] py-[14px]">
<span className="whitespace-nowrap text-start font-lato text-[14px] font-normal capitalize leading-[20px] tracking-[0.2px]">
{info.getValue()}
</span>
</div>
),
}),
columnHelper.accessor((row) => row.username, {
id: 'username',
header: () => (
<div className="flex h-full items-start justify-start border-b-[4px] border-[#F0F3F4] px-[20px] py-[12px] text-start">
<span className="min-w-max font-lato text-[11px] font-bold uppercase leading-[16px] tracking-[0.6px] text-[#6C747D]">
Username
</span>
</div>
),
cell: (info) => (
<div className="flex h-full flex-col border-b border-[#F0F3F4] px-[20px] py-[14px]">
<span className="whitespace-nowrap text-start font-lato text-[14px] font-normal leading-[20px] tracking-[0.2px]">
{info.getValue()}
</span>
</div>
),
}),
columnHelper.accessor((row) => row.ip_address, {
id: 'ip_address',
header: () => (
<div className="flex h-full items-start justify-start border-b-[4px] border-[#F0F3F4] px-[20px] py-[12px] text-start">
<span className="min-w-max font-lato text-[11px] font-bold uppercase leading-[16px] tracking-[0.6px] text-[#6C747D]">
Ip Address
</span>
</div>
),
cell: (info) => (
<div className="flex h-full flex-col border-b border-[#F0F3F4] px-[20px] py-[14px]">
<span className="text-start font-lato text-[14px] font-normal capitalize leading-[20px] tracking-[0.2px]">
{info.getValue()}
</span>
</div>
),
}),
columnHelper.accessor((row) => row.attempt_type, {
id: 'attempt_type',
header: () => (
<div className="flex h-full items-start justify-start gap-[16px] border-b-[4px] border-[#F0F3F4] px-[20px] py-[12px] text-start">
<span className="font-lato text-[11px] font-bold uppercase leading-[16px] tracking-[0.6px] text-[#6C747D]">
Attempt Type
</span>
<div className="translate-y-[-2px]">
<TableDropdownFilter
key="attempt_type"
label="Attempt Type"
name="attempt_type"
id="attempt_type"
placeholder="Select"
value={
find(localTableData?.columns, {
id: 'attempt_type',
})?.value
? find(localTableData?.columns, {
id: 'attempt_type',
})?.value
: ''
}
optionsDataName="attempt_type"
optionsData={
tableData?.dropdown_options?.attempt_type
? tableData?.dropdown_options?.attempt_type
: []
}
onChange={(value) => {
handleColumnSearch(
{
id: 'attempt_type',
value: value?.id,
},
localTableData,
debounceSearch
);
}}
/>
</div>
</div>
),
cell: (info) => (
<div className="flex h-full flex-col border-b border-[#F0F3F4] px-[20px] py-[14px]">
<span className="text-start font-lato text-[14px] font-normal capitalize leading-[20px] tracking-[0.2px]">
{info.getValue()}
</span>
</div>
),
}),
columnHelper.accessor((row) => row.attempt_time, {
id: 'attempt_time',
header: () => (
<div className="flex h-full items-start justify-start gap-[16px] border-b-[4px] border-[#F0F3F4] px-[20px] py-[12px] text-start">
<span className="whitespace-nowrap font-lato text-[11px] font-bold uppercase leading-[16px] tracking-[0.6px] text-[#6C747D]">
Attempt Time
</span>
<div className="">
<TableDateRangeFilter
key="attempt_time"
label="Stockist"
name="attempt_time"
id="attempt_time"
placeholder="Select"
value={
find(localTableData?.columns, {
id: 'attempt_time',
})?.value
? find(localTableData?.columns, {
id: 'attempt_time',
})?.value
: ''
}
optionsDataName="attempt_time"
optionsData={tableData?.dropdown_options?.attempt_time}
onChange={(value) => {
handleColumnSearch(
{
id: 'attempt_time',
value: value,
},
localTableData,
debounceSearch
);
}}
/>
</div>
</div>
),
cell: (info) => (
<div className="flex h-full flex-col border-b border-[#F0F3F4] px-[20px] py-[14px]">
<span className="whitespace-nowrap text-start font-lato text-[14px] font-normal capitalize leading-[20px] tracking-[0.2px]">
{info.getValue()}
</span>
</div>
),
}),
columnHelper.accessor((row) => row.role, {
id: 'role',
header: () => (
<div className="flex h-full items-start justify-start gap-[16px] border-b-[4px] border-[#F0F3F4] px-[20px] py-[12px] text-start">
<span className="font-lato text-[11px] font-bold uppercase leading-[16px] tracking-[0.6px] text-[#6C747D]">
Role
</span>
<div className="translate-y-[-2px]">
<TableDropdownFilter
key="role"
label="Role"
name="role"
id="role"
placeholder="Select"
value={
find(localTableData?.columns, {
id: 'role',
})?.value
? find(localTableData?.columns, {
id: 'role',
})?.value
: ''
}
optionsDataName="role"
optionsData={
tableData?.dropdown_options?.role
? tableData?.dropdown_options?.role
: []
}
onChange={(value) => {
handleColumnSearch(
{
id: 'role',
value: value?.id,
},
localTableData,
debounceSearch
);
}}
/>
</div>
</div>
),
cell: (info) => (
<div className="flex h-full flex-col border-b border-[#F0F3F4] px-[20px] py-[14px]">
<span className="text-start font-lato text-[14px] font-normal capitalize leading-[20px] tracking-[0.2px]">
{info.getValue()}
</span>
</div>
),
}),
columnHelper.accessor((row) => row.user_agent, {
id: 'user_agent',
header: () => (
<div className="flex h-full items-start justify-start border-b-[4px] border-[#F0F3F4] px-[20px] py-[12px] text-start">
<span className="min-w-max font-lato text-[11px] font-bold uppercase leading-[16px] tracking-[0.6px] text-[#6C747D]">
user agent
</span>
</div>
),
cell: (info) => (
<div className="flex h-full flex-col border-b border-[#F0F3F4] px-[20px] py-[14px]">
<span className="whitespace-nowrap text-start font-lato text-[14px] font-normal capitalize leading-[20px] tracking-[0.2px]">
{info.getValue()}
</span>
</div>
),
}),
columnHelper.accessor((row) => row.session_expired_at, {
id: 'session_expired_at',
header: () => (
<div className="flex h-full items-start justify-start gap-[16px] border-b-[4px] border-[#F0F3F4] px-[20px] py-[12px] text-start">
<span className="whitespace-nowrap font-lato text-[11px] font-bold uppercase leading-[16px] tracking-[0.6px] text-[#6C747D]">
Session Expired At
</span>
<div className="">
<TableDateRangeFilter
key="session_expired_at"
label="Session Expired At"
name="session_expired_at"
id="session_expired_at"
placeholder="Select"
value={
find(localTableData?.columns, {
id: 'session_expired_at',
})?.value
? find(localTableData?.columns, {
id: 'session_expired_at',
})?.value
: ''
}
optionsDataName="session_expired_at"
optionsData={
tableData?.dropdown_options?.session_expired_at
}
onChange={(value) => {
handleColumnSearch(
{
id: 'session_expired_at',
value: value,
},
localTableData,
debounceSearch
);
}}
/>
</div>
</div>
),
cell: (info) => (
<div className="flex h-full flex-col border-b border-[#F0F3F4] px-[20px] py-[14px]">
<span className="whitespace-nowrap text-start font-lato text-[14px] font-normal capitalize leading-[20px] tracking-[0.2px]">
{info.getValue()}
</span>
</div>
),
}),
columnHelper.accessor((row) => row.is_login_successful, {
id: 'is_login_successful',
header: () => (
<div className="flex h-full items-start justify-start gap-[16px] border-b-[4px] border-[#F0F3F4] px-[20px] py-[12px] text-start">
<span className="font-lato text-[11px] font-bold uppercase leading-[16px] tracking-[0.6px] text-[#6C747D]">
Login Attempt
</span>
<div className="translate-y-[-2px]">
<TableDropdownFilter
key="is_login_successful"
label="Is Login Successful"
name="is_login_successful"
id="is_login_successful"
placeholder="Select"
value={
find(localTableData?.columns, {
id: 'is_login_successful',
})?.value
? find(localTableData?.columns, {
id: 'is_login_successful',
})?.value
: ''
}
optionsDataName="is_login_successful"
optionsData={
tableData?.dropdown_options?.is_login_successful
? tableData?.dropdown_options?.is_login_successful
: []
}
onChange={(value) => {
handleColumnSearch(
{
id: 'is_login_successful',
value: value?.id,
},
localTableData,
debounceSearch
);
}}
/>
</div>
</div>
),
cell: (info) => (
<div className="flex h-full flex-col border-b border-[#F0F3F4] px-[20px] py-[14px]">
<span
className={`w-fit min-w-[77px] rounded-[15px] px-[4px] py-[3px] text-center font-lato text-[12px] font-normal capitalize leading-[16px] tracking-[0.2px] text-[#1C1E27] ${
info.getValue() ? 'bg-[#E4F9F2]' : 'bg-[#FBE0DD]'
}`}
>
{info.getValue() ? 'Successful' : 'Failed'}
</span>
</div>
),
}),
];


return columnsData;
}

export default columns;
Loading