Skip to content

Commit c3d9460

Browse files
anroszkiewiczglatosinski
authored andcommitted
[#88170] frontend: src: components: Close device shell
Signed-off-by: Anna Roszkiewicz <[email protected]>
1 parent 62e75cd commit c3d9460

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

frontend/src/components/Terminal.vue

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ Container for the hterm.js terminal.
1313
</template>
1414

1515
<script lang="ts">
16-
import { defineComponent, computed, onMounted, onUnmounted, watch, nextTick } from 'vue';
16+
import {
17+
defineComponent,
18+
computed,
19+
onMounted,
20+
onUnmounted,
21+
watch,
22+
nextTick,
23+
defineEmits,
24+
} from 'vue';
1725
1826
// @ts-ignore
1927
import { hterm, lib } from '../third-party/hterm';
@@ -25,7 +33,7 @@ export default defineComponent({
2533
type: String,
2634
},
2735
},
28-
setup(props) {
36+
setup(props, { emit }) {
2937
const notifications = useNotifications();
3038
3139
let term: any;
@@ -40,11 +48,7 @@ export default defineComponent({
4048
'shift-insert-paste': false,
4149
};
4250
const closeEventListener = (event: CloseEvent) => {
43-
term.io.print('Console unavailable');
44-
if (event.reason) {
45-
term.io.print(`: ${event.reason}`);
46-
}
47-
term.io.print('\n\r');
51+
emit('shell-disconnected');
4852
4953
notifications.notifyError({
5054
headline: 'Device shell connection closed',

frontend/src/components/devices/Device.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,11 @@ Component wraps functionality for displaying and working with a single rdfm devi
192192
:class="['terminal-wrapper', { fullscreen: isFullscreen }]"
193193
v-if="isTerminalOpened"
194194
>
195-
<Terminal class="terminal" :device="device?.mac_address" />
195+
<Terminal
196+
class="terminal"
197+
:device="device?.mac_address"
198+
@shell-disconnected="disconnect"
199+
/>
196200
</div>
197201
</div>
198202
</template>
@@ -1081,6 +1085,11 @@ export default {
10811085
isFullscreen.value = !isFullscreen.value;
10821086
};
10831087
1088+
const disconnect = () => {
1089+
toggleTerminal();
1090+
device.value!.connected = false;
1091+
};
1092+
10841093
return {
10851094
id: route.params.id,
10861095
interval,
@@ -1108,6 +1117,7 @@ export default {
11081117
terminalButton,
11091118
terminalFullscreen,
11101119
isFullscreen,
1120+
disconnect,
11111121
allowedTo,
11121122
deviceUpdates,
11131123
deviceVersions,

0 commit comments

Comments
 (0)