mirror of
https://github.com/a-mayb3/KanbanCloneAngular.git
synced 2026-03-21 09:55:37 +01:00
minor fixes
This commit is contained in:
parent
d1e016b7df
commit
d31630db18
5 changed files with 157 additions and 94 deletions
|
|
@ -3,48 +3,6 @@
|
||||||
background-color: #f5f7fa;
|
background-color: #f5f7fa;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
|
||||||
background: white;
|
|
||||||
padding: 20px 40px;
|
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header h1 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 24px;
|
|
||||||
color: #667eea;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-info {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.username {
|
|
||||||
font-weight: 500;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-logout {
|
|
||||||
padding: 8px 20px;
|
|
||||||
background-color: #667eea;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: 500;
|
|
||||||
transition: background-color 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-logout:hover {
|
|
||||||
background-color: #5568d3;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
padding: 40px;
|
padding: 40px;
|
||||||
max-width: 1400px;
|
max-width: 1400px;
|
||||||
|
|
@ -57,16 +15,92 @@
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.welcome-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16px;
|
||||||
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.welcome-message h2 {
|
.welcome-message h2 {
|
||||||
margin: 0 0 15px 0;
|
margin: 0 0 10px 0;
|
||||||
color: #333;
|
color: #333;
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-create {
|
||||||
|
padding: 10px 18px;
|
||||||
|
background-color: #10b981;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-create:hover {
|
||||||
|
background-color: #059669;
|
||||||
|
}
|
||||||
|
|
||||||
.welcome-message p {
|
.welcome-message p {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
color: #666;
|
color: #666;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Projects List */
|
||||||
|
.projects-grid {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading,
|
||||||
|
.error-state {
|
||||||
|
background: white;
|
||||||
|
padding: 30px 24px;
|
||||||
|
border-radius: 12px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-state p {
|
||||||
|
color: #c0392b;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading p {
|
||||||
|
color: #666;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-projects {
|
||||||
|
background: white;
|
||||||
|
padding: 60px 40px;
|
||||||
|
border-radius: 12px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-projects p {
|
||||||
|
margin: 0;
|
||||||
|
color: #95a5a6;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.create-link {
|
||||||
|
color: #10b981;
|
||||||
|
font-weight: 600;
|
||||||
|
text-decoration: underline;
|
||||||
|
text-underline-offset: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.create-link:hover {
|
||||||
|
color: #059669;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,27 @@
|
||||||
<div class="home-container">
|
<div class="home-container">
|
||||||
<header class="header">
|
|
||||||
<h1>Kanban Board</h1>
|
|
||||||
<div class="user-info">
|
|
||||||
@if (authService.currentUser()) {
|
|
||||||
<span class="username">{{ authService.currentUser()?.email }}</span>
|
|
||||||
<button class="btn-logout" (click)="logout()">Logout</button>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<main class="content">
|
<main class="content">
|
||||||
<div class="welcome-message">
|
<div class="welcome-message">
|
||||||
<h2>Welcome, {{ authService.currentUser()?.name }}! 👋</h2>
|
<div class="welcome-header">
|
||||||
|
<h2>Welcome, {{ authService.currentUser()?.name }}! 👋</h2>
|
||||||
|
<button class="btn-create" (click)="onCreateProject()">Create project</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="project-list">
|
<div class="projects-grid">
|
||||||
|
@if (projectList.length > 0) {
|
||||||
<ng-template *ngIf="projectList.length > 0; else noProjects">
|
@for (project of projectList; track project.id) {
|
||||||
<div class="project-item" *ngFor="let project of projectList">
|
<app-project-item [project]="project" (projectClick)="onProjectClick($event)" />
|
||||||
<h3>{{ project.name }}</h3>
|
}
|
||||||
<p>{{ project.description }}</p>
|
} @else {
|
||||||
</div>
|
<div class="no-projects">
|
||||||
</ng-template>
|
<p>
|
||||||
<ng-template #noProjects>
|
You have no projects.
|
||||||
<p>You have no projects yet. Create one to get started!</p>
|
<a class="create-link" href="#" (click)="onCreateProject(); $event.preventDefault()">
|
||||||
</ng-template>
|
Create one now
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,30 @@
|
||||||
import { Component, inject } from '@angular/core';
|
import { Component, inject } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { NgIf, NgFor } from '@angular/common';
|
import { Router } from '@angular/router';
|
||||||
import { AuthService } from '../../services/auth.service';
|
import { AuthService } from '../../services/auth.service';
|
||||||
|
import { ProjectItemComponent } from '../../components/project-item/project-item.component';
|
||||||
import { Project } from '../../models/projects.models';
|
import { Project } from '../../models/projects.models';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-home',
|
selector: 'app-home',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, NgIf, NgFor],
|
imports: [CommonModule, ProjectItemComponent],
|
||||||
templateUrl: './home.component.html',
|
templateUrl: './home.component.html',
|
||||||
styleUrl: './home.component.css'
|
styleUrl: './home.component.css'
|
||||||
})
|
})
|
||||||
export class HomeComponent {
|
export class HomeComponent {
|
||||||
protected authService = inject(AuthService);
|
protected authService = inject(AuthService);
|
||||||
|
private router = inject(Router);
|
||||||
|
|
||||||
protected projectList : Project[] = this.authService.currentUser()?.projects || [];
|
protected get projectList(): Project[] {
|
||||||
|
return this.authService.currentUser()?.projects ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
logout() {
|
onProjectClick(project: Project) {
|
||||||
this.authService.logout().subscribe();
|
this.router.navigate(['/projects', project.id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
onCreateProject() {
|
||||||
|
this.router.navigate(['/projects/new']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
<label for="email">e-mail address</label>
|
<label for="email">e-mail address</label>
|
||||||
<input
|
<input
|
||||||
id="email"
|
id="email"
|
||||||
type="email"
|
type="email"
|
||||||
[(ngModel)]="email"
|
[(ngModel)]="email"
|
||||||
name="email"
|
name="email"
|
||||||
placeholder="Enter your e-mail address"
|
placeholder="Enter your e-mail address"
|
||||||
|
|
|
||||||
|
|
@ -3,23 +3,45 @@ import { FormsModule } from '@angular/forms';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { AuthService } from '../../services/auth.service';
|
import { AuthService } from '../../services/auth.service';
|
||||||
|
import { catchError, of, throwError } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login',
|
selector: 'app-login',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [FormsModule, CommonModule],
|
imports: [FormsModule, CommonModule],
|
||||||
templateUrl: './login.component.html',
|
templateUrl: './login.component.html',
|
||||||
styleUrl: './login.component.css'
|
styleUrl: './login.component.css',
|
||||||
})
|
})
|
||||||
export class LoginComponent implements OnInit {
|
export class LoginComponent implements OnInit {
|
||||||
private authService = inject(AuthService);
|
private authService = inject(AuthService);
|
||||||
private router = inject(Router);
|
private router = inject(Router);
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
// If already logged in, redirect to home
|
|
||||||
if (this.authService.isAuthenticated()) {
|
if (this.authService.isAuthenticated()) {
|
||||||
this.router.navigate(['/']);
|
this.router.navigate(['/']);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.authService
|
||||||
|
.checkSession()
|
||||||
|
.pipe(
|
||||||
|
catchError((error) => {
|
||||||
|
if (error?.status === 401 || error?.status === 422) {
|
||||||
|
return of(null);
|
||||||
|
}
|
||||||
|
return throwError(() => error);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.subscribe({
|
||||||
|
next: (user) => {
|
||||||
|
if (user) {
|
||||||
|
this.router.navigate(['/']);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
this.errorMessage.set(error?.error?.message || 'Session check failed.');
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
email = '';
|
email = '';
|
||||||
|
|
@ -36,25 +58,27 @@ export class LoginComponent implements OnInit {
|
||||||
this.isLoading.set(true);
|
this.isLoading.set(true);
|
||||||
this.errorMessage.set('');
|
this.errorMessage.set('');
|
||||||
|
|
||||||
this.authService.login({
|
this.authService
|
||||||
email: this.email,
|
.login({
|
||||||
password: this.password
|
email: this.email,
|
||||||
}).subscribe({
|
password: this.password,
|
||||||
next: (response) => {
|
})
|
||||||
this.isLoading.set(false);
|
.subscribe({
|
||||||
if (response.success) {
|
next: (response) => {
|
||||||
// Redirect to home/dashboard after successful login
|
this.isLoading.set(false);
|
||||||
this.router.navigate(['/']);
|
if (response.success || response.user) {
|
||||||
} else {
|
// Redirect to home/dashboard after successful login
|
||||||
this.errorMessage.set(response.message || 'Login failed');
|
this.router.navigate(['/']);
|
||||||
}
|
} else {
|
||||||
},
|
this.errorMessage.set(response.message || 'Login failed');
|
||||||
error: (error) => {
|
}
|
||||||
this.isLoading.set(false);
|
},
|
||||||
this.errorMessage.set(
|
error: (error) => {
|
||||||
error.error?.message || 'Login failed. Please check your credentials.'
|
this.isLoading.set(false);
|
||||||
);
|
this.errorMessage.set(
|
||||||
}
|
error.error?.message || 'Login failed. Please check your credentials.',
|
||||||
});
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue