Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sadnub committed Apr 2, 2024
1 parent afc40fc commit bd3e365
Show file tree
Hide file tree
Showing 62 changed files with 17,956 additions and 7,148 deletions.
5 changes: 2 additions & 3 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ version: '3.7'
services:
app-dev:
container_name: trmm-app-dev
image: node:18-alpine
image: node:20-alpine
restart: always
command: /bin/sh -c "npm install --cache ~/.npm && npm run serve"
user: 1000:1000
command: /bin/sh -c "npm install --cache ~/.npm && npm i -g @quasar/cli && npm run serve"
working_dir: /workspace/web
volumes:
- ..:/workspace:cached
Expand Down
18,847 changes: 14,045 additions & 4,802 deletions package-lock.json

Large diffs are not rendered by default.

25 changes: 17 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,38 @@
"serve": "quasar dev",
"build": "quasar build",
"lint": "eslint --ext .js,.ts,.vue ./",
"format": "prettier --write \"**/*.{js,ts,vue,,html,md,json}\" --ignore-path .gitignore"
"format": "prettier --write \"**/*.{js,ts,vue,,html,md,json}\" --ignore-path .gitignore",
"test:unit:ui": "vitest --ui",
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
"test:unit": "vitest",
"test:unit:ci": "vitest run"
},
"dependencies": {
"@quasar/extras": "1.16.9",
"@vueuse/core": "10.9.0",
"@vueuse/shared": "10.9.0",
"apexcharts": "3.48.0",
"axios": "1.6.8",
"dotenv": "16.4.5",
"monaco-editor": "0.47.0",
"pinia": "^2.1.7",
"qrcode.vue": "3.4.1",
"quasar": "2.15.1",
"vue": "3.4.21",
"vue-router": "4.3.0",
"vue3-apexcharts": "1.5.2",
"vuedraggable": "4.1.0",
"vue-router": "4.3.0",
"@vueuse/core": "10.9.0",
"@vueuse/shared": "10.9.0",
"monaco-editor": "0.47.0",
"vuex": "4.1.0",
"xterm": "^5.3.0",
"xterm-addon-fit": "^0.8.0",
"yaml": "2.4.1"
},
"devDependencies": {
"@quasar/cli": "2.4.0",
"@intlify/unplugin-vue-i18n": "3.0.1",
"@quasar/app-vite": "1.8.0",
"@quasar/cli": "2.4.0",
"@quasar/quasar-app-extension-testing-unit-jest": "^3.0.0-beta.7",
"@quasar/quasar-app-extension-testing-unit-vitest": "^1.0.0-beta.1",
"@types/node": "20.11.30",
"@typescript-eslint/eslint-plugin": "7.3.1",
"@typescript-eslint/parser": "7.3.1",
Expand All @@ -41,6 +47,9 @@
"eslint-config-prettier": "9.1.0",
"eslint-plugin-vue": "8.7.1",
"prettier": "3.2.5",
"typescript": "5.4.3"
"typescript": "5.4.3",
"@vue/test-utils": "^2.4.3",
"vitest": "^1.1.0",
"@vitest/ui": "^1.1.0"
}
}
}
2 changes: 1 addition & 1 deletion quasar.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = configure(function (/* ctx */) {
// app boot file (/src/boot)
// --> boot files are part of "main.js"
// https://v2.quasar.dev/quasar-cli-vite/boot-files
boot: ["axios", "monaco", "integrations"],
boot: ["pinia", "axios", "monaco", "integrations"],

// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css
css: ["app.sass"],
Expand Down
7 changes: 7 additions & 0 deletions quasar.extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"@quasar/testing-unit-vitest": {
"options": [
"ui"
]
}
}
13 changes: 13 additions & 0 deletions src/api/alerts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import axios from "axios";

import type { AlertTemplate } from "@/types/alerts";

export async function saveAlertTemplate(id: number, payload: AlertTemplate) {
const { data } = await axios.put(`alerts/templates/${id}/`, payload);
return data;
}

export async function addAlertTemplate(payload: AlertTemplate) {
const { data } = await axios.post("alerts/templates/", payload);
return data;
}
45 changes: 0 additions & 45 deletions src/api/core.js

This file was deleted.

105 changes: 105 additions & 0 deletions src/api/core.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import axios from "axios";

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

const baseUrl = "/core";

export async function fetchDashboardInfo(params = {}) {
const { data } = await axios.get(`${baseUrl}/dashinfo/`, { params: params });
return data;
}

export async function fetchCustomFields(params = {}) {
try {
const { data } = await axios.get(`${baseUrl}/customfields/`, {
params: params,
});
return data;
} catch (e) {
console.error(e);
}
}

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): 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 {
timeout: number;
env_vars: string[];
args: string[];
}

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

// TODO: Build out type for openai payload
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export async function generateScript(payload: any) {
const { data } = await axios.post(`${baseUrl}/openai/generate/`, payload);
return data;
}
16 changes: 6 additions & 10 deletions src/boot/axios.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from "axios";
import { useAuthStore } from "@/stores/auth";
import { Notify } from "quasar";

export const getBaseUrl = () => {
Expand All @@ -18,27 +19,22 @@ export function setErrorMessage(data, message) {
];
}

export default function ({ app, router, store }) {
export default function ({ app, router }) {
app.config.globalProperties.$axios = axios;

axios.interceptors.request.use(
function (config) {
const auth = useAuthStore();
config.baseURL = getBaseUrl();
const token = store.state.token;
const token = auth.token;
if (token != null) {
config.headers.Authorization = `Token ${token}`;
}
// config.transformResponse = [
// function (data) {
// console.log(data);
// return data;
// },
// ];
return config;
},
function (err) {
return Promise.reject(err);
}
},
);

axios.interceptors.response.use(
Expand Down Expand Up @@ -101,6 +97,6 @@ export default function ({ app, router, store }) {
}

return Promise.reject({ ...error });
}
},
);
}
11 changes: 11 additions & 0 deletions src/boot/pinia.ts
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)
});
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 bd3e365

Please sign in to comment.