Skip to content

Commit

Permalink
add server tasks and script run/commands
Browse files Browse the repository at this point in the history
  • Loading branch information
sadnub committed Feb 11, 2024
1 parent 11042a0 commit 7a091cc
Show file tree
Hide file tree
Showing 18 changed files with 2,156 additions and 771 deletions.
53 changes: 52 additions & 1 deletion src/api/core.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from "axios";

import type { URLAction, URLActionRunResponse } from "@/types/core/urlactions";
import type { AutomatedTask } from "@/types/tasks";

const baseUrl = "/core";

Expand All @@ -26,7 +27,57 @@ export async function removeURLAction(id: number) {
return data;
}

export async function runURLAction(id: number, payload): Promise<URLActionRunResponse> {
export async function runURLAction(id: number): Promise<URLActionRunResponse> {
const { data } = await axios.post(`${baseUrl}/urlaction/${id}/run/`);
return data;
}

export async function fetchServerTasks(params = {}): Promise<AutomatedTask[]> {
const { data } = await axios.get(`${baseUrl}/servertasks/`, {
params: params,
});
return data;
}

export async function saveServerTask(action: AutomatedTask) {
const { data } = await axios.post(`${baseUrl}/servertasks/`, action);
return data;
}

export async function editServerTask(id: number, action: AutomatedTask) {
const { data } = await axios.put(`${baseUrl}/servertasks/${id}/`, action);
return data;
}

export async function removeServerTask(id: number) {
const { data } = await axios.delete(`${baseUrl}/servertasks/${id}/`);
return data;
}

export interface ServerScriptResponse {
output: string;
execution_time: number;
}

export async function runServerTask(id: number): Promise<ServerScriptResponse> {
const { data } = await axios.post(`${baseUrl}/servertasks/${id}/run/`);
return data;
}

export interface ServerScriptRunRequest {
id: number;
timeout: number;
env_vars: string[];
args: string[];
}

export async function runServerScript(
id: number,
payload: ServerScriptRunRequest,
): Promise<ServerScriptResponse> {
const { data } = await axios.post(
`${baseUrl}/serverscript/${id}/run/`,
payload,
);
return data;
}
10 changes: 10 additions & 0 deletions src/components/FileBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@
>
<q-item-section>Server Maintenance</q-item-section>
</q-item>
<!-- Run Serverside Script-->
<q-item clickable v-close-popup @click="showServerScriptRun">
<q-item-section>Run Server Script</q-item-section>
</q-item>
<!-- clear cache -->
<q-item clickable v-close-popup @click="clearCache">
<q-item-section>Clear Cache</q-item-section>
Expand Down Expand Up @@ -276,6 +280,7 @@ import DeploymentTable from "@/components/clients/DeploymentTable.vue";
import ServerMaintenance from "@/components/modals/core/ServerMaintenance.vue";
import CodeSign from "@/components/modals/coresettings/CodeSign.vue";
import PermissionsManager from "@/components/accounts/PermissionsManager.vue";
import RunServerScript from "@/components/modals/core/RunServerScript.vue";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { notifyWarning } from "@/utils/notify";
Expand Down Expand Up @@ -447,6 +452,11 @@ export default {
component: ReportsManager,
});
},
showServerScriptRun() {
this.$q.dialog({
component: RunServerScript,
});
},
},
};
</script>
Loading

0 comments on commit 7a091cc

Please sign in to comment.