aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_elements/form-dataset/form-dataset.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/app/_elements/form-dataset/form-dataset.component.ts')
-rw-r--r--frontend/src/app/_elements/form-dataset/form-dataset.component.ts20
1 files changed, 10 insertions, 10 deletions
diff --git a/frontend/src/app/_elements/form-dataset/form-dataset.component.ts b/frontend/src/app/_elements/form-dataset/form-dataset.component.ts
index 5e088e46..62afaa47 100644
--- a/frontend/src/app/_elements/form-dataset/form-dataset.component.ts
+++ b/frontend/src/app/_elements/form-dataset/form-dataset.component.ts
@@ -5,7 +5,7 @@ import { ModelsService } from 'src/app/_services/models.service';
import shared from 'src/app/Shared';
import { DatatableComponent, TableData } from '../datatable/datatable.component';
import { CsvParseService } from 'src/app/_services/csv-parse.service';
-import {FormControl, Validators} from '@angular/forms';
+import { FormControl, Validators } from '@angular/forms';
@Component({
selector: 'app-form-dataset',
@@ -18,7 +18,7 @@ export class FormDatasetComponent {
nameFormControl = new FormControl('', [Validators.required, Validators.email]);
- delimiterOptions: Array<string> = [",", ";", "|", "razmak", "novi red"]; //podrazumevano ","
+ delimiterOptions: Array<string> = [",", ";", "|", "razmak", "novi red"]; //podrazumevano ","
csvRecords: any[] = [];
files: File[] = [];
@@ -29,7 +29,7 @@ export class FormDatasetComponent {
tableData: TableData = new TableData();
- @ViewChild('fileInput') fileInput! : ElementRef
+ @ViewChild('fileInput') fileInput!: ElementRef
filename: String;
@@ -65,7 +65,7 @@ export class FormDatasetComponent {
if (typeof fileReader.result === 'string') {
const result = this.csv.csvToArray(fileReader.result, (this.dataset.delimiter == "razmak") ? " " : (this.dataset.delimiter == "novi red") ? "\t" : this.dataset.delimiter)
-
+
this.csvRecords = result.splice(0, 11);
this.colsNumber = result[0].length;
@@ -91,28 +91,28 @@ export class FormDatasetComponent {
this.dataset.accessibleByLink = true;
}
- uploadDataset() {
+ uploadDataset(onSuccess: Function = (dataset: Dataset) => { }, onError: Function = () => { }) {
if (this.files[0] == undefined) {
shared.openDialog("Greška", "Niste izabrali fajl za učitavanje.");
return;
}
- this.modelsService.uploadData(this.files[0]).subscribe((file) => {
+ return this.modelsService.uploadData(this.files[0]).subscribe((file) => {
//console.log('ADD MODEL: STEP 2 - ADD DATASET WITH FILE ID ' + file._id);
this.dataset._id = "";
this.dataset.fileId = file._id;
this.dataset.uploaderId = shared.userId;
this.datasetsService.addDataset(this.dataset).subscribe((dataset) => {
- shared.openDialog("Obaveštenje", "Uspešno ste dodali novi izvor podataka u kolekciju. Molimo sačekajte par trenutaka da se procesira.");
+ onSuccess();
}, (error) => {
- shared.openDialog("Neuspeo pokušaj!", "Izvor podataka sa unetim nazivom već postoji u Vašoj kolekciji. Izmenite naziv ili iskoristite postojeći dataset.");
+ onError();
}); //kraj addDataset subscribe
}, (error) => {
-
+ onError();
}); //kraj uploadData subscribe
}
-
+
}