diff options
author | Ivan Ljubisavljevic <ivan996sk@gmail.com> | 2022-05-16 00:49:40 +0200 |
---|---|---|
committer | Ivan Ljubisavljevic <ivan996sk@gmail.com> | 2022-05-16 00:49:40 +0200 |
commit | cc4e071ce18834d3bd4cd8ae123afab3ea5832b7 (patch) | |
tree | be1009111b7112a0ef28388bbbb381016ad0cdcf | |
parent | 22911bdc9c5ff39ff86d8298179b147c4580f82c (diff) | |
parent | a2989dc4534837f24f23ac33e5b30515ee6cfae7 (diff) |
Merge branch 'redesign' of http://gitlab.pmf.kg.ac.rs/igrannonica/neuronstellar into redesign
4 files changed, 47 insertions, 8 deletions
diff --git a/frontend/src/app/_elements/folder/folder.component.ts b/frontend/src/app/_elements/folder/folder.component.ts index e62c59f9..fff5a25d 100644 --- a/frontend/src/app/_elements/folder/folder.component.ts +++ b/frontend/src/app/_elements/folder/folder.component.ts @@ -65,8 +65,10 @@ export class FolderComponent implements AfterViewInit { } displayFile() { - if (this.type == FolderType.Dataset) + if (this.type == FolderType.Dataset){ this.formDataset.dataset = <Dataset>this.fileToDisplay; + this.formDataset.existingFlag=false; + } else if (this.type == FolderType.Model) this.formModel.newModel = <Model>this.fileToDisplay; } @@ -93,11 +95,13 @@ export class FolderComponent implements AfterViewInit { this.newFileSelected = true; this.listView = false; this.displayFile(); - if (this.type == FolderType.Dataset) + if (this.type == FolderType.Dataset){ this.formDataset.clear(); + } } selectFile(file?: FolderFile) { + this.formDataset.resetPagging(); this.selectedFile = file; this.fileToDisplay = file; if (this.type == FolderType.Experiment && file) { 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 07a3ee1a..9f8e9e6f 100644 --- a/frontend/src/app/_elements/form-dataset/form-dataset.component.html +++ b/frontend/src/app/_elements/form-dataset/form-dataset.component.html @@ -1,6 +1,5 @@ <div class="folderBox" *ngIf="dataset"> - - + <div class="topBar"> <div class="kolona mb-3"> <div class="fileButton"> @@ -43,10 +42,16 @@ <div class="file-container" [ngClass]="{'dottedClass': !tableData.hasInput}"> <i class="material-icons-outlined icon-display" [ngClass]="{'hidden': tableData.hasInput}">file_upload</i> + <input class="file" id="file-upload" (change)="changeListener($event)" #fileInput type="file" accept=".csv"> <div class="mt-5 datatable"> + <div [ngClass]="{'hidden': (!existingFlag)}" class="text-center"> + <button mat-button (click)="goBack()"><mat-icon>keyboard_arrow_left</mat-icon></button> + <div style="display: inline;">{{(this.begin/10)+1}}</div> + <button mat-button (click)="goForward()"><mat-icon>keyboard_arrow_right</mat-icon></button> + </div> <app-datatable [tableData]="tableData"></app-datatable> </div> diff --git a/frontend/src/app/_elements/form-dataset/form-dataset.component.ts b/frontend/src/app/_elements/form-dataset/form-dataset.component.ts index 94ef9905..79fbe2c9 100644 --- a/frontend/src/app/_elements/form-dataset/form-dataset.component.ts +++ b/frontend/src/app/_elements/form-dataset/form-dataset.component.ts @@ -24,6 +24,9 @@ export class FormDatasetComponent { files: File[] = []; rowsNumber: number = 0; colsNumber: number = 0; + begin:number=0; + end:number=10; + existingFlag:boolean=false; @Input() dataset: Dataset; //dodaj ! potencijalno @@ -40,7 +43,21 @@ export class FormDatasetComponent { } //@ViewChild('fileImportInput', { static: false }) fileImportInput: any; cemu je ovo sluzilo? + resetPagging(){ + this.begin=0; + } + goBack(){ + if(this.begin-10<=0) + this.begin=0; + else + this.begin-=10; + this.loadExisting(); + } + goForward(){ + this.begin+=10; + this.loadExisting(); + } clear(){ this.tableData.hasInput = false; } @@ -56,6 +73,7 @@ export class FormDatasetComponent { this.filename = this.files[0].name; this.tableData.loaded = false; + this.existingFlag=false; this.update(); } @@ -64,7 +82,6 @@ export class FormDatasetComponent { update() { this.firstInput = true - if (this.files.length < 1) return; @@ -91,20 +108,27 @@ export class FormDatasetComponent { } loadExisting(){ + this.existingFlag=true; this.firstInput = false; this.tableData.hasInput = true; this.tableData.loaded = false; - - this.datasetsService.getDatasetFile(this.dataset.fileId).subscribe((file: string | undefined) => { + this.datasetsService.getDatasetHeader(this.dataset.fileId).subscribe((header: string | undefined)=>{ + + this.datasetsService.getDatasetFilePaging(this.dataset.fileId,this.begin,this.end).subscribe((file: string | undefined) => { if (file) { this.tableData.loaded = true; this.tableData.numRows = this.dataset.rowCount; this.tableData.numCols = this.dataset.columnInfo.length; - this.tableData.data = this.csv.csvToArray(file, (this.dataset.delimiter == "razmak") ? " " : (this.dataset.delimiter == "novi red") ? "\t" : this.dataset.delimiter); + this.tableData.data = this.csv.csvToArray(header+'\n'+file, (this.dataset.delimiter == "razmak") ? " " : (this.dataset.delimiter == "novi red") ? "\t" : this.dataset.delimiter); } + else{ + this.begin-=10; + this.loadExisting(); + } }); + }); } diff --git a/frontend/src/app/_services/datasets.service.ts b/frontend/src/app/_services/datasets.service.ts index 2211996f..f5677097 100644 --- a/frontend/src/app/_services/datasets.service.ts +++ b/frontend/src/app/_services/datasets.service.ts @@ -27,6 +27,12 @@ export class DatasetsService { getDatasetFile(fileId: any): any { return this.http.get(`${Configuration.settings.apiURL}/file/csvRead/${fileId}/-1/11`, { headers: this.authService.authHeader(), responseType: 'text' }); } + getDatasetFilePaging(fileId:any,begin:any,end:any){ + return this.http.get(`${Configuration.settings.apiURL}/file/csvRead/${fileId}/${begin}/${end}`, { headers: this.authService.authHeader(), responseType: 'text' }); + } + getDatasetHeader(fileId:any){ + return this.http.get(`${Configuration.settings.apiURL}/file/csvRead/${fileId}/-1/1`, { headers: this.authService.authHeader(), responseType: 'text' }); + } getDatasetFilePartial(fileId: any, startRow: number, rowNum: number): Observable<any> { return this.http.get(`${Configuration.settings.apiURL}/file/csvRead/${fileId}/${startRow}/${rowNum}`, { headers: this.authService.authHeader(), responseType: 'text' }); } |