diff options
Diffstat (limited to 'frontend/src/app/experiment')
-rw-r--r-- | frontend/src/app/experiment/experiment.component.html | 23 | ||||
-rw-r--r-- | frontend/src/app/experiment/experiment.component.ts | 111 |
2 files changed, 94 insertions, 40 deletions
diff --git a/frontend/src/app/experiment/experiment.component.html b/frontend/src/app/experiment/experiment.component.html index 25d1b3e3..7746b13e 100644 --- a/frontend/src/app/experiment/experiment.component.html +++ b/frontend/src/app/experiment/experiment.component.html @@ -21,7 +21,8 @@ <input class="form-check-input" type="checkbox" value="{{item.columnName}}" id="cb_{{item.columnName}}" name="cbsNew" [checked]="this.selectedOutputColumnVal != item.columnName" - [disabled]="this.selectedOutputColumnVal == item.columnName"> + [disabled]="this.selectedOutputColumnVal == item.columnName" + (click)="checkedColumnsChanged(item, 0)"> <label class="form-check-label" for="cb_{{item.columnName}}"> {{item.columnName}} </label> @@ -36,7 +37,8 @@ <input class="form-check-input" type="radio" value="{{item.columnName}}" id="rb_{{item.columnName}}" name="rbsNew" [(ngModel)]="this.experiment.outputColumn" - (change)="this.selectedOutputColumnVal = item.columnName"> + (change)="this.selectedOutputColumnVal = item.columnName" + (click)="checkedColumnsChanged(item, 1);"> <label class="form-check-label" for="rb_{{item.columnName}}"> {{item.columnName}} </label> @@ -66,9 +68,18 @@ <div class="collapse" id="fillMissingCustom"> <div> <label for="columnReplacers" class="form-label">Unesite zamenu za svaku kolonu:</label> + <div class="my-3" *ngIf="getSelectedNullColumnsArray().length > 0" > + <label class="text-center form-control mx-3 text-secondary"> + Kolone <span style="font-style: italic;" *ngFor="let colname of getSelectedNullColumnsArray(); let i = index"> + <span *ngIf="i != getSelectedNullColumnsArray().length - 1">{{colname}}, </span> + <span *ngIf="i == getSelectedNullColumnsArray().length - 1">{{colname}} </span> + </span> + nemaju nedostajućih vrednosti za popunjavanje. + </label> + </div> <div id="columnReplacers"> - <div *ngFor="let column of selectedDataset.columnInfo; let i = index" class="my-3"> - <div *ngIf="getInputById('cb_'+column.columnName).checked || selectedOutputColumnVal == column.columnName" class=""> + <div *ngFor="let column of selectedColumnsInfoArray; let i = index" class="my-3"> + <div *ngIf="column.numNulls > 0"> <span class="w-20 mx-3"> {{column.columnName}} <span class="small" style="color:gray;">({{column.numNulls}} null) </span> @@ -97,7 +108,7 @@ <div class="input-group-append"> <select [id]="'replaceOptions'+i" class="form-control btn-primary" - *ngIf="column.isNumber" (change)="replace($event, column);"> + *ngIf="column.isNumber" (change)="replace($event, column); checkFillColRadio(column.columnName);"> <option *ngFor="let option of Object.keys(ReplaceWith); let optionName of Object.values(ReplaceWith)" [value]="option"> @@ -107,7 +118,7 @@ <select [id]="'replaceOptions'+i" class="form-control btn-outline-primary" *ngIf="!column.isNumber && column.numNulls > 0" - (change)="replace($event, column);"> + (change)="replace($event, column); checkFillColRadio(column.columnName);"> <option *ngFor="let option of column.uniqueValues" [value]="option"> {{ option }} </option> diff --git a/frontend/src/app/experiment/experiment.component.ts b/frontend/src/app/experiment/experiment.component.ts index 047963b5..7ccca528 100644 --- a/frontend/src/app/experiment/experiment.component.ts +++ b/frontend/src/app/experiment/experiment.component.ts @@ -22,7 +22,9 @@ export class ExperimentComponent implements OnInit { ReplaceWith = ReplaceWith; Object = Object; + selectedColumnsInfoArray: ColumnInfo[] = []; selectedOutputColumnVal: string = ''; + selectedNullColumnsArray: string[] = []; constructor(private modelsService: ModelsService, private experimentsService: ExperimentsService) { } @@ -32,6 +34,9 @@ export class ExperimentComponent implements OnInit { updateDataset(dataset: Dataset) { //console.log(dataset); this.selectedDataset = dataset; + this.selectedColumnsInfoArray = this.selectedDataset.columnInfo; + this.selectedNullColumnsArray = []; + console.log("array:", this.selectedColumnsInfoArray); } updateModel(model: Model) { @@ -63,6 +68,21 @@ export class ExperimentComponent implements OnInit { (<HTMLInputElement>document.getElementById("fillCol_" + colName)).checked = true; } + checkedColumnsChanged(checkedColumnInfo: ColumnInfo, buttonType: number) { //0-input,1-output + let col = this.selectedColumnsInfoArray.find(x => x.columnName == checkedColumnInfo.columnName); + if (buttonType == 0) { //inputCol + if (col == undefined) + this.selectedColumnsInfoArray.push(checkedColumnInfo); + else + this.selectedColumnsInfoArray = this.selectedColumnsInfoArray.filter(x => x.columnName != checkedColumnInfo.columnName); + } + else { //outputCol + if (col == undefined) //ako je vec cekiran neki output, samo dodaj sad ovaj, a taj output postaje input i ostaje u nizu + this.selectedColumnsInfoArray.push(checkedColumnInfo); + } + //console.log(this.selectedColumnsInfoArray); + } + replace(event: Event, column: ColumnInfo) { let option = (<HTMLInputElement>event.target).value; @@ -89,45 +109,52 @@ export class ExperimentComponent implements OnInit { } } - getNullValuesReplacersArray()/*: NullValReplacer[]*/ { + getSelectedNullColumnsArray(): string[] { + let colNames: string[] = []; + + for (let i = 0; i < this.selectedColumnsInfoArray.length; i++) { + let oneColInfo = this.selectedColumnsInfoArray[i]; + if (oneColInfo.numNulls == 0) + colNames.push(oneColInfo.columnName); + } + return colNames; + } + + getNullValuesReplacersArray(): NullValReplacer[] { let array: NullValReplacer[] = []; - // TODO ispravi - /*if (this.datasetFile) { - - if (this.newModel.nullValues == NullValueOptions.Replace) { - - for (let i = 0; i < this.datasetFile[0].length; i++) { - let column = this.datasetFile[0][i]; - - if (this.calculateSumOfNullValuesInCol(column) > 0) { //ako kolona nema null vrednosti, ne dodajemo je u niz - if ((<HTMLInputElement>document.getElementById("delCol_" + column)).checked) { - array.push({ - column: column, - option: NullValueOptions.DeleteColumns, - value: "" - }); - } - else if ((<HTMLInputElement>document.getElementById("delRows_" + column)).checked) { - array.push({ - column: column, - option: NullValueOptions.DeleteRows, - value: "" - }); - } - else if (((<HTMLInputElement>document.getElementById("fillCol_" + column)).checked)) { - array.push({ - column: column, - option: NullValueOptions.Replace, - value: (<HTMLInputElement>document.getElementById("fillText_" + column)).value - }); - } + if (this.experiment.nullValues == NullValueOptions.Replace) { + + for (let i = 0; i < this.selectedColumnsInfoArray.length; i++) { + let oneColInfo = this.selectedColumnsInfoArray[i]; + + if (oneColInfo.numNulls > 0) { //ako kolona nema null vrednosti, ne dodajemo je u niz + if ((<HTMLInputElement>document.getElementById("delCol_" + oneColInfo.columnName)).checked) { + array.push({ + column: oneColInfo.columnName, + option: NullValueOptions.DeleteColumns, + value: "" + }); + } + else if ((<HTMLInputElement>document.getElementById("delRows_" + oneColInfo.columnName)).checked) { + array.push({ + column: oneColInfo.columnName, + option: NullValueOptions.DeleteRows, + value: "" + }); + } + else if (((<HTMLInputElement>document.getElementById("fillCol_" + oneColInfo.columnName)).checked)) { + array.push({ + column: oneColInfo.columnName, + option: NullValueOptions.Replace, + value: (<HTMLInputElement>document.getElementById("fillText_" + oneColInfo.columnName)).value + }); } } } } //console.log(array); - return array;*/ + return array; } saveExperiment() { @@ -135,19 +162,35 @@ export class ExperimentComponent implements OnInit { Shared.openDialog("Greška", "Izvor podataka nije izabran!"); return; } - //ispitivanje da li ima ulazne kolone TODO - if (this.experiment.outputColumn == '') { Shared.openDialog("Greška", "Molimo Vas da izaberete izlaznu kolonu."); return; } + if (this.selectedColumnsInfoArray.length <= 1) { //jer izlazna je izabrana + Shared.openDialog("Greška", "Molimo Vas da izaberete ulazne kolone."); + return; + } this.experiment._id = ''; this.experiment.uploaderId = ''; this.experiment.datasetId = this.selectedDataset._id; + + let pom = this.selectedColumnsInfoArray.filter(x => x.columnName != this.experiment.outputColumn); + for (let i = 0; i < pom.length; i++) + this.experiment.inputColumns.push(pom[i].columnName); + + this.selectedColumnsInfoArray = this.selectedColumnsInfoArray.filter(x => x.numNulls > 0); + //TREBAJU MI NULLVALUESREPLACERI + this.experiment.nullValuesReplacers = this.getNullValuesReplacersArray(); + + console.log("Eksperiment:", this.experiment); this.experimentsService.addExperiment(this.experiment).subscribe((response) => { this.experiment = response; + + this.selectedColumnsInfoArray = []; + this.selectedNullColumnsArray = []; + Shared.openDialog("Obaveštenje", "Eksperiment je uspešno kreiran."); }, (error) => { |