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 --- .../frontend/src/app/app-routing.module.ts | 22 ++++++++ .../frontend/src/app/app.component.css | 14 +++++ .../frontend/src/app/app.component.html | 6 +++ .../frontend/src/app/app.component.spec.ts | 35 +++++++++++++ .../frontend/src/app/app.component.ts | 10 ++++ .../frontend/src/app/app.module.ts | 35 +++++++++++++ .../src/app/homepage/homepage.component.css | 18 +++++++ .../src/app/homepage/homepage.component.html | 29 ++++++++++ .../src/app/homepage/homepage.component.spec.ts | 25 +++++++++ .../src/app/homepage/homepage.component.ts | 42 +++++++++++++++ .../app/izmeni-laptop/izmeni-laptop.component.css | 10 ++++ .../app/izmeni-laptop/izmeni-laptop.component.html | 25 +++++++++ .../izmeni-laptop/izmeni-laptop.component.spec.ts | 25 +++++++++ .../app/izmeni-laptop/izmeni-laptop.component.ts | 43 +++++++++++++++ .../frontend/src/app/laptop/laptop.component.css | 22 ++++++++ .../frontend/src/app/laptop/laptop.component.html | 41 +++++++++++++++ .../src/app/laptop/laptop.component.spec.ts | 25 +++++++++ .../frontend/src/app/laptop/laptop.component.ts | 30 +++++++++++ .../frontend/src/app/models/laptop.ts | 11 ++++ .../frontend/src/app/navbar/navbar.component.css | 17 ++++++ .../frontend/src/app/navbar/navbar.component.html | 4 ++ .../src/app/navbar/navbar.component.spec.ts | 25 +++++++++ .../frontend/src/app/navbar/navbar.component.ts | 27 ++++++++++ .../src/app/new-laptop/new-laptop.component.css | 10 ++++ .../src/app/new-laptop/new-laptop.component.html | 24 +++++++++ .../app/new-laptop/new-laptop.component.spec.ts | 25 +++++++++ .../src/app/new-laptop/new-laptop.component.ts | 35 +++++++++++++ .../page-not-found/page-not-found.component.css | 4 ++ .../page-not-found/page-not-found.component.html | 3 ++ .../page-not-found.component.spec.ts | 25 +++++++++ .../app/page-not-found/page-not-found.component.ts | 15 ++++++ .../src/app/services/library.service.spec.ts | 16 ++++++ .../frontend/src/app/services/library.service.ts | 61 ++++++++++++++++++++++ 33 files changed, 759 insertions(+) create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/app-routing.module.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.css create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.html create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.spec.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/app.module.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.css create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.html create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.spec.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/homepage/homepage.component.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.css create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.html create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.spec.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.css create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.html create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.spec.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/models/laptop.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.css create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.html create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.spec.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.css create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.html create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.spec.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.css create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.html create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.spec.ts create mode 100755 sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.ts 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') diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/app-routing.module.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/app-routing.module.ts new file mode 100755 index 00000000..6991b1d0 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/app-routing.module.ts @@ -0,0 +1,22 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { HomepageComponent } from './homepage/homepage.component'; +import { IzmeniLaptopComponent } from './izmeni-laptop/izmeni-laptop.component'; +import { LaptopComponent } from './laptop/laptop.component'; +import { NewLaptopComponent } from './new-laptop/new-laptop.component'; +import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; + +const routes: Routes = [ + {path:"", component:HomepageComponent}, + {path:"homepage", component:HomepageComponent}, + {path:"newLaptop", component:NewLaptopComponent}, + {path:"izmeniLaptop/:id", component:IzmeniLaptopComponent}, + {path:"laptop/:id", component:LaptopComponent}, + {path:"**", component:PageNotFoundComponent} +]; + +@NgModule({ + imports: [RouterModule.forRoot(routes)], + exports: [RouterModule] +}) +export class AppRoutingModule { } diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.css b/sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.css new file mode 100755 index 00000000..56ebd4a2 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.css @@ -0,0 +1,14 @@ +h1{ + padding: 30px; + text-align: center; + color:rgb(42, 71, 165); +} +div{ + width: 100%; + background-color:rgb(134, 186, 235); + color: blueviolet; +} + +html{ + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; +} \ No newline at end of file diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.html b/sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.html new file mode 100755 index 00000000..39dcd1dd --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.html @@ -0,0 +1,6 @@ + +
+

