Skip to content

Commit

Permalink
chore: format all files
Browse files Browse the repository at this point in the history
  • Loading branch information
Yberion committed Jan 12, 2023
1 parent a496a60 commit 8a1fdfc
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 137 deletions.
26 changes: 13 additions & 13 deletions projects/demo/e2e/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ 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/',
framework: 'jasmine',
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
}
}));
}
};
jasmine.getEnv().addReporter(
new SpecReporter({
spec: {
displayStacktrace: StacktraceOption.PRETTY,
},
})
);
},
};
6 changes: 1 addition & 5 deletions projects/demo/e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
"outDir": "../../../out-tsc/e2e",
"module": "commonjs",
"target": "es2018",
"types": [
"jasmine",
"jasminewd2",
"node"
]
"types": ["jasmine", "jasminewd2", "node"]
}
}
70 changes: 36 additions & 34 deletions projects/demo/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,83 +1,85 @@
<div id="demoApp" class="container">
<div class="demo-container">
<a class="github-logo" href="https://github.com/Koderlabs/ngx-device-detector">
<img src="assets/images/github-logo.png">
<img src="assets/images/github-logo.png" />
</a>
<div class="demo-heading">
<a href="https://github.com/Koderlabs/ngx-device-detector">
<h1 align="center" class="demo-heading-text">ngx-device-detector</h1>
</a>

<p align="center">
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.
</p>

