From 567980baa45fd7ad4a25d3e34247d7fc9bc50f37 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Fri, 23 Jul 2021 03:08:19 +0300 Subject: [PATCH 1/2] add library for common ui --- angular.json | 28 ++++++++++++++++-- jest.config.js | 2 +- libs/common-ui/.eslintrc.json | 33 ++++++++++++++++++++++ libs/common-ui/README.md | 7 +++++ libs/common-ui/jest.config.js | 20 +++++++++++++ libs/common-ui/src/index.ts | 1 + libs/common-ui/src/lib/common-ui.module.ts | 7 +++++ libs/common-ui/src/test-setup.ts | 1 + libs/common-ui/tsconfig.json | 24 ++++++++++++++++ libs/common-ui/tsconfig.lib.json | 14 +++++++++ libs/common-ui/tsconfig.spec.json | 10 +++++++ nx.json | 3 ++ tsconfig.base.json | 3 +- 13 files changed, 149 insertions(+), 4 deletions(-) create mode 100644 libs/common-ui/.eslintrc.json create mode 100644 libs/common-ui/README.md create mode 100644 libs/common-ui/jest.config.js create mode 100644 libs/common-ui/src/index.ts create mode 100644 libs/common-ui/src/lib/common-ui.module.ts create mode 100644 libs/common-ui/src/test-setup.ts create mode 100644 libs/common-ui/tsconfig.json create mode 100644 libs/common-ui/tsconfig.lib.json create mode 100644 libs/common-ui/tsconfig.spec.json diff --git a/angular.json b/angular.json index f3a7abdae..95d3aa1c3 100644 --- a/angular.json +++ b/angular.json @@ -1,5 +1,4 @@ { - "$schema": "node_modules/@angular/cli/lib/config/schema.json", "version": 1, "cli": { "defaultCollection": "@nrwl/angular", @@ -9,12 +8,15 @@ "defaultProject": "red-ui", "schematics": { "@nrwl/angular:application": { + "linter": "eslint", "unitTestRunner": "jest", "e2eTestRunner": "cypress" }, "@nrwl/angular:library": { + "linter": "eslint", "unitTestRunner": "jest" - } + }, + "@nrwl/angular:component": {} }, "projects": { "red-ui": { @@ -186,6 +188,28 @@ "style": "scss" } } + }, + "common-ui": { + "projectType": "library", + "root": "libs/common-ui", + "sourceRoot": "libs/common-ui/src", + "prefix": "redaction", + "architect": { + "test": { + "builder": "@nrwl/jest:jest", + "outputs": ["coverage/libs/common-ui"], + "options": { + "jestConfig": "libs/common-ui/jest.config.js", + "passWithNoTests": true + } + }, + "lint": { + "builder": "@nrwl/linter:eslint", + "options": { + "lintFilePatterns": ["libs/common-ui/src/**/*.ts", "libs/common-ui/src/**/*.html"] + } + } + } } } } diff --git a/jest.config.js b/jest.config.js index 1dda619f6..9659a89a6 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,3 +1,3 @@ module.exports = { - projects: ['/apps/red-ui', '/libs/red-ui-http', '/libs/red-cache'] + projects: ['/apps/red-ui', '/libs/red-ui-http', '/libs/red-cache', '/libs/common-ui'] }; diff --git a/libs/common-ui/.eslintrc.json b/libs/common-ui/.eslintrc.json new file mode 100644 index 000000000..ae74dc230 --- /dev/null +++ b/libs/common-ui/.eslintrc.json @@ -0,0 +1,33 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "extends": ["plugin:@nrwl/nx/angular", "plugin:@angular-eslint/template/process-inline-templates"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "redaction", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "redaction", + "style": "kebab-case" + } + ] + } + }, + { + "files": ["*.html"], + "extends": ["plugin:@nrwl/nx/angular-template"], + "rules": {} + } + ] +} diff --git a/libs/common-ui/README.md b/libs/common-ui/README.md new file mode 100644 index 000000000..f2a6bbc60 --- /dev/null +++ b/libs/common-ui/README.md @@ -0,0 +1,7 @@ +# common-ui + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test common-ui` to execute the unit tests. diff --git a/libs/common-ui/jest.config.js b/libs/common-ui/jest.config.js new file mode 100644 index 000000000..f06ef5fa7 --- /dev/null +++ b/libs/common-ui/jest.config.js @@ -0,0 +1,20 @@ +module.exports = { + displayName: 'common-ui', + preset: '../../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + astTransformers: { + before: ['jest-preset-angular/build/InlineFilesTransformer', 'jest-preset-angular/build/StripStylesTransformer'] + } + } + }, + coverageDirectory: '../../coverage/libs/common-ui', + snapshotSerializers: [ + 'jest-preset-angular/build/serializers/no-ng-attributes', + 'jest-preset-angular/build/serializers/ng-snapshot', + 'jest-preset-angular/build/serializers/html-comment' + ] +}; diff --git a/libs/common-ui/src/index.ts b/libs/common-ui/src/index.ts new file mode 100644 index 000000000..3b5ad4f19 --- /dev/null +++ b/libs/common-ui/src/index.ts @@ -0,0 +1 @@ +export * from './lib/common-ui.module'; diff --git a/libs/common-ui/src/lib/common-ui.module.ts b/libs/common-ui/src/lib/common-ui.module.ts new file mode 100644 index 000000000..e4e641375 --- /dev/null +++ b/libs/common-ui/src/lib/common-ui.module.ts @@ -0,0 +1,7 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +@NgModule({ + imports: [CommonModule] +}) +export class CommonUiModule {} diff --git a/libs/common-ui/src/test-setup.ts b/libs/common-ui/src/test-setup.ts new file mode 100644 index 000000000..1100b3e8a --- /dev/null +++ b/libs/common-ui/src/test-setup.ts @@ -0,0 +1 @@ +import 'jest-preset-angular/setup-jest'; diff --git a/libs/common-ui/tsconfig.json b/libs/common-ui/tsconfig.json new file mode 100644 index 000000000..d7a0c7629 --- /dev/null +++ b/libs/common-ui/tsconfig.json @@ -0,0 +1,24 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ], + "compilerOptions": { + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "angularCompilerOptions": { + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true + } +} diff --git a/libs/common-ui/tsconfig.lib.json b/libs/common-ui/tsconfig.lib.json new file mode 100644 index 000000000..bbcc12b1c --- /dev/null +++ b/libs/common-ui/tsconfig.lib.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "target": "es2015", + "declaration": true, + "declarationMap": true, + "inlineSources": true, + "types": [], + "lib": ["dom", "es2018"] + }, + "exclude": ["src/test-setup.ts", "**/*.spec.ts"], + "include": ["**/*.ts"] +} diff --git a/libs/common-ui/tsconfig.spec.json b/libs/common-ui/tsconfig.spec.json new file mode 100644 index 000000000..cfff29a54 --- /dev/null +++ b/libs/common-ui/tsconfig.spec.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "files": ["src/test-setup.ts"], + "include": ["**/*.spec.ts", "**/*.d.ts"] +} diff --git a/nx.json b/nx.json index 8b9c0489f..0d03d6b85 100644 --- a/nx.json +++ b/nx.json @@ -30,6 +30,9 @@ }, "red-cache": { "tags": [] + }, + "common-ui": { + "tags": [] } } } diff --git a/tsconfig.base.json b/tsconfig.base.json index e033abefc..3218e8111 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -29,7 +29,8 @@ "@environments/*": ["apps/red-ui/src/environments/*"], "@shared/*": ["apps/red-ui/src/app/modules/shared/*"], "@app-config/*": ["apps/red-ui/src/app/modules/app-config/*"], - "@upload-download/*": ["apps/red-ui/src/app/modules/upload-download/*"] + "@upload-download/*": ["apps/red-ui/src/app/modules/upload-download/*"], + "@devplant/common-ui": ["libs/common-ui/src/index.ts"] } }, "exclude": ["node_modules", "tmp"], From 5f8f11108f9130ebec1f7de617b81275fcf7091d Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Fri, 23 Jul 2021 03:09:30 +0300 Subject: [PATCH 2/2] working entire platform search --- apps/red-ui/src/app/app.component.html | 4 +- apps/red-ui/src/app/app.module.ts | 11 +- .../base-screen/base-screen.component.html | 70 ++------ .../base-screen/base-screen.component.ts | 53 +++++- .../spotlight-search-action.ts | 6 + .../spotlight-search-dialog-data.ts | 6 + .../spotlight-search.component.html | 43 +++++ .../spotlight-search.component.scss | 51 ++++++ .../spotlight-search.component.ts | 68 ++++++++ .../src/app/modules/auth/red-role.guard.ts | 59 ++++--- .../file-actions/file-actions.component.scss | 4 - .../scroll-button.component.html | 12 +- .../scroll-button/scroll-button.component.ts | 24 +-- .../dossier/dossiers-routing.module.ts | 24 ++- .../app/modules/dossier/dossiers.module.ts | 3 +- .../search-screen.component.html | 98 +++++++++++ .../search-screen.component.scss | 38 +++++ .../search-screen/search-screen.component.ts | 155 ++++++++++++++++++ .../src/app/modules/icons/icons.module.ts | 6 +- .../shared/base/base-listing.component.ts | 2 +- .../input-with-action.component.html | 12 +- .../input-with-action.component.ts | 2 +- .../page-header/page-header.component.html | 3 +- .../page-header/page-header.component.ts | 9 +- .../shared/directives/sync-width.directive.ts | 4 +- .../shared/services/screen-state.service.ts | 2 +- .../modules/shared/services/search.service.ts | 16 +- .../src/app/services/loading.service.ts | 2 +- .../app/services/router-history.service.ts | 2 +- .../red-ui/src/app/state/app-state.service.ts | 11 +- apps/red-ui/src/assets/i18n/en.json | 19 +++ .../red-ui/src/assets/icons/general/enter.svg | 15 ++ .../src/assets/styles/red-page-layout.scss | 8 + libs/red-ui-http/src/lib/model/models.ts | 1 + 34 files changed, 688 insertions(+), 155 deletions(-) create mode 100644 apps/red-ui/src/app/components/spotlight-search/spotlight-search-action.ts create mode 100644 apps/red-ui/src/app/components/spotlight-search/spotlight-search-dialog-data.ts create mode 100644 apps/red-ui/src/app/components/spotlight-search/spotlight-search.component.html create mode 100644 apps/red-ui/src/app/components/spotlight-search/spotlight-search.component.scss create mode 100644 apps/red-ui/src/app/components/spotlight-search/spotlight-search.component.ts create mode 100644 apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.html create mode 100644 apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.scss create mode 100644 apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts create mode 100644 apps/red-ui/src/assets/icons/general/enter.svg diff --git a/apps/red-ui/src/app/app.component.html b/apps/red-ui/src/app/app.component.html index 3ac47a12a..dbdf8372d 100644 --- a/apps/red-ui/src/app/app.component.html +++ b/apps/red-ui/src/app/app.component.html @@ -1,4 +1,2 @@ - + diff --git a/apps/red-ui/src/app/app.module.ts b/apps/red-ui/src/app/app.module.ts index e6788e007..b61e28269 100644 --- a/apps/red-ui/src/app/app.module.ts +++ b/apps/red-ui/src/app/app.module.ts @@ -32,6 +32,7 @@ import { GlobalErrorHandler } from '@utils/global-error-handler.service'; import { REDMissingTranslationHandler } from '@utils/missing-translations-handler'; import { configurationInitializer } from '@app-config/configuration.initializer'; import { AppConfigService } from '@app-config/app-config.service'; +import { SpotlightSearchComponent } from '@components/spotlight-search/spotlight-search.component'; export function httpLoaderFactory(httpClient: HttpClient) { return new TranslateHttpLoader(httpClient, '/assets/i18n/', '.json'); @@ -49,7 +50,15 @@ function cleanupBaseUrl(baseUrl: string) { const screens = [BaseScreenComponent, DownloadsListScreenComponent, UserProfileScreenComponent]; -const components = [AppComponent, LogoComponent, AuthErrorComponent, ToastComponent, NotificationsComponent, ...screens]; +const components = [ + AppComponent, + LogoComponent, + AuthErrorComponent, + ToastComponent, + NotificationsComponent, + SpotlightSearchComponent, + ...screens +]; @NgModule({ declarations: [...components], diff --git a/apps/red-ui/src/app/components/base-screen/base-screen.component.html b/apps/red-ui/src/app/components/base-screen/base-screen.component.html index a4e3893fd..8a5dbedc2 100644 --- a/apps/red-ui/src/app/components/base-screen/base-screen.component.html +++ b/apps/red-ui/src/app/components/base-screen/base-screen.component.html @@ -6,11 +6,7 @@ - + - diff --git a/apps/red-ui/src/app/modules/shared/components/input-with-action/input-with-action.component.ts b/apps/red-ui/src/app/modules/shared/components/input-with-action/input-with-action.component.ts index 10e87ca2b..cc00278b3 100644 --- a/apps/red-ui/src/app/modules/shared/components/input-with-action/input-with-action.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/input-with-action/input-with-action.component.ts @@ -29,7 +29,7 @@ export class InputWithActionComponent { } clearContent() { - this.form.patchValue({ query: '' }); + this.form.patchValue({ query: '' }, { emitEvent: true }); } executeAction($event?: MouseEvent) { diff --git a/apps/red-ui/src/app/modules/shared/components/page-header/page-header.component.html b/apps/red-ui/src/app/modules/shared/components/page-header/page-header.component.html index 1c9ef9031..7f6fa8bb4 100644 --- a/apps/red-ui/src/app/modules/shared/components/page-header/page-header.component.html +++ b/apps/red-ui/src/app/modules/shared/components/page-header/page-header.component.html @@ -1,7 +1,7 @@