aboutsummaryrefslogtreecommitdiff
path: root/sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop')
-rwxr-xr-xsandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.css10
-rwxr-xr-xsandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.html25
-rwxr-xr-xsandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.spec.ts25
-rwxr-xr-xsandbox/TestIvanLjubisavljevic/frontend/src/app/izmeni-laptop/izmeni-laptop.component.ts43
4 files changed, 103 insertions, 0 deletions
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 @@
+<div *ngIf="laptop" id="forma">
+ <label>Brand:</label>
+ <input type="text" [(ngModel)]="laptop.brand" ><br>
+ <label>Model:</label>
+ <input type="text" [(ngModel)]="laptop.model"><br>
+ <label>Ram:</label>
+ <input type="number" [(ngModel)]="laptop.ram"> <br>
+ <label>Memorija:</label>
+ <input type="number" [(ngModel)]="laptop.hdd"> <br>
+ <label>Grafika:</label>
+ <input type="text" [(ngModel)]="laptop.graphics"> <br>
+ <label>Ekran:</label>
+ <input type="text" [(ngModel)]="laptop.display"> <br>
+ <label>Procesor:</label>
+ <input type="text" [(ngModel)]="laptop.processor"><br>
+ <label>Cena:</label>
+ <input type="number" [(ngModel)]="laptop.price"><br>
+
+ <button (click)="izmeni(laptop)">Sačuvaj izmene</button><br>
+ <button (click)="back()">Nazad na početnu</button>
+</div>
+
+<div *ngIf="izmenio" id="forma">
+ <p style="color:green">Uspešno izmenjeni podaci!</p>
+</div> \ 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<IzmeniLaptopComponent>;
+
+ 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"])
+ }
+
+
+
+}