From 61102486680ba215c4a340039aa65a7c93f8a335 Mon Sep 17 00:00:00 2001 From: itzMiney Date: Wed, 18 Mar 2026 07:15:21 +0100 Subject: [PATCH] merged shortener page into admin page, refactored into modal --- angular.json | 2 +- src/app/admin/admin.component.css | 5 +- src/app/admin/admin.component.html | 15 +- src/app/admin/admin.component.ts | 38 +++-- src/app/app.routes.ts | 2 - src/app/login/login.component.ts | 24 +--- src/app/shared/modal/modal.component.css | 6 +- src/app/shared/modal/modal.component.html | 6 +- src/app/shared/services/auth.service.ts | 69 ++++----- .../shortener/shortener.component.css | 94 ++++++++---- .../shared/shortener/shortener.component.html | 89 ++++++++++++ .../shared/shortener/shortener.component.ts | 130 +++++++++++++++++ src/app/shortener/shortener.component.html | 85 ----------- src/app/shortener/shortener.component.ts | 135 ------------------ 14 files changed, 363 insertions(+), 337 deletions(-) rename src/app/{ => shared}/shortener/shortener.component.css (63%) create mode 100644 src/app/shared/shortener/shortener.component.html create mode 100644 src/app/shared/shortener/shortener.component.ts delete mode 100644 src/app/shortener/shortener.component.html delete mode 100644 src/app/shortener/shortener.component.ts diff --git a/angular.json b/angular.json index 2d38b90..8bca3fc 100644 --- a/angular.json +++ b/angular.json @@ -43,7 +43,7 @@ }, { "type": "anyComponentStyle", - "maximumWarning": "4kB", + "maximumWarning": "5kB", "maximumError": "8kB" } ], diff --git a/src/app/admin/admin.component.css b/src/app/admin/admin.component.css index abe8982..7b6796d 100644 --- a/src/app/admin/admin.component.css +++ b/src/app/admin/admin.component.css @@ -296,7 +296,7 @@ button { background-color: #8a6bbf; color: white; padding: 12px 22px; - margin: 10px; + margin-right: 15px; border: none; border-radius: 25px; cursor: pointer; @@ -335,7 +335,8 @@ button.toggle-button:hover:active, button.toggle-button:hover { button.logout { background-color: #713252; - margin: 0 0 0 5px; + margin: 0; + padding: 12px 16px; } button.logout:hover { diff --git a/src/app/admin/admin.component.html b/src/app/admin/admin.component.html index 81421f6..b5c1ab5 100644 --- a/src/app/admin/admin.component.html +++ b/src/app/admin/admin.component.html @@ -2,15 +2,16 @@
- Logo @if (!isNarrow) { + Logo

Admin Dashboard

}
+ - +
@@ -129,7 +130,7 @@ @@ -187,3 +188,11 @@ + + + + diff --git a/src/app/admin/admin.component.ts b/src/app/admin/admin.component.ts index 3a2cf68..e95c02d 100644 --- a/src/app/admin/admin.component.ts +++ b/src/app/admin/admin.component.ts @@ -9,6 +9,7 @@ import {ViewportService} from '../shared/services/viewport.service'; import {Title} from '@angular/platform-browser'; import {ModalComponent} from '../shared/modal/modal.component'; import {AuthService} from '../shared/services/auth.service'; +import {ShortenerComponent} from '../shared/shortener/shortener.component'; @Component({ selector: 'app-admin', @@ -19,7 +20,8 @@ import {AuthService} from '../shared/services/auth.service'; NgStyle, ModalComponent, TitleCasePipe, - RouterLink + RouterLink, + ShortenerComponent ] }) export class AdminComponent implements OnInit, OnDestroy { @@ -35,10 +37,12 @@ export class AdminComponent implements OnInit, OnDestroy { content: string = ''; modalTitle: string = ''; - isModalOpen: boolean = false; + isUserModalOpen: boolean = false; userMode: 'create' | 'edit' | 'delete' = 'create'; isUserDropdownOpen = false; + isShortenerModalOpen: boolean = false; + userData = { username: '', password: '', @@ -72,7 +76,7 @@ export class AdminComponent implements OnInit, OnDestroy { } startTokenValidation() { - this.tokenValidationInterval = interval(300000).subscribe(() => { + this.tokenValidationInterval = interval(60000).subscribe(() => { this.authService.validateToken().subscribe(); }); } @@ -209,12 +213,25 @@ export class AdminComponent implements OnInit, OnDestroy { } openUserModal() { - this.isModalOpen = true; + this.isUserModalOpen = true; this.modalTitle = 'Manage Users'; this.userMode = 'create'; this.isUserDropdownOpen = false; } + closeModal() { + this.isUserModalOpen = false; + this.userData = { + username: '', + password: '', + id: '', + }; + } + + closeShortenerModal() { + this.isShortenerModalOpen = false; + } + toggleUserDropdown(): void { this.isUserDropdownOpen = !this.isUserDropdownOpen; } @@ -254,15 +271,6 @@ export class AdminComponent implements OnInit, OnDestroy { } } - closeModal() { - this.isModalOpen = false; - this.userData = { - username: '', - password: '', - id: '', - }; - } - createUserFromValues(username: string, password: string): void { if (!username?.trim() || !password?.trim()) { alert('Both username and password are required!'); @@ -387,4 +395,8 @@ export class AdminComponent implements OnInit, OnDestroy { this.deleteArticle(articleId); } } + + openShortenerModal() { + this.isShortenerModalOpen = true; + } } diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index eb18062..09a83dc 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -10,7 +10,6 @@ import {SocialsComponent} from './socials/socials.component'; // import {ServicesComponent} from './services/services.component'; // import {TosComponent} from './tos/tos.component'; import {ImprintComponent} from './imprint/imprint.component'; -import {ShortenerComponent} from './shortener/shortener.component'; import {PrivacyComponent} from './privacy/privacy.component'; import {SuccessComponent} from './checkout/success/success.component'; import {CancelComponent} from './checkout/cancel/cancel.component'; @@ -28,7 +27,6 @@ export const routes: Routes = [ { path: 'privacy', component: PrivacyComponent }, { path: 'imprint', component: ImprintComponent }, { path: 'blog/:slug', component: ArticlePageComponent }, - { path: 'shortener', component: ShortenerComponent }, { path: 'checkout/success', pathMatch: 'full', component: SuccessComponent }, { path: 'checkout/cancel', pathMatch: 'full', component: CancelComponent }, { path: '**', pathMatch: 'full', component: NotFoundComponent } diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index 7e09521..d790308 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -1,10 +1,9 @@ -import {Component, Inject, OnInit, PLATFORM_ID} from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {AuthService} from '../shared/services/auth.service'; -import {ActivatedRoute, Router} from '@angular/router'; +import {Router} from '@angular/router'; import {FormsModule} from '@angular/forms'; import {ViewportService} from '../shared/services/viewport.service'; import { Title } from '@angular/platform-browser'; -import { take } from 'rxjs/operators'; import {ParallaxComponent} from '../shared/parallax/parallax.component'; @Component({ @@ -21,35 +20,18 @@ export class LoginComponent implements OnInit { username = ''; password = ''; errorMessage = ''; - private readonly allowedAdminRoutes = new Set([ - '/admin', - '/shortener' - ]); isNarrow = false; - redirectUrl = '/admin'; constructor( private authService: AuthService, private router: Router, - private route: ActivatedRoute, private deviceService: ViewportService, private titleService: Title, - @Inject(PLATFORM_ID) private platformId: Object ) {} ngOnInit() { this.titleService.setTitle('Login | itzMiney') this.isNarrow = this.deviceService.isNarrow; - - this.route.queryParams.pipe(take(1)).subscribe(params => { - const raw = params['redirectUrl']; - - if (typeof raw === 'string' && this.allowedAdminRoutes.has(raw)) { - this.redirectUrl = raw; - } else { - this.redirectUrl = '/admin'; - } - }); } onLogin() { @@ -57,7 +39,7 @@ export class LoginComponent implements OnInit { this.authService.login(this.username.trim(), this.password).subscribe({ next: () => { - void this.router.navigateByUrl(this.redirectUrl); + void this.router.navigate(['/admin']); }, error: (err) => { this.errorMessage = diff --git a/src/app/shared/modal/modal.component.css b/src/app/shared/modal/modal.component.css index c62995f..d42e9b8 100644 --- a/src/app/shared/modal/modal.component.css +++ b/src/app/shared/modal/modal.component.css @@ -26,12 +26,12 @@ .close-btn { position: absolute; - top: 4px; - right: 8px; + top: 25px; + right: 25px; background: none; color: white; border: none; - font-size: 28px; + font-size: 40px; cursor: pointer; transition: all ease-in-out 0.2s; } diff --git a/src/app/shared/modal/modal.component.html b/src/app/shared/modal/modal.component.html index aca3bd2..0827133 100644 --- a/src/app/shared/modal/modal.component.html +++ b/src/app/shared/modal/modal.component.html @@ -1,7 +1,7 @@ @if (isOpen) { -