Added Ivy file page without full pagination
This commit is contained in:
parent
2186c75c6f
commit
be5f495bfa
|
@ -47,6 +47,8 @@ import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||||
import { MatNativeDateModule, DateAdapter } from '@angular/material/core';
|
import { MatNativeDateModule, DateAdapter } from '@angular/material/core';
|
||||||
import {MatPaginatorModule} from '@angular/material/paginator';
|
import {MatPaginatorModule} from '@angular/material/paginator';
|
||||||
import { CustomDateAdapter } from './custom-date-adapter';
|
import { CustomDateAdapter } from './custom-date-adapter';
|
||||||
|
import { MatTableModule } from '@angular/material/table'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,6 +91,7 @@ export function getBaseHref(platformLocation: PlatformLocation): string {
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
MatPaginatorModule,
|
MatPaginatorModule,
|
||||||
|
MatTableModule,
|
||||||
MatNativeDateModule,
|
MatNativeDateModule,
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
ChartsModule,
|
ChartsModule,
|
||||||
|
|
|
@ -201,7 +201,7 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<mat-paginator #paginator [length]="topBarData[0]" [pageSize]="pageSize" [pageSizeOptions]="pageSizeOptions"
|
<mat-paginator #paginator [length]="100000" [pageSize]="pageSize" [pageSizeOptions]="pageSizeOptions"
|
||||||
(page)="updatePage($event)">
|
(page)="updatePage($event)">
|
||||||
</mat-paginator>
|
</mat-paginator>
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,67 @@
|
||||||
|
|
||||||
<div class="container-fluid mt--7">
|
<div
|
||||||
<div class="card">
|
class="full-height bg-primary"
|
||||||
<div class="card-header">
|
fxLayout="row"
|
||||||
<h3 class="mb-0">The following files were imported from IVY</h3>
|
fxLayoutAlign="center center"
|
||||||
</div>
|
fxLayoutGap="40px"
|
||||||
<div class="card-body">
|
>
|
||||||
<div class="justify-content-center">
|
<mat-card fxFlex="50%">
|
||||||
<div class="table-responsive">
|
<mat-card-header>
|
||||||
<table class="table align-items-center table-flush">
|
<h1>The following files were imported from IVY</h1>
|
||||||
<thead><tr><th>Date Added</th><th>File Name</th><th>Sample Count</th></tr></thead>
|
</mat-card-header>
|
||||||
<tbody>
|
|
||||||
<tr *ngFor="let file of fileList">
|
<mat-card-content fxLayout="row wrap" fxLayoutAlign="center center">
|
||||||
<td>{{file.date_added | date : 'medium'}}</td>
|
<table mat-table [dataSource]="fileList" class="mat-elevation-z8">
|
||||||
<td>{{file.file_name}}</td>
|
|
||||||
<td>{{file.sample_count}}</td>
|
<!--- Note that these columns can be defined in any order.
|
||||||
</tr>
|
The actual rendered columns are set as a property on the row definition" -->
|
||||||
</tbody>
|
|
||||||
|
<!-- Position Column -->
|
||||||
|
<ng-container matColumnDef="position">
|
||||||
|
<th mat-header-cell *matHeaderCellDef> Date Added </th>
|
||||||
|
<td mat-cell *matCellDef="let element"> {{element.date_added | date:"medium"}} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- Name Column -->
|
||||||
|
<ng-container matColumnDef="name">
|
||||||
|
<th mat-header-cell *matHeaderCellDef> File Name </th>
|
||||||
|
<td mat-cell *matCellDef="let element"> {{element.file_name}} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- Weight Column -->
|
||||||
|
<ng-container matColumnDef="weight">
|
||||||
|
<th mat-header-cell *matHeaderCellDef> Sample Count </th>
|
||||||
|
<td mat-cell *matCellDef="let element"> {{element.sample_count}} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
<mat-card-actions>
|
||||||
</div>
|
<button
|
||||||
</div>
|
mat-flat-button
|
||||||
|
class="btn-lg"
|
||||||
|
color="accent"
|
||||||
|
fxFlex="50%"
|
||||||
|
(click) = "prev()"
|
||||||
|
><mat-icon>navigate_before</mat-icon>Prev </button>
|
||||||
|
<button
|
||||||
|
id="btn_next"
|
||||||
|
#nextButton="matButton"
|
||||||
|
mat-flat-button
|
||||||
|
class="btn-lg"
|
||||||
|
color="accent"
|
||||||
|
fxFlex="50%"
|
||||||
|
(click) = "next()"
|
||||||
|
>Next <mat-icon>navigate_next</mat-icon></button>
|
||||||
|
|
||||||
|
</mat-card-actions>
|
||||||
|
|
||||||
|
|
||||||
|
</mat-card-content>
|
||||||
|
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
<mat-paginator #paginator [length]="100000" [pageSize]="pageSize" [pageSizeOptions]="pageSizeOptions"
|
|
||||||
(page)="updatePage($event)">
|
|
||||||
</mat-paginator>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
|
@ -1,19 +1,55 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import {APP_BASE_HREF} from '@angular/common';
|
||||||
|
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
|
||||||
|
import {ReactiveFormsModule} from '@angular/forms';
|
||||||
|
import {MatButtonModule} from '@angular/material/button';
|
||||||
|
import {MatCardModule} from '@angular/material/card';
|
||||||
|
import {MatFormFieldModule} from '@angular/material/form-field';
|
||||||
|
import {MatIconModule} from '@angular/material/icon';
|
||||||
|
import {MatInputModule} from '@angular/material/input';
|
||||||
|
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
|
||||||
|
import {Router} from '@angular/router';
|
||||||
|
import {ApiService} from '../services/api.service';
|
||||||
|
import {CacheService} from '../services/cache.service';
|
||||||
|
import {SettingsService} from '../services/settings.service';
|
||||||
|
import {MockEnvironment} from '../testing/environment.mock';
|
||||||
|
|
||||||
import { ImportedFilesComponent } from './imported-files.component';
|
import { ImportedFilesComponent } from './imported-files.component';
|
||||||
|
|
||||||
describe('ImportedFilesComponent', () => {
|
describe('ImportedFilesComponent', () => {
|
||||||
let component: ImportedFilesComponent;
|
let component: ImportedFilesComponent;
|
||||||
let fixture: ComponentFixture<ImportedFilesComponent>;
|
let fixture: ComponentFixture<ImportedFilesComponent>;
|
||||||
|
const mockRouter = {navigate: jasmine.createSpy('navigate')};
|
||||||
|
let httpMock: HttpTestingController;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ ImportedFilesComponent ]
|
declarations: [ ImportedFilesComponent ],
|
||||||
|
imports: [
|
||||||
|
HttpClientTestingModule,
|
||||||
|
MatButtonModule,
|
||||||
|
MatCardModule,
|
||||||
|
MatFormFieldModule,
|
||||||
|
MatIconModule,
|
||||||
|
MatInputModule,
|
||||||
|
NoopAnimationsModule,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
{provide: 'APP_ENVIRONMENT', useClass: MockEnvironment},
|
||||||
|
{provide: APP_BASE_HREF, useValue: '/'},
|
||||||
|
{provide: Router, useValue: mockRouter},
|
||||||
|
ApiService,
|
||||||
|
CacheService,
|
||||||
|
SettingsService,
|
||||||
|
]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
||||||
|
httpMock = TestBed.inject(HttpTestingController);
|
||||||
fixture = TestBed.createComponent(ImportedFilesComponent);
|
fixture = TestBed.createComponent(ImportedFilesComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
|
@ -4,6 +4,13 @@ import { ApiService } from '../services/api.service';
|
||||||
import {PageEvent} from '@angular/material/paginator'
|
import {PageEvent} from '@angular/material/paginator'
|
||||||
import { IvyFile } from '../models/ivyfile.interface';
|
import { IvyFile } from '../models/ivyfile.interface';
|
||||||
|
|
||||||
|
export interface PeriodicElement {
|
||||||
|
name: string;
|
||||||
|
position: number;
|
||||||
|
weight: number;
|
||||||
|
symbol: string;
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-imported-files',
|
selector: 'app-imported-files',
|
||||||
templateUrl: './imported-files.component.html',
|
templateUrl: './imported-files.component.html',
|
||||||
|
@ -11,22 +18,32 @@ import { IvyFile } from '../models/ivyfile.interface';
|
||||||
})
|
})
|
||||||
export class ImportedFilesComponent implements OnInit {
|
export class ImportedFilesComponent implements OnInit {
|
||||||
fileList: IvyFile[] = [];
|
fileList: IvyFile[] = [];
|
||||||
|
|
||||||
constructor(private fileService: ApiService) { }
|
constructor(private fileService: ApiService) { }
|
||||||
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.fileService.getFiles(0).subscribe(fileList => this.fileList = fileList);
|
this.fileService.getFiles(0).subscribe(fileList => this.fileList = fileList);
|
||||||
}
|
}
|
||||||
|
displayedColumns: string[] = ['position', 'name', 'weight'];
|
||||||
current_page: number = 0;
|
current_page: number = 0;
|
||||||
pageSize: number = 10;
|
pageSize: number = 10;
|
||||||
pageSizeOptions: number[] = [10,20,50,100];
|
pageSizeOptions: number[] = [10,20,50,100];
|
||||||
|
|
||||||
updatePage(event: PageEvent) {
|
updatePage(event: PageEvent) {
|
||||||
this.current_page = event.pageIndex;
|
this.current_page = event.pageIndex;
|
||||||
|
|
||||||
this.fileService.getFiles(this.current_page).subscribe(fileList => this.fileList = fileList);
|
this.fileService.getFiles(this.current_page).subscribe(fileList => this.fileList = fileList);
|
||||||
}
|
}
|
||||||
|
next(){
|
||||||
|
if (this.fileList.length > 0){
|
||||||
|
this.current_page += 1;
|
||||||
|
this.fileService.getFiles(this.current_page).subscribe(fileList => this.fileList = fileList); }}
|
||||||
|
prev(){
|
||||||
|
if (this.current_page > 0){
|
||||||
|
this.current_page -= 1;
|
||||||
|
this.fileService.getFiles(this.current_page).subscribe(fileList => this.fileList = fileList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
@import './material-theme.scss';
|
@import './material-theme.scss';
|
||||||
@include cr-connect-theme($cr-connect-theme);
|
@include cr-connect-theme($cr-connect-theme);
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
}
|
Loading…
Reference in New Issue