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/edit-page/edit-page.component.css | 0 .../src/app/edit-page/edit-page.component.html | 70 ++++++++++++++++++++++ .../src/app/edit-page/edit-page.component.spec.ts | 25 ++++++++ .../front/src/app/edit-page/edit-page.component.ts | 56 +++++++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 sandbox/testAppSonja/frontend/front/src/app/edit-page/edit-page.component.css create mode 100644 sandbox/testAppSonja/frontend/front/src/app/edit-page/edit-page.component.html create mode 100644 sandbox/testAppSonja/frontend/front/src/app/edit-page/edit-page.component.spec.ts create mode 100644 sandbox/testAppSonja/frontend/front/src/app/edit-page/edit-page.component.ts (limited to 'sandbox/testAppSonja/frontend/front/src/app/edit-page') diff --git a/sandbox/testAppSonja/frontend/front/src/app/edit-page/edit-page.component.css b/sandbox/testAppSonja/frontend/front/src/app/edit-page/edit-page.component.css new file mode 100644 index 00000000..e69de29b diff --git a/sandbox/testAppSonja/frontend/front/src/app/edit-page/edit-page.component.html b/sandbox/testAppSonja/frontend/front/src/app/edit-page/edit-page.component.html new file mode 100644 index 00000000..3faaca85 --- /dev/null +++ b/sandbox/testAppSonja/frontend/front/src/app/edit-page/edit-page.component.html @@ -0,0 +1,70 @@ +
+
+ + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+ +

+ Povratak na spisak studenata + +
+ + \ No newline at end of file diff --git a/sandbox/testAppSonja/frontend/front/src/app/edit-page/edit-page.component.spec.ts b/sandbox/testAppSonja/frontend/front/src/app/edit-page/edit-page.component.spec.ts new file mode 100644 index 00000000..898e7568 --- /dev/null +++ b/sandbox/testAppSonja/frontend/front/src/app/edit-page/edit-page.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EditPageComponent } from './edit-page.component'; + +describe('EditPageComponent', () => { + let component: EditPageComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ EditPageComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(EditPageComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/sandbox/testAppSonja/frontend/front/src/app/edit-page/edit-page.component.ts b/sandbox/testAppSonja/frontend/front/src/app/edit-page/edit-page.component.ts new file mode 100644 index 00000000..e86c1f39 --- /dev/null +++ b/sandbox/testAppSonja/frontend/front/src/app/edit-page/edit-page.component.ts @@ -0,0 +1,56 @@ +import { Component, OnInit } from '@angular/core'; +import { NgForm } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { StudentService } from '../services/student.service'; +import { Student } from '../Student'; + +@Component({ + selector: 'app-edit-page', + templateUrl: './edit-page.component.html', + styleUrls: ['./edit-page.component.css'] +}) +export class EditPageComponent implements OnInit { + + submitted = false; + id: number = -1; + student = new Student(); + + constructor(private studentService: StudentService, private route: ActivatedRoute, private router: Router) { } + + ngOnInit(): void { + this.route.paramMap.subscribe( + params => this.id = parseInt(params.get('id')!) + ); + + this.loadOneStudent(); + } + + loadOneStudent() { + this.studentService.getOneStudent(this.id) + .subscribe( + data => this.student = data + ) + } + + handleSubmit(f: NgForm) { //f.value su name-ovi pokupljeni iz forme pa njihove vrednosti + let editedStudent : Student = { + id: f.value.id, + firstName: f.value.firstname, //znaci ovo je name iz forme + lastName: f.value.lastname, + regNum: f.value.regNum, + address: f.value.address, + phoneNum: f.value.phone, + gpa: f.value.gpa + } + + this.studentService.updateStudent(this.id, editedStudent) + .subscribe( + data => { + this.submitted = true; + //console.log("Form:", f.value); + this.router.navigate(['']); + } + ) + } + +} -- cgit v1.2.3