Added Services Page, ToS & Imprint

This commit is contained in:
itzMiney committed 2025-02-06 01:56:17 +01:00
1 parent 3b8fd5752e
commit 0b9596b534
29 files changed
+1038 -23

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
<footer>
<p>&#169; 2024 itzMiney</p>
<p><a href="mailto:itzminey@proton.ne">itzminey&#64;proton.me</a></p>
<p><a href="/tos">Terms of Service</a> &bull; <a href="/imprint">Imprint</a></p>
<!-- Optional: Add social media icons -->
<div class="social-icons">
@@ -12,6 +12,7 @@
<li><a [routerLink]="'/'" [class.active]="activeLink === '/'"><i class="fa-solid fa-address-card"></i>&#x2007;About</a></li>
<li><a [routerLink]="'/portfolio'" [class.active]="activeLink === '/portfolio'"><i class="fa-solid fa-image"></i>&#x2007;Portfolio</a></li>
<li><a [routerLink]="'/socials'" [class.active]="activeLink === '/socials'"><i class="fa-solid fa-hashtag"></i>&#x2007;Socials</a></li>
<li><a [routerLink]="'/services'" [class.active]="activeLink === '/services'"><i class="fa-solid fa-money-bill"></i>&#x2007;Services</a></li>
<li><a [routerLink]="'/blog'" [class.active]="activeLink === '/blog'"><i class="fa-solid fa-newspaper"></i>&#x2007;Blog</a></li>
</ul>
</div>
@@ -3,6 +3,7 @@
<a [routerLink]="'/'" [class.active]="activeLink === '/'">About</a>
<a [routerLink]="'/portfolio'" [class.active]="activeLink === '/portfolio'">Portfolio</a>
<a [routerLink]="'/socials'" [class.active]="activeLink === '/socials'">Socials</a>
<a [routerLink]="'/services'" [class.active]="activeLink === '/services'">Services</a>
<a [routerLink]="'/blog'" [class.active]="activeLink === '/blog'">Blog</a>
</div>
</nav>
@@ -0,0 +1,70 @@
import {Injectable} from '@angular/core';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {Observable} from 'rxjs';
import { map } from 'rxjs/operators';
interface Article {
id: number;
title: string;
slug: string;
content: string;
createdAt: string;
updatedAt: string;
views: number;
authorId: number;
authorName: string;
}
@Injectable({
providedIn: 'root'
})
export class ArticleService {
private apiUrl = '/api/articles';
constructor(private http: HttpClient) {}
getAllArticles(): Observable<Article[]> {
return this.http.get<Article[]>(`${this.apiUrl}?timestamp=${new Date().getTime()}`);
}
getArticleBySlug(slug: string): Observable<Article |undefined> {
return this.http.get<Article>(`${this.apiUrl}/slug/${slug}`).pipe(
map(article => article)
);
}
getArticleById(id: number): Observable<Article |undefined> {
return this.http.get<Article>(`${this.apiUrl}/id/${id}`).pipe(
map(article => article)
);
}
postArticle(token: string, title: string, content: string ): Observable<any[]> {
return this.http.post<any[]>(this.apiUrl, {
title,
content
},{
headers: {
'Authorization': `Bearer ${token}`
}
});
}
deleteArticle(id: number, token: string): Observable<boolean> {
const headers = new HttpHeaders().set('Authorization', `Bearer ${token}`);
return this.http.delete<any>(`${this.apiUrl}/${id}`, { headers }).pipe(
map((response) => {
// If the backend responds successfully, return true
return !!(response && response.message === 'Article deleted');
})
);
}
editArticle(id: number, token: string | null, title: string, content: string): Observable<any> {
const headers = new HttpHeaders().set('Authorization', `Bearer ${token}`);
const body = { title, content };
return this.http.put<any>(`${this.apiUrl}/${id}`, body, { headers });
}
}
+25
View File
@@ -0,0 +1,25 @@
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable, tap} from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class AuthService {
private apiUrl = '/api/auth/login';
constructor(private http: HttpClient) {}
login(username: string, password: string): Observable<any> {
return this.http.post(this.apiUrl, { username, password })
.pipe(
tap((response: any) => {
// Store token in localStorage after successful login
if (response.token) {
localStorage.setItem('token', response.token);
}
})
);
}
}
@@ -0,0 +1,24 @@
import {Inject, Injectable, PLATFORM_ID} from '@angular/core';
import {isPlatformBrowser} from '@angular/common';
@Injectable({
providedIn: 'root',
})
export class DeviceDetectorService {
isMobile: boolean = false;
constructor(@Inject(PLATFORM_ID) private platformId: Object) {
this.updateDeviceType();
if (isPlatformBrowser(this.platformId)) {
window.addEventListener('resize', () => this.updateDeviceType());
}
}
private updateDeviceType() {
if (isPlatformBrowser(this.platformId)) {
this.isMobile = window.innerWidth <= 768;
} else {
this.isMobile = false;
}
}
}
+64
View File
@@ -0,0 +1,64 @@
import { Injectable } from '@angular/core';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import { Observable } from 'rxjs';
import {map} from 'rxjs/operators';
interface Username {
id: number;
username: string;
password: string;
createdAt: string;
updatedAt: string;
}
@Injectable({
providedIn: 'root'
})
export class UserService {
private apiUrl = '/api/users';
constructor(private http: HttpClient) {}
getAllUsers(token: string | null): Observable<any[]> {
const headers = new HttpHeaders().set('Authorization', `Bearer ${token}`);
return this.http.get<any[]>(`${this.apiUrl}/?timestamp=${new Date().getTime()}`, { headers });
}
createUser(token: string, username: string, password: string): Observable<any> {
const headers = new HttpHeaders().set('Authorization', `Bearer ${token}`);
return this.http.post<any>(this.apiUrl, {
username,
password
}, { headers });
}
editUser(id: number, token: string | null, username: string, password: string): Observable<any> {
const headers = new HttpHeaders().set('Authorization', `Bearer ${token}`);
const body: any = {};
if (username) {
body.username = username
}
if (password) {
body.password = password;
}
return this.http.put<any>(`${this.apiUrl}/${id}`, body, { headers });
}
deleteUser(id: number, token: string): Observable<boolean> {
const headers = new HttpHeaders().set('Authorization', `Bearer ${token}`);
return this.http.delete<any>(`${this.apiUrl}/${id}`, { headers }).pipe(
map((response) => {
// If the backend responds successfully, return true
return !!(response && response.message === 'User deleted');
})
);
}
getUserById(id: number, token: string): Observable<Username | undefined> {
const headers = new HttpHeaders().set('Authorization', `Bearer ${token}`);
return this.http.get<Username>(`${this.apiUrl}/${id}`, { headers }).pipe(
map(user => user)
);
}
}
@@ -0,0 +1,52 @@
import {Inject, Injectable, PLATFORM_ID} from '@angular/core';
import {isPlatformBrowser} from '@angular/common';
@Injectable({
providedIn: 'root',
})
export class VantaBackgroundService {
private vantaEffect: Map<string, any> = new Map();
constructor(
@Inject(PLATFORM_ID) private platformId: Object,
) {}
initVanta(elementId: string, options?: any) {
if (isPlatformBrowser(this.platformId)) {
const element = document.getElementById(elementId);
if (element && !this.vantaEffect.has(elementId)) {
(window as any).VANTA.NET({
el: element,
mouseControls: false,
touchControls: false,
gyroControls: false,
scale: 1.0,
scaleMobile: 1.0,
points: 12.0,
maxDistance: 30.0,
spacing: 25.0,
showDots: false,
minWidth: window.innerWidth,
minHeight: window.innerHeight,
...(options || {}),
});
element.style.position = 'fixed';
}
}
}
resizeVanta(elementId: string): void {
const effect = this.vantaEffect.get(elementId);
if (effect) {
effect.resize();
}
}
destroyVanta(elementId: string): void {
const effect = this.vantaEffect.get(elementId);
if (effect) {
effect.destroy();
this.vantaEffect.delete(elementId);
}
}
}