Made it possible to create links with commands for console page.
This commit is contained in:
@@ -102,14 +102,21 @@
|
||||
import {useStorage} from "@vueuse/core";
|
||||
import {notification} from "~/utils/index.js";
|
||||
|
||||
const fromTask = useRoute().query.task || '';
|
||||
const route = useRoute()
|
||||
|
||||
const fromTask = route.query.task || '';
|
||||
let fromCommand = route.query.cmd || '';
|
||||
if (fromCommand) {
|
||||
// -- decode base64
|
||||
fromCommand = atob(fromCommand);
|
||||
}
|
||||
|
||||
useHead({title: `Console`})
|
||||
|
||||
let sse;
|
||||
|
||||
const response = ref([]);
|
||||
const command = ref('');
|
||||
const command = ref(fromCommand);
|
||||
const isLoading = ref(false);
|
||||
const outputConsole = ref();
|
||||
const hasPrefix = computed(() => command.value.startsWith('console') || command.value.startsWith('docker'));
|
||||
@@ -162,11 +169,15 @@ const finished = () => {
|
||||
onUpdated(() => outputConsole.value.scrollTop = outputConsole.value.scrollHeight);
|
||||
|
||||
onMounted(async () => {
|
||||
if (!fromTask) {
|
||||
if (!fromTask && '' === command.value) {
|
||||
await RunCommand();
|
||||
return
|
||||
}
|
||||
|
||||
if (!fromTask) {
|
||||
return
|
||||
}
|
||||
|
||||
const response = await request(`/tasks/${fromTask}`);
|
||||
const json = await response.json();
|
||||
command.value = `${json.command} ${json.args || ''}`;
|
||||
|
||||
@@ -292,6 +292,13 @@ const copyText = (str) => {
|
||||
notification('success', 'Success', 'Text copied to clipboard.')
|
||||
}
|
||||
|
||||
const makeConsoleCommand = (cmd) => {
|
||||
const params = new URLSearchParams();
|
||||
// -- base64 encode the command to prevent XSS
|
||||
params.append('cmd', btoa(cmd));
|
||||
return `/console?${params.toString()}`
|
||||
}
|
||||
|
||||
const stringToRegex = (str) => new RegExp(str.match(/\/(.+)\/.*/)[1], str.match(/\/.+\/(.*)/)[1]);
|
||||
|
||||
export {
|
||||
@@ -304,5 +311,6 @@ export {
|
||||
makeGUIDLink,
|
||||
formatDuration,
|
||||
copyText,
|
||||
stringToRegex
|
||||
stringToRegex,
|
||||
makeConsoleCommand
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user