-
Notifications
You must be signed in to change notification settings - Fork 1
TTA 115 time tracker doesnt notifies the user when they lost internet connection or have a slow connection #928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
d0c5298
e04763f
b56113b
84bde1c
da0522a
4665966
07809f5
fe5b055
1d40b7d
5f65148
a912865
940f4b8
470a043
5f8aac5
2e9e2cb
e88247c
37cec9b
8e72487
5bc7915
aabefaf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
<app-internet-connection-status listen="true"> | ||
|
||
<ng-container *fast> | ||
</ng-container> | ||
|
||
<ng-container *slow> | ||
</ng-container> | ||
|
||
<ng-container *offline> | ||
</ng-container> | ||
|
||
</app-internet-connection-status> | ||
<router-outlet></router-outlet> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { ConnectionDirective } from './connection.directive'; | ||
|
||
describe('ConnectionDirective', () => { | ||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ConnectionDirective] | ||
}); | ||
}); | ||
|
||
it('should create an instance', () => { | ||
const directive = new ConnectionDirective('slowSrc', 'fastSrc', 'offlineSrc', undefined); | ||
expect(directive).toBeTruthy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,34 @@ | ||||||||||||||||||||||||||||||||||||||
import { Directive, Attribute, ElementRef, OnInit } from '@angular/core'; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
@Directive({ | ||||||||||||||||||||||||||||||||||||||
selector: '[appConnection]' | ||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
export class ConnectionDirective implements OnInit { | ||||||||||||||||||||||||||||||||||||||
constructor( | ||||||||||||||||||||||||||||||||||||||
@Attribute('slowSrc') private slowSrc, | ||||||||||||||||||||||||||||||||||||||
@Attribute('fastSrc') private fastSrc, | ||||||||||||||||||||||||||||||||||||||
@Attribute('offlineSrc') private offlineSrc, | ||||||||||||||||||||||||||||||||||||||
private host: ElementRef<HTMLImageElement> | ||||||||||||||||||||||||||||||||||||||
) { | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
ngOnInit() { | ||||||||||||||||||||||||||||||||||||||
const { effectiveType } = navigator.connection; | ||||||||||||||||||||||||||||||||||||||
let networkSatus; | ||||||||||||||||||||||||||||||||||||||
if (!(/\fast-5g|3g|4g/.test(effectiveType)) || !(/\slow-2g|2g/.test(effectiveType))){ | ||||||||||||||||||||||||||||||||||||||
networkSatus = this.offlineSrc; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
if (/\fast-5g|3g|4g/.test(effectiveType)) { | ||||||||||||||||||||||||||||||||||||||
networkSatus = this.fastSrc; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
if (/\slow-2g|2g/.test(effectiveType)) { | ||||||||||||||||||||||||||||||||||||||
networkSatus = this.slowSrc; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Me parece que así se ve mas limpio. Entiendo que quisiste poner la negación primero, pero lo más común es que la conección sea buena, y si programamos poniendo el caso mas común al principio mejora la legibilidad del código, se entiende mejor el comportamiento. |
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
this.host.nativeElement.setAttribute('src', networkSatus); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,14 @@ | ||||||||||||||||||
import { TestBed } from '@angular/core/testing'; | ||||||||||||||||||
import { FastDirective } from './fast.directive'; | ||||||||||||||||||
|
||||||||||||||||||
describe('FastDirective', () => { | ||||||||||||||||||
beforeEach(() => { | ||||||||||||||||||
TestBed.configureTestingModule({ | ||||||||||||||||||
declarations: [FastDirective] | ||||||||||||||||||
}); | ||||||||||||||||||
}); | ||||||||||||||||||
it('should create an instance', () => { | ||||||||||||||||||
const directive = new FastDirective(undefined); | ||||||||||||||||||
expect(directive).toBeTruthy(); | ||||||||||||||||||
}); | ||||||||||||||||||
Comment on lines
+10
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Directive, TemplateRef } from '@angular/core'; | ||
|
||
@Directive({ | ||
selector: '[appFast]' | ||
}) | ||
|
||
export class FastDirective { | ||
|
||
constructor(public tpl: TemplateRef<any>) { } | ||
|
||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,14 @@ | ||||||||||||||||||
import { TestBed } from '@angular/core/testing'; | ||||||||||||||||||
import { OfflineDirective } from './offline.directive'; | ||||||||||||||||||
|
||||||||||||||||||
describe('FastDirective', () => { | ||||||||||||||||||
beforeEach(() => { | ||||||||||||||||||
TestBed.configureTestingModule({ | ||||||||||||||||||
declarations: [OfflineDirective] | ||||||||||||||||||
}); | ||||||||||||||||||
}); | ||||||||||||||||||
it('should create an instance', () => { | ||||||||||||||||||
const directive = new OfflineDirective(undefined); | ||||||||||||||||||
expect(directive).toBeTruthy(); | ||||||||||||||||||
}); | ||||||||||||||||||
Comment on lines
+10
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creo q esa linea en blanco estaba bien porque separa las importaciones externas de los modulos internos