-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
881 additions
and
474 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import axios from "axios"; | ||
|
||
import type { URLAction, URLActionRunResponse } from "@/types/core/urlactions"; | ||
|
||
const baseUrl = "/core"; | ||
|
||
export async function fetchURLActions(params = {}) { | ||
const { data } = await axios.get(`${baseUrl}/urlaction/`, { | ||
params: params, | ||
}); | ||
return data; | ||
} | ||
|
||
export async function saveURLAction(action: URLAction) { | ||
const { data } = await axios.post(`${baseUrl}/urlaction/`, action); | ||
return data; | ||
} | ||
|
||
export async function editURLAction(id: number, action: URLAction) { | ||
const { data } = await axios.put(`${baseUrl}/urlaction/${id}/`, action); | ||
return data; | ||
} | ||
|
||
export async function removeURLAction(id: number) { | ||
const { data } = await axios.delete(`${baseUrl}/urlaction/${id}/`); | ||
return data; | ||
} | ||
|
||
export async function runURLAction(id: number, payload): Promise<URLActionRunResponse> { | ||
const { data } = await axios.post(`${baseUrl}/urlaction/${id}/run/`); | ||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { boot } from "quasar/wrappers"; | ||
import { createPinia } from "pinia"; | ||
|
||
export default boot(({ app }) => { | ||
const pinia = createPinia(); | ||
|
||
app.use(pinia); | ||
|
||
// You can add Pinia plugins here | ||
// pinia.use(SomePiniaPlugin) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<template> | ||
<q-dialog | ||
ref="dialogRef" | ||
@hide="onDialogHide" | ||
maximized | ||
@show="setupXTerm" | ||
@before-hide="disconnect" | ||
> | ||
<q-card class="q-dialog-plugin"> | ||
<q-bar> | ||
Tactical RMM Server Command Prompt - Careful! With great power comes | ||
great responsibility! | ||
<q-space /> | ||
<q-btn dense flat icon="close" v-close-popup> | ||
<q-tooltip class="bg-white text-primary">Close</q-tooltip> | ||
</q-btn> | ||
</q-bar> | ||
|
||
<div | ||
ref="xtermContainer" | ||
:style="{ height: `${$q.screen.height - 34}px` }" | ||
></div> | ||
</q-card> | ||
</q-dialog> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, watch } from "vue"; | ||
import { useDialogPluginComponent } from "quasar"; | ||
import { Terminal } from "xterm"; | ||
import { FitAddon } from "xterm-addon-fit"; | ||
import { useResizeObserver, useDebounceFn } from "@vueuse/core"; | ||
import { useDashWSConnection } from "@/websocket/websocket"; | ||
import "xterm/css/xterm.css"; | ||
// emits | ||
defineEmits([...useDialogPluginComponent.emits]); | ||
// setup quasar plugins | ||
const { dialogRef, onDialogHide } = useDialogPluginComponent(); | ||
// set ws connection | ||
const { data, send } = useDashWSConnection(); | ||
watch(data, (newValue) => { | ||
if (newValue.action === "trmmcli.output") term.write(newValue.data.output); | ||
}); | ||
const xtermContainer = ref<HTMLElement | null>(null); | ||
let term: Terminal; | ||
const fit = new FitAddon(); | ||
// Setup Xterm | ||
function setupXTerm() { | ||
term = new Terminal({ | ||
cursorBlink: true, | ||
scrollback: 1000, | ||
}); | ||
term.loadAddon(fit); | ||
term.open(xtermContainer.value!); | ||
fit.fit(); | ||
term.onData((data) => { | ||
console.log("browser terminal received new data:", data); | ||
send(JSON.stringify({ action: "trmmcli.input", data: { input: data } })); | ||
}); | ||
send( | ||
JSON.stringify({ | ||
action: "trmmcli.connect", | ||
data: { cols: term.cols, rows: term.rows }, | ||
}), | ||
); | ||
useResizeObserver(dialogRef, () => { | ||
resizeWindow(); | ||
}); | ||
} | ||
const resizeWindow = useDebounceFn(() => { | ||
fit.fit(); | ||
const dims = { cols: term.cols, rows: term.rows }; | ||
console.log("sending new dimensions to server's pty", dims); | ||
send(JSON.stringify({ action: "trmmcli.resize", data: dims })); | ||
}, 300); | ||
function disconnect() { | ||
term.dispose(); | ||
send(JSON.stringify({ action: "trmmcli.disconnect" })); | ||
} | ||
</script> |
Oops, something went wrong.