Skip to content
Merged

Dev #185

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
546cbc2
[CMG-214] - Destination Stack | Error message is not showing when max…
sayalijoshi27 Jul 9, 2024
7d6658c
Merge pull request #178 from contentstack/feature/CMG-57
v1shalpatel Jul 9, 2024
2231f01
logs details
RohitKini Jul 10, 2024
9754728
logger
RohitKini Jul 10, 2024
7c24b73
Conflict resolved
sayalijoshi27 Jul 10, 2024
3473dea
Merge branch 'feature/profile-design' of https://github.com/contentst…
sayalijoshi27 Jul 10, 2024
b0ac49b
refactor:resolved duplicate mapper fields
AishDani Jul 10, 2024
2e3782b
refactor:removed console
AishDani Jul 10, 2024
5326ca9
Merge pull request #179 from contentstack/feature/legacy-cms
v1shalpatel Jul 10, 2024
a5e30cd
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 Jul 10, 2024
ad2adc9
Test Migration Logger screen completed
sayalijoshi27 Jul 10, 2024
d1531b5
Merge pull request #180 from contentstack/feature/profile-design
v1shalpatel Jul 10, 2024
ef423e9
refactor:legacy cms bugs
AishDani Jul 11, 2024
b04cd02
Merge branch 'dev' of github.com:contentstack/migration-v2-node-serve…
AishDani Jul 11, 2024
01225da
Merge pull request #181 from contentstack/feature/legacy-cms
v1shalpatel Jul 11, 2024
571a1ba
solved functional bugs on dest stack
snehalsankhe Jul 12, 2024
79a9be4
merged from dev
snehalsankhe Jul 12, 2024
29c4c83
Merge pull request #183 from contentstack/layout-changes
v1shalpatel Jul 12, 2024
8da6a61
refactor:destination stack modal bug resolved
AishDani Jul 12, 2024
cddcd75
Merge branch 'dev' of github.com:contentstack/migration-v2-node-serve…
AishDani Jul 12, 2024
520637c
Merge pull request #184 from contentstack/bugs-legacyCMS
v1shalpatel Jul 12, 2024
8d7eb78
refactor:close modal prop added
AishDani Jul 12, 2024
a0c0e38
Merge pull request #186 from contentstack/bugs-legacyCMS
v1shalpatel Jul 12, 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
Prev Previous commit
Next Next commit
Test Migration Logger screen completed
  • Loading branch information
