diff --git a/frontend/src/app/app.html b/frontend/src/app/app.html index fce9681..d73d60c 100644 --- a/frontend/src/app/app.html +++ b/frontend/src/app/app.html @@ -1,5 +1,19 @@ - Dashboard + + home + Dashboard + + + + + + edit + + + + + close + - \ No newline at end of file + diff --git a/frontend/src/app/app.routes.ts b/frontend/src/app/app.routes.ts index 35ed008..61b4955 100644 --- a/frontend/src/app/app.routes.ts +++ b/frontend/src/app/app.routes.ts @@ -1,9 +1,11 @@ import { Routes } from '@angular/router'; import { ItemListComponent } from './components/item-list/item-list'; import { ItemFormComponent } from './components/item-form/item-form'; +import { HomeComponent } from './components/home/home'; export const routes: Routes = [ - { path: '', component: ItemListComponent }, + { path: '', component: HomeComponent }, + { path: 'admin', component: ItemListComponent }, { path: 'create', component: ItemFormComponent }, { path: 'edit/:id', component: ItemFormComponent }, { path: '**', redirectTo: '' } diff --git a/frontend/src/app/app.scss b/frontend/src/app/app.scss index e69de29..d0ca4cc 100644 --- a/frontend/src/app/app.scss +++ b/frontend/src/app/app.scss @@ -0,0 +1,3 @@ +.spacer { + flex: 1 1 auto; +} diff --git a/frontend/src/app/app.ts b/frontend/src/app/app.ts index 0934108..0f0b125 100644 --- a/frontend/src/app/app.ts +++ b/frontend/src/app/app.ts @@ -1,14 +1,27 @@ -import { Component } from '@angular/core'; -import { RouterOutlet } from '@angular/router'; +import { Component, OnInit } from '@angular/core'; +import { RouterModule, RouterOutlet, Router, NavigationEnd } from '@angular/router'; import { MaterialModule } from './material.module'; +import { filter } from 'rxjs/operators'; +import { CommonModule } from '@angular/common'; @Component({ selector: 'app-root', standalone: true, - imports: [RouterOutlet, MaterialModule], + imports: [RouterOutlet, RouterModule, MaterialModule, CommonModule], templateUrl: './app.html', styleUrls: ['./app.scss'] }) -export class AppComponent { +export class AppComponent implements OnInit { title = 'frontend'; -} \ No newline at end of file + isAdminView = false; + + constructor(private router: Router) {} + + ngOnInit() { + this.router.events.pipe( + filter((event): event is NavigationEnd => event instanceof NavigationEnd) + ).subscribe((event: NavigationEnd) => { + this.isAdminView = event.urlAfterRedirects === '/admin'; + }); + } +} diff --git a/frontend/src/app/components/home/home.html b/frontend/src/app/components/home/home.html new file mode 100644 index 0000000..e7a902f --- /dev/null +++ b/frontend/src/app/components/home/home.html @@ -0,0 +1,17 @@ +
+
+ + + +
+ + + dashboard + + {{ item.displayName }} +
+
+
+
+
+
diff --git a/frontend/src/app/components/home/home.scss b/frontend/src/app/components/home/home.scss new file mode 100644 index 0000000..af22917 --- /dev/null +++ b/frontend/src/app/components/home/home.scss @@ -0,0 +1,45 @@ +.card-container { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); + gap: 20px; + padding: 20px; +} + +.card-link { + text-decoration: none; + color: inherit; +} + +.item-card { + cursor: pointer; + transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out; +} + +.item-card:hover { + transform: translateY(-5px); + box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); +} + +// Custom flex container inside the header +.card-header-content { + display: flex; + align-items: center; // Revert to center alignment + width: 100%; + height: 64px; // Give the container a fixed height +} + +// Remove margin from the title and add padding for spacing +.card-header-content .mat-card-title { + margin: 0; + padding-left: 16px; +} + + +.default-avatar-icon { + // Vertically align the icon in the avatar space + display: flex; + justify-content: center; + align-items: center; + width: 40px; + height: 40px; +} diff --git a/frontend/src/app/components/home/home.spec.ts b/frontend/src/app/components/home/home.spec.ts new file mode 100644 index 0000000..70dd3ad --- /dev/null +++ b/frontend/src/app/components/home/home.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { Home } from './home'; + +describe('Home', () => { + let component: Home; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [Home] + }) + .compileComponents(); + + fixture = TestBed.createComponent(Home); + component = fixture.componentInstance; + await fixture.whenStable(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/components/home/home.ts b/frontend/src/app/components/home/home.ts new file mode 100644 index 0000000..48029ee --- /dev/null +++ b/frontend/src/app/components/home/home.ts @@ -0,0 +1,28 @@ +import { Component, OnInit } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { MaterialModule } from '../../material.module'; +import { ApiService } from '../../services/api'; +import { Item } from '../../models/item'; +import { Observable } from 'rxjs'; + +@Component({ + selector: 'app-home', + standalone: true, + imports: [CommonModule, MaterialModule], + templateUrl: './home.html', + styleUrls: ['./home.scss'] +}) +export class HomeComponent implements OnInit { + items$!: Observable; + imgErrorMap = new Map(); + + constructor(private apiService: ApiService) {} + + ngOnInit(): void { + this.items$ = this.apiService.getItems(); + } + + onImgError(itemId: number) { + this.imgErrorMap.set(itemId, true); + } +} \ No newline at end of file diff --git a/frontend/src/app/material.module.ts b/frontend/src/app/material.module.ts index 02356ce..25eab33 100644 --- a/frontend/src/app/material.module.ts +++ b/frontend/src/app/material.module.ts @@ -6,6 +6,7 @@ import { MatInputModule } from '@angular/material/input'; import { MatTableModule } from '@angular/material/table'; import { MatToolbarModule } from '@angular/material/toolbar'; import { MatIconModule } from '@angular/material/icon'; +import { MatTooltipModule } from '@angular/material/tooltip'; @NgModule({ exports: [ @@ -16,6 +17,7 @@ import { MatIconModule } from '@angular/material/icon'; MatTableModule, MatToolbarModule, MatIconModule, + MatTooltipModule, ] }) export class MaterialModule { } diff --git a/frontend/src/index.html b/frontend/src/index.html index bf5ba55..e043bb4 100644 --- a/frontend/src/index.html +++ b/frontend/src/index.html @@ -2,7 +2,7 @@ - Frontend + Dashboard