memorium/islands/KMenu/commands.ts

53 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-07-31 04:19:04 +02:00
import { Menu } from "@islands/KMenu/types.ts";
2023-08-04 13:48:12 +02:00
import { addMovieInfos } from "@islands/KMenu/commands/add_movie_infos.ts";
import { createNewMovie } from "@islands/KMenu/commands/create_movie.ts";
import { createNewArticle } from "@islands/KMenu/commands/create_article.ts";
2023-08-04 22:35:25 +02:00
import { getCookie } from "@lib/string.ts";
2023-07-31 04:19:04 +02:00
export const menus: Record<string, Menu> = {
main: {
title: "Run",
entries: [
2023-08-01 18:35:35 +02:00
{
title: "Clear Cache",
2023-08-02 13:11:17 +02:00
icon: "IconRefresh",
2023-08-01 18:35:35 +02:00
cb: async (state) => {
state.activeState.value = "loading";
await fetch("/api/cache", {
method: "DELETE",
});
state.activeState.value = "normal";
state.visible.value = false;
},
2023-08-04 22:35:25 +02:00
visible: () => {
if (!getCookie("session_cookie")) return false;
return true;
},
},
{
title: "Login",
icon: "IconLogin",
cb: () => {
window.location.pathname = "/api/auth/login";
},
visible: () => {
return !getCookie("session_cookie");
},
},
{
title: "Logout",
icon: "IconLogout",
cb: () => {
window.location.pathname = "/api/auth/logout";
},
visible: () => {
return !!getCookie("session_cookie");
},
2023-08-01 18:35:35 +02:00
},
2023-08-04 13:48:12 +02:00
createNewArticle,
createNewMovie,
addMovieInfos,
2023-07-31 04:19:04 +02:00
],
},
};