aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_pages
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/app/_pages')
-rw-r--r--frontend/src/app/_pages/my-models/my-models.component.html32
-rw-r--r--frontend/src/app/_pages/my-models/my-models.component.ts51
2 files changed, 69 insertions, 14 deletions
diff --git a/frontend/src/app/_pages/my-models/my-models.component.html b/frontend/src/app/_pages/my-models/my-models.component.html
index e94f67f5..870e0ddb 100644
--- a/frontend/src/app/_pages/my-models/my-models.component.html
+++ b/frontend/src/app/_pages/my-models/my-models.component.html
@@ -1,5 +1,27 @@
-<ul class="list-group my-2">
- <li class="list-group-item" *ngFor="let model of myModels">
- <app-item-model [model]="model"></app-item-model>
- </li>
-</ul> \ No newline at end of file
+<div id="wrapper">
+ <div id="container" class="container p-5" style="background-color: white; min-height: 100%;">
+ <div class="row mt-3 mb-2 d-flex justify-content-center">
+
+ <div class="col-sm-6" style="margin-bottom: 10px;">
+ </div>
+
+ <div class="row">
+ <div class="col-sm-4" style="margin-bottom: 10px;" *ngFor="let model of myModels">
+ <app-item-model [model]="model"></app-item-model>
+ <div style="width: 25%; margin: auto;">
+ <button (click)="deleteThisModel(model)" style="margin-top: 3px; width: 100%;">Obriši</button>
+ </div>
+ </div>
+ </div>
+ <div class="text-center" *ngIf="this.myModels.length == 0" >
+ <h2>Nema rezultata</h2>
+ </div>
+ </div>
+
+ </div>
+
+
+
+
+
+ </div>
diff --git a/frontend/src/app/_pages/my-models/my-models.component.ts b/frontend/src/app/_pages/my-models/my-models.component.ts
index 3ab57e59..bd6b0a2b 100644
--- a/frontend/src/app/_pages/my-models/my-models.component.ts
+++ b/frontend/src/app/_pages/my-models/my-models.component.ts
@@ -1,22 +1,55 @@
import { Component, OnInit } from '@angular/core';
import Model from 'src/app/_data/Model';
+import { ModelsService } from 'src/app/_services/models.service';
@Component({
selector: 'app-my-models',
templateUrl: './my-models.component.html',
styleUrls: ['./my-models.component.css']
})
-export class MyModelsComponent /*implements OnInit*/ {
- myModels: Model[];
+export class MyModelsComponent implements OnInit {
+ myModels: Model[] = [];
+ //myModel: Model;
- constructor() {
- this.myModels = [
- new Model('Titanik', 'Opis titanik'),
- new Model('Neki drugi set', 'opis'),
- new Model('Treci set', 'opis')
- ]; }
+ constructor(private modelsS : ModelsService) {
+
+
+
+ }
+
+ ngOnInit(): void {
+ this.getAllMyModels();
- /*ngOnInit(): void {
+ }
+/*
+ editModel(): void{
+ this.modelsS.editModel().subscribe(m => {
+ this.myModel = m;
+
+ })
}
*/
+
+deleteThisModel(model: Model): void{
+ console.log("OK");
+ this.modelsS.deleteModel(model).subscribe((response) => {
+ console.log("OBRISANOOO JEE", response);
+ //na kraju uspesnog
+ this.getAllMyModels();
+ }, (error) =>{
+ if (error.error == "Model with name = {name} deleted") {
+ alert("Greška pri brisanju modela!");
+ }
+ });
+
+}
+
+ getAllMyModels(): void{
+ this.modelsS.getMyModels().subscribe(m => {
+
+ this.myModels = m;
+ console.log(this.myModels);
+ });
+ }
+
}