Dobrodošli u prvi online info servis laptopova

+ +
+ diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.spec.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.spec.ts new file mode 100755 index 00000000..74b5b3eb --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.spec.ts @@ -0,0 +1,35 @@ +import { TestBed } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { AppComponent } from './app.component'; + +describe('AppComponent', () => { + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ + RouterTestingModule + ], + declarations: [ + AppComponent + ], + }).compileComponents(); + }); + + it('should create the app', () => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.componentInstance; + expect(app).toBeTruthy(); + }); + + it(`should have as title 'frontend'`, () => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.componentInstance; + expect(app.title).toEqual('frontend'); + }); + + it('should render title', () => { + const fixture = TestBed.createComponent(AppComponent); + fixture.detectChanges(); + const compiled = fixture.nativeElement as HTMLElement; + expect(compiled.querySelector('.content span')?.textContent).toContain('frontend app is running!'); + }); +}); diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.ts new file mode 100755 index 00000000..9d6b2f11 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/app.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.css'] +}) +export class AppComponent { + title = 'frontend'; +} diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/app.module.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/app.module.ts new file mode 100755 index 00000000..98295d39 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/app.module.ts @@ -0,0 +1,35 @@ +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; + +import { AppRoutingModule } from './app-routing.module'; +import { AppComponent } from './app.component'; +import { HomepageComponent } from './homepage/homepage.component'; +import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; +import { LaptopComponent } from './laptop/laptop.component'; +import { FormsModule } from '@angular/forms'; + +import { HttpClientModule } from '@angular/common/http'; +import { IzmeniLaptopComponent } from './izmeni-laptop/izmeni-laptop.component'; +import { NewLaptopComponent } from './new-laptop/new-laptop.component'; +import { NavbarComponent } from './navbar/navbar.component'; + +@NgModule({ + declarations: [ + AppComponent, + HomepageComponent, + PageNotFoundComponent, + LaptopComponent, + IzmeniLaptopComponent, + NewLaptopComponent, + NavbarComponent + ], + imports: [ + BrowserModule, + AppRoutingModule, + FormsModule, + HttpClientModule + ], + providers: [], + bootstrap: [AppComponent] +}) +export class AppModule { } 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SPISAK DOSTUPNIH LAPTOPOVA
BRENDMODELRAMMEMORIJAGRAFIKAEKRANPROCESORCENAUREDIOBRIŠI
{{laptop.brand}}{{laptop.model}}{{laptop.ram}} gb{{laptop.hdd}} gb{{laptop.graphics}}{{laptop.display}}"{{laptop.processor}}{{laptop.price}} €
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; + + 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 + }) + }) + } + +} diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.css b/sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.css new file mode 100755 index 00000000..ab085673 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.css @@ -0,0 +1,10 @@ +input{ + margin:5px; +} +button{ + margin:5px; +} +#forma{ + width: 250px; + margin: auto; +} \ No newline at end of file diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.html b/sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.html new file mode 100755 index 00000000..c49a700d --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.html @@ -0,0 +1,25 @@ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+

Uspešno izmenjeni podaci!

