Skip to content

Commit 84f52de

Browse files
committed
center window and theme changes to webterm
1 parent 2e509cf commit 84f52de

6 files changed

Lines changed: 62 additions & 45 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "web",
3-
"version": "0.101.63",
3+
"version": "0.101.64",
44
"private": true,
55
"productName": "Tactical RMM",
66
"scripts": {

src/api/agents.js

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,28 @@
11
import axios from "axios";
22
import { openURL } from "quasar";
33
import { router } from "@/router";
4+
import { getCenteredWindowOptions } from "@/utils/helpers";
45

56
const baseUrl = "/agents";
67

78
export function runTakeControl(agent_id) {
89
const url = router.resolve(`/takecontrol/${agent_id}`).href;
910
openURL(url, null, {
10-
popup: true,
11-
scrollbars: false,
12-
location: false,
13-
status: false,
14-
toolbar: false,
15-
menubar: false,
16-
width: 1600,
17-
height: 900,
11+
...getCenteredWindowOptions(1600, 900),
1812
});
1913
}
2014

2115
export function runWebVNC(agent_id, port) {
2216
const url = router.resolve(`/webvnc/${agent_id}/${port}`).href;
2317
openURL(url, null, {
24-
popup: true,
25-
scrollbars: false,
26-
location: false,
27-
status: false,
28-
toolbar: false,
29-
menubar: false,
30-
width: 1600,
31-
height: 900,
18+
...getCenteredWindowOptions(1600, 900),
3219
});
3320
}
3421

3522
export function openAgentWindow(agent_id) {
3623
const url = router.resolve(`/agents/${agent_id}`).href;
3724
openURL(url, null, {
38-
popup: true,
39-
scrollbars: false,
40-
location: false,
41-
status: false,
42-
toolbar: false,
43-
menubar: false,
44-
width: 1600,
45-
height: 900,
25+
...getCenteredWindowOptions(1600, 900),
4626
});
4727
}
4828

@@ -51,14 +31,7 @@ export function runRemoteBackground(agent_id, agentPlatform) {
5131
`/remotebackground/${agent_id}?agentPlatform=${agentPlatform}`,
5232
).href;
5333
openURL(url, null, {
54-
popup: true,
55-
scrollbars: false,
56-
location: false,
57-
status: false,
58-
toolbar: false,
59-
menubar: false,
60-
width: 1280,
61-
height: 900,
34+
...getCenteredWindowOptions(1280, 900),
6235
});
6336
}
6437

src/api/core.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import type {
88
TestRunURLActionResponse,
99
} from "@/types/core/urlactions";
1010

11+
import { getCenteredWindowOptions } from "@/utils/helpers";
12+
1113
import type { CoreSetting } from "@/types/core/settings";
1214

1315
const baseUrl = "/core";
@@ -85,14 +87,7 @@ export async function checkWebTermPerms(): Promise<{
8587
export function openWebTerminal(): void {
8688
const url: string = router.resolve("/webterm").href;
8789
openURL(url, undefined, {
88-
popup: true,
89-
scrollbars: false,
90-
location: false,
91-
status: false,
92-
toolbar: false,
93-
menubar: false,
94-
width: 1280,
95-
height: 720,
90+
...getCenteredWindowOptions(1280, 720),
9691
});
9792
}
9893

src/utils/helpers.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,28 @@ export function copyOutput(val: string) {
66
notifySuccess("Copied to clipboard");
77
});
88
}
9+
10+
export function getCenteredWindowOptions(width: number, height: number) {
11+
const left =
12+
typeof window === "undefined"
13+
? 0
14+
: Math.round((window.screen.width - width) / 2);
15+
16+
const top =
17+
typeof window === "undefined"
18+
? 0
19+
: Math.round((window.screen.height - height) / 2);
20+
21+
return {
22+
popup: true,
23+
scrollbars: false,
24+
location: false,
25+
status: false,
26+
toolbar: false,
27+
menubar: false,
28+
width,
29+
height,
30+
left,
31+
top,
32+
};
33+
}

src/views/WebTerminal.vue

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,42 @@ onBeforeUnmount(() => {
4545
function setupXTerm() {
4646
term = new Terminal({
4747
convertEol: true,
48-
fontFamily: "Menlo, Monaco, Courier New, monospace",
48+
fontFamily: "Menlo, Monaco, 'SF Mono', 'Courier New', monospace",
4949
fontSize: 15,
5050
fontWeight: 400,
5151
cursorBlink: true,
52+
scrollback: 50000,
5253
theme: {
53-
background: "#333",
54+
background: "#1d1f21",
55+
foreground: "#c5c8c6",
56+
cursor: "#c5c8c6",
57+
cursorAccent: "#1d1f21",
58+
selectionBackground: "rgba(255,255,255,0.18)",
59+
black: "#1d1f21",
60+
red: "#cc6666",
61+
green: "#b5bd68",
62+
yellow: "#f0c674",
63+
blue: "#81a2be",
64+
magenta: "#b294bb",
65+
cyan: "#8abeb7",
66+
white: "#c5c8c6",
67+
brightBlack: "#666666",
68+
brightRed: "#d54e53",
69+
brightGreen: "#b9ca4a",
70+
brightYellow: "#e7c547",
71+
brightBlue: "#7aa6da",
72+
brightMagenta: "#c397d8",
73+
brightCyan: "#70c0b1",
74+
brightWhite: "#eaeaea",
5475
},
5576
});
5677
5778
term.loadAddon(fit);
5879
term.open(xtermContainer.value!);
5980
fit.fit();
81+
requestAnimationFrame(() => {
82+
term?.focus();
83+
});
6084
term.onData((data) => {
6185
send(JSON.stringify({ action: "trmmcli.input", data: { input: data } }));
6286
});

0 commit comments

Comments
 (0)