refactor to define helper service more accurately

This commit is contained in:
itzMiney committed 2026-03-17 23:21:12 +01:00
1 parent 5527acfb6a
commit 7618e4bf5d
28 files changed
+78 -403

No files matched your search

+3 -3
View File
@@ -7,7 +7,7 @@
</app-parallax>
<div class="landing-container">
<div class="title-box">
<h1 [ngStyle]="{'font-size': isMobile ? '4rem' : '5rem'}"><code>itzMiney</code></h1>
<h1 [ngStyle]="{'font-size': isNarrow ? '4rem' : '5rem'}"><code>itzMiney</code></h1>
<p class="subtitle">{{ 'ABOUT_SUB' | translate}}</p>
</div>
<div class="down-arrow" (click)="scrollDown()">
@@ -17,11 +17,11 @@
<div class="separator"></div>
<section id="content" #contentTrigger></section>
<div class="about-container">
<div class="terminal" [ngStyle]="{'margin': isMobile ? '10px;' : '25px'}">
<div class="terminal" [ngStyle]="{'margin': isNarrow ? '10px;' : '25px'}">
<div class="titlebar">
<div class="window-title"><p><code>Konsole</code></p></div> <div class="window-actions"><p>🟡 🟣 🔴</p></div>
</div>
<div class="terminal-window" [ngStyle]="{'width': isMobile ? '100%' : '900px' }">
<div class="terminal-window" [ngStyle]="{'width': isNarrow ? '100%' : '900px' }">
<app-terminal-emulator [bootOnVisible]="terminalShouldBoot"></app-terminal-emulator>
</div>
</div>
+4 -4
View File
@@ -1,5 +1,5 @@
import {AfterViewInit, Component, ElementRef, HostListener, OnInit, ViewChild, ViewEncapsulation} from '@angular/core';
import {DeviceDetectorService} from '../shared/services/device-detector.service';
import {ViewportService} from '../shared/services/viewport.service';
import {Title} from '@angular/platform-browser';
import {TranslatePipe} from '@ngx-translate/core';
import {ParallaxComponent} from '../shared/parallax/parallax.component';
@@ -21,20 +21,20 @@ import {TerminalEmulatorComponent} from '../shared/terminal-emulator/terminal-em
styleUrls: ['./about.component.css']
})
export class AboutComponent implements OnInit, AfterViewInit {
isMobile: boolean = false;
isNarrow: boolean = false;
terminalShouldBoot: boolean = false;
@ViewChild('contentTrigger') contentTrigger!: ElementRef;
constructor(
private deviceService: DeviceDetectorService,
private deviceService: ViewportService,
private titleService: Title
) {
}
ngOnInit() {
this.titleService.setTitle('itzMiney\'s Home');
this.isMobile = this.deviceService.isMobile;
this.isNarrow = this.deviceService.isNarrow;
}
ngAfterViewInit() {
+4 -4
View File
@@ -1,7 +1,7 @@
<div id="admin-bg">
<div class="height-container">
<!-- Left Section: Edit/Delete Article -->
@if (!isMobile) {
@if (!isNarrow) {
<div class="left-section">
<div class="delete-article-tile">
<h2>Delete Article</h2>
@@ -22,7 +22,7 @@
</div>
}
<!-- Center Section: Admin Dashboard and Create Article Tiles -->
<div class="center-section" [ngStyle]="{'width': isMobile ? '100%' : '33.33%'}">
<div class="center-section" [ngStyle]="{'width': isNarrow ? '100%' : '33.33%'}">
<div class="admin-dashboard-tile">
<h2>Admin Dashboard</h2>
<div class="admin-actions">
@@ -73,7 +73,7 @@
<button type="submit" [disabled]="createForm.invalid">Create Article</button>
</form>
</div>
@if (isMobile) {
@if (isNarrow) {
<div class="delete-article-tile">
<h2>Delete Article</h2>
<form #deleteFormMobile="ngForm" id="deleteFormMobile" (ngSubmit)="deleteArticle(deleteFormMobile)">
@@ -143,7 +143,7 @@
</div>
<!-- Right Section: Articles List Tile -->
@if (!isMobile) {
@if (!isNarrow) {
<div class="right-section">
<div class="articles-list-tile">
<h2>
+4 -4
View File
@@ -5,7 +5,7 @@ import {UserService} from '../shared/services/user.service';
import { NgStyle } from '@angular/common';
import {Observer, Subscription, interval} from 'rxjs';
import {FormsModule, NgForm} from '@angular/forms';
import {DeviceDetectorService} from '../shared/services/device-detector.service';
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';
@@ -27,7 +27,7 @@ export class AdminComponent implements OnInit, OnDestroy {
users: any[] = [];
noArticles: boolean = false;
isMobile: boolean = false;
isNarrow: boolean = false;
title: string = '';
content: string = '';
@@ -47,14 +47,14 @@ export class AdminComponent implements OnInit, OnDestroy {
private articleService: ArticleService,
private userService: UserService,
private router: Router,
private deviceService: DeviceDetectorService,
private deviceService: ViewportService,
private titleService: Title,
protected authService: AuthService
) {}
ngOnInit() {
this.titleService.setTitle('Admin Panel | itzMiney')
this.isMobile = this.deviceService.isMobile;
this.isNarrow = this.deviceService.isNarrow;
this.authService.validateToken().subscribe();
this.startTokenValidation();
this.loadArticles();
+1 -1
View File
@@ -1,4 +1,4 @@
@if (!isMobile) {
@if (!isNarrow) {
@if (showNavbar) {
<app-navbar ></app-navbar>
}
+4 -4
View File
@@ -4,7 +4,7 @@ import {ActivatedRoute, Router, RouterOutlet} from '@angular/router';
import {NavbarComponent} from './shared/navbar/navbar.component';
import {MobileNavbarComponent} from './shared/mobile-navbar/mobile-navbar.component';
import {FooterComponent} from './shared/footer/footer.component';
import {DeviceDetectorService} from './shared/services/device-detector.service';
import {ViewportService} from './shared/services/viewport.service';
import {TranslateService} from '@ngx-translate/core';
@Component({
@@ -14,14 +14,14 @@ import {TranslateService} from '@ngx-translate/core';
styleUrl: './app.component.css',
})
export class AppComponent implements OnInit {
isMobile: boolean = false;
isNarrow: boolean = false;
showNavbar: boolean = true;
showFooter: boolean = true;
constructor(
private router: Router,
private activatedRoute: ActivatedRoute,
private deviceService: DeviceDetectorService,
private deviceService: ViewportService,
private translate: TranslateService,
) {
this.translate.setDefaultLang('en');
@@ -30,7 +30,7 @@ export class AppComponent implements OnInit {
ngOnInit() {
this.router.events.subscribe(() => this.checkRoute())
this.isMobile = this.deviceService.isMobile;
this.isNarrow = this.deviceService.isNarrow;
}
checkRoute() {
-2
View File
@@ -1,7 +1,6 @@
import {ApplicationConfig, importProvidersFrom, provideZoneChangeDetection} from '@angular/core';
import {provideRouter, withInMemoryScrolling, withViewTransitions} from '@angular/router';
import {routes} from './app.routes';
import {provideAnimationsAsync} from '@angular/platform-browser/animations/async';
import {provideClientHydration, withEventReplay} from '@angular/platform-browser';
import {HttpClient, provideHttpClient} from '@angular/common/http';
import {AuthService} from './shared/services/auth.service';
@@ -23,7 +22,6 @@ export const appConfig: ApplicationConfig = {
anchorScrolling: 'enabled'
})
),
provideAnimationsAsync(),
provideClientHydration(withEventReplay()),
provideHttpClient(),
AuthService,
+1 -1
View File
@@ -6,7 +6,7 @@
">
</app-parallax>
<div class="height-container">
<div class="blog-header" [ngStyle]="{'margin-top': isMobile ? '72px' : '112px'}">
<div class="blog-header" [ngStyle]="{'margin-top': isNarrow ? '72px' : '112px'}">
<h1>Blog</h1>
<p class="subtitle">{{ 'BLOG_SUB' | translate }}</p>
</div>
+4 -4
View File
@@ -1,5 +1,5 @@
import {Component, OnInit} from '@angular/core';
import {DeviceDetectorService} from '../shared/services/device-detector.service'
import {ViewportService} from '../shared/services/viewport.service'
import { DatePipe, AsyncPipe, SlicePipe, NgStyle } from '@angular/common';
import { ArticleService } from '../shared/services/article.service';
import { Router } from '@angular/router';
@@ -23,9 +23,9 @@ import {ParallaxComponent} from '../shared/parallax/parallax.component';
})
export class BlogComponent implements OnInit {
articles$: Observable<any[]> | undefined;
isMobile: boolean = false;
isNarrow: boolean = false;
constructor(
private deviceService: DeviceDetectorService,
private deviceService: ViewportService,
private articleService: ArticleService,
private router: Router,
private titleService: Title
@@ -33,7 +33,7 @@ export class BlogComponent implements OnInit {
ngOnInit() {
this.titleService.setTitle('Blog | itzMiney')
this.isMobile = this.deviceService.isMobile;
this.isNarrow = this.deviceService.isNarrow;
this.articles$ = this.articleService.getAllArticles();
}
+4 -4
View File
@@ -2,7 +2,7 @@ import {Component, Inject, OnInit, PLATFORM_ID} from '@angular/core';
import {AuthService} from '../shared/services/auth.service';
import {ActivatedRoute, Router} from '@angular/router';
import {FormsModule} from '@angular/forms';
import {DeviceDetectorService} from '../shared/services/device-detector.service';
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';
@@ -25,21 +25,21 @@ export class LoginComponent implements OnInit {
'/admin',
'/shortener'
]);
isMobile = false;
isNarrow = false;
redirectUrl = '/admin';
constructor(
private authService: AuthService,
private router: Router,
private route: ActivatedRoute,
private deviceService: DeviceDetectorService,
private deviceService: ViewportService,
private titleService: Title,
@Inject(PLATFORM_ID) private platformId: Object
) {}
ngOnInit() {
this.titleService.setTitle('Login | itzMiney')
this.isMobile = this.deviceService.isMobile;
this.isNarrow = this.deviceService.isNarrow;
this.route.queryParams.pipe(take(1)).subscribe(params => {
const raw = params['redirectUrl'];
+1 -1
View File
@@ -12,7 +12,7 @@ import {ParallaxComponent} from '../shared/parallax/parallax.component';
})
export class NotFoundComponent implements OnInit {
isMobile: boolean = false;
isNarrow: boolean = false;
constructor(
private titleService: Title,
) {
+1 -1
View File
@@ -7,7 +7,7 @@
</app-parallax>
<div class="height-container">
<div class="portfolio-container">
<div class="portfolio-header" [ngStyle]="{'margin-top': isMobile ? '60px' : '120px'}">
<div class="portfolio-header" [ngStyle]="{'margin-top': isNarrow ? '60px' : '120px'}">
<h1>{{ 'PORTF_TITLE' | translate }}</h1>
<p class="subtitle">{{ 'PORTF_SUB' | translate }}</p>
</div>
+4 -4
View File
@@ -1,5 +1,5 @@
import {Component, OnInit, ViewEncapsulation} from '@angular/core';
import {DeviceDetectorService} from '../shared/services/device-detector.service';
import {ViewportService} from '../shared/services/viewport.service';
import { CommonModule, NgStyle } from '@angular/common';
import {Title} from '@angular/platform-browser';
import {AudioPlayerComponent} from '../shared/audio-player/audio-player.component';
@@ -33,15 +33,15 @@ export class PortfolioComponent implements OnInit {
];
selectedItem: any = null;
showModal = false;
isMobile: boolean = false;
isNarrow: boolean = false;
constructor(
private deviceService: DeviceDetectorService,
private deviceService: ViewportService,
private titleService: Title,
) {}
ngOnInit() {
this.titleService.setTitle('Portfolio | itzMiney');
this.isMobile = this.deviceService.isMobile;
this.isNarrow = this.deviceService.isNarrow;
}
openModal(item: any) {
+1 -1
View File
@@ -7,7 +7,7 @@
</app-parallax>
<div class="height-container">
<div class="privacy-container">
<div class="floating-nav" [class.hidden]="isMobile">
<div class="floating-nav" [class.hidden]="isNarrow">
<ul>
<li><a href="#controller" [class.active]="activeSection === 'controller'" (click)="scrollToSection($event, 'controller')">{{ 'privacy.nav.controller' | translate }}</a></li>
<li><a href="#what-data" [class.active]="activeSection === 'whatData'" (click)="scrollToSection($event, 'what-data')">{{ 'privacy.nav.whatData' | translate }}</a></li>
+4 -4
View File
@@ -1,5 +1,5 @@
import {AfterViewInit, Component, OnInit} from '@angular/core';
import {DeviceDetectorService} from '../shared/services/device-detector.service';
import {ViewportService} from '../shared/services/viewport.service';
import {Title} from '@angular/platform-browser';
import {TranslatePipe} from '@ngx-translate/core';
import {ParallaxComponent} from '../shared/parallax/parallax.component';
@@ -15,12 +15,12 @@ import {ParallaxComponent} from '../shared/parallax/parallax.component';
})
export class PrivacyComponent implements OnInit, AfterViewInit {
isMobile: boolean = false;
isNarrow: boolean = false;
activeSection: string = '';
copiedSection: string | null = null;
constructor(
private deviceService: DeviceDetectorService,
private deviceService: ViewportService,
private titleService: Title,
) {}
@@ -39,7 +39,7 @@ export class PrivacyComponent implements OnInit, AfterViewInit {
ngOnInit() {
this.titleService.setTitle('Privacy Policy | itzMiney');
this.isMobile = this.deviceService.isMobile;
this.isNarrow = this.deviceService.isNarrow;
}
ngAfterViewInit() {
+1 -1
View File
@@ -7,7 +7,7 @@
</app-parallax>
<div class="height-container">
<div class="services-container">
<div class="services-header" [ngStyle]="{'margin-top': isMobile ? '60px' : '120px'}">
<div class="services-header" [ngStyle]="{'margin-top': isNarrow ? '60px' : '120px'}">
<h1>{{ 'SERVS_TITLE' | translate}}</h1>
<p class="subtitle">Web Development & Design</p>
</div>
+4 -4
View File
@@ -1,5 +1,5 @@
import {Component, OnInit} from '@angular/core';
import {DeviceDetectorService} from '../shared/services/device-detector.service';
import {ViewportService} from '../shared/services/viewport.service';
import {Title} from '@angular/platform-browser';
import {NgIf, NgFor, NgStyle} from '@angular/common';
import {TranslatePipe, TranslateService} from '@ngx-translate/core';
@@ -21,7 +21,7 @@ import {ParallaxComponent} from '../shared/parallax/parallax.component';
export class ServicesComponent implements OnInit {
private apiUrl = '/api/stripe/create-checkout-session';
isMobile: boolean = false;
isNarrow: boolean = false;
activeTab: string[] = [];
services: {
@@ -33,7 +33,7 @@ export class ServicesComponent implements OnInit {
}[] = [];
constructor(
private deviceService: DeviceDetectorService,
private deviceService: ViewportService,
private titleService: Title,
private translate: TranslateService,
private http: HttpClient
@@ -45,7 +45,7 @@ export class ServicesComponent implements OnInit {
ngOnInit() {
this.titleService.setTitle('Services | itzMiney');
this.isMobile = this.deviceService.isMobile;
this.isNarrow = this.deviceService.isNarrow;
this.loadServices();
this.translate.onLangChange.subscribe(() => this.loadServices());
}
@@ -1,4 +1,4 @@
<div class="audio-player" [ngClass]="{ mobile: isMobile }">
<div class="audio-player" [ngClass]="{ mobile: isNarrow }">
<div id="youtube-player"></div>
<h3>{{ nowPlayingTitle() }}</h3>
<div class="controls">
@@ -1,5 +1,5 @@
import {Component, AfterViewInit, signal, OnInit} from '@angular/core';
import {DeviceDetectorService} from '../services/device-detector.service';
import {ViewportService} from '../services/viewport.service';
import {NgClass} from '@angular/common';
@@ -19,17 +19,17 @@ declare global {
styleUrl: './audio-player.component.css'
})
export class AudioPlayerComponent implements AfterViewInit, OnInit {
isMobile: boolean = false;
isNarrow: boolean = false;
private player: any;
isPlayerReady = signal(false);
isPlaying = signal(false);
nowPlayingTitle = signal<string>('');
constructor(private deviceService: DeviceDetectorService) {}
constructor(private deviceService: ViewportService) {}
ngOnInit() {
this.isMobile = this.deviceService.isMobile;
this.isNarrow = this.deviceService.isNarrow;
}
ngAfterViewInit() {
@@ -1,5 +1,5 @@
import {Component, OnInit} from '@angular/core';
import {DeviceDetectorService} from '../services/device-detector.service';
import {ViewportService} from '../services/viewport.service';
import {NavigationEnd, Router, RouterLink} from '@angular/router';
import {TranslatePipe, TranslateService} from '@ngx-translate/core';
@@ -17,15 +17,15 @@ import {TranslatePipe, TranslateService} from '@ngx-translate/core';
export class MobileNavbarComponent implements OnInit{
currentLang: string;
menuOpen = false;
isMobile: boolean = false;
isNarrow: boolean = false;
activeLink: string = '';
constructor(
private router: Router,
private deviceService: DeviceDetectorService,
private deviceService: ViewportService,
private translate: TranslateService
) {
this.isMobile = this.deviceService.isMobile;
this.isNarrow = this.deviceService.isNarrow;
this.currentLang = this.translate.currentLang || this.translate.getDefaultLang() || 'en';
}
+4 -4
View File
@@ -1,6 +1,6 @@
import {Component, OnInit} from '@angular/core';
import {NavigationEnd, Router, RouterLink} from '@angular/router';
import {DeviceDetectorService} from '../services/device-detector.service';
import {ViewportService} from '../services/viewport.service';
import {filter} from 'rxjs/operators';
import {TranslatePipe, TranslateService} from '@ngx-translate/core';
@@ -16,14 +16,14 @@ import {TranslatePipe, TranslateService} from '@ngx-translate/core';
export class NavbarComponent implements OnInit {
currentLang: string;
activeLink: string = '';
isMobile: boolean = false;
isNarrow: boolean = false;
constructor(
private router: Router,
private deviceService: DeviceDetectorService,
private deviceService: ViewportService,
private translate: TranslateService
) {
this.isMobile = this.deviceService.isMobile;
this.isNarrow = this.deviceService.isNarrow;
this.currentLang = this.translate.currentLang || this.translate.getDefaultLang() || 'en';
}
@@ -1,5 +1,5 @@
import {AfterViewInit, Component, ElementRef, Inject, OnDestroy, OnInit, PLATFORM_ID, ViewChild, Input} from '@angular/core';
import {DeviceDetectorService} from '../services/device-detector.service';
import {ViewportService} from '../services/viewport.service';
import {isPlatformBrowser} from '@angular/common';
import Parallax from 'parallax-js';
@@ -16,17 +16,17 @@ export class ParallaxComponent implements OnInit, OnDestroy, AfterViewInit {
@Input() bgGradient: string =
'radial-gradient(circle 120vw at center, rgba(90,78,130,0.32), transparent 40%), linear-gradient(180deg,#1b172c 0%, #0b0b0f 100%)';
isMobile: boolean = false;
isNarrow: boolean = false;
private parallaxInstance: Parallax | null = null;
constructor(
private deviceService: DeviceDetectorService,
private deviceService: ViewportService,
@Inject(PLATFORM_ID) private platformId: Object
) {
}
ngOnInit() {
this.isMobile = this.deviceService.isMobile;
this.isNarrow = this.deviceService.isNarrow;
}
ngAfterViewInit() {
@@ -39,8 +39,8 @@ export class ParallaxComponent implements OnInit, OnDestroy, AfterViewInit {
clipRelativeInput: true,
calibrateX: true,
calibrateY: true,
scalarX: this.isMobile ? 6 : 12,
scalarY: this.isMobile ? 6 : 12,
scalarX: this.isNarrow ? 6 : 12,
scalarY: this.isNarrow ? 6 : 12,
frictionX: 0.1,
frictionY: 0.1,
});
@@ -4,8 +4,8 @@ import {isPlatformBrowser} from '@angular/common';
@Injectable({
providedIn: 'root',
})
export class DeviceDetectorService {
isMobile: boolean = false;
export class ViewportService {
isNarrow: boolean = false;
constructor(@Inject(PLATFORM_ID) private platformId: Object) {
this.updateDeviceType();
@@ -16,9 +16,9 @@ export class DeviceDetectorService {
private updateDeviceType() {
if (isPlatformBrowser(this.platformId)) {
this.isMobile = window.innerWidth <= 768;
this.isNarrow = window.innerWidth <= 768;
} else {
this.isMobile = false;
this.isNarrow = false;
}
}
}
+1 -1
View File
@@ -9,7 +9,7 @@
</app-parallax>
<div class="height-container">
<div class="socials-container">
<div class="socials-header" [ngStyle]="{'margin-top': isMobile ? '80px' : '120px'}">
<div class="socials-header" [ngStyle]="{'margin-top': isNarrow ? '80px' : '120px'}">
<h1>Socials</h1>
<p class="subtitle">{{ 'SOCIALS_SUB' | translate }}</p>
</div>
+4 -4
View File
@@ -1,6 +1,6 @@
import {Component, OnInit} from '@angular/core';
import {NgStyle} from '@angular/common';
import {DeviceDetectorService} from '../shared/services/device-detector.service';
import {ViewportService} from '../shared/services/viewport.service';
import {Title} from '@angular/platform-browser';
import {TranslatePipe} from '@ngx-translate/core';
import {ParallaxComponent} from '../shared/parallax/parallax.component';
@@ -16,14 +16,14 @@ import {ParallaxComponent} from '../shared/parallax/parallax.component';
styleUrl: './socials.component.css'
})
export class SocialsComponent implements OnInit {
isMobile: boolean = false;
isNarrow: boolean = false;
constructor(
private deviceService: DeviceDetectorService,
private deviceService: ViewportService,
private titleService: Title
) {}
ngOnInit() {
this.titleService.setTitle('Socials | itzMiney');
this.isMobile = this.deviceService.isMobile;
this.isNarrow = this.deviceService.isNarrow;
}
}
+1 -1
View File
@@ -7,7 +7,7 @@
</app-parallax>
<div class="height-container">
<div class="tos-container">
<div class="floating-nav" [class.hidden]="isMobile">
<div class="floating-nav" [class.hidden]="isNarrow">
<ul>
<li><a href="#introduction" [class.active]="activeSection === 'introduction'" (click)="scrollToSection($event, 'introduction')">{{ 'termsOfService.sections.introduction.title' | translate }}</a></li>
<li><a href="#services-provided" [class.active]="activeSection === 'services-provided'" (click)="scrollToSection($event, 'services-provided')">{{ 'termsOfService.sections.servicesProvided.title' | translate }}</a></li>
+4 -4
View File
@@ -1,5 +1,5 @@
import {AfterViewInit, Component, OnInit,} from '@angular/core';
import {DeviceDetectorService} from '../shared/services/device-detector.service';
import {ViewportService} from '../shared/services/viewport.service';
import {Title} from '@angular/platform-browser';
import {NgIf} from '@angular/common';
import {TranslatePipe} from '@ngx-translate/core';
@@ -17,12 +17,12 @@ import {ParallaxComponent} from '../shared/parallax/parallax.component';
})
export class TosComponent implements OnInit, AfterViewInit {
isMobile: boolean = false;
isNarrow: boolean = false;
activeSection: string = '';
copiedSection: string | null = null;
constructor(
private deviceService: DeviceDetectorService,
private deviceService: ViewportService,
private titleService: Title
) {}
@@ -41,7 +41,7 @@ export class TosComponent implements OnInit, AfterViewInit {
ngOnInit() {
this.titleService.setTitle('Terms of Service | itzMiney');
this.isMobile = this.deviceService.isMobile;
this.isNarrow = this.deviceService.isNarrow;
}
ngAfterViewInit() {