6 Commits
v0.3.0 ... dev

Author SHA1 Message Date
8de238028e feat: search pages 2024-07-22 19:23:25 +03:00
3522df4066 feat: start search pages 2024-07-22 16:53:34 +03:00
d5803c4a94 fix: remove unnecessary code 2024-07-22 15:39:17 +03:00
ca7294c3f7 new version: 0.3.1 2024-07-22 15:06:06 +03:00
d109ba8974 feat: nice update indicator in header 2024-07-22 15:04:29 +03:00
8f6193b846 feat: dmca page 2024-07-22 14:42:09 +03:00
17 changed files with 211 additions and 83 deletions

View File

@@ -1,19 +1,12 @@
@if (serviceWorkerEnabled) {
@if (hasUpdate) {
<h1>Update available</h1>
<button (click)="update()">Update</button>
} @else {
<h1>Update not available</h1>
}
}
<app-header></app-header>
<div class="md:h-12 h-16"></div>
<div
class="content overflow-y-auto md:h-[calc(100vh-3rem)] h-[calc(100vh-4rem)] flex flex-col justify-between flex-shrink-0"
class="content overflow-y-auto md:h-[calc(100vh-3rem)] h-[calc(100vh-4rem)] flex flex-col justify-between"
>
<router-outlet></router-outlet>
<app-footer></app-footer>
<div class="md:min-h-0 min-h-16"></div>
<div class="h-max">
<router-outlet></router-outlet>
</div>
<app-footer class="md:mb-0 mb-16 flex-shrink-0"></app-footer>
</div>
<app-tab-bar></app-tab-bar>
<app-notification></app-notification>

View File

@@ -23,17 +23,4 @@ import { TabBarComponent } from "./components/tab-bar/tab-bar.component";
})
export class AppComponent {
title = "NwaifuAnime";
constructor(private sw: AppService) {}
get hasUpdate() {
return this.sw.isUpdateAvailable;
}
update() {
this.sw.update();
}
get serviceWorkerEnabled() {
return this.sw.serviceWorkerEnabled;
}
}

View File

