Compare commits
3 Commits
90b68b717a
...
22ff290a81
Author | SHA1 | Date | |
---|---|---|---|
22ff290a81 | |||
f9c6f4b827 | |||
eb7ad5d1a3 |
56
MALFunctions.go
Normal file
56
MALFunctions.go
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func MALHelper(method string, malUrl string, body url.Values) json.RawMessage {
|
||||||
|
client := &http.Client{}
|
||||||
|
|
||||||
|
req, _ := http.NewRequest(method, malUrl, strings.NewReader(body.Encode()))
|
||||||
|
|
||||||
|
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
req.Header.Add("Authorization", "Bearer "+myAnimeListJwt.AccessToken)
|
||||||
|
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Errored when sending request to the server")
|
||||||
|
message, _ := json.Marshal(struct {
|
||||||
|
Message string `json:"message" ts_type:"message"`
|
||||||
|
}{
|
||||||
|
Message: "Errored when sending request to the server" + err.Error(),
|
||||||
|
})
|
||||||
|
|
||||||
|
return message
|
||||||
|
}
|
||||||
|
|
||||||
|
defer resp.Body.Close()
|
||||||
|
respBody, _ := io.ReadAll(resp.Body)
|
||||||
|
|
||||||
|
return respBody
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) GetMyAnimeList(count int) MALWatchlist {
|
||||||
|
limit := strconv.Itoa(count)
|
||||||
|
user := a.GetMyAnimeListLoggedInUser()
|
||||||
|
malUrl := "https://api.myanimelist.net/v2/users/" + user.Name + "/animelist?fields=list_status&status=watching&limit=" + limit
|
||||||
|
|
||||||
|
var malList MALWatchlist
|
||||||
|
|
||||||
|
respBody := MALHelper("GET", malUrl, nil)
|
||||||
|
|
||||||
|
err := json.Unmarshal(respBody, &malList)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed to unmarshal json response, %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return malList
|
||||||
|
}
|
28
MALTypes.go
28
MALTypes.go
@ -1,5 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
type MyAnimeListJWT struct {
|
type MyAnimeListJWT struct {
|
||||||
TokenType string `json:"token_type"`
|
TokenType string `json:"token_type"`
|
||||||
ExpiresIn int `json:"expires_in"`
|
ExpiresIn int `json:"expires_in"`
|
||||||
@ -37,3 +39,29 @@ type AnimeStatistics struct {
|
|||||||
NumTimesRewatched int `json:"num_times_rewatched" ts_type:"numTimesRewatched"`
|
NumTimesRewatched int `json:"num_times_rewatched" ts_type:"numTimesRewatched"`
|
||||||
MeanScore float64 `json:"mean_score" ts_type:"meanScore"`
|
MeanScore float64 `json:"mean_score" ts_type:"meanScore"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MALWatchlist struct {
|
||||||
|
Data []struct {
|
||||||
|
Node struct {
|
||||||
|
Id int `json:"id" ts_type:"id"`
|
||||||
|
Title string `json:"title" ts_type:"title"`
|
||||||
|
MainPicture struct {
|
||||||
|
Medium string `json:"medium" json:"medium"`
|
||||||
|
Large string `json:"large" json:"large"`
|
||||||
|
} `json:"main_picture" json:"mainPicture"`
|
||||||
|
} `json:"node" json:"node"`
|
||||||
|
ListStatus struct {
|
||||||
|
Status string `json:"status" ts_type:"status"`
|
||||||
|
Score int `json:"score" ts_type:"score"`
|
||||||
|
NumEpisodesWatched int `json:"num_episodes_watched" ts_type:"numEpisodesWatched"`
|
||||||
|
IsRewatching bool `json:"is_rewatching" ts_type:"isRewatching"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at" ts_type:"updatedAt"`
|
||||||
|
StartDate string `json:"start_date" ts_type:"startDate"`
|
||||||
|
FinishDate string `json:"finish_date" ts_type:"finishDate"`
|
||||||
|
} `json:"list_status" ts_type:"listStatus"`
|
||||||
|
} `json:"data" json:"data"`
|
||||||
|
Paging struct {
|
||||||
|
Previous string `json:"previous" ts_type:"previous"`
|
||||||
|
Next string `json:"next" ts_type:"next"`
|
||||||
|
} `json:"paging" ts_type:"paging"`
|
||||||
|
}
|
||||||
|
@ -12,5 +12,7 @@ vars:secret [
|
|||||||
SIMKL_AUTH_TOKEN,
|
SIMKL_AUTH_TOKEN,
|
||||||
ANILIST_ACCESS_TOKEN,
|
ANILIST_ACCESS_TOKEN,
|
||||||
MAL_CODE,
|
MAL_CODE,
|
||||||
MAL_VERIFIER
|
MAL_VERIFIER,
|
||||||
|
MAL_USER,
|
||||||
|
MAL_ACCESS_TOKEN
|
||||||
]
|
]
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
title,
|
title,
|
||||||
watchListPage,
|
watchListPage,
|
||||||
animePerPage,
|
animePerPage,
|
||||||
|
malWatchList
|
||||||
} from "./GlobalVariablesAndHelperFunctions.svelte";
|
} from "./GlobalVariablesAndHelperFunctions.svelte";
|
||||||
import {
|
import {
|
||||||
CheckIfAniListLoggedIn,
|
CheckIfAniListLoggedIn,
|
||||||
@ -23,7 +24,7 @@
|
|||||||
GetAniListUserWatchingList,
|
GetAniListUserWatchingList,
|
||||||
GetSimklLoggedInUser,
|
GetSimklLoggedInUser,
|
||||||
SimklGetUserWatchlist,
|
SimklGetUserWatchlist,
|
||||||
GetMyAnimeListLoggedInUser,
|
GetMyAnimeListLoggedInUser, GetMyAnimeList,
|
||||||
} from "../wailsjs/go/main/App";
|
} from "../wailsjs/go/main/App";
|
||||||
import {MediaListSort} from "./anilist/types/AniListTypes";
|
import {MediaListSort} from "./anilist/types/AniListTypes";
|
||||||
import type {AniListCurrentUserWatchList} from "./anilist/types/AniListCurrentUserWatchListType"
|
import type {AniListCurrentUserWatchList} from "./anilist/types/AniListCurrentUserWatchListType"
|
||||||
@ -32,6 +33,7 @@
|
|||||||
import {default as Modal} from "./modal/Modal.svelte"
|
import {default as Modal} from "./modal/Modal.svelte"
|
||||||
import ChangeDataDialogue from "./ChangeDataDialogue.svelte";
|
import ChangeDataDialogue from "./ChangeDataDialogue.svelte";
|
||||||
import {onMount} from "svelte";
|
import {onMount} from "svelte";
|
||||||
|
import Pagination from "./Pagination.svelte";
|
||||||
|
|
||||||
|
|
||||||
let isAniListLoggedIn: boolean
|
let isAniListLoggedIn: boolean
|
||||||
@ -50,51 +52,46 @@
|
|||||||
const size = "xl"
|
const size = "xl"
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
await CheckIfAniListLoggedIn().then(result => {
|
await CheckIfAniListLoggedIn().then(loggedIn => {
|
||||||
if (result) {
|
if (loggedIn) {
|
||||||
GetAniListLoggedInUser().then(result => {
|
GetAniListLoggedInUser().then(user => {
|
||||||
aniListUser.set(result)
|
aniListUser.set(user)
|
||||||
if (isAniListPrimary) {
|
if (isAniListPrimary) {
|
||||||
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((watchList) => {
|
||||||
aniListWatchlist.set(result)
|
aniListWatchlist.set(watchList)
|
||||||
aniListLoggedIn.set(true)
|
aniListLoggedIn.set(loggedIn)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
aniListLoggedIn.set(result)
|
aniListLoggedIn.set(loggedIn)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await CheckIfMyAnimeListLoggedIn().then(result => {
|
await CheckIfMyAnimeListLoggedIn().then(loggedIn => {
|
||||||
if (result) {
|
if (loggedIn) {
|
||||||
GetMyAnimeListLoggedInUser().then(result => {
|
GetMyAnimeListLoggedInUser().then(user => {
|
||||||
malUser.set(result)
|
malUser.set(user)
|
||||||
malLoggedIn.set(result)
|
GetMyAnimeList(1000).then(watchList => {
|
||||||
|
malWatchList.set(watchList)
|
||||||
|
malLoggedIn.set(loggedIn)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await CheckIfSimklLoggedIn().then(result => {
|
await CheckIfSimklLoggedIn().then(loggedIn => {
|
||||||
if (result) {
|
if (loggedIn) {
|
||||||
GetSimklLoggedInUser().then(result => {
|
GetSimklLoggedInUser().then(user => {
|
||||||
simklUser.set(result)
|
simklUser.set(user)
|
||||||
SimklGetUserWatchlist().then(result => {
|
SimklGetUserWatchlist().then(result => {
|
||||||
simklWatchList.set(result)
|
simklWatchList.set(result)
|
||||||
simklLoggedIn.set(result)
|
simklLoggedIn.set(loggedIn)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
function ChangeWatchListPage(newPage: number) {
|
|
||||||
GetAniListUserWatchingList(newPage, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
|
||||||
watchListPage.set(newPage)
|
|
||||||
aniListWatchlist.set(result)
|
|
||||||
aniListLoggedIn.set(true)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Header/>
|
<Header/>
|
||||||
@ -104,50 +101,7 @@
|
|||||||
<div class="mx-auto max-w-2xl p-4 sm:p-6 lg:max-w-7xl lg:px-8">
|
<div class="mx-auto max-w-2xl p-4 sm:p-6 lg:max-w-7xl lg:px-8">
|
||||||
<h1 class="text-left text-xl font-bold mb-4">Your AniList WatchList</h1>
|
<h1 class="text-left text-xl font-bold mb-4">Your AniList WatchList</h1>
|
||||||
|
|
||||||
<div class="mb-8">
|
<Pagination />
|
||||||
<nav aria-label="Page navigation example">
|
|
||||||
<ul class="inline-flex -space-x-px text-base h-10">
|
|
||||||
{#if page === 1}
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<button disabled
|
|
||||||
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight text-gray-500 bg-white border border-e-0 border-gray-300 rounded-s-lg dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 cursor-default">Previous</button>
|
|
||||||
</li>
|
|
||||||
{:else}
|
|
||||||
<li>
|
|
||||||
<button on:click={() => ChangeWatchListPage(page-1)}
|
|
||||||
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight text-gray-500 bg-white border border-e-0 border-gray-300 rounded-s-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Previous</button>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
{#each {length: aniListWatchListLoaded.data.Page.pageInfo.lastPage} as _, i}
|
|
||||||
{#if i+1 === page}
|
|
||||||
<li>
|
|
||||||
<button on:click={() => ChangeWatchListPage(i+1)}
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight border border-gray-300 bg-gray-100 dark:border-gray-700 dark:bg-gray-700 dark:text-white">{i+1}</button>
|
|
||||||
</li>
|
|
||||||
{:else}
|
|
||||||
<li>
|
|
||||||
<button on:click={() => ChangeWatchListPage(i+1)}
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">{i+1}</button>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
{/each}
|
|
||||||
{#if page === aniListWatchListLoaded.data.Page.pageInfo.lastPage}
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<button disabled
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 rounded-e-lg dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 cursor-default">Next</button>
|
|
||||||
</li>
|
|
||||||
{:else}
|
|
||||||
<li>
|
|
||||||
<button on:click={() => ChangeWatchListPage(page+1)}
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 rounded-e-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Next</button>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<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">
|
<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 aniListWatchListLoaded.data.Page.mediaList as media}
|
{#each aniListWatchListLoaded.data.Page.mediaList as media}
|
||||||
@ -181,49 +135,7 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-8">
|
<Pagination />
|
||||||
<nav aria-label="Page navigation example">
|
|
||||||
<ul class="inline-flex -space-x-px text-base h-10">
|
|
||||||
{#if page === 1}
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<button disabled
|
|
||||||
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight text-gray-500 bg-white border border-e-0 border-gray-300 rounded-s-lg dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 cursor-default">Previous</button>
|
|
||||||
</li>
|
|
||||||
{:else}
|
|
||||||
<li>
|
|
||||||
<button on:click={() => ChangeWatchListPage(page-1)}
|
|
||||||
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight text-gray-500 bg-white border border-e-0 border-gray-300 rounded-s-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Previous</button>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
{#each {length: aniListWatchListLoaded.data.Page.pageInfo.lastPage} as _, i}
|
|
||||||
{#if i+1 === page}
|
|
||||||
<li>
|
|
||||||
<button on:click={() => ChangeWatchListPage(i+1)}
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight border border-gray-300 bg-gray-100 dark:border-gray-700 dark:bg-gray-700 dark:text-white">{i+1}</button>
|
|
||||||
</li>
|
|
||||||
{:else}
|
|
||||||
<li>
|
|
||||||
<button on:click={() => ChangeWatchListPage(i+1)}
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">{i+1}</button>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
{/each}
|
|
||||||
{#if page === aniListWatchListLoaded.data.Page.pageInfo.lastPage}
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<button disabled
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 rounded-e-lg dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 cursor-default">Next</button>
|
|
||||||
</li>
|
|
||||||
{:else}
|
|
||||||
<li>
|
|
||||||
<button on:click={() => ChangeWatchListPage(page+1)}
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 rounded-e-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Next</button>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
import {writable} from 'svelte/store'
|
import {writable} from 'svelte/store'
|
||||||
import type {SimklUser, SimklWatchList} from "./simkl/types/simklTypes";
|
import type {SimklUser, SimklWatchList} from "./simkl/types/simklTypes";
|
||||||
import {type AniListUser, MediaListSort} from "./anilist/types/AniListTypes";
|
import {type AniListUser, MediaListSort} from "./anilist/types/AniListTypes";
|
||||||
import type {MyAnimeListUser} from "./mal/types/MALTypes";
|
import type {MALWatchlist, MyAnimeListUser} from "./mal/types/MALTypes";
|
||||||
|
|
||||||
export let aniListAnime: AniListGetSingleAnime
|
export let aniListAnime: AniListGetSingleAnime
|
||||||
export let title = writable("")
|
export let title = writable("")
|
||||||
@ -25,6 +25,7 @@
|
|||||||
export let aniListUser = writable({} as AniListUser)
|
export let aniListUser = writable({} as AniListUser)
|
||||||
export let malUser = writable({} as MyAnimeListUser)
|
export let malUser = writable({} as MyAnimeListUser)
|
||||||
export let aniListWatchlist = writable({} as AniListCurrentUserWatchList)
|
export let aniListWatchlist = writable({} as AniListCurrentUserWatchList)
|
||||||
|
export let malWatchList = writable({} as MALWatchlist)
|
||||||
|
|
||||||
export let watchListPage = writable(1)
|
export let watchListPage = writable(1)
|
||||||
export let animePerPage = writable(20)
|
export let animePerPage = writable(20)
|
||||||
|
145
frontend/src/Pagination.svelte
Normal file
145
frontend/src/Pagination.svelte
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import {
|
||||||
|
aniListLoggedIn,
|
||||||
|
aniListWatchlist,
|
||||||
|
animePerPage,
|
||||||
|
watchListPage,
|
||||||
|
} from "./GlobalVariablesAndHelperFunctions.svelte";
|
||||||
|
|
||||||
|
import type {AniListCurrentUserWatchList} from "./anilist/types/AniListCurrentUserWatchListType"
|
||||||
|
import {GetAniListUserWatchingList} from "../wailsjs/go/main/App";
|
||||||
|
import {MediaListSort} from "./anilist/types/AniListTypes";
|
||||||
|
|
||||||
|
let aniListWatchListLoaded: AniListCurrentUserWatchList
|
||||||
|
let page: number
|
||||||
|
let perPage: number
|
||||||
|
|
||||||
|
watchListPage.subscribe(value => page = value)
|
||||||
|
animePerPage.subscribe(value => perPage = value)
|
||||||
|
aniListWatchlist.subscribe((value) => aniListWatchListLoaded = value)
|
||||||
|
|
||||||
|
const perPageOptions = [10, 20, 50]
|
||||||
|
|
||||||
|
function ChangeWatchListPage(newPage: number) {
|
||||||
|
GetAniListUserWatchingList(newPage, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
||||||
|
watchListPage.set(newPage)
|
||||||
|
aniListWatchlist.set(result)
|
||||||
|
aniListLoggedIn.set(true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function changePage(e): void {
|
||||||
|
if ((e.key === "Enter" || e.key === "Tab") && Number(e.target.value) !== page) ChangeWatchListPage(Number(e.target.value))
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeCountPerPage(e): void {
|
||||||
|
GetAniListUserWatchingList(1, Number(e.target.value), MediaListSort.UpdatedTimeDesc).then((result) => {
|
||||||
|
animePerPage.set(Number(e.target.value))
|
||||||
|
watchListPage.set(1)
|
||||||
|
aniListWatchlist.set(result)
|
||||||
|
aniListLoggedIn.set(true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="mb-8">
|
||||||
|
{#if aniListWatchListLoaded.data.Page.pageInfo.lastPage <= 12}
|
||||||
|
<nav aria-label="Page navigation" class="hidden md:block">
|
||||||
|
<ul class="inline-flex -space-x-px text-base h-10">
|
||||||
|
{#if page === 1}
|
||||||
|
<li>
|
||||||
|
<button disabled
|
||||||
|
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight text-gray-500 bg-white border border-e-0 border-gray-300 rounded-s-lg dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 cursor-default">
|
||||||
|
Previous
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{:else}
|
||||||
|
<li>
|
||||||
|
<button on:click={() => ChangeWatchListPage(page-1)}
|
||||||
|
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight text-gray-500 bg-white border border-e-0 border-gray-300 rounded-s-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">
|
||||||
|
Previous
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
|
{#each {length: aniListWatchListLoaded.data.Page.pageInfo.lastPage} as _, i}
|
||||||
|
{#if i + 1 === page}
|
||||||
|
<li>
|
||||||
|
<button on:click={() => ChangeWatchListPage(i+1)}
|
||||||
|
class="flex items-center justify-center px-4 h-10 leading-tight border border-gray-300 bg-gray-100 dark:border-gray-700 dark:bg-gray-700 dark:text-white">{i + 1}</button>
|
||||||
|
</li>
|
||||||
|
{:else}
|
||||||
|
<li>
|
||||||
|
<button on:click={() => ChangeWatchListPage(i+1)}
|
||||||
|
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">{i + 1}</button>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
{#if page === aniListWatchListLoaded.data.Page.pageInfo.lastPage}
|
||||||
|
<li>
|
||||||
|
<button disabled
|
||||||
|
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 rounded-e-lg dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 cursor-default">
|
||||||
|
Next
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{:else}
|
||||||
|
<li>
|
||||||
|
<button on:click={() => ChangeWatchListPage(page+1)}
|
||||||
|
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 rounded-e-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">
|
||||||
|
Next
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
{/if}
|
||||||
|
<div class="flex mt-5">
|
||||||
|
<div class="w-20 mx-auto">
|
||||||
|
<select bind:value={perPage} on:change={(e) => changeCountPerPage(e)} id="countPerPage"
|
||||||
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
|
||||||
|
{#each perPageOptions as option}
|
||||||
|
<option value={option}>
|
||||||
|
{option}
|
||||||
|
</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div>Total Anime: {aniListWatchListLoaded.data.Page.pageInfo.total}</div>
|
||||||
|
{#if aniListWatchListLoaded.data.Page.pageInfo.lastPage <= 12}
|
||||||
|
<div class="md:hidden">Page: {page} of {aniListWatchListLoaded.data.Page.pageInfo.lastPage}</div>
|
||||||
|
{:else}
|
||||||
|
<div>Page: {page} of {aniListWatchListLoaded.data.Page.pageInfo.lastPage}</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="max-w-xs mx-auto">
|
||||||
|
<div class="relative flex items-center max-w-[11rem]">
|
||||||
|
<button type="button" id="decrement-button" on:click={() => ChangeWatchListPage(page-1)}
|
||||||
|
class="bg-gray-100 dark:bg-gray-700 dark:hover:bg-gray-600 dark:border-gray-600 hover:bg-gray-200 border border-gray-300 rounded-s-lg p-3 h-11 focus:ring-gray-100 dark:focus:ring-gray-700 focus:ring-2 focus:outline-none">
|
||||||
|
<svg class="w-3 h-3 text-gray-900 dark:text-white" aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 2">
|
||||||
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||||
|
d="M1 1h16"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<input type="number" min="1" max="{aniListWatchListLoaded.data.Page.pageInfo.lastPage}"
|
||||||
|
on:keydown={changePage} id="page-counter"
|
||||||
|
class="[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none bg-gray-50 border-x-0 border-gray-300 h-11 font-medium text-center text-gray-900 text-sm focus:ring-blue-500 focus:border-blue-500 block w-full pb-6 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
|
value={page} required/>
|
||||||
|
<div class="absolute bottom-1 start-1/2 -translate-x-1/2 rtl:translate-x-1/2 flex items-center text-xs text-gray-400 space-x-1 rtl:space-x-reverse">
|
||||||
|
<span>Page #</span>
|
||||||
|
</div>
|
||||||
|
<button type="button" id="increment-button" on:click={() => ChangeWatchListPage(page+1)}
|
||||||
|
class="bg-gray-100 dark:bg-gray-700 dark:hover:bg-gray-600 dark:border-gray-600 hover:bg-gray-200 border border-gray-300 rounded-e-lg p-3 h-11 focus:ring-gray-100 dark:focus:ring-gray-700 focus:ring-2 focus:outline-none">
|
||||||
|
<svg class="w-3 h-3 text-gray-900 dark:text-white" aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 18">
|
||||||
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||||
|
d="M9 1v16M1 9h16"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -28,4 +28,38 @@ export interface AnimeStatistics {
|
|||||||
numEpisodes: number
|
numEpisodes: number
|
||||||
numTimesRewatched: number
|
numTimesRewatched: number
|
||||||
meanScore: number
|
meanScore: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MALWatchlist {
|
||||||
|
data: {
|
||||||
|
node: Node
|
||||||
|
listStatus: ListStatus
|
||||||
|
}[]
|
||||||
|
paging: Paging
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Node {
|
||||||
|
id: number
|
||||||
|
title: string
|
||||||
|
mainPicture: MainPicture
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MainPicture {
|
||||||
|
medium: string
|
||||||
|
large: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ListStatus {
|
||||||
|
status: string
|
||||||
|
score: number
|
||||||
|
numEpisodesWatched: number
|
||||||
|
isRewatching: boolean
|
||||||
|
updated_at: string
|
||||||
|
startDate: string
|
||||||
|
finishDate: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Paging {
|
||||||
|
previous: string
|
||||||
|
next: string
|
||||||
|
}
|
||||||
|
8
frontend/wailsjs/go/main/App.d.ts
vendored
8
frontend/wailsjs/go/main/App.d.ts
vendored
@ -20,10 +20,18 @@ export function GetAniListLoggedInUser():Promise<main.AniListUser>;
|
|||||||
|
|
||||||
export function GetAniListUserWatchingList(arg1:number,arg2:number,arg3:string):Promise<main.AniListCurrentUserWatchList>;
|
export function GetAniListUserWatchingList(arg1:number,arg2:number,arg3:string):Promise<main.AniListCurrentUserWatchList>;
|
||||||
|
|
||||||
|
export function GetMyAnimeList(arg1:number):Promise<main.MALWatchlist>;
|
||||||
|
|
||||||
export function GetMyAnimeListLoggedInUser():Promise<main.MyAnimeListUser>;
|
export function GetMyAnimeListLoggedInUser():Promise<main.MyAnimeListUser>;
|
||||||
|
|
||||||
export function GetSimklLoggedInUser():Promise<main.SimklUser>;
|
export function GetSimklLoggedInUser():Promise<main.SimklUser>;
|
||||||
|
|
||||||
|
export function LogoutAniList():Promise<string>;
|
||||||
|
|
||||||
|
export function LogoutMyAnimeList():Promise<string>;
|
||||||
|
|
||||||
|
export function LogoutSimkl():Promise<string>;
|
||||||
|
|
||||||
export function MyAnimeListLogin():Promise<void>;
|
export function MyAnimeListLogin():Promise<void>;
|
||||||
|
|
||||||
export function SimklGetUserWatchlist():Promise<main.SimklWatchList>;
|
export function SimklGetUserWatchlist():Promise<main.SimklWatchList>;
|
||||||
|
@ -38,6 +38,10 @@ export function GetAniListUserWatchingList(arg1, arg2, arg3) {
|
|||||||
return window['go']['main']['App']['GetAniListUserWatchingList'](arg1, arg2, arg3);
|
return window['go']['main']['App']['GetAniListUserWatchingList'](arg1, arg2, arg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function GetMyAnimeList(arg1) {
|
||||||
|
return window['go']['main']['App']['GetMyAnimeList'](arg1);
|
||||||
|
}
|
||||||
|
|
||||||
export function GetMyAnimeListLoggedInUser() {
|
export function GetMyAnimeListLoggedInUser() {
|
||||||
return window['go']['main']['App']['GetMyAnimeListLoggedInUser']();
|
return window['go']['main']['App']['GetMyAnimeListLoggedInUser']();
|
||||||
}
|
}
|
||||||
@ -46,6 +50,18 @@ export function GetSimklLoggedInUser() {
|
|||||||
return window['go']['main']['App']['GetSimklLoggedInUser']();
|
return window['go']['main']['App']['GetSimklLoggedInUser']();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function LogoutAniList() {
|
||||||
|
return window['go']['main']['App']['LogoutAniList']();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function LogoutMyAnimeList() {
|
||||||
|
return window['go']['main']['App']['LogoutMyAnimeList']();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function LogoutSimkl() {
|
||||||
|
return window['go']['main']['App']['LogoutSimkl']();
|
||||||
|
}
|
||||||
|
|
||||||
export function MyAnimeListLogin() {
|
export function MyAnimeListLogin() {
|
||||||
return window['go']['main']['App']['MyAnimeListLogin']();
|
return window['go']['main']['App']['MyAnimeListLogin']();
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,38 @@ export namespace main {
|
|||||||
this.anime_type = source["anime_type"];
|
this.anime_type = source["anime_type"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export class MALWatchlist {
|
||||||
|
data: struct { Node struct { Id int "json:\"id\" ts_type:\"id\""; Title string "json:\"title\" ts_type:\"title\""; MainPicture struct { Medium string "json:\"medium\" json:\"medium\""; Large string "json:\"large\" json:\"large\"" } "json:\"main_picture\" json:\"mainPicture\"" } "json:\"node\" json:\"node\""; ListStatus struct { Status string "json:\"status\" ts_type:\"status\""; Score int "json:\"score\" ts_type:\"score\""; NumEpisodesWatched int "json:\"num_episodes_watched\" ts_type:\"numEpisodesWatched\""; IsRewatching bool "json:\"is_rewatching\" ts_type:\"isRewatching\""; UpdatedAt time.Time "json:\"updated_at\" ts_type:\"updatedAt\""; StartDate string "json:\"start_date\" ts_type:\"startDate\""; FinishDate string "json:\"finish_date\" ts_type:\"finishDate\"" } "json:\"list_status\" ts_type:\"listStatus\"" }[];
|
||||||
|
paging: paging;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new MALWatchlist(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.data = this.convertValues(source["data"], struct { Node struct { Id int "json:\"id\" ts_type:\"id\""; Title string "json:\"title\" ts_type:\"title\""; MainPicture struct { Medium string "json:\"medium\" json:\"medium\""; Large string "json:\"large\" json:\"large\"" } "json:\"main_picture\" json:\"mainPicture\"" } "json:\"node\" json:\"node\""; ListStatus struct { Status string "json:\"status\" ts_type:\"status\""; Score int "json:\"score\" ts_type:\"score\""; NumEpisodesWatched int "json:\"num_episodes_watched\" ts_type:\"numEpisodesWatched\""; IsRewatching bool "json:\"is_rewatching\" ts_type:\"isRewatching\""; UpdatedAt time.Time "json:\"updated_at\" ts_type:\"updatedAt\""; StartDate string "json:\"start_date\" ts_type:\"startDate\""; FinishDate string "json:\"finish_date\" ts_type:\"finishDate\"" } "json:\"list_status\" ts_type:\"listStatus\"" });
|
||||||
|
this.paging = source["paging"];
|
||||||
|
}
|
||||||
|
|
||||||
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||||
|
if (!a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
if (a.slice && a.map) {
|
||||||
|
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||||
|
} else if ("object" === typeof a) {
|
||||||
|
if (asMap) {
|
||||||
|
for (const key of Object.keys(a)) {
|
||||||
|
a[key] = new classs(a[key]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
return new classs(a);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
export class MediaList {
|
export class MediaList {
|
||||||
id: number;
|
id: number;
|
||||||
mediaId: number;
|
mediaId: number;
|
||||||
@ -301,3 +333,70 @@ export namespace struct { MediaList main {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export namespace struct { Node struct { Id int "json:\"id\" ts_type:\"id\""; Title string "json:\"title\" ts_type:\"title\""; MainPicture struct { Medium string "json:\"medium\" json:\"medium\""; Large string "json:\"large\" json:\"large\"" } "json:\"main_picture\" json:\"mainPicture\"" } "json:\"node\" json:\"node\""; ListStatus struct { Status string "json:\"status\" ts_type:\"status\""; Score int "json:\"score\" ts_type:\"score\""; NumEpisodesWatched int "json:\"num_episodes_watched\" ts_type:\"numEpisodesWatched\""; IsRewatching bool "json:\"is_rewatching\" ts_type:\"isRewatching\""; UpdatedAt time {
|
||||||
|
|
||||||
|
export class {
|
||||||
|
// Go type: struct { Id int "json:\"id\" ts_type:\"id\""; Title string "json:\"title\" ts_type:\"title\""; MainPicture struct { Medium string "json:\"medium\" json:\"medium\""; Large string "json:\"large\" json:\"large\"" } "json:\"main_picture\" json:\"mainPicture\"" }
|
||||||
|
node: any;
|
||||||
|
list_status: listStatus;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new (source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.node = this.convertValues(source["node"], Object);
|
||||||
|
this.list_status = source["list_status"];
|
||||||
|
}
|
||||||
|
|
||||||
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||||
|
if (!a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
if (a.slice && a.map) {
|
||||||
|
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||||
|
} else if ("object" === typeof a) {
|
||||||
|
if (asMap) {
|
||||||
|
for (const key of Object.keys(a)) {
|
||||||
|
a[key] = new classs(a[key]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
return new classs(a);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace struct { Status string "json:\"status\" ts_type:\"status\""; Score int "json:\"score\" ts_type:\"score\""; NumEpisodesWatched int "json:\"num_episodes_watched\" ts_type:\"numEpisodesWatched\""; IsRewatching bool "json:\"is_rewatching\" ts_type:\"isRewatching\""; UpdatedAt time {
|
||||||
|
|
||||||
|
export class {
|
||||||
|
status: status;
|
||||||
|
score: score;
|
||||||
|
num_episodes_watched: numEpisodesWatched;
|
||||||
|
is_rewatching: isRewatching;
|
||||||
|
updated_at: updatedAt;
|
||||||
|
start_date: startDate;
|
||||||
|
finish_date: finishDate;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new (source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.status = source["status"];
|
||||||
|
this.score = source["score"];
|
||||||
|
this.num_episodes_watched = source["num_episodes_watched"];
|
||||||
|
this.is_rewatching = source["is_rewatching"];
|
||||||
|
this.updated_at = source["updated_at"];
|
||||||
|
this.start_date = source["start_date"];
|
||||||
|
this.finish_date = source["finish_date"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user