From 487e306f5590b193575a4172914d298bb18dc83a Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 13 Nov 2023 19:54:50 +0100 Subject: [PATCH] fixed line breaks --- src/Components/LogCard/index.js | 467 +------------------------------- 1 file changed, 2 insertions(+), 465 deletions(-) diff --git a/src/Components/LogCard/index.js b/src/Components/LogCard/index.js index 29d9f47..3aef7e7 100644 --- a/src/Components/LogCard/index.js +++ b/src/Components/LogCard/index.js @@ -214,13 +214,9 @@ export default function LogCard({ color = "#2980b9"; // no match } - style = { padding: "1px", color }; + style = { padding: "1px", color, whiteSpace: "pre-line" }; - return ( - - {log.replace(/(?:\r\n|\r|\n)/g, "
")} -
- ); + return {log}; }} followOutput={true} /> @@ -253,462 +249,3 @@ export default function LogCard({ ); } - -/* - - useEffect(() => { - console.log("useffect logs"); - - // scroll to bottom - if (checkboxAutoScrollChecked && virtuosoRef.current !== undefined) { - console.log("logLength current", logs.length); - - //virtuosoRef.current.autoscrollToBottom(); - - virtuosoRef.current.scrollToIndex({ - index: logs.length + 1, - align: "start", - behavior: "auto", - }); - } - }, [logs]); - - - loadLogs(selectedDate)} /> - -*/ - -/* - const inBrackets = (content, contentColor) => { - return ( - <> - [ - {content} - ] - - ); - }; - - const getMessageType = (logType) => { - if (logType === Constants.SYSTEM_LOG_TYPE.INFO) { - return inBrackets("INFO", "#27ae60"); - } - if (logType === Constants.SYSTEM_LOG_TYPE.DEBUG) { - return inBrackets("DEB", "#e67e22"); - } - if (logType === Constants.SYSTEM_LOG_TYPE.ERROR) { - return inBrackets("ERR", "#e74c3c"); - } - return ""; - }; - - {logData.Logs.filter((log) => { - return ( - (log.Type === 0 && checkboxInfoChecked) || - (log.Type === 1 && checkboxErrorChecked) - ); - }).map((log, i) => { - if ( - (log.Type === 0 && !checkboxInfoChecked) || - (log.Type === 1 && !checkboxErrorChecked) - ) { - return ""; - } - - return ( -
- {inBrackets(FormatDatetime(log.Time), "#7f8c8d")}{" "} - {getMessageType(log.Type)} - {log.Message} -
- ); - })} -*/ - -/*myFetch( - `/log?type=${type === "grouptasks" ? "g" : "s"}&date=${date}&lang=${ - i18n.language - }`, - "GET", - null, - {}, - 0, - Constants.LOG_API_ADDRESS - ) - .then((data) => { - fetchResponse.current = data; - - setLoadingSpinner(false); - - if (data.Logs === null) { - data.Logs = []; - } else { - for (let i = 0; i < data.Logs.length; i++) { - let items = []; - - if (data.Logs[i].Message === "") { - items.push( - - Message not found.{" "} - {data.Logs[i].LogData.length > 0 && ( - <> - Given Args:{" "} - {data.Logs[i].LogData.map((data) => ( - - {data.Type}:{data.Value} - - ))} - - )} - - ); - } - - let splittedMessage = data.Logs[i].Message.split(" "); - - for (let s = 0; s < splittedMessage.length; s++) { - if (splittedMessage[s].includes("%")) { - if (splittedMessage[s] === "%userId%") { - const foundData = data.Logs[i].LogData.find( - (data) => data.Type === "userId" - ); - - if (foundData !== undefined) { - const foundUser = fetchResponse.current.Users.find( - (user) => user.Id === foundData.Value - ); - - items.push( - - {foundUser !== undefined - ? foundUser.Username - : foundData.Value}{" "} - - ); - } else { - items.push( - - ); - } - } else if (splittedMessage[s] === "%groupTaskId%") { - const foundData = data.Logs[i].LogData.find( - (data) => data.Type === "groupTaskId" - ); - - if (foundData !== undefined) { - const foundGroupTask = - fetchResponse.current.GroupTasks.find( - (groupTask) => groupTask.Id === foundData.Value - ); - - items.push( - - ID: - - {foundData.Value} - - - } - title={t("logCard.popover.groupTaskId.title")} - trigger="click" - > - - {foundGroupTask !== undefined - ? foundGroupTask.GroupName - : foundData.Value} - - - } - /> - ); - } else { - items.push( - - ); - } - } else if (splittedMessage[s] === "%taskStepId%") { - const foundData = data.Logs[i].LogData.find( - (data) => data.Type === "taskStepId" - ); - - if (foundData !== undefined) { - const foundGroupTaskStep = - fetchResponse.current.GroupTasksSteps.find( - (step) => step.Id === foundData.Value - ); - - items.push( - - ID: - - {foundGroupTaskStep !== undefined - ? foundGroupTaskStep.Id - : foundData.Value} - - - } - title={t("logCard.popover.groupTaskStep.title")} - trigger="click" - > - {" "} - - {foundGroupTaskStep !== undefined - ? getGroupTaskStepName(foundGroupTaskStep) - : foundData.Value} - - - } - /> - ); - } else { - items.push( - - ); - } - } else if (splittedMessage[s] === "%roleId%") { - const foundData = data.Logs[i].LogData.find( - (data) => data.Type === "roleId" - ); - - if (foundData !== undefined) { - const foundRole = fetchResponse.current.Roles.find( - (role) => role.Id === foundData.Value - ); - - items.push( - - ID: - {foundData.Value} - - } - title={t("logCard.popover.role.title")} - trigger="click" - > - {" "} - - {foundRole !== undefined - ? foundRole.DisplayName - : foundData.Value} - - - } - /> - ); - } else { - items.push( - - ); - } - } else if (splittedMessage[s] === "%groupId%") { - const foundDataCategory = data.Logs[i].LogData.find( - (data) => data.Type === "category" - ); - - const foundDataGroupId = data.Logs[i].LogData.find( - (data) => data.Type === "groupId" - ); - - if ( - foundDataCategory !== undefined && - foundDataGroupId !== undefined - ) { - const foundGroup = - fetchResponse.current.CategoryGroups.find( - (categoryGroup) => - categoryGroup.category === foundDataCategory.Value - ).groups.find( - (group) => group.id === foundDataGroupId.Value - ); - - items.push( - - ID: - {foundDataGroupId.Value} - - } - title={t("logCard.popover.groupId.title")} - trigger="click" - > - {" "} - - {foundGroup !== undefined - ? foundGroup.name - : foundDataGroupId.Value} - - - } - /> - ); - } else { - items.push( - - ); - } - } else { - items.push( - - ); - } - } else { - items.push({splittedMessage[s]} ); - } - } - - data.Logs[i].Message = items; - } - } - - setLogData(data); - }) - .catch((errStatus) => console.log("error", errStatus)); */ - -/* - const getDate = () => { - const today = new Date(); - - return `${today.getDate()}-${today.getMonth() + 1}-${today.getFullYear()}`; - }; */ - -/*const getColorCode = (index) => { - const colorCodes = ["#3498db", "#9b59b6", "#1abc9c"]; - const colorIndex = index % colorCodes.length; - return colorCodes[colorIndex]; - }; - - const ColoredSpanItem = ({ dataLogs, splittedMessage, children }) => { - const logDataIndex = dataLogs.LogData.findIndex( - (data) => data.Type === splittedMessage.replace(new RegExp("%", "g"), "") - ); - - if (logDataIndex !== -1) { - return ( - - {children === undefined ? ( - dataLogs.LogData[logDataIndex].Value - ) : ( - <>{children} - )}{" "} - - ); - } - return <>; - }; - - const getGroupTaskStepName = (groupTaskStep) => { - const foundName = fetchResponse.current.CategoryGroups.find( - (categoryGroup) => - categoryGroup.category === - fetchResponse.current.GroupTasks.find( - (groupTask) => groupTask.Id === groupTaskStep.GroupTasksId - )?.Category - )?.groups.find( - (groups) => - groups.id === - fetchResponse.current.GroupTasks.find( - (groupTask) => groupTask.Id === groupTaskStep.GroupTasksId - ).GroupId - ).tasks[groupTaskStep.Step - 1]; - - return foundName !== undefined ? foundName.name : groupTaskStep.Id; - }; */ - -/* -{logData.Dates.findIndex((date) => date === selectedDate) > 0 ? ( - - - setSelectedDate( - logData.Dates[ - logData.Dates.findIndex((date) => date === selectedDate) - - 1 - ] - ) - } - /> - - ) : ( - - )} - - {logData.Dates.findIndex((date) => date === selectedDate) + 1 < - logData.Dates.length ? ( - - - setSelectedDate( - logData.Dates[ - logData.Dates.findIndex((date) => date === selectedDate) + - 1 - ] - ) - } - /> - - ) : ( - - )} -*/