<p align="center" class="badges">
<a href="https://travis-ci.org/KoderLabs/ngx-device-detector"><img src="http://img.shields.io/travis/KoderLabs/ngx-device-detector.svg?style=flat" alt="travis build status" ></a>
<a href="https://www.npmjs.com/package/ngx-device-detector"><img src="https://img.shields.io/npm/v/ngx-device-detector.svg" alt="npm version" ></a>
<a href="https://www.npmjs.com/package/ngx-device-detector"><img src="https://img.shields.io/github/stars/KoderLabs/ngx-device-detector.svg?style=social&label=Star&style=flat-square" alt="github stars" ></a>
<a href="https://www.npmjs.com/package/ngx-device-detector"><img src="https://img.shields.io/npm/l/ngx-device-detector.svg?style=flat-square" alt="license" ></a>
<a href="https://travis-ci.org/KoderLabs/ngx-device-detector"
><img
src="http://img.shields.io/travis/KoderLabs/ngx-device-detector.svg?style=flat"
alt="travis build status"
/></a>
<a href="https://www.npmjs.com/package/ngx-device-detector"
><img src="https://img.shields.io/npm/v/ngx-device-detector.svg" alt="npm version"
/></a>
<a href="https://www.npmjs.com/package/ngx-device-detector"
><img
src="https://img.shields.io/github/stars/KoderLabs/ngx-device-detector.svg?style=social&label=Star&style=flat-square"
alt="github stars"
/></a>
<a href="https://www.npmjs.com/package/ngx-device-detector"
><img src="https://img.shields.io/npm/l/ngx-device-detector.svg?style=flat-square" alt="license"
/></a>
</p>
<hr>
</div>
<div class="demo-message text-center">
Demo is at Angular version = {{version}}
<hr />
</div>
<div class="demo-message text-center">Demo is at Angular version = {{ version }}</div>
<div class="demo-message">
<p class="text-center">
Open this page from different devices to see the appropriate details
</p>
<p class="text-center">Open this page from different devices to see the appropriate details</p>
<h4 class="text-center">Device Information</h4>
</div>
<div class="user-agent">
<div class="user-agent__input">
<div class="form-group">
<label for="userAgentInput">Test User Agent</label>
<input class="form-control" id="userAgentInput" #userAgentInput type="text" placeholder="">
<input class="form-control" id="userAgentInput" #userAgentInput type="text" placeholder="" />
<small id="uaHelp" class="form-text text-muted">Paste the user agent (window.navigator.userAgent) here</small>
</div>
</div>
<div class="user-agent__buttons">
<button class="btn btn-primary btn-sm" (click)="applyDevice(userAgentInput.value)">Apply test user agent</button>
<button class="btn btn-primary btn-sm" (click)="applyDevice(userAgentInput.value)">
Apply test user agent
</button>
<button class="btn btn-warning btn-sm" (click)="resetDeviceInfo()">Reset device info</button>
</div>
</div>
<div class="information-table">
<div class="device-icon">
<div
class="fa"
[ngClass]="{'fa-desktop': isDesktop, 'fa-mobile': isMobile, 'fa-tablet': isTablet}">
</div>
<div class="device-text" *ngIf="isMobile">
Mobile
</div>
<div class="device-text" *ngIf="isTablet">
Tablet
</div>
<div class="device-text" *ngIf="isDesktop">
Desktop
</div>
<div class="fa" [ngClass]="{ 'fa-desktop': isDesktop, 'fa-mobile': isMobile, 'fa-tablet': isTablet }"></div>
<div class="device-text" *ngIf="isMobile">Mobile</div>
<div class="device-text" *ngIf="isTablet">Tablet</div>
<div class="device-text" *ngIf="isDesktop">Desktop</div>
</div>
<table class="table table-hover">
<tr>
<th>Property</th>
<th>Value</th>
</tr>
<tr *ngFor="let info of deviceInfo | keys: propsToShow" class="info-item w3-hover-blue">
<td>{{info.key}}</td>
<td>{{info.value}}</td>
<tr *ngFor="let info of deviceInfo | keys : propsToShow" class="info-item w3-hover-blue">
<td>{{ info.key }}</td>
<td>{{ info.value }}</td>
</tr>
<tr class="info-item w3-hover-blue">
<td>isDesktop()</td>
<td>{{isDesktop}}</td>
<td>{{ isDesktop }}</td>
</tr>
<tr class="info-item w3-hover-blue">
<td>isMobile()</td>
<td>{{isMobile}}</td>
<td>{{ isMobile }}</td>
</tr>
<tr class="info-item w3-hover-blue">
<td>isTablet()</td>
<td>{{isTablet}}</td>
<td>{{ isTablet }}</td>
</tr>
</table>
</div>
Expand Down
2 changes: 1 addition & 1 deletion projects/demo/src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
max-width: 600px;
padding-top: 40px;
.demo-container {
.github-logo{
.github-logo {
cursor: pointer;
position: absolute;
top: 10px;
Expand Down
47 changes: 18 additions & 29 deletions projects/demo/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,31 @@ describe('AppComponent', () => {
let fixture: ComponentFixture<AppComponent>;
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);
app = fixture.debugElement.componentInstance;
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 <tr> 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 <tr> tags ', waitForAsync(() => {
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelectorAll('table tr.info-item').length).toEqual(11); // all the 6 required properties
}));
});
12 changes: 7 additions & 5 deletions projects/demo/src/app/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) || '');
}
}
Expand All @@ -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 {}
2 changes: 1 addition & 1 deletion projects/demo/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const environment = {
production: true
production: true,
};
2 changes: 1 addition & 1 deletion projects/demo/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// The list of file replacements can be found in `angular.json`.

export const environment = {
production: false
production: false,
};

/*
Expand Down
26 changes: 13 additions & 13 deletions projects/demo/src/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Demo</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
<head>
<meta charset="utf-8" />
<title>Demo</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
<app-root></app-root>
</body>
</html>
5 changes: 3 additions & 2 deletions projects/demo/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
9 changes: 2 additions & 7 deletions projects/demo/tsconfig.server.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
14 changes: 2 additions & 12 deletions projects/demo/tslint.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}
2 changes: 1 addition & 1 deletion projects/ngx-device-detector/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"lib": {
"entryFile": "src/public-api.ts"
}
}
}
2 changes: 1 addition & 1 deletion projects/ngx-device-detector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
"dependencies": {
"tslib": "^2.0.0"
}
}
}
14 changes: 2 additions & 12 deletions projects/ngx-device-detector/tslint.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}

0 comments on commit 8a1fdfc

Please sign in to comment.