mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-09 20:12:10 +10:00
fix: last eslint errors
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
<!-- eslint-disable vue/no-v-html -->
|
||||||
<template>
|
<template>
|
||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<!-- Create article button - only show for admin users -->
|
<!-- Create article button - only show for admin users -->
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
<!-- eslint-disable vue/no-v-html -->
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="flex grow flex-col gap-y-5 overflow-y-auto bg-zinc-900 px-6 py-6 ring-1 ring-white/10"
|
class="flex grow flex-col gap-y-5 overflow-y-auto bg-zinc-900 px-6 py-6 ring-1 ring-white/10"
|
||||||
|
|||||||
@ -2,11 +2,12 @@ import type { TaskMessage } from "~/server/internal/tasks";
|
|||||||
import { WebSocketHandler } from "./ws";
|
import { WebSocketHandler } from "./ws";
|
||||||
|
|
||||||
const websocketHandler = new WebSocketHandler("/api/v1/task");
|
const websocketHandler = new WebSocketHandler("/api/v1/task");
|
||||||
const taskStates: { [key: string]: Ref<TaskMessage | undefined> } = {};
|
// const taskStates: { [key: string]: } = {};
|
||||||
|
const taskStates = new Map<string, Ref<TaskMessage | undefined>>();
|
||||||
|
|
||||||
function handleUpdateMessage(msg: TaskMessage) {
|
function handleUpdateMessage(msg: TaskMessage) {
|
||||||
const taskStates = useTaskStates();
|
const taskStates = useTaskStates();
|
||||||
const state = taskStates[msg.id];
|
const state = taskStates.get(msg.id);
|
||||||
if (!state) return;
|
if (!state) return;
|
||||||
if (!state.value || msg.reset) {
|
if (!state.value || msg.reset) {
|
||||||
state.value = msg;
|
state.value = msg;
|
||||||
@ -29,18 +30,22 @@ websocketHandler.listen((message) => {
|
|||||||
const [action, ...data] = message.split("/");
|
const [action, ...data] = message.split("/");
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "connect":
|
case "connect": {
|
||||||
const taskReady = useTaskReady();
|
const taskReady = useTaskReady();
|
||||||
taskReady.value = true;
|
taskReady.value = true;
|
||||||
break;
|
break;
|
||||||
case "disconnect":
|
}
|
||||||
|
case "disconnect": {
|
||||||
const disconnectTaskId = data[0];
|
const disconnectTaskId = data[0];
|
||||||
delete taskStates[disconnectTaskId];
|
taskStates.delete(disconnectTaskId);
|
||||||
console.log(`disconnected from ${disconnectTaskId}`);
|
console.log(`disconnected from ${disconnectTaskId}`);
|
||||||
break;
|
break;
|
||||||
case "error":
|
}
|
||||||
|
case "error": {
|
||||||
const [taskId, title, description] = data;
|
const [taskId, title, description] = data;
|
||||||
taskStates[taskId].value ??= {
|
const state = taskStates.get(taskId);
|
||||||
|
if (!state) break;
|
||||||
|
state.value ??= {
|
||||||
id: taskId,
|
id: taskId,
|
||||||
name: "Unknown task",
|
name: "Unknown task",
|
||||||
success: false,
|
success: false,
|
||||||
@ -48,8 +53,9 @@ websocketHandler.listen((message) => {
|
|||||||
error: undefined,
|
error: undefined,
|
||||||
log: [],
|
log: [],
|
||||||
};
|
};
|
||||||
taskStates[taskId].value.error = { title, description };
|
state.value.error = { title, description };
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -61,15 +67,12 @@ export const useTaskReady = () => useState("taskready", () => false);
|
|||||||
export const useTask = (taskId: string): Ref<TaskMessage | undefined> => {
|
export const useTask = (taskId: string): Ref<TaskMessage | undefined> => {
|
||||||
if (import.meta.server) return ref(undefined);
|
if (import.meta.server) return ref(undefined);
|
||||||
const taskStates = useTaskStates();
|
const taskStates = useTaskStates();
|
||||||
if (
|
const task = taskStates.get(taskId);
|
||||||
taskStates[taskId] &&
|
if (task && task.value && !task.value.error) return task;
|
||||||
taskStates[taskId].value &&
|
|
||||||
!taskStates[taskId].value.error
|
|
||||||
)
|
|
||||||
return taskStates[taskId];
|
|
||||||
|
|
||||||
taskStates[taskId] = ref(undefined);
|
taskStates.set(taskId, ref(undefined));
|
||||||
console.log("connecting to " + taskId);
|
console.log("connecting to " + taskId);
|
||||||
websocketHandler.send(`connect/${taskId}`);
|
websocketHandler.send(`connect/${taskId}`);
|
||||||
return taskStates[taskId];
|
// TODO: this may have changed behavior
|
||||||
|
return taskStates.get(taskId) ?? ref(undefined);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -30,7 +30,7 @@ export class WebSocketHandler {
|
|||||||
this.ws.onmessage = (e) => {
|
this.ws.onmessage = (e) => {
|
||||||
const message = e.data;
|
const message = e.data;
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case "unauthenticated":
|
case "unauthenticated": {
|
||||||
const error = createError({
|
const error = createError({
|
||||||
statusCode: 403,
|
statusCode: 403,
|
||||||
statusMessage: "Unable to connect to websocket - unauthenticated",
|
statusMessage: "Unable to connect to websocket - unauthenticated",
|
||||||
@ -40,6 +40,7 @@ export class WebSocketHandler {
|
|||||||
} else {
|
} else {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (this.listeners.length == 0) {
|
if (this.listeners.length == 0) {
|
||||||
this.inQueue.push(message);
|
this.inQueue.push(message);
|
||||||
|
|||||||
@ -2,7 +2,10 @@
|
|||||||
import type { NuxtError } from "#app";
|
import type { NuxtError } from "#app";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
error: Object as () => NuxtError,
|
error: {
|
||||||
|
type: Object as () => NuxtError,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@ -105,7 +108,7 @@ if (import.meta.client) {
|
|||||||
src="/wallpapers/error-wallpaper.jpg"
|
src="/wallpapers/error-wallpaper.jpg"
|
||||||
class="absolute inset-0 h-full w-full object-cover"
|
class="absolute inset-0 h-full w-full object-cover"
|
||||||
alt=""
|
alt=""
|
||||||
>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -152,10 +152,6 @@ import { ref, type Component } from "vue";
|
|||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogPanel,
|
DialogPanel,
|
||||||
Menu,
|
|
||||||
MenuButton,
|
|
||||||
MenuItem,
|
|
||||||
MenuItems,
|
|
||||||
TransitionChild,
|
TransitionChild,
|
||||||
TransitionRoot,
|
TransitionRoot,
|
||||||
} from "@headlessui/vue";
|
} from "@headlessui/vue";
|
||||||
@ -163,10 +159,7 @@ import {
|
|||||||
Bars3Icon,
|
Bars3Icon,
|
||||||
ServerStackIcon,
|
ServerStackIcon,
|
||||||
HomeIcon,
|
HomeIcon,
|
||||||
LockClosedIcon,
|
|
||||||
Cog6ToothIcon,
|
Cog6ToothIcon,
|
||||||
FlagIcon,
|
|
||||||
BellIcon,
|
|
||||||
DocumentIcon,
|
DocumentIcon,
|
||||||
UserGroupIcon,
|
UserGroupIcon,
|
||||||
} from "@heroicons/vue/24/outline";
|
} from "@heroicons/vue/24/outline";
|
||||||
@ -209,10 +202,10 @@ const navigation: Array<NavigationItem & { icon: Component }> = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const notifications = useNotifications();
|
// const notifications = useNotifications();
|
||||||
const unreadNotifications = computed(() =>
|
// const unreadNotifications = computed(() =>
|
||||||
notifications.value.filter((e) => !e.read)
|
// notifications.value.filter((e) => !e.read)
|
||||||
);
|
// );
|
||||||
|
|
||||||
const currentNavigationIndex = useCurrentNavigationIndex(navigation);
|
const currentNavigationIndex = useCurrentNavigationIndex(navigation);
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
const whitelistedPrefixes = ["/auth", "/api", "/setup"];
|
const whitelistedPrefixes = ["/auth", "/api", "/setup"];
|
||||||
const requireAdmin = ["/admin"];
|
const requireAdmin = ["/admin"];
|
||||||
|
|
||||||
export default defineNuxtRouteMiddleware(async (to, from) => {
|
export default defineNuxtRouteMiddleware(async (to, _from) => {
|
||||||
if (import.meta.server) return;
|
if (import.meta.server) return;
|
||||||
const error = useError();
|
const error = useError();
|
||||||
if (error.value !== undefined) return;
|
if (error.value !== undefined) return;
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import path from "path";
|
|
||||||
import tailwindcss from "@tailwindcss/vite";
|
import tailwindcss from "@tailwindcss/vite";
|
||||||
|
|
||||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||||
|
|||||||
@ -97,16 +97,7 @@ import {
|
|||||||
TransitionChild,
|
TransitionChild,
|
||||||
TransitionRoot,
|
TransitionRoot,
|
||||||
} from "@headlessui/vue";
|
} from "@headlessui/vue";
|
||||||
import {
|
import { Bars3Icon, XMarkIcon } from "@heroicons/vue/24/outline";
|
||||||
Bars3Icon,
|
|
||||||
CalendarIcon,
|
|
||||||
ChartPieIcon,
|
|
||||||
DocumentDuplicateIcon,
|
|
||||||
FolderIcon,
|
|
||||||
HomeIcon,
|
|
||||||
UsersIcon,
|
|
||||||
XMarkIcon,
|
|
||||||
} from "@heroicons/vue/24/outline";
|
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const sidebarOpen = ref(false);
|
const sidebarOpen = ref(false);
|
||||||
|
|||||||
@ -94,6 +94,7 @@
|
|||||||
import { CheckIcon } from "@heroicons/vue/24/outline";
|
import { CheckIcon } from "@heroicons/vue/24/outline";
|
||||||
import { DateTime } from "luxon";
|
import { DateTime } from "luxon";
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore pending https://github.com/nitrojs/nitro/issues/2758
|
// @ts-ignore pending https://github.com/nitrojs/nitro/issues/2758
|
||||||
const clients = ref(await $dropFetch("/api/v1/user/client"));
|
const clients = ref(await $dropFetch("/api/v1/user/client"));
|
||||||
|
|
||||||
@ -114,7 +115,7 @@ function revokeClientWrapper(id: string) {
|
|||||||
title: "Failed to revoke client",
|
title: "Failed to revoke client",
|
||||||
description: `Failed to revoke client: ${e}`,
|
description: `Failed to revoke client: ${e}`,
|
||||||
},
|
},
|
||||||
(_, c) => c()
|
(_, c) => c(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
<template></template>
|
<template><div></div></template>
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div></div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div></div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
<template></template>
|
<template><div></div></template>
|
||||||
|
|||||||
Reference in New Issue
Block a user