Skip to content

Commit 9eace91

Browse files
committed
feat: Add Execution Logs component and filtering functionality
- Implemented ExecutionLogs component to display migration logs with filtering options. - Created FilterModal for selecting log levels (info, error). - Integrated API call to fetch migration logs with pagination and filtering. - Updated Settings component to include Execution Logs section. - Added styles for ExecutionLogs and FilterModal components. - Defined TypeScript interfaces for log entries and filter options. - Enhanced user experience with loading states and no data messages.
1 parent 1ec4f40 commit 9eace91

File tree

12 files changed

+957
-49
lines changed

12 files changed

+957
-49
lines changed

api/src/routes/migration.routes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ router.post(
6060
);
6161

6262
router.get(
63-
"/get_migration_logs/:orgId/:projectId/:stackId",
63+
"/get_migration_logs/:orgId/:projectId/:stackId/:skip/:limit/:startIndex/:stopIndex/:searchText/:filter",
6464
asyncRouter(migrationController.getLogs)
6565

6666
)

api/src/services/migration.service.ts

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -636,25 +636,32 @@ const startMigration = async (req: Request): Promise<any> => {
636636
const getLogs = async (req: Request): Promise<any> => {
637637
const projectId = path.basename(req?.params?.projectId);
638638
const stackId = path.basename(req?.params?.stackId);
639-
const srcFunc = 'getLogs';
639+
const limit = parseInt(req?.params?.limit);
640+
const startIndex = parseInt(req?.params?.startIndex);
641+
const stopIndex = startIndex + limit;
642+
const searchText = req?.params?.searchText;
643+
const filter = req?.params?.filter;
640644

641-
if (projectId.includes('..') || stackId.includes('..')) {
642-
throw new BadRequestError('Invalid projectId or stackId');
645+
const srcFunc = "getLogs";
646+
647+
if (projectId.includes("..") || stackId.includes("..")) {
648+
throw new BadRequestError("Invalid projectId or stackId");
643649
}
644650

645651
try {
646-
const logsDir = path.join(process.cwd(), 'logs');
652+
const mainPath = process.cwd().split("migration-v2")[0];
653+
const logsDir = path.join(mainPath, "migration-v2", "api", "logs");
647654
const loggerPath = path.join(logsDir, projectId, `${stackId}.log`);
648-
const absolutePath = path.resolve(loggerPath); // Resolve the absolute path
655+
const absolutePath = path.resolve(loggerPath);
649656

650657
if (!absolutePath.startsWith(logsDir)) {
651-
throw new BadRequestError('Access to this file is not allowed.');
658+
throw new BadRequestError("Access to this file is not allowed.");
652659
}
653660

654661
if (fs.existsSync(absolutePath)) {
655-
const logs = await fs.promises.readFile(absolutePath, 'utf8');
656-
const logEntries = logs
657-
.split('\n')
662+
const logs = await fs.promises.readFile(absolutePath, "utf8");
663+
let logEntries = logs
664+
.split("\n")
658665
.map((line) => {
659666
try {
660667
return JSON.parse(line);
@@ -663,7 +670,40 @@ const getLogs = async (req: Request): Promise<any> => {
663670
}
664671
})
665672
.filter((entry) => entry !== null);
666-
return logEntries;
673+
674+
logEntries = logEntries.slice(1, logEntries.length - 2);
675+
676+
if (filter != "all") {
677+
const filters = filter.split("-");
678+
logEntries = logEntries.filter((log) => {
679+
return filters.some((filter) => {
680+
return (
681+
log?.level?.toLowerCase()?.includes(filter?.toLowerCase())
682+
);
683+
});
684+
});
685+
686+
}
687+
688+
if (searchText != "null") {
689+
logEntries = logEntries.filter((log) => {
690+
return (
691+
log?.level?.toLowerCase()?.includes(searchText?.toLowerCase()) ||
692+
log?.message?.toLowerCase()?.includes(searchText?.toLowerCase()) ||
693+
log?.methodName
694+
?.toLowerCase()
695+
?.includes(searchText?.toLowerCase()) ||
696+
log?.timestamp?.toLowerCase()?.includes(searchText?.toLowerCase())
697+
);
698+
});
699+
700+
}
701+
702+
const paginatedLogs = logEntries.slice(startIndex, stopIndex);
703+
return {
704+
logs: paginatedLogs,
705+
total: logEntries.length,
706+
};
667707
} else {
668708
logger.error(getLogMessage(srcFunc, HTTP_TEXTS.LOGS_NOT_FOUND));
669709
throw new BadRequestError(HTTP_TEXTS.LOGS_NOT_FOUND);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.Icon--original {
2+
width: 240px !important;
3+
height: 240px !important;
4+
}
5+
.table-toolbar-horizontal {
6+
display: flex;
7+
justify-content: space-between;
8+
align-items: center;
9+
padding: 12px 16px;
10+
background-color: #f9fbfd; /* optional, match table bg */
11+
border-bottom: 1px solid #e5eaf1;
12+
}
13+
14+
.search-container {
15+
width: 500px;
16+
}
17+
18+
.dropdown-container {
19+
display: flex;
20+
align-items: center;
21+
}
22+
23+
.table-empty-state {
24+
text-align: center;
25+
padding: 40px 0;
26+
color: #3f4e5c;
27+
display: flex;
28+
flex-direction: column;
29+
align-items: center;
30+
justify-content: center;
31+
}
32+
33+
.table-empty-state svg {
34+
max-width: 300px;
35+
margin-bottom: 12px;
36+
}
37+
38+
.table-empty-text {
39+
font-size: 16px;
40+
font-weight: 500;
41+
}
42+
43+
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
import React from 'react';
2+
3+
export const NoDataSvg = () => {
4+
return (
5+
<div>
6+
<svg
7+
style={{width: "240px", height: "240px"}}
8+
width="240"
9+
height="240"
10+
viewBox="0 0 240 240"
11+
fill="none"
12+
xmlns="http://www.w3.org/2000/svg"
13+
className="Icon--original"
14+
name="NoDataEmptyState"
15+
data-test-id="cs-empty-state-module-image">
16+
<path fill="#fff" d="M0 0h240v240H0z"></path>
17+
<path
18+
opacity="0.25"
19+
d="M15.082 118.747c2.297 19.398 11.134 41.932 28.853 52.315 26.731 15.642 24.478 39.723 76.661 50.195 8.13 1.635 15.862 2.341 23.153 2.165a93.893 93.893 0 0011.355-.928c33.139-4.86 55.452-27.881 63.671-55.717 10.781-36.586-10.737-60.534-25.009-74.982-14.272-14.36-24.744-59.341-75.91-70.034-7.821-1.635-15.818-2.474-23.771-2.297-18.205.442-38.088 6.45-51.83 18.91a62.043 62.043 0 00-3.004 2.917c-19.132 19.618-27.218 50.99-24.125 77.412l-.044.044z"
20+
fill="#DDE3EE"></path>
21+
<path
22+
d="M76.92 64.92L81 57l6.6-1.68 7.2 2.28 3 4.56.72 3.72-21.6.12v-1.08z"
23+
fill="#EDEBFD"></path>
24+
<path d="M76.08 65.76l34.8.84v2.52l-24.6-.6-5.64-1.44-4.56.48v-1.8z" fill="#EDEBFD"></path>
25+
<path
26+
d="M71.28 83.64l4.08-8.76 6.36-3.48 5.16-3.12 11.76.6 1.536 11.137a11.342 11.342 0 01-.576 5.423l-15 11.4-8.4.48-6.96-4.44-2.28-2.64 4.32-6.6z"
27+
fill="#fff"></path>
28+
<path
29+
d="M66.72 89.76L73.08 96l8.52 1.56 5.04-.84 2.16 5.88 3.6 13.92v5.28l-1.68 6 1.08 2.16 2.76.84v6.96l-6.6.48-11.16 4.2-5.04-.72-5.04 1.2-6.96 4.08-9.84 8.28-2.4-1.92-2.76-6.36 2.04-14.4 5.64-22.44 6.36-15.12 7.92-5.28z"
30+
fill="#6E6B86"></path>
31+
<path
32+
d="M76.08 67.92l5.04-.96 3.84 1.68 3.6 4.44 1.8 6.12 3 3 4.2 1.8 2.04 2.88.72 3.48-1.8 6.48-4.2 3-4.56.96v-1.32l-2.28-.6-3.12-1.68-1.44-5.16.48-7.2.96-6.48.6-4.32-1.2-1.8-2.16-.96-1.8 1.8-.96 1.32 1.92 2.64H79.2l-3.6-3-.96-2.76 1.44-3.36z"
33+
fill="#475161"></path>
34+
<path
35+
d="M50.28 154.68L63.96 144l8.16-2.28 4.68.6 9.6-3.6 7.56-.96 6 .96 2.76 1.44 2.76 3.36 3.96-1.32 3.48.12.72 6.12-2.88 13.08-4.08 13.2v4.08l2.64 1.08v3.24l7.92 1.56 1.32 3.12-3.84 3.84-9.72 1.2H91.08l-6.24-3.36-1.32-4.8.36-8.76 2.88-17.64-8.4 3.72-12.6.6-10.56-2.28-4.92-5.64z"
36+
fill="#fff"></path>
37+
<path
38+
d="M52.32 162.24H78.6v29.4l-3.12 1.08-10.08.36-12.48-1.2-.24-.96-.36-28.68z"
39+
fill="#DDE3EE"></path>
40+
<path
41+
d="M92.04 123.6l5.04-2.64 3.24-.84h3.48l3.12.84 2.76 1.56.96 3.12 3.84.96.96 1.68 3.24 3 .84 3-1.68 1.56-1.56 4.44-2.88 1.68-4.2.36-3.84 1.32-1.2-2.64-4.08-2.28-5.88-1.08.36-6.72-3.48-1.44-.48-2.04 1.44-3.84z"
42+
fill="#fff"></path>
43+
<path
44+
d="M14.4 181.68h37.92M109.68 181.68H224.4M78.48 181.68h5.04M75.6 74.4c-1.72 4.28-5.832 13.344-8.52 15.36-3.36 2.52-7.56 2.4-10.8 10.44-2.592 6.432-3.72 9.64-3.96 10.44-2.12 7.68-6.504 24.936-7.08 32.52-.576 7.584 2.88 11.16 4.68 12M72.12 141.84c-7.777.384-17.88 9.12-21.96 13.44 1.52 2.52 6.36 6.48 14.28 7.08m7.68-20.52c-2.6-4.8-7.657-16.056-7.08-22.68m7.08 22.68l2.754.403a7.91 7.91 0 004.186-.523l7.22-3c1.6-.6 6.527-1.44 13.44 0 8.639 1.8 5.759 14.04 5.519 15.84-.192 1.44-1.44 19.56-2.04 28.44m-26.16-20.64l9.44-4.259a.238.238 0 01.337.249c-.98 6.655-2.869 19.365-3.057 20.21-.24 1.08-.48 10.08 1.32 10.8.21.084.625.059 1.2-.052M103.2 183c-4.65 2.017-13.537 5.654-16.92 6.308M103.2 183c21.582-.304 15.103 6.322 11.913 8.392-.773.501-1.698.683-2.609.817-19.733 2.89-25.715-.694-26.224-2.901M81.48 105c.96.6 2.855 2.16 2.76 3.6-.12 1.8.72 16.92 2.04 18.72"
45+
stroke="#475161"
46+
strokeWidth="0.96"
47+
strokeLinecap="round"></path>
48+
<path
49+
d="M52.44 191.555V162.36H78.6v29.242a.231.231 0 01-.143.218c-5.605 2.293-19.384.96-25.82-.029a.235.235 0 01-.197-.236zM109.079 182.88c.28-1 .624-3.12-.24-3.6-1.08-.6-4.08.96-2.04-4.44 1.469-3.887 4.538-16.293 6.303-23.752.361-1.524.64-3.074.577-4.639-.078-1.974-.468-4.102-1.6-4.369-1.632-.384-5.08.8-6.6 1.44M67.08 90c1.8 3.16 7.703 8.977 16.92 6.96M84.96 68.4l25.01.72c1.354-.295 1.522-1.116 1.317-1.726-.173-.515-.762-.666-1.304-.677L76.559 66c-.56.44-1.343 1.391 0 1.68M98.28 66c1.8-7.68-15.72-19.2-21.6-.48"
50+
stroke="#475161"
51+
strokeWidth="0.96"
52+
strokeLinecap="round"></path>
53+
<path
54+
d="M84.097 68.085c1.831 1.002 2.747 2.508 3.787 4.296 2.24 3.769 1.23 4.881 2.849 7.261 2.572 3.797 6.008 2.318 8.24 5.99 1.911 3.12 1.031 6.789.804 7.639-.22.803-1.154 4.057-4.22 5.927-2.666 1.598-5.917 1.573-6.035 1.1-.045-.174.274-.532 2.208-1.429a6.17 6.17 0 01-2.49.62c-1.224.026-2.337-.362-2.312-.526.022-.14.653-.042 1.223-.48.351-.257.526-.613.643-.906-1.056.483-2.331.836-3.446.304-2.984-1.443-2.47-8.47-2.299-10.813.546-7.55 3.33-11.306 1.14-14.326-.177-.243-1.063-1.48-2.264-1.451-1.516.053-2.966 2.15-2.73 3.717.222 1.351 1.613 1.95 1.484 2.169-.188.282-2.593-.57-4.393-2.547-.654-.724-1.21-1.312-1.376-2.247-.322-1.63.608-3.304 1.635-4.222 2.156-1.868 5.567-1.172 7.552-.076z"
55+
stroke="#475161"
56+
strokeWidth="0.96"
57+
strokeMiterlimit="10"></path>
58+
<path
59+
d="M87.6 99.36c.64 1.76 2.016 6.12 2.4 8.04.48 2.4 1.68 6.84 1.92 8.04.135.675.475 2.217.762 3.506a5.07 5.07 0 01-.163 2.782c-.794 2.268-1.84 5.278-1.92 5.592-.12.48-.36 2.76 3.36 3.24M98.28 69.12l2.104 13.448a.24.24 0 01-.292.27l-3.733-.878M92.64 71.4c.76-.48 2.544-1.08 3.6.36M99.84 73.503c.76-.48 2.544-1.08 3.6.36"
60+
stroke="#475161"
61+
strokeWidth="0.96"
62+
strokeLinecap="round"></path>
63+
<circle
64+
cx="94.8"
65+
cy="73.92"
66+
r="0.84"
67+
fill="#475161"
68+
stroke="#475161"
69+
strokeWidth="0.24"></circle>
70+
<circle
71+
cx="101.52"
72+
cy="75.6"
73+
r="0.84"
74+
fill="#475161"
75+
stroke="#475161"
76+
strokeWidth="0.24"></circle>
77+
<path
78+
d="M92.04 124.08c2.16-1.72 7.127-4.872 9.719-3.72M98.52 122.4c1.72-1.32 5.328-3.528 6-1.8.672 1.728 2.44 4.8 3.24 6.12M94.32 129.24v8.4"
79+
stroke="#475161"
80+
strokeWidth="0.96"
81+
strokeLinecap="round"></path>
82+
<path
83+
d="M112.559 142.08c1.12-.24 3.408-.984 3.6-2.04.24-1.32.96-3.12 1.56-3.72.6-.6 4.56-3.36-1.8-7.44-.84-.84-.12-1.8-1.2-2.28-.486-.216-1.527-.366-2.558-.463-1.402-.132-2.81.066-4.162.463v0l-1.28 1.361a2.157 2.157 0 01-1.573.679h-7.595c-1.105 0-2.2.204-3.232.6v0"
84+
stroke="#475161"
85+
strokeWidth="0.96"
86+
strokeLinecap="round"></path>
87+
<path
88+
d="M98.16 125.521c.896.597 3.07 1.586 4.996 1.088a.808.808 0 01.727.144l1.956 1.648M111.84 192.48h17.52M132.479 192.24h2.88M130.56 187.2h2.88M121.199 187.2h7.2M107.039 125.4c12.48-11.4 43.68-33.96 88.8-37.2M104.519 127.32l-1.08.96M104.64 120.48c1.92.08 5.832 1.248 6.12 5.28"
89+
stroke="#475161"
90+
strokeWidth="0.96"
91+
strokeLinecap="round"></path>
92+
<path
93+
d="M115.319 118.92c1.96 2.64 7.464 4.44 13.8-9.48M129.119 109.32c1.96 2.64 17.16 1.44 22.68-10.68 1.96 2.64 17.28.84 23.88-7.32M175.92 91.44c5.88 4.56 17.64-2.04 17.64-3M195.84 88.68l5.28 61.2"
94+
stroke="#475161"
95+
strokeWidth="0.48"
96+
strokeLinecap="round"></path>
97+
<circle cx="201.48" cy="151.56" r="1.56" stroke="#475161" strokeWidth="0.48"></circle>
98+
<path
99+
d="M201.72 153.12c.36 1.4.648 4.128-1.08 3.84"
100+
stroke="#475161"
101+
strokeWidth="0.48"
102+
strokeLinecap="round"></path>
103+
<path
104+
d="M200.639 156.12l-.48 1.44M199.92 156.24l-.24.72"
105+
stroke="#475161"
106+
strokeWidth="0.96"
107+
strokeLinecap="round"></path>
108+
<ellipse cx="202.44" cy="190.92" rx="16.68" ry="5.88" fill="#EEF1F7"></ellipse>
109+
<ellipse cx="202.439" cy="190.92" rx="9.24" ry="3.24" fill="#DDE3EE"></ellipse>
110+
<path
111+
d="M161.596 190.393c-3.246-.866 1.803-1.793 5.891-2.473 1.963 0 5.986.124 6.371.618.481.619 2.404.495 6.251.371 3.847-.123.962 1.855 1.683 3.029.721 1.174-7.093 3.461-10.218 3.647-3.126.185-5.891-1.298-.842-2.226 5.049-.927.962-1.668-1.923-1.854l-.099-.006c-2.811-.181-3.906-.251-7.114-1.106zM210.163 204.554c3.245.73-1.804 1.512-5.891 2.086-1.963 0-5.987-.104-6.371-.521-.481-.522-2.404-.418-6.251-.313-3.847.104-.962-1.565-1.683-2.556-.722-.99 7.092-2.92 10.218-3.076 3.125-.157 5.89 1.095.841 1.877-5.049.782-.961 1.408 1.924 1.564l.099.006c2.811.152 3.905.211 7.114.933z"
112+
fill="#EEF1F7"></path>
113+
<path
114+
d="M144.36 193.92c0 .041-.029.105-.138.183a1.716 1.716 0 01-.48.211c-.42.126-1.008.206-1.662.206-.655 0-1.243-.08-1.663-.206a1.694 1.694 0 01-.479-.211c-.11-.078-.138-.142-.138-.183 0-.041.028-.104.138-.182.106-.076.268-.149.479-.212.42-.126 1.008-.206 1.663-.206.654 0 1.242.08 1.662.206.211.063.373.136.48.212.109.078.138.141.138.182zM144.36 198.48c0 .041-.029.105-.138.183a1.716 1.716 0 01-.48.211c-.42.127-1.008.206-1.662.206-.655 0-1.243-.079-1.663-.206a1.694 1.694 0 01-.479-.211c-.11-.078-.138-.142-.138-.183 0-.041.028-.104.138-.182.106-.076.268-.149.479-.212.42-.126 1.008-.206 1.663-.206.654 0 1.242.08 1.662.206.211.063.373.136.48.212.109.078.138.141.138.182zM157.08 196.08c0 .005-.005.037-.079.087-.071.048-.18.095-.326.137a4.408 4.408 0 01-1.155.136c-.456 0-.865-.053-1.155-.136a1.174 1.174 0 01-.326-.137c-.074-.05-.079-.082-.079-.087 0-.005.005-.037.079-.087.07-.048.18-.095.326-.137.29-.083.699-.136 1.155-.136.456 0 .864.053 1.155.136.146.042.255.089.326.137.074.05.079.082.079.087zM186.359 206.16c0 .006-.005.037-.079.088-.07.047-.18.094-.326.136-.29.083-.699.136-1.155.136-.456 0-.864-.053-1.155-.136a1.223 1.223 0 01-.326-.136c-.074-.051-.079-.082-.079-.088 0-.005.005-.037.079-.087.071-.048.18-.095.326-.137a4.408 4.408 0 011.155-.136c.456 0 .865.053 1.155.136.146.042.256.089.326.137.074.05.079.082.079.087z"
115+
stroke="#475161"
116+
strokeWidth="0.24"></path>
117+
<path
118+
d="M119.3 41.52H43.114a.236.236 0 01-.212-.347c1.346-2.512 4.333-7.194 6.898-8.293 3.36-1.44 4.8-.6 7.8 0s4.2-2.16 4.92-3c.72-.84 4.56-4.8 11.64-5.76 7.08-.96 9.36-.6 12.72 3.36 3.36 3.96 2.64 5.28 7.56 5.4 4.92.12 4.2.6 9.24 2.88s2.16.6 7.32.6c3.85 0 7.094 2.992 8.487 4.79a.23.23 0 01-.187.37zM159.621 32.64h-39.229a.234.234 0 01-.209-.346c.736-1.347 2.219-3.632 3.499-4.185 1.748-.755 2.498-.315 4.058 0 1.561.315 2.185-1.133 2.56-1.574.375-.44 2.372-2.517 6.056-3.02 3.683-.504 4.869-.315 6.617 1.762 1.748 2.077 1.374 2.769 3.933 2.832 2.56.063 2.185.314 4.807 1.51 2.622 1.196 1.124.315 3.809.315 1.886 0 3.494 1.392 4.28 2.342.123.15.013.364-.181.364zM159.382 63.84h-39.23a.235.235 0 01-.209-.346c.737-1.347 2.22-3.632 3.5-4.185 1.748-.755 2.497-.315 4.058 0s2.185-1.133 2.56-1.573c.374-.441 2.372-2.518 6.055-3.021 3.684-.504 4.87-.315 6.618 1.762 1.748 2.077 1.373 2.77 3.933 2.832 2.56.063 2.185.315 4.807 1.51 2.622 1.196 1.124.315 3.808.315 1.887 0 3.494 1.393 4.28 2.343.124.149.013.364-.18.364z"
119+
stroke="#475161"
120+
strokeWidth="0.96"
121+
strokeLinecap="round"></path>
122+
<path
123+
d="M64.27 57.766c-.661.639-1.775 2.063-.936 2.652 1.048.736 2.342.775 2.662 1.202.32.427.213 1.174-.444 2.146-.657.97-.589 1.518-.14 1.729.359.169.804.092.982.033M67.365 56.712c-.661.638-1.775 2.062-.936 2.651 1.047.737 2.342.775 2.662 1.203.32.426.213 1.173-.444 2.145-.657.971-.59 1.518-.14 1.73.359.168.804.092.982.032M71.67 48.38c-.662.639-1.775 2.063-.937 2.652 1.048.736 2.343.775 2.662 1.202.32.427.214 1.174-.444 2.145-.657.972-.588 1.519-.14 1.73.36.169.805.092.983.033M74.765 47.326c-.662.638-1.775 2.062-.937 2.651 1.048.737 2.342.776 2.662 1.203.32.427.213 1.174-.444 2.145-.657.971-.589 1.519-.14 1.73.36.168.805.092.982.033"
124+
stroke="#6E6B86"
125+
strokeWidth="0.96"
126+
strokeLinecap="round"></path>
127+
</svg>
128+
</div>
129+
);
130+
};

0 commit comments

Comments
 (0)