diff options
| author | Danijel Anđelković <adanijel99@gmail.com> | 2022-05-20 00:28:05 +0200 | 
|---|---|---|
| committer | Danijel Anđelković <adanijel99@gmail.com> | 2022-05-20 00:28:05 +0200 | 
| commit | 423faeef851d141d02cbebb59be1d9f9e2c2a9d1 (patch) | |
| tree | 7efac7bd0b2d42fa82aa1218dea4b8c4f3f33f5c /frontend/src | |
| parent | 4229eae95fb6daab9ccb6ab0ae05e29689588eb2 (diff) | |
| parent | 638f410ad569c632c8dab6cdf66d6b5fd90d5b0c (diff) | |
Merge branch 'redesign' of http://gitlab.pmf.kg.ac.rs/igrannonica/neuronstellar into redesign
Diffstat (limited to 'frontend/src')
16 files changed, 163 insertions, 265 deletions
diff --git a/frontend/src/app/_elements/_charts/box-plot/box-plot.component.ts b/frontend/src/app/_elements/_charts/box-plot/box-plot.component.ts index 07976da3..b3d25280 100644 --- a/frontend/src/app/_elements/_charts/box-plot/box-plot.component.ts +++ b/frontend/src/app/_elements/_charts/box-plot/box-plot.component.ts @@ -16,25 +16,16 @@ Chart.register(BoxPlotController, BoxAndWiskers, LinearScale, CategoryScale);  })  export class BoxPlotComponent implements AfterViewInit { -  @Input() width?: number; -  @Input() height?: number; -  @Input() mean?: number; -  @Input() median?: number; -  @Input() min?: number; -  @Input() max?: number; -  @Input() q1?: number; -  @Input() q3?: number; +  @Input() width!: number; +  @Input() height!: number; +  @Input() mean!: number; +  @Input() median!: number; +  @Input() min!: number; +  @Input() max!: number; +  @Input() q1!: number; +  @Input() q3!: number; -  updateChart(min: number, max: number, q1: number, q3: number, median: number) { -    if (this.myChart) { -      this.boxplotData.datasets[0].data = [[min, q1, median, q3, max]] -      this.myChart?.update(); -    } -    /*this.boxplotData.datasets = [{ -      data: [[min, q1, median, q3, max]], -    }]*/ - -  }; +      /*    updatePieChart(uniqueValues: string[], uniqueValuesPercent: number[]){ @@ -55,27 +46,29 @@ export class BoxPlotComponent implements AfterViewInit {      //this.updateChart();    } -  boxplotData = { -    // define label tree -    //labels: ['January'/*, 'February', 'March', 'April', 'May', 'June', 'July'*/], -    datasets: [{ -      label: 'Dataset 1', -      backgroundColor: '#0063AB', -      borderColor: '#dfd7d7', -      borderWidth: 1, -      outlierColor: '#999999', -      scaleFontColor: '#0063AB', -      padding: 10, -      itemRadius: 0, -      data: [ -        randomValues(100, 0, 100), -      ] -    }] -  }; +      ngAfterViewInit(): void { -    this.myChart = new Chart(this.chartRef.nativeElement, { +    const boxplotData = { +      // define label tree +      //labels: ['January'/*, 'February', 'March', 'April', 'May', 'June', 'July'*/], +      labels:[""], +      datasets: [{ +        label: 'Dataset 1', +        backgroundColor: '#0063AB', +        borderColor: '#dfd7d7', +        borderWidth: 1, +        outlierColor: '#999999', +        scaleFontColor: '#0063AB', +        padding: 10, +        itemRadius: 0, +        data: [ +          {min:this.min,q1:this.q1,q3:this.q3,median:this.median,max:this.max,mean:this.mean} +        ] +      }] +    }; +    const myChart = new Chart(this.chartRef.nativeElement, {        type: "boxplot", -      data: this.boxplotData, +      data: boxplotData,        options: {          plugins: {            legend: { @@ -92,8 +85,6 @@ export class BoxPlotComponent implements AfterViewInit {              }            },            y: { -            min: this.min, -            max: this.max,              ticks: {                color: '#dfd7d7'              }, @@ -106,5 +97,4 @@ export class BoxPlotComponent implements AfterViewInit {      });    } -  myChart?: Chart;  } diff --git a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.ts b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.ts index 89a76a44..7d21129c 100644 --- a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.ts +++ b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.ts @@ -41,32 +41,33 @@ export class LineChartComponent implements AfterViewInit {      }    }    update(myEpochs: number[], myAcc: number[], myLoss: number[], myMae: number[], myMse: number[], myValAcc:number[],myValLoss:number[],myValMae:number[],myValMse:number[]) { -    this.dataAcc.length = 0; -    this.dataAcc.push(...myAcc); - +         this.dataEpoch.length = 0;      this.dataEpoch.push(...myEpochs); -    this.dataMAE.length = 0; -    this.dataMAE.push(...myMae); +    this.dataAcc.length = 0; +    this.dataAcc.push(...myAcc);      this.dataLOSS.length = 0;      this.dataLOSS.push(...myLoss); -    this.dataMSE.length = 0; -    this.dataMSE.push(...myValAcc); +    this.dataMAE.length = 0; +    this.dataMAE.push(...myMae);      this.dataMSE.length = 0; -    this.dataMSE.push(...myValLoss); +    this.dataMSE.push(...myMse); -    this.dataMSE.length = 0; -    this.dataMSE.push(...myValMae); +    this.dataValAcc.length = 0; +    this.dataValAcc.push(...myValAcc); -    this.dataMSE.length = 0; -    this.dataMSE.push(...myValMse); +    this.dataValLoss.length = 0; +    this.dataValLoss.push(...myValLoss); -    this.dataMSE.length = 0; -    this.dataMSE.push(...myMse); +    this.dataValMAE.length = 0; +    this.dataValMAE.push(...myValMae); + +    this.dataValMSE.length = 0; +    this.dataValMSE.push(...myValMse);      this.myChart.update();    } @@ -89,7 +90,7 @@ export class LineChartComponent implements AfterViewInit {            },            {              label: 'Val_Accuracy', -            data: this.dataMSE, +            data: this.dataValAcc,              borderWidth: 1            },            { @@ -99,7 +100,7 @@ export class LineChartComponent implements AfterViewInit {            },            {              label: 'Val_Loss', -            data: this.dataMSE, +            data: this.dataValLoss,              borderWidth: 1            },            { @@ -109,7 +110,7 @@ export class LineChartComponent implements AfterViewInit {            },            {              label: 'Val_MAE', -            data: this.dataMSE, +            data: this.dataValMAE,              borderWidth: 1            },            { @@ -119,7 +120,7 @@ export class LineChartComponent implements AfterViewInit {            },            {              label: 'Val_MSE', -            data: this.dataMSE, +            data: this.dataValMSE,              borderWidth: 1            }            ] diff --git a/frontend/src/app/_elements/column-table/column-table.component.ts b/frontend/src/app/_elements/column-table/column-table.component.ts index 694b1a83..9a8cbeee 100644 --- a/frontend/src/app/_elements/column-table/column-table.component.ts +++ b/frontend/src/app/_elements/column-table/column-table.component.ts @@ -78,39 +78,14 @@ export class ColumnTableComponent implements AfterViewInit {    } -  updateCharts() { -    //min: number, max: number, q1: number, q3: number, median: number -    let i = 0; -    this.boxplotComp.changes.subscribe(() => { -      const bps = this.boxplotComp.toArray(); -      this.dataset?.columnInfo.forEach((colInfo, index) => { -        if (this.experiment.columnTypes[index] == ColumnType.numerical) { -          bps[i].updateChart(colInfo!.min, colInfo.max, colInfo.q1, colInfo.q3, colInfo.median); -          i++; -        } -      }); -    }); -  } +   + -  updatePieChart() { -    //min: number, max: number, q1: number, q3: number, median: number -    let i = 0; -    const pieChart = this.piechartComp.toArray(); -    console.log(pieChart) -    this.dataset?.columnInfo.forEach((colInfo, index) => { -      console.log(i) -      if (this.experiment.columnTypes[index] == ColumnType.categorical) { -        console.log("prosao IF") -        pieChart[i].updatePieChart(colInfo!.uniqueValues, colInfo.uniqueValuesPercent); -        i++; -      } -    }); -  }    loadDataset(dataset: Dataset) {      console.log("LOADED DATASET"); -    if (this.route.snapshot.paramMap.get("id") == null) { +    if (this.route.snapshot.paramMap.get("id") == null && this.route.snapshot.paramMap.get("predictorId") == null) {        this.dataset = dataset;        this.setColumnTypeInitial(); diff --git a/frontend/src/app/_elements/folder/folder.component.ts b/frontend/src/app/_elements/folder/folder.component.ts index 13ec8937..ed38bbd6 100644 --- a/frontend/src/app/_elements/folder/folder.component.ts +++ b/frontend/src/app/_elements/folder/folder.component.ts @@ -122,7 +122,7 @@ export class FolderComponent implements AfterViewInit {    }    goToExperimentPageWithPredictor(file: FolderFile, predictor: Predictor) { -    this.router.navigate(['/experiment/' + file._id + "/" + predictor._id]); +    this.router.navigate(['/experiment/p/' + predictor._id]);    }    createNewFile() { diff --git a/frontend/src/app/_elements/form-dataset/form-dataset.component.html b/frontend/src/app/_elements/form-dataset/form-dataset.component.html index 78bb4bd1..024f58e8 100644 --- a/frontend/src/app/_elements/form-dataset/form-dataset.component.html +++ b/frontend/src/app/_elements/form-dataset/form-dataset.component.html @@ -10,7 +10,7 @@              <div role="group">                  <mat-form-field class="example-full-width" appearance="fill">                      <mat-label>Naziv</mat-label> -                    <input type="text" matInput value="{{dataset?.name}}" [(ngModel)]="dataset.name" (change)="editEvent.emit()"> +                    <input type="text" matInput value="{{dataset?.name}}" [(ngModel)]="dataset.name" (input)="editEvent.emit()">                      <mat-error *ngIf="nameFormControl.hasError('required')"> diff --git a/frontend/src/app/_elements/metric-view/metric-view.component.ts b/frontend/src/app/_elements/metric-view/metric-view.component.ts index fbca2edf..65b1ef9b 100644 --- a/frontend/src/app/_elements/metric-view/metric-view.component.ts +++ b/frontend/src/app/_elements/metric-view/metric-view.component.ts @@ -16,7 +16,7 @@ export class MetricViewComponent implements OnInit {    history: any[] = []; -  update(history: any[]) { +  update(history: any[],totalEpochs:number) {      const myAcc: number[] = [];      const myMae: number[] = [];      const myMse: number[] = []; @@ -29,7 +29,15 @@ export class MetricViewComponent implements OnInit {      const myEpochs: number[] = [];      this.history = history;      this.history.forEach((metrics, epoch) => { -      myEpochs.push(epoch + 1); +      if(totalEpochs>100) +      { +        let epochEstimate=epoch*Math.round(Math.sqrt(totalEpochs)) +        if(epochEstimate>totalEpochs) +          epochEstimate=totalEpochs; +        myEpochs.push(epochEstimate); +      } +      else +        myEpochs.push(epoch + 1);        for (let key in metrics) {          let value = metrics[key];          //console.log(key, ':::', value, epoch); diff --git a/frontend/src/app/_modals/yes-no-dialog/yes-no-dialog.component.css b/frontend/src/app/_modals/yes-no-dialog/yes-no-dialog.component.css index e69de29b..e99a1e1e 100644 --- a/frontend/src/app/_modals/yes-no-dialog/yes-no-dialog.component.css +++ b/frontend/src/app/_modals/yes-no-dialog/yes-no-dialog.component.css @@ -0,0 +1,8 @@ +#btnYes { +    background-color: var(--offwhite); +    color: var(--ns-bg-dark-100); +} + +#btnNo { +    color: gray; +}
\ No newline at end of file diff --git a/frontend/src/app/_modals/yes-no-dialog/yes-no-dialog.component.html b/frontend/src/app/_modals/yes-no-dialog/yes-no-dialog.component.html index 77e7be42..0470d395 100644 --- a/frontend/src/app/_modals/yes-no-dialog/yes-no-dialog.component.html +++ b/frontend/src/app/_modals/yes-no-dialog/yes-no-dialog.component.html @@ -1,10 +1,10 @@ -<h2 mat-dialog-title class="text-muted">{{data.title}}</h2> -<div mat-dialog-content class="mt-4" style="color: rgb(81, 76, 76);"> +<h2 mat-dialog-title class="text-center">{{data.title}}</h2> +<div mat-dialog-content class="mt-5 mb-4 mx-1">      <form (keydown)="withEnterKey($event)">          {{data.message}}      </form>  </div>  <div mat-dialog-actions class="d-flex justify-content-center mt-4"> -    <button mat-button cdkFocusInitial (click)="onYesClick()" style="background-color: lightgray;">Da</button> -    <button mat-button cdkFocusInitial (click)="onNoClick()" style="background-color: lightgray;">Ne</button> +    <button id="btnYes" mat-stroked-button color="basic" (click)="onYesClick()">Da</button> +    <button id="btnNo" mat-stroked-button (click)="onNoClick()">Ne</button>  </div>
\ No newline at end of file diff --git a/frontend/src/app/_pages/experiment/experiment.component.ts b/frontend/src/app/_pages/experiment/experiment.component.ts index ee269f65..398321f2 100644 --- a/frontend/src/app/_pages/experiment/experiment.component.ts +++ b/frontend/src/app/_pages/experiment/experiment.component.ts @@ -21,7 +21,7 @@ import { PredictorsService } from 'src/app/_services/predictors.service';    templateUrl: './experiment.component.html',    styleUrls: ['./experiment.component.css']  }) -export class ExperimentComponent implements AfterViewInit, OnInit { +export class ExperimentComponent implements AfterViewInit {    @ViewChild(MatStepper) stepper!: MatStepper;    @ViewChild('stepsContainer') stepsContainer!: ElementRef; @@ -44,46 +44,6 @@ export class ExperimentComponent implements AfterViewInit, OnInit {      this.experiment = new Experiment("exp1");    } -  ngOnInit(): void { -    this.route.queryParams.subscribe(params => { - -      let experimentId = this.route.snapshot.paramMap.get("id"); -      let predictorId = this.route.snapshot.paramMap.get("predictorId"); - -      if (predictorId != null && experimentId != null) { -        this.experimentsService.getExperimentById(experimentId).subscribe((response) => { -          this.experiment = response; -          this.datasetsService.getDatasetById(this.experiment.datasetId).subscribe((response: Dataset) => { -            this.dataset = response; -            this.folderDataset.forExperiment = this.experiment; -            this.folderDataset.selectFile(this.dataset); //sad 3. i 4. korak da se ucitaju -   -            //this.predictorsService.getPredictor(predictorId!).subscribe((response) => { -            let predictor = response; -            //this.modelsService.getModelById(predictor.modelId).subscribe((response) => { -            this.modelsService.getModelById("62853d70696d62ceeb8db7cd").subscribe((response) => { -              //imamo model -              this.folderModel.formModel.newModel = response; -              //this.metricView.update(predictor.metrics); -            }); -            //}); -          }); -        }); -      } -      else if (predictorId == null && experimentId != null) { -        this.experimentsService.getExperimentById(experimentId).subscribe((response) => { -          this.experiment = response; -          this.datasetsService.getDatasetById(this.experiment.datasetId).subscribe((response: Dataset) => { -            this.dataset = response; -            this.folderDataset.forExperiment = this.experiment; -            this.folderDataset.selectFile(this.dataset); -          }); -        }); -      } - -    }); -  } -    /*updateExperiment(){    }*/ @@ -131,11 +91,57 @@ export class ExperimentComponent implements AfterViewInit, OnInit {            stat = stat.replace(/'/g, '"');            //console.log('JSON', this.trainingResult);            this.history.push(JSON.parse(stat)); -          this.metricView.update(this.history); +          this.metricView.update(this.history,this.modelToTrain.epochs);          }        });      } + +    this.route.queryParams.subscribe(params => { + +      let experimentId = this.route.snapshot.paramMap.get("id"); +      let predictorId = this.route.snapshot.paramMap.get("predictorId"); +      console.log("paramexp: ", experimentId, ", parampredictor: ", predictorId); +      if (predictorId != null) { +        this.predictorsService.getPredictor(predictorId!).subscribe((response) => { +          let predictor = response; +          //console.log("predictor: ", predictor); +          this.experimentsService.getExperimentById(predictor.experimentId).subscribe((response) => { +            this.experiment = response; +            //console.log("experiment: ", this.experiment); +            this.datasetsService.getDatasetById(this.experiment.datasetId).subscribe((response: Dataset) => { +              this.dataset = response; +              //console.log("dataset: ", this.dataset); +              this.folderDataset.forExperiment = this.experiment; +              this.folderDataset.selectFile(this.dataset); //sad 3. i 4. korak da se ucitaju + +              this.modelsService.getModelById(predictor.modelId).subscribe((response) => { +                let model = response; +                //console.log("model: ", model); +                this.folderModel.formModel.newModel = model; +                this.step3 = true; +                let numOfEpochsArray = Array.from({length: model.epochs}, (_, i) => i + 1); +                //console.log("metric view1:", this.metricView); +                setTimeout(() => { +                  this.metricView.linechartComponent.update(numOfEpochsArray, predictor.metricsAcc, predictor.metricsLoss, predictor.metricsMae, predictor.metricsMse, predictor.metricsValAcc, predictor.metricsValLoss, predictor.metricsValMae, predictor.metricsValMse); +                }) +              }); +            }); +          }); +        }); +      } +      else if (experimentId != null) { +        this.experimentsService.getExperimentById(experimentId).subscribe((response) => { +          this.experiment = response; +          this.datasetsService.getDatasetById(this.experiment.datasetId).subscribe((response: Dataset) => { +            this.dataset = response; +            this.folderDataset.forExperiment = this.experiment; +            this.folderDataset.selectFile(this.dataset); +          }); +        }); +      } + +    });    }    history: any[] = []; @@ -208,7 +214,6 @@ export class ExperimentComponent implements AfterViewInit, OnInit {        this.columnTable.loaded = false;        this.dataset = undefined;        this.experiment.datasetId = ''; -      this.step1 = false;        return;      }      const d = <Dataset>dataset; diff --git a/frontend/src/app/_pages/my-models/my-models.component.html b/frontend/src/app/_pages/my-models/my-models.component.html deleted file mode 100644 index 9b281239..00000000 --- a/frontend/src/app/_pages/my-models/my-models.component.html +++ /dev/null @@ -1,43 +0,0 @@ -<div id="header"> -    <h1>Moji modeli</h1> -</div> -<div id="wrapper"> -    <div id="container" class="container p-5" style="background-color: rgba(255, 255, 255, 0.8); 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 class="panel-footer row"><!-- panel-footer --> -                    <div class="col-xs-6 text-center"> -                        <div> -                            <button type="button" class="btn btn-default btn-lg"style="min-width: 7rem;float: left;" (click)="useThisModel(model)" mat-raised-button color="primary">Koristi -                                <span class="glyphicon glyphicon-search"></span> -                            </button> -                            <button (click)="deleteThisModel(model)" mat-raised-button color="warn" style="min-width: 7rem;float: right" ><mat-icon>delete</mat-icon></button> -                             -                         -                        </div> -                    </div> -                </div><!-- end panel-footer --> - -                 -                 -                </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 deleted file mode 100644 index d379fa69..00000000 --- a/frontend/src/app/_pages/my-models/my-models.component.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; -import shared from 'src/app/Shared'; -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[] = []; -  //myModel: Model; - -  constructor(private modelsS : ModelsService, private router : Router) { - -     - -     } - -  ngOnInit(): void { -    this.getAllMyModels(); - -  } -/* -  editModel(): void{ -    this.modelsS.editModel().subscribe(m => { -      this.myModel = m; - -    }) -  } -*/ - -deleteThisModel(model: Model): void{ -  shared.openYesNoDialog('Brisanje seta podataka','Da li ste sigurni da želite da obrišete model?',() => { -  this.modelsS.deleteModel(model).subscribe((response) => { -    this.getAllMyModels(); -  }, (error) =>{ -      if (error.error == "Model with name = {name} deleted") { -        shared.openDialog("Obaveštenje", "Greška prilikom brisanja modela."); -      } -    }); -  }); -} - - -useThisModel(model: Model): void{ - -  this.router.navigate(['/training']) -   -} -  getAllMyModels(): void{ -    this.modelsS.getMyModels().subscribe(m => { -      this.myModels = m; -    }); -  } - -} diff --git a/frontend/src/app/_pages/profile/profile.component.css b/frontend/src/app/_pages/profile/profile.component.css index bbd4c9ba..48b1304b 100644 --- a/frontend/src/app/_pages/profile/profile.component.css +++ b/frontend/src/app/_pages/profile/profile.component.css @@ -22,4 +22,9 @@ mat-form-field {  .selectedPicture {      background-color: var(--ns-accent); +} + +.mat-raised-button { +    width: 180px !important; +    height: 50px !important;  }
\ No newline at end of file diff --git a/frontend/src/app/_pages/profile/profile.component.html b/frontend/src/app/_pages/profile/profile.component.html index 8d655513..39f33255 100644 --- a/frontend/src/app/_pages/profile/profile.component.html +++ b/frontend/src/app/_pages/profile/profile.component.html @@ -27,11 +27,11 @@                              <div class="row gx-3 mb-3">                                  <!-- Form Group (password)-->                                  <div class="col-md-6"> -                                    <small *ngIf="wrongPassBool" class="form-text danger-Text">Neispravna lozinka.</small>                                      <mat-form-field appearance="fill">                                          <mat-label>Važeća lozinka</mat-label>                                          <input matInput id="inputPassword" name="inputPassword" type="password" placeholder="" [(ngModel)]="this.oldPass">                                      </mat-form-field> +                                    <small *ngIf="wrongPassBool" class="form-text danger-Text">Neispravna lozinka.</small>                                      <small *ngIf="wrongOldPassBool" class="form-text danger-Text">Pogrešan format.</small>                                  </div>                                  <!-- Form Group (new password)--> @@ -50,7 +50,7 @@                                  <div class="col-md-6">                                      <div class="col text-center">                                          <!-- Save changes button--> -                                        <button mat-raised-button color="primary" (click)="savePasswordChanges()">Promeni lozinku</button> +                                        <button mat-raised-button color="basic" (click)="savePasswordChanges()">Promeni lozinku</button>                                      </div>                                  </div>                                  <!-- Form Group (new password again)--> @@ -122,7 +122,7 @@                              <div class="container">                                  <div class="card-group">                                      <!--bootstrap card with 3 horizontal images--> -                                    <div class="row overflow-auto" style="max-height: 200px;"> +                                    <div class="row overflow-auto" style="max-height: 255px;">                                          <div class="card col-md-3" *ngFor="let picture of this.pictures" (click)="this.photoId = picture.photoId.toString()" [ngClass]="{'selectedPicture': this.photoId == picture.photoId.toString()}">                                              <img src="{{picture.path}}">                                          </div> @@ -134,7 +134,7 @@                          <div class="row mt-5">                              <div class="col text-center">                                  <!-- Save changes button--> -                                <button mat-raised-button color="primary" (click)="saveInfoChanges()">Sačuvaj izmene</button> +                                <button mat-raised-button color="basic" (click)="saveInfoChanges()">Sačuvaj izmene</button>                              </div>                          </div>                      </form> diff --git a/frontend/src/app/_pages/profile/profile.component.ts b/frontend/src/app/_pages/profile/profile.component.ts index fdcd347c..aed8e40c 100644 --- a/frontend/src/app/_pages/profile/profile.component.ts +++ b/frontend/src/app/_pages/profile/profile.component.ts @@ -7,7 +7,8 @@ import { PICTURES } from 'src/app/_data/ProfilePictures';  import { Picture } from 'src/app/_data/ProfilePictures';  import shared from '../../Shared';  import { share } from 'rxjs'; - +import { MatDialog } from '@angular/material/dialog'; +import { AlertDialogComponent } from 'src/app/_modals/alert-dialog/alert-dialog.component';  @Component({    selector: 'app-profile', @@ -43,13 +44,13 @@ export class ProfileComponent implements OnInit {    wrongNewPass2Bool: boolean = false;    pattName: RegExp = /^[a-zA-ZšŠđĐčČćĆžŽ]+([ \-][a-zA-ZšŠđĐčČćĆžŽ]+)*$/; -  pattUsername: RegExp = /^[a-zA-Z0-9]{6,18}$/; +  pattUsername: RegExp = /^[a-zA-Z0-9]{4,18}$/;    pattTwoSpaces: RegExp = /  /;    pattEmail: RegExp = /^[a-zA-Z0-9]+([\.\-\+][a-zA-Z0-9]+)*\@([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}$/;    pattPassword: RegExp = /.{6,30}$/; -  constructor(private userInfoService: UserInfoService, private authService: AuthService, private router: Router) { } +  constructor(private userInfoService: UserInfoService, private authService: AuthService, private router: Router, public dialog?: MatDialog) { }    ngOnInit(): void {      this.userInfoService.getUserInfo().subscribe((response) => { @@ -95,19 +96,24 @@ export class ProfileComponent implements OnInit {        if (this.user.username != editedUser.username) { //promenio username, ide logout          this.user = editedUser;          this.resetInfo(); -        shared.openDialog("Obaveštenje", "Nakon promene korisničkog imena, moraćete ponovo da se ulogujete."); -        this.authService.logOut(); -        this.router.navigate(['']); -        return; +        const dialogRef = this.dialog?.open(AlertDialogComponent, { +          width: '350px', +          data: { title: "Obaveštenje", message: "Nakon promene korisničkog imena, moraćete ponovo da se ulogujete." } +        }); +        dialogRef?.afterClosed().subscribe(res => { +          this.authService.logOut(); +          this.router.navigate(['']); +          return; +        }); +      } +      else { +        shared.openDialog("Obaveštenje", "Podaci su uspešno promenjeni."); +        this.user = editedUser; +        this.resetInfo();        } -      shared.openDialog("Obaveštenje", "Podaci su uspešno promenjeni."); -      this.user = editedUser; -      this.resetInfo();      }, (error: any) =>{        if (error.error == "Username already exists!") {          shared.openDialog("Obaveštenje", "Ukucano korisničko ime je već zauzeto! Izaberite neko drugo."); -        //(<HTMLSelectElement>document.getElementById("inputUsername")).focus(); -        //poruka obavestenja ispod inputa          this.resetInfo();        }      }); @@ -122,12 +128,10 @@ export class ProfileComponent implements OnInit {      if (this.newPass1 == '' && this.newPass2 == '') //ne zeli da promeni lozinku        return; -    //console.log("zeli da promeni lozinku");      if (this.newPass1 != this.newPass2) { //netacno ponovio novu lozinku        this.wrongNewPassBool = true;        this.resetNewPassInputs(); -      //console.log("Netacno ponovljena lozinka");        return;      } @@ -135,19 +139,23 @@ export class ProfileComponent implements OnInit {      this.userInfoService.changeUserPassword(passwordArray).subscribe((response: any) => {        //console.log("PROMENIO LOZINKU");        this.resetNewPassInputs(); -      shared.openDialog("Obaveštenje", "Nakon promene lozinke, moraćete ponovo da se ulogujete."); -      this.authService.logOut(); -      this.router.navigate(['']); +      const dialogRef = this.dialog?.open(AlertDialogComponent, { +        width: '350px', +        data: { title: "Obaveštenje", message: "Nakon promene lozinke, moraćete ponovo da se ulogujete." } +      }); +      dialogRef?.afterClosed().subscribe(res => { +        this.authService.logOut(); +        this.router.navigate(['']); +        return; +      });      }, (error: any) => {        if (error.error == 'Wrong old password!') {          this.wrongPassBool = true; -        //(<HTMLSelectElement>document.getElementById("inputPassword")).focus();          return;        }        else if (error.error == 'Identical password!') {          shared.openDialog("Obaveštenje", "Stara i nova lozinka su identične.");           this.resetNewPassInputs(); -        //(<HTMLSelectElement>document.getElementById("inputNewPassword")).focus();          return;        }      }); diff --git a/frontend/src/app/_services/datasets.service.ts b/frontend/src/app/_services/datasets.service.ts index 3fb4e8f2..2775613c 100644 --- a/frontend/src/app/_services/datasets.service.ts +++ b/frontend/src/app/_services/datasets.service.ts @@ -44,8 +44,8 @@ export class DatasetsService {      return this.http.get<Dataset>(`${Configuration.settings.apiURL}/dataset/get/${datasetId}`, { headers: this.authService.authHeader() });    } -  editDataset(dataset: Dataset): Observable<Dataset> { -    return this.http.put<Dataset>(`${Configuration.settings.apiURL}/dataset/` + dataset._id, dataset, { headers: this.authService.authHeader() }); +  editDataset(dataset: Dataset){ +    return this.http.put(`${Configuration.settings.apiURL}/dataset/` + dataset._id, dataset, { headers: this.authService.authHeader() ,responseType:'text'});    }    deleteDataset(dataset: Dataset) { diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index 56442842..d5552ce9 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -12,7 +12,7 @@ import { TestComponent } from './_pages/test/test.component';  const routes: Routes = [    { path: '', component: HomeComponent, data: { title: 'Početna strana' } }, -  { path: 'experiment/:id/:predictorId', component: ExperimentComponent, data: { title: 'Eksperiment' } }, +  { path: 'experiment/p/:predictorId', component: ExperimentComponent, data: { title: 'Eksperiment' } },    { path: 'experiment/:id', component: ExperimentComponent, data: { title: 'Eksperiment' } },    { path: 'experiment', component: ExperimentComponent, data: { title: 'Eksperiment' } },    { path: 'archive', component: ArchiveComponent, data: { title: 'Arhiva' } },  | 
