mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-10 12:53:03 -05:00
feat(challenge23): create table for testing table challenge
This commit is contained in:
36
libs/testing-table/backend/.eslintrc.json
Normal file
36
libs/testing-table/backend/.eslintrc.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"extends": ["../../../.eslintrc.json"],
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts"],
|
||||
"rules": {
|
||||
"@angular-eslint/directive-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "attribute",
|
||||
"prefix": "angularChallenges",
|
||||
"style": "camelCase"
|
||||
}
|
||||
],
|
||||
"@angular-eslint/component-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "element",
|
||||
"prefix": "angular-challenges",
|
||||
"style": "kebab-case"
|
||||
}
|
||||
]
|
||||
},
|
||||
"extends": [
|
||||
"plugin:@nx/angular",
|
||||
"plugin:@angular-eslint/template/process-inline-templates"
|
||||
]
|
||||
},
|
||||
{
|
||||
"files": ["*.html"],
|
||||
"extends": ["plugin:@nx/angular-template"],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
3
libs/testing-table/backend/README.md
Normal file
3
libs/testing-table/backend/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# testing-table-backend
|
||||
|
||||
This library was generated with [Nx](https://nx.dev).
|
||||
20
libs/testing-table/backend/project.json
Normal file
20
libs/testing-table/backend/project.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "testing-table-backend",
|
||||
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "libs/testing-table/backend/src",
|
||||
"prefix": "angular-challenges",
|
||||
"tags": [],
|
||||
"projectType": "library",
|
||||
"targets": {
|
||||
"lint": {
|
||||
"executor": "@nx/linter:eslint",
|
||||
"outputs": ["{options.outputFile}"],
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"libs/testing-table/backend/**/*.ts",
|
||||
"libs/testing-table/backend/**/*.html"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1
libs/testing-table/backend/src/index.ts
Normal file
1
libs/testing-table/backend/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './lib/fake-backend.service';
|
||||
42
libs/testing-table/backend/src/lib/fake-backend.service.ts
Normal file
42
libs/testing-table/backend/src/lib/fake-backend.service.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { SortDirection } from '@angular/material/sort';
|
||||
import { User, randUser } from '@ngneat/falso';
|
||||
import { map, take, timer } from 'rxjs';
|
||||
|
||||
type SortDirectionIndex = 1 | -1 | 0;
|
||||
|
||||
const sort: Record<SortDirection, SortDirectionIndex> = {
|
||||
asc: 1,
|
||||
desc: -1,
|
||||
'': 0,
|
||||
};
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class FakeBackendService {
|
||||
private readonly users = randUser({ length: 10 });
|
||||
|
||||
getUsers = (active: keyof User, dir: SortDirection, pageIndex: number) =>
|
||||
timer(0, 1000).pipe(
|
||||
take(1),
|
||||
map(() => this.sortByKey(this.users, active, sort[dir]))
|
||||
);
|
||||
|
||||
private sortByKey(
|
||||
arr: User[],
|
||||
key: keyof User,
|
||||
direction: SortDirectionIndex
|
||||
): User[] {
|
||||
return arr.sort((a, b) => {
|
||||
const valueA = a[key];
|
||||
const valueB = b[key];
|
||||
|
||||
if (valueA < valueB) {
|
||||
return -1 * direction;
|
||||
} else if (valueA > valueB) {
|
||||
return 1 * direction;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
26
libs/testing-table/backend/tsconfig.json
Normal file
26
libs/testing-table/backend/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2022",
|
||||
"useDefineForClassFields": false,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
}
|
||||
],
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
||||
12
libs/testing-table/backend/tsconfig.lib.json
Normal file
12
libs/testing-table/backend/tsconfig.lib.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../../dist/out-tsc",
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"inlineSources": true,
|
||||
"types": []
|
||||
},
|
||||
"exclude": ["src/**/*.spec.ts", "jest.config.ts", "src/**/*.test.ts"],
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
3
libs/testing-table/model/README.md
Normal file
3
libs/testing-table/model/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# testing-table-model
|
||||
|
||||
This library was generated with [Nx](https://nx.dev).
|
||||
9
libs/testing-table/model/project.json
Normal file
9
libs/testing-table/model/project.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "testing-table-model",
|
||||
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "libs/testing-table/model/src",
|
||||
"prefix": "angular-challenges",
|
||||
"tags": [],
|
||||
"projectType": "library",
|
||||
"targets": {}
|
||||
}
|
||||
0
libs/testing-table/model/src/index.ts
Normal file
0
libs/testing-table/model/src/index.ts
Normal file
26
libs/testing-table/model/tsconfig.json
Normal file
26
libs/testing-table/model/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2022",
|
||||
"useDefineForClassFields": false,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
}
|
||||
],
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
||||
12
libs/testing-table/model/tsconfig.lib.json
Normal file
12
libs/testing-table/model/tsconfig.lib.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../../dist/out-tsc",
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"inlineSources": true,
|
||||
"types": []
|
||||
},
|
||||
"exclude": ["src/**/*.spec.ts", "jest.config.ts", "src/**/*.test.ts"],
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user