aboutsummaryrefslogtreecommitdiff
path: root/sandbox/testAppSonja/frontend/front/src/app/main-page
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/testAppSonja/frontend/front/src/app/main-page')
-rw-r--r--sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.css0
-rw-r--r--sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.html72
-rw-r--r--sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.spec.ts25
-rw-r--r--sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.ts35
4 files changed, 132 insertions, 0 deletions
diff --git a/sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.css b/sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.css
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.css
diff --git a/sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.html b/sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.html
new file mode 100644
index 00000000..d731a5bd
--- /dev/null
+++ b/sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.html
@@ -0,0 +1,72 @@
+<h2>Spisak studenata</h2>
+
+<table *ngIf="students && students.length > 0">
+ <thead>
+ <tr>
+ <th>Ime i prezime</th>
+ <th>Broj indeksa</th>
+ <th>Prosecna ocena</th>
+ <th>Adresa</th>
+ <th>Broj telefona</th>
+ <th></th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr *ngFor="let student of students">
+ <td>{{student.firstName}} {{student.lastName}}</td>
+ <td>{{student.regNum}}</td>
+ <td>{{student.gpa}}</td>
+ <td>{{student.address}}</td>
+ <td>{{student.phoneNum}}</td>
+ <td>
+ <button><a routerLink="../edit/{{student.id}}" type="button" class="btn btn-primary">Izmeni podatke</a></button>
+ </td>
+ <td>
+ <button type="button" class="btn btn-primary" (click)="pickStudentForDelete(student.id)">Obrisi studenta</button>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<div>
+ <button id="btnDodaj" type="button" class="btn btn-primary"><a routerLink="../add">Dodaj novog studenta</a></button>
+</div>
+
+<!--
+<p *ngIf="!students || !students.length">
+ Nema studenata!
+</p>
+-->
+
+<style>
+
+ h2 {
+ text-align: center;
+ margin-bottom: 50px;
+ }
+
+ table {
+ border-collapse: collapse;
+ width: 60%;
+ margin: auto;
+ }
+
+ th, td {
+ text-align: left;
+ padding: 8px;
+ }
+
+ tr:nth-child(even){background-color: #f2f2f2}
+
+ th {
+ background-color: #04AA6D;
+ color: white;
+ }
+
+ div {
+ text-align: center;
+ padding-top: 70px;
+ }
+
+</style> \ No newline at end of file
diff --git a/sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.spec.ts b/sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.spec.ts
new file mode 100644
index 00000000..c2d5899c
--- /dev/null
+++ b/sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { MainPageComponent } from './main-page.component';
+
+describe('MainPageComponent', () => {
+ let component: MainPageComponent;
+ let fixture: ComponentFixture<MainPageComponent>;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ MainPageComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(MainPageComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.ts b/sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.ts
new file mode 100644
index 00000000..cf749fc3
--- /dev/null
+++ b/sandbox/testAppSonja/frontend/front/src/app/main-page/main-page.component.ts
@@ -0,0 +1,35 @@
+import { Component, OnInit } from '@angular/core';
+import { StudentService } from '../services/student.service';
+import { Student } from '../Student';
+
+@Component({
+ selector: 'app-main-page',
+ templateUrl: './main-page.component.html',
+ styleUrls: ['./main-page.component.css']
+})
+export class MainPageComponent implements OnInit {
+
+ public students: Student[] = [];
+ submitted = false;
+ count: number = 0;
+
+ constructor(private studentService: StudentService) { }
+
+ ngOnInit(): void {
+ this.studentService
+ .getStudents()
+ .subscribe((students : Student[]) => this.students = students);
+ }
+
+ pickStudentForDelete(id: number) {
+ this.studentService.deleteStudent(id)
+ .subscribe(
+ data => {
+ this.submitted = true;
+ this.ngOnInit();
+ //console.log("Data: " + data);
+ }
+ );
+ }
+
+}