InfiniteScroll and Layer list filter

This commit is contained in:
Michał Zieliński
2023-10-20 13:56:40 +02:00
parent a358dc75cf
commit a96ca6a795
9 changed files with 227 additions and 201 deletions

View File

@@ -22,14 +22,14 @@
"@angular/material-moment-adapter": "^16.2.9",
"@angular/platform-browser": "^16.2.10",
"@angular/platform-browser-dynamic": "^16.2.10",
"@angular/pwa": "16.2.0",
"@angular/pwa": "16.2.7",
"@angular/router": "^16.2.10",
"@angular/service-worker": "^16.2.10",
"jwt-decode": "^3.1.2",
"moment": "^2.29.4",
"rxjs": "^7.6.0",
"uuid": "^9.0.0",
"zone.js": "^0.13.1"
"uuid": "9.0.1",
"zone.js": "0.14.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^16.2.7",
@@ -40,18 +40,18 @@
"@angular-eslint/template-parser": "16.2.0",
"@angular/cli": "~16.2.7",
"@angular/compiler-cli": "^16.2.10",
"@types/jasmine": "4.3.5",
"@types/uuid": "^9.0.0",
"@typescript-eslint/eslint-plugin": "6.4.0",
"@typescript-eslint/parser": "6.4.0",
"eslint": "8.47.0",
"jasmine-core": "5.1.0",
"@types/jasmine": "5.1.1",
"@types/uuid": "9.0.6",
"@typescript-eslint/eslint-plugin": "6.8.0",
"@typescript-eslint/parser": "6.8.0",
"eslint": "8.51.0",
"jasmine-core": "5.1.1",
"karma": "~6.4.0",
"karma-chrome-launcher": "3.2.0",
"karma-coverage": "2.2.1",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "2.1.0",
"tslib": "2.6.1",
"tslib": "2.6.2",
"typescript": "5.1.6"
}
}

View File

@@ -0,0 +1,43 @@
import { Directive, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
export enum SCROLLEND_DIRECTION {
DOWN = 'down',
UP = 'UP',
}
@Directive({
selector: '[diunabiScrollEnd]',
standalone: true,
})
export class ScrollEndDirective implements OnInit, OnDestroy {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@Output() diunabiScrollEnd: EventEmitter<any> = new EventEmitter();
@Input() rootMargin = '0px 0px 0px 0px';
@Input() desiredDirection: SCROLLEND_DIRECTION = SCROLLEND_DIRECTION.DOWN;
observer?: IntersectionObserver;
previousEntry?: IntersectionObserverEntry;
scrollDirection?: SCROLLEND_DIRECTION;
constructor(
private el: ElementRef,
) { }
ngOnInit(): void {
this.observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
this.scrollDirection = this.previousEntry?.boundingClientRect.bottom ?? 0 > entry.boundingClientRect.bottom ? SCROLLEND_DIRECTION.DOWN : SCROLLEND_DIRECTION.UP;
if (!this.previousEntry?.isIntersecting && entry.isIntersecting && this.scrollDirection === this.desiredDirection) {
this.diunabiScrollEnd.emit();
}
this.previousEntry = entry;
});
}, {
rootMargin: this.rootMargin,
});
this.observer.observe(this.el.nativeElement);
}
ngOnDestroy(): void {
this.observer?.disconnect();
}
}

View File

