Update socket_io_provider.ts
This commit is contained in:
parent
fa8fd8116f
commit
d2263a3ec3
|
|
@ -310,10 +310,22 @@ export class WebSocketIo {
|
|||
})
|
||||
|
||||
socket.on('get_list_logs', async (data) => {
|
||||
const dir = 'storage/system_logs'
|
||||
let getListSystemLogs = fs
|
||||
.readdirSync('storage/system_logs')
|
||||
.map((f) => 'storage/system_logs/' + f)
|
||||
.readdirSync(dir)
|
||||
.map((file) => {
|
||||
const fullPath = `${dir}/${file}`
|
||||
const stat = fs.statSync(fullPath)
|
||||
|
||||
return {
|
||||
path: fullPath,
|
||||
time: stat.mtime.getTime(), // hoặc stat.birthtime
|
||||
}
|
||||
})
|
||||
.sort((a, b) => b.time - a.time) // giảm dần (mới nhất trước)
|
||||
.slice(0, 1000)
|
||||
.map((f) => f.path) // lấy lại path
|
||||
|
||||
io.to(socket.id).emit('list_logs', getListSystemLogs)
|
||||
|
||||
// const listHistory = await this.getHistory(data?.stationId, data?.lineId)
|
||||
|
|
|
|||
Loading…
Reference in New Issue