This commit is contained in:
joseph le 2026-05-20 14:36:12 +07:00
parent 5135f7ba9a
commit 46f72decd3
2 changed files with 22 additions and 2 deletions

View File

@ -242,6 +242,7 @@ const ModalLineHistory = ({
}} }}
testLogContent={selectedHistory?.output || ""} testLogContent={selectedHistory?.output || ""}
isShowShortLog={true} isShowShortLog={true}
portPhysical={selectedHistory?.portPhysical}
/> />
</> </>
); );

View File

@ -12,18 +12,37 @@ const ModalLog = ({
onClose, onClose,
testLogContent, testLogContent,
isShowShortLog = false, isShowShortLog = false,
portPhysical,
}: { }: {
opened: boolean; opened: boolean;
onClose: () => void; onClose: () => void;
testLogContent: string; testLogContent: string;
isShowShortLog?: boolean; isShowShortLog?: boolean;
portPhysical?: {
name: string;
tested: boolean;
}[];
}) => { }) => {
const [valueLog, setValueLog] = useState(testLogContent); const [valueLog, setValueLog] = useState(testLogContent);
const [isShort, setIsShort] = useState(false); const [isShort, setIsShort] = useState(false);
const [valueTestedPorts, setValueTestedPorts] = useState<string>("");
useEffect(() => { useEffect(() => {
setValueLog(testLogContent); setValueLog(testLogContent);
}, [testLogContent]); }, [testLogContent]);
useEffect(() => {
if(portPhysical && Array.isArray(portPhysical)) {
const portPoE = portPhysical.filter(port => !port.name.includes("SFP"))
const poeTested = portPhysical.filter(port => port.tested && !port.name.includes("SFP"))
const portSFP = portPhysical.filter(port => port.name.includes("SFP"))
const sfpTested = portPhysical.filter(port => port.tested && port.name.includes("SFP"))
const value = `POE Tested: ${poeTested.length}/${portPoE.length}\nSFP Tested: ${sfpTested.length}/${portSFP.length}`;
setValueTestedPorts(value);
setValueLog(testLogContent + "\n\n" + value);
}
}, [portPhysical]);
const addTooltipsToHighlights = () => { const addTooltipsToHighlights = () => {
const highlights = document.querySelectorAll(".highlight"); const highlights = document.querySelectorAll(".highlight");
highlights.forEach((highlight) => { highlights.forEach((highlight) => {
@ -99,7 +118,7 @@ const ModalLog = ({
<Button <Button
variant="outline" variant="outline"
onClick={() => { onClick={() => {
setValueLog(createShortLog(testLogContent)); setValueLog(createShortLog(testLogContent) + "\n\n" + valueTestedPorts);
setIsShort(true); setIsShort(true);
}} }}
color="green" color="green"
@ -110,7 +129,7 @@ const ModalLog = ({
<Button <Button
variant="outline" variant="outline"
onClick={() => { onClick={() => {
setValueLog(testLogContent); setValueLog(testLogContent + "\n\n" + valueTestedPorts);
setIsShort(false); setIsShort(false);
}} }}
color="green" color="green"