@@ -76,13 +76,9 @@ export class Layer extends Base {
});
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static getList(_http: HttpClient, start: number, limit: number, codes: string[]): any {
static getList(_http: HttpClient, start: number, limit: number, name: string, type: LayerType | ''): any {
return new Promise((resolve, reject) => {
let codesQuery = "";
if (codes.length) {
codesQuery = `&${codes.map(x => `codes=${x}`).join('&')}`;
}
_http.get<Layer[]>(`${environment.api.url}/layers?start=${start}&limit=${limit}${codesQuery}`)
_http.get<Layer[]>(`${environment.api.url}/layers?start=${start}&limit=${limit}&name=${name}&type=${type}`)
.pipe(map(data => data.map(x => new Layer().deserialize(x))))
.subscribe({
next: (data) => resolve(data),

View File

@@ -1,4 +1,25 @@
<table mat-table [dataSource]="dataSource" (scroll)="onScroll($event)">
<br>
<div class="row">
<div class="col">
<mat-form-field appearance="outline" class="search-field">
<mat-label>Name</mat-label>
<input matInput [(ngModel)]="name" (ngModelChange)="nameUpdate.next($event)">
</mat-form-field>
</div>
<div class="col">
<mat-form-field appearance="outline" class="search-field">
<mat-label>Type</mat-label>
<mat-select (selectionChange)="loadList()" [(ngModel)]="type">
<mat-option value="">All</mat-option>
<mat-option [value]="LayerType.Import">Import</mat-option>
<mat-option [value]="LayerType.Processed">Processed</mat-option>
<mat-option [value]="LayerType.Administration">Administration</mat-option>
<mat-option [value]="LayerType.Dictionary">Dictionary</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
<table mat-table [dataSource]="dataSource">
<ng-container matColumnDef="number">
<th mat-header-cell *matHeaderCellDef>Number</th>
<td mat-cell *matCellDef="let element">{{element.number}}</td>
@@ -17,3 +38,4 @@
<tr mat-header-row *matHeaderRowDef="displayedColumns, sticky: false"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['Detail/', row.id]"></tr>
</table>
<div (diunabiScrollEnd)="loadMore()"></div>

View File

@@ -0,0 +1,4 @@
.search-field {
width: 95%;
margin: 5px;
}

View File

@@ -1,5 +1,5 @@
import { HttpClient } from '@angular/common/http';
import { Component, HostListener, OnInit } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { MatSortModule } from '@angular/material/sort';
import { MatTableModule } from '@angular/material/table';
import { Layer, LayerType } from 'src/app/models/layer.model';
@@ -12,7 +12,9 @@ import { MatSelectModule } from '@angular/material/select';
import { FormsModule } from '@angular/forms';
import { MatChipsModule} from '@angular/material/chips';
import { MatIconModule } from '@angular/material/icon';
import { NgFor } from '@angular/common';
import { KeyValuePipe, NgFor } from '@angular/common';
import { ScrollEndDirective } from 'src/app/directives/scroll-end.directive';
import { Subject, debounceTime, distinctUntilChanged } from 'rxjs';
@Component({
selector: 'diunabi-layers-list',
@@ -21,7 +23,7 @@ import { NgFor } from '@angular/common';
standalone: true,
imports: [MatGridListModule, MatButtonModule, RouterLink, MatFormFieldModule,
MatInputModule, MatTableModule, MatSortModule, MatSelectModule, FormsModule,
MatChipsModule, MatIconModule, NgFor]
MatChipsModule, MatIconModule, NgFor, ScrollEndDirective, KeyValuePipe]
})
export class LayersListComponent implements OnInit {
displayedColumns = ['number', 'name', 'type'];
@@ -33,51 +35,36 @@ export class LayersListComponent implements OnInit {
end: number = this.limit + this.start;
loadingInProgress = false;
type = "";
codes: string[] = [];
type: LayerType | '' = '';
name: string = '';
nameUpdate = new Subject<string>();
constructor(
private _http: HttpClient,
) { }
//@HostListener('document:scroll', ['$event'])
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public async onScroll(event: any) {
console.log('on scrool', event);
if (event.target.offsetHeight + event.target.scrollTop >= event.target.scrollHeight - 1 && !this.loadingInProgress) {
this.loadingInProgress = true;
this.dataSource = await Layer.getList(this._http, this.start, this.limit, this.codes);
this.start = this.end;
this.end = this.limit + this.start;
setTimeout(() => {
this.loadingInProgress = false;
}, 500);
}
}
async ngOnInit() {
this.dataSource = await Layer.getList(this._http, this.start, this.limit, this.codes);
this.nameUpdate.pipe(
debounceTime(400),
distinctUntilChanged())
.subscribe(() => {
this.loadList();
});
await this.loadList();
}
async loadList() {
this.start = 0;
this.end = this.limit;
this.dataSource = await Layer.getList(this._http, this.start, this.limit, this.name, this.type);
}
async loadMore() {
this.start = this.end;
this.end = this.limit + this.start;
}
async removeCode(code: string) {
const index = this.codes.indexOf(code);
if (index >= 0) {
this.start = 0;
this.end = this.limit + this.start;
this.codes.splice(index, 1);
this.dataSource = await Layer.getList(this._http, this.start, this.limit, this.codes);
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async addCode(event: any) {
const value = (event.target.value || '').trim();
if (value) {
this.start = 0;
this.end = this.limit + this.start;
this.codes.push(value);
this.dataSource = await Layer.getList(this._http, this.start, this.limit, this.codes);
}
event.target.value = '';
this.end += this.limit;
this.dataSource = this.dataSource.concat(
await Layer.getList(this._http, this.start, this.limit, this.name, this.type)
);
}
}

View File

@@ -103,17 +103,6 @@
"@angular-devkit/architect" "0.1602.7"
rxjs "7.8.1"
"@angular-devkit/core@16.2.0":
version "16.2.0"
resolved "https://registry.yarnpkg.com/@angular-devkit/core/-/core-16.2.0.tgz#477c6f9006d9efa4ff54c8f7a8a391df70788602"
integrity sha512-l1k6Rqm3YM16BEn3CWyQKrk9xfu+2ux7Bw3oS+h1TO4/RoxO2PgHj8LLRh/WNrYVarhaqO7QZ5ePBkXNMkzJ1g==
dependencies:
ajv "8.12.0"
ajv-formats "2.1.1"
jsonc-parser "3.2.0"
rxjs "7.8.1"
source-map "0.7.4"
"@angular-devkit/core@16.2.7":
version "16.2.7"
resolved "https://registry.yarnpkg.com/@angular-devkit/core/-/core-16.2.7.tgz#193b3e6b4975dc387fab9a0eb9f4d44828e8fef5"
@@ -126,17 +115,6 @@
rxjs "7.8.1"
source-map "0.7.4"
"@angular-devkit/schematics@16.2.0":
version "16.2.0"
resolved "https://registry.yarnpkg.com/@angular-devkit/schematics/-/schematics-16.2.0.tgz#4de900615451fce61cf5bcbc7935986ad89e49f5"
integrity sha512-QMDJXPE0+YQJ9Ap3MMzb0v7rx6ZbBEokmHgpdIjN3eILYmbAdsSGE8HTV8NjS9nKmcyE9OGzFCMb7PFrDTlTAw==
dependencies:
"@angular-devkit/core" "16.2.0"
jsonc-parser "3.2.0"
magic-string "0.30.1"
ora "5.4.1"
rxjs "7.8.1"
"@angular-devkit/schematics@16.2.7":
version "16.2.7"
resolved "https://registry.yarnpkg.com/@angular-devkit/schematics/-/schematics-16.2.7.tgz#6b7a8e4ffdc5a79016b5c86ff4e666f19aad9892"
@@ -367,13 +345,13 @@
dependencies:
tslib "^2.3.0"
"@angular/pwa@16.2.0":
version "16.2.0"
resolved "https://registry.yarnpkg.com/@angular/pwa/-/pwa-16.2.0.tgz#b8356012f667312e10d856e8663e106757a5d29c"
integrity sha512-zZsglQIinUT0OFddJHC4XleauZlPmwMhXY7uUpL4nVo/hANsyF5GuEskiHx3mujU+O4a3QmeLHXzjnOeb5pxHQ==
"@angular/pwa@16.2.7":
version "16.2.7"
resolved "https://registry.yarnpkg.com/@angular/pwa/-/pwa-16.2.7.tgz#e51173eeb5df18e568fd7a75633c6ecc344057b6"
integrity sha512-7Tv3XIGmxRNmDyVOMKziUhsRSMuECLcKPJW9tl6cdIfcBCvjqEkZCGyQ4p2wBwYKhzcufHTF5hnLuOW8oQ0oCQ==
dependencies:
"@angular-devkit/schematics" "16.2.0"
"@schematics/angular" "16.2.0"
"@angular-devkit/schematics" "16.2.7"
"@schematics/angular" "16.2.7"
parse5-html-rewriting-stream "7.0.0"
"@angular/router@^16.2.10":
@@ -1928,17 +1906,17 @@
minimatch "^3.1.2"
strip-json-comments "^3.1.1"
"@eslint/js@^8.47.0":
version "8.47.0"
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.47.0.tgz#5478fdf443ff8158f9de171c704ae45308696c7d"
integrity sha512-P6omY1zv5MItm93kLM8s2vr1HICJH8v0dvddDhysbIuZ+vcjOHg5Zbkf1mTkcmi2JA9oBG2anOkRnW8WJTS8Og==
"@eslint/js@8.51.0":
version "8.51.0"
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.51.0.tgz#6d419c240cfb2b66da37df230f7e7eef801c32fa"
integrity sha512-HxjQ8Qn+4SI3/AFv6sOrDB+g6PpUTDwSJiQqOrnneEk8L71161srI9gjzzZvYVbzHiVg/BvcH95+cK/zfIt4pg==
"@humanwhocodes/config-array@^0.11.10":
version "0.11.10"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.10.tgz#5a3ffe32cc9306365fb3fd572596cd602d5e12d2"
integrity sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==
"@humanwhocodes/config-array@^0.11.11":
version "0.11.12"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.12.tgz#549afec9bfce5232ac6325db12765f407e70e3a0"
integrity sha512-NlGesA1usRNn6ctHCZ21M4/dKPgW9Nn1FypRdIKKgZOKzkVV4T1FlK5mBiLhHBCDmEbdQG0idrcXlbZfksJ+RA==
dependencies:
"@humanwhocodes/object-schema" "^1.2.1"
"@humanwhocodes/object-schema" "^2.0.0"
debug "^4.1.1"
minimatch "^3.0.5"
@@ -1947,10 +1925,10 @@
resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c"
integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==
"@humanwhocodes/object-schema@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==
"@humanwhocodes/object-schema@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.0.tgz#04ad39d82176c7da1591c81e78b993cffd8348d8"
integrity sha512-9S9QrXY2K0L4AGDcSgTi9vgiCcG8VcBv4Mp7/1hDPYoswIy6Z6KO5blYto82BT8M0MZNRWmCFLpCs3HlpYGGdw==
"@isaacs/cliui@^8.0.2":
version "8.0.2"
@@ -2899,15 +2877,6 @@
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"
integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==
"@schematics/angular@16.2.0":
version "16.2.0"
resolved "https://registry.yarnpkg.com/@schematics/angular/-/angular-16.2.0.tgz#53c373054127e6838c8ec390f5ea51054c09a401"
integrity sha512-Ib0/ZCkjWt7a5p3209JVwEWwf41v03K3ylvlxLIEo1ZGijAZAlrBj4GrA5YQ+TmPm2hRyt+owss7x91/x+i0Gw==
dependencies:
"@angular-devkit/core" "16.2.0"
"@angular-devkit/schematics" "16.2.0"
jsonc-parser "3.2.0"
"@schematics/angular@16.2.7":
version "16.2.7"
resolved "https://registry.yarnpkg.com/@schematics/angular/-/angular-16.2.7.tgz#64f1c2b025d365f77289c84fb79b7f8d6e17edd3"
@@ -3049,10 +3018,10 @@
dependencies:
"@types/node" "*"
"@types/jasmine@4.3.5":
version "4.3.5"
resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-4.3.5.tgz#05c6b401c041b8a4f3303c3a58c9580aac2b898c"
integrity sha512-9YHUdvuNDDRJYXZwHqSsO72Ok0vmqoJbNn73ttyITQp/VA60SarnZ+MPLD37rJAhVoKp+9BWOvJP5tHIRfZylQ==
"@types/jasmine@5.1.1":
version "5.1.1"
resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-5.1.1.tgz#7d2a2a983e1e822858ea9e30d90e11a3fe408fc0"
integrity sha512-qL4GoZHHJl1JQ0vK31OtXMfkfGxYJnysmYz9kk0E8j5W96ThKykBF90uD3PcVmQUAzulbsaus2eFiBhCH5itfw==
"@types/json-schema@*", "@types/json-schema@^7.0.12", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9":
version "7.0.12"
@@ -3124,10 +3093,10 @@
dependencies:
"@types/node" "*"
"@types/uuid@^9.0.0":
version "9.0.2"
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-9.0.2.tgz#ede1d1b1e451548d44919dc226253e32a6952c4b"
integrity sha512-kNnC1GFBLuhImSnV7w4njQkUiJi0ZXUycu1rUaouPqiKlXkh77JKgdRnTAp1x5eBwcIwbtI+3otwzuIDEuDoxQ==
"@types/uuid@9.0.6":
version "9.0.6"
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-9.0.6.tgz#c91ae743d8344a54b2b0c691195f5ff5265f6dfb"
integrity sha512-BT2Krtx4xaO6iwzwMFUYvWBWkV2pr37zD68Vmp1CDV196MzczBRxuEpD6Pr395HAgebC/co7hOphs53r8V7jew==
"@types/ws@^8.5.5":
version "8.5.5"
@@ -3136,16 +3105,16 @@
dependencies:
"@types/node" "*"
"@typescript-eslint/eslint-plugin@6.4.0":
version "6.4.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.4.0.tgz#53428b616f7d80fe879f45a08f11cc0f0b62cf13"
integrity sha512-62o2Hmc7Gs3p8SLfbXcipjWAa6qk2wZGChXG2JbBtYpwSRmti/9KHLqfbLs9uDigOexG+3PaQ9G2g3201FWLKg==
"@typescript-eslint/eslint-plugin@6.8.0":
version "6.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.8.0.tgz#06abe4265e7c82f20ade2dcc0e3403c32d4f148b"
integrity sha512-GosF4238Tkes2SHPQ1i8f6rMtG6zlKwMEB0abqSJ3Npvos+doIlc/ATG+vX1G9coDF3Ex78zM3heXHLyWEwLUw==
dependencies:
"@eslint-community/regexpp" "^4.5.1"
"@typescript-eslint/scope-manager" "6.4.0"
"@typescript-eslint/type-utils" "6.4.0"
"@typescript-eslint/utils" "6.4.0"
"@typescript-eslint/visitor-keys" "6.4.0"
"@typescript-eslint/scope-manager" "6.8.0"
"@typescript-eslint/type-utils" "6.8.0"
"@typescript-eslint/utils" "6.8.0"
"@typescript-eslint/visitor-keys" "6.8.0"
debug "^4.3.4"
graphemer "^1.4.0"
ignore "^5.2.4"
@@ -3153,15 +3122,15 @@
semver "^7.5.4"
ts-api-utils "^1.0.1"
"@typescript-eslint/parser@6.4.0":
version "6.4.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.4.0.tgz#47e7c6e22ff1248e8675d95f488890484de67600"
integrity sha512-I1Ah1irl033uxjxO9Xql7+biL3YD7w9IU8zF+xlzD/YxY6a4b7DYA08PXUUCbm2sEljwJF6ERFy2kTGAGcNilg==
"@typescript-eslint/parser@6.8.0":
version "6.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.8.0.tgz#bb2a969d583db242f1ee64467542f8b05c2e28cb"
integrity sha512-5tNs6Bw0j6BdWuP8Fx+VH4G9fEPDxnVI7yH1IAPkQH5RUtvKwRoqdecAPdQXv4rSOADAaz1LFBZvZG7VbXivSg==
dependencies:
"@typescript-eslint/scope-manager" "6.4.0"
"@typescript-eslint/types" "6.4.0"
"@typescript-eslint/typescript-estree" "6.4.0"
"@typescript-eslint/visitor-keys" "6.4.0"
"@typescript-eslint/scope-manager" "6.8.0"
"@typescript-eslint/types" "6.8.0"
"@typescript-eslint/typescript-estree" "6.8.0"
"@typescript-eslint/visitor-keys" "6.8.0"
debug "^4.3.4"
"@typescript-eslint/scope-manager@5.62.0":
@@ -3172,13 +3141,13 @@
"@typescript-eslint/types" "5.62.0"
"@typescript-eslint/visitor-keys" "5.62.0"
"@typescript-eslint/scope-manager@6.4.0":
version "6.4.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.4.0.tgz#3048e4262ba3eafa4e2e69b08912d9037ec646ae"
integrity sha512-TUS7vaKkPWDVvl7GDNHFQMsMruD+zhkd3SdVW0d7b+7Zo+bd/hXJQ8nsiUZMi1jloWo6c9qt3B7Sqo+flC1nig==
"@typescript-eslint/scope-manager@6.8.0":
version "6.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.8.0.tgz#5cac7977385cde068ab30686889dd59879811efd"
integrity sha512-xe0HNBVwCph7rak+ZHcFD6A+q50SMsFwcmfdjs9Kz4qDh5hWhaPhFjRs/SODEhroBI5Ruyvyz9LfwUJ624O40g==
dependencies:
"@typescript-eslint/types" "6.4.0"
"@typescript-eslint/visitor-keys" "6.4.0"
"@typescript-eslint/types" "6.8.0"
"@typescript-eslint/visitor-keys" "6.8.0"
"@typescript-eslint/type-utils@5.62.0":
version "5.62.0"
@@ -3190,13 +3159,13 @@
debug "^4.3.4"
tsutils "^3.21.0"
"@typescript-eslint/type-utils@6.4.0":
version "6.4.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.4.0.tgz#c8ac92716ed6a9d5443aa3e342910355b0796ba0"
integrity sha512-TvqrUFFyGY0cX3WgDHcdl2/mMCWCDv/0thTtx/ODMY1QhEiyFtv/OlLaNIiYLwRpAxAtOLOY9SUf1H3Q3dlwAg==
"@typescript-eslint/type-utils@6.8.0":
version "6.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.8.0.tgz#50365e44918ca0fd159844b5d6ea96789731e11f"
integrity sha512-RYOJdlkTJIXW7GSldUIHqc/Hkto8E+fZN96dMIFhuTJcQwdRoGN2rEWA8U6oXbLo0qufH7NPElUb+MceHtz54g==
dependencies:
"@typescript-eslint/typescript-estree" "6.4.0"
"@typescript-eslint/utils" "6.4.0"
"@typescript-eslint/typescript-estree" "6.8.0"
"@typescript-eslint/utils" "6.8.0"
debug "^4.3.4"
ts-api-utils "^1.0.1"
@@ -3205,10 +3174,10 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.62.0.tgz#258607e60effa309f067608931c3df6fed41fd2f"
integrity sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==
"@typescript-eslint/types@6.4.0":
version "6.4.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.4.0.tgz#5b109a59a805f0d8d375895e42d9e5f0037f66ee"
integrity sha512-+FV9kVFrS7w78YtzkIsNSoYsnOtrYVnKWSTVXoL1761CsCRv5wpDOINgsXpxD67YCLZtVQekDDyaxfjVWUJmmg==
"@typescript-eslint/types@6.8.0":
version "6.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.8.0.tgz#1ab5d4fe1d613e3f65f6684026ade6b94f7e3ded"
integrity sha512-p5qOxSum7W3k+llc7owEStXlGmSl8FcGvhYt8Vjy7FqEnmkCVlM3P57XQEGj58oqaBWDQXbJDZxwUWMS/EAPNQ==
"@typescript-eslint/typescript-estree@5.62.0":
version "5.62.0"
@@ -3223,13 +3192,13 @@
semver "^7.3.7"
tsutils "^3.21.0"
"@typescript-eslint/typescript-estree@6.4.0":
version "6.4.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.4.0.tgz#3c58d20632db93fec3d6ab902acbedf593d37276"
integrity sha512-iDPJArf/K2sxvjOR6skeUCNgHR/tCQXBsa+ee1/clRKr3olZjZ/dSkXPZjG6YkPtnW6p5D1egeEPMCW6Gn4yLA==
"@typescript-eslint/typescript-estree@6.8.0":
version "6.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.8.0.tgz#9565f15e0cd12f55cf5aa0dfb130a6cb0d436ba1"
integrity sha512-ISgV0lQ8XgW+mvv5My/+iTUdRmGspducmQcDw5JxznasXNnZn3SKNrTRuMsEXv+V/O+Lw9AGcQCfVaOPCAk/Zg==
dependencies:
"@typescript-eslint/types" "6.4.0"
"@typescript-eslint/visitor-keys" "6.4.0"
"@typescript-eslint/types" "6.8.0"
"@typescript-eslint/visitor-keys" "6.8.0"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
@@ -3250,17 +3219,17 @@
eslint-scope "^5.1.1"
semver "^7.3.7"
"@typescript-eslint/utils@6.4.0":
version "6.4.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.4.0.tgz#23e996b693603c5924b1fbb733cc73196256baa5"
integrity sha512-BvvwryBQpECPGo8PwF/y/q+yacg8Hn/2XS+DqL/oRsOPK+RPt29h5Ui5dqOKHDlbXrAeHUTnyG3wZA0KTDxRZw==
"@typescript-eslint/utils@6.8.0":
version "6.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.8.0.tgz#d42939c2074c6b59844d0982ce26a51d136c4029"
integrity sha512-dKs1itdE2qFG4jr0dlYLQVppqTE+Itt7GmIf/vX6CSvsW+3ov8PbWauVKyyfNngokhIO9sKZeRGCUo1+N7U98Q==
dependencies:
"@eslint-community/eslint-utils" "^4.4.0"
"@types/json-schema" "^7.0.12"
"@types/semver" "^7.5.0"
"@typescript-eslint/scope-manager" "6.4.0"
"@typescript-eslint/types" "6.4.0"
"@typescript-eslint/typescript-estree" "6.4.0"
"@typescript-eslint/scope-manager" "6.8.0"
"@typescript-eslint/types" "6.8.0"
"@typescript-eslint/typescript-estree" "6.8.0"
semver "^7.5.4"
"@typescript-eslint/visitor-keys@5.62.0":
@@ -3271,12 +3240,12 @@
"@typescript-eslint/types" "5.62.0"
eslint-visitor-keys "^3.3.0"
"@typescript-eslint/visitor-keys@6.4.0":
version "6.4.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.4.0.tgz#96a426cdb1add28274abd7a34aefe27f8b7d51ef"
integrity sha512-yJSfyT+uJm+JRDWYRYdCm2i+pmvXJSMtPR9Cq5/XQs4QIgNoLcoRtDdzsLbLsFM/c6um6ohQkg/MLxWvoIndJA==
"@typescript-eslint/visitor-keys@6.8.0":
version "6.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.8.0.tgz#cffebed56ae99c45eba901c378a6447b06be58b8"
integrity sha512-oqAnbA7c+pgOhW2OhGvxm0t1BULX5peQI/rLsNDpGM78EebV3C9IGbX5HNZabuZ6UQrYveCLjKo8Iy/lLlBkkg==
dependencies:
"@typescript-eslint/types" "6.4.0"
"@typescript-eslint/types" "6.8.0"
eslint-visitor-keys "^3.4.1"
"@vitejs/plugin-basic-ssl@1.0.1":
@@ -4783,16 +4752,16 @@ eslint-visitor-keys@^3.4.3:
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800"
integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==
eslint@8.47.0:
version "8.47.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.47.0.tgz#c95f9b935463fb4fad7005e626c7621052e90806"
integrity sha512-spUQWrdPt+pRVP1TTJLmfRNJJHHZryFmptzcafwSvHsceV81djHOdnEeDmkdotZyLNjDhrOasNK8nikkoG1O8Q==
eslint@8.51.0:
version "8.51.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.51.0.tgz#4a82dae60d209ac89a5cff1604fea978ba4950f3"
integrity sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==
dependencies:
"@eslint-community/eslint-utils" "^4.2.0"
"@eslint-community/regexpp" "^4.6.1"
"@eslint/eslintrc" "^2.1.2"
"@eslint/js" "^8.47.0"
"@humanwhocodes/config-array" "^0.11.10"
"@eslint/js" "8.51.0"
"@humanwhocodes/config-array" "^0.11.11"
"@humanwhocodes/module-importer" "^1.0.1"
"@nodelib/fs.walk" "^1.2.8"
ajv "^6.12.4"
@@ -5872,10 +5841,10 @@ jake@^10.8.5:
filelist "^1.0.4"
minimatch "^3.1.2"
jasmine-core@5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-5.1.0.tgz#2a52c92ec2e5a4bf674c3de0edbaa10c3875b6fc"
integrity sha512-bFMMwpKuTZXCuGd51yClFobw5SOtad1kmdWnYO8dNwYV8i01Xj0C2+nyQpSKl1EKxiPfyd1ZgBl/rsusL3aS6w==
jasmine-core@5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-5.1.1.tgz#38b6ccfbe60aa2a863cf441751d9639b5a571edc"
integrity sha512-UrzO3fL7nnxlQXlvTynNAenL+21oUQRlzqQFsA2U11ryb4+NLOCOePZ70PTojEaUKhiFugh7dG0Q+I58xlPdWg==
jasmine-core@^4.1.0:
version "4.6.0"
@@ -8163,6 +8132,11 @@ tslib@2.6.1, tslib@^2.0.3:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.1.tgz#fd8c9a0ff42590b25703c0acb3de3d3f4ede0410"
integrity sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==
tslib@2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae"
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==
tslib@^1.8.1:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
@@ -8319,16 +8293,16 @@ utils-merge@1.0.1:
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==
uuid@9.0.1:
version "9.0.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30"
integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==
uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
uuid@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5"
integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==
v8-compile-cache@2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"
@@ -8701,9 +8675,9 @@ yocto-queue@^1.0.0:
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-1.0.0.tgz#7f816433fb2cbc511ec8bf7d263c3b58a1a3c251"
integrity sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==
zone.js@^0.13.1:
version "0.13.1"
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.13.1.tgz#ea06f6a80ba8ac0c68e412365ae72e2cd0787982"
integrity sha512-+bIeDAFEBYuXRuU3qGQvzdPap+N1zjM4KkBAiiQuVVCrHrhjDuY6VkUhNa5+U27+9w0q3fbKiMCbpJ0XzMmSWA==
zone.js@0.14.0:
version "0.14.0"
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.14.0.tgz#ddab2133e8a88be4b225fc2a414e8357f9902a68"
integrity sha512-Sz0G0TjMuyApIcuTJeK742+xLLKEPjYtkdBEazBlYePHkICVp9DPKqI/4dJt3LCtQBd52sCxz23uAFJ2OJa6Ow==
dependencies:
tslib "^2.3.0"

View File

@@ -37,24 +37,24 @@ namespace WebAPI.Controllers
}
[HttpGet]
public IActionResult GetAll(int start, int limit, [FromQuery] string[] codes)
public IActionResult GetAll(int start, int limit, string? name, LayerType? type)
{
try
{
if (codes != null && codes.Length > 0)
IQueryable<Layer> response = db.Layers.Where(x => !x.IsDeleted);
if (name != null)
{
response = response.Where(x => x.Name.Contains(name));
}
if (type != null)
{
response = response.Where(x => x.Type == type);
}
return Ok(db.Layers.Where(x => !x.IsDeleted)
.Where(x => codes.Select(Int32.Parse).ToList().Contains(x.Number))
return Ok(response
.OrderByDescending(x => x.Number)
.Skip(start).Take(limit).ToList());
}
else
{
return Ok(db.Layers.Where(x => !x.IsDeleted)
.OrderByDescending(x => x.Number)
.Skip(start).Take(limit).ToList());
}
}
catch (Exception e)
{

View File

@@ -18,7 +18,7 @@ namespace WebAPI.Models
[Required]
public string? Source { get; set; }
[Required]
public string? Name { get; set; }
public string Name { get; set; }
[Required]
public LayerType Type { get; set; }
[Required]