From dce4e644d5e5d9c97ff5ac337448b52f2a2a64fd Mon Sep 17 00:00:00 2001 From: TAMARA JERINIC Date: Wed, 2 Mar 2022 23:38:27 +0100 Subject: Merge branch 'dev' of http://gitlab.pmf.kg.ac.rs/igrannonica/neuronstellar into Tamara # Conflicts: # .gitignore --- .../src/app/services/library.service.spec.ts | 16 ++++++ .../frontend/src/app/services/library.service.ts | 61 ++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.spec.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.ts (limited to 'sandbox/TestIvanLjubisavljevic/frontend/src/app/services') diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.spec.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.spec.ts new file mode 100755 index 00000000..c64a4343 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { LibraryServiceService } from './library.service'; + +describe('LibraryService', () => { + let service: LibraryServiceService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(LibraryServiceService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.ts new file mode 100755 index 00000000..e16759d9 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/services/library.service.ts @@ -0,0 +1,61 @@ +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { HttpClient, HttpClientModule, HttpHeaders } from '@angular/common/http'; +import { Laptop } from '../models/laptop'; + +@Injectable({ + providedIn: 'root' +}) + +export class LibraryServiceService { + + constructor(private http:HttpClient) { } + + //DAJ SVE LAPTOPOVE + dajLaptopove(): Observable + { + return this.http.get("http://localhost:5000/api/sviLaptopovi"); + } + + //DAJ ODREDJENI LAPTOP + dajLaptop(id:String): Observable + { + return this.http.get("http://localhost:5000/api/laptop/"+id); + } + + //UNESI NOVI LAPTOP + unesiLaptop(reqBody:Laptop): Observable + { + return this.http.post("http://localhost:5000/api/add", + {"brand": reqBody.brand, + "model": reqBody.model, + "ram": reqBody.ram, + "hdd": reqBody.hdd, + "graphics": reqBody.graphics, + "price":reqBody.price, + "display" : reqBody.display, + "id": "a873b90f-5fca-4c41-a00e-8ea497cce542", + "processor": reqBody.processor}); + } + + //IZMENI LAPTOP + izmeniLaptop(reqBody?:Laptop): Observable + { + return this.http.put("http://localhost:5000/api/update", + {"brand": reqBody?.brand, + "model": reqBody?.model, + "ram": reqBody?.ram, + "hdd": reqBody?.hdd, + "graphics": reqBody?.graphics, + "price":reqBody?.price, + "display" : reqBody?.display, + "processor": reqBody?.processor, + "id":reqBody?.id}); + } + + //OBRISI LAPTOP + obrisiLaptop(id:String): Observable + { + return this.http.delete("http://localhost:5000/api/brisanje/"+id); + } +} \ No newline at end of file -- cgit v1.2.3