improvements
This commit is contained in:
parent
7319a17837
commit
ac95677b18
@ -1,10 +1,18 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { Component, computed, inject } from '@angular/core';
|
import { Component, computed, inject } from '@angular/core';
|
||||||
import { FormsModule } from '@angular/forms';
|
import {
|
||||||
|
FormBuilder,
|
||||||
|
FormGroup,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
Validators,
|
||||||
|
} from '@angular/forms';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { MessageService } from 'primeng/api';
|
||||||
import { ButtonModule } from 'primeng/button';
|
import { ButtonModule } from 'primeng/button';
|
||||||
|
import { CardModule } from 'primeng/card';
|
||||||
import { InputTextModule } from 'primeng/inputtext';
|
import { InputTextModule } from 'primeng/inputtext';
|
||||||
import { MultiSelectModule } from 'primeng/multiselect';
|
import { MultiSelectModule } from 'primeng/multiselect';
|
||||||
|
import { ToastModule } from 'primeng/toast';
|
||||||
import { StudentService } from './student.service';
|
import { StudentService } from './student.service';
|
||||||
import { LocaleStore } from './translations/locale.service';
|
import { LocaleStore } from './translations/locale.service';
|
||||||
|
|
||||||
@ -13,54 +21,97 @@ import { LocaleStore } from './translations/locale.service';
|
|||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
FormsModule,
|
ReactiveFormsModule,
|
||||||
InputTextModule,
|
InputTextModule,
|
||||||
MultiSelectModule,
|
MultiSelectModule,
|
||||||
ButtonModule,
|
ButtonModule,
|
||||||
|
CardModule,
|
||||||
|
ToastModule,
|
||||||
],
|
],
|
||||||
|
providers: [MessageService],
|
||||||
template: `
|
template: `
|
||||||
<div class="card-container">
|
<div class="form-container">
|
||||||
|
<p-card styleClass="form-card">
|
||||||
|
<ng-template pTemplate="header">
|
||||||
|
<div class="card-header">
|
||||||
|
<i class="pi pi-user-plus header-icon"></i>
|
||||||
<h2 class="page-title">Add New Student</h2>
|
<h2 class="page-title">Add New Student</h2>
|
||||||
<form (ngSubmit)="submit()" #f="ngForm">
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
<ng-template pTemplate="content">
|
||||||
|
<form
|
||||||
|
[formGroup]="studentForm"
|
||||||
|
(ngSubmit)="submit()"
|
||||||
|
class="student-form"
|
||||||
|
>
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<label for="name">Name:</label>
|
<label for="name" class="form-label">
|
||||||
|
<i class="pi pi-user field-icon"></i>
|
||||||
|
Full Name
|
||||||
|
</label>
|
||||||
<input
|
<input
|
||||||
id="name"
|
id="name"
|
||||||
pInputText
|
pInputText
|
||||||
[(ngModel)]="name"
|
formControlName="name"
|
||||||
name="name"
|
placeholder="Enter student's full name"
|
||||||
required
|
class="form-input"
|
||||||
placeholder="Enter student name"
|
[class.ng-invalid]="isFieldInvalid('name')"
|
||||||
|
[class.ng-dirty]="isFieldInvalid('name')"
|
||||||
/>
|
/>
|
||||||
|
<div *ngIf="isFieldInvalid('name')" class="error-message">
|
||||||
|
<i class="pi pi-exclamation-triangle"></i>
|
||||||
|
{{ getFieldError('name') }}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<label for="email">Email:</label>
|
<label for="email" class="form-label">
|
||||||
|
<i class="pi pi-envelope field-icon"></i>
|
||||||
|
Email Address
|
||||||
|
</label>
|
||||||
<input
|
<input
|
||||||
id="email"
|
id="email"
|
||||||
pInputText
|
pInputText
|
||||||
[(ngModel)]="email"
|
|
||||||
name="email"
|
|
||||||
required
|
|
||||||
type="email"
|
type="email"
|
||||||
placeholder="Enter student email"
|
formControlName="email"
|
||||||
|
placeholder="Enter student's email address"
|
||||||
|
class="form-input"
|
||||||
|
[class.ng-invalid]="isFieldInvalid('email')"
|
||||||
|
[class.ng-dirty]="isFieldInvalid('email')"
|
||||||
/>
|
/>
|
||||||
|
<div *ngIf="isFieldInvalid('email')" class="error-message">
|
||||||
|
<i class="pi pi-exclamation-triangle"></i>
|
||||||
|
{{ getFieldError('email') }}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<label for="courses">Courses:</label>
|
<label for="courses" class="form-label">
|
||||||
|
<i class="pi pi-book field-icon"></i>
|
||||||
|
Courses
|
||||||
|
</label>
|
||||||
<p-multiselect
|
<p-multiselect
|
||||||
id="courses"
|
id="courses"
|
||||||
[options]="courseOptions()"
|
[options]="courseOptions()"
|
||||||
[(ngModel)]="selectedCourses"
|
formControlName="courses"
|
||||||
name="courses"
|
placeholder="Select courses for the student"
|
||||||
placeholder="Select Courses"
|
|
||||||
[showToggleAll]="true"
|
[showToggleAll]="true"
|
||||||
|
[class.ng-invalid]="isFieldInvalid('courses')"
|
||||||
|
[class.ng-dirty]="isFieldInvalid('courses')"
|
||||||
|
styleClass="form-multiselect"
|
||||||
></p-multiselect>
|
></p-multiselect>
|
||||||
|
<div *ngIf="isFieldInvalid('courses')" class="error-message">
|
||||||
|
<i class="pi pi-exclamation-triangle"></i>
|
||||||
|
{{ getFieldError('courses') }}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button
|
<button
|
||||||
pButton
|
pButton
|
||||||
type="button"
|
type="button"
|
||||||
label="Cancel"
|
label="Cancel"
|
||||||
|
icon="pi pi-times"
|
||||||
class="p-button-outlined"
|
class="p-button-outlined"
|
||||||
(click)="cancel()"
|
(click)="cancel()"
|
||||||
></button>
|
></button>
|
||||||
@ -70,48 +121,172 @@ import { LocaleStore } from './translations/locale.service';
|
|||||||
label="Add Student"
|
label="Add Student"
|
||||||
icon="pi pi-user-plus"
|
icon="pi pi-user-plus"
|
||||||
class="p-button-primary"
|
class="p-button-primary"
|
||||||
[disabled]="f.invalid"
|
[disabled]="studentForm.invalid || isSubmitting"
|
||||||
|
[loading]="isSubmitting"
|
||||||
></button>
|
></button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
</ng-template>
|
||||||
|
</p-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p-toast></p-toast>
|
||||||
`,
|
`,
|
||||||
styles: [
|
styles: [
|
||||||
`
|
`
|
||||||
|
.form-container {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 2rem auto;
|
||||||
|
padding: 0 var(--spacing-md);
|
||||||
|
}
|
||||||
|
|
||||||
:host ::ng-deep {
|
:host ::ng-deep {
|
||||||
.p-inputtext:enabled:focus {
|
.form-card {
|
||||||
border-color: var(--primary-color);
|
border-radius: var(--border-radius);
|
||||||
box-shadow: var(--focus-ring);
|
box-shadow: var(--card-shadow);
|
||||||
|
background: var(--card-background);
|
||||||
|
border: 1px solid var(--table-border-color);
|
||||||
|
|
||||||
|
.p-card-header {
|
||||||
|
background: linear-gradient(
|
||||||
|
135deg,
|
||||||
|
var(--primary-color),
|
||||||
|
var(--primary-light)
|
||||||
|
);
|
||||||
|
color: #ffffff !important;
|
||||||
|
padding: var(--spacing-lg);
|
||||||
|
border-radius: var(--border-radius) var(--border-radius) 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-multiselect:not(.p-disabled).p-focus {
|
.p-card-body {
|
||||||
border-color: var(--primary-color);
|
padding: var(--spacing-xl);
|
||||||
box-shadow: var(--focus-ring);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-inputtext,
|
.form-input,
|
||||||
.p-multiselect {
|
.form-multiselect {
|
||||||
|
width: 100%;
|
||||||
background-color: var(--card-background) !important;
|
background-color: var(--card-background) !important;
|
||||||
color: var(--text-color) !important;
|
color: var(--text-color) !important;
|
||||||
border-radius: var(--input-radius) !important;
|
border-radius: var(--input-radius) !important;
|
||||||
border: 1px solid var(--table-border-color) !important;
|
border: 1px solid var(--table-border-color) !important;
|
||||||
transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s,
|
transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s,
|
||||||
color 0.3s;
|
color 0.3s;
|
||||||
|
padding: var(--spacing-sm) var(--spacing-md) !important;
|
||||||
|
|
||||||
|
&:enabled:focus {
|
||||||
|
border-color: var(--primary-color) !important;
|
||||||
|
box-shadow: var(--focus-ring) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-inputtext:enabled:hover,
|
&:enabled:hover {
|
||||||
.p-multiselect:not(.p-disabled):hover {
|
border-color: var(--primary-light) !important;
|
||||||
border-color: var(--primary-light);
|
}
|
||||||
|
|
||||||
|
&.ng-invalid.ng-dirty {
|
||||||
|
border-color: #e24c4c !important;
|
||||||
|
box-shadow: 0 0 0 2px rgba(226, 76, 76, 0.2) !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-container {
|
.p-multiselect {
|
||||||
max-width: 480px;
|
min-height: 2.5rem;
|
||||||
margin: 2rem auto;
|
|
||||||
|
.p-multiselect-label {
|
||||||
|
color: var(--text-color) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-multiselect-trigger {
|
||||||
|
color: var(--text-secondary) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-icon {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
color: #ffffff !important;
|
||||||
|
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-title {
|
||||||
|
margin: 0;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
color: #ffffff !important;
|
||||||
|
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.student-form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--spacing-lg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-field {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--spacing-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-sm);
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-color);
|
||||||
|
letter-spacing: 0.2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-icon {
|
||||||
|
color: var(--primary-color);
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-message {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-xs);
|
||||||
|
color: #e24c4c;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
margin-top: var(--spacing-xs);
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-actions {
|
.form-actions {
|
||||||
margin-top: var(--spacing-lg);
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: var(--spacing-md);
|
||||||
|
margin-top: var(--spacing-xl);
|
||||||
|
padding-top: var(--spacing-lg);
|
||||||
|
border-top: 1px solid var(--table-border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.form-container {
|
||||||
|
margin: 1rem auto;
|
||||||
|
padding: 0 var(--spacing-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
:host ::ng-deep {
|
||||||
|
.form-card .p-card-body {
|
||||||
|
padding: var(--spacing-lg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-actions {
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.p-button {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
],
|
],
|
||||||
@ -120,10 +295,16 @@ export class AddStudentComponent {
|
|||||||
private readonly studentService = inject(StudentService);
|
private readonly studentService = inject(StudentService);
|
||||||
private readonly localeStore = inject(LocaleStore);
|
private readonly localeStore = inject(LocaleStore);
|
||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
|
private readonly fb = inject(FormBuilder);
|
||||||
|
private readonly messageService = inject(MessageService);
|
||||||
|
|
||||||
protected name = '';
|
protected isSubmitting = false;
|
||||||
protected email = '';
|
|
||||||
protected selectedCourses: string[] = [];
|
protected studentForm: FormGroup = this.fb.group({
|
||||||
|
name: ['', [Validators.required, Validators.minLength(2)]],
|
||||||
|
email: ['', [Validators.required, Validators.email]],
|
||||||
|
courses: [[], [Validators.required, Validators.minLength(1)]],
|
||||||
|
});
|
||||||
|
|
||||||
protected courseOptions = computed(() => {
|
protected courseOptions = computed(() => {
|
||||||
return [
|
return [
|
||||||
@ -135,16 +316,63 @@ export class AddStudentComponent {
|
|||||||
'History',
|
'History',
|
||||||
'Literature',
|
'Literature',
|
||||||
'Physical Education',
|
'Physical Education',
|
||||||
|
'Art',
|
||||||
|
'Music',
|
||||||
|
'Geography',
|
||||||
|
'Economics',
|
||||||
].map((course) => ({ label: course, value: course }));
|
].map((course) => ({ label: course, value: course }));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
protected isFieldInvalid(fieldName: string): boolean {
|
||||||
|
const field = this.studentForm.get(fieldName);
|
||||||
|
return field ? field.invalid && field.dirty : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getFieldError(fieldName: string): string {
|
||||||
|
const field = this.studentForm.get(fieldName);
|
||||||
|
if (!field || !field.errors) return '';
|
||||||
|
|
||||||
|
if (field.errors['required']) return `${fieldName} is required`;
|
||||||
|
if (field.errors['email']) return 'Please enter a valid email address';
|
||||||
|
if (field.errors['minlength']) {
|
||||||
|
const requiredLength = field.errors['minlength'].requiredLength;
|
||||||
|
return `${fieldName} must be at least ${requiredLength} characters`;
|
||||||
|
}
|
||||||
|
if (field.errors['minLength']) return `Please select at least one course`;
|
||||||
|
|
||||||
|
return 'Invalid input';
|
||||||
|
}
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
|
if (this.studentForm.valid) {
|
||||||
|
this.isSubmitting = true;
|
||||||
|
|
||||||
|
const formValue = this.studentForm.value;
|
||||||
this.studentService.addStudent({
|
this.studentService.addStudent({
|
||||||
name: this.name,
|
name: formValue.name,
|
||||||
email: this.email,
|
email: formValue.email,
|
||||||
courses: this.selectedCourses,
|
courses: formValue.courses,
|
||||||
});
|
});
|
||||||
this.router.navigate([`/${this.localeStore.getCurrentLocale()}/students`]);
|
|
||||||
|
this.messageService.add({
|
||||||
|
severity: 'success',
|
||||||
|
summary: 'Success',
|
||||||
|
detail: `Student ${formValue.name} has been added successfully`,
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.router.navigate([
|
||||||
|
`/${this.localeStore.getCurrentLocale()}/students`,
|
||||||
|
]);
|
||||||
|
}, 1000);
|
||||||
|
} else {
|
||||||
|
this.studentForm.markAllAsTouched();
|
||||||
|
this.messageService.add({
|
||||||
|
severity: 'error',
|
||||||
|
summary: 'Validation Error',
|
||||||
|
detail: 'Please fix the errors in the form',
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
|
|||||||
@ -1,77 +1,79 @@
|
|||||||
import { Component, computed, inject, OnInit } from '@angular/core';
|
import { Component, computed, inject, OnInit } from '@angular/core';
|
||||||
import { RouterLink, RouterOutlet } from '@angular/router';
|
import { RouterOutlet } from '@angular/router';
|
||||||
import { stored } from '@mmstack/primitives';
|
import { stored } from '@mmstack/primitives';
|
||||||
import { ButtonModule } from 'primeng/button';
|
import { ButtonModule } from 'primeng/button';
|
||||||
import { OverlayPanelModule } from 'primeng/overlaypanel';
|
import { MenubarModule } from 'primeng/menubar';
|
||||||
|
import { PopoverModule } from 'primeng/popover';
|
||||||
import { TooltipModule } from 'primeng/tooltip';
|
import { TooltipModule } from 'primeng/tooltip';
|
||||||
|
import { injectAppT } from './translations/app.t';
|
||||||
import { LocaleStore } from './translations/locale.service';
|
import { LocaleStore } from './translations/locale.service';
|
||||||
|
import { AppTranslatePipe } from './translations/translate.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
RouterOutlet,
|
RouterOutlet,
|
||||||
RouterLink,
|
|
||||||
ButtonModule,
|
ButtonModule,
|
||||||
OverlayPanelModule,
|
MenubarModule,
|
||||||
|
PopoverModule,
|
||||||
TooltipModule,
|
TooltipModule,
|
||||||
|
AppTranslatePipe,
|
||||||
],
|
],
|
||||||
template: `
|
template: `
|
||||||
<header class="navbar">
|
<p-menubar [model]="menuItems()" styleClass="custom-menubar">
|
||||||
<div class="navbar-left">
|
<ng-template pTemplate="start">
|
||||||
<span class="app-title">StudentInfo</span>
|
<div class="logo-container">
|
||||||
|
<i class="pi pi-graduation-cap logo-icon"></i>
|
||||||
|
<span class="logo-text">StudentInfo</span>
|
||||||
</div>
|
</div>
|
||||||
<nav class="navbar-center">
|
</ng-template>
|
||||||
<a [routerLink]="overviewUrl()" routerLinkActive="active">Overview</a>
|
<ng-template pTemplate="end">
|
||||||
<a [routerLink]="addStudentUrl()" routerLinkActive="active"
|
<div class="user-actions">
|
||||||
>Add Student</a
|
|
||||||
>
|
|
||||||
</nav>
|
|
||||||
<div class="navbar-right">
|
|
||||||
<button
|
<button
|
||||||
pButton
|
pButton
|
||||||
class="p-button-text p-button-rounded theme-toggle-btn"
|
class="p-button-text p-button-rounded theme-toggle-btn"
|
||||||
[icon]="isDarkMode() ? 'pi pi-sun' : 'pi pi-moon'"
|
[icon]="isDarkMode() ? 'pi pi-sun' : 'pi pi-moon'"
|
||||||
(click)="toggleTheme()"
|
(click)="toggleTheme()"
|
||||||
pTooltip="Toggle theme"
|
[pTooltip]="'app.toggleTheme' | translate"
|
||||||
tooltipPosition="bottom"
|
tooltipPosition="bottom"
|
||||||
></button>
|
></button>
|
||||||
<!-- Language Selector Button -->
|
|
||||||
<button
|
<button
|
||||||
pButton
|
pButton
|
||||||
type="button"
|
type="button"
|
||||||
[label]="currentLocale() === 'en' ? 'EN' : 'SL'"
|
[label]="currentLocale() === 'en' ? 'EN' : 'SL'"
|
||||||
class="p-button-rounded p-button-text language-selector"
|
class="p-button-rounded p-button-text language-selector"
|
||||||
(click)="languagePanel.toggle($event)"
|
(click)="languagePopover.toggle($event)"
|
||||||
pTooltip="Change language"
|
[pTooltip]="'app.changeLanguage' | translate"
|
||||||
tooltipPosition="bottom"
|
tooltipPosition="bottom"
|
||||||
></button>
|
></button>
|
||||||
|
<p-popover #languagePopover>
|
||||||
<!-- Language Selection Panel -->
|
|
||||||
<p-overlayPanel #languagePanel>
|
|
||||||
<div class="language-options">
|
<div class="language-options">
|
||||||
<button
|
<button
|
||||||
pButton
|
pButton
|
||||||
type="button"
|
type="button"
|
||||||
label="English"
|
[label]="'app.english' | translate"
|
||||||
(click)="changeLanguage('en'); languagePanel.hide()"
|
(click)="changeLanguage('en'); languagePopover.hide()"
|
||||||
[class.active]="currentLocale() === 'en'"
|
[class.active]="currentLocale() === 'en'"
|
||||||
class="p-button-text w-full text-left"
|
class="p-button-text w-full text-left"
|
||||||
></button>
|
></button>
|
||||||
<button
|
<button
|
||||||
pButton
|
pButton
|
||||||
type="button"
|
type="button"
|
||||||
label="Slovenian"
|
[label]="'app.slovenian' | translate"
|
||||||
(click)="changeLanguage('sl'); languagePanel.hide()"
|
(click)="changeLanguage('sl'); languagePopover.hide()"
|
||||||
[class.active]="currentLocale() === 'sl'"
|
[class.active]="currentLocale() === 'sl'"
|
||||||
class="p-button-text w-full text-left"
|
class="p-button-text w-full text-left"
|
||||||
></button>
|
></button>
|
||||||
</div>
|
</div>
|
||||||
</p-overlayPanel>
|
</p-popover>
|
||||||
|
<div class="user-profile">
|
||||||
<img class="avatar" src="/placeholder-user.jpg" alt="User" />
|
<img class="avatar" src="/placeholder-user.jpg" alt="User" />
|
||||||
<span class="username">Gal Podlipnik</span>
|
<span class="username">Gal Podlipnik</span>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
</p-menubar>
|
||||||
<main class="main-content">
|
<main class="main-content">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
@ -80,21 +82,73 @@ import { LocaleStore } from './translations/locale.service';
|
|||||||
`,
|
`,
|
||||||
styles: [
|
styles: [
|
||||||
`
|
`
|
||||||
.navbar {
|
:host ::ng-deep {
|
||||||
display: flex;
|
.custom-menubar {
|
||||||
align-items: center;
|
background: var(--primary-color);
|
||||||
justify-content: space-between;
|
border: none;
|
||||||
background-color: var(--primary-color);
|
border-radius: 0;
|
||||||
padding: 0 var(--spacing-lg);
|
padding: 0 var(--spacing-lg);
|
||||||
height: 4rem;
|
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
transition: background-color 0.3s;
|
transition: background-color 0.3s;
|
||||||
|
|
||||||
|
.p-menubar-root-list {
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar-left .app-title {
|
.p-menuitem-link {
|
||||||
|
color: rgba(255, 255, 255, 0.95) !important;
|
||||||
|
font-weight: 500;
|
||||||
|
padding: var(--spacing-sm) var(--spacing-md) !important;
|
||||||
|
border-radius: var(--input-radius);
|
||||||
|
transition: all 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.15) !important;
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.p-highlight {
|
||||||
|
background: rgba(255, 255, 255, 0.25) !important;
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menuitem-icon {
|
||||||
|
color: rgba(255, 255, 255, 0.95) !important;
|
||||||
|
font-weight: 600;
|
||||||
|
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar-button {
|
||||||
|
color: #fff !important;
|
||||||
|
background: transparent !important;
|
||||||
|
border: none !important;
|
||||||
|
box-shadow: none !important;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.1) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo-icon {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo-text {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
@ -102,78 +156,107 @@ import { LocaleStore } from './translations/locale.service';
|
|||||||
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
|
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar-center a {
|
.user-actions {
|
||||||
color: rgba(255, 255, 255, 0.85);
|
|
||||||
margin: 0 var(--spacing-md);
|
|
||||||
text-decoration: none;
|
|
||||||
font-weight: 500;
|
|
||||||
padding: var(--spacing-sm) 0;
|
|
||||||
position: relative;
|
|
||||||
transition: color 0.2s;
|
|
||||||
|
|
||||||
&.active,
|
|
||||||
&:hover {
|
|
||||||
color: #fff;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
bottom: -2px;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 2px;
|
|
||||||
background-color: #fff;
|
|
||||||
border-radius: 2px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.navbar-right {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 1rem;
|
gap: var(--spacing-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-toggle-btn {
|
||||||
|
background: rgba(255, 255, 255, 0.15) !important;
|
||||||
|
color: #fff !important;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.25) !important;
|
||||||
|
width: 2.5rem;
|
||||||
|
height: 2.5rem;
|
||||||
|
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.25) !important;
|
||||||
|
border-color: rgba(255, 255, 255, 0.35) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.language-selector {
|
||||||
|
background: rgba(255, 255, 255, 0.15) !important;
|
||||||
|
color: #fff !important;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.25) !important;
|
||||||
|
min-width: 3rem;
|
||||||
|
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.25) !important;
|
||||||
|
border-color: rgba(255, 255, 255, 0.35) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-profile {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
width: 2.5rem;
|
width: 2rem;
|
||||||
height: 2.5rem;
|
height: 2rem;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
margin-right: var(--spacing-sm);
|
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
border: 2px solid rgba(255, 255, 255, 0.3);
|
border: 2px solid rgba(255, 255, 255, 0.3);
|
||||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
|
|
||||||
background: #fff;
|
background: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.username {
|
.username {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin-left: 0.25rem;
|
font-size: 0.9rem;
|
||||||
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
|
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-toggle-btn {
|
.language-options {
|
||||||
background: #fff !important;
|
display: flex;
|
||||||
color: var(--primary-color) !important;
|
flex-direction: column;
|
||||||
border-radius: 50%;
|
gap: var(--spacing-xs);
|
||||||
cursor: pointer;
|
min-width: 120px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-selector {
|
:host ::ng-deep {
|
||||||
background: #fff !important;
|
.p-popover {
|
||||||
color: var(--primary-color) !important;
|
background-color: var(--card-background) !important;
|
||||||
cursor: pointer;
|
border: 1px solid var(--table-border-color) !important;
|
||||||
|
box-shadow: var(--card-shadow) !important;
|
||||||
|
border-radius: var(--border-radius) !important;
|
||||||
|
|
||||||
|
.p-popover-content {
|
||||||
|
background-color: var(--card-background) !important;
|
||||||
|
color: var(--text-color) !important;
|
||||||
|
padding: var(--spacing-md) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark-theme .language-selector {
|
.p-popover-arrow {
|
||||||
background: #fff !important;
|
background-color: var(--card-background) !important;
|
||||||
color: var(--primary-color) !important;
|
border-color: var(--table-border-color) !important;
|
||||||
border: 1.5px solid var(--primary-light);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:root .theme-toggle-btn {
|
.p-button-text {
|
||||||
--theme-toggle-bg: #f3f4f8;
|
color: var(--text-color) !important;
|
||||||
--theme-toggle-icon: #23272f;
|
background: transparent !important;
|
||||||
|
border: none !important;
|
||||||
|
padding: var(--spacing-sm) var(--spacing-md) !important;
|
||||||
|
border-radius: var(--input-radius) !important;
|
||||||
|
transition: all 0.2s !important;
|
||||||
|
text-align: left !important;
|
||||||
|
width: 100% !important;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--primary-lighter) !important;
|
||||||
|
color: var(--primary-color) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background-color: var(--primary-color) !important;
|
||||||
|
color: #ffffff !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-content {
|
.main-content {
|
||||||
@ -190,19 +273,14 @@ import { LocaleStore } from './translations/locale.service';
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.navbar {
|
.user-actions {
|
||||||
flex-direction: column;
|
gap: var(--spacing-sm);
|
||||||
height: auto;
|
|
||||||
padding: var(--spacing-md);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar-center {
|
.user-profile {
|
||||||
margin: var(--spacing-md) 0;
|
.username {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar-right {
|
|
||||||
width: 100%;
|
|
||||||
justify-content: flex-end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-content {
|
.main-content {
|
||||||
@ -217,13 +295,21 @@ export class App implements OnInit {
|
|||||||
key: 'theme',
|
key: 'theme',
|
||||||
});
|
});
|
||||||
private readonly locale = inject(LocaleStore);
|
private readonly locale = inject(LocaleStore);
|
||||||
|
private readonly t = injectAppT();
|
||||||
|
|
||||||
currentLocale = computed(() => this.locale.getCurrentLocale());
|
currentLocale = computed(() => this.locale.getCurrentLocale());
|
||||||
|
|
||||||
isDarkMode = computed(() => this.theme() === 'dark');
|
isDarkMode = computed(() => this.theme() === 'dark');
|
||||||
|
|
||||||
overviewUrl = computed(() => `/${this.currentLocale()}/students`);
|
menuItems = computed(() => [
|
||||||
addStudentUrl = computed(() => `/${this.currentLocale()}/students/add`);
|
{
|
||||||
|
label: this.t('app.overview'),
|
||||||
|
routerLink: `/${this.currentLocale()}/students`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: this.t('app.addStudent'),
|
||||||
|
routerLink: `/${this.currentLocale()}/students/add`,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.applyTheme();
|
this.applyTheme();
|
||||||
|
|||||||
@ -31,4 +31,3 @@ export const appConfig: ApplicationConfig = {
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,19 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { Component, computed, inject, OnInit, signal } from '@angular/core';
|
import { Component, computed, inject, OnInit } from '@angular/core';
|
||||||
import { FormsModule } from '@angular/forms';
|
import {
|
||||||
|
FormBuilder,
|
||||||
|
FormGroup,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
Validators,
|
||||||
|
} from '@angular/forms';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { queryParam } from '@mmstack/router-core';
|
import { queryParam } from '@mmstack/router-core';
|
||||||
|
import { MessageService } from 'primeng/api';
|
||||||
import { ButtonModule } from 'primeng/button';
|
import { ButtonModule } from 'primeng/button';
|
||||||
|
import { CardModule } from 'primeng/card';
|
||||||
import { InputTextModule } from 'primeng/inputtext';
|
import { InputTextModule } from 'primeng/inputtext';
|
||||||
import { MultiSelectModule } from 'primeng/multiselect';
|
import { MultiSelectModule } from 'primeng/multiselect';
|
||||||
|
import { ToastModule } from 'primeng/toast';
|
||||||
import { StudentService } from './student.service';
|
import { StudentService } from './student.service';
|
||||||
import { LocaleStore } from './translations/locale.service';
|
import { LocaleStore } from './translations/locale.service';
|
||||||
|
|
||||||
@ -14,131 +22,333 @@ import { LocaleStore } from './translations/locale.service';
|
|||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
FormsModule,
|
ReactiveFormsModule,
|
||||||
InputTextModule,
|
InputTextModule,
|
||||||
MultiSelectModule,
|
MultiSelectModule,
|
||||||
ButtonModule,
|
ButtonModule,
|
||||||
|
CardModule,
|
||||||
|
ToastModule,
|
||||||
],
|
],
|
||||||
|
providers: [MessageService],
|
||||||
template: `
|
template: `
|
||||||
<div class="card-container">
|
<div class="form-container">
|
||||||
<h2 class="page-title">Edit Student</h2>
|
|
||||||
@if (student()) {
|
@if (student()) {
|
||||||
<form #f="ngForm">
|
<p-card styleClass="form-card">
|
||||||
|
<ng-template pTemplate="header">
|
||||||
|
<div class="card-header">
|
||||||
|
<i class="pi pi-user-edit header-icon"></i>
|
||||||
|
<h2 class="page-title">Edit Student</h2>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
<ng-template pTemplate="content">
|
||||||
|
<form
|
||||||
|
[formGroup]="studentForm"
|
||||||
|
(ngSubmit)="save()"
|
||||||
|
class="student-form"
|
||||||
|
>
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<label for="name">Name:</label>
|
<label for="name" class="form-label">
|
||||||
|
<i class="pi pi-user field-icon"></i>
|
||||||
|
Full Name
|
||||||
|
</label>
|
||||||
<input
|
<input
|
||||||
id="name"
|
id="name"
|
||||||
pInputText
|
pInputText
|
||||||
[(ngModel)]="editedStudent().name"
|
formControlName="name"
|
||||||
name="name"
|
placeholder="Enter student's full name"
|
||||||
|
class="form-input"
|
||||||
|
[class.ng-invalid]="isFieldInvalid('name')"
|
||||||
|
[class.ng-dirty]="isFieldInvalid('name')"
|
||||||
/>
|
/>
|
||||||
|
<div *ngIf="isFieldInvalid('name')" class="error-message">
|
||||||
|
<i class="pi pi-exclamation-triangle"></i>
|
||||||
|
{{ getFieldError('name') }}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<label for="email">Email:</label>
|
<label for="email" class="form-label">
|
||||||
|
<i class="pi pi-envelope field-icon"></i>
|
||||||
|
Email Address
|
||||||
|
</label>
|
||||||
<input
|
<input
|
||||||
id="email"
|
id="email"
|
||||||
pInputText
|
pInputText
|
||||||
[(ngModel)]="editedStudent().email"
|
type="email"
|
||||||
name="email"
|
formControlName="email"
|
||||||
|
placeholder="Enter student's email address"
|
||||||
|
class="form-input"
|
||||||
|
[class.ng-invalid]="isFieldInvalid('email')"
|
||||||
|
[class.ng-dirty]="isFieldInvalid('email')"
|
||||||
/>
|
/>
|
||||||
|
<div *ngIf="isFieldInvalid('email')" class="error-message">
|
||||||
|
<i class="pi pi-exclamation-triangle"></i>
|
||||||
|
{{ getFieldError('email') }}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<label for="courses">Courses:</label>
|
<label for="courses" class="form-label">
|
||||||
|
<i class="pi pi-book field-icon"></i>
|
||||||
|
Courses
|
||||||
|
</label>
|
||||||
<p-multiselect
|
<p-multiselect
|
||||||
id="courses"
|
id="courses"
|
||||||
[options]="courseOptions()"
|
[options]="courseOptions()"
|
||||||
[(ngModel)]="editedStudent().courses"
|
formControlName="courses"
|
||||||
name="courses"
|
placeholder="Select courses for the student"
|
||||||
placeholder="Select Courses"
|
|
||||||
[showToggleAll]="true"
|
[showToggleAll]="true"
|
||||||
|
[class.ng-invalid]="isFieldInvalid('courses')"
|
||||||
|
[class.ng-dirty]="isFieldInvalid('courses')"
|
||||||
|
styleClass="form-multiselect"
|
||||||
></p-multiselect>
|
></p-multiselect>
|
||||||
|
<div *ngIf="isFieldInvalid('courses')" class="error-message">
|
||||||
|
<i class="pi pi-exclamation-triangle"></i>
|
||||||
|
{{ getFieldError('courses') }}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button
|
<button
|
||||||
pButton
|
pButton
|
||||||
type="button"
|
type="button"
|
||||||
label="Cancel"
|
label="Cancel"
|
||||||
|
icon="pi pi-times"
|
||||||
class="p-button-outlined"
|
class="p-button-outlined"
|
||||||
(click)="cancel()"
|
(click)="cancel()"
|
||||||
></button>
|
></button>
|
||||||
<button
|
<button
|
||||||
pButton
|
pButton
|
||||||
type="button"
|
type="submit"
|
||||||
label="Save Changes"
|
label="Save Changes"
|
||||||
icon="pi pi-save"
|
icon="pi pi-save"
|
||||||
class="p-button-primary"
|
class="p-button-primary"
|
||||||
(click)="save()"
|
[disabled]="studentForm.invalid || isSubmitting"
|
||||||
|
[loading]="isSubmitting"
|
||||||
></button>
|
></button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
</ng-template>
|
||||||
|
</p-card>
|
||||||
} @if (!student()) {
|
} @if (!student()) {
|
||||||
<div class="not-found-message">
|
<p-card styleClass="error-card">
|
||||||
<i class="pi pi-exclamation-triangle" style="font-size: 3rem"></i>
|
<ng-template pTemplate="content">
|
||||||
<p>Student not found. Please return to the overview page.</p>
|
<div class="not-found-content">
|
||||||
|
<i class="pi pi-exclamation-triangle error-icon"></i>
|
||||||
|
<h3>Student Not Found</h3>
|
||||||
|
<p>
|
||||||
|
The student you're looking for doesn't exist or has been removed.
|
||||||
|
</p>
|
||||||
<button
|
<button
|
||||||
pButton
|
pButton
|
||||||
type="button"
|
type="button"
|
||||||
label="Back to Overview"
|
label="Back to Overview"
|
||||||
icon="pi pi-arrow-left"
|
icon="pi pi-arrow-left"
|
||||||
|
class="p-button-primary"
|
||||||
(click)="cancel()"
|
(click)="cancel()"
|
||||||
></button>
|
></button>
|
||||||
</div>
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
</p-card>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p-toast></p-toast>
|
||||||
`,
|
`,
|
||||||
styles: [
|
styles: [
|
||||||
`
|
`
|
||||||
:host ::ng-deep {
|
.form-container {
|
||||||
.p-inputtext:disabled {
|
max-width: 600px;
|
||||||
opacity: 0.8;
|
margin: 2rem auto;
|
||||||
background-color: #f5f5f5;
|
padding: 0 var(--spacing-md);
|
||||||
color: var(--text-secondary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-inputtext,
|
:host ::ng-deep {
|
||||||
.p-multiselect {
|
.form-card {
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
box-shadow: var(--card-shadow);
|
||||||
|
background: var(--card-background);
|
||||||
|
border: 1px solid var(--table-border-color);
|
||||||
|
|
||||||
|
.p-card-header {
|
||||||
|
background: linear-gradient(
|
||||||
|
135deg,
|
||||||
|
var(--primary-color),
|
||||||
|
var(--primary-light)
|
||||||
|
);
|
||||||
|
color: #ffffff !important;
|
||||||
|
padding: var(--spacing-lg);
|
||||||
|
border-radius: var(--border-radius) var(--border-radius) 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-card-body {
|
||||||
|
padding: var(--spacing-xl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-card {
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
box-shadow: var(--card-shadow);
|
||||||
|
background: var(--card-background);
|
||||||
|
border: 1px solid #e24c4c;
|
||||||
|
|
||||||
|
.p-card-body {
|
||||||
|
padding: var(--spacing-xl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-input,
|
||||||
|
.form-multiselect {
|
||||||
|
width: 100%;
|
||||||
background-color: var(--card-background) !important;
|
background-color: var(--card-background) !important;
|
||||||
color: var(--text-color) !important;
|
color: var(--text-color) !important;
|
||||||
border-radius: var(--input-radius) !important;
|
border-radius: var(--input-radius) !important;
|
||||||
border: 1px solid var(--table-border-color) !important;
|
border: 1px solid var(--table-border-color) !important;
|
||||||
transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s,
|
transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s,
|
||||||
color 0.3s;
|
color 0.3s;
|
||||||
|
padding: var(--spacing-sm) var(--spacing-md) !important;
|
||||||
|
|
||||||
|
&:enabled:focus {
|
||||||
|
border-color: var(--primary-color) !important;
|
||||||
|
box-shadow: var(--focus-ring) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-inputtext:enabled:focus,
|
&:enabled:hover {
|
||||||
.p-multiselect:not(.p-disabled).p-focus {
|
border-color: var(--primary-light) !important;
|
||||||
border-color: var(--primary-color);
|
|
||||||
box-shadow: var(--focus-ring);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-inputtext:enabled:hover,
|
&.ng-invalid.ng-dirty {
|
||||||
.p-multiselect:not(.p-disabled):hover {
|
border-color: #e24c4c !important;
|
||||||
border-color: var(--primary-light);
|
box-shadow: 0 0 0 2px rgba(226, 76, 76, 0.2) !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-container {
|
.p-multiselect {
|
||||||
max-width: 480px;
|
min-height: 2.5rem;
|
||||||
margin: 2rem auto;
|
|
||||||
|
.p-multiselect-label {
|
||||||
|
color: var(--text-color) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-multiselect-trigger {
|
||||||
|
color: var(--text-secondary) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-icon {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
color: #ffffff !important;
|
||||||
|
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-title {
|
||||||
|
margin: 0;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
color: #ffffff !important;
|
||||||
|
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.student-form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--spacing-lg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-field {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--spacing-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-sm);
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-color);
|
||||||
|
letter-spacing: 0.2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-icon {
|
||||||
|
color: var(--primary-color);
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-message {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-xs);
|
||||||
|
color: #e24c4c;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
margin-top: var(--spacing-xs);
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-actions {
|
.form-actions {
|
||||||
margin-top: var(--spacing-lg);
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: var(--spacing-md);
|
||||||
|
margin-top: var(--spacing-xl);
|
||||||
|
padding-top: var(--spacing-lg);
|
||||||
|
border-top: 1px solid var(--table-border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.not-found-message {
|
.not-found-content {
|
||||||
text-align: center;
|
|
||||||
padding: 2rem;
|
|
||||||
color: #d32f2f;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 1rem;
|
text-align: center;
|
||||||
|
gap: var(--spacing-lg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.not-found-message p {
|
.error-icon {
|
||||||
font-size: 1.2rem;
|
font-size: 3rem;
|
||||||
margin: 1rem 0;
|
color: #e24c4c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.not-found-content h3 {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--text-color);
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.not-found-content p {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 1rem;
|
||||||
|
max-width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.form-container {
|
||||||
|
margin: 1rem auto;
|
||||||
|
padding: 0 var(--spacing-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
:host ::ng-deep {
|
||||||
|
.form-card .p-card-body,
|
||||||
|
.error-card .p-card-body {
|
||||||
|
padding: var(--spacing-lg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-actions {
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.p-button {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
],
|
],
|
||||||
@ -148,16 +358,20 @@ export class EditStudentComponent implements OnInit {
|
|||||||
private readonly localeStore = inject(LocaleStore);
|
private readonly localeStore = inject(LocaleStore);
|
||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
private readonly queryId = queryParam('id');
|
private readonly queryId = queryParam('id');
|
||||||
|
private readonly fb = inject(FormBuilder);
|
||||||
|
private readonly messageService = inject(MessageService);
|
||||||
|
|
||||||
|
protected isSubmitting = false;
|
||||||
|
|
||||||
protected student = computed(() =>
|
protected student = computed(() =>
|
||||||
this.studentService.getStudentById(this.queryId() ?? '')
|
this.studentService.getStudentById(this.queryId() ?? '')
|
||||||
);
|
);
|
||||||
|
|
||||||
protected editedStudent = signal({
|
protected studentForm: FormGroup = this.fb.group({
|
||||||
id: '',
|
id: [''],
|
||||||
name: '',
|
name: ['', [Validators.required, Validators.minLength(2)]],
|
||||||
email: '',
|
email: ['', [Validators.required, Validators.email]],
|
||||||
courses: [] as string[],
|
courses: [[], [Validators.required, Validators.minLength(1)]],
|
||||||
});
|
});
|
||||||
|
|
||||||
protected courseOptions = computed(() => {
|
protected courseOptions = computed(() => {
|
||||||
@ -170,26 +384,71 @@ export class EditStudentComponent implements OnInit {
|
|||||||
'History',
|
'History',
|
||||||
'Literature',
|
'Literature',
|
||||||
'Physical Education',
|
'Physical Education',
|
||||||
|
'Art',
|
||||||
|
'Music',
|
||||||
|
'Geography',
|
||||||
|
'Economics',
|
||||||
].map((course) => ({ label: course, value: course }));
|
].map((course) => ({ label: course, value: course }));
|
||||||
});
|
});
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
const currentStudent = this.student();
|
const currentStudent = this.student();
|
||||||
if (currentStudent) {
|
if (currentStudent) {
|
||||||
this.editedStudent.set({
|
this.studentForm.patchValue({
|
||||||
id: currentStudent.id,
|
id: currentStudent.id,
|
||||||
name: currentStudent.name,
|
name: currentStudent.name,
|
||||||
email: currentStudent.email,
|
email: currentStudent.email,
|
||||||
courses: [...currentStudent.courses],
|
courses: [...currentStudent.courses],
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
console.error('Student not found');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected isFieldInvalid(fieldName: string): boolean {
|
||||||
|
const field = this.studentForm.get(fieldName);
|
||||||
|
return field ? field.invalid && field.dirty : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getFieldError(fieldName: string): string {
|
||||||
|
const field = this.studentForm.get(fieldName);
|
||||||
|
if (!field || !field.errors) return '';
|
||||||
|
|
||||||
|
if (field.errors['required']) return `${fieldName} is required`;
|
||||||
|
if (field.errors['email']) return 'Please enter a valid email address';
|
||||||
|
if (field.errors['minlength']) {
|
||||||
|
const requiredLength = field.errors['minlength'].requiredLength;
|
||||||
|
return `${fieldName} must be at least ${requiredLength} characters`;
|
||||||
|
}
|
||||||
|
if (field.errors['minLength']) return `Please select at least one course`;
|
||||||
|
|
||||||
|
return 'Invalid input';
|
||||||
|
}
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
this.studentService.updateStudent(this.editedStudent());
|
if (this.studentForm.valid) {
|
||||||
this.router.navigate([`/${this.localeStore.getCurrentLocale()}/students`]);
|
this.isSubmitting = true;
|
||||||
|
|
||||||
|
const formValue = this.studentForm.value;
|
||||||
|
this.studentService.updateStudent(formValue);
|
||||||
|
|
||||||
|
this.messageService.add({
|
||||||
|
severity: 'success',
|
||||||
|
summary: 'Success',
|
||||||
|
detail: `Student ${formValue.name} has been updated successfully`,
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.router.navigate([
|
||||||
|
`/${this.localeStore.getCurrentLocale()}/students`,
|
||||||
|
]);
|
||||||
|
}, 1000);
|
||||||
|
} else {
|
||||||
|
this.studentForm.markAllAsTouched();
|
||||||
|
this.messageService.add({
|
||||||
|
severity: 'error',
|
||||||
|
summary: 'Validation Error',
|
||||||
|
detail: 'Please fix the errors in the form',
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
|
|||||||
@ -1,25 +1,55 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { Component, computed, inject } from '@angular/core';
|
import { Component, computed, inject } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { ConfirmationService } from 'primeng/api';
|
||||||
import { ButtonModule } from 'primeng/button';
|
import { ButtonModule } from 'primeng/button';
|
||||||
|
import { ConfirmDialogModule } from 'primeng/confirmdialog';
|
||||||
import { TableModule } from 'primeng/table';
|
import { TableModule } from 'primeng/table';
|
||||||
|
import { TagModule } from 'primeng/tag';
|
||||||
|
import { TooltipModule } from 'primeng/tooltip';
|
||||||
import { StudentService } from './student.service';
|
import { StudentService } from './student.service';
|
||||||
|
import { injectAppT } from './translations/app.t';
|
||||||
import { LocaleStore } from './translations/locale.service';
|
import { LocaleStore } from './translations/locale.service';
|
||||||
import { AppTranslatePipe } from './translations/translate.pipe';
|
import { AppTranslatePipe } from './translations/translate.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-overview',
|
selector: 'app-overview',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, TableModule, ButtonModule, AppTranslatePipe],
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
TableModule,
|
||||||
|
ButtonModule,
|
||||||
|
ConfirmDialogModule,
|
||||||
|
TagModule,
|
||||||
|
TooltipModule,
|
||||||
|
AppTranslatePipe,
|
||||||
|
],
|
||||||
|
providers: [ConfirmationService],
|
||||||
template: `
|
template: `
|
||||||
<div>
|
<div class="overview-container">
|
||||||
<div class="header-actions">
|
<div class="header-section">
|
||||||
|
<div class="header-content">
|
||||||
|
<div class="title-section">
|
||||||
|
<i class="pi pi-users title-icon"></i>
|
||||||
<h2 class="page-title">{{ 'app.studentOverview' | translate }}</h2>
|
<h2 class="page-title">{{ 'app.studentOverview' | translate }}</h2>
|
||||||
<div class="action-buttons-header">
|
</div>
|
||||||
|
<div class="stats-section">
|
||||||
|
<div class="stat-card">
|
||||||
|
<i class="pi pi-users stat-icon"></i>
|
||||||
|
<div class="stat-content">
|
||||||
|
<span class="stat-number">{{ students().length }}</span>
|
||||||
|
<span class="stat-label">{{
|
||||||
|
'app.totalStudents' | translate
|
||||||
|
}}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="action-buttons">
|
||||||
<button
|
<button
|
||||||
pButton
|
pButton
|
||||||
type="button"
|
type="button"
|
||||||
label="Add New Student"
|
[label]="'app.addNewStudent' | translate"
|
||||||
icon="pi pi-plus"
|
icon="pi pi-plus"
|
||||||
class="p-button-primary"
|
class="p-button-primary"
|
||||||
(click)="goToAdd()"
|
(click)="goToAdd()"
|
||||||
@ -27,11 +57,13 @@ import { AppTranslatePipe } from './translations/translate.pipe';
|
|||||||
<button
|
<button
|
||||||
pButton
|
pButton
|
||||||
type="button"
|
type="button"
|
||||||
label="Generate Mock Data"
|
[label]="'app.generateMockData' | translate"
|
||||||
icon="pi pi-refresh"
|
icon="pi pi-refresh"
|
||||||
class="p-button-secondary"
|
class="p-button-secondary"
|
||||||
(click)="generateMock()"
|
(click)="generateMock()"
|
||||||
[disabled]="students().length > 0"
|
[disabled]="students().length > 0"
|
||||||
|
[pTooltip]="'app.generateSampleData' | translate"
|
||||||
|
tooltipPosition="top"
|
||||||
></button>
|
></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -46,41 +78,86 @@ import { AppTranslatePipe } from './translations/translate.pipe';
|
|||||||
[stripedRows]="true"
|
[stripedRows]="true"
|
||||||
styleClass="p-datatable-rounded"
|
styleClass="p-datatable-rounded"
|
||||||
[responsiveLayout]="'stack'"
|
[responsiveLayout]="'stack'"
|
||||||
|
[loading]="false"
|
||||||
|
[showLoader]="false"
|
||||||
>
|
>
|
||||||
<ng-template pTemplate="header">
|
<ng-template pTemplate="header">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>
|
||||||
<th>Email</th>
|
<div class="column-header">
|
||||||
<th>Courses</th>
|
<i class="pi pi-user column-icon"></i>
|
||||||
<th style="width: 150px">Actions</th>
|
{{ 'app.name' | translate }}
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<div class="column-header">
|
||||||
|
<i class="pi pi-envelope column-icon"></i>
|
||||||
|
{{ 'app.email' | translate }}
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<div class="column-header">
|
||||||
|
<i class="pi pi-book column-icon"></i>
|
||||||
|
{{ 'app.courses' | translate }}
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
|
<th style="width: 150px">
|
||||||
|
<div class="column-header">
|
||||||
|
<i class="pi pi-cog column-icon"></i>
|
||||||
|
{{ 'app.actions' | translate }}
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-template pTemplate="body" let-st>
|
<ng-template pTemplate="body" let-student>
|
||||||
<tr>
|
<tr>
|
||||||
<td><span class="p-column-title">Name</span>{{ st.name }}</td>
|
|
||||||
<td><span class="p-column-title">Email</span>{{ st.email }}</td>
|
|
||||||
<td>
|
<td>
|
||||||
<span class="p-column-title">Courses</span
|
<span class="p-column-title">{{ 'app.name' | translate }}</span>
|
||||||
>{{ st.courses.join(', ') }}
|
<div class="student-name">
|
||||||
|
<i class="pi pi-user student-icon"></i>
|
||||||
|
{{ student.name }}
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="p-column-title">Actions</span>
|
<span class="p-column-title">{{ 'app.email' | translate }}</span>
|
||||||
|
<div class="student-email">
|
||||||
|
<i class="pi pi-envelope email-icon"></i>
|
||||||
|
{{ student.email }}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span class="p-column-title">{{
|
||||||
|
'app.courses' | translate
|
||||||
|
}}</span>
|
||||||
|
<div class="courses-container">
|
||||||
|
<p-tag
|
||||||
|
*ngFor="let course of student.courses"
|
||||||
|
[value]="course"
|
||||||
|
severity="info"
|
||||||
|
styleClass="course-tag"
|
||||||
|
></p-tag>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span class="p-column-title">{{
|
||||||
|
'app.actions' | translate
|
||||||
|
}}</span>
|
||||||
<div class="action-buttons">
|
<div class="action-buttons">
|
||||||
<button
|
<button
|
||||||
pButton
|
pButton
|
||||||
icon="pi pi-pencil"
|
icon="pi pi-pencil"
|
||||||
class="p-button-rounded p-button-text"
|
class="p-button-rounded p-button-text p-button-success"
|
||||||
tooltipPosition="top"
|
tooltipPosition="top"
|
||||||
pTooltip="Edit Student"
|
[pTooltip]="'app.editStudent' | translate"
|
||||||
(click)="editStudent(st.id)"
|
(click)="editStudent(student.id)"
|
||||||
></button>
|
></button>
|
||||||
<button
|
<button
|
||||||
pButton
|
pButton
|
||||||
icon="pi pi-trash"
|
icon="pi pi-trash"
|
||||||
class="p-button-rounded p-button-text p-button-danger"
|
class="p-button-rounded p-button-text p-button-danger"
|
||||||
tooltipPosition="top"
|
tooltipPosition="top"
|
||||||
pTooltip="Delete Student"
|
[pTooltip]="'app.deleteStudent' | translate"
|
||||||
(click)="deleteStudent(st.id)"
|
(click)="confirmDelete(student)"
|
||||||
></button>
|
></button>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@ -88,50 +165,130 @@ import { AppTranslatePipe } from './translations/translate.pipe';
|
|||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-template pTemplate="emptymessage">
|
<ng-template pTemplate="emptymessage">
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="4" class="text-center">
|
<td colspan="4" class="empty-state">
|
||||||
No students found. Add your first student!
|
<div class="empty-content">
|
||||||
|
<i class="pi pi-users empty-icon"></i>
|
||||||
|
<h3>{{ 'app.noStudentsFound' | translate }}</h3>
|
||||||
|
<p>{{ 'app.startByAdding' | translate }}</p>
|
||||||
|
<button
|
||||||
|
pButton
|
||||||
|
type="button"
|
||||||
|
[label]="'app.addFirstStudent' | translate"
|
||||||
|
icon="pi pi-plus"
|
||||||
|
class="p-button-primary"
|
||||||
|
(click)="goToAdd()"
|
||||||
|
></button>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</p-table>
|
</p-table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p-confirmDialog
|
||||||
|
[header]="'app.confirmDelete' | translate"
|
||||||
|
icon="pi pi-exclamation-triangle"
|
||||||
|
[acceptLabel]="'app.delete' | translate"
|
||||||
|
[rejectLabel]="'app.cancel' | translate"
|
||||||
|
acceptButtonStyleClass="p-button-danger"
|
||||||
|
rejectButtonStyleClass="p-button-text"
|
||||||
|
></p-confirmDialog>
|
||||||
`,
|
`,
|
||||||
styles: [
|
styles: [
|
||||||
`
|
`
|
||||||
.header-actions {
|
.overview-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
flex-direction: column;
|
||||||
align-items: center;
|
gap: var(--spacing-xl);
|
||||||
margin-bottom: 1.5rem;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-buttons-header {
|
.header-section {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 1rem;
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: var(--spacing-lg);
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-content {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-xl);
|
||||||
|
}
|
||||||
|
|
||||||
|
.title-section {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.title-icon {
|
||||||
|
font-size: 2rem;
|
||||||
|
color: var(--primary-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-title {
|
.page-title {
|
||||||
margin-bottom: 0;
|
margin: 0;
|
||||||
|
color: var(--primary-color);
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 2rem;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-section {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--spacing-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-sm);
|
||||||
|
padding: var(--spacing-md);
|
||||||
|
background: var(--card-background);
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
box-shadow: var(--card-shadow);
|
||||||
|
border: 1px solid var(--table-border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-icon {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
color: var(--primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-number {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-label {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-buttons {
|
.action-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 0.5rem;
|
gap: var(--spacing-md);
|
||||||
justify-content: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:host ::ng-deep {
|
:host ::ng-deep {
|
||||||
.p-datatable {
|
.p-datatable {
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-shadow: var(--card-shadow);
|
|
||||||
background-color: var(--card-background);
|
background-color: var(--card-background);
|
||||||
|
|
||||||
.p-datatable-header {
|
.p-datatable-header {
|
||||||
background-color: var(--card-background) !important;
|
background-color: var(--card-background) !important;
|
||||||
border: none;
|
border: none;
|
||||||
padding: 1.25rem 1.5rem;
|
padding: 0 !important;
|
||||||
|
border-bottom: 1px solid var(--table-border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-datatable-thead > tr > th {
|
.p-datatable-thead > tr > th {
|
||||||
@ -175,9 +332,9 @@ import { AppTranslatePipe } from './translations/translate.pipe';
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.p-highlight {
|
&.p-highlight {
|
||||||
background-color: #000000 !important;
|
background-color: var(--primary-color) !important;
|
||||||
color: #ffffff !important;
|
color: #ffffff !important;
|
||||||
border-color: #000000 !important;
|
border-color: var(--primary-color) !important;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,13 +357,101 @@ import { AppTranslatePipe } from './translations/translate.pipe';
|
|||||||
transition: background 0.2s, color 0.2s, box-shadow 0.2s;
|
transition: background 0.2s, color 0.2s, box-shadow 0.2s;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.p-tag {
|
||||||
|
margin-right: var(--spacing-xs);
|
||||||
|
margin-bottom: var(--spacing-xs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.column-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
.column-icon {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.student-name {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-sm);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.student-icon {
|
||||||
|
color: var(--primary-color);
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.student-email {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
.email-icon {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.courses-container {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: var(--spacing-xs);
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--spacing-sm);
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state {
|
||||||
|
text-align: center;
|
||||||
|
padding: var(--spacing-xl) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-icon {
|
||||||
|
font-size: 3rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-content h3 {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--text-color);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-content p {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--text-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 768px) {
|
@media screen and (max-width: 768px) {
|
||||||
.header-actions {
|
.header-section {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
gap: 1rem;
|
}
|
||||||
|
|
||||||
|
.header-content {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: var(--spacing-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-buttons {
|
||||||
|
justify-content: stretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
:host ::ng-deep {
|
:host ::ng-deep {
|
||||||
@ -232,7 +477,11 @@ export class OverviewComponent {
|
|||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
private readonly studentsService = inject(StudentService);
|
private readonly studentsService = inject(StudentService);
|
||||||
private readonly localeStore = inject(LocaleStore);
|
private readonly localeStore = inject(LocaleStore);
|
||||||
|
private readonly confirmationService = inject(ConfirmationService);
|
||||||
|
private readonly t = injectAppT();
|
||||||
|
|
||||||
protected readonly students = computed(() => this.studentsService.students());
|
protected readonly students = computed(() => this.studentsService.students());
|
||||||
|
|
||||||
protected generateMock = () => this.studentsService.generateMockData();
|
protected generateMock = () => this.studentsService.generateMockData();
|
||||||
|
|
||||||
goToAdd() {
|
goToAdd() {
|
||||||
@ -252,6 +501,15 @@ export class OverviewComponent {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
confirmDelete(student: any) {
|
||||||
|
this.confirmationService.confirm({
|
||||||
|
message: `Are you sure you want to delete ${student.name}?`,
|
||||||
|
accept: () => {
|
||||||
|
this.deleteStudent(student.id);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
deleteStudent(id: string) {
|
deleteStudent(id: string) {
|
||||||
this.studentsService.deleteSutdent(id);
|
this.studentsService.deleteSutdent(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,8 @@ export type Student = {
|
|||||||
name: string;
|
name: string;
|
||||||
email: string;
|
email: string;
|
||||||
courses: string[];
|
courses: string[];
|
||||||
|
createdAt?: Date;
|
||||||
|
updatedAt?: Date;
|
||||||
};
|
};
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
@ -18,41 +20,117 @@ export class StudentService {
|
|||||||
key: 'students',
|
key: 'students',
|
||||||
});
|
});
|
||||||
|
|
||||||
courses = ['Mathematics', 'Physics', 'Chemistry', 'History', 'Literature'];
|
courses = [
|
||||||
|
'Mathematics',
|
||||||
|
'Physics',
|
||||||
|
'Chemistry',
|
||||||
|
'Biology',
|
||||||
|
'Computer Science',
|
||||||
|
'History',
|
||||||
|
'Literature',
|
||||||
|
'Physical Education',
|
||||||
|
'Art',
|
||||||
|
'Music',
|
||||||
|
'Geography',
|
||||||
|
'Economics',
|
||||||
|
];
|
||||||
|
|
||||||
addStudent({ name, email, courses }: Omit<Student, 'id'>) {
|
addStudent({
|
||||||
const newStudent: Student = {
|
|
||||||
id: uuid(),
|
|
||||||
name,
|
name,
|
||||||
email,
|
email,
|
||||||
courses,
|
courses,
|
||||||
|
}: Omit<Student, 'id' | 'createdAt' | 'updatedAt'>) {
|
||||||
|
const newStudent: Student = {
|
||||||
|
id: uuid(),
|
||||||
|
name: name.trim(),
|
||||||
|
email: email.trim().toLowerCase(),
|
||||||
|
courses: courses.filter((course) => course.trim() !== ''),
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
this.students.update((students) => [...students, newStudent]);
|
this.students.update((students) => [...students, newStudent]);
|
||||||
|
return newStudent;
|
||||||
}
|
}
|
||||||
|
|
||||||
getStudentById(id: string) {
|
getStudentById(id: string): Student | undefined {
|
||||||
return this.students().find((student) => student.id === id);
|
return this.students().find((student) => student.id === id);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStudent(student: Partial<Student>) {
|
updateStudent(student: Partial<Student> & { id: string }) {
|
||||||
this.students.update((students) =>
|
this.students.update((students) =>
|
||||||
students.map((s) => (s.id === student.id ? { ...s, ...student } : s))
|
students.map((s) =>
|
||||||
|
s.id === student.id
|
||||||
|
? {
|
||||||
|
...s,
|
||||||
|
...student,
|
||||||
|
name: student.name?.trim() || s.name,
|
||||||
|
email: student.email?.trim().toLowerCase() || s.email,
|
||||||
|
courses:
|
||||||
|
student.courses?.filter((course) => course.trim() !== '') ||
|
||||||
|
s.courses,
|
||||||
|
updatedAt: new Date(),
|
||||||
|
}
|
||||||
|
: s
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
generateMockData() {
|
generateMockData() {
|
||||||
const mockData: Student[] = generateRandom();
|
const mockData: Student[] = generateRandom().map((student) => ({
|
||||||
|
...student,
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date(),
|
||||||
|
}));
|
||||||
this.students.set(mockData);
|
this.students.set(mockData);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStudentCourse(id: string, courses: string[]) {
|
updateStudentCourse(id: string, courses: string[]) {
|
||||||
this.students.update((students) =>
|
this.students.update((students) =>
|
||||||
students.map((s) => (s.id === id ? { ...s, courses } : s))
|
students.map((s) =>
|
||||||
|
s.id === id
|
||||||
|
? {
|
||||||
|
...s,
|
||||||
|
courses: courses.filter((course) => course.trim() !== ''),
|
||||||
|
updatedAt: new Date(),
|
||||||
|
}
|
||||||
|
: s
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteSutdent(id: string) {
|
deleteSutdent(id: string) {
|
||||||
this.students.update((students) => students.filter((s) => s.id !== id));
|
this.students.update((students) => students.filter((s) => s.id !== id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getStudentsByCourse(course: string): Student[] {
|
||||||
|
return this.students().filter((student) =>
|
||||||
|
student.courses.some((c) =>
|
||||||
|
c.toLowerCase().includes(course.toLowerCase())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
searchStudents(query: string): Student[] {
|
||||||
|
const searchTerm = query.toLowerCase();
|
||||||
|
return this.students().filter(
|
||||||
|
(student) =>
|
||||||
|
student.name.toLowerCase().includes(searchTerm) ||
|
||||||
|
student.email.toLowerCase().includes(searchTerm) ||
|
||||||
|
student.courses.some((course) =>
|
||||||
|
course.toLowerCase().includes(searchTerm)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getTotalStudents(): number {
|
||||||
|
return this.students().length;
|
||||||
|
}
|
||||||
|
|
||||||
|
getStudentsByDateRange(startDate: Date, endDate: Date): Student[] {
|
||||||
|
return this.students().filter((student) => {
|
||||||
|
const createdAt = student.createdAt || new Date();
|
||||||
|
return createdAt >= startDate && createdAt <= endDate;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,5 +2,55 @@ import { createAppTranslation } from './app.namespace';
|
|||||||
|
|
||||||
export default createAppTranslation('sl', {
|
export default createAppTranslation('sl', {
|
||||||
studentOverview: 'Pregled študentov',
|
studentOverview: 'Pregled študentov',
|
||||||
|
addNewStudent: 'Dodaj novega študenta',
|
||||||
|
generateMockData: 'Ustvari testne podatke',
|
||||||
|
generateSampleData: 'Ustvari vzorčne podatke študentov',
|
||||||
|
totalStudents: 'Skupaj študentov',
|
||||||
|
editStudent: 'Uredi študenta',
|
||||||
|
deleteStudent: 'Izbriši študenta',
|
||||||
|
confirmDelete: 'Potrdi brisanje',
|
||||||
|
confirmDeleteMessage: 'Ali ste prepričani, da želite izbrisati {name}?',
|
||||||
|
delete: 'Izbriši',
|
||||||
|
cancel: 'Prekliči',
|
||||||
|
noStudentsFound: 'Ni najdenih študentov',
|
||||||
|
startByAdding: 'Začnite z dodajanjem prvega študenta v sistem.',
|
||||||
|
addFirstStudent: 'Dodaj prvega študenta',
|
||||||
|
showingStudents: 'Prikazujem {first} do {last} od {totalRecords} študentov',
|
||||||
|
name: 'Ime',
|
||||||
|
email: 'E-pošta',
|
||||||
|
courses: 'Predmeti',
|
||||||
|
actions: 'Akcije',
|
||||||
|
fullName: 'Polno ime',
|
||||||
|
emailAddress: 'E-poštni naslov',
|
||||||
|
enterStudentName: 'Vnesite polno ime študenta',
|
||||||
|
enterStudentEmail: 'Vnesite e-poštni naslov študenta',
|
||||||
|
selectCourses: 'Izberite predmete za študenta',
|
||||||
|
saveChanges: 'Shrani spremembe',
|
||||||
|
studentNotFound: 'Študent ni najden',
|
||||||
|
studentNotFoundMessage:
|
||||||
|
'Študent, ki ga iščete, ne obstaja ali je bil odstranjen.',
|
||||||
|
backToOverview: 'Nazaj na pregled',
|
||||||
|
validationErrors: {
|
||||||
|
nameRequired: 'Ime je obvezno',
|
||||||
|
nameMinLength: 'Ime mora vsebovati vsaj {length} znakov',
|
||||||
|
emailRequired: 'E-pošta je obvezna',
|
||||||
|
emailInvalid: 'Vnesite veljaven e-poštni naslov',
|
||||||
|
coursesRequired: 'Izberite vsaj en predmet',
|
||||||
|
},
|
||||||
|
success: {
|
||||||
|
studentAdded: 'Študent {name} je bil uspešno dodan',
|
||||||
|
studentUpdated: 'Študent {name} je bil uspešno posodobljen',
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
validationError: 'Napaka pri preverjanju',
|
||||||
|
fixFormErrors: 'Prosimo, popravite napake v obrazcu',
|
||||||
|
},
|
||||||
|
overview: 'Pregled',
|
||||||
|
overviewDescription: 'Ogled in upravljanje vseh študentov',
|
||||||
|
addStudent: 'Dodaj študenta',
|
||||||
|
addStudentDescription: 'Dodaj novega študenta v sistem',
|
||||||
|
toggleTheme: 'Preklopi temo',
|
||||||
|
changeLanguage: 'Spremeni jezik',
|
||||||
|
english: 'Angleščina',
|
||||||
|
slovenian: 'Slovenščina',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,57 @@ import { createNamespace } from '@mmstack/translate';
|
|||||||
|
|
||||||
const ns = createNamespace('app', {
|
const ns = createNamespace('app', {
|
||||||
studentOverview: 'Student Overview',
|
studentOverview: 'Student Overview',
|
||||||
|
addNewStudent: 'Add New Student',
|
||||||
|
generateMockData: 'Generate Mock Data',
|
||||||
|
generateSampleData: 'Generate sample student data',
|
||||||
|
totalStudents: 'Total Students',
|
||||||
|
editStudent: 'Edit Student',
|
||||||
|
deleteStudent: 'Delete Student',
|
||||||
|
confirmDelete: 'Confirm Delete',
|
||||||
|
confirmDeleteMessage: 'Are you sure you want to delete {name}?',
|
||||||
|
delete: 'Delete',
|
||||||
|
cancel: 'Cancel',
|
||||||
|
noStudentsFound: 'No students found',
|
||||||
|
startByAdding: 'Start by adding your first student to the system.',
|
||||||
|
addFirstStudent: 'Add First Student',
|
||||||
|
showingStudents: 'Showing {first} to {last} of {totalRecords} students',
|
||||||
|
name: 'Name',
|
||||||
|
email: 'Email',
|
||||||
|
courses: 'Courses',
|
||||||
|
actions: 'Actions',
|
||||||
|
fullName: 'Full Name',
|
||||||
|
emailAddress: 'Email Address',
|
||||||
|
enterStudentName: "Enter student's full name",
|
||||||
|
enterStudentEmail: "Enter student's email address",
|
||||||
|
selectCourses: 'Select courses for the student',
|
||||||
|
saveChanges: 'Save Changes',
|
||||||
|
studentNotFound: 'Student Not Found',
|
||||||
|
studentNotFoundMessage:
|
||||||
|
"The student you're looking for doesn't exist or has been removed.",
|
||||||
|
backToOverview: 'Back to Overview',
|
||||||
|
validationErrors: {
|
||||||
|
nameRequired: 'Name is required',
|
||||||
|
nameMinLength: 'Name must be at least {length} characters',
|
||||||
|
emailRequired: 'Email is required',
|
||||||
|
emailInvalid: 'Please enter a valid email address',
|
||||||
|
coursesRequired: 'Please select at least one course',
|
||||||
|
},
|
||||||
|
success: {
|
||||||
|
studentAdded: 'Student {name} has been added successfully',
|
||||||
|
studentUpdated: 'Student {name} has been updated successfully',
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
validationError: 'Validation Error',
|
||||||
|
fixFormErrors: 'Please fix the errors in the form',
|
||||||
|
},
|
||||||
|
overview: 'Overview',
|
||||||
|
overviewDescription: 'View and manage all students',
|
||||||
|
addStudent: 'Add Student',
|
||||||
|
addStudentDescription: 'Add a new student to the system',
|
||||||
|
toggleTheme: 'Toggle theme',
|
||||||
|
changeLanguage: 'Change language',
|
||||||
|
english: 'English',
|
||||||
|
slovenian: 'Slovenian',
|
||||||
});
|
});
|
||||||
|
|
||||||
export default ns.translation;
|
export default ns.translation;
|
||||||
@ -9,4 +60,3 @@ export default ns.translation;
|
|||||||
export type AppLocale = (typeof ns)['translation'];
|
export type AppLocale = (typeof ns)['translation'];
|
||||||
|
|
||||||
export const createAppTranslation = ns.createTranslation;
|
export const createAppTranslation = ns.createTranslation;
|
||||||
|
|
||||||
|
|||||||
348
src/styles.scss
348
src/styles.scss
@ -3,83 +3,96 @@
|
|||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: 'Roboto', 'Helvetica Neue', Arial, sans-serif;
|
font-family: 'Inter', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
|
||||||
background-color: var(--background-color);
|
background-color: var(--background-color);
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
transition: background-color 0.3s, color 0.3s;
|
transition: background-color 0.3s, color 0.3s;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
|
line-height: 1.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
// Base colors
|
--primary-color: #6366f1;
|
||||||
--primary-color: #6200ee;
|
--primary-light: #818cf8;
|
||||||
--primary-light: #7f39fb;
|
--primary-dark: #4f46e5;
|
||||||
--primary-dark: #3700b3;
|
--primary-lighter: #e0e7ff;
|
||||||
--accent-color: #03dac6;
|
--accent-color: #10b981;
|
||||||
--text-color: #23272f;
|
--accent-light: #34d399;
|
||||||
--text-secondary: #555a64;
|
--text-color: #1f2937;
|
||||||
--background-color: #f4f6fa;
|
--text-secondary: #6b7280;
|
||||||
|
--text-muted: #9ca3af;
|
||||||
|
--background-color: #f9fafb;
|
||||||
|
--background-secondary: #f3f4f6;
|
||||||
|
|
||||||
// Card & containers
|
--card-background: #ffffff;
|
||||||
--card-background: #fff;
|
--card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
||||||
--card-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
|
--card-shadow-hover: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||||
|
|
||||||
// Table colors
|
--table-header-bg: #f8fafc;
|
||||||
--table-header-bg: #f3f4f8;
|
--table-row-bg: #ffffff;
|
||||||
--table-row-bg: #fff;
|
--table-row-hover-bg: #f1f5f9;
|
||||||
--table-row-hover-bg: #f0f0f5;
|
--table-border-color: #e2e8f0;
|
||||||
--table-border-color: #e0e3ea;
|
|
||||||
|
|
||||||
// Pagination
|
--paginator-button-hover-bg: rgba(99, 102, 241, 0.1);
|
||||||
--paginator-button-selected-bg: #000000;
|
--paginator-button-selected-bg: #6366f1;
|
||||||
--paginator-button-selected-text: #ffffff;
|
--paginator-button-selected-text: #ffffff;
|
||||||
--paginator-button-hover-bg: rgba(98, 0, 238, 0.08);
|
|
||||||
|
|
||||||
// Spacing
|
|
||||||
--spacing-xs: 0.25rem;
|
--spacing-xs: 0.25rem;
|
||||||
--spacing-sm: 0.5rem;
|
--spacing-sm: 0.5rem;
|
||||||
--spacing-md: 1rem;
|
--spacing-md: 1rem;
|
||||||
--spacing-lg: 1.5rem;
|
--spacing-lg: 1.5rem;
|
||||||
--spacing-xl: 2rem;
|
--spacing-xl: 2rem;
|
||||||
|
--spacing-2xl: 3rem;
|
||||||
|
|
||||||
// Border radius
|
|
||||||
--border-radius: 12px;
|
--border-radius: 12px;
|
||||||
|
--border-radius-sm: 8px;
|
||||||
|
--border-radius-lg: 16px;
|
||||||
--input-radius: 8px;
|
--input-radius: 8px;
|
||||||
|
|
||||||
// Focus
|
--focus-ring: 0 0 0 3px rgba(99, 102, 241, 0.1);
|
||||||
--focus-ring: 0 0 0 2px var(--primary-light);
|
--focus-ring-error: 0 0 0 3px rgba(239, 68, 68, 0.1);
|
||||||
|
|
||||||
|
--transition-fast: 0.15s ease;
|
||||||
|
--transition-normal: 0.3s ease;
|
||||||
|
--transition-slow: 0.5s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark-theme {
|
.dark-theme {
|
||||||
--primary-color: #bb86fc;
|
--primary-color: #a855f7;
|
||||||
--primary-light: #e2b9ff;
|
--primary-light: #c084fc;
|
||||||
--primary-dark: #3700b3;
|
--primary-dark: #9333ea;
|
||||||
--accent-color: #03dac6;
|
--primary-lighter: #f3e8ff;
|
||||||
--text-color: #e0e0e0;
|
--accent-color: #10b981;
|
||||||
--text-secondary: #b0b0b0;
|
--accent-light: #34d399;
|
||||||
--background-color: #181a20;
|
--text-color: #f9fafb;
|
||||||
--card-background: #23242a;
|
--text-secondary: #d1d5db;
|
||||||
--card-shadow: 0 4px 16px rgba(0, 0, 0, 0.32);
|
--text-muted: #9ca3af;
|
||||||
--table-header-bg: #23242a;
|
--background-color: #111827;
|
||||||
--table-row-bg: #181a20;
|
--background-secondary: #1f2937;
|
||||||
--table-row-hover-bg: #23242a;
|
|
||||||
--table-border-color: #33343a;
|
--card-background: #1f2937;
|
||||||
--paginator-button-hover-bg: rgba(187, 134, 252, 0.12);
|
--card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
|
||||||
--paginator-button-selected-bg: #000000;
|
--card-shadow-hover: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
|
||||||
|
|
||||||
|
--table-header-bg: #374151;
|
||||||
|
--table-row-bg: #1f2937;
|
||||||
|
--table-row-hover-bg: #374151;
|
||||||
|
--table-border-color: #374151;
|
||||||
|
|
||||||
|
--paginator-button-hover-bg: rgba(168, 85, 247, 0.2);
|
||||||
|
--paginator-button-selected-bg: #a855f7;
|
||||||
--paginator-button-selected-text: #ffffff;
|
--paginator-button-selected-text: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Typography
|
|
||||||
.page-title {
|
.page-title {
|
||||||
margin-bottom: var(--spacing-lg);
|
margin-bottom: var(--spacing-lg);
|
||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
font-size: 2rem;
|
font-size: 2rem;
|
||||||
letter-spacing: 0.5px;
|
letter-spacing: -0.025em;
|
||||||
transition: color 0.3s;
|
transition: color var(--transition-normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layout patterns
|
|
||||||
.flex-row {
|
.flex-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -95,17 +108,20 @@ body {
|
|||||||
gap: var(--spacing-md);
|
gap: var(--spacing-md);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cards and containers
|
|
||||||
.card-container {
|
.card-container {
|
||||||
background-color: var(--card-background);
|
background-color: var(--card-background);
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
padding: var(--spacing-xl) var(--spacing-lg);
|
padding: var(--spacing-xl) var(--spacing-lg);
|
||||||
box-shadow: var(--card-shadow);
|
box-shadow: var(--card-shadow);
|
||||||
margin-bottom: var(--spacing-xl);
|
margin-bottom: var(--spacing-xl);
|
||||||
transition: background-color 0.3s, box-shadow 0.3s;
|
transition: background-color var(--transition-normal), box-shadow var(--transition-normal);
|
||||||
|
border: 1px solid var(--table-border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-container:hover {
|
||||||
|
box-shadow: var(--card-shadow-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forms
|
|
||||||
.form-field {
|
.form-field {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -116,7 +132,8 @@ body {
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
margin-bottom: var(--spacing-sm);
|
margin-bottom: var(--spacing-sm);
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
letter-spacing: 0.2px;
|
letter-spacing: 0.025em;
|
||||||
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-actions {
|
.form-actions {
|
||||||
@ -135,9 +152,9 @@ input[type='email'],
|
|||||||
padding: var(--spacing-sm) var(--spacing-md) !important;
|
padding: var(--spacing-sm) var(--spacing-md) !important;
|
||||||
background-color: var(--card-background) !important;
|
background-color: var(--card-background) !important;
|
||||||
color: var(--text-color) !important;
|
color: var(--text-color) !important;
|
||||||
transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s,
|
transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-normal), color var(--transition-normal);
|
||||||
color 0.3s;
|
|
||||||
box-shadow: none !important;
|
box-shadow: none !important;
|
||||||
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type='text']:focus,
|
input[type='text']:focus,
|
||||||
@ -157,15 +174,15 @@ input[type='email']:focus,
|
|||||||
color: var(--text-color) !important;
|
color: var(--text-color) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrimeNG component styling
|
|
||||||
.p-component-styles {
|
.p-component-styles {
|
||||||
// Buttons
|
|
||||||
.p-button {
|
.p-button {
|
||||||
border-radius: var(--input-radius);
|
border-radius: var(--input-radius);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
letter-spacing: 0.2px;
|
letter-spacing: 0.025em;
|
||||||
transition: background 0.2s, color 0.2s, box-shadow 0.2s;
|
transition: all var(--transition-fast);
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
padding: var(--spacing-sm) var(--spacing-md);
|
||||||
|
|
||||||
&.p-button-primary {
|
&.p-button-primary {
|
||||||
background-color: var(--primary-color);
|
background-color: var(--primary-color);
|
||||||
@ -176,18 +193,20 @@ input[type='email']:focus,
|
|||||||
background-color: var(--primary-light);
|
background-color: var(--primary-light);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
box-shadow: var(--focus-ring);
|
box-shadow: var(--focus-ring);
|
||||||
|
transform: translateY(-1px);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.p-button-secondary {
|
&.p-button-secondary {
|
||||||
background-color: var(--accent-color);
|
background-color: var(--accent-color);
|
||||||
border: none;
|
border: none;
|
||||||
color: #23272f;
|
color: #fff;
|
||||||
&:hover,
|
&:hover,
|
||||||
&:focus {
|
&:focus {
|
||||||
background-color: #26ffe6;
|
background-color: var(--accent-light);
|
||||||
color: #23272f;
|
color: #fff;
|
||||||
box-shadow: var(--focus-ring);
|
box-shadow: var(--focus-ring);
|
||||||
|
transform: translateY(-1px);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,20 +216,34 @@ input[type='email']:focus,
|
|||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
&:hover,
|
&:hover,
|
||||||
&:focus {
|
&:focus {
|
||||||
background: var(--primary-light);
|
background: var(--primary-color);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
box-shadow: var(--focus-ring);
|
box-shadow: var(--focus-ring);
|
||||||
|
transform: translateY(-1px);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.p-button-danger {
|
&.p-button-danger {
|
||||||
background-color: #e53935;
|
background-color: #ef4444;
|
||||||
border: none;
|
border: none;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
&:hover,
|
&:hover,
|
||||||
&:focus {
|
&:focus {
|
||||||
background-color: #b71c1c;
|
background-color: #dc2626;
|
||||||
|
box-shadow: var(--focus-ring-error);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.p-button-success {
|
||||||
|
background-color: var(--accent-color);
|
||||||
|
border: none;
|
||||||
|
color: #fff;
|
||||||
|
&:hover,
|
||||||
|
&:focus {
|
||||||
|
background-color: var(--accent-light);
|
||||||
box-shadow: var(--focus-ring);
|
box-shadow: var(--focus-ring);
|
||||||
|
transform: translateY(-1px);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,25 +252,31 @@ input[type='email']:focus,
|
|||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
&:hover,
|
&:hover,
|
||||||
&:focus {
|
&:focus {
|
||||||
background: var(--primary-light);
|
background: var(--primary-lighter);
|
||||||
color: #fff;
|
color: var(--primary-color);
|
||||||
box-shadow: var(--focus-ring);
|
box-shadow: var(--focus-ring);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
cursor: not-allowed;
|
||||||
|
transform: none !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tables
|
|
||||||
.p-datatable {
|
.p-datatable {
|
||||||
margin-top: var(--spacing-lg);
|
margin-top: var(--spacing-lg);
|
||||||
background-color: var(--card-background);
|
background-color: var(--card-background);
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-shadow: var(--card-shadow);
|
box-shadow: var(--card-shadow);
|
||||||
transition: background-color 0.3s, box-shadow 0.3s;
|
transition: background-color var(--transition-normal), box-shadow var(--transition-normal);
|
||||||
|
border: 1px solid var(--table-border-color);
|
||||||
|
|
||||||
.p-datatable-header {
|
.p-datatable-header {
|
||||||
background-color: var(--card-background);
|
background-color: var(--card-background);
|
||||||
padding: var(--spacing-md);
|
padding: 0;
|
||||||
border-bottom: 1px solid var(--table-border-color);
|
border-bottom: 1px solid var(--table-border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,14 +286,14 @@ input[type='email']:focus,
|
|||||||
border-color: var(--table-border-color);
|
border-color: var(--table-border-color);
|
||||||
padding: var(--spacing-md);
|
padding: var(--spacing-md);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
font-size: 1rem;
|
font-size: 0.875rem;
|
||||||
letter-spacing: 0.1px;
|
letter-spacing: 0.025em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-datatable-tbody > tr {
|
.p-datatable-tbody > tr {
|
||||||
background-color: var(--table-row-bg);
|
background-color: var(--table-row-bg);
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
transition: background-color 0.2s;
|
transition: background-color var(--transition-fast);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: var(--table-row-hover-bg);
|
background-color: var(--table-row-hover-bg);
|
||||||
@ -265,6 +304,7 @@ input[type='email']:focus,
|
|||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
border-color: var(--table-border-color);
|
border-color: var(--table-border-color);
|
||||||
padding: var(--spacing-md);
|
padding: var(--spacing-md);
|
||||||
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,37 +314,178 @@ input[type='email']:focus,
|
|||||||
border-color: var(--table-border-color);
|
border-color: var(--table-border-color);
|
||||||
padding: var(--spacing-md);
|
padding: var(--spacing-md);
|
||||||
|
|
||||||
.p-paginator-element.p-highlight {
|
.p-paginator-element {
|
||||||
background-color: #000000 !important;
|
color: var(--text-color) !important;
|
||||||
|
|
||||||
|
&.p-highlight {
|
||||||
|
background-color: var(--primary-color) !important;
|
||||||
color: #ffffff !important;
|
color: #ffffff !important;
|
||||||
border-color: #000000 !important;
|
border-color: var(--primary-color) !important;
|
||||||
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-paginator-element:hover {
|
&:hover:not(.p-highlight) {
|
||||||
background-color: var(--paginator-button-hover-bg);
|
background-color: var(--paginator-button-hover-bg);
|
||||||
|
color: var(--text-color) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-paginator-pages {
|
||||||
|
.p-paginator-page {
|
||||||
|
color: var(--text-color) !important;
|
||||||
|
|
||||||
|
&.p-highlight {
|
||||||
|
background-color: var(--primary-color) !important;
|
||||||
|
color: #ffffff !important;
|
||||||
|
border-color: var(--primary-color) !important;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover:not(.p-highlight) {
|
||||||
|
background-color: var(--paginator-button-hover-bg);
|
||||||
|
color: var(--text-color) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-paginator-first,
|
||||||
|
.p-paginator-prev,
|
||||||
|
.p-paginator-next,
|
||||||
|
.p-paginator-last {
|
||||||
|
color: var(--text-color) !important;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--paginator-button-hover-bg);
|
||||||
|
color: var(--text-color) !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply these styles globally
|
.p-card {
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
box-shadow: var(--card-shadow);
|
||||||
|
background: var(--card-background);
|
||||||
|
border: 1px solid var(--table-border-color);
|
||||||
|
transition: box-shadow var(--transition-normal);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
box-shadow: var(--card-shadow-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-card-header {
|
||||||
|
background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
|
||||||
|
color: white;
|
||||||
|
padding: var(--spacing-lg);
|
||||||
|
border-radius: var(--border-radius) var(--border-radius) 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-card-body {
|
||||||
|
padding: var(--spacing-xl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-toast {
|
||||||
|
.p-toast-message {
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
box-shadow: var(--card-shadow);
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-toast-message-success {
|
||||||
|
background: var(--accent-color);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-toast-message-error {
|
||||||
|
background: #ef4444;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-toast-message-info {
|
||||||
|
background: var(--primary-color);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-toast-message-warn {
|
||||||
|
background: #f59e0b;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-confirmdialog {
|
||||||
|
.p-dialog-header {
|
||||||
|
background: var(--card-background);
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-dialog-content {
|
||||||
|
background: var(--card-background);
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-dialog-footer {
|
||||||
|
background: var(--card-background);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-tag {
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 600;
|
||||||
|
padding: var(--spacing-xs) var(--spacing-sm);
|
||||||
|
color: var(--text-color) !important;
|
||||||
|
background-color: var(--primary-lighter) !important;
|
||||||
|
border: 1px solid var(--primary-color) !important;
|
||||||
|
|
||||||
|
&.p-tag-info {
|
||||||
|
background-color: var(--primary-lighter) !important;
|
||||||
|
color: var(--primary-color) !important;
|
||||||
|
border-color: var(--primary-color) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.p-tag-success {
|
||||||
|
background-color: rgba(16, 185, 129, 0.1) !important;
|
||||||
|
color: var(--accent-color) !important;
|
||||||
|
border-color: var(--accent-color) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.p-tag-warning {
|
||||||
|
background-color: rgba(245, 158, 11, 0.1) !important;
|
||||||
|
color: #f59e0b !important;
|
||||||
|
border-color: #f59e0b !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.p-tag-danger {
|
||||||
|
background-color: rgba(239, 68, 68, 0.1) !important;
|
||||||
|
color: #ef4444 !important;
|
||||||
|
border-color: #ef4444 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@extend .p-component-styles;
|
@extend .p-component-styles;
|
||||||
}
|
}
|
||||||
|
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
width: 10px;
|
width: 8px;
|
||||||
background: var(--background-color);
|
background: var(--background-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb {
|
::-webkit-scrollbar-thumb {
|
||||||
background: var(--table-border-color);
|
background: var(--table-border-color);
|
||||||
border-radius: 8px;
|
border-radius: var(--border-radius-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: var(--text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.card-container {
|
.card-container {
|
||||||
padding: 1.5rem;
|
padding: var(--spacing-lg);
|
||||||
margin: 0 1rem;
|
margin: 0 var(--spacing-sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-actions {
|
.form-actions {
|
||||||
@ -314,4 +495,19 @@ body {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.page-title {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
:root {
|
||||||
|
--spacing-lg: 1rem;
|
||||||
|
--spacing-xl: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-container {
|
||||||
|
padding: var(--spacing-md);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user