diff options
Diffstat (limited to 'sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage')
4 files changed, 114 insertions, 0 deletions
| diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.css b/sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.css new file mode 100755 index 00000000..5f298325 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.css @@ -0,0 +1,18 @@ +table { +    border-collapse: collapse; +    width: 100%; +    border: 1px solid green; +    margin-top:15px; +  } + +th{ +    border:1px solid rgb(19, 0, 128); +    height: 30px; +    background-color:rgb(134, 186, 235); +} + +td{ +    border:1px solid rgb(19, 0, 128); +    height: 30px; +    text-align: center; +}
\ No newline at end of file diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.html b/sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.html new file mode 100755 index 00000000..406ff0ea --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.html @@ -0,0 +1,29 @@ +<table *ngIf="laptops"> +    <tr> +        <th colspan="11">SPISAK DOSTUPNIH LAPTOPOVA</th> +    </tr> +    <tr> +        <th>BREND</th> +        <th>MODEL</th> +        <th>RAM</th> +        <th>MEMORIJA</th> +        <th>GRAFIKA</th> +        <th>EKRAN</th> +        <th>PROCESOR</th> +        <th>CENA</th> +        <th>UREDI</th> +        <th>OBRIŠI</th> +    </tr> +    <tr *ngFor="let laptop of laptops" (click)="pogledaj(laptop.id)"> +        <td>{{laptop.brand}}</td> +        <td>{{laptop.model}}</td> +        <td>{{laptop.ram}} gb</td> +        <td>{{laptop.hdd}} gb</td> +        <td>{{laptop.graphics}}</td> +        <td>{{laptop.display}}"</td> +        <td>{{laptop.processor}}</td> +        <td>{{laptop.price}} €</td> +        <td ><button (click)="izmeni(laptop)">IZMENI</button></td> +        <td ><button (click)="obrisi(laptop)">ORBIŠI</button></td> +    </tr> +</table> diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.spec.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.spec.ts new file mode 100755 index 00000000..116588cc --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { HomepageComponent } from './homepage.component'; + +describe('HomepageComponent', () => { +  let component: HomepageComponent; +  let fixture: ComponentFixture<HomepageComponent>; + +  beforeEach(async () => { +    await TestBed.configureTestingModule({ +      declarations: [ HomepageComponent ] +    }) +    .compileComponents(); +  }); + +  beforeEach(() => { +    fixture = TestBed.createComponent(HomepageComponent); +    component = fixture.componentInstance; +    fixture.detectChanges(); +  }); + +  it('should create', () => { +    expect(component).toBeTruthy(); +  }); +}); diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.ts new file mode 100755 index 00000000..4ebea54d --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.ts @@ -0,0 +1,42 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import { Laptop } from '../models/laptop'; +import { LibraryServiceService } from '../services/library.service'; + +@Component({ +  selector: 'app-homepage', +  templateUrl: './homepage.component.html', +  styleUrls: ['./homepage.component.css'] +}) +export class HomepageComponent implements OnInit { +  laptops?:Laptop[] +  constructor(private library : LibraryServiceService, private router:Router) { } + +  ngOnInit(): void { +     +    this.library.dajLaptopove().subscribe(laptopovi =>{ +      this.laptops = laptopovi +    }) +  } + +  pogledaj(id:String) +  { +    this.router.navigate(["/laptop/"+id]) +  } + +  izmeni(laptop:Laptop) +  { +    this.router.navigate(['/izmeniLaptop/'+laptop.id]) +  } + +  obrisi(laptop:Laptop) +  { +    this.library.obrisiLaptop(laptop.id).subscribe(req=>{ +       +        this.library.dajLaptopove().subscribe(laptopovi =>{ +          this.laptops = laptopovi +        }) +    }) +  } + +} | 