@@ -3,6 +3,7 @@ import { AuthComponent } from "./components/auth/auth.component";
import { DetailComponent } from "./components/detail/detail.component";
import { HomeComponent } from "./components/home/home.component";
import { ReaderComponent } from "./components/reader/reader.component";
import { DmcaComponent } from "./components/dmca/dmca.component";
export const appRoutes: Route[] = [
{
@@ -15,4 +16,5 @@ export const appRoutes: Route[] = [
path: "auth",
component: AuthComponent,
},
{ path: "dmca", component: DmcaComponent },
];

View File

@@ -18,13 +18,20 @@
>
Сохранить
</button>
<button
type="button"
(click)="clearToken()"
class="hover:bg-slate-600 bg-slate-400 p-3 rounded-md text-white"
>
Очистить
</button>
</div>
</li>
<li>
Вход через скрипт TamperMonkey. Если нет кнопки, значит вы не установили скрипт
<a
href="https://test-front.mangalib.me"
class="hover:bg-slate-600 bg-slate-400 p-3 rounded-md text-white tamperMonkey"
class="hover:bg-slate-600 bg-slate-400 px-3 md:py-3 py-1 rounded-md text-white tamperMonkey"
>
Вход
</a>

View File

@@ -67,6 +67,12 @@ export class AuthComponent implements AfterViewInit, OnDestroy {
});
}
clearToken() {
this.rulibAuthService.deleteToken();
if (this.libSocialToken) this.libSocialToken.nativeElement.value = "";
this.notificationService.info("Токен успешно удален!", "Вход");
}
ngAfterViewInit(): void {
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
const { token, service } = params;

View File

@@ -0,0 +1,17 @@
<p class="text-3xl ps-[3rem] mt-3">DMCA Disclaimer</p>
<div class="h-full px-[3rem] flex flex-col gap-3">
<div class="block">
<p>На русском:</p>
<p>
Разработчики этого приложения не имеют никакого отношения к контенту, доступному в приложении.
Оно собрано из источников, свободно доступных через любой веб-браузер.
</p>
</div>
<div class="block">
<p>English:</p>
<p>
The developers of this application does not have any affiliation with the content available in
the app. It is collecting from the sources freely available through any web browser.
</p>
</div>
</div>

View File

@@ -0,0 +1,9 @@
import { Component } from "@angular/core";
@Component({
selector: "app-dmca",
standalone: true,
templateUrl: "./dmca.component.html",
styleUrl: "./dmca.component.less",
})
export class DmcaComponent {}

View File

@@ -1,19 +1,14 @@
<div class="footer w-full border-t border-black bg-gray-300 pt-3 min-h-[15rem] mt-3">
<p class="text-3xl ps-[5rem]">DMCA Disclaimer</p>
<div class="footer-content h-full px-[5rem] flex flex-col gap-3">
<div class="block">
<p>На русском:</p>
<p>
Разработчики этого приложения не имеют никакого отношения к контенту, доступному в
приложении. Оно собрано из источников, свободно доступных через любой веб-браузер.
</p>
</div>
<div class="block">
<p>English:</p>
<p>
The developers of this application does not have any affiliation with the content available
in the app. It is collecting from the sources freely available through any web browser.
</p>
</div>
<div
class="footer w-full border-t border-black bg-gray-300 min-h-[3rem] mt-3 px-12 flex flex-row justify-between items-center"
>
<div class="links flex flex-row flex-start gap-3 items-center">
<a routerLink="/dmca" title="DMCA Disclaimer" class="underline">DMCA</a>
</div>
<a
class="underline flex flex-row items-center gap-1"
target="_blank"
title="Source code"
href="https://git.nwaifu.su/neuro_llc/NwaifuWeb/src/branch/dev/apps/NwaifuAnime"
>Исходный код <i class="lni lni-git"></i
></a>
</div>

View File

@@ -1,9 +1,12 @@
import { Component } from "@angular/core";
import { ChangeDetectionStrategy, Component } from "@angular/core";
import { RouterLink } from "@angular/router";
@Component({
selector: "app-footer",
templateUrl: "./footer.component.html",
styleUrls: ["./footer.component.less"],
standalone: true,
imports: [RouterLink],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FooterComponent {}

View File

@@ -8,6 +8,15 @@
<img src="pic/Blank-profile.png" alt="Profile pic" class="w-full h-full" />
</div>
</button>
@if (this.swEnabled && this.swHasUpdate) {
<button title="Update" (click)="swUpdate()" class="md:w-fit w-full">
<div
class="h-8 md:w-8 w-full rounded-md bg-green-300 flex flex-col justify-center items-center md:ms-1 ms-0 md:mt-0 mt-2"
>
<i class="lni lni-download text-gray-700"></i>
</div>
</button>
}
</div>
<div
[class]="

View File

@@ -9,6 +9,7 @@ import {
} from "@angular/core";
import { RouterLink } from "@angular/router";
import { Subject } from "rxjs";
import { AppService } from "../../app.service";
import { SearchFieldComponent } from "../search-field/search-field.component";
@Component({
@@ -24,11 +25,24 @@ export class HeaderComponent implements AfterViewInit, OnDestroy {
@ViewChild("profileMenu") profileMenu: ElementRef<HTMLDivElement> | null = null;
private destroy$ = new Subject<void>();
constructor(private swService: AppService) {}
get swEnabled() {
return this.swService.serviceWorkerEnabled;
}
swUpdate() {
this.swService.update();
}
get swHasUpdate() {
return this.swService.isUpdateAvailable;
}
@HostListener("window:click", ["$event"])
toggleProfileMenu(event: MouseEvent) {
if (this.profileBtn && this.profileBtn.nativeElement.contains(event.target as Node)) {
this.menuOpened = !this.menuOpened;
console.log(this.menuOpened);
} else {
this.menuOpened = false;
}
@@ -51,14 +65,6 @@ export class HeaderComponent implements AfterViewInit, OnDestroy {
}
}
get menuBtnClass(): string {
return `lni ${this.menuOpened ? "lni-close" : "lni-menu"} text-white`;
}
get searchBarClass(): string {
return `search-bar bg-slate-300 md:w-full w-full md:m-0 ms-2 me-2 md:h-6 h-10 md:flex justify-start flex-row items-center rounded-md ${this.menuOpened ? "flex" : "hidden"}`;
}
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();

View File

@@ -16,9 +16,15 @@
<img
[src]="popularTitle.cover.thumbnail"
[alt]="popularTitle.slug"
class="w-[200px] h-auto aspect-auto"
class="w-[200px] max-h-[250px] h-auto aspect-auto"
/>
<p>{{ popularTitle.rus_name }}</p>
<p class="text-center">
{{
popularTitle.rus_name.length > 50
? popularTitle.rus_name.slice(0, 50) + "..."
: popularTitle.rus_name
}}
</p>
</div>
</a>
}
@@ -28,31 +34,68 @@
</div>
}
} @else {
<div class="flex flex-col items-center w-full px-3 mt-3">
<div class="flex justify-center items-center mt-3">
@if (loading) {
<h1>Loading...</h1>
}
@if (notFound && !loading) {
} @else if (notFound && !loading) {
<h1>Not found</h1>
} @else {
<h1>Найдено по запросу "{{ search }}" результатов: {{ items.length }}</h1>
}
@for (item of items; track $index) {
<a
routerLink="/detail"
[queryParams]="{ url: item.slug_url }"
title="{{ item.name }}"
class="mb-6 max-w-[700px] w-full"
>
<div
class="card flex flex-col items-center border-black border-2 rounded-md p-4 w-full h-[350px]"
</div>
<div class="flex flex-col items-center justify-start gap-3">
<div
class="flex md:flex-row flex-col flex-nowrap md:flex-wrap gap-2 justify-start items-center w-full px-3 mt-3 md:mx-12"
>
@for (item of currentPageItems; track $index) {
<a
routerLink="/detail"
[queryParams]="{ url: item.slug_url }"
title="{{ item.name }}"
class="my-1 max-w-[400px] w-full"
>
<h1>{{ item.rus_name }}</h1>
<img
[src]="item.cover.thumbnail"
[alt]="item.slug"
class="w-[200px] h-auto max-h-[300px] aspect-auto"
/>
</div>
</a>
<div
class="card flex flex-col items-center border-black border-2 rounded-md p-4 w-full h-[350px]"
>
<p class="text-center">
{{
item.rus_name.length > 50 ? item.rus_name.substring(0, 50) + "..." : item.rus_name
}}
</p>
<img
[src]="item.cover.thumbnail"
[alt]="item.slug"
class="w-[200px] h-auto max-h-[250px] aspect-auto"
/>
</div>
</a>
}
</div>
@if (items.length) {
<div class="flex flex-row items-center justify-between w-full px-3">
<button
[ngClass]="{
'bg-slate-600 text-white p-3 rounded-md hover:scale-105': 1,
'opacity-15': currentPage === 0,
}"
[disabled]="currentPage === 0"
(click)="previousSearchPage()"
>
Назад
</button>
<p>Страница {{ currentPage + 1 }} из {{ maxPages + 1 }}</p>
<button
[ngClass]="{
'bg-slate-600 text-white p-3 rounded-md hover:scale-105': 1,
'opacity-15': currentPage === maxPages,
}"
[disabled]="currentPage === maxPages"
*ngIf="currentPage < items.length / 8"
(click)="nextSearchPage()"
>
Вперед
</button>
</div>
}
</div>
}

View File

@@ -1,3 +0,0 @@
:host {
height: max-content;
}

View File

@@ -1,7 +1,8 @@
import { CommonModule } from "@angular/common";
import { Component, Input, OnDestroy, OnInit } from "@angular/core";
import { ActivatedRoute, RouterLink } from "@angular/router";
import { map, Subject, Subscription, takeUntil } from "rxjs";
import { ActivatedRoute, Router, RouterLink } from "@angular/router";
import { Subject, Subscription, map, takeUntil } from "rxjs";
import { RulibAuthService } from "../../services/parsers/rulib/rulib.auth.service";
import { IRuLIBPopular } from "../../services/parsers/rulib/rulib.popular.dto";
import { Datum } from "../../services/parsers/rulib/rulib.search.dto";
import { SearchService } from "../../services/search.service";
@@ -19,6 +20,7 @@ export class HomeComponent implements OnDestroy, OnInit {
notFound = false;
search: string = "";
popularItemsMap: Map<string, IRuLIBPopular[]> = new Map<string, IRuLIBPopular[]>();
currentPage = 0;
private destroy$ = new Subject<void>();
private popularSubscription = new Subscription();
@@ -26,6 +28,8 @@ export class HomeComponent implements OnDestroy, OnInit {
constructor(
private searchService: SearchService,
private route: ActivatedRoute,
private ruLibAuthService: RulibAuthService,
private router: Router,
) {
this.searchService.setMangalibParser();
}
@@ -60,17 +64,58 @@ export class HomeComponent implements OnDestroy, OnInit {
}
private getPopularSlashlib() {
this.searchService.setSlashlibParser();
this.getPopular(this.searchService.getRuLibName());
this.ruLibAuthService
.checkToken(this.ruLibAuthService.getToken())
.pipe(takeUntil(this.destroy$))
.subscribe((loggedIn) => {
if (!loggedIn) return;
this.searchService.setSlashlibParser();
this.getPopular(this.searchService.getRuLibName());
});
}
get popularItems() {
return Array.from(this.popularItemsMap.entries()).sort((a, b) => (a[0] > b[0] ? 1 : -1));
}
get currentPageItems() {
return this.items.slice(
8 * this.currentPage,
Math.min(this.items.length, 8 * (this.currentPage + 1)),
);
}
get maxPages() {
return Math.ceil(this.items.length / 8) - 1;
}
nextSearchPage() {
this.currentPage = Math.min(this.currentPage + 1, Math.ceil(this.items.length / 8) - 1);
this.router.navigate([], {
queryParams: { page: this.currentPage },
relativeTo: this.route,
queryParamsHandling: "merge",
});
}
previousSearchPage() {
this.currentPage = Math.max(this.currentPage - 1, 0);
this.router.navigate([], {
queryParams: { page: this.currentPage },
relativeTo: this.route,
queryParamsHandling: "merge",
});
}
ngOnInit(): void {
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
if (this.search && params["search"] && this.search === params["search"]) return;
this.search = params["search"] ?? "";
try {
this.currentPage = Math.max(0, +params["page"] || 0);
} catch {
this.currentPage = 0;
}
this.items = [];
this.loading = true;
if (this.search) {
@@ -81,6 +126,9 @@ export class HomeComponent implements OnDestroy, OnInit {
.subscribe((data) => {
this.loading = false;
this.items = data.data;
const maxPage = Math.ceil(this.items.length / 8) - 1;
console.log(maxPage);
this.currentPage = Math.min(this.currentPage, maxPage);
this.notFound = this.items.length === 0;
});
} else {

View File

@@ -28,6 +28,12 @@ export class RulibAuthService implements OnDestroy {
return token_data.rulib_token ?? "";
}
deleteToken(): void {
const token_data: IToken = JSON.parse(localStorage.getItem("token") ?? "{}");
token_data.rulib_token = "";
localStorage.setItem("token", JSON.stringify(token_data));
}
checkToken(token: string): Observable<boolean> {
return this.http
.get(this.api_url + "/api/auth/me", {

View File

@@ -1,6 +1,6 @@
{
"name": "nwaifu-web",
"version": "0.3.0",
"version": "0.3.1",
"scripts": {
"ng": "ng",
"start": "nx serve NwaifuWeb",