Added User Management to Admin Panel, reorganized some stuff

This commit is contained in:
itzMiney committed 2025-01-03 23:59:17 +01:00
1 parent d83992d3ce
commit 83260af2e6
22 files changed
+439 -36

No files matched your search

@@ -0,0 +1,115 @@
@keyframes fadeIn {
0% {
opacity: 0;
visibility: hidden;
}
100% {
opacity: 1;
visibility: visible;
}
}
#vanta-article-bg {
animation: fadeIn 1s ease-out;
position: fixed;
top: 0;
left: 0;
width: 100vw; /* Full viewport width */
height: 100vh; /* Full viewport height */
z-index: -100; /* Place the background behind content */
}
.height-container {
display: flex;
min-height: 100vh;
justify-content: center;
align-items: center;
text-align: center;
z-index: 10;
}
.article-container {
z-index: 1;
width: 100%;
min-height: 100vh;
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 50%, rgb(0, 0, 0) 100%);
padding: 30px;
justify-items: center;
align-items: center;
}
.content-container {
display: inline-grid;
max-width: 960px;
}
h1 {
font-size: 2.5rem;
color: #fff;
margin-top: 120px;
margin-bottom: 40px;
font-weight: 600;
}
.article-content {
font-size: 1.2rem;
color: #fff;
line-height: 1.8; /* Improve readability */
margin-bottom: 30px;
}
.article-meta {
font-size: 1rem;
color: #e6e6e6;
text-align: left;
}
.article-meta p {
margin: 8px 0;
}
.content-container button {
background-color: #713252;
color: #fff;
border: none;
padding: 10px 20px;
font-size: 1rem;
cursor: pointer;
border-radius: 25px;
transition: background-color 0.3s;
font-weight: 400;
margin-bottom: 20px;
}
.content-container button:hover {
background-color: #bf9bae;
}
.error-message h1 {
font-size: 10rem;
margin: 0;
font-weight: 700;
color: white;
}
.error-message p {
font-size: 1.5rem;
margin: 20px 0;
font-weight: 400;
color: white;
}
.error-message button {
background-color: #713252;
color: #fff;
border: none;
padding: 10px 20px;
font-size: 1rem;
cursor: pointer;
border-radius: 25px;
transition: background-color 0.3s;
font-weight: 400;
}
.error-message button:hover {
background-color: #bf9bae;
}
@@ -0,0 +1,29 @@
<div id="vanta-article-bg"></div>
<div class="height-container">
<div class="article-container" *ngIf="article; else error">
<div>
<!-- Article Title -->
<h1>{{ article.title }}</h1>
<div class="content-container">
<!-- Article Content -->
<div class="article-content" [innerHTML]="article.content"></div>
<a href="/blog"><button>Back to Overview</button></a>
<!-- Article Metadata -->
<div class="article-meta">
<p><strong>Author:</strong> {{ article.authorName}}</p>
<p><strong>Views:</strong> {{ article.views }}</p><br>
<p><strong>Created At:</strong> {{ article.createdAt | date:'MMM dd, yyyy, HH:mm' }}</p>
</div>
</div>
</div>
</div>
<!-- Error Message -->
<ng-template #error>
<div class="error-message">
<h1>404</h1>
<p>Article not found!</p>
<a href="/blog"><button>Back to Overview</button></a>
</div>
</ng-template>
</div>
@@ -0,0 +1,106 @@
import {AfterViewInit, Component, Inject, OnDestroy, OnInit, PLATFORM_ID} from '@angular/core';
import {DeviceDetectorService} from '../../services/device-detector.service'
import {DatePipe, isPlatformBrowser, NgIf} from '@angular/common';
import {VantaBackgroundService} from '../../services/vanta-background.service';
import {ArticleService} from '../../services/article.service';
import {ActivatedRoute} from '@angular/router';
import {Title} from '@angular/platform-browser';
interface Article {
id: number;
title: string;
slug: string;
content: string;
createdAt: string;
updatedAt: string;
views: number;
authorId: number;
authorName: string;
}
@Component({
selector: 'app-article-page',
imports: [
NgIf,
DatePipe
],
templateUrl: './article-page.component.html',
styleUrl: './article-page.component.css'
})
export class ArticlePageComponent implements OnInit, OnDestroy, AfterViewInit {
private readonly elementId = 'vanta-article-bg';
isMobile: boolean = false;
article: Article | undefined;
currentArticle: any;
constructor(
private deviceService: DeviceDetectorService,
private vantaService: VantaBackgroundService,
private articleService: ArticleService,
private titleService: Title,
private route: ActivatedRoute,
@Inject(PLATFORM_ID) private platformId: Object
) {
}
ngOnInit() {
this.isMobile = this.deviceService.isMobile;
this.route.params.subscribe((params) => {
const slug = params['slug'];
if (slug) {
this.loadTitleBySlug(slug);
} else {
this.titleService.setTitle('Article | itzMiney');
}
});
if (isPlatformBrowser(this.platformId)) {
window.addEventListener('resize', this.onResize.bind(this));
}
const slug = this.route.snapshot.paramMap.get('slug') || '';
this.articleService.getArticleBySlug(slug).subscribe(
(article) => {
this.article = article;
console.log('Article found!')
},
(error) => {
console.error('Error fetching article:', error);
}
);
}
ngAfterViewInit() {
this.vantaService.initVanta(this.elementId, {
color: 0xac1f4e,
backgroundColor: 0x191522
});
}
ngOnDestroy() {
this.vantaService.destroyVanta(this.elementId);
if (isPlatformBrowser(this.platformId)) {
window.removeEventListener('resize', this.onResize);
}
}
onResize() {
this.vantaService.resizeVanta(this.elementId);
}
loadTitleBySlug(slug: string) {
this.articleService.getArticleBySlug(slug).subscribe(
(article) => {
if (article) {
this.currentArticle = article;
this.titleService.setTitle( article.title );
} else {
console.warn('Article not found for slug:', slug);
this.titleService.setTitle('Article Not Found');
}
},
(error) => {
console.error('Failed to load article title', error);
this.titleService.setTitle('Error loading Article');
}
);
}
}