git.psu.edu will be upgraded to critical security release 13.7.4 Monday, 11/18 between 9 and 10pm. Please email support@git.psu.edu if you have trouble with anything Gitlab-related. Please see the git.psu.edu Yammer group for more information.

Commit 477253eb authored by Ryan Diehl's avatar Ryan Diehl

Merge branch 'feature/loading-events' into 'develop'

fix(loading-events): removes duplicate LoadingEvents implementation

See merge request !38
parents 4cb08256 cc8ad912
Pipeline #109711 passed with stages
in 3 minutes and 11 seconds
......@@ -337,34 +337,6 @@
}
}
},
"utils-loading-events": {
"projectType": "library",
"root": "libs/utils/loading-events",
"sourceRoot": "libs/utils/loading-events/src",
"prefix": "ut",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["libs/utils/loading-events/tsconfig.lib.json", "libs/utils/loading-events/tsconfig.spec.json"],
"exclude": ["**/node_modules/**", "!libs/utils/loading-events/**"]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"options": {
"jestConfig": "libs/utils/loading-events/jest.config.js",
"tsConfig": "libs/utils/loading-events/tsconfig.spec.json",
"setupFile": "libs/utils/loading-events/src/test-setup.ts"
}
}
},
"schematics": {
"@nrwl/angular:component": {
"styleext": "scss"
}
}
},
"utils-ngrx": {
"projectType": "library",
"root": "libs/utils/ngrx",
......
import { DOCUMENT } from '@angular/common';
import { Inject, Injectable } from '@angular/core';
import { Logger } from '@psu/utils/logger';
@Injectable({ providedIn: 'root' })
export class LoadingEvents {
private doc: Document;
private isAppReady: boolean;
constructor(@Inject(DOCUMENT) doc: any) {
constructor(@Inject(DOCUMENT) doc: any, private log: Logger) {
this.doc = doc;
this.isAppReady = false;
}
......@@ -15,9 +16,8 @@ export class LoadingEvents {
if (this.isAppReady) {
return;
}
const bubbles = true;
const cancelable = false;
this.doc.dispatchEvent(this.createEvent('appready', bubbles, cancelable));
this.log.debug('appready event triggered');
this.doc.dispatchEvent(this.createEvent('appready', true, false));
this.isAppReady = true;
}
......
# @psu/utils/loading-events
This library is used to dispatch a `CustomEvent` to the DOM when the application
is done bootstrapping. Our index.html files show a loading banner outside of Angular.
This library is used to communicate that the app is ready to load, which fades out
the loading banner and fades in the application.
## Running unit tests
Run `nx test utils-loading-events` to execute the unit tests.
module.exports = {
name: 'utils-loading-events',
preset: '../../../jest.config.js',
coverageDirectory: '../../../coverage/libs/utils/loading-events',
snapshotSerializers: [
'jest-preset-angular/AngularSnapshotSerializer.js',
'jest-preset-angular/HTMLCommentSerializer.js'
]
};
{
"lib": {
"entryFile": "src/index.ts"
}
}
export { LoadingEvents } from './lib/loading-events';
export { LoadingEventsModule } from './lib/loading-events.module';
import { async, TestBed } from '@angular/core/testing';
import { LoadingEventsModule } from './loading-events.module';
describe('LoadingEventsModule', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [LoadingEventsModule]
}).compileComponents();
}));
it('should create', () => {
expect(LoadingEventsModule).toBeDefined();
});
});
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { LoggerModule } from '@psu/utils/logger';
import { LoadingEvents } from './loading-events';
@NgModule({
imports: [CommonModule, LoggerModule],
providers: [LoadingEvents]
})
export class LoadingEventsModule {}
import { DOCUMENT } from '@angular/common';
import { Inject, Injectable } from '@angular/core';
import { Logger } from '@psu/utils/logger';
@Injectable()
export class LoadingEvents {
private doc: Document;
private isAppReady: boolean;
constructor(@Inject(DOCUMENT) doc: any, private log: Logger) {
this.doc = doc;
this.isAppReady = false;
}
public triggerAppReady(): void {
if (this.isAppReady) {
return;
}
this.log.debug('appready event triggered');
this.doc.dispatchEvent(this.createEvent('appready', true, false));
this.isAppReady = true;
}
private createEvent(eventType: string, bubbles: boolean, cancelable: boolean): Event {
const customEvent: any = new CustomEvent(eventType, {
bubbles,
cancelable
});
return customEvent;
}
}
import 'jest-preset-angular';
import '../../../../jestGlobalMocks';
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
"include": ["**/*.ts"]
}
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"target": "es2015",
"declaration": true,
"inlineSources": true,
"types": [],
"lib": ["dom", "es2018"]
},
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
},
"exclude": ["src/test-setup.ts", "**/*.spec.ts"]
}
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": ["**/*.spec.ts", "**/*.d.ts"]
}
{
"extends": "../../../tslint.json",
"rules": {
"directive-selector": [true, "attribute", "ut", "camelCase"],
"component-selector": [true, "element", "ut", "kebab-case"]
}
}
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { LoadingEventsModule } from '@psu/utils/loading-events';
import { LoggerModule } from '@psu/utils/logger';
import { PropertiesService } from './properties.service';
@NgModule({
imports: [CommonModule, LoggerModule, LoadingEventsModule],
imports: [CommonModule, LoggerModule],
providers: [PropertiesService]
})
export class PropertiesModule {}
import { HttpRequest } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { async, TestBed } from '@angular/core/testing';
import { NO_CACHE_HEADER } from '@psu/utils/browser';
import { LoadingEvents } from '@psu/utils/loading-events';
import { LoadingEvents, NO_CACHE_HEADER } from '@psu/utils/browser';
import { Logger } from '@psu/utils/logger';
import * as mockdate from 'mockdate';
import { Mock } from 'ts-mocks';
......
import { HttpBackend, HttpClient, HttpHeaders } from '@angular/common/http';
import { Inject, Injectable, Injector, Optional } from '@angular/core';
import { NO_CACHE_HEADER } from '@psu/utils/browser';
import { LoadingEvents } from '@psu/utils/loading-events';
import { LoadingEvents, NO_CACHE_HEADER } from '@psu/utils/browser';
import { Logger } from '@psu/utils/logger';
import { Observable, throwError } from 'rxjs';
import { catchError, tap } from 'rxjs/operators';
......
......@@ -41,9 +41,6 @@
"utils-logger": {
"tags": []
},
"utils-loading-events": {
"tags": []
},
"utils-ngrx": {
"tags": []
},
......
......@@ -25,7 +25,6 @@
"@psu/utils/theming": ["libs/utils/theming/src/index.ts"],
"@psu/utils/properties": ["libs/utils/properties/src/index.ts"],
"@psu/utils/logger": ["libs/utils/logger/src/index.ts"],
"@psu/utils/loading-events": ["libs/utils/loading-events/src/index.ts"],
"@psu/utils/ngrx": ["libs/utils/ngrx/src/index.ts"],
"@psu/utils/cdn": ["libs/utils/cdn/src/index.ts"],
"@psu/utils/form": ["libs/utils/form/src/index.ts"],
......
  • SonarQube analysis indicates that quality gate is failed.

    • Bugs is failed: Actual value 1 > 0
    • high_severity_vulns is passed: Actual value 0
    • medium_severity_vulns is passed: Actual value 0

    SonarQube analysis reported 17 issues

    • 5 major
    • 🔽 7 minor
    • 5 info

    Top 10 extra issues

    Note: The following issues were found on lines that were not modified in the commit. Because these issues can't be reported as line comments, they are summarized here:

    1. Unexpected empty source 📘
    2. Remove this useless assignment to variable "result". 📘
    3. Remove this useless assignment to variable "complete". 📘
    4. Remove this useless assignment to variable "loadResult". 📘
    5. Remove this useless assignment to variable "loadComplete". 📘
    6. 🔽 Add an "alt" attribute to this image. 📘
    7. 🔽 This assertion is unnecessary since it does not change the type of the expression. 📘
    8. 🔽 This assertion is unnecessary since it does not change the type of the expression. 📘
    9. 🔽 This assertion is unnecessary since it does not change the type of the expression. 📘
    10. 🔽 This assertion is unnecessary since it does not change the type of the expression. 📘
    • ... 7 more
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment