Update view IOS
This commit is contained in:
parent
75acf0ed8c
commit
8612d88858
|
|
@ -79,6 +79,7 @@ interface LineConfig {
|
||||||
runningScenario: string
|
runningScenario: string
|
||||||
runningPhysical: boolean
|
runningPhysical: boolean
|
||||||
listFeatureTested: string[]
|
listFeatureTested: string[]
|
||||||
|
isReady: boolean
|
||||||
// history: string
|
// history: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,7 +141,6 @@ export default class LineConnection {
|
||||||
private testingPortPoE: boolean
|
private testingPortPoE: boolean
|
||||||
private outputTestingPortPoE: string
|
private outputTestingPortPoE: string
|
||||||
private debounceSendSummaryReport: NodeJS.Timeout | null = null
|
private debounceSendSummaryReport: NodeJS.Timeout | null = null
|
||||||
public isReady: boolean
|
|
||||||
|
|
||||||
constructor(config: LineConfig, socketIO: any, handleClearLine: () => void) {
|
constructor(config: LineConfig, socketIO: any, handleClearLine: () => void) {
|
||||||
this.config = config
|
this.config = config
|
||||||
|
|
@ -174,7 +174,6 @@ export default class LineConnection {
|
||||||
this.debounceSendSummaryReport = null
|
this.debounceSendSummaryReport = null
|
||||||
this.testingPortPoE = false
|
this.testingPortPoE = false
|
||||||
this.outputTestingPortPoE = ''
|
this.outputTestingPortPoE = ''
|
||||||
this.isReady = false
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Connect to line with socket
|
* Connect to line with socket
|
||||||
|
|
@ -251,8 +250,8 @@ export default class LineConnection {
|
||||||
}
|
}
|
||||||
this.config.output += cleanData(rawData)
|
this.config.output += cleanData(rawData)
|
||||||
this.config.output = this.config.output.slice(-15000)
|
this.config.output = this.config.output.slice(-15000)
|
||||||
if (!this.isReady && canInputCommand(message)) {
|
if (!this.config.isReady && canInputCommand(message)) {
|
||||||
this.isReady = true
|
this.config.isReady = true
|
||||||
this.socketIO.emit('update_status_ready', {
|
this.socketIO.emit('update_status_ready', {
|
||||||
stationId,
|
stationId,
|
||||||
lineId: id,
|
lineId: id,
|
||||||
|
|
@ -300,7 +299,7 @@ export default class LineConnection {
|
||||||
this.config.listFeatureTested = []
|
this.config.listFeatureTested = []
|
||||||
this.config.latestScenario = undefined
|
this.config.latestScenario = undefined
|
||||||
this.physicalTest = new PhysicalPortTest([])
|
this.physicalTest = new PhysicalPortTest([])
|
||||||
this.isReady = false
|
this.config.isReady = false
|
||||||
// this.config.inventory = undefined
|
// this.config.inventory = undefined
|
||||||
this.socketIO.emit('line_disconnected', {
|
this.socketIO.emit('line_disconnected', {
|
||||||
stationId,
|
stationId,
|
||||||
|
|
@ -406,7 +405,7 @@ export default class LineConnection {
|
||||||
this.outputBuffer = ''
|
this.outputBuffer = ''
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!this.isReady) {
|
if (!this.config.isReady) {
|
||||||
console.log('Device is not ready')
|
console.log('Device is not ready')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -1845,6 +1844,7 @@ ${log}
|
||||||
runningScenario: '',
|
runningScenario: '',
|
||||||
runningPhysical: false,
|
runningPhysical: false,
|
||||||
listFeatureTested: [],
|
listFeatureTested: [],
|
||||||
|
isReady: false,
|
||||||
}
|
}
|
||||||
this.physicalTest = new PhysicalPortTest([])
|
this.physicalTest = new PhysicalPortTest([])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -617,7 +617,7 @@ export class WebSocketIo {
|
||||||
let lineIds: number[] = []
|
let lineIds: number[] = []
|
||||||
for (const lineId of dataLines) {
|
for (const lineId of dataLines) {
|
||||||
const line = this.lineMap.get(lineId)
|
const line = this.lineMap.get(lineId)
|
||||||
if (line && line.isReady) {
|
if (line && line.config.isReady) {
|
||||||
lineIds.push(lineId)
|
lineIds.push(lineId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -905,6 +905,7 @@ export class WebSocketIo {
|
||||||
runningScenario: '',
|
runningScenario: '',
|
||||||
latestScenario: latestScenario,
|
latestScenario: latestScenario,
|
||||||
listFeatureTested: [],
|
listFeatureTested: [],
|
||||||
|
isReady: false,
|
||||||
},
|
},
|
||||||
socket,
|
socket,
|
||||||
async () => {
|
async () => {
|
||||||
|
|
|
||||||
|
|
@ -125,11 +125,19 @@ const CardLine = ({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (line?.latestScenario?.detectAI) {
|
if (line?.latestScenario?.detectAI) {
|
||||||
const data =
|
if (
|
||||||
line?.latestScenario?.detectAI?.issue &&
|
!line?.latestScenario?.detectAI?.issue ||
|
||||||
Array.isArray(line?.latestScenario?.detectAI?.issue)
|
line?.latestScenario?.detectAI?.issue.length === 0
|
||||||
? "- " + line?.latestScenario?.detectAI?.issue?.join("\n- ")
|
) {
|
||||||
: "";
|
setIsShowIssue(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const data = Array.isArray(line?.latestScenario?.detectAI?.issue)
|
||||||
|
? "- " +
|
||||||
|
line?.latestScenario?.detectAI?.issue
|
||||||
|
.filter((i: string) => i.trim())
|
||||||
|
.join("\n- ")
|
||||||
|
: "";
|
||||||
if (data && !data.includes("No issues detected")) setIsShowIssue(true);
|
if (data && !data.includes("No issues detected")) setIsShowIssue(true);
|
||||||
else setIsShowIssue(false);
|
else setIsShowIssue(false);
|
||||||
} else setIsShowIssue(false);
|
} else setIsShowIssue(false);
|
||||||
|
|
|
||||||
|
|
@ -40,28 +40,31 @@ const ModalSelectIOS = ({
|
||||||
const [isDisable, setIsDisable] = useState<boolean>(false);
|
const [isDisable, setIsDisable] = useState<boolean>(false);
|
||||||
|
|
||||||
const filterIos = (type: string = "") => {
|
const filterIos = (type: string = "") => {
|
||||||
// Switch: Ưu tiên các dòng 4 chữ số cụ thể
|
const name = (str: string) => str.toLowerCase();
|
||||||
// c2960, c3560, c3750, c3850, c4500, c9xxx
|
|
||||||
const switchRegex = /^(c2960|c3560|c3750|c3850|c4500|c9\d{3})/i;
|
|
||||||
|
|
||||||
// Router: Các dòng ISR đời cũ và mới
|
// SWITCH families
|
||||||
// c18xx, c19xx, c28xx, c29xx (nhưng không phải 2960), c38xx (nhưng không phải 3850), c39xx, isr, asr
|
const switchRegex =
|
||||||
|
/^(c29(60|50)|c35(60|70)|c37(50)|c38(50)|c45(00)|c9\d{3}|cat\d+k|cat\d{4}|catalyst)/i;
|
||||||
|
|
||||||
|
// ROUTER families
|
||||||
const routerRegex =
|
const routerRegex =
|
||||||
/^(c8\d{2}|c18|c19|c28|c29(?!60)|c38(?!50)|c39|isr|asr)/i;
|
/^(c8\d{2}|c18\d{2}|c19\d{2}|c28\d{2}|c29(?!60)\d{2}|c38(?!50)\d{2}|c39\d{2}|isr\d*|asr\d*|csr\d*|ir\d*)/i;
|
||||||
|
|
||||||
return listIos
|
return listIos
|
||||||
.filter((ios) => {
|
.filter((ios) => {
|
||||||
|
const iosName = name(ios.name);
|
||||||
|
|
||||||
if (type === "switch") {
|
if (type === "switch") {
|
||||||
return switchRegex.test(ios.name);
|
return switchRegex.test(iosName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === "router") {
|
if (type === "router") {
|
||||||
return routerRegex.test(ios.name);
|
return routerRegex.test(iosName);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
return true; // nếu không truyền type thì trả hết
|
||||||
})
|
})
|
||||||
.filter((ios) =>
|
.filter((ios) => name(ios.name).includes(inputSearch.toLowerCase()));
|
||||||
ios.name.toLowerCase().includes(inputSearch.toLowerCase())
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue