From 83321ae3526763f80e9a070a6ee842557824d5a4 Mon Sep 17 00:00:00 2001 From: chuanlin2018 Date: Wed, 6 Mar 2024 12:21:03 -0500 Subject: [PATCH] Upgraded to Angular16 --- angular/angular.json | 276 +++++++++--------- angular/jest.config.js | 8 + angular/package.json | 150 +++++----- angular/setup-jest.ts | 1 + angular/src/app/app.module.ts | 2 +- .../can-deactivate/can-deactivate.guard.ts | 6 +- angular/src/app/operators.js | 4 +- .../search-panel/search-panel.component.ts | 1 + .../src/app/search/search.component.spec.ts | 2 - angular/src/app/search/search.component.ts | 2 +- angular/src/app/search/search.module.ts | 2 - .../combobox/combo-box.component.spec.ts | 40 +-- .../config-service/config.service.spec.ts | 26 +- .../app/shared/name-list/name-list.service.ts | 3 +- .../search-query/search-query.service.ts | 4 +- .../searchfields-list.service.ts | 4 +- .../taxonomy-list/taxonomy-list.service.ts | 4 +- angular/src/karma.conf.js | 65 ----- angular/src/styles.css | 2 - angular/src/test.ts | 22 -- angular/src/tsconfig.spec.json | 18 -- angular/tsconfig.json | 9 +- angular/tsconfig.spec.json | 17 ++ 23 files changed, 282 insertions(+), 386 deletions(-) create mode 100644 angular/jest.config.js create mode 100644 angular/setup-jest.ts delete mode 100644 angular/src/karma.conf.js delete mode 100644 angular/src/test.ts delete mode 100644 angular/src/tsconfig.spec.json create mode 100644 angular/tsconfig.spec.json diff --git a/angular/angular.json b/angular/angular.json index 62bbdaeef..21bd7f44a 100644 --- a/angular/angular.json +++ b/angular/angular.json @@ -1,153 +1,137 @@ { - "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "version": 1, - "newProjectRoot": "projects", - "projects": { - "angular": { - "root": "", - "sourceRoot": "src", - "projectType": "application", - "prefix": "app", - "schematics": {}, - "architect": { - "build": { - "builder": "@angular-devkit/build-angular:browser", - "options": { - "outputPath": "dist/angular", - "index": "src/index.html", - "main": "src/main.ts", - "polyfills": "src/polyfills.ts", - "tsConfig": "src/tsconfig.app.json", - - "assets": [ - "src/favicon.ico", - "src/assets" - ], - "styles": [ - "node_modules/primeng/resources/themes/saga-blue/theme.css", - "src/styles/font-awesome/css/font-awesome.min.css", - "node_modules/primeng/resources/primeng.css", - "node_modules/primeicons/primeicons.css", - "node_modules/primeflex/primeflex.css", - "node_modules/bootstrap/dist/css/bootstrap.min.css", - "src/styles/main.css", - "src/styles/styles.layout.css", - "src/assets/fontcss/roboto.css", - "src/styles.css" - ], - "scripts": [ - "node_modules/primeui/primeui-ng-all.min.js" - ], - "vendorChunk": true, - "extractLicenses": false, - "buildOptimizer": false, - "sourceMap": true, - "optimization": false, - "namedChunks": true - }, - "configurations": { - "production": { - "budgets": [ - { - "type": "anyComponentStyle", - "maximumWarning": "6kb" + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "angular": { + "root": "", + "sourceRoot": "src", + "projectType": "application", + "prefix": "app", + "schematics": {}, + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/angular", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "src/tsconfig.app.json", + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "node_modules/primeng/resources/themes/saga-blue/theme.css", + "src/styles/font-awesome/css/font-awesome.min.css", + "node_modules/primeng/resources/primeng.css", + "node_modules/primeicons/primeicons.css", + "node_modules/primeflex/primeflex.css", + "node_modules/bootstrap/dist/css/bootstrap.min.css", + "src/styles/main.css", + "src/styles/styles.layout.css", + "src/assets/fontcss/roboto.css", + "src/styles.css" + ], + "scripts": [ + "node_modules/primeui/primeui-ng-all.min.js" + ], + "vendorChunk": true, + "extractLicenses": false, + "buildOptimizer": false, + "sourceMap": true, + "optimization": false, + "namedChunks": true + }, + "configurations": { + "production": { + "budgets": [ + { + "type": "anyComponentStyle", + "maximumWarning": "6kb" + } + ], + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "namedChunks": false, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true + }, + "mock": { + "budgets": [ + { + "type": "anyComponentStyle", + "maximumWarning": "6kb" + } + ], + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.mock.ts" + } + ] + } + }, + "defaultConfiguration": "" + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "angular:build" + }, + "configurations": { + "production": { + "browserTarget": "angular:build:production" + }, + "mock": { + "browserTarget": "angular:build:mock" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "angular:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:jest", + "options": { + "polyfills": [ + "zone.js", + "zone.js/testing" + ], + "tsConfig": "tsconfig.spec.json" + } } - ], - "fileReplacements": [ - { - "replace": "src/environments/environment.ts", - "with": "src/environments/environment.prod.ts" - } - ], - "optimization": true, - "outputHashing": "all", - "sourceMap": false, - "namedChunks": false, - "extractLicenses": true, - "vendorChunk": false, - "buildOptimizer": true - }, - "mock": { - "budgets": [ - { - "type": "anyComponentStyle", - "maximumWarning": "6kb" - } - ], - "fileReplacements": [ - { - "replace": "src/environments/environment.ts", - "with": "src/environments/environment.mock.ts" - } - ] - } - }, - "defaultConfiguration": "" - }, - "serve": { - "builder": "@angular-devkit/build-angular:dev-server", - "options": { - "browserTarget": "angular:build" - }, - "configurations": { - "production": { - "browserTarget": "angular:build:production" - }, - "mock": { - "browserTarget": "angular:build:mock" } - } - }, - "extract-i18n": { - "builder": "@angular-devkit/build-angular:extract-i18n", - "options": { - "browserTarget": "angular:build" - } }, - "test": { - "builder": "@angular-devkit/build-angular:karma", - "options": { - "main": "src/test.ts", - "polyfills": "src/polyfills.ts", - "tsConfig": "src/tsconfig.spec.json", - "karmaConfig": "src/karma.conf.js", - "styles": [ - "src/styles.css", - "node_modules/bootstrap/dist/css/bootstrap.min.css", - "node_modules/primeng/resources/primeng.min.css", - "node_modules/primeicons/primeicons.css", - "src/styles/font-awesome/css/font-awesome.min.css", - "src/styles/main.css" - ], - "scripts": [ - "node_modules/lodash/lodash.min.js", - "node_modules/primeui/primeui-ng-all.min.js" - ], - "assets": [ - "src/favicon.ico", - "src/assets" - ] - } - } - } - }, - "angular-e2e": { - "root": "e2e/", - "projectType": "application", - "architect": { - "e2e": { - "builder": "@angular-devkit/build-angular:protractor", - "options": { - "protractorConfig": "e2e/protractor.conf.js", - "devServerTarget": "angular:serve:mock" - }, - "configurations": { - "production": { - "devServerTarget": "angular:serve:mock" + "angular-e2e": { + "root": "e2e/", + "projectType": "application", + "architect": { + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "e2e/protractor.conf.js", + "devServerTarget": "angular:serve:mock" + }, + "configurations": { + "production": { + "devServerTarget": "angular:serve:mock" + } + } + } } - } } - } } - } -} +} \ No newline at end of file diff --git a/angular/jest.config.js b/angular/jest.config.js new file mode 100644 index 000000000..f32a691be --- /dev/null +++ b/angular/jest.config.js @@ -0,0 +1,8 @@ +module.exports = { + preset: 'jest-preset-angular', + setupFilesAfterEnv: ['./setup-jest.ts'], + moduleNameMapper: { + "^lodash-es$": "lodash" + }, + globalSetup: 'jest-preset-angular/global-setup' +}; diff --git a/angular/package.json b/angular/package.json index 3f4ddacea..1f4350f69 100644 --- a/angular/package.json +++ b/angular/package.json @@ -1,79 +1,73 @@ { - "name": "angular", - "version": "0.0.0", - "scripts": { - "ng": "ng", - "start": "ng serve --port 5555", - "build": "ng build --configuration production --aot --vendor-chunk --common-chunk --delete-output-path --build-optimizer", - "test": "ng test", - "lint": "ng lint", - "e2e": "ng e2e", - "webdriver": "webdriver-manager update" - }, - "private": true, - "dependencies": { - "@angular-devkit/schematics": "^14.2.13", - "@angular/animations": "14.3.0", - "@angular/cdk": "^12.0.0", - "@angular/common": "14.3.0", - "@angular/compiler": "14.3.0", - "@angular/core": "14.3.0", - "@angular/forms": "14.3.0", - "@angular/localize": "14.3.0", - "@angular/platform-browser": "14.3.0", - "@angular/platform-browser-dynamic": "14.3.0", - "@angular/router": "14.3.0", - "@fullcalendar/core": "^5.10.1", - "@ng-bootstrap/ng-bootstrap": "^11.0.0", - "ajv": "^6.12.6", - "bootstrap": "^4.0.0", - "chart.js": "^3.6.2", - "core-js": "^2.5.4", - "font-awesome": "^4.7.0", - "jasmine": "^2.8.0", - "lodash-es": "^4.17.21", - "ngx-pagination": "^3.2.1", - "ngx-toastr": "^12.0.0", - "popper.js": "^1.14.7", - "primeflex": "^3.1.2", - "primeicons": "^5.0.0", - "primeng": "^13.0.0", - "primeui": "^4.1.15", - "quill": "^1.3.7", - "rxjs": "6.6.7", - "rxjs-compat": "6.3.3", - "tslib": "^1.10.0", - "yargs-parser": "^21.0.0", - "zone.js": "~0.11.4" - }, - "devDependencies": { - "@angular-devkit/build-angular": "^14.2.13", - "@angular-eslint/builder": "13.5.0", - "@angular-eslint/eslint-plugin": "13.5.0", - "@angular-eslint/eslint-plugin-template": "13.5.0", - "@angular-eslint/schematics": "13.5.0", - "@angular-eslint/template-parser": "13.5.0", - "@angular/cli": "14.2.13", - "@angular/compiler-cli": "14.3.0", - "@angular/language-service": "14.3.0", - "@types/jasmine": "~3.6.0", - "@types/jasminewd2": "~2.0.3", - "@types/node": "^12.11.1", - "@typescript-eslint/eslint-plugin": "5.27.1", - "@typescript-eslint/parser": "5.27.1", - "eslint": "^8.17.0", - "jasmine-core": "~3.8.0", - "jasmine-spec-reporter": "~5.0.0", - "karma": "~6.3.16", - "karma-chrome-launcher": "~3.1.0", - "karma-coverage-istanbul-reporter": "~3.0.2", - "karma-jasmine": "~4.0.0", - "karma-jasmine-html-reporter": "^1.6.0", - "ts-node": "~7.0.0", - "tslint": "^6.1.3", - "typescript": "~4.8.4" - }, - "browser": { - "process": false - } -} \ No newline at end of file + "name": "angular", + "version": "0.0.0", + "scripts": { + "ng": "ng", + "start": "ng serve --port 5555", + "build": "ng build --configuration production --aot --vendor-chunk --common-chunk --delete-output-path --build-optimizer", + "test": "jest --config ./jest.config.js --silent", + "lint": "ng lint", + "e2e": "ng e2e", + "webdriver": "webdriver-manager update" + }, + "private": true, + "dependencies": { + "@angular-devkit/schematics": "^16.2.12", + "@angular/animations": "16.2.12", + "@angular/cdk": "^16.2.0", + "@angular/common": "16.2.12", + "@angular/compiler": "16.2.12", + "@angular/core": "16.2.12", + "@angular/forms": "16.2.12", + "@angular/localize": "16.2.12", + "@angular/platform-browser": "16.2.12", + "@angular/platform-browser-dynamic": "16.2.12", + "@angular/router": "16.2.12", + "@fullcalendar/core": "^5.10.1", + "@ng-bootstrap/ng-bootstrap": "^15.0.0", + "@popperjs/core": "2.11.8", + "ajv": "^6.12.6", + "bootstrap": "^5.1.3", + "chart.js": "^3.6.2", + "core-js": "^2.5.4", + "cross-fetch": "^4.0.0", + "font-awesome": "^4.7.0", + "lodash-es": "^4.17.21", + "ngx-toastr": "^17.0.0", + "primeflex": "^3.3.0", + "primeicons": "^5.0.0", + "primeng": "^16.4.3", + "primeui": "^4.1.15", + "quill": "^1.3.7", + "rxjs": "~7.8.1", + "tslib": "^2.3.0", + "yargs-parser": "^21.0.0", + "zone.js": "~0.13.3" + }, + "devDependencies": { + "@angular-devkit/build-angular": "^16.2.12", + "@angular-eslint/builder": "15.2.0", + "@angular-eslint/eslint-plugin": "15.2.0", + "@angular-eslint/eslint-plugin-template": "15.2.0", + "@angular-eslint/schematics": "16.1.0", + "@angular-eslint/template-parser": "15.2.0", + "@angular/cli": "16.2.12", + "@angular/compiler-cli": "16.2.12", + "@angular/language-service": "16.2.12", + "@types/jest": "^29.5.12", + "@types/node": "^12.11.5", + "@typescript-eslint/eslint-plugin": "5.54.0", + "@typescript-eslint/parser": "5.54.0", + "eslint": "^8.35.0", + "jest": "^29.5.0", + "jest-environment-jsdom": "^29.5.0", + "jest-preset-angular": "^13.1.6", + "ts-jest": "^29.1.2", + "ts-node": "~7.0.0", + "tslint": "^6.1.3", + "typescript": "~4.9.5" + }, + "browser": { + "process": false + } +} diff --git a/angular/setup-jest.ts b/angular/setup-jest.ts new file mode 100644 index 000000000..5553a4a6c --- /dev/null +++ b/angular/setup-jest.ts @@ -0,0 +1 @@ +import 'jest-preset-angular/setup-jest'; \ No newline at end of file diff --git a/angular/src/app/app.module.ts b/angular/src/app/app.module.ts index efe26cf88..91e551dcc 100644 --- a/angular/src/app/app.module.ts +++ b/angular/src/app/app.module.ts @@ -63,7 +63,7 @@ enableProdMode(); HeadbarComponent ], imports: [ - RouterModule.forRoot(routes ,{ useHash: true, relativeLinkResolution: 'corrected' }), + RouterModule.forRoot(routes ,{ useHash: true }), BrowserModule, HttpClientModule, TreeModule, diff --git a/angular/src/app/can-deactivate/can-deactivate.guard.ts b/angular/src/app/can-deactivate/can-deactivate.guard.ts index 5d3037d22..8bbeba4d6 100644 --- a/angular/src/app/can-deactivate/can-deactivate.guard.ts +++ b/angular/src/app/can-deactivate/can-deactivate.guard.ts @@ -1,10 +1,10 @@ import { Injectable } from '@angular/core'; -import { CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; -import { Observable } from 'rxjs/Observable'; +import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; +import { Observable } from 'rxjs'; import {ComponentCanDeactivate} from './component-can-deactivate'; @Injectable() -export class CanDeactivateGuard implements CanDeactivate { +export class CanDeactivateGuard { canDeactivate(component: ComponentCanDeactivate): boolean { if(!component.canDeactivate()){ diff --git a/angular/src/app/operators.js b/angular/src/app/operators.js index c30c6903a..b06312cf2 100644 --- a/angular/src/app/operators.js +++ b/angular/src/app/operators.js @@ -1,4 +1,4 @@ "use strict"; -require("rxjs/add/operator/map"); -require("rxjs/add/operator/catch"); +// require("rxjs/add/operator/map"); +// require("rxjs/add/operator/catch"); //# sourceMappingURL=operators.js.map \ No newline at end of file diff --git a/angular/src/app/search-panel/search-panel.component.ts b/angular/src/app/search-panel/search-panel.component.ts index 8089dd61f..7944e2d53 100644 --- a/angular/src/app/search-panel/search-panel.component.ts +++ b/angular/src/app/search-panel/search-panel.component.ts @@ -16,6 +16,7 @@ import { Observable } from 'rxjs'; import { SDPQuery, QueryRow, CurrentQueryInfo } from '../shared/search-query/query'; import { ReadVarExpr } from '@angular/compiler'; import { find } from './autocomplete'; +import fetch from 'cross-fetch'; @Component({ selector: 'app-search-panel', diff --git a/angular/src/app/search/search.component.spec.ts b/angular/src/app/search/search.component.spec.ts index 34aacaa73..3f433e634 100644 --- a/angular/src/app/search/search.component.spec.ts +++ b/angular/src/app/search/search.component.spec.ts @@ -3,7 +3,6 @@ import { NO_ERRORS_SCHEMA } from '@angular/core'; import { SearchComponent } from './search.component'; import { RouterTestingModule } from '@angular/router/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { NgxPaginationModule } from 'ngx-pagination'; import { MockModule } from '../mock.module'; import { GoogleAnalyticsService } from "../shared/ga-service/google-analytics.service"; import { GoogleAnalyticsServiceMock } from "../shared/ga-service/google-analytics.service.mock"; @@ -19,7 +18,6 @@ describe('SearchComponent', () => { imports: [ RouterTestingModule, HttpClientTestingModule, - NgxPaginationModule, MockModule, BrowserAnimationsModule, ToastrModule.forRoot() diff --git a/angular/src/app/search/search.component.ts b/angular/src/app/search/search.component.ts index 8386e7460..a25a94248 100644 --- a/angular/src/app/search/search.component.ts +++ b/angular/src/app/search/search.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, OnDestroy, ElementRef, NgZone, ViewChild, HostListener } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { Subscription } from 'rxjs/Subscription'; +import { Subscription } from 'rxjs'; import * as _ from 'lodash-es'; import { SearchQueryService } from '../shared/search-query/search-query.service'; import { trigger, state, style, animate, transition } from '@angular/animations'; diff --git a/angular/src/app/search/search.module.ts b/angular/src/app/search/search.module.ts index 0ee239ab7..424d36497 100644 --- a/angular/src/app/search/search.module.ts +++ b/angular/src/app/search/search.module.ts @@ -8,7 +8,6 @@ import { HttpClientModule } from '@angular/common/http'; import { TaxonomyListService } from '../shared/taxonomy-list/index'; import { SearchfieldsListService } from '../shared/searchfields-list/index'; import { SearchQueryService } from '../shared/search-query/index'; -import {NgxPaginationModule} from 'ngx-pagination'; // <-- import the module import { DropdownModule } from 'primeng/dropdown'; import { AccordionModule } from 'primeng/accordion'; import { TreeModule } from 'primeng/tree'; @@ -48,7 +47,6 @@ import { PaginationComponent } from './pagination/pagination.component'; CheckboxModule, TooltipModule, ProgressSpinnerModule, - NgxPaginationModule, InputTextareaModule, SearchPanelModule], declarations: [SearchComponent,ReadMoreComponent, FiltersComponent, ResultsComponent, PaginationComponent], diff --git a/angular/src/app/shared/combobox/combo-box.component.spec.ts b/angular/src/app/shared/combobox/combo-box.component.spec.ts index a4dd5d0aa..19c08a7f4 100644 --- a/angular/src/app/shared/combobox/combo-box.component.spec.ts +++ b/angular/src/app/shared/combobox/combo-box.component.spec.ts @@ -1,25 +1,25 @@ -// import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -// import { ComboBoxComponent } from './combo-box.component'; +import { ComboBoxComponent } from './combo-box.component'; -// describe('ComboBoxComponent', () => { -// let component: ComboBoxComponent; -// let fixture: ComponentFixture; +describe('ComboBoxComponent', () => { + let component: ComboBoxComponent; + let fixture: ComponentFixture; -// beforeEach(async(() => { -// TestBed.configureTestingModule({ -// declarations: [ ComboBoxComponent ] -// }) -// .compileComponents(); -// })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ComboBoxComponent ] + }) + .compileComponents(); + })); -// beforeEach(() => { -// fixture = TestBed.createComponent(ComboBoxComponent); -// component = fixture.componentInstance; -// fixture.detectChanges(); -// }); + beforeEach(() => { + fixture = TestBed.createComponent(ComboBoxComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); -// it('should create', () => { -// expect(component).toBeTruthy(); -// }); -// }); + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/angular/src/app/shared/config-service/config.service.spec.ts b/angular/src/app/shared/config-service/config.service.spec.ts index 034b63366..cf03b982c 100644 --- a/angular/src/app/shared/config-service/config.service.spec.ts +++ b/angular/src/app/shared/config-service/config.service.spec.ts @@ -9,7 +9,7 @@ import * as rxjs from 'rxjs'; describe('AppConfig', () => { beforeEach(() => TestBed.configureTestingModule({ - imports: [ HttpClientModule ], + imports: [ HttpClientTestingModule ], providers: [ HttpClient ] })); @@ -25,17 +25,17 @@ describe('AppConfig', () => { expect(conf.APPVERSION).toEqual("debug"); }); - it('getConfig: returns default config by default', (done) => { + it('getConfig: returns default config by default', async () => { let service: AppConfig = TestBed.get(AppConfig); expect(service).toBeTruthy(); let defdata: Config = service.getDefaultConfig(); - service.getConfig().subscribe((data) => { expect(data).toEqual(defdata); done(); }, - (err) => { fail(err); done(); }); - }); + service.getConfig().subscribe((data) => { expect(data).toEqual(defdata); }, + (err) => { fail(err); }); + }, 1000); - it('getRemoteConfig', (done) => { + it('getRemoteConfig', async () => { let service: AppConfig = TestBed.get(AppConfig); expect(service).toBeTruthy(); @@ -46,13 +46,14 @@ describe('AppConfig', () => { expect(conf["SDPAPI"]).toEqual("http://localhost:5555/"); expect(conf.GACODE).toEqual("not-set"); expect(conf.APPVERSION).toEqual("1.3.0"); - done(); }, - (err) => { fail(err); done();} + (err) => { + fail(err); + } ); - }); + }, 1000); - it('loadRemoteConfig', (done) => { + it('loadRemoteConfig', async () => { let service: AppConfig = TestBed.get(AppConfig); expect(service).toBeTruthy(); @@ -64,9 +65,8 @@ describe('AppConfig', () => { expect(conf["SDPAPI"]).toEqual("http://localhost:5555/"); expect(conf.GACODE).toEqual("not-set"); expect(conf.APPVERSION).toEqual("1.3.0"); - done(); }, - (err) => { fail(err); done(); } + (err) => { fail(err); } ); - }); + }, 1000); }); diff --git a/angular/src/app/shared/name-list/name-list.service.ts b/angular/src/app/shared/name-list/name-list.service.ts index d89e1fa8d..4ed20b2ff 100644 --- a/angular/src/app/shared/name-list/name-list.service.ts +++ b/angular/src/app/shared/name-list/name-list.service.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; +import { throwError } from 'rxjs'; // import 'rxjs/add/operator/do'; // for debugging /** @@ -35,6 +36,6 @@ export class NameListService { let errMsg = (error.message) ? error.message : error.status ? `${error.status} - ${error.statusText}` : 'Server error'; console.error(errMsg); // log to console instead - return Observable.throw(errMsg); + return throwError(() => errMsg); } } diff --git a/angular/src/app/shared/search-query/search-query.service.ts b/angular/src/app/shared/search-query/search-query.service.ts index e37eba749..293060b95 100644 --- a/angular/src/app/shared/search-query/search-query.service.ts +++ b/angular/src/app/shared/search-query/search-query.service.ts @@ -1,12 +1,10 @@ import {Injectable} from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import { Subject} from 'rxjs/Subject'; +import { Subject, Observable} from 'rxjs'; import {BehaviorSubject } from 'rxjs'; -import {Observable } from 'rxjs'; import * as _ from 'lodash-es'; import { SelectItem, TreeNode } from 'primeng/api'; -import 'rxjs/add/operator/toPromise'; import { SDPQuery, QueryRow, CurrentQueryInfo } from './query'; import { SearchfieldsListService } from '../../shared/searchfields-list/index'; import { NotificationService } from '../../shared/notification-service/notification.service'; diff --git a/angular/src/app/shared/searchfields-list/searchfields-list.service.ts b/angular/src/app/shared/searchfields-list/searchfields-list.service.ts index 361c68a5a..5bea7ed3e 100644 --- a/angular/src/app/shared/searchfields-list/searchfields-list.service.ts +++ b/angular/src/app/shared/searchfields-list/searchfields-list.service.ts @@ -36,7 +36,7 @@ export class SearchfieldsListService { }), rxjsop.catchError((err) => { console.error("Failed to download fields: " + JSON.stringify(err)); - return throwError(err); + return throwError(() => err); }) ); } @@ -50,7 +50,7 @@ export class SearchfieldsListService { let errMsg = (error.message) ? error.message : error.status ? `${error.status} - ${error.statusText}` : 'Server error'; console.error(errMsg); // log to console instead - return Observable.throw(errMsg); + return throwError(() => errMsg); } /** diff --git a/angular/src/app/shared/taxonomy-list/taxonomy-list.service.ts b/angular/src/app/shared/taxonomy-list/taxonomy-list.service.ts index 8ef161eea..d955a491c 100644 --- a/angular/src/app/shared/taxonomy-list/taxonomy-list.service.ts +++ b/angular/src/app/shared/taxonomy-list/taxonomy-list.service.ts @@ -32,7 +32,7 @@ export class TaxonomyListService { }), rxjsop.catchError((err) => { console.error("Failed to download taxonomy: " + JSON.stringify(err)); - return throwError(err); + return throwError(() => err); }) ); } @@ -46,7 +46,7 @@ export class TaxonomyListService { let errMsg = (error.message) ? error.message : error.status ? `${error.status} - ${error.statusText}` : 'Server error'; console.error(errMsg); // log to console instead - return Observable.throw(errMsg); + return throwError(() => errMsg); } } diff --git a/angular/src/karma.conf.js b/angular/src/karma.conf.js deleted file mode 100644 index 25f6e487e..000000000 --- a/angular/src/karma.conf.js +++ /dev/null @@ -1,65 +0,0 @@ -// Karma configuration file, see link for more information -// https://karma-runner.github.io/1.0/config/configuration-file.html -const path = require('path'); - -module.exports = function (config) { - config.set({ - basePath: '', - frameworks: ['jasmine', '@angular-devkit/build-angular'], - files: [ - { pattern: path.resolve("src/assets") + "/*.json", watched: true, - included: false, nocache: false, served: true } - ], - proxies: { '/assets/': '/base/assets/' }, - plugins: [ - require('karma-jasmine'), - require('karma-chrome-launcher'), - // require( 'karma-phantomjs-launcher' ), - require('karma-jasmine-html-reporter'), - require('karma-coverage-istanbul-reporter'), - require('@angular-devkit/build-angular/plugins/karma') - ], - client: { - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, - coverageIstanbulReporter: { - dir: require('path').join(__dirname, '../coverage'), - reports: ['html', 'lcovonly'], - fixWebpackSourcePaths: true - }, - // customLaunchers: { - // myChromeHeadless: { - // base: 'ChromeHeadless', - // flags: [ - // '--headless', - // '--disable-gpu', - // // Without a remote debugging port, Google Chrome exits immediately. - // '--remote-debugging-port=9222', - // '--disable-web-security' - // ], - // } - // }, - browsers: ['HeadlessChrome'], - customLaunchers: { - HeadlessChrome: { - base: 'ChromeHeadless', - flags: [ - // '--headless', - '--disable-gpu', - // Without a remote debugging port, Google Chrome exits immediately. - '--remote-debugging-port=9222' - ] - }, - DebugChrome: { - base: 'Chrome' - } - }, - reporters: ['progress', 'kjhtml'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, -// browsers: ['myChromeHeadless'], - singleRun: true - }); -}; diff --git a/angular/src/styles.css b/angular/src/styles.css index af6287540..a4aec9d9e 100644 --- a/angular/src/styles.css +++ b/angular/src/styles.css @@ -7,8 +7,6 @@ font-family: sans-serif; } -@import "~ngx-toastr/toastr.css"; - :root { /* Colors */ --science-theme-background-default: #019fbb; diff --git a/angular/src/test.ts b/angular/src/test.ts deleted file mode 100644 index 6b03dbe8b..000000000 --- a/angular/src/test.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file is required by karma.conf.js and loads recursively all the .spec and framework files - -import 'zone.js/testing'; -import { getTestBed } from '@angular/core/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; - -declare const require: any; - -// First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting(), { - teardown: { destroyAfterEach: false } -} -); -// Then we find all the tests. -const context = require.context('./', true, /\.spec\.ts$/); -// And load the modules. -context.keys().map(context); diff --git a/angular/src/tsconfig.spec.json b/angular/src/tsconfig.spec.json deleted file mode 100644 index de7733630..000000000 --- a/angular/src/tsconfig.spec.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "outDir": "../out-tsc/spec", - "types": [ - "jasmine", - "node" - ] - }, - "files": [ - "test.ts", - "polyfills.ts" - ], - "include": [ - "**/*.spec.ts", - "**/*.d.ts" - ] -} diff --git a/angular/tsconfig.json b/angular/tsconfig.json index 4b4c97b90..8f83f5220 100644 --- a/angular/tsconfig.json +++ b/angular/tsconfig.json @@ -11,8 +11,10 @@ "moduleResolution": "node", "experimentalDecorators": true, "esModuleInterop": true, - "target": "es2020", - "types": [ "node","jasmine" ], + "target": "ES2022", + "types": [ + "jest", "node" + ], "typeRoots": [ "node_modules/@types" ], @@ -20,7 +22,8 @@ "es2017", "dom", "es6" - ] + ], + "useDefineForClassFields": false } } \ No newline at end of file diff --git a/angular/tsconfig.spec.json b/angular/tsconfig.spec.json new file mode 100644 index 000000000..46c27226d --- /dev/null +++ b/angular/tsconfig.spec.json @@ -0,0 +1,17 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/spec", + "types": [ + "jest", + "node" + ] + }, + "files": [ + "src/polyfills.ts" + ], + "include": [ + "**/*.spec.ts", + "**/*.d.ts" + ] +} \ No newline at end of file