diff --git a/projects/demo/e2e/protractor.conf.js b/projects/demo/e2e/protractor.conf.js index f238c0b..952a41c 100644 --- a/projects/demo/e2e/protractor.conf.js +++ b/projects/demo/e2e/protractor.conf.js @@ -9,11 +9,9 @@ const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter'); */ exports.config = { allScriptsTimeout: 11000, - specs: [ - './src/**/*.e2e-spec.ts' - ], + specs: ['./src/**/*.e2e-spec.ts'], capabilities: { - browserName: 'chrome' + browserName: 'chrome', }, directConnect: true, baseUrl: 'http://localhost:4200/', @@ -21,16 +19,18 @@ exports.config = { jasmineNodeOpts: { showColors: true, defaultTimeoutInterval: 30000, - print: function() {} + print: function () {}, }, onPrepare() { require('ts-node').register({ - project: require('path').join(__dirname, './tsconfig.json') + project: require('path').join(__dirname, './tsconfig.json'), }); - jasmine.getEnv().addReporter(new SpecReporter({ - spec: { - displayStacktrace: StacktraceOption.PRETTY - } - })); - } -}; \ No newline at end of file + jasmine.getEnv().addReporter( + new SpecReporter({ + spec: { + displayStacktrace: StacktraceOption.PRETTY, + }, + }) + ); + }, +}; diff --git a/projects/demo/e2e/tsconfig.json b/projects/demo/e2e/tsconfig.json index 4f6467f..b18e2a4 100644 --- a/projects/demo/e2e/tsconfig.json +++ b/projects/demo/e2e/tsconfig.json @@ -5,10 +5,6 @@ "outDir": "../../../out-tsc/e2e", "module": "commonjs", "target": "es2018", - "types": [ - "jasmine", - "jasminewd2", - "node" - ] + "types": ["jasmine", "jasminewd2", "node"] } } diff --git a/projects/demo/src/app/app.component.html b/projects/demo/src/app/app.component.html index 7a70e17..8ab6c0b 100644 --- a/projects/demo/src/app/app.component.html +++ b/projects/demo/src/app/app.component.html @@ -1,7 +1,7 @@
@@ -9,75 +9,77 @@

ngx-device-detector

- An Angular 5+ powered AOT compatible device detector that helps to identify browser, os and other useful information regarding the device using the app. The processing is based on user-agent. + An Angular 5+ powered AOT compatible device detector that helps to identify browser, os and other useful + information regarding the device using the app. The processing is based on user-agent.

- travis build status - npm version - github stars - license + travis build status + npm version + github stars + license

-
-
-
- Demo is at Angular version = {{version}} +
+
Demo is at Angular version = {{ version }}
-

- Open this page from different devices to see the appropriate details -

+

Open this page from different devices to see the appropriate details

Device Information

