mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-01-24 14:24:47 +08:00
chore(frontend): remove useless 'authed' param
This commit is contained in:
parent
5470d5b07e
commit
8eac8aff1c
@ -25,11 +25,11 @@ const loading = ref<{ [key: number]: boolean }>({});
|
||||
|
||||
function resolve(flag: Flag) {
|
||||
loading.value[flag.id] = true;
|
||||
useInternalApi(`flags/${flag.id}/resolve/${props.resolved ? "false" : "true"}`, false, "POST")
|
||||
useInternalApi(`flags/${flag.id}/resolve/${props.resolved ? "false" : "true"}`, "POST")
|
||||
.catch<any>((e) => handleRequestError(e, i18n))
|
||||
.then(async () => {
|
||||
if (flags && flags.value) {
|
||||
const newFlags = await useInternalApi<PaginatedResult<Flag>>("flags/" + (props.resolved ? "resolved" : "unresolved"), false).catch((e) =>
|
||||
const newFlags = await useInternalApi<PaginatedResult<Flag>>("flags/" + (props.resolved ? "resolved" : "unresolved")).catch((e) =>
|
||||
handleRequestError(e, i18n)
|
||||
);
|
||||
if (newFlags) {
|
||||
@ -50,7 +50,7 @@ async function getNotifications(flag: Flag) {
|
||||
return;
|
||||
}
|
||||
|
||||
notifications.value = (await useInternalApi<HangarFlagNotification[]>(`flags/${flag.id}/notifications`, false, "get").catch((e) =>
|
||||
notifications.value = (await useInternalApi<HangarFlagNotification[]>(`flags/${flag.id}/notifications`, "get").catch((e) =>
|
||||
handleRequestError(e, i18n)
|
||||
)) as HangarFlagNotification[];
|
||||
currentId.value = flag.id;
|
||||
|
@ -24,7 +24,7 @@ const loading = ref<boolean>(false);
|
||||
async function fetch() {
|
||||
if (!props.raw) return;
|
||||
loading.value = true;
|
||||
renderedMarkdown.value = await useInternalApi<string>("pages/render", false, "post", {
|
||||
renderedMarkdown.value = await useInternalApi<string>("pages/render", "post", {
|
||||
content: props.raw,
|
||||
}).catch<any>((e) => handleRequestError(e, i18n));
|
||||
loading.value = false;
|
||||
|
@ -82,21 +82,21 @@ if (authStore.user) {
|
||||
.catch((e) => handleRequestError(e, i18n));
|
||||
|
||||
if (hasPerms(NamedPermission.MOD_NOTES_AND_FLAGS)) {
|
||||
useInternalApi<number>("admin/approval/projectneedingapproval", false)
|
||||
useInternalApi<number>("admin/approval/projectneedingapproval")
|
||||
.then((v) => {
|
||||
if (v) {
|
||||
projectApprovalQueue.value = v;
|
||||
}
|
||||
})
|
||||
.catch((e) => handleRequestError(e, i18n));
|
||||
useInternalApi<number>("admin/approval/versionsneedingapproval", false)
|
||||
useInternalApi<number>("admin/approval/versionsneedingapproval")
|
||||
.then((v) => {
|
||||
if (v) {
|
||||
versionApprovalQueue.value = v;
|
||||
}
|
||||
})
|
||||
.catch((e) => handleRequestError(e, i18n));
|
||||
useInternalApi<number>("flags/unresolvedamount", false)
|
||||
useInternalApi<number>("flags/unresolvedamount")
|
||||
.then((v) => {
|
||||
if (v) {
|
||||
reportQueue.value = v;
|
||||
@ -150,7 +150,7 @@ function markNotificationRead(notification: HangarNotification) {
|
||||
notification.read = true;
|
||||
unreadNotifications.value--;
|
||||
loadedUnreadNotifications.value--;
|
||||
useInternalApi(`notifications/${notification.id}`, true, "post").catch((e) => handleRequestError(e, i18n));
|
||||
useInternalApi(`notifications/${notification.id}`, "post").catch((e) => handleRequestError(e, i18n));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ function hasInvalidDependency(dependencies: PluginDependency[]) {
|
||||
async function save() {
|
||||
loading.value = true;
|
||||
try {
|
||||
await useInternalApi(`versions/version/${props.project.id}/${projectVersion.value?.id}/savePluginDependencies`, true, "post", {
|
||||
await useInternalApi(`versions/version/${props.project.id}/${projectVersion.value?.id}/savePluginDependencies`, "post", {
|
||||
platform: platform.value?.name?.toUpperCase(),
|
||||
pluginDependencies: depTable.value.dependencies,
|
||||
});
|
||||
|
@ -29,7 +29,7 @@ const flagComment = ref<string>();
|
||||
|
||||
async function submit(close: () => void) {
|
||||
try {
|
||||
await useInternalApi("flags/", true, "POST", {
|
||||
await useInternalApi("flags/", "POST", {
|
||||
projectId: props.project.id,
|
||||
reason: flagReason.value,
|
||||
comment: flagComment.value,
|
||||
|
@ -23,7 +23,7 @@ const comment = ref<string>("");
|
||||
|
||||
async function confirm(close: () => void) {
|
||||
try {
|
||||
await useInternalApi(`admin/lock-user/${props.user.name}/${!props.user.locked}`, true, "post", {
|
||||
await useInternalApi(`admin/lock-user/${props.user.name}/${!props.user.locked}`, "post", {
|
||||
content: comment.value,
|
||||
});
|
||||
close();
|
||||
|
@ -24,7 +24,7 @@ const name = props.organization ? props.author : props.slug;
|
||||
|
||||
function leave() {
|
||||
const url = props.organization ? `organizations/org/${props.author}/members/leave` : `projects/project/${props.author}/${props.slug}/members/leave`;
|
||||
useInternalApi(url, true, "post")
|
||||
useInternalApi(url, "post")
|
||||
.then(() => router.go(0))
|
||||
.catch((e) => handleRequestError(e, i18n));
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ watch(name, async () => {
|
||||
if (!name.value) return;
|
||||
validateLoading.value = true;
|
||||
nameErrorMessages.value = [];
|
||||
await useInternalApi("pages/checkName", true, "get", {
|
||||
await useInternalApi("pages/checkName", "get", {
|
||||
projectId: props.projectId,
|
||||
name: name.value,
|
||||
parentId: parent.value,
|
||||
@ -66,13 +66,13 @@ function flatDeep(pages: HangarProjectPage[], prefix: string): Option[] {
|
||||
async function createPage() {
|
||||
try {
|
||||
loading.value = true;
|
||||
const slug = await useInternalApi<string>(`pages/create/${props.projectId}`, true, "post", {
|
||||
const slug = await useInternalApi<string>(`pages/create/${props.projectId}`, "post", {
|
||||
name: name.value,
|
||||
parentId: parent.value,
|
||||
});
|
||||
|
||||
if (updateProjectPagesCallback) {
|
||||
updateProjectPagesCallback(await useInternalApi<HangarProjectPage[]>(`pages/list/${props.projectId}`, false, "get"));
|
||||
updateProjectPagesCallback(await useInternalApi<HangarProjectPage[]>(`pages/list/${props.projectId}`, "get"));
|
||||
}
|
||||
|
||||
await router.push(`/${route.params.user}/${route.params.project}/pages/${slug}`);
|
||||
|
@ -20,7 +20,7 @@ const loading = ref<boolean>(false);
|
||||
|
||||
async function deleteOrg() {
|
||||
loading.value = true;
|
||||
await useInternalApi(`organizations/org/${props.organization}/delete`, true, "post", {
|
||||
await useInternalApi(`organizations/org/${props.organization}/delete`, "post", {
|
||||
content: comment.value,
|
||||
}).catch((e) => handleRequestError(e, i18n));
|
||||
await router.push("/");
|
||||
|
@ -23,7 +23,7 @@ const result = ref<string[]>([]);
|
||||
const loading = ref<boolean>(false);
|
||||
async function doSearch(val: string) {
|
||||
result.value = [];
|
||||
const users = await useApi<PaginatedResult<User>>("users", false, "get", {
|
||||
const users = await useApi<PaginatedResult<User>>("users", "get", {
|
||||
query: val,
|
||||
limit: 25,
|
||||
offset: 0,
|
||||
@ -33,7 +33,7 @@ async function doSearch(val: string) {
|
||||
|
||||
async function transfer() {
|
||||
loading.value = true;
|
||||
await useInternalApi<string>(`organizations/org/${props.organization}/transfer`, true, "post", {
|
||||
await useInternalApi<string>(`organizations/org/${props.organization}/transfer`, "post", {
|
||||
content: search.value,
|
||||
}).catch((e) => handleRequestError(e, i18n));
|
||||
notificationStore.success(i18n.t("organization.settings.success.transferRequest", [search.value]));
|
||||
|
@ -27,7 +27,7 @@ const internalVisibility = computed({
|
||||
|
||||
async function changeOrgVisibility(org: string) {
|
||||
loading.value = true;
|
||||
await useInternalApi<{ [key: string]: boolean }>(`organizations/${org}/userOrganizationsVisibility`, true, "POST", internalVisibility.value[org] as any, {
|
||||
await useInternalApi<{ [key: string]: boolean }>(`organizations/${org}/userOrganizationsVisibility`, "POST", internalVisibility.value[org] as any, {
|
||||
"Content-Type": "application/json",
|
||||
}).catch((e) => handleRequestError(e, i18n));
|
||||
loading.value = false;
|
||||
|
@ -34,7 +34,7 @@ const selectedVersions = ref(projectVersion.value?.platformDependencies[platform
|
||||
|
||||
function save() {
|
||||
loading.value = true;
|
||||
useInternalApi(`versions/version/${props.project.id}/${projectVersion.value?.id}/savePlatformVersions`, true, "post", {
|
||||
useInternalApi(`versions/version/${props.project.id}/${projectVersion.value?.id}/savePlatformVersions`, "post", {
|
||||
platform: platform.value?.name?.toUpperCase(),
|
||||
versions: selectedVersions.value,
|
||||
})
|
||||
|
@ -29,7 +29,7 @@ const content = ref<string>("");
|
||||
const warning = ref<boolean>(false);
|
||||
|
||||
async function submit() {
|
||||
await useInternalApi(`flags/${props.flag.id}/notify`, true, "post", {
|
||||
await useInternalApi(`flags/${props.flag.id}/notify`, "post", {
|
||||
warning: warning.value,
|
||||
toReporter: props.sendToReporter,
|
||||
content: content.value,
|
||||
|
@ -25,7 +25,7 @@ const loading = ref(false);
|
||||
async function save() {
|
||||
loading.value = true;
|
||||
try {
|
||||
await useInternalApi(props.action, true, "post", {
|
||||
await useInternalApi(props.action, "post", {
|
||||
content: newTagline.value,
|
||||
});
|
||||
router.go(0);
|
||||
|
@ -31,7 +31,7 @@ const setVisibility = computed(() => backendData.visibilities.find((v) => v.name
|
||||
const currentVisibility = computed(() => backendData.visibilities.find((v) => v.name === props.propVisibility));
|
||||
|
||||
async function submit(): Promise<void> {
|
||||
await useInternalApi(props.postUrl, true, "post", {
|
||||
await useInternalApi(props.postUrl, "post", {
|
||||
visibility: visibility.value,
|
||||
comment: setVisibility.value?.showModal ? reason.value : null,
|
||||
}).catch((e) => handleRequestError(e, i18n));
|
||||
|
@ -89,7 +89,7 @@ function cancelTransfer() {
|
||||
|
||||
saving.value = true;
|
||||
const url = props.organization ? `organizations/org/${props.author}/canceltransfer` : `projects/project/${props.author}/${props.slug}/canceltransfer`;
|
||||
useInternalApi(url, true, "post")
|
||||
useInternalApi(url, "post")
|
||||
.then(() => router.go(0))
|
||||
.catch((e) => handleRequestError(e, i18n))
|
||||
.finally(() => (saving.value = false));
|
||||
@ -119,7 +119,7 @@ function post(member: EditableMember, action: "edit" | "add" | "remove") {
|
||||
|
||||
saving.value = true;
|
||||
const url = props.organization ? `organizations/org/${props.author}/members/${action}` : `projects/project/${props.author}/${props.slug}/members/${action}`;
|
||||
useInternalApi(url, true, "post", member)
|
||||
useInternalApi(url, "post", member)
|
||||
.then(() => {
|
||||
router.go(0);
|
||||
})
|
||||
@ -140,7 +140,7 @@ function convertMember(member: JoinableMember): EditableMember {
|
||||
|
||||
async function doSearch(val: string) {
|
||||
result.value = [];
|
||||
const users = await useApi<PaginatedResult<User>>("users", false, "get", {
|
||||
const users = await useApi<PaginatedResult<User>>("users", "get", {
|
||||
query: val,
|
||||
limit: 25,
|
||||
offset: 0,
|
||||
|
@ -41,7 +41,7 @@ const watchingCount = ref(props.project.stats.watchers);
|
||||
const isOwn = computed(() => !user || user.name === props.project.namespace.owner);
|
||||
|
||||
function toggleState(route: string, completedKey: string, revokedKey: string, value: Ref<boolean>, count: Ref<number>) {
|
||||
useInternalApi(`projects/project/${props.project.id}/${route}/${!value.value}`, true, "post")
|
||||
useInternalApi(`projects/project/${props.project.id}/${route}/${!value.value}`, "post")
|
||||
.then(() => {
|
||||
value.value = !value.value;
|
||||
if (value.value) {
|
||||
@ -65,7 +65,7 @@ function toggleWatch() {
|
||||
|
||||
async function sendForApproval() {
|
||||
try {
|
||||
await useInternalApi(`projects/visibility/${props.project.id}/sendforapproval`, true, "post");
|
||||
await useInternalApi(`projects/visibility/${props.project.id}/sendforapproval`, "post");
|
||||
notification.success(i18n.t("projectApproval.sendForApproval"));
|
||||
await router.go(0);
|
||||
} catch (e) {
|
||||
|
@ -31,7 +31,7 @@ async function deletePageAndUpdateProject() {
|
||||
|
||||
try {
|
||||
if (updateProjectPages) {
|
||||
updateProjectPages(await useInternalApi<HangarProjectPage[]>(`pages/list/${props.project.id}`, false, "get"));
|
||||
updateProjectPages(await useInternalApi<HangarProjectPage[]>(`pages/list/${props.project.id}`, "get"));
|
||||
}
|
||||
} catch (e: any) {
|
||||
handleRequestError(e, i18n);
|
||||
|
@ -44,14 +44,12 @@ function request<T>(url: string, method: AxiosRequestConfig["method"], data: obj
|
||||
});
|
||||
}
|
||||
|
||||
export function useApi<T>(url: string, authed = true, method: AxiosRequestConfig["method"] = "get", data: object = {}): Promise<T> {
|
||||
export function useApi<T>(url: string, method: AxiosRequestConfig["method"] = "get", data: object = {}): Promise<T> {
|
||||
fetchLog("useApi", url);
|
||||
return request(`v1/${url}`, method, data);
|
||||
}
|
||||
|
||||
// TODO do something with authed
|
||||
|
||||
export function useInternalApi<T = void>(url: string, authed = true, method: AxiosRequestConfig["method"] = "get", data: object = {}): Promise<T> {
|
||||
export function useInternalApi<T = void>(url: string, method: AxiosRequestConfig["method"] = "get", data: object = {}): Promise<T> {
|
||||
fetchLog("useInternalApi", url);
|
||||
return request(`internal/${url}`, method, data);
|
||||
}
|
||||
|
@ -19,94 +19,90 @@ import { useApi, useInternalApi } from "~/composables/useApi";
|
||||
import { useAsyncData } from "#imports";
|
||||
|
||||
export async function useProjects(params: Record<string, any> = { limit: 25, offset: 0 }) {
|
||||
return (await useAsyncData("useProjects", () => useApi<PaginatedResult<Project>>("projects", false, "get", params))).data;
|
||||
return (await useAsyncData("useProjects", () => useApi<PaginatedResult<Project>>("projects", "get", params))).data;
|
||||
}
|
||||
|
||||
export async function useUser(user: string) {
|
||||
return (await useAsyncData("useUser:" + user, () => useApi<User>("users/" + user, false))).data;
|
||||
return (await useAsyncData("useUser:" + user, () => useApi<User>("users/" + user))).data;
|
||||
}
|
||||
|
||||
export async function useOrganization(user: string) {
|
||||
return (await useAsyncData("useOrganization:" + user, () => useInternalApi<Organization>(`organizations/org/${user}`, false))).data;
|
||||
return (await useAsyncData("useOrganization:" + user, () => useInternalApi<Organization>(`organizations/org/${user}`))).data;
|
||||
}
|
||||
|
||||
export async function useProject(user: string, project: string) {
|
||||
return (await useAsyncData("useProject:" + user + ":" + project, () => useInternalApi<HangarProject>("projects/project/" + user + "/" + project, false)))
|
||||
.data;
|
||||
return (await useAsyncData("useProject:" + user + ":" + project, () => useInternalApi<HangarProject>("projects/project/" + user + "/" + project))).data;
|
||||
}
|
||||
|
||||
export async function useStargazers(user: string, project: string) {
|
||||
return (await useAsyncData("useStargazers:" + user + ":" + project, () => useApi<PaginatedResult<User>>(`projects/${user}/${project}/stargazers`, false)))
|
||||
.data;
|
||||
return (await useAsyncData("useStargazers:" + user + ":" + project, () => useApi<PaginatedResult<User>>(`projects/${user}/${project}/stargazers`))).data;
|
||||
}
|
||||
|
||||
export async function useWatchers(user: string, project: string) {
|
||||
return (await useAsyncData("useWatchers:" + user + ":" + project, () => useApi<PaginatedResult<User>>(`projects/${user}/${project}/watchers`, false))).data;
|
||||
return (await useAsyncData("useWatchers:" + user + ":" + project, () => useApi<PaginatedResult<User>>(`projects/${user}/${project}/watchers`))).data;
|
||||
}
|
||||
|
||||
export async function useStaff() {
|
||||
return (await useAsyncData("useStaff", () => useApi<PaginatedResult<User>>("staff", false))).data;
|
||||
return (await useAsyncData("useStaff", () => useApi<PaginatedResult<User>>("staff"))).data;
|
||||
}
|
||||
|
||||
export async function useAuthors() {
|
||||
return (await useAsyncData("useAuthors", () => useApi<PaginatedResult<User>>("authors", false))).data;
|
||||
return (await useAsyncData("useAuthors", () => useApi<PaginatedResult<User>>("authors"))).data;
|
||||
}
|
||||
|
||||
export async function useInvites() {
|
||||
return (await useAsyncData("useInvites", () => useInternalApi<Invites>("invites", false))).data;
|
||||
return (await useAsyncData("useInvites", () => useInternalApi<Invites>("invites"))).data;
|
||||
}
|
||||
|
||||
export async function useNotifications() {
|
||||
return (await useAsyncData("useNotifications", () => useInternalApi<PaginatedResult<HangarNotification>>("notifications", false))).data;
|
||||
return (await useAsyncData("useNotifications", () => useInternalApi<PaginatedResult<HangarNotification>>("notifications"))).data;
|
||||
}
|
||||
|
||||
export async function useUnreadNotifications() {
|
||||
return (await useAsyncData("useUnreadNotifications", () => useInternalApi<PaginatedResult<HangarNotification>>("unreadnotifications", false))).data;
|
||||
return (await useAsyncData("useUnreadNotifications", () => useInternalApi<PaginatedResult<HangarNotification>>("unreadnotifications"))).data;
|
||||
}
|
||||
|
||||
export async function useReadNotifications() {
|
||||
return (await useAsyncData("useReadNotifications", () => useInternalApi<PaginatedResult<HangarNotification>>("readnotifications", false))).data;
|
||||
return (await useAsyncData("useReadNotifications", () => useInternalApi<PaginatedResult<HangarNotification>>("readnotifications"))).data;
|
||||
}
|
||||
|
||||
export async function useRecentNotifications(amount: number) {
|
||||
return (await useAsyncData("useRecentNotifications:" + amount, () => useInternalApi<HangarNotification[]>("recentnotifications?amount=" + amount, false)))
|
||||
.data;
|
||||
return (await useAsyncData("useRecentNotifications:" + amount, () => useInternalApi<HangarNotification[]>("recentnotifications?amount=" + amount))).data;
|
||||
}
|
||||
|
||||
export async function useUnreadNotificationsCount() {
|
||||
return (await useAsyncData("useUnreadNotificationsCount", () => useInternalApi<number>("unreadcount", false))).data;
|
||||
return (await useAsyncData("useUnreadNotificationsCount", () => useInternalApi<number>("unreadcount"))).data;
|
||||
}
|
||||
|
||||
export async function useResolvedFlags() {
|
||||
return (await useAsyncData("useResolvedFlags", () => useInternalApi<PaginatedResult<Flag>>("flags/resolved", false))).data;
|
||||
return (await useAsyncData("useResolvedFlags", () => useInternalApi<PaginatedResult<Flag>>("flags/resolved"))).data;
|
||||
}
|
||||
|
||||
export async function useUnresolvedFlags() {
|
||||
return (await useAsyncData("useUnresolvedFlags", () => useInternalApi<PaginatedResult<Flag>>("flags/unresolved", false))).data;
|
||||
return (await useAsyncData("useUnresolvedFlags", () => useInternalApi<PaginatedResult<Flag>>("flags/unresolved"))).data;
|
||||
}
|
||||
|
||||
export async function useProjectFlags(projectId: number) {
|
||||
return (await useAsyncData("useProjectFlags:" + projectId, () => useInternalApi<Flag[]>("flags/" + projectId, false))).data;
|
||||
return (await useAsyncData("useProjectFlags:" + projectId, () => useInternalApi<Flag[]>("flags/" + projectId))).data;
|
||||
}
|
||||
|
||||
export async function useProjectNotes(projectId: number) {
|
||||
return (await useAsyncData("useProjectNotes:" + projectId, () => useInternalApi<Note[]>("projects/notes/" + projectId, false))).data;
|
||||
return (await useAsyncData("useProjectNotes:" + projectId, () => useInternalApi<Note[]>("projects/notes/" + projectId))).data;
|
||||
}
|
||||
|
||||
export async function useProjectChannels(user: string, project: string) {
|
||||
return (await useAsyncData("useProjectChannels:" + user + ":" + project, () => useInternalApi<ProjectChannel[]>(`channels/${user}/${project}`, false))).data;
|
||||
return (await useAsyncData("useProjectChannels:" + user + ":" + project, () => useInternalApi<ProjectChannel[]>(`channels/${user}/${project}`))).data;
|
||||
}
|
||||
|
||||
export async function useProjectVersions(user: string, project: string) {
|
||||
return (
|
||||
await useAsyncData("useProjectVersions:" + user + ":" + project, () => useApi<PaginatedResult<Version>>(`projects/${user}/${project}/versions`, false))
|
||||
).data;
|
||||
return (await useAsyncData("useProjectVersions:" + user + ":" + project, () => useApi<PaginatedResult<Version>>(`projects/${user}/${project}/versions`)))
|
||||
.data;
|
||||
}
|
||||
|
||||
export async function useProjectVersionsInternal(user: string, project: string, version: string) {
|
||||
return (
|
||||
await useAsyncData("useProjectVersionsInternal:" + user + ":" + project + ":" + version, () =>
|
||||
useInternalApi<HangarVersion>(`versions/version/${user}/${project}/versions/${version}`, false)
|
||||
useInternalApi<HangarVersion>(`versions/version/${user}/${project}/versions/${version}`)
|
||||
)
|
||||
).data;
|
||||
}
|
||||
@ -114,23 +110,23 @@ export async function useProjectVersionsInternal(user: string, project: string,
|
||||
export async function usePage(user: string, project: string, path?: string) {
|
||||
return (
|
||||
await useAsyncData("usePage:" + user + ":" + project + ":" + path, () =>
|
||||
useInternalApi<ProjectPage>(`pages/page/${user}/${project}` + (path ? "/" + path : ""), false)
|
||||
useInternalApi<ProjectPage>(`pages/page/${user}/${project}` + (path ? "/" + path : ""))
|
||||
)
|
||||
).data;
|
||||
}
|
||||
|
||||
export async function useHealthReport() {
|
||||
return (await useAsyncData("useHealthReport", () => useInternalApi<HealthReport>("admin/health", false))).data;
|
||||
return (await useAsyncData("useHealthReport", () => useInternalApi<HealthReport>("admin/health"))).data;
|
||||
}
|
||||
|
||||
export async function useActionLogs() {
|
||||
return (await useAsyncData("useActionLogs", () => useInternalApi<PaginatedResult<LoggedAction>>("admin/log/", false))).data;
|
||||
return (await useAsyncData("useActionLogs", () => useInternalApi<PaginatedResult<LoggedAction>>("admin/log/"))).data;
|
||||
}
|
||||
|
||||
export async function useVersionApprovals() {
|
||||
return (
|
||||
await useAsyncData("useVersionApprovals", () =>
|
||||
useInternalApi<{ underReview: ReviewQueueEntry[]; notStarted: ReviewQueueEntry[] }>("admin/approval/versions", false)
|
||||
useInternalApi<{ underReview: ReviewQueueEntry[]; notStarted: ReviewQueueEntry[] }>("admin/approval/versions")
|
||||
)
|
||||
).data;
|
||||
}
|
||||
@ -140,9 +136,8 @@ export async function usePossibleOwners() {
|
||||
}
|
||||
|
||||
export async function useOrgVisibility(user: string) {
|
||||
return (
|
||||
await useAsyncData("useOrgVisibility:" + user, () => useInternalApi<{ [key: string]: boolean }>(`organizations/${user}/userOrganizationsVisibility`, true))
|
||||
).data;
|
||||
return (await useAsyncData("useOrgVisibility:" + user, () => useInternalApi<{ [key: string]: boolean }>(`organizations/${user}/userOrganizationsVisibility`)))
|
||||
.data;
|
||||
}
|
||||
|
||||
export async function useUserData(user: string) {
|
||||
@ -150,13 +145,13 @@ export async function useUserData(user: string) {
|
||||
await useAsyncData("useUserData:" + user, async () => {
|
||||
// noinspection ES6MissingAwait
|
||||
const data = await Promise.all([
|
||||
useApi<PaginatedResult<ProjectCompact>>(`users/${user}/starred`, false),
|
||||
useApi<PaginatedResult<ProjectCompact>>(`users/${user}/watching`, false),
|
||||
useApi<PaginatedResult<Project>>(`projects`, false, "get", {
|
||||
useApi<PaginatedResult<ProjectCompact>>(`users/${user}/starred`),
|
||||
useApi<PaginatedResult<ProjectCompact>>(`users/${user}/watching`),
|
||||
useApi<PaginatedResult<Project>>(`projects`, "get", {
|
||||
owner: user,
|
||||
}),
|
||||
useInternalApi<{ [key: string]: RoleTable }>(`organizations/${user}/userOrganizations`, false),
|
||||
useApi<ProjectCompact[]>(`users/${user}/pinned`, false),
|
||||
useInternalApi<{ [key: string]: RoleTable }>(`organizations/${user}/userOrganizations`),
|
||||
useApi<ProjectCompact[]>(`users/${user}/pinned`),
|
||||
]);
|
||||
return {
|
||||
starred: data[0] as PaginatedResult<ProjectCompact>,
|
||||
|
@ -118,7 +118,7 @@ class Auth {
|
||||
authLog("no point in updating if we already have a user");
|
||||
return;
|
||||
}
|
||||
const user = await useInternalApi<HangarUser>("users/@me", true).catch((err) => {
|
||||
const user = await useInternalApi<HangarUser>("users/@me").catch((err) => {
|
||||
authLog("no user, with err", Object.assign({}, err));
|
||||
return this.invalidate(axios);
|
||||
});
|
||||
|
@ -10,7 +10,7 @@ export const validProjectName = withOverrideMessage((ownerId: () => string) =>
|
||||
return { $valid: true };
|
||||
}
|
||||
try {
|
||||
await useInternalApi("projects/validateName", false, "get", {
|
||||
await useInternalApi("projects/validateName", "get", {
|
||||
userId: ownerId(),
|
||||
value,
|
||||
});
|
||||
@ -33,7 +33,7 @@ export const validOrgName = withOverrideMessage(
|
||||
}
|
||||
|
||||
try {
|
||||
await useInternalApi("organizations/validate", false, "get", {
|
||||
await useInternalApi("organizations/validate", "get", {
|
||||
name: value,
|
||||
});
|
||||
return { $valid: true };
|
||||
@ -51,7 +51,7 @@ export const validApiKeyName = withOverrideMessage((username: string) =>
|
||||
return { $valid: true };
|
||||
}
|
||||
try {
|
||||
await useInternalApi(`api-keys/check-key/${username}`, true, "get", {
|
||||
await useInternalApi(`api-keys/check-key/${username}`, "get", {
|
||||
name: value,
|
||||
});
|
||||
return { $valid: true };
|
||||
@ -70,7 +70,7 @@ export const validChannelName = withOverrideMessage((projectId: string, existing
|
||||
return { $valid: true };
|
||||
}
|
||||
try {
|
||||
await useInternalApi("channels/checkName", true, "get", {
|
||||
await useInternalApi("channels/checkName", "get", {
|
||||
projectId,
|
||||
name: value,
|
||||
existingName,
|
||||
@ -91,7 +91,7 @@ export const validChannelColor = withOverrideMessage((projectId: string, existin
|
||||
return { $valid: true };
|
||||
}
|
||||
try {
|
||||
await useInternalApi("channels/checkColor", true, "get", {
|
||||
await useInternalApi("channels/checkColor", "get", {
|
||||
projectId,
|
||||
color: value,
|
||||
existingColor,
|
||||
|
@ -22,7 +22,7 @@ export async function useProjectPage(route: RouteLocationNormalizedLoaded, route
|
||||
|
||||
async function savePage(content: string) {
|
||||
if (!page) return;
|
||||
await useInternalApi(`pages/save/${project.id}/${page.value?.id}`, true, "post", {
|
||||
await useInternalApi(`pages/save/${project.id}/${page.value?.id}`, "post", {
|
||||
content,
|
||||
}).catch((e) => handleRequestError(e, i18n, "page.new.error.save"));
|
||||
if (page.value) {
|
||||
@ -33,7 +33,7 @@ export async function useProjectPage(route: RouteLocationNormalizedLoaded, route
|
||||
|
||||
async function deletePage() {
|
||||
if (!page) return;
|
||||
await useInternalApi(`pages/delete/${project.id}/${page.value?.id}`, true, "post").catch((e) => handleRequestError(e, i18n, "page.new.error.save"));
|
||||
await useInternalApi(`pages/delete/${project.id}/${page.value?.id}`, "post").catch((e) => handleRequestError(e, i18n, "page.new.error.save"));
|
||||
await router.replace(`/${route.params.user}/${route.params.project}`);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ async function loadRoutePerms(to: RouteLocationNormalized) {
|
||||
const authStore = useAuthStore();
|
||||
if (to.params.user && to.params.project) {
|
||||
if (authStore.authenticated) {
|
||||
const perms = await useApi<UserPermissions>("permissions", true, "get", {
|
||||
const perms = await useApi<UserPermissions>("permissions", "get", {
|
||||
author: to.params.user,
|
||||
slug: to.params.project,
|
||||
}).catch(() => authStore.setRoutePerms(null));
|
||||
@ -37,7 +37,7 @@ async function loadRoutePerms(to: RouteLocationNormalized) {
|
||||
}
|
||||
} else if (to.params.user) {
|
||||
if (authStore.authenticated) {
|
||||
const perms = await useApi<UserPermissions>("permissions", true, "get", {
|
||||
const perms = await useApi<UserPermissions>("permissions", "get", {
|
||||
organization: to.params.user,
|
||||
}).catch(() => authStore.setRoutePerms(null));
|
||||
if (perms) {
|
||||
@ -96,7 +96,7 @@ async function globalPermsRequired(authStore: ReturnType<typeof useAuthStore>, t
|
||||
const result = checkLogin(authStore, to, 403);
|
||||
if (result) return result;
|
||||
const i18n = useI18n();
|
||||
const check = await useApi<PermissionCheck>("permissions/hasAll", true, "get", {
|
||||
const check = await useApi<PermissionCheck>("permissions/hasAll", "get", {
|
||||
permissions: toNamedPermission(to.meta.globalPermsRequired as string[]),
|
||||
}).catch((e) => {
|
||||
try {
|
||||
|
@ -39,7 +39,7 @@ useHead(
|
||||
);
|
||||
|
||||
async function refreshChannels() {
|
||||
const newChannels = await useInternalApi<ProjectChannel[]>(`channels/${props.project.namespace.owner}/${props.project.namespace.slug}`, false).catch((e) =>
|
||||
const newChannels = await useInternalApi<ProjectChannel[]>(`channels/${props.project.namespace.owner}/${props.project.namespace.slug}`).catch((e) =>
|
||||
handleRequestError(e, i18n)
|
||||
);
|
||||
if (channels && newChannels) {
|
||||
@ -48,7 +48,7 @@ async function refreshChannels() {
|
||||
}
|
||||
|
||||
async function deleteChannel(channel: ProjectChannel) {
|
||||
await useInternalApi(`channels/${props.project.id}/delete/${channel.id}`, true, "post")
|
||||
await useInternalApi(`channels/${props.project.id}/delete/${channel.id}`, "post")
|
||||
.then(() => {
|
||||
refreshChannels();
|
||||
notifications.warn(i18n.t("channel.modal.success.deletedChannel", [channel.name]));
|
||||
@ -57,7 +57,7 @@ async function deleteChannel(channel: ProjectChannel) {
|
||||
}
|
||||
|
||||
async function addChannel(channel: ProjectChannel) {
|
||||
await useInternalApi(`channels/${props.project.id}/create`, true, "post", {
|
||||
await useInternalApi(`channels/${props.project.id}/create`, "post", {
|
||||
name: channel.name,
|
||||
color: channel.color,
|
||||
flags: channel.flags,
|
||||
@ -71,7 +71,7 @@ async function addChannel(channel: ProjectChannel) {
|
||||
|
||||
async function editChannel(channel: ProjectChannel) {
|
||||
if (!channel.id) return;
|
||||
await useInternalApi(`channels/${props.project.id}/edit`, true, "post", {
|
||||
await useInternalApi(`channels/${props.project.id}/edit`, "post", {
|
||||
id: channel.id,
|
||||
name: channel.name,
|
||||
color: channel.color,
|
||||
|
@ -34,7 +34,7 @@ const openProjectPages = await useOpenProjectPages(route, props.project);
|
||||
const sponsors = ref(props.project.settings.sponsors);
|
||||
const editingSponsors = ref(false);
|
||||
function saveSponsors(content: string) {
|
||||
useInternalApi(`projects/project/${props.project.namespace.owner}/${props.project.namespace.slug}/sponsors`, true, "post", {
|
||||
useInternalApi(`projects/project/${props.project.namespace.owner}/${props.project.namespace.slug}/sponsors`, "post", {
|
||||
content,
|
||||
})
|
||||
.then(() => {
|
||||
|
@ -45,11 +45,11 @@ async function addNote() {
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
await useInternalApi(`projects/notes/${props.project.id}`, true, "post", {
|
||||
await useInternalApi(`projects/notes/${props.project.id}`, "post", {
|
||||
content: text.value,
|
||||
}).catch((e) => handleRequestError(e, i18n));
|
||||
text.value = "";
|
||||
const newNotes = await useInternalApi<Note[]>("projects/notes/" + props.project.id, false).catch((e) => handleRequestError(e, i18n));
|
||||
const newNotes = await useInternalApi<Note[]>("projects/notes/" + props.project.id).catch((e) => handleRequestError(e, i18n));
|
||||
if (notes && newNotes) {
|
||||
notes.value = newNotes;
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ const search = ref<string>("");
|
||||
const result = ref<string[]>([]);
|
||||
async function doSearch(val: string) {
|
||||
result.value = [];
|
||||
const users = await useApi<PaginatedResult<User>>("users", false, "get", {
|
||||
const users = await useApi<PaginatedResult<User>>("users", "get", {
|
||||
query: val,
|
||||
limit: 25,
|
||||
offset: 0,
|
||||
@ -135,7 +135,7 @@ async function save() {
|
||||
loading.save = true;
|
||||
try {
|
||||
if (!(await v.value.$validate())) return;
|
||||
await useInternalApi(`projects/project/${route.params.user}/${route.params.project}/settings`, true, "post", {
|
||||
await useInternalApi(`projects/project/${route.params.user}/${route.params.project}/settings`, "post", {
|
||||
...form,
|
||||
});
|
||||
await router.go(0);
|
||||
@ -148,7 +148,7 @@ async function save() {
|
||||
async function transfer() {
|
||||
loading.transfer = true;
|
||||
try {
|
||||
await useInternalApi<string>(`projects/project/${route.params.user}/${route.params.project}/transfer`, true, "post", {
|
||||
await useInternalApi<string>(`projects/project/${route.params.user}/${route.params.project}/transfer`, "post", {
|
||||
content: search.value,
|
||||
});
|
||||
notificationStore.success(i18n.t("project.settings.success.transferRequest", [search.value]));
|
||||
@ -161,7 +161,7 @@ async function transfer() {
|
||||
async function rename() {
|
||||
loading.rename = true;
|
||||
try {
|
||||
const newSlug = await useInternalApi<string>(`projects/project/${route.params.user}/${route.params.project}/rename`, true, "post", {
|
||||
const newSlug = await useInternalApi<string>(`projects/project/${route.params.user}/${route.params.project}/rename`, "post", {
|
||||
content: newName.value,
|
||||
});
|
||||
notificationStore.success(i18n.t("project.settings.success.rename", [newName.value]));
|
||||
@ -174,7 +174,7 @@ async function rename() {
|
||||
|
||||
async function softDelete(comment: string) {
|
||||
try {
|
||||
await useInternalApi(`projects/project/${props.project.id}/manage/delete`, true, "post", {
|
||||
await useInternalApi(`projects/project/${props.project.id}/manage/delete`, "post", {
|
||||
content: comment,
|
||||
});
|
||||
useNotificationStore().success(i18n.t("project.settings.success.softDelete"));
|
||||
@ -190,7 +190,7 @@ async function softDelete(comment: string) {
|
||||
|
||||
async function hardDelete(comment: string) {
|
||||
try {
|
||||
await useInternalApi(`projects/project/${props.project.id}/manage/hardDelete`, true, "post", {
|
||||
await useInternalApi(`projects/project/${props.project.id}/manage/hardDelete`, "post", {
|
||||
content: comment,
|
||||
});
|
||||
notificationStore.success(i18n.t("project.settings.success.hardDelete"));
|
||||
@ -209,7 +209,7 @@ async function uploadIcon() {
|
||||
data.append("projectIcon", cropperResult.value);
|
||||
loading.uploadIcon = true;
|
||||
try {
|
||||
const response = await useInternalApi<string | null>(`projects/project/${route.params.user}/${route.params.project}/saveIcon`, true, "post", data);
|
||||
const response = await useInternalApi<string | null>(`projects/project/${route.params.user}/${route.params.project}/saveIcon`, "post", data);
|
||||
cropperResult.value = null;
|
||||
await loadIconIntoCropper();
|
||||
if (response) {
|
||||
@ -226,7 +226,7 @@ async function uploadIcon() {
|
||||
async function resetIcon() {
|
||||
loading.resetIcon = true;
|
||||
try {
|
||||
const response = await useInternalApi<string | null>(`projects/project/${route.params.user}/${route.params.project}/resetIcon`, true, "post");
|
||||
const response = await useInternalApi<string | null>(`projects/project/${route.params.user}/${route.params.project}/resetIcon`, "post");
|
||||
if (response) {
|
||||
useNotificationStore().success(i18n.t("project.settings.success.resetIconWarn", [response]));
|
||||
} else {
|
||||
|
@ -92,7 +92,7 @@ function setPlatform(plat: Platform) {
|
||||
|
||||
async function savePage(content: string) {
|
||||
try {
|
||||
await useInternalApi(`versions/version/${props.project.id}/${projectVersion.value?.id}/saveDescription`, true, "post", {
|
||||
await useInternalApi(`versions/version/${props.project.id}/${projectVersion.value?.id}/saveDescription`, "post", {
|
||||
content,
|
||||
});
|
||||
if (projectVersion.value) {
|
||||
@ -106,7 +106,7 @@ async function savePage(content: string) {
|
||||
|
||||
async function setPinned(value: boolean) {
|
||||
try {
|
||||
await useInternalApi(`versions/version/${props.project.id}/${projectVersion.value?.id}/pinned?value=${value}`, true, "post");
|
||||
await useInternalApi(`versions/version/${props.project.id}/${projectVersion.value?.id}/pinned?value=${value}`, "post");
|
||||
notification.success(i18n.t(`version.page.pinned.request.${value}`));
|
||||
router.go(0);
|
||||
} catch (e) {
|
||||
@ -116,7 +116,7 @@ async function setPinned(value: boolean) {
|
||||
|
||||
async function deleteVersion(comment: string) {
|
||||
try {
|
||||
await useInternalApi(`versions/version/${props.project.id}/${projectVersion.value?.id}/delete`, true, "post", {
|
||||
await useInternalApi(`versions/version/${props.project.id}/${projectVersion.value?.id}/delete`, "post", {
|
||||
content: comment,
|
||||
});
|
||||
notification.success(i18n.t("version.success.softDelete"));
|
||||
@ -128,7 +128,7 @@ async function deleteVersion(comment: string) {
|
||||
|
||||
async function hardDeleteVersion(comment: string) {
|
||||
try {
|
||||
await useInternalApi(`versions/version/${props.project.id}/${projectVersion.value?.id}/hardDelete`, true, "post", {
|
||||
await useInternalApi(`versions/version/${props.project.id}/${projectVersion.value?.id}/hardDelete`, "post", {
|
||||
content: comment,
|
||||
});
|
||||
notification.success(i18n.t("version.success.hardDelete"));
|
||||
@ -145,7 +145,7 @@ async function hardDeleteVersion(comment: string) {
|
||||
|
||||
async function restoreVersion() {
|
||||
try {
|
||||
await useInternalApi(`versions/version/${props.project.id}/${projectVersion.value?.id}/restore`, true, "post");
|
||||
await useInternalApi(`versions/version/${props.project.id}/${projectVersion.value?.id}/restore`, "post");
|
||||
notification.success(i18n.t("version.success.restore"));
|
||||
await router.replace(`/${route.params.user}/${route.params.project}/versions`);
|
||||
} catch (e) {
|
||||
|
@ -305,7 +305,7 @@ function sendReviewRequest(
|
||||
}
|
||||
): Promise<void> {
|
||||
const msg = `reviews.presets.${urlPath}`;
|
||||
return useInternalApi(`reviews/${projectVersion.value.id}/reviews/${urlPath}`, true, "post", { message: msg, args })
|
||||
return useInternalApi(`reviews/${projectVersion.value.id}/reviews/${urlPath}`, "post", { message: msg, args })
|
||||
.then(() => {
|
||||
if (currentUserReview.value) {
|
||||
currentUserReview.value.messages.push({
|
||||
|
@ -72,7 +72,6 @@ watch(
|
||||
}
|
||||
const newVersions = await useApi<PaginatedResult<Version>>(
|
||||
`projects/${route.params.user}/${route.params.project}/versions`,
|
||||
false,
|
||||
"get",
|
||||
requestOptions.value
|
||||
).catch((e) => handleRequestError(e, i18n));
|
||||
|
@ -213,7 +213,7 @@ async function createPendingVersion() {
|
||||
})
|
||||
);
|
||||
|
||||
pendingVersion.value = await useInternalApi<PendingVersion>(`versions/version/${props.project.id}/upload`, true, "post", formData).catch<any>((e) =>
|
||||
pendingVersion.value = await useInternalApi<PendingVersion>(`versions/version/${props.project.id}/upload`, "post", formData).catch<any>((e) =>
|
||||
handleRequestError(e, i18n)
|
||||
);
|
||||
loading.create = false;
|
||||
@ -257,7 +257,7 @@ async function createVersion() {
|
||||
}
|
||||
|
||||
try {
|
||||
await useInternalApi(`versions/version/${props.project.id}/create`, true, "post", pendingVersion.value);
|
||||
await useInternalApi(`versions/version/${props.project.id}/create`, "post", pendingVersion.value);
|
||||
await router.push(`/${route.params.user}/${route.params.project}/versions`);
|
||||
} catch (e: any) {
|
||||
handleRequestError(e, i18n);
|
||||
|
@ -50,7 +50,7 @@ useHead(useSeo(i18n.t("apiKeys.title") + " | " + props.user.name, null, route, a
|
||||
async function create() {
|
||||
if (!(await v.value.$validate())) return;
|
||||
loadingCreate.value = true;
|
||||
const key = await useInternalApi<string>(`api-keys/create-key/${route.params.user}`, true, "post", {
|
||||
const key = await useInternalApi<string>(`api-keys/create-key/${route.params.user}`, "post", {
|
||||
name: name.value,
|
||||
permissions: selectedPerms.value,
|
||||
}).catch((err) => handleRequestError(err, i18n));
|
||||
@ -71,7 +71,7 @@ async function create() {
|
||||
|
||||
async function deleteKey(key: ApiKey) {
|
||||
loadingDelete[key.name] = true;
|
||||
await useInternalApi(`api-keys/delete-key/${route.params.user}`, true, "post", {
|
||||
await useInternalApi(`api-keys/delete-key/${route.params.user}`, "post", {
|
||||
content: key.name,
|
||||
}).catch((err) => handleRequestError(err, i18n));
|
||||
apiKeys.value = apiKeys.value.filter((k) => k.name !== key.name);
|
||||
|
@ -41,7 +41,7 @@ const oneMonthBefore = new Date(now.getFullYear(), now.getMonth() - 1, now.getDa
|
||||
const startDate = ref<string>(toISODateString(oneMonthBefore));
|
||||
const endDate = ref<string>(toISODateString(now));
|
||||
|
||||
let data: DayStats[] = (await useInternalApi<DayStats[]>("admin/stats", true, "get", {
|
||||
let data: DayStats[] = (await useInternalApi<DayStats[]>("admin/stats", "get", {
|
||||
from: startDate.value,
|
||||
to: endDate.value,
|
||||
}).catch((e) => handleRequestError(e, i18n))) as DayStats[];
|
||||
@ -119,7 +119,7 @@ watch(endDate, updateDate);
|
||||
|
||||
async function updateDate() {
|
||||
console.log("update", startDate, endDate);
|
||||
data = (await useInternalApi<DayStats[]>("admin/stats", true, "get", {
|
||||
data = (await useInternalApi<DayStats[]>("admin/stats", "get", {
|
||||
from: startDate.value,
|
||||
to: endDate.value,
|
||||
}).catch((e) => handleRequestError(e, i18n))) as DayStats[];
|
||||
|
@ -31,10 +31,10 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
const backendData = useBackendDataStore();
|
||||
|
||||
const projects = await useApi<PaginatedResult<Project>>("projects", false, "get", {
|
||||
const projects = await useApi<PaginatedResult<Project>>("projects", "get", {
|
||||
owner: route.params.user,
|
||||
}).catch((e) => handleRequestError(e, i18n));
|
||||
const orgs = await useInternalApi<{ [key: string]: OrganizationRoleTable }>(`organizations/${route.params.user}/userOrganizations`, false).catch((e) =>
|
||||
const orgs = await useInternalApi<{ [key: string]: OrganizationRoleTable }>(`organizations/${route.params.user}/userOrganizations`).catch((e) =>
|
||||
handleRequestError(e, i18n)
|
||||
);
|
||||
const user = await useUser(route.params.user as string).catch((e) => handleRequestError(e, i18n));
|
||||
@ -67,7 +67,7 @@ const _authUrl = computed(() => authUrl(route.params.user as string));
|
||||
const selectedRole = ref();
|
||||
async function processRole(add: boolean) {
|
||||
try {
|
||||
await useInternalApi("/admin/user/" + route.params.user + "/" + selectedRole.value, true, add ? "POST" : "DELETE");
|
||||
await useInternalApi("/admin/user/" + route.params.user + "/" + selectedRole.value, add ? "POST" : "DELETE");
|
||||
if (user) {
|
||||
user.value = await useApi<User>(("users/" + route.params.user) as string);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ async function save() {
|
||||
data[pl.enumName] = pl.possibleVersions;
|
||||
}
|
||||
try {
|
||||
await useInternalApi("admin/platformVersions", true, "post", data);
|
||||
await useInternalApi("admin/platformVersions", "post", data);
|
||||
notification.success(i18n.t("platformVersions.success"));
|
||||
router.go(0);
|
||||
} catch (e: any) {
|
||||
|
@ -53,7 +53,7 @@ async function updatePage(newPage: number) {
|
||||
}
|
||||
|
||||
async function update() {
|
||||
authors.value = await useApi<PaginatedResult<User>>("authors", false, "GET", requestParams.value);
|
||||
authors.value = await useApi<PaginatedResult<User>>("authors", "GET", requestParams.value);
|
||||
}
|
||||
|
||||
useHead(useSeo(i18n.t("pages.authorsTitle"), "Hangar Project Authors", route, null));
|
||||
|
@ -92,7 +92,7 @@ watch(
|
||||
);
|
||||
|
||||
async function updateProjects() {
|
||||
projects.value = await useApi<PaginatedResult<Project>>("projects", false, "get", requestParams.value);
|
||||
projects.value = await useApi<PaginatedResult<Project>>("projects", "get", requestParams.value);
|
||||
await checkOffsetLargerCount();
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ useHead(useSeo("New Project", null, route, null));
|
||||
|
||||
function convertBBCode() {
|
||||
converter.value.loading = true;
|
||||
useInternalApi<string>("pages/convert-bbcode", false, "post", {
|
||||
useInternalApi<string>("pages/convert-bbcode", "post", {
|
||||
content: converter.value.bbCode,
|
||||
})
|
||||
.then((markdown) => {
|
||||
@ -134,7 +134,7 @@ function createProject() {
|
||||
if (!form.value.pageContent) {
|
||||
form.value.pageContent = "# " + form.value.name + " \nWelcome to your new project!";
|
||||
}
|
||||
useInternalApi<string>("projects/create", true, "post", form.value)
|
||||
useInternalApi<string>("projects/create", "post", form.value)
|
||||
.then((u) => {
|
||||
router.push(u);
|
||||
})
|
||||
|
@ -37,7 +37,7 @@ useHead(useSeo(i18n.t("organization.new.title"), null, route, null));
|
||||
|
||||
async function create() {
|
||||
try {
|
||||
await useInternalApi("organizations/create", true, "post", {
|
||||
await useInternalApi("organizations/create", "post", {
|
||||
name: name.value,
|
||||
});
|
||||
await router.push("/" + name.value);
|
||||
|
@ -65,7 +65,7 @@ const filteredInvites = computed(() => {
|
||||
useHead(useSeo("Notifications", null, route, null));
|
||||
|
||||
async function markAllAsRead() {
|
||||
await useInternalApi(`markallread`, true, "post").catch((e) => handleRequestError(e, i18n));
|
||||
await useInternalApi(`markallread`, "post").catch((e) => handleRequestError(e, i18n));
|
||||
unreadNotifications.value.result = [];
|
||||
unreadNotifications.value.pagination.limit = 0;
|
||||
unreadNotifications.value.pagination.offset = 0;
|
||||
@ -73,7 +73,7 @@ async function markAllAsRead() {
|
||||
}
|
||||
|
||||
async function markNotificationRead(notification: HangarNotification, router = true) {
|
||||
await useInternalApi(`notifications/${notification.id}`, true, "post").catch((e) => handleRequestError(e, i18n));
|
||||
await useInternalApi(`notifications/${notification.id}`, "post").catch((e) => handleRequestError(e, i18n));
|
||||
notification.read = true;
|
||||
notifications.value.result = notifications.value.result.filter((n) => n !== notification);
|
||||
if (notification.action && router) {
|
||||
@ -82,7 +82,7 @@ async function markNotificationRead(notification: HangarNotification, router = t
|
||||
}
|
||||
|
||||
async function updateInvite(invite: Invite, status: "accept" | "decline") {
|
||||
await useInternalApi(`invites/${invite.type}/${invite.roleTableId}/${status}`, true, "post").catch((e) => handleRequestError(e, i18n));
|
||||
await useInternalApi(`invites/${invite.type}/${invite.roleTableId}/${status}`, "post").catch((e) => handleRequestError(e, i18n));
|
||||
if (status === "accept") {
|
||||
invite.accepted = true;
|
||||
} else {
|
||||
|
@ -55,7 +55,7 @@ async function updatePage(newPage: number) {
|
||||
}
|
||||
|
||||
async function update() {
|
||||
staff.value = await useApi<PaginatedResult<User>>("staff", false, "GET", requestParams.value);
|
||||
staff.value = await useApi<PaginatedResult<User>>("staff", "GET", requestParams.value);
|
||||
}
|
||||
|
||||
useHead(useSeo(i18n.t("pages.staffTitle"), null, route, null));
|
||||
|
@ -22,7 +22,7 @@ useHead(useSeo("BBCode Converter", null, route, null));
|
||||
|
||||
async function convertBBCode() {
|
||||
loading.value = true;
|
||||
output.value = await useInternalApi<string>("pages/convert-bbcode", false, "post", {
|
||||
output.value = await useInternalApi<string>("pages/convert-bbcode", "post", {
|
||||
content: input.value,
|
||||
}).catch<any>((e) => handleRequestError(e, i18n));
|
||||
loading.value = false;
|
||||
|
@ -64,7 +64,7 @@ export const useBackendDataStore = defineStore("backendData", () => {
|
||||
// todo consider caching these in node server/globally, these are all always needed
|
||||
await Promise.all([
|
||||
fetchIfNeeded(async () => {
|
||||
const categoryResult = await useInternalApi<IProjectCategory[]>("data/categories", false);
|
||||
const categoryResult = await useInternalApi<IProjectCategory[]>("data/categories");
|
||||
for (const c of categoryResult) {
|
||||
c.title = "project.category." + c.apiName;
|
||||
}
|
||||
@ -72,7 +72,7 @@ export const useBackendDataStore = defineStore("backendData", () => {
|
||||
}, projectCategories),
|
||||
|
||||
fetchIfNeeded(async () => {
|
||||
const permissionResultTemp = await useInternalApi<{ value: NamedPermission; frontendName: string; permission: string }[]>("data/permissions", false);
|
||||
const permissionResultTemp = await useInternalApi<{ value: NamedPermission; frontendName: string; permission: string }[]>("data/permissions");
|
||||
const permissionResult: IPermission[] = permissionResultTemp.map(({ value, frontendName, permission }) => ({
|
||||
value,
|
||||
frontendName,
|
||||
@ -82,25 +82,25 @@ export const useBackendDataStore = defineStore("backendData", () => {
|
||||
}, permissions),
|
||||
|
||||
fetchIfNeeded(async () => {
|
||||
const platformResult: IPlatform[] = await useInternalApi<IPlatform[]>("data/platforms", false);
|
||||
const platformResult: IPlatform[] = await useInternalApi<IPlatform[]>("data/platforms");
|
||||
return convertToMap<Platform, IPlatform>(platformResult, (value) => value.name.toUpperCase());
|
||||
}, platforms),
|
||||
|
||||
fetchIfNeeded(async () => {
|
||||
const promptsResult: IPrompt[] = await useInternalApi<IPrompt[]>("data/prompts", false);
|
||||
const promptsResult: IPrompt[] = await useInternalApi<IPrompt[]>("data/prompts");
|
||||
return convertToMap<Prompt, IPrompt>(promptsResult, (value) => value.name);
|
||||
}, prompts),
|
||||
|
||||
fetchIfNeeded(() => useInternalApi<string[]>("data/licenses", false), licenses),
|
||||
fetchIfNeeded(() => useInternalApi<AnnouncementObject[]>("data/announcements", false), announcements),
|
||||
fetchIfNeeded(() => useInternalApi<IVisibility[]>("data/visibilities", false), visibilities),
|
||||
fetchIfNeeded(() => useInternalApi<NonNullable<typeof validations.value>>("data/validations", false), validations),
|
||||
fetchIfNeeded(() => useInternalApi<NonNullable<typeof orgRoles.value>>("data/orgRoles", false), orgRoles),
|
||||
fetchIfNeeded(() => useInternalApi<NonNullable<typeof channelColors.value>>("data/channelColors", false), channelColors),
|
||||
fetchIfNeeded(() => useInternalApi<NonNullable<typeof projectRoles.value>>("data/projectRoles", false), projectRoles),
|
||||
fetchIfNeeded(() => useInternalApi<NonNullable<typeof globalRoles.value>>("data/globalRoles", false), globalRoles),
|
||||
fetchIfNeeded(() => useInternalApi<NonNullable<typeof flagReasons.value>>("data/flagReasons", false), flagReasons),
|
||||
fetchIfNeeded(() => useInternalApi<NonNullable<typeof versionInfo.value>>("data/version-info", false), versionInfo),
|
||||
fetchIfNeeded(() => useInternalApi<string[]>("data/licenses"), licenses),
|
||||
fetchIfNeeded(() => useInternalApi<AnnouncementObject[]>("data/announcements"), announcements),
|
||||
fetchIfNeeded(() => useInternalApi<IVisibility[]>("data/visibilities"), visibilities),
|
||||
fetchIfNeeded(() => useInternalApi<NonNullable<typeof validations.value>>("data/validations"), validations),
|
||||
fetchIfNeeded(() => useInternalApi<NonNullable<typeof orgRoles.value>>("data/orgRoles"), orgRoles),
|
||||
fetchIfNeeded(() => useInternalApi<NonNullable<typeof channelColors.value>>("data/channelColors"), channelColors),
|
||||
fetchIfNeeded(() => useInternalApi<NonNullable<typeof projectRoles.value>>("data/projectRoles"), projectRoles),
|
||||
fetchIfNeeded(() => useInternalApi<NonNullable<typeof globalRoles.value>>("data/globalRoles"), globalRoles),
|
||||
fetchIfNeeded(() => useInternalApi<NonNullable<typeof flagReasons.value>>("data/flagReasons"), flagReasons),
|
||||
fetchIfNeeded(() => useInternalApi<NonNullable<typeof versionInfo.value>>("data/version-info"), versionInfo),
|
||||
]);
|
||||
} catch (e) {
|
||||
console.error("ERROR FETCHING BACKEND DATA");
|
||||
|
@ -58,9 +58,7 @@ export const useSettingsStore = defineStore("settings", () => {
|
||||
language: locale.value,
|
||||
};
|
||||
try {
|
||||
await (store.user?.id
|
||||
? useInternalApi("users/" + store.user?.name + "/settings/", true, "post", data)
|
||||
: useInternalApi("users/anon/settings/", false, "post", data));
|
||||
await useInternalApi("users/" + (store.user?.name || "anon") + "/settings/", "post", data);
|
||||
} catch (e) {
|
||||
settingsLog("cant save settings", e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user