mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
hook up close block to backend to remove the running process
This commit is contained in:
parent
91d7392c34
commit
b721f59166
@ -8,6 +8,7 @@ import * as rxjs from "rxjs";
|
||||
import type { WailsEvent } from "@wailsio/runtime/types/events";
|
||||
import { Events } from "@wailsio/runtime";
|
||||
import { produce } from "immer";
|
||||
import * as BlockService from "@/bindings/pkg/service/blockservice/BlockService";
|
||||
|
||||
const globalStore = jotai.createStore();
|
||||
|
||||
@ -95,6 +96,7 @@ function removeBlockFromTab(tabId: string, blockId: string) {
|
||||
});
|
||||
globalStore.set(atoms.tabsAtom, newTabArr);
|
||||
removeBlock(blockId);
|
||||
BlockService.CloseBlock(blockId);
|
||||
}
|
||||
|
||||
export { globalStore, atoms, getBlockSubject, addBlockIdToTab, blockDataMap, useBlockAtom, removeBlockFromTab };
|
||||
|
@ -108,6 +108,15 @@ func CreateBlock(bdef *BlockDef, rtOpts *RuntimeOpts) (*BlockData, error) {
|
||||
return blockData, nil
|
||||
}
|
||||
|
||||
func CloseBlock(blockId string) {
|
||||
bc := GetBlockController(blockId)
|
||||
if bc == nil {
|
||||
return
|
||||
}
|
||||
bc.Close()
|
||||
close(bc.InputCh)
|
||||
}
|
||||
|
||||
func GetBlockData(blockId string) *BlockData {
|
||||
globalLock.Lock()
|
||||
defer globalLock.Unlock()
|
||||
@ -140,6 +149,12 @@ type RunShellOpts struct {
|
||||
TermSize shellexec.TermSize `json:"termsize,omitempty"`
|
||||
}
|
||||
|
||||
func (bc *BlockController) Close() {
|
||||
if bc.getShellProc() != nil {
|
||||
bc.ShellProc.Close()
|
||||
}
|
||||
}
|
||||
|
||||
func (bc *BlockController) DoRunShellCommand(rc *RunShellOpts) error {
|
||||
if bc.getShellProc() != nil {
|
||||
return nil
|
||||
|
@ -34,6 +34,10 @@ func (bs *BlockService) CreateBlock(bdefMap map[string]any, rtOptsMap map[string
|
||||
return rtnMap, nil
|
||||
}
|
||||
|
||||
func (bs *BlockService) CloseBlock(blockId string) {
|
||||
blockcontroller.CloseBlock(blockId)
|
||||
}
|
||||
|
||||
func (bs *BlockService) GetBlockData(blockId string) (map[string]any, error) {
|
||||
blockData := blockcontroller.GetBlockData(blockId)
|
||||
if blockData == nil {
|
||||
|
Loading…
Reference in New Issue
Block a user