Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed:Fixed an issue where the request tree would go white when the Socket was closed #1436

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM jumpserver/koko-base:20240827_084143 AS stage-build
FROM jumpserver/koko-base:20240827_110133 AS stage-build
WORKDIR /opt/koko
ARG TARGETARCH
COPY . .
Expand Down
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"serve": "vite",
"build": "vue-tsc -b && vite build",
"preview": "vite preview",
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/Kubernetes/MainContent/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ const onSocketData = (msgType: string, msg: any, terminal: Terminal) => {
}
case 'CLOSE': {
sessionId.value = '';
message.error(t('TerminalClosed'));
message.error(t('WebSocketClosed'));
break;
}
default:
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/Kubernetes/Tree/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<n-descriptions label-placement="top" class="tree-wrapper">
<template #header>
<n-flex align="center" justify="space-between">
{{ t('List of Assets') }}
{{ t('KubernetesManagement') }}
<n-icon size="16px" :component="EllipsisHorizontal" class="mr-2.5 cursor-pointer" />
</n-flex>
</template>
Expand Down
6 changes: 3 additions & 3 deletions ui/src/hooks/helper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export const generateWsURL = () => {
break;
}
case 'kubernetes': {
connectURL = `${BASE_WS_URL}/koko/ws/terminal/?token=${route.query.token}`;
connectURL = `${BASE_WS_URL}/koko/ws/terminal/?token=${route.query.token}&type=k8s`;
break;
}
case 'Share': {
Expand Down Expand Up @@ -322,11 +322,11 @@ export const generateWsURL = () => {
export const onWebsocketWrong = (event: Event, type: string, terminal?: Terminal) => {
switch (type) {
case 'error': {
terminal ? terminal.write('Connection Websocket Error') : message.error('Error');
terminal ? terminal.write('Connection Websocket Error') : '';
break;
}
case 'disconnected': {
terminal ? terminal.write('Connection Websocket Closed') : message.error('Disconnected');
terminal ? terminal.write('Connection Websocket Closed') : '';
break;
}
}
Expand Down
2 changes: 0 additions & 2 deletions ui/src/hooks/useK8s.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ export const useK8s = () => {
}
case 'CLOSE':
case 'ERROR': {
message.error('Receive Connection Closed');

socket.close();
break;
}
Expand Down
15 changes: 13 additions & 2 deletions ui/src/hooks/useTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const useTerminal = async (el: HTMLElement, option: ICallbackOptions): Pr
break;
}
case 'CLOSE': {
terminal?.writeln('Receive Connection closed');
terminal?.writeln('Receive Connection Closed');
socket.close();
sendEventToLuna('CLOSE', '');
break;
Expand Down Expand Up @@ -273,7 +273,7 @@ export const useTerminal = async (el: HTMLElement, option: ICallbackOptions): Pr
break;
}
case 'TERMINAL_ERROR': {
message.error(`Socket Error ${socketData.err}`);
// message.error(`Socket Error ${socketData.err}`);
terminal?.write(socketData.err);
break;
}
Expand Down Expand Up @@ -526,6 +526,17 @@ export const useTerminal = async (el: HTMLElement, option: ICallbackOptions): Pr
});

mittBus.on('sync-theme', ({ type, data }) => {
if (option.type === 'k8s') {
return socket.send(
JSON.stringify({
k8s_id: k8s_id.value,
id: terminalId.value,
type,
data: JSON.stringify(data)
})
);
}

sendWsMessage(type, data);
});
};
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/Connection/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ const onSocketData = (msgType: string, msg: any, terminal: Terminal) => {
}
case 'ClOSE': {
sessionId.value = '';
message.error(t('TerminalClosed'));
message.error(t('WebSocketClosed'));
break;
}
default:
Expand Down