+
\ No newline at end of file diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.spec.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.spec.ts new file mode 100755 index 00000000..cd33375a --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { IzmeniLaptopComponent } from './izmeni-laptop.component'; + +describe('IzmeniLaptopComponent', () => { + let component: IzmeniLaptopComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ IzmeniLaptopComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(IzmeniLaptopComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.ts new file mode 100755 index 00000000..7a4f44b4 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.ts @@ -0,0 +1,43 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Laptop } from '../models/laptop'; +import { LibraryServiceService } from '../services/library.service'; + +@Component({ + selector: 'app-izmeni-laptop', + templateUrl: './izmeni-laptop.component.html', + styleUrls: ['./izmeni-laptop.component.css'] +}) +export class IzmeniLaptopComponent implements OnInit { + laptop?:Laptop + izmenio?:boolean + constructor(private router:Router,private library:LibraryServiceService, private route:ActivatedRoute) { } + + ngOnInit(): void { + this.route.params.subscribe(url=>{ + this.library.dajLaptop(url["id"]).subscribe(laptop =>{ + this.laptop = laptop + }) + }) + } + + izmeni(laptop?:Laptop) + { + this.library.izmeniLaptop(laptop).subscribe(laptop=>{ + this.route.params.subscribe(url=>{ + this.library.dajLaptop(url["id"]).subscribe(laptop =>{ + this.laptop = laptop + this.izmenio = true; + }) + }) + }) + } + + back() + { + this.router.navigate(["/homepage"]) + } + + + +} diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.css b/sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.css new file mode 100755 index 00000000..6d5e47ba --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.css @@ -0,0 +1,22 @@ +table { + border-collapse: collapse; + width: 100%; + border: 1px solid green; + margin-top:15px; + } + +th{ + border:1px solid green; + height: 30px; + background-color:springgreen; +} + +td{ + border:1px solid salmon; + height: 30px; + text-align: center; +} +#forma{ + width: 250px; + margin: auto; +} \ No newline at end of file diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.html b/sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.html new file mode 100755 index 00000000..e1f90df3 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.html @@ -0,0 +1,41 @@ +
+

Karakteristike laptopa:

+ Brend: {{laptop.brand}}
+ Model: {{laptop.model}}
+ RAM: {{laptop.ram}} GB
+ HDD: {{laptop.hdd}} GB
+ Grafika: {{laptop.graphics}} (GB)
+ Dijagonala ekrana: {{laptop.display}} "
+ Procesor: {{laptop.processor}}
+ Cena: {{laptop.price}} €

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LAPTOPOVI MARKE {{laptop.brand}}
BrendMODELRAMHDDGrafikaDijagonala ekranaProcesorCena
{{laptop.brand}}{{laptop.model}}{{laptop.ram}}{{laptop.hdd}}{{laptop.graphics}}{{laptop.display}}{{laptop.processor}}{{laptop.price}} €
+
+ \ No newline at end of file diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.spec.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.spec.ts new file mode 100755 index 00000000..a9ef8a05 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { LaptopComponent } from './laptop.component'; + +describe('LaptopComponent', () => { + let component: LaptopComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ LaptopComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(LaptopComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.ts new file mode 100755 index 00000000..94d711bb --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/laptop/laptop.component.ts @@ -0,0 +1,30 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Laptop } from '../models/laptop'; +import { LibraryServiceService } from '../services/library.service'; + +@Component({ + selector: 'app-laptop', + templateUrl: './laptop.component.html', + styleUrls: ['./laptop.component.css'] +}) +export class LaptopComponent implements OnInit { + laptop?:Laptop + laptopoviM?:Laptop[] + constructor(private library: LibraryServiceService, private route:ActivatedRoute, private router:Router) { } + + ngOnInit(): void { + + this.route.params.subscribe(url =>{ + this.library.dajLaptop(url["id"]).subscribe(laptop=>{ + this.laptop = laptop; + }) + }) + } + + + pogledaj(id:String) + { + this.router.navigate(["/laptop/"+id]) + } +} diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/models/laptop.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/models/laptop.ts new file mode 100755 index 00000000..d5747358 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/models/laptop.ts @@ -0,0 +1,11 @@ +export interface Laptop{ + brand: String; + model: String; + ram: Number; + hdd:Number; + graphics: String; + price: Number; + display : String; + processor: String; + id: String; +} \ No newline at end of file diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.css b/sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.css new file mode 100755 index 00000000..48a0e297 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.css @@ -0,0 +1,17 @@ +button{ + margin:5px; + padding:5px; + width: 150px; + color: rgb(19, 0, 128); + font-weight: bold; +} + +button:hover{ + background-color: rgb(170, 165, 190); + color:black; +} + +div{ + margin: auto; + width: 26%; +} \ No newline at end of file diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.html b/sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.html new file mode 100755 index 00000000..928fc01e --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.html @@ -0,0 +1,4 @@ +
+ + +
\ No newline at end of file diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.spec.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.spec.ts new file mode 100755 index 00000000..f8ccd6f4 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { NavbarComponent } from './navbar.component'; + +describe('NavbarComponent', () => { + let component: NavbarComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ NavbarComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(NavbarComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.ts new file mode 100755 index 00000000..2cdf7ae3 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/navbar/navbar.component.ts @@ -0,0 +1,27 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import { CookieService } from 'ngx-cookie-service'; + +@Component({ + selector: 'app-navbar', + templateUrl: './navbar.component.html', + styleUrls: ['./navbar.component.css'] +}) +export class NavbarComponent implements OnInit { + + constructor(private router:Router, private cookie:CookieService) { } + + ngOnInit(): void { + } + + pocetna() + { + this.router.navigate(["/homepage"]) + } + + dodaj() + { + this.router.navigate(["/newLaptop"]) + } + +} diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.css b/sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.css new file mode 100755 index 00000000..ab085673 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.css @@ -0,0 +1,10 @@ +input{ + margin:5px; +} +button{ + margin:5px; +} +#forma{ + width: 250px; + margin: auto; +} \ No newline at end of file diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.html b/sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.html new file mode 100755 index 00000000..0669929b --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.html @@ -0,0 +1,24 @@ +
+

DODAJ LAPTOP

+ +
+ +
+   +
+   +
+     +
+ +
+ +
+         +
+ + + + +
+ diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.spec.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.spec.ts new file mode 100755 index 00000000..a2218fc7 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { NewLaptopComponent } from './new-laptop.component'; + +describe('NewLaptopComponent', () => { + let component: NewLaptopComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ NewLaptopComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(NewLaptopComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.ts new file mode 100755 index 00000000..5211c4d3 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/new-laptop/new-laptop.component.ts @@ -0,0 +1,35 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import { LaptopComponent } from '../laptop/laptop.component'; +import { Laptop } from '../models/laptop'; +import { LibraryServiceService } from '../services/library.service'; + +@Component({ + selector: 'app-new-laptop', + templateUrl: './new-laptop.component.html', + styleUrls: ['./new-laptop.component.css'] +}) +export class NewLaptopComponent implements OnInit { + + laptop:Laptop= {} as Laptop + constructor(private router:Router, private library: LibraryServiceService) { } + + ngOnInit(): void { + + } + + + back() + { + this.router.navigate(["/homepage"]) + } + + dodaj(laptop:Laptop) + { + this.library.unesiLaptop(laptop).subscribe(laptop=>{ + this.router.navigate(["/laptop/"+laptop.id]) + }) + } + + +} diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.css b/sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.css new file mode 100755 index 00000000..f918ef97 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.css @@ -0,0 +1,4 @@ +div{ + width: 500px; + margin:auto; +} \ No newline at end of file diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.html b/sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.html new file mode 100755 index 00000000..d1e18002 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.html @@ -0,0 +1,3 @@ +
+

PAGE NOT FOUND ERROR 404

+
\ No newline at end of file diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.spec.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.spec.ts new file mode 100755 index 00000000..aa242a97 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PageNotFoundComponent } from './page-not-found.component'; + +describe('PageNotFoundComponent', () => { + let component: PageNotFoundComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ PageNotFoundComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(PageNotFoundComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.ts b/sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.ts new file mode 100755 index 00000000..8aeb7485 --- /dev/null +++ b/sandbox/TestIvanLjubisavljevic/frontend/src/app/page-not-found/page-not-found.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-page-not-found', + templateUrl: './page-not-found.component.html', + styleUrls: ['./page-not-found.component.css'] +}) +export class PageNotFoundComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} 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