sayalijoshi27 committed Jul 10, 2024
commit ad2adc9bec493eb693a7d1ab22591ba46c4b49e7
2 changes: 1 addition & 1 deletion api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ try {
logger.info(`Server listening at port ${config.PORT}`)
);
// Chokidar - Watch for log file changes
const logFilePath = "/Users/rohit/migration-v2-node-server/api/combine.log"; // Replace with the actual path to your log file
const logFilePath = "/Users/sayali.joshi/Projects/migration-v2-node-server/api/combine.log"; // Replace with the actual path to your log file
const watcher = chokidar.watch(logFilePath);
// Socket.IO - Send logs to client
const io = new Server(
Expand Down
6 changes: 3 additions & 3 deletions ui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
crossorigin="anonymous"
/>

<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
rel="preload"
as="style"
href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
/>

<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Montserrat:[email protected]&display=swap"
rel="stylesheet"
/>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet">

<link rel="stylesheet" href="https://ui.contentstack.com/contentstack.min.css" />
<script
Expand Down
58 changes: 49 additions & 9 deletions ui/src/components/LogScreen/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,64 @@

.logs-container {
font-family: Arial, sans-serif;
background-color: $color-base-white-5;
border: 1px solid #EDF1F7;
border-radius: 8px;
margin: 0 $px-24 $px-24;
position: relative;
}
.logs-wrapper {
position: relative;
.action-items {
position: absolute;
right: 48px;
top: 24px;
}
}


.log-entry {
align-items: center;
background-color: $color-base-white-10;
display: flex;
padding: 5px 0;
position: relative;
&::before {
background-color: $color-base-white-5;
border-right: 1px solid $color-brand-secondary-lightest;
bottom: 0;
content: "";
left: 0;
position: absolute;
right: 0;
top: 0;
width: 50px;
}

.log-number, .log-time, .log-message {
font-family: "IBM Plex Mono", monospace;
font-size: $size-font-medium;
font-weight: $font-weight-medium;
}
}

.log-number {
text-align: center;
min-width: 50px;
color: $color-font-active;
position: relative;
}

.log-time {
font-weight: bold;
margin-right: 8px;
color: #333;
padding-right: 5px;
color: $color-font-active;
font-family: "IBM Plex Mono", monospace;
font-size: $size-font-medium;
font-weight: $font-weight-medium;
padding: 0 $px-16;
}

.log-message {
color: $color-black-222;
flex-grow: 1;
color: #555;
}

.log-entry:nth-child(odd) {
background-color: #f9f9f9;
padding: 0 $px-16;
}
109 changes: 54 additions & 55 deletions ui/src/components/LogScreen/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
import React, { useEffect, useState } from 'react';
import { PageLayout, PageTitle, Button } from '@contentstack/venus-components';
// Libraries
import React, { useEffect, useState, useRef } from 'react';
import { Icon } from '@contentstack/venus-components';
import io from 'socket.io-client';

// CSS
import './index.scss';

const logStyles: { [key: string]: React.CSSProperties } = {
info: { backgroundColor: '#f1f1f1' },
warn: { backgroundColor: '#ffeeba', color: '#856404' },
error: { backgroundColor: '#f8d7da', color: '#721c24' },
success: { backgroundColor: '#d4edda', color: '#155724' },
};

const LogViewer = () => {
type LogsType = {
serverPath: string;
}

const LogViewer = ({serverPath}: LogsType) => {
const [logs, setLogs] = useState(["Loading logs..."]);

useEffect(() => {
const socket = io('http://localhost:5000'); // Connect to the server
const socket = io(serverPath || ''); // Connect to the server
socket.on('logUpdate', (newLogs: string) => {
console.log("new logs", newLogs);

const logArray = newLogs.split('\n');
// console.log(logArray);
console.log(logArray);
setLogs(logArray);

});
Expand All @@ -25,57 +35,46 @@ const LogViewer = () => {
socket.disconnect(); // Cleanup on component unmount
};
}, []);

//SCROLL LISTENER
useEffect(() => {
window.addEventListener("scroll", handleScrollToTop);
});

return(
<div
style={{
height: '100vh',
overflow: 'auto',
transform: 'scale(0.6)',
width: '100vw'
}}
>
<PageLayout
content={{
component: <div style={{height: '600px', padding: '20px 0', textAlign: 'center'}}>List Data</div>
}}
footer={{
// component: <div className="flex-justify flex-v-center"><div>2020 Contentstack. All rights reserved. Support | Privacy | Terms</div><div><Button buttonType="primary">Save</Button></div></div>
}}
header={{
// backNavigation: function noRefCheck(){},
component: <h2>Logs</h2>,
}}
type="edit"
// version="v1"
/>
</div>
)
// return (
// <div style={{ fontFamily: 'monospace' }}>
// <h2>Execution Logs</h2>
// <div className="logs-container" style={{ height: '400px', overflowY: 'scroll' }}>
// {logs?.map((log, index) => {
// console.log(log);
// try {
// const logObject = JSON.parse(log);
// const level = logObject.level;
// const timestamp = logObject.timestamp;
// const message = logObject.message;
// return (
// <div key={index} style={logStyles[level] || logStyles.info} className="log-entry">
// <span className="log-time">{index}</span>
// <span className="log-time">{new Date(timestamp).toTimeString().split(' ')[0]}</span>
// <span className="log-message">{message}</span>
// </div>
// );
// } catch (error) {
// console.error('Invalid JSON string', error);
// }
// })}
// </div>
// </div>
// );
const refScrollUp = useRef<HTMLDivElement>(null);
const handleScrollToTop = () => {
console.log("=============", refScrollUp, refScrollUp?.current);

refScrollUp?.current?.scrollIntoView({ behavior: "smooth" });
}
return (
<div className='logs-wrapper'>
<div className="logs-container" style={{ height: '400px', overflowY: 'auto' }}>
{logs?.map((log, index) => {
console.log(log);
try {
const logObject = JSON.parse(log);
const level = logObject.level;
const timestamp = logObject.timestamp;
const message = logObject.message;
return (
<div key={index} style={logStyles[level] || logStyles.info} className="log-entry" ref={index === 0 ? refScrollUp : null}>
<div className="log-number">{index}</div>
<div className="log-time">{new Date(timestamp).toTimeString().split(' ')[0]}</div>
<div className="log-message">{message}</div>
</div>
);
} catch (error) {
console.error('Invalid JSON string', error);
}
})}

</div>
<div className='action-items'>
<Icon icon="ArrowUp" version='v2' onClick={handleScrollToTop} />
</div>
</div>
);
};

export default LogViewer;
13 changes: 5 additions & 8 deletions ui/src/components/TestMigration/index.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
@import '../../scss/App.scss';
@import '../../scss/variables';









.migration-step-container {
max-height: 70vh;
overflow-y: auto;
overflow-x: hidden;
}
11 changes: 8 additions & 3 deletions ui/src/components/TestMigration/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useEffect, useState } from 'react';
import { useNavigate, useParams } from 'react-router-dom';
import { Field, FieldLabel, TextInput, Link, Icon, Tooltip } from '@contentstack/venus-components';
import { useSelector } from 'react-redux';

Expand All @@ -12,6 +11,12 @@ import { CS_ENTRIES } from '../../utilities/constants';
// Interface
import { MigrationType } from './testMigration.interface';

// Component
import LogViewer from '../LogScreen';

// CSS
import './index.scss';

const TestMigration = () => {
const [data, setData] = useState<MigrationType>({});

Expand All @@ -30,7 +35,7 @@ const TestMigration = () => {
}, []);

return (
<div className='step-content-wrapper'>
<div className='migration-step-container'>
<div className='content-block'>
<div className='content-header text-uppercase'>UID</div>
<div className='content-body'>
Expand Down Expand Up @@ -74,7 +79,7 @@ const TestMigration = () => {
<div className='content-block'>
<div className='content-header'>Execution Logs</div>
<div>

<LogViewer serverPath="http://localhost:5001" />
</div>
</div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions ui/src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import { Button } from '@contentstack/venus-components';
import parse from 'html-react-parser';
import LogViewer from '../../components/LogScreen';

// Services
import { getCMSDataFromFile } from '../../cmsData/cmsSelector';

Expand Down Expand Up @@ -45,7 +45,6 @@ const Home = () => {
</Button>
</Link>
)}
<LogViewer/>
</div>
);
};
Expand Down