Update
This commit is contained in:
parent
77787b3c93
commit
32873ad388
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||||
|
|
||||||
|
export default class extends BaseSchema {
|
||||||
|
protected tableName = 'tickets'
|
||||||
|
|
||||||
|
async up() {
|
||||||
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
|
table.increments('id')
|
||||||
|
table.string('description').notNullable()
|
||||||
|
table.string('model').notNullable()
|
||||||
|
table.string('sn').notNullable()
|
||||||
|
table.integer('line_id').notNullable()
|
||||||
|
table.integer('station_id').notNullable()
|
||||||
|
table.string('status').notNullable()
|
||||||
|
table.text('history').notNullable()
|
||||||
|
table.timestamps()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async down() {
|
||||||
|
this.schema.dropTable(this.tableName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -159,15 +159,15 @@ export class WebSocketIo {
|
||||||
socket.on('open_cli', async (data) => {
|
socket.on('open_cli', async (data) => {
|
||||||
const { lineId, userEmail, userName: name, stationId } = data
|
const { lineId, userEmail, userName: name, stationId } = data
|
||||||
const line = this.lineMap.get(lineId)
|
const line = this.lineMap.get(lineId)
|
||||||
if (line) {
|
if (line && line?.userOpenCLI) {
|
||||||
line.userOpenCLI({ userEmail, userName: name })
|
line?.userOpenCLI({ userEmail, userName: name })
|
||||||
} else {
|
} else {
|
||||||
if (this.lineConnecting.includes(lineId)) return
|
if (this.lineConnecting.includes(lineId)) return
|
||||||
const linesData = await Line.findBy('id', lineId)
|
const linesData = await Line.findBy('id', lineId)
|
||||||
const stationData = await Station.findBy('id', stationId)
|
const stationData = await Station.findBy('id', stationId)
|
||||||
if (linesData && stationData) {
|
if (linesData && stationData) {
|
||||||
this.lineConnecting.push(lineId)
|
this.lineConnecting.push(lineId)
|
||||||
await this.connectLine(io, [linesData], stationData)
|
await this.connectLine(io, [linesData], stationData, line?.config?.output || '')
|
||||||
const lineReconnect = this.lineMap.get(lineId)
|
const lineReconnect = this.lineMap.get(lineId)
|
||||||
if (lineReconnect) {
|
if (lineReconnect) {
|
||||||
lineReconnect.userOpenCLI({ userEmail, userName: name })
|
lineReconnect.userOpenCLI({ userEmail, userName: name })
|
||||||
|
|
@ -179,15 +179,15 @@ export class WebSocketIo {
|
||||||
socket.on('close_cli', async (data) => {
|
socket.on('close_cli', async (data) => {
|
||||||
const { lineId, stationId } = data
|
const { lineId, stationId } = data
|
||||||
const line = this.lineMap.get(lineId)
|
const line = this.lineMap.get(lineId)
|
||||||
if (line) {
|
if (line && line?.userCloseCLI) {
|
||||||
line.userCloseCLI()
|
line?.userCloseCLI()
|
||||||
} else {
|
} else {
|
||||||
if (this.lineConnecting.includes(lineId)) return
|
if (this.lineConnecting.includes(lineId)) return
|
||||||
const linesData = await Line.findBy('id', lineId)
|
const linesData = await Line.findBy('id', lineId)
|
||||||
const stationData = await Station.findBy('id', stationId)
|
const stationData = await Station.findBy('id', stationId)
|
||||||
if (linesData && stationData) {
|
if (linesData && stationData) {
|
||||||
this.lineConnecting.push(lineId)
|
this.lineConnecting.push(lineId)
|
||||||
await this.connectLine(io, [linesData], stationData)
|
await this.connectLine(io, [linesData], stationData, line?.config?.output || '')
|
||||||
const lineReconnect = this.lineMap.get(lineId)
|
const lineReconnect = this.lineMap.get(lineId)
|
||||||
if (lineReconnect) {
|
if (lineReconnect) {
|
||||||
lineReconnect.userCloseCLI()
|
lineReconnect.userCloseCLI()
|
||||||
|
|
@ -422,7 +422,7 @@ export class WebSocketIo {
|
||||||
return io
|
return io
|
||||||
}
|
}
|
||||||
|
|
||||||
private async connectLine(socket: any, lines: Line[], station: Station) {
|
private async connectLine(socket: any, lines: Line[], station: Station, output = '') {
|
||||||
try {
|
try {
|
||||||
this.stationMap.set(station.id, station)
|
this.stationMap.set(station.id, station)
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
|
|
@ -435,7 +435,7 @@ export class WebSocketIo {
|
||||||
stationId: station.id,
|
stationId: station.id,
|
||||||
apcName: line.apcName,
|
apcName: line.apcName,
|
||||||
outlet: line.outlet,
|
outlet: line.outlet,
|
||||||
output: '',
|
output: output,
|
||||||
status: '',
|
status: '',
|
||||||
openCLI: false,
|
openCLI: false,
|
||||||
userEmailOpenCLI: '',
|
userEmailOpenCLI: '',
|
||||||
|
|
@ -505,7 +505,7 @@ export class WebSocketIo {
|
||||||
|
|
||||||
if (linesData && stationData) {
|
if (linesData && stationData) {
|
||||||
this.lineConnecting.push(lineId)
|
this.lineConnecting.push(lineId)
|
||||||
await this.connectLine(io, [linesData], stationData)
|
await this.connectLine(io, [linesData], stationData, line?.config?.output || '')
|
||||||
this.lineConnecting = this.lineConnecting.filter((el) => el !== lineId)
|
this.lineConnecting = this.lineConnecting.filter((el) => el !== lineId)
|
||||||
|
|
||||||
const lineReconnect = this.lineMap.get(lineId)
|
const lineReconnect = this.lineMap.get(lineId)
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,20 @@ const CardLine = ({
|
||||||
onDoubleClick={() => {
|
onDoubleClick={() => {
|
||||||
openTerminal(line);
|
openTerminal(line);
|
||||||
}}
|
}}
|
||||||
|
onFocus={() => {
|
||||||
|
socket?.emit("open_cli", {
|
||||||
|
lineId: line.id,
|
||||||
|
stationId: line.stationId || line.station_id,
|
||||||
|
userEmail: user?.email,
|
||||||
|
userName: user?.userName,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
onBlur={() => {
|
||||||
|
socket?.emit("close_cli", {
|
||||||
|
lineId: line?.id,
|
||||||
|
stationId: line.stationId || line.station_id,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box>
|
<Box>
|
||||||
|
|
|
||||||
|
|
@ -810,6 +810,7 @@ export const DrawerSwitchControl: React.FC<DrawerProps> = ({
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open) {
|
if (!open) {
|
||||||
setListPortsSelected([]);
|
setListPortsSelected([]);
|
||||||
|
setLoading(true);
|
||||||
}
|
}
|
||||||
}, [open]);
|
}, [open]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ interface TerminalCLIProps {
|
||||||
paddingLeft?: string;
|
paddingLeft?: string;
|
||||||
};
|
};
|
||||||
onDoubleClick?: () => void;
|
onDoubleClick?: () => void;
|
||||||
|
onFocus?: () => void;
|
||||||
|
onBlur?: () => void;
|
||||||
fontSize?: number;
|
fontSize?: number;
|
||||||
miniSize?: boolean;
|
miniSize?: boolean;
|
||||||
loadingContent?: boolean;
|
loadingContent?: boolean;
|
||||||
|
|
@ -40,6 +42,8 @@ const TerminalCLI: React.FC<TerminalCLIProps> = ({
|
||||||
miniSize = false,
|
miniSize = false,
|
||||||
initContent = "",
|
initContent = "",
|
||||||
loadingContent = false,
|
loadingContent = false,
|
||||||
|
onFocus,
|
||||||
|
onBlur,
|
||||||
}) => {
|
}) => {
|
||||||
const xtermRef = useRef<HTMLDivElement>(null);
|
const xtermRef = useRef<HTMLDivElement>(null);
|
||||||
const terminal = useRef<Terminal>(null);
|
const terminal = useRef<Terminal>(null);
|
||||||
|
|
@ -182,6 +186,17 @@ const TerminalCLI: React.FC<TerminalCLIProps> = ({
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
onClick={(event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
if (!isDisabled) {
|
||||||
|
terminal.current?.focus();
|
||||||
|
if (onFocus) onFocus();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onBlurCapture={() => {
|
||||||
|
if (onBlur) onBlur();
|
||||||
|
}}
|
||||||
ref={xtermRef}
|
ref={xtermRef}
|
||||||
style={{
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue