2024-07-09 10:16:53 -04:00
|
|
|
<script lang="ts">
|
2024-07-24 09:17:39 -04:00
|
|
|
import {
|
|
|
|
AniListSearch,
|
|
|
|
GetAniListUserWatchingList
|
|
|
|
} from "../wailsjs/go/main/App";
|
2024-07-25 09:18:08 -04:00
|
|
|
import {type AniSearchList, MediaListSort} from "./anilist/types/AniListTypes";
|
2024-07-24 09:17:39 -04:00
|
|
|
import type {AniListCurrentUserWatchList} from "./anilist/types/AniListCurrentUserWatchListType"
|
2024-07-25 09:18:08 -04:00
|
|
|
import Header from "./Header.svelte";
|
|
|
|
import {Button, Modal} from "flowbite-svelte";
|
|
|
|
import type {AniListGetSingleAnime} from "./anilist/types/AniListCurrentUserWatchListType.js";
|
|
|
|
import {GetAniListItem} from "../wailsjs/go/main/App";
|
|
|
|
import ChangeDataDialogue from "./ChangeDataDialogue.svelte";
|
2024-07-24 09:17:39 -04:00
|
|
|
|
|
|
|
let aniSearch = ""
|
|
|
|
let aniListSearch: AniSearchList
|
2024-07-25 09:18:08 -04:00
|
|
|
let aniListSearchActive = false
|
2024-07-24 09:17:39 -04:00
|
|
|
let aniListLoggedIn = false
|
|
|
|
let aniListWatchlist: AniListCurrentUserWatchList
|
|
|
|
let page = 1
|
|
|
|
let perPage = 20
|
2024-07-25 09:18:08 -04:00
|
|
|
let anilistModal = false;
|
|
|
|
let anime: AniListGetSingleAnime
|
|
|
|
let title: string
|
2024-07-24 09:17:39 -04:00
|
|
|
|
|
|
|
function runAniListSearch(): void {
|
2024-07-25 09:18:08 -04:00
|
|
|
AniListSearch(aniSearch).then(result => {
|
|
|
|
aniListSearch = result
|
|
|
|
aniListSearchActive = true
|
|
|
|
})
|
2024-07-24 09:17:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function anilistGetUserWatchlist(): void {
|
|
|
|
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
|
|
|
aniListWatchlist = result
|
|
|
|
aniListLoggedIn = true
|
|
|
|
})
|
|
|
|
}
|
2024-07-25 09:18:08 -04:00
|
|
|
|
2024-07-25 16:29:28 -04:00
|
|
|
export function GetAniListSingleItemAndOpenModal(aniId: number): void {
|
2024-07-25 09:18:08 -04:00
|
|
|
GetAniListItem(aniId).then(result => {
|
|
|
|
anime = result
|
|
|
|
title = anime.data.MediaList.media.title.english === "" ?
|
|
|
|
anime.data.MediaList.media.title.romaji :
|
|
|
|
anime.data.MediaList.media.title.english
|
|
|
|
anilistModal = true
|
|
|
|
})
|
|
|
|
}
|
2024-07-09 10:16:53 -04:00
|
|
|
</script>
|
|
|
|
|
2024-07-25 09:18:08 -04:00
|
|
|
<Header />
|
|
|
|
|
2024-07-09 10:16:53 -04:00
|
|
|
<main>
|
2024-07-24 09:17:39 -04:00
|
|
|
<div class="input-box" id="aniSearch">
|
2024-07-25 09:18:08 -04:00
|
|
|
<input autocomplete="off" bind:value={aniSearch} class="input text-black" id="aniSearchInput" type="text"/>
|
|
|
|
<button class="text-gray-800 dark:text-white hover:bg-gray-50 focus:ring-4 focus:ring-gray-300 font-medium rounded-lg text-sm px-4 lg:px-5 py-2 lg:py-2.5 mr-2 dark:hover:bg-gray-700 focus:outline-none dark:focus:ring-gray-800" on:click={runAniListSearch}>Search AniList</button>
|
2024-07-24 09:17:39 -04:00
|
|
|
</div>
|
|
|
|
|
2024-07-25 09:18:08 -04:00
|
|
|
{#if aniListSearchActive}
|
|
|
|
<div class="mx-auto max-w-2xl px-4 py-16 sm:px-6 sm:py-24 lg:max-w-7xl lg:px-8">
|
|
|
|
<h1>Your Search Results</h1>
|
|
|
|
|
|
|
|
<div class="grid grid-cols-1 gap-x-6 gap-y-10 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 xl:gap-x-8">
|
|
|
|
{#each aniListSearch.data.Page.media as media}
|
|
|
|
<button on:click={() => GetAniListSingleItemAndOpenModal(media.id)} class="group">
|
|
|
|
<!-- <div class="aspect-h-1 aspect-w-1 w-full overflow-hidden rounded-lg bg-gray-200 xl:aspect-h-8 xl:aspect-w-7">-->
|
|
|
|
<div class="justify-center rounded-lg bg-gray-200">
|
|
|
|
<img src={media.coverImage.large} alt="anime cover"/>
|
|
|
|
</div>
|
|
|
|
<h3 class="mt-4 text-sm text-white-700">{
|
|
|
|
media.title.english === "" ?
|
|
|
|
media.title.romaji :
|
|
|
|
media.title.english
|
|
|
|
}</h3>
|
|
|
|
</button>
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
|
2024-07-24 09:17:39 -04:00
|
|
|
<button class="btn" on:click={anilistGetUserWatchlist}>Login to AniList</button>
|
|
|
|
{#if aniListLoggedIn}
|
|
|
|
<div>You are logged in {aniListWatchlist.data.Page.mediaList[0].user.name}!</div>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if aniListLoggedIn}
|
|
|
|
<div class="mx-auto max-w-2xl px-4 py-16 sm:px-6 sm:py-24 lg:max-w-7xl lg:px-8">
|
|
|
|
<h1>Your Watching List</h1>
|
|
|
|
|
|
|
|
<div class="grid grid-cols-1 gap-x-6 gap-y-10 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 xl:gap-x-8">
|
|
|
|
{#each aniListWatchlist.data.Page.mediaList as media}
|
2024-07-25 09:18:08 -04:00
|
|
|
<button on:click={() => GetAniListSingleItemAndOpenModal(media.media.id)} class="group">
|
2024-07-24 09:17:39 -04:00
|
|
|
<!-- <div class="aspect-h-1 aspect-w-1 w-full overflow-hidden rounded-lg bg-gray-200 xl:aspect-h-8 xl:aspect-w-7">-->
|
|
|
|
<div class="justify-center rounded-lg bg-gray-200">
|
|
|
|
<img src={media.media.coverImage.large} alt="anime cover"/>
|
|
|
|
</div>
|
|
|
|
<h3 class="mt-4 text-sm text-white-700">{
|
|
|
|
media.media.title.english === "" ?
|
|
|
|
media.media.title.romaji :
|
|
|
|
media.media.title.english
|
|
|
|
}</h3>
|
|
|
|
<p class="mt-1 text-lg font-medium text-white-900">{media.progress}
|
|
|
|
/ {media.media.nextAiringEpisode.episode !== 0 ?
|
|
|
|
media.media.nextAiringEpisode.episode - 1 : media.media.episodes}</p>
|
|
|
|
{#if media.media.episodes > 0}
|
|
|
|
<p class="mt-1 text-lg font-medium text-white-900">Total
|
|
|
|
Episodes: {media.media.episodes}</p>
|
|
|
|
{/if}
|
2024-07-25 09:18:08 -04:00
|
|
|
</button>
|
2024-07-24 09:17:39 -04:00
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/if}
|
2024-07-25 09:18:08 -04:00
|
|
|
<Modal title={title} bind:open={anilistModal} autoclose>
|
|
|
|
<ChangeDataDialogue anime={anime} />
|
|
|
|
</Modal>
|
2024-07-09 10:16:53 -04:00
|
|
|
</main>
|