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

Feat/fe task detail and history #364

Closed
wants to merge 12 commits into from
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prem056627 remove this file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prem056627 remove this file

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this file

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prem056627 Please remove this file

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*! For license information please see main.33db755a.js.LICENSE.txt */
2 changes: 1 addition & 1 deletion frontend/src/components/Modal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ReactComponent as ModalCloseIcon } from '../../assets/images/svg/modal-
function Modal({ label = '', show = false, closeModal, ModalBody }) {
return (
<Transition appear show={show} as={Fragment}>
<Dialog as="div" className="relative z-10" onClose={() => {}}>
<Dialog as="div" className="relative z-30" onClose={() => {}}>
<Transition.Child
as={Fragment}
enter="ease-in-out duration-700"
Expand Down
64 changes: 64 additions & 0 deletions frontend/src/components/Table/HeaderInfoHover.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Menu, Transition } from '@headlessui/react';
import { Fragment, useState } from 'react';
import { usePopper } from 'react-popper';
import { ReactComponent as InfoIcon } from '../../../src/assets/images/svg/info-icon.svg';

export default function HeaderInfoHover({ message }) {
const [referenceElement, setReferenceElement] = useState(null);
const [popperElement, setPopperElement] = useState(null);
const [isOpen, setIsOpen] = useState(false);

const { styles, attributes } = usePopper(referenceElement, popperElement, {
placement: 'bottom-end',
modifiers: [
{
name: 'offset',
options: {
offset: [460, 2],
},
},
],
});

return (
<div
className="relative"
onMouseEnter={() => setIsOpen(true)}
onMouseLeave={() => setIsOpen(false)}
>
<Menu as="div" className="relative flex">
<Transition
as={Fragment}
ref={(ref) => setPopperElement(ref)}
style={styles.popper}
{...attributes.popper}
show={isOpen}
>
<Menu.Items className="absolute bottom-[30px] right-0 z-20 min-w-[186px] origin-bottom-right rounded-[4px] bg-white shadow-table-menu focus:outline-none">
<div className="p-[4px]">
<Menu.Item>
{({ active }) => (
<div
className={`${
active ? 'bg-white' : ''
} flex w-full max-w-fit flex-col rounded-[2px] px-[12px] py-[8px]`}
>
<span className="text-wrap text-start font-lato text-[12px] leading-[16px] tracking-[0.2px] text-[#6C747D]">
{message}
</span>
</div>
)}
</Menu.Item>
</div>
</Menu.Items>
</Transition>
<Menu.Button
className="relative z-10 flex w-full justify-center focus:outline-none"
ref={(ref) => setReferenceElement(ref)}
>
<InfoIcon className="h-[16px] min-h-[16px] w-[16px] min-w-[16px] z-10 " />
</Menu.Button>
</Menu>
</div>
);
}
2 changes: 1 addition & 1 deletion frontend/src/components/Table/TableHead.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { flexRender } from '@tanstack/react-table';

function TableHead({ table }) {
return (
<thead className="sticky top-0 z-[2] bg-[#ffffff]">
<thead className="sticky top-0 z-30 bg-[#ffffff] ">
{table.getHeaderGroups().map((headerGroup) => (
<tr key={headerGroup.id}>
{headerGroup.headers.map((header) => (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "buildMajor": 0, "buildMinor": 3, "buildPatch": 0, "buildTag": "" }
{"buildMajor":0,"buildMinor":3,"buildPatch":1,"buildTag":""}
110 changes: 110 additions & 0 deletions frontend/src/mocks/appTasksManagementHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const newTask = () => {
last_login: faker.date.past(),
is_enabled: faker.datatype.boolean(),
created_at: faker.date.past(),
docstring: '\n This is a docstring\n ',
code: '@shared_task()\ndef test():\n """\n This is a docstring\n """\n print("test")\n return "test"\n',
};
};

Expand Down Expand Up @@ -99,6 +101,7 @@ export const appTasksManagementHandlers = [
return res(
ctx.delay(500),
ctx.status(200),

ctx.json({
success: true,
response: {
Expand All @@ -123,6 +126,113 @@ export const appTasksManagementHandlers = [
);
}),

rest.get('/api/v1/apps/:appId/tasks/:taskId', (req, res, ctx) => {
return res(
ctx.delay(500),
ctx.status(200),
ctx.json({
success: true,
response: {
task: {
id: 2,
attached_policies: [],
crontab: {
minute: '*',
hour: '*',
day_of_week: '*',
day_of_month: '*',
month_of_year: '*',
},
schedule: '* * * * *',
docstring: '',
code: '',
run_history: [
{
date_created: '2024-08-12T07:30:00.043275Z',
date_done: '2024-08-12T07:30:00.043294Z',
result: '"Task completed successfully"',
traceback: null,
},
{
date_created: '2024-08-12T07:29:00.039694Z',
date_done: '2024-08-12T07:29:00.039726Z',
result: '"Data processed"',
traceback:
'Traceback(mostrecentalllast):Filetask.py,line4,inprocess_datadatafetch_dTraceback(mostrecent call last):\n File "task.py", line 34, in process_data\n data = fetch_dTraceback (most recent call last):\n File "task.py", line 34, in process_data\n data = fetch_dTraceback (most recent call last):\n File "task.py", line 34, in process_data\n data = fetch_dTraceback (most recent call last):\n File "task.py", line 34, in process_data\n data = fetch_dTraceback (most recent call last):Filetask.py", line 34, in process_data\n data = fetch_dTraceback (most recent call last):\n File "task.py", line 34, in process_data\n data = fetch_dTraceback (most recent call last):\n File "task.py", line 34, in process_data\n data = fetch_data()\nKeyError: \'id\'',
},
{
date_created: '2024-08-12T07:28:00.141579Z',
date_done: '2024-08-12T07:28:00.141628Z',
result: '"Export failed"',
traceback:
'TraceThisisaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocsspropertiesappliedtowraporbreakwordsappropriatelysuchtextcanoverfloworbreaklayoutsinunexpectedsituationsback (most recent call last):\n File "task.py", line 22, in export_data\n export_to_csv(data)\nFileNotFoundError: [Errno 2] No such file or directory: \'output.csv\'',
},
{
date_created: '2024-08-12T07:27:00.141579Z',
date_done: '2024-08-12T07:27:00.141628Z',
result: '"Email sent"',
traceback: null,
},
{
date_created: '2024-08-12T07:26:00.141579Z',
date_done: '2024-08-12T07:26:00.141628Z',
result: '"Database update failed"',
traceback:
'TracThisisaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocsspropertiesappliedtowraporbreakwordsappropriatelysuchtextcanoverfloworbreaklayoutsinunexpectedsituationseback (most recent call last):\n File "task.py", line 45, in update_database\n cursor.execute(query)\npsycopg2.IntegrityError: duplicate key value violates unique constraint "users_pkey"',
},
{
date_created: '2024-08-12T07:25:00.141579Z',
date_done: '2024-08-12T07:25:00.141628Z',
result: '"Backup completed with warnings"',
traceback:
'Traceback (most recent call last):\n File "backup.py", line 10, in perform_backup\n raise Warning(\'Low disk space\')\nWarning: Low disk space',
},
{
date_created: '2024-08-12T07:24:00.141579Z',
date_done: '2024-08-12T07:24:00.141628Z',
result: '"Report generation failed"',
traceback:
'Traceback (most recent call last):\n FiThisisaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocssproaplaceholderparagraphdesignedtoshowwhattextwithoutspaceslookslikewhenitisrenderedinawebpagewithnocsspropertiesappliedtowraporbreakwordsappropriatelysuchtextcanoverfloworbreaklayoutsinunexpectedsituationsle "report.py", line 59, in generate_report\n report = create_report(data)\nValueError: Missing required field \'report_name\'',
},
{
date_created: '2024-08-12T07:23:00.141579Z',
date_done: '2024-08-12T07:23:00.141628Z',
result: '"Task completed with warnings"',
traceback:
'Traceback (most recent call last):\n File "task.py", line 78, in execute_task\n validate_input(input_data)\nDeprecationWarning: \'validate_input\' is deprecated and will be removed in future versions',
},
{
date_created: '2024-08-12T07:22:00.141579Z',
date_done: '2024-08-12T07:22:00.141628Z',
result: '"Task failed"',
traceback:
'Traceback (most recent call last):\n File "task.py", line 11, in perform_task\n run_process()\nTypeError: \'NoneType\' object is not callable',
},
{
date_created: '2024-08-12T07:21:00.141579Z',
date_done: '2024-08-12T07:21:00.141628Z',
result: '"File upload failed"',
traceback:
'Traceback (most recent call last):\n File "upload.py", line 27, in upload_file\n response = requests.post(url, files=files)\nrequests.exceptions.ConnectionError: Failed to establish a new connection',
},
],

created_at: '2024-08-12T07:22:14.716445Z',
created_by: '',
modified_at: '2024-08-12T07:30:21.674722Z',
modified_by: '',
name: 'accounts.tasks.test',
is_enabled: false,
is_deleted: true,
args: '["CRMApp2", "accounts.tasks.test"]',
kwargs: {},
interval: null,
master_task: 52,
},
},
})
);
}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prem056627 revert this data as previously discussed

rest.post('/api/v1/apps/:appId/tasks/', (req, res, ctx) => {
const action = req.url.searchParams.get('action');
if (action === 'sync_tasks') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createColumnHelper } from '@tanstack/react-table';
import { find } from 'lodash';
import moment from 'moment';
import HeaderInfo from '../../../../components/Table/HeaderInfo';

import ListGeneralCell from '../../../../components/Table/ListGeneralCell';
import TableDateRangeFilter from '../../../../components/Table/TableDateRangeFilter';
import TableDropdownFilter from '../../../../components/Table/TableDropdownFilter';
Expand Down Expand Up @@ -146,7 +147,7 @@ function columns({ debounceSearch, localTableData, tableData }) {
id: 'actor',
header: () => (
<div className="flex h-full items-start justify-start gap-[10px] whitespace-nowrap 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]">
<span className="font-lato text-[11px] font-bold uppercase leading-[16px] tracking-[0.6px] text-[#6C747D] ">
Actor
</span>
<HeaderInfo message={'* Denotes Platform User'} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ export default function RowMenu({ rowData }) {
</Menu.Button>
<Transition
as={Fragment}
// @ts-ignore
ref={(ref) => setPopperElement(ref)}
style={styles['popper']}
{...attributes['popper']}
>
<Menu.Items className="absolute top-[30px] right-0 w-[186px] origin-top-right rounded-[4px] bg-white shadow-table-menu focus:outline-none">
<Menu.Items className="absolute right-0 top-[30px] w-[186px] origin-top-right rounded-[4px] bg-white shadow-table-menu focus:outline-none">
<div className="p-[4px]">
{rowData?.status === 'Installed' ? null : (
<Menu.Item>
Expand All @@ -68,9 +67,6 @@ export default function RowMenu({ rowData }) {
<span className="text-start font-lato text-[14px] font-bold leading-[20px] tracking-[0.2px] text-[#212429]">
Install Package
</span>
{/* <span className="text-start font-lato text-[12px] leading-[16px] tracking-[0.2px] text-[#6C747D]">
install package
</span> */}
</div>
</button>
)}
Expand All @@ -94,9 +90,6 @@ export default function RowMenu({ rowData }) {
<span className="text-start font-lato text-[14px] font-bold leading-[20px] tracking-[0.2px] text-[#212429]">
Configure Package
</span>
{/* <span className="text-start font-lato text-[12px] leading-[16px] tracking-[0.2px] text-[#6C747D]">
configure
</span> */}
prem056627 marked this conversation as resolved.
Show resolved Hide resolved
</div>
</button>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function RowMenu({ rowData }) {
style={styles['popper']}
{...attributes['popper']}
>
<Menu.Items className="absolute top-[30px] right-0 w-[210px] origin-top-right rounded-[4px] bg-white shadow-table-menu focus:outline-none">
<Menu.Items className="absolute right-0 top-[30px] w-[210px] origin-top-right rounded-[4px] bg-white shadow-table-menu focus:outline-none">
<div className="p-[4px]">
<Menu.Item>
{({ active }) => (
Expand All @@ -73,30 +73,6 @@ export default function RowMenu({ rowData }) {
</button>
)}
</Menu.Item>
{/* <Menu.Item>
{({ active }) => (
<button
type="button"
className="flex w-full disabled:opacity-50"
onClick={handleDeletePolicy}
disabled={rowData?.type === 'system' ? true : false}
>
<div
className={`${
active ? 'bg-[#F0F3F4]' : ''
} flex w-full flex-col rounded-[2px] px-[12px] py-[8px]`}
>
<span className="text-start font-lato text-[14px] font-bold leading-[20px] tracking-[0.2px] text-[#AA2113]">
Delete Policy
</span>
<span className="text-start font-lato text-[12px] leading-[16px] tracking-[0.2px] text-[#6C747D]">
this will delete the entire permission along with all it’s
details
</span>
</div>
</button>
)}
</Menu.Item> */}
</div>
</Menu.Items>
</Transition>
Expand Down
Loading
Loading