import { CommonModule } from '@angular/common'; import { Component, computed, inject } from '@angular/core'; import { Router } from '@angular/router'; import { ButtonModule } from 'primeng/button'; import { TableModule } from 'primeng/table'; import { StudentService } from './student.service'; import { LocaleStore } from './translations/locale.service'; import { AppTranslatePipe } from './translations/translate.pipe'; @Component({ selector: 'app-overview', standalone: true, imports: [CommonModule, TableModule, ButtonModule, AppTranslatePipe], template: `

{{ 'app.studentOverview' | translate }}

Name Email Courses Actions Name{{ st.name }} Email{{ st.email }} Courses{{ st.courses.join(', ') }} Actions
No students found. Add your first student!
`, styles: [ ` .header-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; gap: 1rem; } .action-buttons-header { display: flex; gap: 1rem; } .page-title { margin-bottom: 0; } .action-buttons { display: flex; gap: 0.5rem; justify-content: center; } :host ::ng-deep { .p-datatable { border-radius: var(--border-radius); overflow: hidden; box-shadow: var(--card-shadow); background-color: var(--card-background); .p-datatable-header { background-color: var(--card-background) !important; border: none; padding: 1.25rem 1.5rem; } .p-datatable-thead > tr > th { background-color: var(--table-header-bg) !important; color: var(--text-color) !important; padding: 1rem 1.5rem; font-weight: 700; border-width: 0 0 1px 0; border-color: var(--table-border-color); } .p-datatable-tbody > tr { background-color: var(--table-row-bg) !important; color: var(--text-color) !important; &:hover { background-color: var(--table-row-hover-bg) !important; } > td { background-color: transparent !important; color: var(--text-color) !important; padding: 1rem 1.5rem; border-width: 0 0 1px 0; border-color: var(--table-border-color); } &:last-child > td { border-bottom: none; } } .p-paginator { border-width: 0; padding: 1.25rem; background-color: var(--card-background) !important; .p-paginator-page { &:hover:not(.p-highlight) { background-color: var(--paginator-button-hover-bg) !important; } &.p-highlight { background-color: #000000 !important; color: #ffffff !important; border-color: #000000 !important; font-weight: 600; } } } .p-column-title { display: none; } .p-datatable-emptymessage td { color: var(--text-color) !important; background-color: var(--table-row-bg) !important; } } .p-button { border-radius: var(--input-radius); font-weight: 600; letter-spacing: 0.2px; transition: background 0.2s, color 0.2s, box-shadow 0.2s; box-shadow: none; } } @media screen and (max-width: 768px) { .header-actions { flex-direction: column; align-items: stretch; gap: 1rem; } :host ::ng-deep { .p-datatable { .p-datatable-tbody > tr > td { padding: 1rem; background-color: transparent !important; .p-column-title { display: inline-block; font-weight: bold; margin-right: 0.5rem; color: var(--text-color); } } } } } `, ], }) export class OverviewComponent { private readonly router = inject(Router); private readonly studentsService = inject(StudentService); private readonly localeStore = inject(LocaleStore); protected readonly students = computed(() => this.studentsService.students()); protected generateMock = () => this.studentsService.generateMockData(); goToAdd() { this.router.navigate([ `/${this.localeStore.getCurrentLocale()}/students/add`, ]); } editStudent(id: number) { this.router.navigate( [`/${this.localeStore.getCurrentLocale()}/students/edit`], { queryParams: { id, }, } ); } deleteStudent(id: string) { this.studentsService.deleteSutdent(id); } }