Skip to content

Commit 64533db

Browse files
committed
Implemented showing timestamp for logs
1 parent 83835ba commit 64533db

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

frontend/src/pages/Runs/Details/Logs/index.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const Logs: React.FC<IProps> = ({ className, projectName, runName, jobSub
2626
const [isLoading, setIsLoading] = useState(false);
2727
const [getProjectLogs] = useLazyGetProjectLogsQuery();
2828
const [isEnabledDecoding, setIsEnabledDecoding] = useLocalStorageState('enable-encode-logs', false);
29-
// const [isShowTimestamp, setIsShowTimestamp] = useLocalStorageState('enable-showing-timestamp-logs', false);
29+
const [isShowTimestamp, setIsShowTimestamp] = useLocalStorageState('enable-showing-timestamp-logs', false);
3030

3131
const logsForView = useMemo(() => {
3232
if (isEnabledDecoding) {
@@ -103,6 +103,10 @@ export const Logs: React.FC<IProps> = ({ className, projectName, runName, jobSub
103103
setIsEnabledDecoding(!isEnabledDecoding);
104104
};
105105

106+
const toggleShowingTimestamp = () => {
107+
setIsShowTimestamp(!isShowTimestamp);
108+
};
109+
106110
useEffect(() => {
107111
getLogItems();
108112
}, []);
@@ -172,11 +176,15 @@ export const Logs: React.FC<IProps> = ({ className, projectName, runName, jobSub
172176
/>
173177
</Box>
174178

175-
{/*<Box>*/}
176-
{/* <Toggle onChange={({ detail }) => setIsShowTimestamp(detail.checked)} checked={isShowTimestamp}>*/}
177-
{/* Show timestamp*/}
178-
{/* </Toggle>*/}
179-
{/*</Box>*/}
179+
<Box>
180+
<Button
181+
ariaLabel="Show timestamp"
182+
formAction="none"
183+
iconName="status-pending"
184+
variant={isShowTimestamp ? 'primary' : 'icon'}
185+
onClick={toggleShowingTimestamp}
186+
/>
187+
</Box>
180188
</div>
181189
</div>
182190
}
@@ -195,7 +203,7 @@ export const Logs: React.FC<IProps> = ({ className, projectName, runName, jobSub
195203
<Code className={styles.terminal} ref={codeRef}>
196204
{logsForView.map((log, i) => (
197205
<p key={i}>
198-
{/*{isShowTimestamp && <span className={styles.timestamp}>{log.timestamp}</span>}*/}
206+
{isShowTimestamp && <span className={styles.timestamp}>{log.timestamp}</span>}
199207
{log.message}
200208
</p>
201209
))}

frontend/src/pages/Runs/Details/Logs/styles.module.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
.switchers {
1515
margin-left: auto;
1616
display: flex;
17-
gap: 24px;
17+
gap: 10px;
18+
19+
button {
20+
width: 32px !important;
21+
}
1822
}
1923
}
2024

0 commit comments

Comments
 (0)