diff options
Diffstat (limited to 'frontend/src/app/_pages')
45 files changed, 715 insertions, 543 deletions
| diff --git a/frontend/src/app/_pages/add-model/add-model.component.css b/frontend/src/app/_pages/add-model/add-model.component.css index e69de29b..4bf569cc 100644 --- a/frontend/src/app/_pages/add-model/add-model.component.css +++ b/frontend/src/app/_pages/add-model/add-model.component.css @@ -0,0 +1,18 @@ +#header { +    background-color: #003459; +    padding-top: 30px; +    padding-bottom: 20px; +} +#header h1 { +    font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; +    text-align: center; +    color: white; +} + +#container { +    border-radius: 8px; +} + +#wrapper { +    color: #003459; +}
\ No newline at end of file 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 bc292bb9..004f308b 100644 --- a/frontend/src/app/_pages/add-model/add-model.component.html +++ b/frontend/src/app/_pages/add-model/add-model.component.html @@ -1,189 +1,257 @@ -<div class="container p-3" style="background-color: rgb(249, 251, 253); min-height: 100%;"> +<div id="header"> +    <h1>Napravite svoj model veštačke neuronske mreže</h1> +</div> -    <h2 class="my-4 text-primary"> Nov model: </h2> -    <div class="form-group row align-items-center"> -        <label for="name" class="col-sm-2 col-form-label col-form-label-lg">Naziv</label> -        <div class="col-sm-7"> -            <input type="text" class="form-control form-control-lg" name="name" placeholder="Naziv..." -                [(ngModel)]="newModel.name"> +<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--> +            <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"> +            </div> +            <div class="col-5"> +                <label for="desc" class="col-sm-2 col-form-label">Opis:</label> +                <div> +                    <textarea class="form-control" name="desc" rows="3" [(ngModel)]="newModel.description"></textarea> +                </div> +            </div> +            <div class="col-2"> +                <label for="dateCreated" class="col-form-label">Datum:</label>    +                <input type="text" class="form-control-plaintext" id="dateCreated" placeholder="--/--/--" +                    value="{{newModel.dateCreated | date: 'dd/MM/yyyy'}}" readonly> +            </div>          </div> - -        <div class="col-sm-3"> -            <input type="text" class="form-control-plaintext text-center" id="dateCreated" placeholder="--/--/--" -                value="{{newModel.dateCreated | date: 'dd/MM/yyyy'}}" readonly> +     +        <div class="mt-5 justify-content-center"> +            <h2>Izvor podataka:</h2> +            <app-dataset-load id="dataset" (loaded)="datasetLoaded = true"></app-dataset-load>          </div> -    </div> -    <div class="form-group row my-2"> -        <label for="desc" class="col-sm-2 col-form-label">Opis</label> -        <div class="col-sm-10"> -            <textarea class="form-control" name="desc" rows="3" [(ngModel)]="newModel.description"></textarea> +        <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">  +                    <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">  +                    <label class="form-check-label" for="rb_{{item}}"> +                      {{item}} +                    </label> +                  </div> +                </div> +              </div> +            </div>          </div> -    </div> -    <!--<div class="form-group row"> -    <label for="value" class="col-4">Vrednost</label> -    <div class="input-group"> -        <input type="number" min="0" class="form-control" name="value" placeholder="Vrednost..." -            [(ngModel)]="newModel.value"> -        <div class="input-group-prepend"> -            <span class="input-group-text">#</span> -        </div> -        <input type="number" min="1" class="form-control" name="count" placeholder="Br." [(ngModel)]="newModel.count"> -        <input type="text" class="form-control" name="sum" placeholder="Suma" -            value="=({{newModel.value * newModel.count}})" readonly> -        </div> -    </div>--> +         +         +        <h2 class="mt-5 mb-4">Parametri treniranja:</h2> -    <div class="my-4"> -        <label for="dataset">Izvor podataka:</label> -        <app-dataset-load id="dataset"></app-dataset-load> -    </div> - -    <div class="form-group row my-2"> -        <div class="col-sm-2 col-form-label"> -            <label for="type" class="form-check-label">Podela test skupa: -                <input class="mx-3 form-check-input" type="checkbox" [checked]="newModel.randomTestSet" -                    (change)="newModel.randomTestSet = !newModel.randomTestSet"> -            </label> - -        </div>          <div> -            <input type="range" min="0.1" max="0.9" step="0.1" class="form-control" name="randomTestSetDistribution" -                [disabled]="!newModel.randomTestSet" [(ngModel)]="newModel.randomTestSetDistribution"> -        </div> -    </div> - -    <h3> Parametri treniranja </h3> - -    <div class="form-group row my-2"> -        <label for="type" class="col-sm-2 col-form-label">Tip mreže: </label> -        <div class="col-sm-10"> -            <select id=typeOptions class="form-control" name="type" [(ngModel)]="newModel.type"> -                <option *ngFor="let option of Object.keys(ANNType); let optionName of Object.values(ANNType)" -                    [value]="option"> -                    {{ optionName }} -                </option> -            </select> -        </div> -    </div> - -    <div class="form-group row my-2"> -        <label for="encoding" class="col-sm-2 col-form-label">Enkoding: </label> -        <div class="col-sm-10"> -            <select id=encodingOptions class="form-control" name="encoding" [(ngModel)]="newModel.encoding"> -                <option *ngFor="let option of Object.keys(Encoding); let optionName of Object.values(Encoding)" -                    [value]="option"> -                    {{ optionName }} -                </option> -            </select> -        </div> -    </div> +            <div class="row p-2"> +                <div class="col-1"> +                </div> +                <div class="col-3"> +                    <label for="type" class="col-form-label">Tip mreže: </label> +                </div> +                <div class="col-2"> +                    <select id=typeOptions class="form-control" name="type" [(ngModel)]="newModel.type"> +                        <option *ngFor="let option of Object.keys(ANNType); let optionName of Object.values(ANNType)" +                            [value]="option"> +                            {{ optionName }} +                        </option> +                    </select> +                </div> +                <div class="col-1"> +                </div> +                <div class="col-3"> +                    <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"> +                </div> +            </div> -    <div class="form-group row my-2"> -        <label for="optimizer" class="col-sm-2 col-form-label">Optimizacija: </label> -        <div class="col-sm-10"> -            <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)" -                    [value]="option"> -                    {{ optionName }} -                </option> -            </select> -        </div> -    </div> +            <div class="row p-2"> +                <div class="col-1"> +                </div> +                <div class="col-3"> +                    <label for="encoding" class="col-form-label">Enkoding: </label> +                </div> +                <div class="col-2"> +                    <select id=encodingOptions class="form-control" name="encoding" [(ngModel)]="newModel.encoding"> +                        <option *ngFor="let option of Object.keys(Encoding); let optionName of Object.values(Encoding)" +                            [value]="option"> +                            {{ optionName }} +                        </option> +                    </select> +                </div> +                <div class="col-1"> +                </div> +                <div class="col-3"> +                    <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"> +                </div> +            </div> -    <div class="form-group row my-2"> -        <label for="lossFunction" class="col-sm-2 col-form-label">Funkcija obrade gubitka: </label> -        <div class="col-sm-10"> -            <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> -            </select> -        </div> -    </div> +            <div class="row p-2"> +                <div class="col-1"> +                </div> +                <div class="col-3"> +                    <label for="optimizer" class="col-form-label">Optimizacija: </label> +                </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)" +                            [value]="option"> +                            {{ optionName }} +                        </option> +                    </select> +                </div> +                <div class="col-1"> +                </div> +                <div class="col-3"> +                    <label for="batchSize" class="col-form-label">Broj uzorka po iteraciji: </label> +                </div> +                <div class="col-1"> +                    <input type="number" min="1" class="form-control" name="batchSize" [(ngModel)]="newModel.batchSize"> +                </div> +            </div> -    <div class="form-group row my-2"> -        <label for="inputNeurons" class="col-sm-2 col-form-label">Broj ulaznih neurona: </label> -        <div class="col-sm-10"> -            <input type="number" min="1" class="form-control" name="inputNeurons" [(ngModel)]="newModel.inputNeurons"> -        </div> -    </div> +            <div class="row p-2"> +                <div class="col-1"> +                </div> +                <div class="col-3"> +                    <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)" +                            [value]="option"> +                            {{ optionName }} +                        </option> +                    </select> +                </div> +                <div class="col-1"> +                </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> +                </div> +                <div class="col-1"> +                </div> +            </div> -    <div class="form-group row my-2"> -        <label for="inputLayerActivationFunction" class="col-sm-2 col-form-label">Funkcija aktivacije ulaznog sloja: -        </label> -        <div class="col-sm-10"> -            <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> +            <div class="row p-2"> +                <div class="col-1"> +                </div> +                <div class="col-3"> +                    <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> +                </div> +                <div class="col-1"> +                </div> +                <div class="col-5"> +                    <label for="type" class="form-check-label">Podela test skupa:   +                        <input class="form-check-input" type="checkbox" [checked]="newModel.randomTestSet" +                            (change)="newModel.randomTestSet = !newModel.randomTestSet"> +                    </label>      +                    test +                    <mat-slider min="0.1" max="0.9" step="0.1" value="0.2" name="randomTestSetDistribution" thumbLabel +                    [disabled]="!newModel.randomTestSet" [(ngModel)]="newModel.randomTestSetDistribution"> +                    </mat-slider> +                    trening +                </div> +                <div class="col"> +                </div> +            </div> -    <div class="form-group row my-2"> -        <label for="hiddenLayerNeurons" class="col-sm-2 col-form-label">Broj neurona skrivenih slojeva: </label> -        <div class="col-sm-10"> -            <input type="number" min="1" class="form-control" name="hiddenLayerNeurons" -                [(ngModel)]="newModel.hiddenLayerNeurons"> -        </div> -    </div> +            <div class="row p-2"> +                <div class="col-1"> +                </div> +                <div class="col-3"> +                    <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> +                </div> +                <div class="col"> +                </div> +                <div class="col"> +                </div> +            </div> -    <div class="form-group row my-2"> -        <label for="hiddenLayerActivationFunction" class="col-sm-2 col-form-label">Funkcija aktivacije skrivenih -            slojeva: -        </label> -        <div class="col-sm-10"> -            <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 class="row p-2"> +                <div class="col-1"> +                </div> +                <div class="col-3"> +                    <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"> +                        <option +                            *ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)" +                            [value]="option"> +                            {{ optionName }} +                        </option> +                    </select> +                </div> +                <div class="col"> +                </div> +                <div class="col"> +                </div> +            </div>          </div> -    </div> -    <div class="form-group row my-2"> -        <label for="hiddenLayers" class="col-sm-2 col-form-label">Broj skrivenih slojeva: </label> -        <div class="col-sm-10"> -            <input type="number" min="1" class="form-control" name="hiddenLayers" [(ngModel)]="newModel.hiddenLayers"> -        </div> -    </div> -    <div class="form-group row my-2"> -        <label for="outputLayerActivationFunction" class="col-sm-2 col-form-label">Funkcija aktivacije izlaznog -            sloja: -        </label> -        <div class="col-sm-10"> -            <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"> -                    {{ optionName }} -                </option> -            </select> +        <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> +            <div class="col"></div> +            <button class="btn btn-lg col-4" style="background-color:#003459; color:white;" (click)="trainModel();">Treniraj model</button> +            <div class="col"></div>          </div> -    </div> -    <div class="form-group row my-2"> -        <label for="batchSize" class="col-sm-2 col-form-label">Broj uzorka po iteraciji: </label> -        <div class="col-sm-10"> -            <input type="number" min="1" class="form-control" name="batchSize" [(ngModel)]="newModel.batchSize"> -        </div>      </div> +</div> -    <div class=" form-group row my-4"> -        <div class="col-4"></div> -        <button class="btn btn-lg btn-primary col-4" (click)="addModel();">Dodaj</button> -        <div class="col-4"></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 3cb47d61..01e8ade9 100644 --- a/frontend/src/app/_pages/add-model/add-model.component.ts +++ b/frontend/src/app/_pages/add-model/add-model.component.ts @@ -1,6 +1,10 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; +import { Observable, of } from 'rxjs';  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'; +  @Component({    selector: 'app-add-model', @@ -9,7 +13,10 @@ import { ANNType, Encoding, ActivationFunction, LossFunction, Optimizer } from '  })  export class AddModelComponent implements OnInit { -  newModel: Model +  @ViewChild(DatasetLoadComponent) datasetLoadComponent?: DatasetLoadComponent; +  datasetLoaded: boolean = false; + +  newModel: Model;    ANNType = ANNType;    Encoding = Encoding; @@ -18,7 +25,7 @@ export class AddModelComponent implements OnInit {    Optimizer = Optimizer;    Object = Object; -  constructor() { +  constructor(private models: ModelsService) {      this.newModel = new Model();    } @@ -26,7 +33,64 @@ export class AddModelComponent implements OnInit {    }    addModel() { -    //TODO +    this.saveModel(false); //trajno cuvanje +  } +  trainModel() { +    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); +      }); +  } + +  getCheckedInputCols() { +    this.newModel.inputColumns = []; +    let checkboxes = document.getElementsByName("cbs"); + +    for (let i = 0; i < checkboxes.length; i++) { +      let thatCb = <HTMLInputElement>checkboxes[i]; +      if (thatCb.checked) +        this.newModel.inputColumns.push(thatCb.value); +    } +    //console.log(this.checkedInputCols); +  } +  getCheckedOutputCol() { +    this.newModel.columnToPredict = ''; +    let radiobuttons = document.getElementsByName("rbs"); + +    for (let i = 0; i < radiobuttons.length; i++) { +      let thatRb = <HTMLInputElement>radiobuttons[i]; +      if (thatRb.checked) { +        this.newModel.columnToPredict = thatRb.value; +        break;  +      } +    } +    //console.log(this.checkedOutputCol); +  } +  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++) {   +      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."); +        return false; +      } +    } +    return true;    }  } diff --git a/frontend/src/app/_pages/login-page/login-page.component.css b/frontend/src/app/_pages/browse-datasets/browse-datasets.component.css index e69de29b..e69de29b 100644 --- a/frontend/src/app/_pages/login-page/login-page.component.css +++ b/frontend/src/app/_pages/browse-datasets/browse-datasets.component.css diff --git a/frontend/src/app/_pages/browse-datasets/browse-datasets.component.html b/frontend/src/app/_pages/browse-datasets/browse-datasets.component.html new file mode 100644 index 00000000..fa38a1bc --- /dev/null +++ b/frontend/src/app/_pages/browse-datasets/browse-datasets.component.html @@ -0,0 +1 @@ +<p>browse-datasets works!</p> diff --git a/frontend/src/app/_pages/only-authorized/only-authorized.component.spec.ts b/frontend/src/app/_pages/browse-datasets/browse-datasets.component.spec.ts index 82a01f63..fda74dbe 100644 --- a/frontend/src/app/_pages/only-authorized/only-authorized.component.spec.ts +++ b/frontend/src/app/_pages/browse-datasets/browse-datasets.component.spec.ts @@ -1,20 +1,20 @@  import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { OnlyAuthorizedComponent } from './only-authorized.component'; +import { BrowseDatasetsComponent } from './browse-datasets.component'; -describe('OnlyAuthorizedComponent', () => { -  let component: OnlyAuthorizedComponent; -  let fixture: ComponentFixture<OnlyAuthorizedComponent>; +describe('BrowseDatasetsComponent', () => { +  let component: BrowseDatasetsComponent; +  let fixture: ComponentFixture<BrowseDatasetsComponent>;    beforeEach(async () => {      await TestBed.configureTestingModule({ -      declarations: [ OnlyAuthorizedComponent ] +      declarations: [ BrowseDatasetsComponent ]      })      .compileComponents();    });    beforeEach(() => { -    fixture = TestBed.createComponent(OnlyAuthorizedComponent); +    fixture = TestBed.createComponent(BrowseDatasetsComponent);      component = fixture.componentInstance;      fixture.detectChanges();    }); diff --git a/frontend/src/app/_pages/browse-datasets/browse-datasets.component.ts b/frontend/src/app/_pages/browse-datasets/browse-datasets.component.ts new file mode 100644 index 00000000..dba6c25e --- /dev/null +++ b/frontend/src/app/_pages/browse-datasets/browse-datasets.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ +  selector: 'app-browse-datasets', +  templateUrl: './browse-datasets.component.html', +  styleUrls: ['./browse-datasets.component.css'] +}) +export class BrowseDatasetsComponent implements OnInit { + +  constructor() { } + +  ngOnInit(): void { +  } + +} diff --git a/frontend/src/app/_pages/only-authorized/only-authorized.component.css b/frontend/src/app/_pages/browse-predictors/browse-predictors.component.css index e69de29b..e69de29b 100644 --- a/frontend/src/app/_pages/only-authorized/only-authorized.component.css +++ b/frontend/src/app/_pages/browse-predictors/browse-predictors.component.css diff --git a/frontend/src/app/_pages/browse-predictors/browse-predictors.component.html b/frontend/src/app/_pages/browse-predictors/browse-predictors.component.html new file mode 100644 index 00000000..01c4af82 --- /dev/null +++ b/frontend/src/app/_pages/browse-predictors/browse-predictors.component.html @@ -0,0 +1 @@ +<p>browse-predictors works!</p> diff --git a/frontend/src/app/_pages/browse-predictors/browse-predictors.component.spec.ts b/frontend/src/app/_pages/browse-predictors/browse-predictors.component.spec.ts new file mode 100644 index 00000000..6d13fedf --- /dev/null +++ b/frontend/src/app/_pages/browse-predictors/browse-predictors.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { BrowsePredictorsComponent } from './browse-predictors.component'; + +describe('BrowsePredictorsComponent', () => { +  let component: BrowsePredictorsComponent; +  let fixture: ComponentFixture<BrowsePredictorsComponent>; + +  beforeEach(async () => { +    await TestBed.configureTestingModule({ +      declarations: [ BrowsePredictorsComponent ] +    }) +    .compileComponents(); +  }); + +  beforeEach(() => { +    fixture = TestBed.createComponent(BrowsePredictorsComponent); +    component = fixture.componentInstance; +    fixture.detectChanges(); +  }); + +  it('should create', () => { +    expect(component).toBeTruthy(); +  }); +}); diff --git a/frontend/src/app/_pages/browse-predictors/browse-predictors.component.ts b/frontend/src/app/_pages/browse-predictors/browse-predictors.component.ts new file mode 100644 index 00000000..b4fb2a9d --- /dev/null +++ b/frontend/src/app/_pages/browse-predictors/browse-predictors.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ +  selector: 'app-browse-predictors', +  templateUrl: './browse-predictors.component.html', +  styleUrls: ['./browse-predictors.component.css'] +}) +export class BrowsePredictorsComponent implements OnInit { + +  constructor() { } + +  ngOnInit(): void { +  } + +} diff --git a/frontend/src/app/_pages/register-page/register-page.component.css b/frontend/src/app/_pages/home/home.component.css index e69de29b..e69de29b 100644 --- a/frontend/src/app/_pages/register-page/register-page.component.css +++ b/frontend/src/app/_pages/home/home.component.css diff --git a/frontend/src/app/_pages/home/home.component.html b/frontend/src/app/_pages/home/home.component.html new file mode 100644 index 00000000..7245f602 --- /dev/null +++ b/frontend/src/app/_pages/home/home.component.html @@ -0,0 +1,53 @@ +<div class="d-flex flex-column align-items-center bg-light"> +    <img src="../../../assets/svg/logo.svg" class="bi me-2" width="256" height="256" role="img"> +    <div *ngIf="shared.loggedIn" class="d-flex flex-column align-items-center"> +        <h2 class="my-4">Započnite sa treniranjem!</h2> +        <div id="cards" class="row align-items-center justify-content-center"> +            <div class="card shadow col-3 m-1" style="width: 18rem;"> +                <div class="card-body"> +                    <mat-icon width="48px" height="48px" +                        style="font-size: 48px; margin-left: 50%; transform: translateX(-100%);">storage</mat-icon> +                    <h3 class="card-title my-2">Moji izvori podataka</h3> +                    <p class="card-text"> +                        <a class="stretched-link" routerLink="my-datasets">Preuredite</a> vaše izvore +                        podataka, ili +                        dodajte novi. +                    </p> +                </div> +            </div> +            <div class="card shadow col-3 m-1" style="width: 18rem;"> +                <div class="card-body"> +                    <mat-icon width="48px" height="48px" +                        style="font-size: 48px; margin-left: 50%; transform: translateX(-100%);">model_training +                    </mat-icon> +                    <h3 class="card-title my-2">Moji modeli</h3> +                    <p class="card-text"> +                        <a class="stretched-link" routerLink="my-models">Pregledajte</a> vaše modele, menjajte ih, +                        napravite nove modele, ili +                        ih obrišite. +                    </p> +                </div> +            </div> +            <div class="card shadow col-3 m-1" style="width: 18rem;"> +                <div class="card-body"> +                    <mat-icon width="48px" height="48px" +                        style="font-size: 48px; margin-left: 50%; transform: translateX(-100%);">batch_prediction +                    </mat-icon> +                    <h3 class="card-title my-2">Rezultati treniranja</h3> +                    <p class="card-text"> +                        <a class="stretched-link" routerLink="my-predictors">Pregledajte</a> sve vaše trenirane +                        modele, +                        koristite ih da predvidite vrednosti za red ili skup podataka, ili ih obrišite. +                    </p> +                </div> +            </div> +        </div> + +    </div> +    <h2 class="my-4">Pogledajte javne izvore podataka!</h2> +    <app-carousel [items]="publicDatasets"> +    </app-carousel> +    <h2 class="my-4">Iskoristite već trenirane modele!</h2> +    <app-carousel [items]="publicPredictors"> +    </app-carousel> +</div>
\ No newline at end of file diff --git a/frontend/src/app/_pages/login-page/login-page.component.spec.ts b/frontend/src/app/_pages/home/home.component.spec.ts index 9da3aca8..2c5a1726 100644 --- a/frontend/src/app/_pages/login-page/login-page.component.spec.ts +++ b/frontend/src/app/_pages/home/home.component.spec.ts @@ -1,20 +1,20 @@  import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { LoginPageComponent } from './login-page.component'; +import { HomeComponent } from './home.component'; -describe('LoginPageComponent', () => { -  let component: LoginPageComponent; -  let fixture: ComponentFixture<LoginPageComponent>; +describe('HomeComponent', () => { +  let component: HomeComponent; +  let fixture: ComponentFixture<HomeComponent>;    beforeEach(async () => {      await TestBed.configureTestingModule({ -      declarations: [ LoginPageComponent ] +      declarations: [ HomeComponent ]      })      .compileComponents();    });    beforeEach(() => { -    fixture = TestBed.createComponent(LoginPageComponent); +    fixture = TestBed.createComponent(HomeComponent);      component = fixture.componentInstance;      fixture.detectChanges();    }); diff --git a/frontend/src/app/_pages/home/home.component.ts b/frontend/src/app/_pages/home/home.component.ts new file mode 100644 index 00000000..7e4471e8 --- /dev/null +++ b/frontend/src/app/_pages/home/home.component.ts @@ -0,0 +1,45 @@ +import { Component, OnInit } from '@angular/core'; +import Dataset from 'src/app/_data/Dataset'; +import Predictor from 'src/app/_data/Predictor'; +import { ItemDatasetComponent } from 'src/app/_elements/item-dataset/item-dataset.component'; +import shared from 'src/app/Shared'; + +@Component({ +  selector: 'app-home', +  templateUrl: './home.component.html', +  styleUrls: ['./home.component.css'] +}) +export class HomeComponent implements OnInit { + +  publicDatasets: Dataset[]; +  publicPredictors: Predictor[]; + +  shared = shared; + +  constructor() { +    this.publicDatasets = [ +      new Dataset('Titanik', 'Titanik', ['Kolona1', 'Kolona2', 'Ime', 'OsobaJePreživela']), +      new Dataset('Drugi Dataset', 'Lorem ipsum dolor sir amet', ['jabuka', 'kruska', 'jagoda']), +      new Dataset('Dataset III', 'Kratak opis izvora podataka', ['c1', 'c2', 'c3', 'c4', 'c5']), +      new Dataset('Drugi Dataset', 'Lorem ipsum dolor sir amet', ['jabuka', 'kruska', 'jagoda']), +      new Dataset('Dataset III', 'Kratak opis izvora podataka', ['c1', 'c2', 'c3', 'c4', 'c5']), +      new Dataset('Drugi Dataset', 'Lorem ipsum dolor sir amet', ['jabuka', 'kruska', 'jagoda']), +      new Dataset('Dataset III', 'Kratak opis izvora podataka', ['c1', 'c2', 'c3', 'c4', 'c5']), +      new Dataset('Dataset III', 'Kratak opis izvora podataka', ['c1', 'c2', 'c3', 'c4', 'c5']) +    ] +    this.publicPredictors = [ +      new Predictor('Preživeli', 'Za uneto ime osobe, predvidja da li je ta osoba preživela ili ne.', ['Ime'], 'OsobaJePreživela'), +      new Predictor('Drugi model', 'Lorem ipsum dolor sir amet', ['kruska'], 'jagoda'), +      new Predictor('Treći model', 'Kratak opis modela', ['c1', 'c2', 'c3'], 'c5'), +      new Predictor('Drugi model', 'Lorem ipsum dolor sir amet', ['kruska'], 'jagoda'), +      new Predictor('Treći model', 'Kratak opis modela', ['c1', 'c2', 'c3'], 'c5'), +      new Predictor('Drugi model', 'Lorem ipsum dolor sir amet', ['kruska'], 'jagoda'), +      new Predictor('Treći model', 'Kratak opis modela', ['c1', 'c2', 'c3'], 'c5'), +      new Predictor('Treći model', 'Kratak opis modela', ['c1', 'c2', 'c3'], 'c5') +    ] +  } + +  ngOnInit(): void { +  } + +} diff --git a/frontend/src/app/_pages/login-page/login-page.component.html b/frontend/src/app/_pages/login-page/login-page.component.html deleted file mode 100644 index 8deb5290..00000000 --- a/frontend/src/app/_pages/login-page/login-page.component.html +++ /dev/null @@ -1,55 +0,0 @@ -<!--<script> -    $(document).ready(function(){ -        $(".btn").click(function(){ -            $("#exampleModal").modal('show'); -        }); - -        $('#exampleModal').modal({ -    		backdrop: 'static', -    		keyboard: false -		}); -    }); -</script>--> - -<!-- Button trigger modal --> -<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#modalForLogin" (click)="openModal()"> -    Open Modal -  </button> - -<!-- -<div style="min-height: 100vh; position: relative;"> - -    <div class="container p-5 rounded-3 shadow-sm border" style="max-width: 50em; margin-top: 50px;"> -        <h3 class="text-center pb-5">Prijavite se</h3> -        <form> -            <div class="form-outline mb-4"> -                <label class="form-label" for="username">Korisničko ime</label> -                <input [(ngModel)]="username" name="username" type="text" id="username" -                    class="form-control form-control-lg" placeholder="Unesite korisničko ime..." /> -            </div> - -            <div class="form-outline mb-3"> -                <label class="form-label" for="password">Lozinka</label> -                <input [(ngModel)]="password" name="password" type="password" id="password" -                    class="form-control form-control-lg" placeholder="Unesite lozinku..." /> -            </div> - -            <div class="text-center text-lg-start mt-4 pt-2"> -                <p *ngIf="wrongCreds" class="small fw-bold mt-2 pt-1 mb-0 text-danger">Lozinka ili e-mail su pogrešni -                </p> -                <br> - -                <button type="button" class="btn btn-primary btn-lg" -                    style="padding-left: 2.5rem; padding-right: 2.5rem;" (click)="onSubmit()">Prijava -                </button> - -                <br> -                <p class="small fw-bold mt-2 pt-1 mb-0">Još uvek nemate nalog? -                    <a routerLink="/register" class="link-danger">Registrujte se</a> -                </p> -            </div> -        </form> -    </div> - -</div> --->
\ No newline at end of file diff --git a/frontend/src/app/_pages/login-page/login-page.component.ts b/frontend/src/app/_pages/login-page/login-page.component.ts deleted file mode 100644 index e5366283..00000000 --- a/frontend/src/app/_pages/login-page/login-page.component.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; -import { CookieService } from 'ngx-cookie-service'; -import { AuthService } from 'src/app/_services/auth.service'; - -import { LoginModalComponent } from 'src/app/_modals/login-modal/login-modal.component'; -import { MDBModalRef, MDBModalService } from 'ng-uikit-pro-standard'; - - -declare var window: any; - -@Component({ -  selector: 'app-login-page', -  templateUrl: './login-page.component.html', -  styleUrls: ['./login-page.component.css'], -   -}) -export class LoginPageComponent{ - -  modalRef?: MDBModalRef; - -  //email: string = ''; -  username: string = ''; -  password: string = ''; - -  public wrongCreds: boolean = false;      //RAZMOTRITI -  //public notApproved: boolean = false;     //RAZMOTRITI - -  formModal: any; - -  constructor( -    private authService: AuthService, -    private cookie: CookieService, -    private router: Router, -    private modalService: MDBModalService -  ) { } - -  openModal() { -    //this.modalRef = this.modalService.show(LoginModalComponent); -  } -  /* -  ngOnInit(): void { -    this.formModal = new window.bootstrap.Modal( -      document.getElementById("exampleModal") -    ); -  } - -  openModal() { -    this.formModal.show(); -    //console.log("ok"); -    //(<HTMLInputElement>document.getElementById("exampleModal")).style.display = "block"; -  } - -  onSubmit() { - -    this.authService.login(this.username, this.password).subscribe((response) => { -      console.log(response); -      this.cookie.set('token', response); -      this.router.navigate(['add-model']); -    }); -  } -*/ -} diff --git a/frontend/src/app/_pages/my-datasets/my-datasets.component.css b/frontend/src/app/_pages/my-datasets/my-datasets.component.css new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/frontend/src/app/_pages/my-datasets/my-datasets.component.css diff --git a/frontend/src/app/_pages/my-datasets/my-datasets.component.html b/frontend/src/app/_pages/my-datasets/my-datasets.component.html new file mode 100644 index 00000000..4b3095be --- /dev/null +++ b/frontend/src/app/_pages/my-datasets/my-datasets.component.html @@ -0,0 +1 @@ +<p>my-datasets works!</p> diff --git a/frontend/src/app/_pages/my-datasets/my-datasets.component.spec.ts b/frontend/src/app/_pages/my-datasets/my-datasets.component.spec.ts new file mode 100644 index 00000000..fc1fc3f3 --- /dev/null +++ b/frontend/src/app/_pages/my-datasets/my-datasets.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MyDatasetsComponent } from './my-datasets.component'; + +describe('MyDatasetsComponent', () => { +  let component: MyDatasetsComponent; +  let fixture: ComponentFixture<MyDatasetsComponent>; + +  beforeEach(async () => { +    await TestBed.configureTestingModule({ +      declarations: [ MyDatasetsComponent ] +    }) +    .compileComponents(); +  }); + +  beforeEach(() => { +    fixture = TestBed.createComponent(MyDatasetsComponent); +    component = fixture.componentInstance; +    fixture.detectChanges(); +  }); + +  it('should create', () => { +    expect(component).toBeTruthy(); +  }); +}); diff --git a/frontend/src/app/_pages/my-datasets/my-datasets.component.ts b/frontend/src/app/_pages/my-datasets/my-datasets.component.ts new file mode 100644 index 00000000..af5eab97 --- /dev/null +++ b/frontend/src/app/_pages/my-datasets/my-datasets.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ +  selector: 'app-my-datasets', +  templateUrl: './my-datasets.component.html', +  styleUrls: ['./my-datasets.component.css'] +}) +export class MyDatasetsComponent implements OnInit { + +  constructor() { } + +  ngOnInit(): void { +  } + +} diff --git a/frontend/src/app/_pages/my-models/my-models.component.css b/frontend/src/app/_pages/my-models/my-models.component.css new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/frontend/src/app/_pages/my-models/my-models.component.css diff --git a/frontend/src/app/_pages/my-models/my-models.component.html b/frontend/src/app/_pages/my-models/my-models.component.html new file mode 100644 index 00000000..2fea257d --- /dev/null +++ b/frontend/src/app/_pages/my-models/my-models.component.html @@ -0,0 +1 @@ +<p>my-models works!</p> diff --git a/frontend/src/app/_pages/my-models/my-models.component.spec.ts b/frontend/src/app/_pages/my-models/my-models.component.spec.ts new file mode 100644 index 00000000..e431d04c --- /dev/null +++ b/frontend/src/app/_pages/my-models/my-models.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MyModelsComponent } from './my-models.component'; + +describe('MyModelsComponent', () => { +  let component: MyModelsComponent; +  let fixture: ComponentFixture<MyModelsComponent>; + +  beforeEach(async () => { +    await TestBed.configureTestingModule({ +      declarations: [ MyModelsComponent ] +    }) +    .compileComponents(); +  }); + +  beforeEach(() => { +    fixture = TestBed.createComponent(MyModelsComponent); +    component = fixture.componentInstance; +    fixture.detectChanges(); +  }); + +  it('should create', () => { +    expect(component).toBeTruthy(); +  }); +}); diff --git a/frontend/src/app/_pages/my-models/my-models.component.ts b/frontend/src/app/_pages/my-models/my-models.component.ts new file mode 100644 index 00000000..e9bc52de --- /dev/null +++ b/frontend/src/app/_pages/my-models/my-models.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ +  selector: 'app-my-models', +  templateUrl: './my-models.component.html', +  styleUrls: ['./my-models.component.css'] +}) +export class MyModelsComponent implements OnInit { + +  constructor() { } + +  ngOnInit(): void { +  } + +} diff --git a/frontend/src/app/_pages/my-predictors/my-predictors.component.css b/frontend/src/app/_pages/my-predictors/my-predictors.component.css new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/frontend/src/app/_pages/my-predictors/my-predictors.component.css diff --git a/frontend/src/app/_pages/my-predictors/my-predictors.component.html b/frontend/src/app/_pages/my-predictors/my-predictors.component.html new file mode 100644 index 00000000..32d085af --- /dev/null +++ b/frontend/src/app/_pages/my-predictors/my-predictors.component.html @@ -0,0 +1 @@ +<p>my-predictors works!</p> diff --git a/frontend/src/app/_pages/register-page/register-page.component.spec.ts b/frontend/src/app/_pages/my-predictors/my-predictors.component.spec.ts index 347fe9f4..37dddf6d 100644 --- a/frontend/src/app/_pages/register-page/register-page.component.spec.ts +++ b/frontend/src/app/_pages/my-predictors/my-predictors.component.spec.ts @@ -1,20 +1,20 @@  import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { RegisterPageComponent } from './register-page.component'; +import { MyPredictorsComponent } from './my-predictors.component'; -describe('RegisterPageComponent', () => { -  let component: RegisterPageComponent; -  let fixture: ComponentFixture<RegisterPageComponent>; +describe('MyPredictorsComponent', () => { +  let component: MyPredictorsComponent; +  let fixture: ComponentFixture<MyPredictorsComponent>;    beforeEach(async () => {      await TestBed.configureTestingModule({ -      declarations: [ RegisterPageComponent ] +      declarations: [ MyPredictorsComponent ]      })      .compileComponents();    });    beforeEach(() => { -    fixture = TestBed.createComponent(RegisterPageComponent); +    fixture = TestBed.createComponent(MyPredictorsComponent);      component = fixture.componentInstance;      fixture.detectChanges();    }); diff --git a/frontend/src/app/_pages/my-predictors/my-predictors.component.ts b/frontend/src/app/_pages/my-predictors/my-predictors.component.ts new file mode 100644 index 00000000..b0d6e9dd --- /dev/null +++ b/frontend/src/app/_pages/my-predictors/my-predictors.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ +  selector: 'app-my-predictors', +  templateUrl: './my-predictors.component.html', +  styleUrls: ['./my-predictors.component.css'] +}) +export class MyPredictorsComponent implements OnInit { + +  constructor() { } + +  ngOnInit(): void { +  } + +} diff --git a/frontend/src/app/_pages/only-authorized/only-authorized.component.html b/frontend/src/app/_pages/only-authorized/only-authorized.component.html deleted file mode 100644 index 27bbcf09..00000000 --- a/frontend/src/app/_pages/only-authorized/only-authorized.component.html +++ /dev/null @@ -1 +0,0 @@ -<p>only-authorized works!</p> diff --git a/frontend/src/app/_pages/only-authorized/only-authorized.component.ts b/frontend/src/app/_pages/only-authorized/only-authorized.component.ts deleted file mode 100644 index be88365f..00000000 --- a/frontend/src/app/_pages/only-authorized/only-authorized.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ -  selector: 'app-only-authorized', -  templateUrl: './only-authorized.component.html', -  styleUrls: ['./only-authorized.component.css'] -}) -export class OnlyAuthorizedComponent implements OnInit { - -  constructor() { } - -  ngOnInit(): void { -  } - -} diff --git a/frontend/src/app/_pages/predict/predict.component.css b/frontend/src/app/_pages/predict/predict.component.css new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/frontend/src/app/_pages/predict/predict.component.css diff --git a/frontend/src/app/_pages/predict/predict.component.html b/frontend/src/app/_pages/predict/predict.component.html new file mode 100644 index 00000000..74a83b71 --- /dev/null +++ b/frontend/src/app/_pages/predict/predict.component.html @@ -0,0 +1 @@ +<p>predict works!</p> diff --git a/frontend/src/app/_pages/predict/predict.component.spec.ts b/frontend/src/app/_pages/predict/predict.component.spec.ts new file mode 100644 index 00000000..65871ecc --- /dev/null +++ b/frontend/src/app/_pages/predict/predict.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PredictComponent } from './predict.component'; + +describe('PredictComponent', () => { +  let component: PredictComponent; +  let fixture: ComponentFixture<PredictComponent>; + +  beforeEach(async () => { +    await TestBed.configureTestingModule({ +      declarations: [ PredictComponent ] +    }) +    .compileComponents(); +  }); + +  beforeEach(() => { +    fixture = TestBed.createComponent(PredictComponent); +    component = fixture.componentInstance; +    fixture.detectChanges(); +  }); + +  it('should create', () => { +    expect(component).toBeTruthy(); +  }); +}); diff --git a/frontend/src/app/_pages/predict/predict.component.ts b/frontend/src/app/_pages/predict/predict.component.ts new file mode 100644 index 00000000..0e313c65 --- /dev/null +++ b/frontend/src/app/_pages/predict/predict.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ +  selector: 'app-predict', +  templateUrl: './predict.component.html', +  styleUrls: ['./predict.component.css'] +}) +export class PredictComponent implements OnInit { + +  constructor() { } + +  ngOnInit(): void { +  } + +} diff --git a/frontend/src/app/_pages/profile/profile.component.css b/frontend/src/app/_pages/profile/profile.component.css new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/frontend/src/app/_pages/profile/profile.component.css diff --git a/frontend/src/app/_pages/profile/profile.component.html b/frontend/src/app/_pages/profile/profile.component.html new file mode 100644 index 00000000..9df0576d --- /dev/null +++ b/frontend/src/app/_pages/profile/profile.component.html @@ -0,0 +1 @@ +<p>profile works!</p> diff --git a/frontend/src/app/_pages/profile/profile.component.spec.ts b/frontend/src/app/_pages/profile/profile.component.spec.ts new file mode 100644 index 00000000..e88012e7 --- /dev/null +++ b/frontend/src/app/_pages/profile/profile.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ProfileComponent } from './profile.component'; + +describe('ProfileComponent', () => { +  let component: ProfileComponent; +  let fixture: ComponentFixture<ProfileComponent>; + +  beforeEach(async () => { +    await TestBed.configureTestingModule({ +      declarations: [ ProfileComponent ] +    }) +    .compileComponents(); +  }); + +  beforeEach(() => { +    fixture = TestBed.createComponent(ProfileComponent); +    component = fixture.componentInstance; +    fixture.detectChanges(); +  }); + +  it('should create', () => { +    expect(component).toBeTruthy(); +  }); +}); diff --git a/frontend/src/app/_pages/profile/profile.component.ts b/frontend/src/app/_pages/profile/profile.component.ts new file mode 100644 index 00000000..93040f3e --- /dev/null +++ b/frontend/src/app/_pages/profile/profile.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ +  selector: 'app-profile', +  templateUrl: './profile.component.html', +  styleUrls: ['./profile.component.css'] +}) +export class ProfileComponent implements OnInit { + +  constructor() { } + +  ngOnInit(): void { +  } + +} diff --git a/frontend/src/app/_pages/register-page/register-page.component.html b/frontend/src/app/_pages/register-page/register-page.component.html deleted file mode 100644 index f8ae046e..00000000 --- a/frontend/src/app/_pages/register-page/register-page.component.html +++ /dev/null @@ -1,80 +0,0 @@ -<div style="min-height: 100vh; position: relative;"> -     -    <!-- TODO <app-navbar [activeNav]="'register'"></app-navbar>--> -     -    <div class="container" style="margin-top: 50px;"> -        <div class="text-black"> -          <div class="row justify-content-center"> -            <div class="col-8 bg-white border rounded-3 shadow-sm p-5"> -              <p class="text-center h2 fw-bold mb-5 mx-1 mx-md-4">Registracija</p> -       -              <form class="mx-1 mx-md-4"> -                <!--Ime--> -                <div class="row"> -                    <div class="col-6 p-2"> -                        <label class="form-label" for="firstName">Ime</label> -                        <input type="text" id="firstName" class="form-control" [(ngModel)]="firstName" name="firstName"> -                        <p *ngIf="wrongFirstNameBool" class="small fw-bold text-danger">Unesite ispravno ime. (minimum 1, maksimum 30 karaktera)</p> -                    </div> -                    <!--Prezime--> -                    <div class="col-6 p-2"> -                        <label class="form-label" for="lastName">Prezime</label> -                        <input type="text" id="lastName" class="form-control" [(ngModel)]="lastName" name="lastName" /> -                        <p *ngIf="wrongLastNameBool" class="small fw-bold text-danger">Unesite ispravno prezime. (minimum 1, maksimum 30 karaktera)</p> -                    </div> -                </div> -                <br> -       -                <div class="row"> -                    <!--Korisnicko ime--> -                    <div class="col-6 p-2"> -                        <label class="form-label" for="nickName">Korisničko ime</label> -                        <input type="text" id="nickName" class="form-control" [(ngModel)]="nickName" name="nickName" /> -                        <p *ngIf="wrongNickNameBool" class="small fw-bold text-danger">Unesite ispravno korisničko ime.</p> -                    </div> -                    <!--Email--> -                    <div class="col-6 p-2"> -                        <label class="form-label" for="email">E-mail adresa</label> -                        <input type="email" id="email" class="form-control" [(ngModel)]="email" name="email" /> -                        <p *ngIf="wrongEmailBool" class="small fw-bold text-danger">Unesite ispravnu e-mail adresu.</p> -                    </div> -                </div> -                <br> -       -                <div class="row"> -                    <!-- Lozinka 1. --> -                    <div class="col-6 p-2"> -                        <label class="form-label" for="pass1">Lozinka</label> -                        <input type="password" id="pass1" class="form-control" [(ngModel)]="pass1" name="pass1" /> -                        <p *ngIf="wrongPass1Bool" class="small fw-bold text-danger">Lozinka se mora sastojati od najmanje 6 karaktera.</p> -                    </div> -       -                    <!-- Lozinka 2. --> -                    <div class="col-6 p-2"> -                        <label class="form-label" for="pass2">Potvrdite lozinku</label> -                        <input type="password" id="pass2" class="form-control" [(ngModel)]="pass2" name="pass2" /> -                        <p *ngIf="wrongPass2Bool" class="small fw-bold text-danger">Lozinke se ne podudaraju.</p> -                    </div> -                </div> -       -                <br><br><br> -                <!--Dugme Registruj se--> -                <div class="d-flex justify-content-center mx-4 mb-3 mb-lg-4"> -                    <button type="button" class="btn btn-primary btn-lg" (click)="validation()">Registrujte se</button> -                </div> -       -                <div class="form-check d-flex justify-content-center mb-5"> -                  <label class="form-check-label" class="small fw-bold mt-2 pt-1 mb-0" for="form2Example3"> -                    Već imate kreiran nalog? -                    <a routerLink="/login" class="link-danger">Prijavite se</a> -                  </label> -                </div> -              </form> -            </div> -          </div> -        </div> -      </div> -     -    <!-- TODO <app-footer></app-footer> --> - -</div>
\ No newline at end of file diff --git a/frontend/src/app/_pages/register-page/register-page.component.ts b/frontend/src/app/_pages/register-page/register-page.component.ts deleted file mode 100644 index 712fc55e..00000000 --- a/frontend/src/app/_pages/register-page/register-page.component.ts +++ /dev/null @@ -1,140 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; -import { AuthService } from 'src/app/_services/auth.service'; - -@Component({ -  selector: 'app-register-page', -  templateUrl: './register-page.component.html', -  styleUrls: ['./register-page.component.css'] -}) -export class RegisterPageComponent implements OnInit { -  firstName: string = ''; -  lastName: string = ''; -  nickName: string = ''; -  email: string = ''; -  pass1: string = ''; -  pass2: string = ''; - -  wrongFirstNameBool: boolean = false; -  wrongLastNameBool: boolean = false; -  wrongNickNameBool: boolean = false; -  wrongEmailBool: boolean = false; -  wrongPass1Bool: boolean = false; -  wrongPass2Bool: boolean = false; - -  pattName: RegExp = /^[a-zA-ZšŠđĐčČćĆžŽ]+([ \-][a-zA-ZšŠđĐčČćĆžŽ]+)*$/; -  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 router: Router, -    private authService: AuthService, -  ) { } - -  ngOnInit(): void { -  } - -  isCorrectName(element: string): boolean { -    if (this.pattName.test(element) && !(this.pattTwoSpaces.test(element)) && (element.length >= 1 && element.length <= 30)) -      return true; -    return false; -  } -  isCorrectEmail(element: string): boolean { -    if (this.pattEmail.test(element.toLowerCase()) && element.length <= 320) -      return true; -    return false; -  } -  isCorrectPassword(element: string): boolean { -    if (this.pattPassword.test(element)) -      return true; -    return false; -  } - -  firstNameValidation() { -    if (this.isCorrectName(this.firstName) == true) { -      this.wrongFirstNameBool = false; -      return; -    } -    (<HTMLSelectElement>document.getElementById('firstName')).focus(); -    this.wrongFirstNameBool = true; -  } -  lastNameValidation() { -    if (this.isCorrectName(this.lastName) == true) { -      this.wrongLastNameBool = false; -      return; -    } -    (<HTMLSelectElement>document.getElementById('lastName')).focus(); -    this.wrongLastNameBool = true; -  } -  nickNameValidation() { -    if (this.isCorrectName(this.nickName) == true) { -      this.wrongNickNameBool = false; -      return; -    } -    (<HTMLSelectElement>document.getElementById('nickName')).focus(); -    this.wrongNickNameBool = true; -  } -  emailValidation() { -    if (this.isCorrectEmail(this.email) == true) { -      this.wrongEmailBool = false; -      return; -    } -    (<HTMLSelectElement>document.getElementById('email')).focus(); -    this.wrongEmailBool = true; -  } -  passwordValidation() { -    if (this.isCorrectPassword(this.pass1) && this.isCorrectPassword(this.pass2) && this.pass1 == this.pass2) { -      this.wrongPass1Bool = false; -      this.wrongPass2Bool = false; -      return; -    } -    this.pass1 = ''; //brisi obe ukucane lozinke -    this.pass2 = ''; -    (<HTMLSelectElement>document.getElementById('pass1')).focus(); -    this.wrongPass1Bool = true; -    this.wrongPass2Bool = true; -  } - -  validation() { -    this.firstName = this.firstName.trim(); -    this.lastName = this.lastName.trim(); -    this.nickName = this.nickName.trim(); -    this.email = this.email.trim(); - -    this.firstNameValidation(); -    this.lastNameValidation(); -    //this.nickNameValidation(); -    this.emailValidation(); -    this.passwordValidation(); - -    if (!(this.wrongFirstNameBool || this.wrongLastNameBool || this.wrongNickNameBool || -      this.wrongEmailBool || this.wrongPass1Bool || this.wrongPass2Bool)) { //sve ok, registruj ga - -      let user = { -        firstName: this.firstName, -        lastName: this.lastName, -        username: this.nickName, -        password: this.pass1, -        email: this.email -      } - -      this.authService.register(user) -        .subscribe( -          (response) => { -            console.log(response); -            if (response === 'User added') -              this.router.navigate(['/login']); //registracija uspesna, idi na login -            else if (response === 'Email Already Exists') -              alert('Nalog sa unetim email-om već postoji!'); -            else if (response === 'Username Already Exists') -              alert('Nalog sa unetim korisnićkim imenom već postoji!'); -          } -        ); -    } -  } - - - - -} diff --git a/frontend/src/app/_pages/settings/settings.component.css b/frontend/src/app/_pages/settings/settings.component.css new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/frontend/src/app/_pages/settings/settings.component.css diff --git a/frontend/src/app/_pages/settings/settings.component.html b/frontend/src/app/_pages/settings/settings.component.html new file mode 100644 index 00000000..4ab2a415 --- /dev/null +++ b/frontend/src/app/_pages/settings/settings.component.html @@ -0,0 +1 @@ +<p>settings works!</p> diff --git a/frontend/src/app/_pages/settings/settings.component.spec.ts b/frontend/src/app/_pages/settings/settings.component.spec.ts new file mode 100644 index 00000000..a3a508b0 --- /dev/null +++ b/frontend/src/app/_pages/settings/settings.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SettingsComponent } from './settings.component'; + +describe('SettingsComponent', () => { +  let component: SettingsComponent; +  let fixture: ComponentFixture<SettingsComponent>; + +  beforeEach(async () => { +    await TestBed.configureTestingModule({ +      declarations: [ SettingsComponent ] +    }) +    .compileComponents(); +  }); + +  beforeEach(() => { +    fixture = TestBed.createComponent(SettingsComponent); +    component = fixture.componentInstance; +    fixture.detectChanges(); +  }); + +  it('should create', () => { +    expect(component).toBeTruthy(); +  }); +}); diff --git a/frontend/src/app/_pages/settings/settings.component.ts b/frontend/src/app/_pages/settings/settings.component.ts new file mode 100644 index 00000000..19862fb0 --- /dev/null +++ b/frontend/src/app/_pages/settings/settings.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ +  selector: 'app-settings', +  templateUrl: './settings.component.html', +  styleUrls: ['./settings.component.css'] +}) +export class SettingsComponent implements OnInit { + +  constructor() { } + +  ngOnInit(): void { +  } + +} | 