- + Paste the user agent (window.navigator.userAgent) here
- +
-
-
-
- Mobile -
-
- Tablet -
-
- Desktop -
+
+
Mobile
+
Tablet
+
Desktop
- - - + + + - + - + - +
Property Value
{{info.key}}{{info.value}}
{{ info.key }}{{ info.value }}
isDesktop(){{isDesktop}}{{ isDesktop }}
isMobile(){{isMobile}}{{ isMobile }}
isTablet(){{isTablet}}{{ isTablet }}
diff --git a/projects/demo/src/app/app.component.scss b/projects/demo/src/app/app.component.scss index 85871b6..16993bd 100644 --- a/projects/demo/src/app/app.component.scss +++ b/projects/demo/src/app/app.component.scss @@ -6,7 +6,7 @@ max-width: 600px; padding-top: 40px; .demo-container { - .github-logo{ + .github-logo { cursor: pointer; position: absolute; top: 10px; diff --git a/projects/demo/src/app/app.component.spec.ts b/projects/demo/src/app/app.component.spec.ts index 07b86c0..e4be962 100644 --- a/projects/demo/src/app/app.component.spec.ts +++ b/projects/demo/src/app/app.component.spec.ts @@ -7,15 +7,13 @@ describe('AppComponent', () => { let fixture: ComponentFixture; let app; - beforeEach( - waitForAsync(() => { - TestBed.configureTestingModule({ - imports: [], - declarations: [AppComponent, KeysPipe], - providers: [DeviceDetectorService], - }).compileComponents(); - }) - ); + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + imports: [], + declarations: [AppComponent, KeysPipe], + providers: [DeviceDetectorService], + }).compileComponents(); + })); beforeEach(() => { fixture = TestBed.createComponent(AppComponent); @@ -23,26 +21,17 @@ describe('AppComponent', () => { fixture.detectChanges(); }); - it( - 'should create the app', - waitForAsync(() => { - expect(app).toBeTruthy(); - }) - ); + it('should create the app', waitForAsync(() => { + expect(app).toBeTruthy(); + })); - it( - 'should render demo heading in an element having class demo-heading-text', - waitForAsync(() => { - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('.demo-heading-text').textContent).toContain('ngx-device-detector'); - }) - ); + it('should render demo heading in an element having class demo-heading-text', waitForAsync(() => { + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector('.demo-heading-text').textContent).toContain('ngx-device-detector'); + })); - it( - 'should render device information inside table in tags ', - waitForAsync(() => { - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelectorAll('table tr.info-item').length).toEqual(11); // all the 6 required properties - }) - ); + it('should render device information inside table in tags ', waitForAsync(() => { + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelectorAll('table tr.info-item').length).toEqual(11); // all the 6 required properties + })); }); diff --git a/projects/demo/src/app/server.ts b/projects/demo/src/app/server.ts index 524448c..4de55e2 100644 --- a/projects/demo/src/app/server.ts +++ b/projects/demo/src/app/server.ts @@ -13,7 +13,7 @@ import { isPlatformServer } from '@angular/common'; export class UniversalDeviceDetectorService extends DeviceDetectorService { constructor(@Inject(PLATFORM_ID) platformId: any, @Optional() @Inject(REQUEST) request: Request) { super(platformId); - if (isPlatformServer(platformId)){ + if (isPlatformServer(platformId)) { super.setDeviceInfo((request.headers['user-agent'] as string) || ''); } } @@ -22,9 +22,11 @@ export class UniversalDeviceDetectorService extends DeviceDetectorService { @NgModule({ imports: [AppModule, ServerModule], bootstrap: [AppComponent], - providers: [{ - provide: DeviceDetectorService, - useClass: UniversalDeviceDetectorService - },] + providers: [ + { + provide: DeviceDetectorService, + useClass: UniversalDeviceDetectorService, + }, + ], }) export class AppServerModule {} diff --git a/projects/demo/src/environments/environment.prod.ts b/projects/demo/src/environments/environment.prod.ts index 3612073..c966979 100644 --- a/projects/demo/src/environments/environment.prod.ts +++ b/projects/demo/src/environments/environment.prod.ts @@ -1,3 +1,3 @@ export const environment = { - production: true + production: true, }; diff --git a/projects/demo/src/environments/environment.ts b/projects/demo/src/environments/environment.ts index 30d7bcc..31cb785 100644 --- a/projects/demo/src/environments/environment.ts +++ b/projects/demo/src/environments/environment.ts @@ -3,7 +3,7 @@ // The list of file replacements can be found in `angular.json`. export const environment = { - production: false + production: false, }; /* diff --git a/projects/demo/src/index.html b/projects/demo/src/index.html index 580880f..7aa6e8f 100644 --- a/projects/demo/src/index.html +++ b/projects/demo/src/index.html @@ -1,15 +1,15 @@ - + - - - Demo - - - - - - - - - + + + Demo + + + + + + + + + diff --git a/projects/demo/src/main.ts b/projects/demo/src/main.ts index ebf5fc9..3866701 100644 --- a/projects/demo/src/main.ts +++ b/projects/demo/src/main.ts @@ -9,6 +9,7 @@ if (environment.production) { } document.addEventListener('DOMContentLoaded', () => { - platformBrowserDynamic().bootstrapModule(AppModule) - .catch(err => console.error(err)); + platformBrowserDynamic() + .bootstrapModule(AppModule) + .catch(err => console.error(err)); }); diff --git a/projects/demo/tsconfig.server.json b/projects/demo/tsconfig.server.json index f121611..bf1cf9a 100644 --- a/projects/demo/tsconfig.server.json +++ b/projects/demo/tsconfig.server.json @@ -4,14 +4,9 @@ "compilerOptions": { "outDir": "../../out-tsc/server", "target": "es2016", - "types": [ - "node" - ] + "types": ["node"] }, - "files": [ - "src/demo.ts", - "server.ts" - ], + "files": ["src/demo.ts", "server.ts"], "angularCompilerOptions": { "entryModule": "./src/demo#AppServerModule" } diff --git a/projects/demo/tslint.json b/projects/demo/tslint.json index 19e8161..8006e74 100644 --- a/projects/demo/tslint.json +++ b/projects/demo/tslint.json @@ -1,17 +1,7 @@ { "extends": "../../tslint.json", "rules": { - "directive-selector": [ - true, - "attribute", - "app", - "camelCase" - ], - "component-selector": [ - true, - "element", - "app", - "kebab-case" - ] + "directive-selector": [true, "attribute", "app", "camelCase"], + "component-selector": [true, "element", "app", "kebab-case"] } } diff --git a/projects/ngx-device-detector/ng-package.json b/projects/ngx-device-detector/ng-package.json index 434b257..922db43 100644 --- a/projects/ngx-device-detector/ng-package.json +++ b/projects/ngx-device-detector/ng-package.json @@ -4,4 +4,4 @@ "lib": { "entryFile": "src/public-api.ts" } -} \ No newline at end of file +} diff --git a/projects/ngx-device-detector/package.json b/projects/ngx-device-detector/package.json index 48317c2..fc1d143 100644 --- a/projects/ngx-device-detector/package.json +++ b/projects/ngx-device-detector/package.json @@ -32,4 +32,4 @@ "dependencies": { "tslib": "^2.0.0" } -} \ No newline at end of file +} diff --git a/projects/ngx-device-detector/tslint.json b/projects/ngx-device-detector/tslint.json index 124133f..205aeda 100644 --- a/projects/ngx-device-detector/tslint.json +++ b/projects/ngx-device-detector/tslint.json @@ -1,17 +1,7 @@ { "extends": "../../tslint.json", "rules": { - "directive-selector": [ - true, - "attribute", - "lib", - "camelCase" - ], - "component-selector": [ - true, - "element", - "lib", - "kebab-case" - ] + "directive-selector": [true, "attribute", "lib", "camelCase"], + "component-selector": [true, "element", "lib", "kebab-case"] } }