mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-31 23:11:28 +01:00
updates for local
This commit is contained in:
parent
9ef6745d66
commit
98a55b2290
@ -31,6 +31,9 @@ ipcMain.on("get-user-name", (event) => {
|
||||
const userInfo = os.userInfo();
|
||||
event.returnValue = userInfo.username;
|
||||
});
|
||||
ipcMain.on("get-host-name", (event) => {
|
||||
event.returnValue = os.hostname();
|
||||
});
|
||||
|
||||
// must match golang
|
||||
function getWaveHomeDir() {
|
||||
|
@ -9,6 +9,7 @@ contextBridge.exposeInMainWorld("api", {
|
||||
getPlatform: () => ipcRenderer.sendSync("get-platform"),
|
||||
getCursorPoint: () => ipcRenderer.sendSync("get-cursor-point"),
|
||||
getUserName: () => ipcRenderer.sendSync("get-user-name"),
|
||||
getHostName: () => ipcRenderer.sendSync("get-host-name"),
|
||||
getAboutModalDetails: () => ipcRenderer.sendSync("get-about-modal-details"),
|
||||
openNewWindow: () => ipcRenderer.send("open-new-window"),
|
||||
showContextMenu: (menu, position) => ipcRenderer.send("contextmenu-show", menu, position),
|
||||
|
@ -17,6 +17,8 @@ import {
|
||||
atoms,
|
||||
getBlockComponentModel,
|
||||
getConnStatusAtom,
|
||||
getHostName,
|
||||
getUserName,
|
||||
globalStore,
|
||||
useBlockAtom,
|
||||
useSettingsKeyAtom,
|
||||
@ -489,6 +491,9 @@ const ChangeConnectionBlockModal = React.memo(
|
||||
} catch (e) {
|
||||
console.log("unable to load conn list from backend. using blank list: ", e);
|
||||
}
|
||||
if (!connList) {
|
||||
connList = [];
|
||||
}
|
||||
let createNew: boolean = true;
|
||||
if (connSelected == "") {
|
||||
createNew = false;
|
||||
@ -537,6 +542,7 @@ const ChangeConnectionBlockModal = React.memo(
|
||||
headerText: "",
|
||||
items: priorityItems,
|
||||
};
|
||||
const localName = getUserName() + "@" + getHostName();
|
||||
const localSuggestion: SuggestionConnectionScope = {
|
||||
headerText: "Local",
|
||||
items: [
|
||||
@ -545,7 +551,7 @@ const ChangeConnectionBlockModal = React.memo(
|
||||
icon: "laptop",
|
||||
iconColor: "var(--grey-text-color)",
|
||||
value: "",
|
||||
label: "Switch to Local Connection",
|
||||
label: localName,
|
||||
// TODO: need to specify user name and host name
|
||||
onSelect: (_: string) => {
|
||||
changeConnection("");
|
||||
@ -619,7 +625,7 @@ const ChangeConnectionBlockModal = React.memo(
|
||||
onKeyDown={(e) => keyutil.keydownWrapper(handleTypeAheadKeyDown)(e)}
|
||||
onChange={(current: string) => setConnSelected(current)}
|
||||
value={connSelected}
|
||||
label="username@host"
|
||||
label="Connect to (username@host)..."
|
||||
onClickBackdrop={() => globalStore.set(changeConnModalAtom, false)}
|
||||
/>
|
||||
);
|
||||
|
@ -507,6 +507,15 @@ function getUserName(): string {
|
||||
return cachedUserName;
|
||||
}
|
||||
|
||||
let cachedHostName: string = null;
|
||||
|
||||
function getHostName(): string {
|
||||
if (cachedHostName == null) {
|
||||
cachedHostName = getApi().getHostName();
|
||||
}
|
||||
return cachedHostName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a link in a new window, or in a new web widget. The user can set all links to open in a new web widget using the `web:openlinksinternally` setting.
|
||||
* @param uri The link to open.
|
||||
@ -642,6 +651,7 @@ export {
|
||||
getEventORefSubject,
|
||||
getEventSubject,
|
||||
getFileSubject,
|
||||
getHostName,
|
||||
getObjectId,
|
||||
getUserName,
|
||||
globalStore,
|
||||
|
1
frontend/types/custom.d.ts
vendored
1
frontend/types/custom.d.ts
vendored
@ -54,6 +54,7 @@ declare global {
|
||||
getPlatform: () => NodeJS.Platform;
|
||||
getEnv: (varName: string) => string;
|
||||
getUserName: () => string;
|
||||
getHostName: () => string;
|
||||
getAboutModalDetails: () => AboutModalDetails;
|
||||
showContextMenu: (menu?: ElectronContextMenuItem[]) => void;
|
||||
onContextMenuClick: (callback: (id: string) => void) => void;
|
||||
|
Loading…
Reference in New Issue
Block a user