Added backend request logic & admin page placeholders, along with some tweaks to frontend design
This commit is contained in:
1 parent
696181a772
commit
0907f0b66b
21 files changed
+446
-19
No files matched your search
+5
-2
@@ -13,6 +13,7 @@
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:application",
|
||||
"options": {
|
||||
"aot": true,
|
||||
"outputPath": "dist/itzmineydev",
|
||||
"index": "src/index.html",
|
||||
"browser": "src/main.ts",
|
||||
@@ -34,7 +35,8 @@
|
||||
},
|
||||
"configurations": {
|
||||
"csr": {
|
||||
"browser": "src/main.ts"
|
||||
"browser": "src/main.ts",
|
||||
"aot": true
|
||||
},
|
||||
"ssr": {
|
||||
"browser": "src/main.ts",
|
||||
@@ -42,7 +44,8 @@
|
||||
"outputMode": "server",
|
||||
"ssr": {
|
||||
"entry": "src/server.ts"
|
||||
}
|
||||
},
|
||||
"aot": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -13,11 +13,15 @@ a {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.height-container {
|
||||
min-height: 100vh;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
.about-container {
|
||||
position: relative;
|
||||
color: white;
|
||||
padding: 120px 20px;
|
||||
box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.1);
|
||||
max-width: 960px;
|
||||
margin: 0px auto 0px auto;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div id="vanta-about-bg"></div>
|
||||
|
||||
<div class="height-container">
|
||||
<div class="about-container">
|
||||
<ng-container *ngIf="!isMobile; else mobileContainer">
|
||||
<div class="about-header" *ngIf="!isMobile">
|
||||
@@ -66,3 +66,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,51 @@
|
||||
#admin-bg {
|
||||
transition: opacity 0.3s ease-in-out;
|
||||
background: #39354a;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw; /* Full viewport width */
|
||||
height: 100vh; /* Full viewport height */
|
||||
z-index: -100; /* Place the background behind content */
|
||||
}
|
||||
|
||||
.admin-container {
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
padding: 40px;
|
||||
width: 350px;
|
||||
text-align: center;
|
||||
margin: 50px auto;
|
||||
}
|
||||
|
||||
.height-container {
|
||||
min-height: 100vh;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
.admin-actions button {
|
||||
background-color: #4CAF50;
|
||||
color: white;
|
||||
padding: 12px 20px;
|
||||
margin: 10px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.admin-actions button:hover {
|
||||
background-color: #45a049;
|
||||
}
|
||||
|
||||
.articles-list {
|
||||
margin-top: 20px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.article {
|
||||
border: 1px solid #ccc;
|
||||
padding: 10px;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<div id="admin-bg"></div>
|
||||
<div class="height-container">
|
||||
<div class="admin-container">
|
||||
<h2>Admin Dashboard</h2>
|
||||
<div class="admin-actions">
|
||||
<button (click)="createArticle()">Create Article</button>
|
||||
<button (click)="viewArticles()">View Articles</button>
|
||||
<button (click)="logout()">Logout</button>
|
||||
</div>
|
||||
|
||||
<div *ngIf="articles && articles.length > 0">
|
||||
<h3>Articles</h3>
|
||||
<div class="articles-list">
|
||||
<div *ngFor="let article of articles" class="article">
|
||||
<h4>{{ article.title }}</h4>
|
||||
<p>{{ article.content }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,56 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { ArticleService } from '../article.service';
|
||||
import {NgFor, NgIf} from '@angular/common';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
|
||||
@Component({
|
||||
selector: 'app-admin',
|
||||
templateUrl: './admin.component.html',
|
||||
styleUrls: ['./admin.component.css'],
|
||||
imports: [
|
||||
NgIf,
|
||||
NgFor,
|
||||
HttpClientModule
|
||||
]
|
||||
})
|
||||
export class AdminComponent implements OnInit {
|
||||
articles: any[] = [];
|
||||
|
||||
constructor(private articleService: ArticleService, private router: Router) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.fetchArticles();
|
||||
}
|
||||
|
||||
// Fetch articles from backend
|
||||
fetchArticles() {
|
||||
const token = localStorage.getItem('token');
|
||||
if (!token) {
|
||||
this.router.navigate(['/login']); // Redirect to login if not logged in
|
||||
return;
|
||||
}
|
||||
|
||||
this.articleService.getArticles(token).subscribe(
|
||||
(data) => {
|
||||
this.articles = data;
|
||||
},
|
||||
(error) => {
|
||||
console.error('Failed to load articles', error);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
createArticle() {
|
||||
alert('Create article functionality goes here');
|
||||
}
|
||||
|
||||
viewArticles() {
|
||||
this.fetchArticles();
|
||||
}
|
||||
|
||||
logout() {
|
||||
localStorage.removeItem('token');
|
||||
this.router.navigate(['/login']); // Redirect to login page
|
||||
}
|
||||
}
|
||||
+12
-1
@@ -4,7 +4,18 @@ import { provideRouter } from '@angular/router';
|
||||
import { routes } from './app.routes';
|
||||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
||||
import { provideClientHydration, withEventReplay } from '@angular/platform-browser';
|
||||
import { provideHttpClient } from '@angular/common/http';
|
||||
import { AuthService } from './auth.service';
|
||||
import { AuthInterceptor } from './auth.interceptor';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), provideAnimationsAsync(), provideClientHydration(withEventReplay())]
|
||||
providers: [
|
||||
provideZoneChangeDetection({ eventCoalescing: true }),
|
||||
provideRouter(routes),
|
||||
provideAnimationsAsync(),
|
||||
provideClientHydration(withEventReplay()),
|
||||
provideHttpClient(),
|
||||
AuthService,
|
||||
AuthInterceptor
|
||||
]
|
||||
};
|
||||
@@ -20,5 +20,13 @@ export const serverRoutes: ServerRoute[] = [
|
||||
{
|
||||
path: '**',
|
||||
renderMode: RenderMode.Client,
|
||||
},
|
||||
{
|
||||
path: 'admin',
|
||||
renderMode: RenderMode.Client,
|
||||
},
|
||||
{
|
||||
path: 'login',
|
||||
renderMode: RenderMode.Client,
|
||||
}
|
||||
]
|
||||
@@ -3,6 +3,8 @@ import { AboutComponent } from './about/about.component';
|
||||
import { PortfolioComponent } from './portfolio/portfolio.component';
|
||||
import { BlogComponent } from './blog/blog.component';
|
||||
import {NotFoundComponent} from './not-found/not-found.component';
|
||||
import {LoginComponent} from './login/login.component';
|
||||
import {AdminComponent} from './admin/admin.component';
|
||||
|
||||
export const routes: Routes = [
|
||||
{
|
||||
@@ -49,6 +51,14 @@ export const routes: Routes = [
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'login',
|
||||
component: LoginComponent,
|
||||
},
|
||||
{
|
||||
path: 'admin',
|
||||
component: AdminComponent,
|
||||
},
|
||||
{
|
||||
path: '**',
|
||||
pathMatch: 'full',
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ArticleService {
|
||||
|
||||
private apiUrl = 'http://localhost:5000/api/articles'; // Replace with your API endpoint
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
getArticles(token: string): Observable<any[]> {
|
||||
return this.http.get<any[]>(this.apiUrl, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class AuthInterceptor implements HttpInterceptor {
|
||||
|
||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||
// Retrieve the token from localStorage
|
||||
const token = localStorage.getItem('token');
|
||||
|
||||
if (token) {
|
||||
// Clone the request and add the Authorization header
|
||||
const clonedRequest = req.clone({
|
||||
setHeaders: {
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
|
||||
// Pass the cloned request to the next handler
|
||||
return next.handle(clonedRequest);
|
||||
}
|
||||
|
||||
// If no token, continue without adding the Authorization header
|
||||
return next.handle(req);
|
||||
}
|
||||
}
|
||||
@@ -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 = 'http://localhost:5000/api/auth/login'; // Replace with your API endpoint
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
login(username: string, password: string): Observable<any> {
|
||||
return this.http.post('http://localhost:5000/api/auth/login', { username, password })
|
||||
.pipe(
|
||||
tap((response: any) => {
|
||||
// Store token in localStorage after successful login
|
||||
if (response.token) {
|
||||
localStorage.setItem('token', response.token);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,9 @@
|
||||
z-index: -100; /* Place the background behind content */
|
||||
}
|
||||
|
||||
.container {
|
||||
.height-container {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
min-height: 100vh;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div id="vanta-blog-bg"></div>
|
||||
<div class="container" id="container">
|
||||
<div class="height-container">
|
||||
<ng-container *ngIf="!isMobile; else mobileError">
|
||||
<div class="error-message">
|
||||
<h2>Soon™</h2>
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#vanta-login-bg {
|
||||
transition: opacity 0.3s ease-in-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 {
|
||||
min-height: 100vh;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
/* Login Form Styles */
|
||||
.login-container {
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
padding: 40px;
|
||||
width: 300px;
|
||||
text-align: center;
|
||||
margin: 0px auto 0px auto;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
button {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
background-color: #4CAF50;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #45a049;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
color: red;
|
||||
font-size: 14px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<div id="vanta-login-bg"></div>
|
||||
|
||||
<div class="height-container">
|
||||
<div class="login-container">
|
||||
<h2>Login</h2>
|
||||
<form (ngSubmit)="onLogin()" #loginForm="ngForm">
|
||||
<label for="username">Username:</label>
|
||||
<input type="text" id="username" name="username" [(ngModel)]="username" required placeholder="Enter your username">
|
||||
|
||||
<label for="password">Password:</label>
|
||||
<input type="password" id="password" name="password" [(ngModel)]="password" required placeholder="Enter your password">
|
||||
|
||||
<button type="submit" [disabled]="!loginForm.valid">Login</button>
|
||||
</form>
|
||||
<p *ngIf="errorMessage" class="error-message">{{ errorMessage }}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,101 @@
|
||||
import {Component, OnInit, OnDestroy, AfterViewInit, Inject} from '@angular/core';
|
||||
import { AuthService } from '../auth.service';
|
||||
import { Router } from '@angular/router';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {NgIf} from '@angular/common';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { isPlatformBrowser } from '@angular/common';
|
||||
import { PLATFORM_ID } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
templateUrl: './login.component.html',
|
||||
styleUrls: ['./login.component.css'],
|
||||
imports: [
|
||||
FormsModule,
|
||||
NgIf,
|
||||
HttpClientModule
|
||||
]
|
||||
})
|
||||
|
||||
export class LoginComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
username: string = '';
|
||||
password: string = '';
|
||||
errorMessage: string = '';
|
||||
private vantaEffect: any;
|
||||
|
||||
constructor(
|
||||
private authService: AuthService,
|
||||
private router: Router,
|
||||
@Inject(PLATFORM_ID) private platformId: Object
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
window.addEventListener('resize', this.onResize.bind(this));
|
||||
|
||||
const bgElement = document.getElementById('vanta-login-bg');
|
||||
if (bgElement) {
|
||||
bgElement.style.position = 'fixed';
|
||||
}
|
||||
}
|
||||
|
||||
onLogin() {
|
||||
this.authService.login(this.username, this.password).subscribe(
|
||||
(response: any) => {
|
||||
localStorage.setItem('token', response.token);
|
||||
this.router.navigate(['/admin']); // Redirect to admin page
|
||||
},
|
||||
() => {
|
||||
this.errorMessage = 'Invalid credentials';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
// Initialize VANTA effect only in the browser
|
||||
this.initVanta();
|
||||
this.resizeVanta();
|
||||
}
|
||||
}
|
||||
ngOnDestroy() {
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
if (this.vantaEffect) {
|
||||
this.vantaEffect.destroy(); // Clean up the effect on destroy
|
||||
}
|
||||
window.removeEventListener('resize', this.onResize); // Remove the listener when the component is destroyed
|
||||
}
|
||||
}
|
||||
|
||||
initVanta() {
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
// Initialize the Vanta effect on the element with ID 'vanta-bg'
|
||||
this.vantaEffect = window.VANTA.NET({
|
||||
el: '#vanta-login-bg',
|
||||
mouseControls: true,
|
||||
touchControls: true,
|
||||
gyroControls: false,
|
||||
scale: 1.00,
|
||||
scaleMobile: 1.00,
|
||||
points: 20.00,
|
||||
maxDistance: 25.00,
|
||||
spacing: 18.00,
|
||||
showDots: false,
|
||||
minWidth: window.innerWidth,
|
||||
minHeight: window.innerHeight,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onResize() {
|
||||
// Update the minHeight and minWidth when the window is resized
|
||||
this.resizeVanta();
|
||||
}
|
||||
|
||||
resizeVanta() {
|
||||
if (this.vantaEffect) {
|
||||
// Trigger the resize on the vanta effect
|
||||
this.vantaEffect.resize();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,9 @@
|
||||
z-index: -100; /* Place the background behind content */
|
||||
}
|
||||
|
||||
.container {
|
||||
.height-container {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
min-height: 100vh;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
@@ -38,7 +38,7 @@ button {
|
||||
padding: 10px 20px;
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
border-radius: 5px;
|
||||
border-radius: 25px;
|
||||
transition: background-color 0.3s;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div id="vanta-not-found-bg"></div>
|
||||
<div class="container" id="container">
|
||||
<div class="height-container">
|
||||
<div class="error-message">
|
||||
<h1>404</h1>
|
||||
<p>Oops! You got lost in space.</p>
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
font-family: 'Roboto', sans-serif;
|
||||
}
|
||||
|
||||
.height-container {
|
||||
min-height: 100vh;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
.portfolio-header {
|
||||
text-align: center;
|
||||
}
|
||||
@@ -83,9 +88,10 @@
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.portfolio-footer {
|
||||
.commission-button {
|
||||
text-align: center;
|
||||
margin-top: 50px;
|
||||
margin-top: 30px;
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
.ko-fi-btn {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<div id="vanta-portfolio-bg"></div>
|
||||
<div class="height-container">
|
||||
<div class="portfolio-container">
|
||||
<ng-container *ngIf="!isMobile; else mobileContainer">
|
||||
<div class="portfolio-header" *ngIf="!isMobile">
|
||||
@@ -18,9 +19,14 @@
|
||||
I mostly do modern graphic designs since a couple years now,
|
||||
but I'm also getting better at coding and you might soon see a couple little coding projects from my <a href="https://github.com/itzminey">GitHub</a> listed here too!<br>
|
||||
If you like what I do consider following me on my <a href="https://linktr.ee/itzminey">socials</a> and if you feel really generous leave a tip on my <a href="https://ko-fi.com/itzminey">Ko-Fi!</a><br>
|
||||
You can also commission me to make designs for you, just click on the button at the end of this page!
|
||||
You can also commission me to make designs for you, just click on the button below!
|
||||
</p>
|
||||
</div>
|
||||
<div class="commission-button">
|
||||
<a href="https://ko-fi.com/itzminey/commissions" target="_blank">
|
||||
<button class="ko-fi-btn">Commission me on Ko-Fi</button>
|
||||
</a>
|
||||
</div>
|
||||
<div class="portfolio-gallery">
|
||||
<div class="gallery-item">
|
||||
<img src="/assets/design1.png" alt="Design 1">
|
||||
@@ -47,9 +53,5 @@
|
||||
<p>Logo Design</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="portfolio-footer">
|
||||
<a href="https://ko-fi.com/itzminey/commissions" target="_blank">
|
||||
<button class="ko-fi-btn">Commission me on Ko-Fi</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user