aboutsummaryrefslogtreecommitdiff
path: root/frontend/src
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src')
-rw-r--r--frontend/src/app/Shared.ts3
-rw-r--r--frontend/src/app/_data/Dataset.ts4
-rw-r--r--frontend/src/app/_data/Model.ts4
-rw-r--r--frontend/src/app/_data/Predictor.ts1
-rw-r--r--frontend/src/app/_elements/dataset-load/dataset-load.component.ts41
-rw-r--r--frontend/src/app/_elements/navbar/navbar.component.html3
-rw-r--r--frontend/src/app/_pages/add-model/add-model.component.html147
-rw-r--r--frontend/src/app/_pages/add-model/add-model.component.ts46
-rw-r--r--frontend/src/app/_pages/home/home.component.html2
-rw-r--r--frontend/src/app/_pages/my-datasets/my-datasets.component.html6
-rw-r--r--frontend/src/app/_pages/my-datasets/my-datasets.component.ts11
-rw-r--r--frontend/src/app/_services/auth.service.ts3
-rw-r--r--frontend/src/app/_services/models.service.ts30
-rw-r--r--frontend/src/app/app-routing.module.ts20
-rw-r--r--frontend/src/app/app.component.spec.ts6
-rw-r--r--frontend/src/app/app.component.ts33
16 files changed, 225 insertions, 135 deletions
diff --git a/frontend/src/app/Shared.ts b/frontend/src/app/Shared.ts
index 126dc846..0adcd4d6 100644
--- a/frontend/src/app/Shared.ts
+++ b/frontend/src/app/Shared.ts
@@ -1,6 +1,7 @@
class Shared {
constructor(
- public loggedIn: boolean
+ public loggedIn: boolean,
+ public username: string = ''
) { }
}
diff --git a/frontend/src/app/_data/Dataset.ts b/frontend/src/app/_data/Dataset.ts
index aaee50eb..6e6cbffe 100644
--- a/frontend/src/app/_data/Dataset.ts
+++ b/frontend/src/app/_data/Dataset.ts
@@ -1,4 +1,5 @@
export default class Dataset {
+ _id: string = '';
constructor(
public name: string = 'Novi izvor podataka',
public description: string = '',
@@ -8,6 +9,7 @@ export default class Dataset {
public isPublic: boolean = false,
public accessibleByLink: boolean = false,
public dateCreated: Date = new Date(),
- public lastUpdated: Date = new Date()
+ public lastUpdated: Date = new Date(),
+ public username: string = 'tester1'
) { }
} \ No newline at end of file
diff --git a/frontend/src/app/_data/Model.ts b/frontend/src/app/_data/Model.ts
index c0bc339d..a891c10c 100644
--- a/frontend/src/app/_data/Model.ts
+++ b/frontend/src/app/_data/Model.ts
@@ -1,4 +1,5 @@
export default class Model {
+ _id: string = '';
constructor(
public name: string = 'Novi model',
public description: string = '',
@@ -24,7 +25,8 @@ export default class Model {
public batchSize: number = 5,
public inputLayerActivationFunction: ActivationFunction = ActivationFunction.Sigmoid,
public hiddenLayerActivationFunction: ActivationFunction = ActivationFunction.Sigmoid,
- public outputLayerActivationFunction: ActivationFunction = ActivationFunction.Sigmoid
+ public outputLayerActivationFunction: ActivationFunction = ActivationFunction.Sigmoid,
+ public username: string = ''
) { }
}
diff --git a/frontend/src/app/_data/Predictor.ts b/frontend/src/app/_data/Predictor.ts
index 05b993f1..7e902eae 100644
--- a/frontend/src/app/_data/Predictor.ts
+++ b/frontend/src/app/_data/Predictor.ts
@@ -1,4 +1,5 @@
export default class Predictor {
+ _id: string = '';
constructor(
public name: string = 'Novi prediktor',
public description: string = '',
diff --git a/frontend/src/app/_elements/dataset-load/dataset-load.component.ts b/frontend/src/app/_elements/dataset-load/dataset-load.component.ts
index 8465c3d6..913592eb 100644
--- a/frontend/src/app/_elements/dataset-load/dataset-load.component.ts
+++ b/frontend/src/app/_elements/dataset-load/dataset-load.component.ts
@@ -19,7 +19,7 @@ export class DatasetLoadComponent {
slice: string = "";
csvRecords: any[] = [];
- files: any[] = [];
+ files: File[] = [];
rowsNumber: number = 0;
colsNumber: number = 0;
@@ -33,6 +33,7 @@ export class DatasetLoadComponent {
changeListener($event: any): void {
this.files = $event.srcElement.files;
+ console.log(this.files);
this.update();
}
@@ -41,25 +42,25 @@ export class DatasetLoadComponent {
if (this.files.length < 1)
return;
- this.ngxCsvParser.parse(this.files[0], { header: false, delimiter: (this.delimiter == "razmak") ? " " : (this.delimiter == "") ? "," : this.delimiter})
- .pipe().subscribe((result) => {
-
- console.log('Result', result);
- if (result.constructor === Array) {
- this.csvRecords = result;
- if (this.hasHeader)
- this.rowsNumber = this.csvRecords.length - 1;
- else
- this.rowsNumber = this.csvRecords.length;
- this.colsNumber = this.csvRecords[0].length;
-
- this.dataset.header = this.csvRecords[0];
-
- this.loaded.emit("loaded");
- }
- }, (error: NgxCSVParserError) => {
- console.log('Error', error);
- });
+ this.ngxCsvParser.parse(this.files[0], { header: false, delimiter: (this.delimiter == "razmak") ? " " : (this.delimiter == "") ? "," : this.delimiter })
+ .pipe().subscribe((result) => {
+
+ console.log('Result', result);
+ if (result.constructor === Array) {
+ this.csvRecords = result;
+ if (this.hasHeader)
+ this.rowsNumber = this.csvRecords.length - 1;
+ else
+ this.rowsNumber = this.csvRecords.length;
+ this.colsNumber = this.csvRecords[0].length;
+
+ this.dataset.header = this.csvRecords[0];
+
+ this.loaded.emit("loaded");
+ }
+ }, (error: NgxCSVParserError) => {
+ console.log('Error', error);
+ });
}
}
diff --git a/frontend/src/app/_elements/navbar/navbar.component.html b/frontend/src/app/_elements/navbar/navbar.component.html
index b9c450af..52e26e6b 100644
--- a/frontend/src/app/_elements/navbar/navbar.component.html
+++ b/frontend/src/app/_elements/navbar/navbar.component.html
@@ -11,7 +11,8 @@
<li><a routerLink="add-model" class="nav-link px-2"
[class]="(currentUrl === '/add-model') ? 'text-secondary' : 'text-white'">Dodaj model</a></li>
<li><a routerLink="my-predictors" class="nav-link px-2"
- [class]="(currentUrl === '/my-predictors') ? 'text-secondary' : 'text-white'">Predvidi</a></li>
+ [class]="(currentUrl === '/my-predictors') ? 'text-secondary' : 'text-white' + (shared.loggedIn) ? '' : 'disabled'">Predvidi</a>
+ </li>
</ul>
<div *ngIf="shared.loggedIn" class="dropdown text-end">
diff --git a/frontend/src/app/_pages/add-model/add-model.component.html b/frontend/src/app/_pages/add-model/add-model.component.html
index 004f308b..c6f21f1e 100644
--- a/frontend/src/app/_pages/add-model/add-model.component.html
+++ b/frontend/src/app/_pages/add-model/add-model.component.html
@@ -3,15 +3,15 @@
</div>
<div id="wrapper">
-
+
<div id="container" class="container p-5" style="background-color: white; min-height: 100%;">
-
- <div class="form-group row mb-4 d-flex justify-content-center"> <!--justify-content-center-->
+
+ <div class="form-group row mb-4 d-flex justify-content-center">
+ <!--justify-content-center-->
<h2 class="col-2"> Nov model: </h2>
<div class="col-3">
- <label for="name" class="col-form-label">Naziv modela:</label>
- <input type="text" class="form-control" name="name" placeholder="Naziv..."
- [(ngModel)]="newModel.name">
+ <label for="name" class="col-form-label">Naziv modela:</label>
+ <input type="text" class="form-control" name="name" placeholder="Naziv..." [(ngModel)]="newModel.name">
</div>
<div class="col-5">
<label for="desc" class="col-sm-2 col-form-label">Opis:</label>
@@ -25,7 +25,7 @@
value="{{newModel.dateCreated | date: 'dd/MM/yyyy'}}" readonly>
</div>
</div>
-
+
<div class="mt-5 justify-content-center">
<h2>Izvor podataka:</h2>
<app-dataset-load id="dataset" (loaded)="datasetLoaded = true"></app-dataset-load>
@@ -33,37 +33,41 @@
<div *ngIf="datasetLoaded">
<div *ngIf="datasetLoadComponent" class="row">
- <div class="col d-flex justify-content-center">
- <h3>Izaberite ulazne kolone:</h3>
- <div id="divInputs" class="form-check mt-2">
- <br>
- <div *ngFor="let item of datasetLoadComponent.dataset.header; let i = index">
- <input *ngIf="i == 0" class="form-check-input" type="checkbox" value="{{item}}" id="cb_{{item}}" name="cbs" checked>
- <input *ngIf="i != 0" class="form-check-input" type="checkbox" value="{{item}}" id="cb_{{item}}" name="cbs">&nbsp;
- <label class="form-check-label" for="cb_{{item}}">
- {{item}}
- </label>
- </div>
- </div>
- </div>
- <div class="col d-flex justify-content-left">
- <h3>Izaberite izlaznu kolonu:</h3>
- <div id="divOutputs" class="form-check mt-2">
- <br>
- <div *ngFor="let item of datasetLoadComponent.dataset.header; let i = index">
- <input *ngIf="i == 0" class="form-check-input" type="radio" value="{{item}}" id="rb_{{item}}" name="rbs" checked>
- <input *ngIf="i != 0" class="form-check-input" type="radio" value="{{item}}" id="rb_{{item}}" name="rbs">&nbsp;
- <label class="form-check-label" for="rb_{{item}}">
- {{item}}
- </label>
- </div>
- </div>
- </div>
+ <div class="col d-flex justify-content-center">
+ <h3>Izaberite ulazne kolone:</h3>
+ <div id="divInputs" class="form-check mt-2">
+ <br>
+ <div *ngFor="let item of datasetLoadComponent.dataset.header; let i = index">
+ <input *ngIf="i == 0" class="form-check-input" type="checkbox" value="{{item}}"
+ id="cb_{{item}}" name="cbs" checked>
+ <input *ngIf="i != 0" class="form-check-input" type="checkbox" value="{{item}}"
+ id="cb_{{item}}" name="cbs">&nbsp;
+ <label class="form-check-label" for="cb_{{item}}">
+ {{item}}
+ </label>
+ </div>
+ </div>
+ </div>
+ <div class="col d-flex justify-content-left">
+ <h3>Izaberite izlaznu kolonu:</h3>
+ <div id="divOutputs" class="form-check mt-2">
+ <br>
+ <div *ngFor="let item of datasetLoadComponent.dataset.header; let i = index">
+ <input *ngIf="i == 0" class="form-check-input" type="radio" value="{{item}}"
+ id="rb_{{item}}" name="rbs" checked>
+ <input *ngIf="i != 0" class="form-check-input" type="radio" value="{{item}}"
+ id="rb_{{item}}" name="rbs">&nbsp;
+ <label class="form-check-label" for="rb_{{item}}">
+ {{item}}
+ </label>
+ </div>
+ </div>
+ </div>
</div>
</div>
-
-
+
+
<h2 class="mt-5 mb-4">Parametri treniranja:</h2>
<div>
@@ -87,7 +91,8 @@
<label for="hiddenLayers" class="col-form-label">Broj skrivenih slojeva: </label>
</div>
<div class="col-1">
- <input type="number" min="1" class="form-control" name="hiddenLayers" [(ngModel)]="newModel.hiddenLayers">
+ <input type="number" min="1" class="form-control" name="hiddenLayers"
+ [(ngModel)]="newModel.hiddenLayers">
</div>
</div>
@@ -111,7 +116,8 @@
<label for="hiddenLayerNeurons" class="col-form-label">Broj neurona skrivenih slojeva: </label>
</div>
<div class="col-1">
- <input type="number" min="1" class="form-control" name="hiddenLayerNeurons" [(ngModel)]="newModel.hiddenLayerNeurons">
+ <input type="number" min="1" class="form-control" name="hiddenLayerNeurons"
+ [(ngModel)]="newModel.hiddenLayerNeurons">
</div>
</div>
@@ -123,7 +129,8 @@
</div>
<div class="col-2">
<select id=optimizerOptions class="form-control" name="optimizer" [(ngModel)]="newModel.optimizer">
- <option *ngFor="let option of Object.keys(Optimizer); let optionName of Object.values(Optimizer)"
+ <option
+ *ngFor="let option of Object.keys(Optimizer); let optionName of Object.values(Optimizer)"
[value]="option">
{{ optionName }}
</option>
@@ -146,8 +153,10 @@
<label for="lossFunction" class="col-form-label">Funkcija obrade gubitka: </label>
</div>
<div class="col-2">
- <select id=lossFunctionOptions class="form-control" name="lossFunction" [(ngModel)]="newModel.lossFunction">
- <option *ngFor="let option of Object.keys(LossFunction); let optionName of Object.values(LossFunction)"
+ <select id=lossFunctionOptions class="form-control" name="lossFunction"
+ [(ngModel)]="newModel.lossFunction">
+ <option
+ *ngFor="let option of Object.keys(LossFunction); let optionName of Object.values(LossFunction)"
[value]="option">
{{ optionName }}
</option>
@@ -157,7 +166,8 @@
</div>
<div class="col-3 mt-2">
<label for="type" class="form-check-label">Nasumičan redosled podataka?</label>
- <input class="mx-3 form-check-input" type="checkbox" [(ngModel)]="newModel.randomOrder" type="checkbox" value="" checked>
+ <input class="mx-3 form-check-input" type="checkbox" [(ngModel)]="newModel.randomOrder"
+ type="checkbox" value="" checked>
</div>
<div class="col-1">
</div>
@@ -167,17 +177,18 @@
<div class="col-1">
</div>
<div class="col-3">
- <label for="inputLayerActivationFunction" class="col-form-label">Funkcija aktivacije ulaznog sloja:</label>
+ <label for="inputLayerActivationFunction" class="col-form-label">Funkcija aktivacije ulaznog
+ sloja:</label>
</div>
<div class="col-2">
- <select id=inputLayerActivationFunctionOptions class="form-control" name="inputLayerActivationFunction"
- [(ngModel)]="newModel.inputLayerActivationFunction">
- <option
- *ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)"
- [value]="option">
- {{ optionName }}
- </option>
- </select>
+ <select id=inputLayerActivationFunctionOptions class="form-control"
+ name="inputLayerActivationFunction" [(ngModel)]="newModel.inputLayerActivationFunction">
+ <option
+ *ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)"
+ [value]="option">
+ {{ optionName }}
+ </option>
+ </select>
</div>
<div class="col-1">
</div>
@@ -188,7 +199,7 @@
</label> &nbsp;&nbsp;&nbsp;&nbsp;
test
<mat-slider min="0.1" max="0.9" step="0.1" value="0.2" name="randomTestSetDistribution" thumbLabel
- [disabled]="!newModel.randomTestSet" [(ngModel)]="newModel.randomTestSetDistribution">
+ [disabled]="!newModel.randomTestSet" [(ngModel)]="newModel.randomTestSetDistribution">
</mat-slider>
trening
</div>
@@ -200,16 +211,17 @@
<div class="col-1">
</div>
<div class="col-3">
- <label for="hiddenLayerActivationFunction" class="col-form-label">Funkcija aktivacije skrivenih slojeva:</label>
+ <label for="hiddenLayerActivationFunction" class="col-form-label">Funkcija aktivacije skrivenih
+ slojeva:</label>
</div>
<div class="col-2">
- <select id=hiddenLayerActivationFunctionOptions class="form-control" name="hiddenLayerActivationFunction"
- [(ngModel)]="newModel.hiddenLayerActivationFunction">
- <option
- *ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)"
- [value]="option">
- {{ optionName }}
- </option>
+ <select id=hiddenLayerActivationFunctionOptions class="form-control"
+ name="hiddenLayerActivationFunction" [(ngModel)]="newModel.hiddenLayerActivationFunction">
+ <option
+ *ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)"
+ [value]="option">
+ {{ optionName }}
+ </option>
</select>
</div>
<div class="col">
@@ -222,11 +234,12 @@
<div class="col-1">
</div>
<div class="col-3">
- <label for="outputLayerActivationFunction" class="col-form-label">Funkcija aktivacije izlaznog sloja:</label>
+ <label for="outputLayerActivationFunction" class="col-form-label">Funkcija aktivacije izlaznog
+ sloja:</label>
</div>
<div class="col-2">
- <select id=outputLayerActivationFunctionOptions class="form-control" name="outputLayerActivationFunction"
- [(ngModel)]="newModel.outputLayerActivationFunction">
+ <select id=outputLayerActivationFunctionOptions class="form-control"
+ name="outputLayerActivationFunction" [(ngModel)]="newModel.outputLayerActivationFunction">
<option
*ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)"
[value]="option">
@@ -245,13 +258,13 @@
<br><br>
<div class="form-group row mt-5 mb-3">
<div class="col"></div>
- <button class="btn btn-lg col-4" style="background-color:#003459; color:white;" (click)="addModel();">Sačuvaj model</button>
+ <button class="btn btn-lg col-4" style="background-color:#003459; color:white;"
+ (click)="addModel();">Sačuvaj model</button>
<div class="col"></div>
- <button class="btn btn-lg col-4" style="background-color:#003459; color:white;" (click)="trainModel();">Treniraj model</button>
+ <button class="btn btn-lg col-4 disabled" style="background-color:#003459; color:white;"
+ (click)="trainModel();">Treniraj model</button>
<div class="col"></div>
</div>
</div>
-</div>
-
-
+</div> \ No newline at end of file
diff --git a/frontend/src/app/_pages/add-model/add-model.component.ts b/frontend/src/app/_pages/add-model/add-model.component.ts
index 01e8ade9..a4cabb82 100644
--- a/frontend/src/app/_pages/add-model/add-model.component.ts
+++ b/frontend/src/app/_pages/add-model/add-model.component.ts
@@ -4,6 +4,7 @@ import Model from 'src/app/_data/Model';
import { ANNType, Encoding, ActivationFunction, LossFunction, Optimizer } from 'src/app/_data/Model';
import { DatasetLoadComponent } from 'src/app/_elements/dataset-load/dataset-load.component';
import { ModelsService } from 'src/app/_services/models.service';
+import shared from 'src/app/Shared';
@Component({
@@ -24,6 +25,7 @@ export class AddModelComponent implements OnInit {
LossFunction = LossFunction;
Optimizer = Optimizer;
Object = Object;
+ shared = shared;
constructor(private models: ModelsService) {
this.newModel = new Model();
@@ -35,23 +37,37 @@ export class AddModelComponent implements OnInit {
addModel() {
this.saveModel(false); //trajno cuvanje
}
+
trainModel() {
- this.saveModel(true).subscribe((modelId : any) => {
+ this.saveModel(true).subscribe((modelId: any) => {
if (modelId)
this.models.trainModel(modelId);
}); //privremeno cuvanje modela => vraca id sacuvanog modela koji cemo da treniramo sad
}
- saveModel(temporary: boolean) : any {
- if (this.datasetLoadComponent)
- this.models.addDataset(this.datasetLoadComponent?.dataset).subscribe((response) => {//id dataseta je response
- this.newModel.datasetId = response;
- this.getCheckedInputCols();
- this.getCheckedOutputCol();
- if (this.validationInputsOutput())
- return this.models.addModel(this.newModel); //id modela
- return of(null);
- });
+ saveModel(temporary: boolean): any {
+ this.getCheckedInputCols();
+ this.getCheckedOutputCol();
+ if (this.validationInputsOutput()) {
+ console.log('ADD MODEL: STEP 1 - UPLOAD FILE');
+ if (this.datasetLoadComponent) {
+ this.models.uploadData(this.datasetLoadComponent.files[0]).subscribe((file) => {
+ console.log('ADD MODEL: STEP 2 - ADD DATASET WITH FILE ID ' + file._id);
+ if (this.datasetLoadComponent) {
+ this.datasetLoadComponent.dataset.fileId = file._id;
+ this.datasetLoadComponent.dataset.username = shared.username;
+ this.models.addDataset(this.datasetLoadComponent.dataset).subscribe((dataset) => {
+ console.log('ADD MODEL: STEP 3 - ADD MODEL WITH DATASET ID ', dataset._id);
+ this.newModel.datasetId = dataset._id;
+ this.newModel.username = shared.username;
+ this.models.addModel(this.newModel).subscribe((response) => {
+ console.log('ADD MODEL: DONE! REPLY:\n', response);
+ });
+ });
+ }
+ });
+ }
+ }
}
getCheckedInputCols() {
@@ -73,17 +89,17 @@ export class AddModelComponent implements OnInit {
let thatRb = <HTMLInputElement>radiobuttons[i];
if (thatRb.checked) {
this.newModel.columnToPredict = thatRb.value;
- break;
+ break;
}
}
//console.log(this.checkedOutputCol);
}
- validationInputsOutput() : boolean {
+ validationInputsOutput(): boolean {
if (this.newModel.inputColumns.length == 0) {
alert("Molimo Vas da izaberete ulaznu kolonu/kolone za mrežu.")
return false;
- }
- for (let i = 0; i < this.newModel.inputColumns.length; i++) {
+ }
+ for (let i = 0; i < this.newModel.inputColumns.length; i++) {
if (this.newModel.inputColumns[i] == this.newModel.columnToPredict) {
let colName = this.newModel.columnToPredict;
alert("Izabrali ste istu kolonu (" + colName + ") kao ulaznu i izlaznu iz mreže. Korigujte izbor.");
diff --git a/frontend/src/app/_pages/home/home.component.html b/frontend/src/app/_pages/home/home.component.html
index 7245f602..274f0fd8 100644
--- a/frontend/src/app/_pages/home/home.component.html
+++ b/frontend/src/app/_pages/home/home.component.html
@@ -47,7 +47,9 @@
<h2 class="my-4">Pogledajte javne izvore podataka!</h2>
<app-carousel [items]="publicDatasets">
</app-carousel>
+ <h3><a routerLink="browse-datasets">Pogledaj sve javne izvore podataka...</a></h3>
<h2 class="my-4">Iskoristite već trenirane modele!</h2>
<app-carousel [items]="publicPredictors">
</app-carousel>
+ <h3><a routerLink="browse-predictors">Pogledaj sve javne trenirane modele...</a></h3>
</div> \ No newline at end of file
diff --git a/frontend/src/app/_pages/my-datasets/my-datasets.component.html b/frontend/src/app/_pages/my-datasets/my-datasets.component.html
index 4b3095be..623b9ac8 100644
--- a/frontend/src/app/_pages/my-datasets/my-datasets.component.html
+++ b/frontend/src/app/_pages/my-datasets/my-datasets.component.html
@@ -1 +1,5 @@
-<p>my-datasets works!</p>
+<ul class="list-group my-2">
+ <li class="list-group-item" *ngFor="let dataset of myDatasets">
+ <app-item-dataset [dataset]="dataset"></app-item-dataset>
+ </li>
+</ul> \ No newline at end of file
diff --git a/frontend/src/app/_pages/my-datasets/my-datasets.component.ts b/frontend/src/app/_pages/my-datasets/my-datasets.component.ts
index af5eab97..13b0c47b 100644
--- a/frontend/src/app/_pages/my-datasets/my-datasets.component.ts
+++ b/frontend/src/app/_pages/my-datasets/my-datasets.component.ts
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
+import Dataset from 'src/app/_data/Dataset';
@Component({
selector: 'app-my-datasets',
@@ -7,7 +8,15 @@ import { Component, OnInit } from '@angular/core';
})
export class MyDatasetsComponent implements OnInit {
- constructor() { }
+ myDatasets?: Dataset[];
+
+ constructor() {
+ this.myDatasets = [
+ new Dataset('Titanik', 'Opis titanik', ['K1', 'K2', 'K3', 'Ime', 'Preziveli']),
+ new Dataset('Neki drugi set', 'opis', ['a', 'b', 'c']),
+ new Dataset('Treci set', 'opis', ['a', 'b', 'c'])
+ ];
+ }
ngOnInit(): void {
}
diff --git a/frontend/src/app/_services/auth.service.ts b/frontend/src/app/_services/auth.service.ts
index afc1567b..20ff45f3 100644
--- a/frontend/src/app/_services/auth.service.ts
+++ b/frontend/src/app/_services/auth.service.ts
@@ -46,7 +46,7 @@ export class AuthService {
this.http.post(`${API_SETTINGS.apiURL}/auth/renewJwt`, {}, { headers: this.authHeader(), responseType: 'text' }).subscribe((response) => {
this.authenticate(response);
});
- }, exp.getTime() - new Date().getTime());
+ }, exp.getTime() - new Date().getTime() - 60000);
}
authenticate(token: string) {
@@ -62,6 +62,7 @@ export class AuthService {
if (this.cookie.check('token')) {
const token = this.cookie.get('token');
this.shared.loggedIn = this.isAuthenticated();
+ this.shared.username = jwtHelper.decodeToken(token).name;
this.enableAutoRefresh();
}
}
diff --git a/frontend/src/app/_services/models.service.ts b/frontend/src/app/_services/models.service.ts
index 80dc1ae3..8299016b 100644
--- a/frontend/src/app/_services/models.service.ts
+++ b/frontend/src/app/_services/models.service.ts
@@ -1,9 +1,10 @@
-import { HttpClient } from '@angular/common/http';
+import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http';
import { Injectable } from '@angular/core';
import Model from '../_data/Model';
import { AuthService } from './auth.service';
import { API_SETTINGS } from 'src/config';
import Dataset from '../_data/Dataset';
+import { Observable } from 'rxjs';
@Injectable({
@@ -13,13 +14,28 @@ export class ModelsService {
constructor(private http: HttpClient, private authService: AuthService) { }
- addModel(model: Model) {
- return this.http.post(`${API_SETTINGS.apiURL}/model/add`, model, { headers: this.authService.authHeader(), responseType: 'text' });
+ uploadData(file: File): Observable<any> {
+ let formData = new FormData();
+ formData.append('file', file, file.name);
+
+ let params = new HttpParams();
+
+ const options = {
+ params: params,
+ reportProgress: false,
+ headers: this.authService.authHeader()
+ };
+
+ return this.http.post(`${API_SETTINGS.apiURL}/file/csv`, formData, options);
+ }
+
+ addModel(model: Model): Observable<any> {
+ return this.http.post(`${API_SETTINGS.apiURL}/model/add`, model, { headers: this.authService.authHeader() });
}
- addDataset(dataset: Dataset) {
- return this.http.post(`${API_SETTINGS.apiURL}/dataset/add`, dataset, { headers: this.authService.authHeader(), responseType: 'text' });
+ addDataset(dataset: Dataset): Observable<any> {
+ return this.http.post(`${API_SETTINGS.apiURL}/dataset/add`, dataset, { headers: this.authService.authHeader() });
}
- trainModel(modelId: string) {
- return this.http.post(`${API_SETTINGS.apiURL}/model/train`, modelId, { headers: this.authService.authHeader(), responseType: 'text' });
+ trainModel(modelId: string): Observable<any> {
+ return this.http.post(`${API_SETTINGS.apiURL}/model/train`, modelId, { headers: this.authService.authHeader() });
}
}
diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts
index ee43b522..001d0b4f 100644
--- a/frontend/src/app/app-routing.module.ts
+++ b/frontend/src/app/app-routing.module.ts
@@ -14,16 +14,16 @@ import { ProfileComponent } from './_pages/profile/profile.component';
import { PredictComponent } from './_pages/predict/predict.component';
const routes: Routes = [
- { path: '', component: HomeComponent },
- { path: 'add-model', component: AddModelComponent },
- { path: 'my-datasets', component: MyDatasetsComponent, canActivate: [AuthGuardService] },
- { path: 'my-models', component: MyModelsComponent, canActivate: [AuthGuardService] },
- { path: 'my-predictors', component: MyPredictorsComponent, canActivate: [AuthGuardService] },
- { path: 'settings', component: SettingsComponent, canActivate: [AuthGuardService] },
- { path: 'profile', component: ProfileComponent, canActivate: [AuthGuardService] },
- { path: 'browse-datasets', component: BrowseDatasetsComponent },
- { path: 'browse-predictors', component: BrowsePredictorsComponent },
- { path: 'predict', component: PredictComponent }
+ { path: '', component: HomeComponent, data: { title: 'Početna strana' } },
+ { path: 'add-model', component: AddModelComponent, data: { title: 'Dodaj model' } },
+ { path: 'my-datasets', component: MyDatasetsComponent, canActivate: [AuthGuardService], data: { title: 'Moji izvori podataka' } },
+ { path: 'my-models', component: MyModelsComponent, canActivate: [AuthGuardService], data: { title: 'Moji modeli' } },
+ { path: 'my-predictors', component: MyPredictorsComponent, canActivate: [AuthGuardService], data: { title: 'Moji trenirani modeli' } },
+ { path: 'settings', component: SettingsComponent, canActivate: [AuthGuardService], data: { title: 'Podešavanja' } },
+ { path: 'profile', component: ProfileComponent, canActivate: [AuthGuardService], data: { title: 'Profil' } },
+ { path: 'browse-datasets', component: BrowseDatasetsComponent, data: { title: 'Javni izvori podataka' } },
+ { path: 'browse-predictors', component: BrowsePredictorsComponent, data: { title: 'Javni trenirani modeli' } },
+ { path: 'predict', component: PredictComponent, data: { title: 'Predvidi vrednosti' } }
];
@NgModule({
diff --git a/frontend/src/app/app.component.spec.ts b/frontend/src/app/app.component.spec.ts
index 74b5b3eb..d0679f89 100644
--- a/frontend/src/app/app.component.spec.ts
+++ b/frontend/src/app/app.component.spec.ts
@@ -20,12 +20,6 @@ describe('AppComponent', () => {
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();
diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts
index 9d6b2f11..f5ae5786 100644
--- a/frontend/src/app/app.component.ts
+++ b/frontend/src/app/app.component.ts
@@ -1,10 +1,37 @@
-import { Component } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
+import { Title } from '@angular/platform-browser';
+import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
+import { filter, map } from 'rxjs';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
-export class AppComponent {
- title = 'frontend';
+export class AppComponent implements OnInit {
+
+ constructor(private router: Router, private titleService: Title) { }
+
+ ngOnInit() {
+ this.router.events
+ .pipe(
+ filter((event) => event instanceof NavigationEnd),
+ map(() => {
+ let route: ActivatedRoute = this.router.routerState.root;
+ let routeTitle = '';
+ while (route!.firstChild) {
+ route = route.firstChild;
+ }
+ if (route.snapshot.data['title']) {
+ routeTitle = route!.snapshot.data['title'];
+ }
+ return routeTitle;
+ })
+ )
+ .subscribe((title: string) => {
+ if (title) {
+ this.titleService.setTitle(`${title} - Igrannonica`);
+ }
+ });
+ }
}