Update note from user
This commit is contained in:
parent
ae7050a719
commit
e1f8e42112
|
|
@ -1042,6 +1042,28 @@ export default class LineConnection {
|
|||
await updateNoteToERP(sn, note)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update note of SN to ERP from user input
|
||||
*/
|
||||
async updateNoteFromUser(sn: string, note: string, licenses: string[]) {
|
||||
const timeZone = process.env.TIME_ZONE || 'Australia/Sydney'
|
||||
const dataFormat = momentTZ().tz(timeZone).format('YYYY/MM/DD, HH:mm')
|
||||
const data = `-------[ATC]-[${dataFormat}]-------\nLicense: ${licenses.join(', ')}\nIssues:\n${note}\n\n`
|
||||
const issueList = note
|
||||
.split('\n')
|
||||
.map((line) => (line[0] === '-' ? line.substring(1).trim() : line.trim()))
|
||||
|
||||
const detectAI = this.config?.latestScenario?.detectAI
|
||||
? { ...this.config.latestScenario.detectAI, issue: issueList }
|
||||
: { issue: issueList, summary: '', status: [] }
|
||||
|
||||
if (this.config.latestScenario) {
|
||||
this.config.latestScenario = { ...this.config.latestScenario, detectAI }
|
||||
}
|
||||
|
||||
await updateNoteToERP(sn, data)
|
||||
}
|
||||
|
||||
/**
|
||||
* Starting physical test (PoE ports testing)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -639,11 +639,17 @@ export async function updateNoteToERP(sn: string, note: string) {
|
|||
}
|
||||
)
|
||||
|
||||
// console.log('updateNoteToERP', responseDataSN?.data?.data)
|
||||
if (!responseDataSN?.data?.data || responseDataSN?.data?.data?.length === 0) {
|
||||
console.log('updateNoteToERP', responseDataSN?.data)
|
||||
return
|
||||
}
|
||||
const dataSN = responseDataSN?.data?.data[0] || {}
|
||||
const dataSN =
|
||||
responseDataSN?.data?.data.length === 1
|
||||
? responseDataSN?.data?.data[0]
|
||||
: responseDataSN?.data?.data.length > 1
|
||||
? responseDataSN?.data?.data.find((el: any) => el.serialNumberA === sn)
|
||||
: {}
|
||||
if (!dataSN?.id) return
|
||||
|
||||
const payload = {
|
||||
id: dataSN?.id,
|
||||
|
|
@ -664,7 +670,7 @@ export async function updateNoteToERP(sn: string, note: string) {
|
|||
}
|
||||
)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
console.log('updateNoteToERP', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -812,6 +812,24 @@ export class WebSocketIo {
|
|||
{}
|
||||
)
|
||||
})
|
||||
|
||||
socket.on('update_note', async (data) => {
|
||||
console.log('Update note', data)
|
||||
const { stationId, lineId, note, licenses, sn } = data
|
||||
// Check station is active
|
||||
const activeStation = await checkStationActive(stationId)
|
||||
if (!activeStation) return
|
||||
|
||||
await this.handleLineOperation(
|
||||
io,
|
||||
stationId,
|
||||
[lineId],
|
||||
async (lineCon) => {
|
||||
lineCon.updateNoteFromUser(sn, note, licenses)
|
||||
},
|
||||
{}
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
socketServer.listen(SOCKET_IO_PORT, () => {
|
||||
|
|
@ -830,7 +848,8 @@ export class WebSocketIo {
|
|||
station: Station,
|
||||
output = '',
|
||||
inventory: string = '',
|
||||
latestScenario?: any
|
||||
latestScenario?: any,
|
||||
data?: any
|
||||
) {
|
||||
try {
|
||||
for (const line of lines) {
|
||||
|
|
@ -851,7 +870,7 @@ export class WebSocketIo {
|
|||
openCLI: false,
|
||||
userEmailOpenCLI: '',
|
||||
userOpenCLI: '',
|
||||
data: [],
|
||||
data: data,
|
||||
ports: [],
|
||||
inventory: inventory,
|
||||
runningPhysical: false,
|
||||
|
|
@ -941,7 +960,8 @@ export class WebSocketIo {
|
|||
stationData,
|
||||
line?.config?.output || '',
|
||||
line?.config?.inventory || '',
|
||||
line?.config?.latestScenario || undefined
|
||||
line?.config?.latestScenario || undefined,
|
||||
line?.config?.data || []
|
||||
)
|
||||
this.lineConnecting = this.lineConnecting.filter((el) => el !== lineId)
|
||||
|
||||
|
|
|
|||
|
|
@ -824,11 +824,43 @@ const ModalTerminal = ({
|
|||
</Text>
|
||||
</Flex>
|
||||
<Box>
|
||||
<Flex justify={"space-between"} align={"center"}>
|
||||
<Text size="md" mr={"sm"} fw={"bold"}>
|
||||
Warning from test report: AI
|
||||
</Text>
|
||||
<Button
|
||||
disabled={isDisable}
|
||||
size="xs"
|
||||
mb={"4px"}
|
||||
variant="light"
|
||||
onClick={() => {
|
||||
setIsDisable(true);
|
||||
setTimeout(() => {
|
||||
setIsDisable(false);
|
||||
}, 3000);
|
||||
socket?.emit("update_note", {
|
||||
lineId: line?.id,
|
||||
stationId: stationItem?.id,
|
||||
note: valueIssue,
|
||||
sn: line?.inventory?.sn || "",
|
||||
licenses: findDataShowLicense()
|
||||
? findDataShowLicense()
|
||||
?.filter(
|
||||
(el: TextTSMLicense) =>
|
||||
el.LICENSE_TYPE === "Permanent"
|
||||
)
|
||||
?.map((v: TextTSMLicense) => v.FEATURE)
|
||||
: [],
|
||||
});
|
||||
}}
|
||||
>
|
||||
Update note
|
||||
</Button>
|
||||
</Flex>
|
||||
|
||||
<Box>
|
||||
<Textarea
|
||||
disabled={isDisable}
|
||||
rows={5}
|
||||
size="sm"
|
||||
placeholder="Report from AI"
|
||||
|
|
|
|||
Loading…
Reference in New Issue