diff --git a/angular.json b/angular.json index 05c7df7..7dadd9b 100644 --- a/angular.json +++ b/angular.json @@ -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 } } }, diff --git a/src/app/about/about.component.css b/src/app/about/about.component.css index b5e12fe..8d3f0bf 100644 --- a/src/app/about/about.component.css +++ b/src/app/about/about.component.css @@ -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; diff --git a/src/app/about/about.component.html b/src/app/about/about.component.html index 9238198..57f3402 100644 --- a/src/app/about/about.component.html +++ b/src/app/about/about.component.html @@ -1,5 +1,5 @@
- +
@@ -66,3 +66,4 @@
+ diff --git a/src/app/admin/admin.component.css b/src/app/admin/admin.component.css new file mode 100644 index 0000000..370a072 --- /dev/null +++ b/src/app/admin/admin.component.css @@ -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; +} diff --git a/src/app/admin/admin.component.html b/src/app/admin/admin.component.html new file mode 100644 index 0000000..6f83c59 --- /dev/null +++ b/src/app/admin/admin.component.html @@ -0,0 +1,21 @@ +
+
+
+

Admin Dashboard

+
+ + + +
+ +
+

Articles

+
+
+

{{ article.title }}

+

{{ article.content }}

+
+
+
+
+
diff --git a/src/app/admin/admin.component.ts b/src/app/admin/admin.component.ts new file mode 100644 index 0000000..a32498c --- /dev/null +++ b/src/app/admin/admin.component.ts @@ -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 + } +} diff --git a/src/app/app.config.ts b/src/app/app.config.ts index cb5d489..eb5928b 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -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 + ] }; diff --git a/src/app/app.routes.server.ts b/src/app/app.routes.server.ts index 315c116..f40376e 100644 --- a/src/app/app.routes.server.ts +++ b/src/app/app.routes.server.ts @@ -20,5 +20,13 @@ export const serverRoutes: ServerRoute[] = [ { path: '**', renderMode: RenderMode.Client, + }, + { + path: 'admin', + renderMode: RenderMode.Client, + }, + { + path: 'login', + renderMode: RenderMode.Client, } ] diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index b30560c..c5c19c8 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -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', diff --git a/src/app/article.service.ts b/src/app/article.service.ts new file mode 100644 index 0000000..4c2fec1 --- /dev/null +++ b/src/app/article.service.ts @@ -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 { + return this.http.get(this.apiUrl, { + headers: { + 'Authorization': `Bearer ${token}` + } + }); + } +} diff --git a/src/app/auth.interceptor.ts b/src/app/auth.interceptor.ts new file mode 100644 index 0000000..e584568 --- /dev/null +++ b/src/app/auth.interceptor.ts @@ -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, next: HttpHandler): Observable> { + // 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); + } +} diff --git a/src/app/auth.service.ts b/src/app/auth.service.ts new file mode 100644 index 0000000..2f4768e --- /dev/null +++ b/src/app/auth.service.ts @@ -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 { + 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); + } + }) + ); + } +} diff --git a/src/app/blog/blog.component.css b/src/app/blog/blog.component.css index 99b7ace..c75e2a3 100644 --- a/src/app/blog/blog.component.css +++ b/src/app/blog/blog.component.css @@ -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; diff --git a/src/app/blog/blog.component.html b/src/app/blog/blog.component.html index bdbb2ce..837af9b 100644 --- a/src/app/blog/blog.component.html +++ b/src/app/blog/blog.component.html @@ -1,5 +1,5 @@
-
+

Soon™

diff --git a/src/app/login/login.component.css b/src/app/login/login.component.css new file mode 100644 index 0000000..f7fad06 --- /dev/null +++ b/src/app/login/login.component.css @@ -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; +} diff --git a/src/app/login/login.component.html b/src/app/login/login.component.html new file mode 100644 index 0000000..2636d85 --- /dev/null +++ b/src/app/login/login.component.html @@ -0,0 +1,17 @@ +
+ +
+ +
diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts new file mode 100644 index 0000000..6453366 --- /dev/null +++ b/src/app/login/login.component.ts @@ -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(); + } + } +} diff --git a/src/app/not-found/not-found.component.css b/src/app/not-found/not-found.component.css index c8f27a2..e6b8f79 100644 --- a/src/app/not-found/not-found.component.css +++ b/src/app/not-found/not-found.component.css @@ -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; } diff --git a/src/app/not-found/not-found.component.html b/src/app/not-found/not-found.component.html index f4cc621..7072920 100644 --- a/src/app/not-found/not-found.component.html +++ b/src/app/not-found/not-found.component.html @@ -1,5 +1,5 @@
-
+

404

Oops! You got lost in space.

diff --git a/src/app/portfolio/portfolio.component.css b/src/app/portfolio/portfolio.component.css index a747657..c73189b 100644 --- a/src/app/portfolio/portfolio.component.css +++ b/src/app/portfolio/portfolio.component.css @@ -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 { diff --git a/src/app/portfolio/portfolio.component.html b/src/app/portfolio/portfolio.component.html index 48d65cf..492fd6e 100644 --- a/src/app/portfolio/portfolio.component.html +++ b/src/app/portfolio/portfolio.component.html @@ -1,4 +1,5 @@
+
@@ -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 GitHub listed here too!
If you like what I do consider following me on my socials and if you feel really generous leave a tip on my Ko-Fi!
- 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!

+ - +