Added anime list deletion
This commit is contained in:
parent
1d6cdd3c9f
commit
ede2c5dc75
36
pages/animelist/delete.go
Normal file
36
pages/animelist/delete.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package animelist
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/components"
|
||||||
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeleteConfirmation shows the confirmation page before deleting an anime list.
|
||||||
|
func DeleteConfirmation(ctx aero.Context) error {
|
||||||
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
|
if user == nil {
|
||||||
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.HTML(components.DeleteAnimeList(user))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete deletes your entire anime list.
|
||||||
|
func Delete(ctx aero.Context) error {
|
||||||
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
|
if user == nil {
|
||||||
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
|
}
|
||||||
|
|
||||||
|
animeList := user.AnimeList()
|
||||||
|
animeList.Lock()
|
||||||
|
animeList.Items = nil
|
||||||
|
animeList.Unlock()
|
||||||
|
|
||||||
|
return ctx.String("ok")
|
||||||
|
}
|
9
pages/animelist/delete.pixy
Normal file
9
pages/animelist/delete.pixy
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
component DeleteAnimeList(user *arn.User)
|
||||||
|
h1.mountable Delete your anime list
|
||||||
|
|
||||||
|
p.text-center.mountable This will delete your entire anime list. Are you sure you want to proceed?
|
||||||
|
|
||||||
|
.buttons
|
||||||
|
button.action.mountable(data-action="deleteAnimeList", data-trigger="click", data-return-path="/+" + user.Nick + "/animelist/watching")
|
||||||
|
Icon("trash")
|
||||||
|
span Yes, delete my anime list.
|
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/pages/animeimport"
|
"github.com/animenotifier/notify.moe/pages/animeimport"
|
||||||
|
"github.com/animenotifier/notify.moe/pages/animelist"
|
||||||
"github.com/animenotifier/notify.moe/pages/apiview"
|
"github.com/animenotifier/notify.moe/pages/apiview"
|
||||||
"github.com/animenotifier/notify.moe/pages/apiview/apidocs"
|
"github.com/animenotifier/notify.moe/pages/apiview/apidocs"
|
||||||
"github.com/animenotifier/notify.moe/pages/character"
|
"github.com/animenotifier/notify.moe/pages/character"
|
||||||
@ -57,6 +58,9 @@ func Register(app *aero.Application) {
|
|||||||
// SoundTrack
|
// SoundTrack
|
||||||
app.Post("/api/soundtrack/:id/download", soundtrack.Download)
|
app.Post("/api/soundtrack/:id/download", soundtrack.Download)
|
||||||
|
|
||||||
|
// AnimeList
|
||||||
|
app.Post("/api/delete/animelist", animelist.Delete)
|
||||||
|
|
||||||
// Upload
|
// Upload
|
||||||
app.Post("/api/upload/user/image", upload.UserImage)
|
app.Post("/api/upload/user/image", upload.UserImage)
|
||||||
app.Post("/api/upload/user/cover", upload.UserCover)
|
app.Post("/api/upload/user/cover", upload.UserCover)
|
||||||
|
@ -49,6 +49,9 @@ func Register(app *aero.Application) {
|
|||||||
page.Get(app, "/animelist/hold", animelist.Redirect)
|
page.Get(app, "/animelist/hold", animelist.Redirect)
|
||||||
page.Get(app, "/animelist/dropped", animelist.Redirect)
|
page.Get(app, "/animelist/dropped", animelist.Redirect)
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
page.Get(app, "/animelist/delete", animelist.DeleteConfirmation)
|
||||||
|
|
||||||
// Compare
|
// Compare
|
||||||
page.Get(app, "/compare/animelist/:nick-1/:nick-2", compare.AnimeList)
|
page.Get(app, "/compare/animelist/:nick-1/:nick-2", compare.AnimeList)
|
||||||
|
|
||||||
|
@ -36,6 +36,12 @@ component SettingsStyle(user *arn.User)
|
|||||||
option(value="airing date") Airing date ⮞ Rating ⮞ Title
|
option(value="airing date") Airing date ⮞ Rating ⮞ Title
|
||||||
option(value="rating") Rating ⮞ Title
|
option(value="rating") Rating ⮞ Title
|
||||||
option(value="title") Title
|
option(value="title") Title
|
||||||
|
|
||||||
|
.widget-section
|
||||||
|
label Delete:
|
||||||
|
a.button(href="/animelist/delete")
|
||||||
|
Icon("trash")
|
||||||
|
span Delete my anime list
|
||||||
|
|
||||||
if arn.IsDevelopment()
|
if arn.IsDevelopment()
|
||||||
.widget.mountable(data-api="/api/settings/" + user.ID)
|
.widget.mountable(data-api="/api/settings/" + user.ID)
|
||||||
|
@ -33,7 +33,6 @@ export async function removeAnimeFromCollection(arn: AnimeNotifier, button: HTML
|
|||||||
}
|
}
|
||||||
|
|
||||||
button.textContent = "Removing..."
|
button.textContent = "Removing..."
|
||||||
|
|
||||||
let {animeId, nick} = button.dataset
|
let {animeId, nick} = button.dataset
|
||||||
|
|
||||||
if(!animeId || !nick) {
|
if(!animeId || !nick) {
|
||||||
@ -50,4 +49,27 @@ export async function removeAnimeFromCollection(arn: AnimeNotifier, button: HTML
|
|||||||
} catch(err) {
|
} catch(err) {
|
||||||
arn.statusMessage.showError(err)
|
arn.statusMessage.showError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete anime list
|
||||||
|
export async function deleteAnimeList(arn: AnimeNotifier, button: HTMLElement) {
|
||||||
|
if(!confirm("Last confirmation: Are you sure you want to delete your entire anime list?")) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
button.textContent = "Deleting..."
|
||||||
|
let {returnPath} = button.dataset
|
||||||
|
|
||||||
|
if(!returnPath) {
|
||||||
|
console.error("Button without data-return-path:", button)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await arn.post("/api/delete/animelist")
|
||||||
|
await arn.app.load(returnPath)
|
||||||
|
arn.statusMessage.showInfo("Your anime list has been deleted.")
|
||||||
|
} catch(err) {
|
||||||
|
arn.statusMessage.showError(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user