moribvndvs / ng2-idle-example Goto Github PK
View Code? Open in Web Editor NEWExample for ng2-idle
Example for ng2-idle
Hi,
whenever I am going to apply in other pages , it is not even loaded page for idle check and not performing idle functionality .
Do i need to perform unsubscribe method for any of the subscribe method, please let me know.
Thanks
Hi, I am trying to show a warning when idle and hide the warning when interrupted. The warning is displayed and successfully hidden on timeout. However when an interrupt is detected, the countdown stops but the warning still displays. I am using ngif to show/hide the warning.
... in my component.ts constructor
idle.onTimeoutWarning.subscribe((countdown) => {
this.showWarning= true;
this.idleTimer = 'Auto log out in ' + countdown + ' seconds!';
});
idle.onIdleEnd.subscribe(() => {
this.showWarning= false;
});
idle.onTimeout.subscribe(() => {
this.showWarning= false;
});
...in my html
<div *ngIf="showWarning">
<div class="alert alert-warning alert-dismissible">
<div >
<p><strong>{{idleTimer}}</strong></p>
</div>
</div>
</div>
I am using angular 6.
Thanks!
I have integrated the @ng-idle/keepalive in my angular 9 project and i am getting the below error.
"ERROR Error: 'seconds' can only be 'false' or a positive number."
Correct integer value is passed to the setIdle as below;
this.idleTimeout = environment.idleTimeoutInSeconds;
// sets an idle timeout in seconds.
idle.setIdle(Number(this.idleTimeout));
Can you please help me getting this resolved.
My problem is the popup comes even if the user is interacting with the application. The popup should come only when the user is idle.
Hello, i'am trying ti implement some tests, to test my implementation with ng-idle, but it fails:
Test-Code:
import { Router } from '@angular/router';
import {async} from '@angular/core/testing';
import { inject, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { TimeoutService } from './timeout.service';
import { CoreTestingModule } from '../../core-testing.module';
fdescribe('TimeoutService', () => {
let router: Router;
let service: TimeoutService;
const spies = {
navigate: null
};
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule, CoreTestingModule],
providers: [TimeoutService]
});
//spies.navigate = spyOn(router, 'navigate').and.stub();
service = TestBed.get(TimeoutService);
}));
fit('should navigate to index after 15 Seconds', () => {
service.setIdleTime(10);
service.setTimeoutTime(5);
console.log('TEST FINISHED');
//expect(spies.navigate).toHaveBeenCalledWith(['/index']);
});
});
My karma.conf.json
module.exports = function (config) {
config.set({
basePath: '..',
frameworks: ['jasmine', 'intl-shim', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-intl-shim'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-junit-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
files: [
'node_modules/intl/locale-data/jsonp/de-DE.js',
'node_modules/ng-idle/angular-idle.min.js'
],
coverageIstanbulReporter: {
dir: require('path').join(__dirname, 'coverage'),
reports: ['html', 'lcovonly', 'cobertura'],
fixWebpackSourcePaths: true
},
client: {
clearContext: true // leave Jasmine Spec Runner output visible in browser
},reporters: ['progress', 'kjhtml', 'junit'], port: 9876, colors: true, logLevel: config.LOG_ERROR, autoWatch: false, browsers: ['ChromeHeadlessNoSandbox'], customLaunchers: { ChromeHeadlessNoSandbox: { base: 'ChromeHeadless', flags: [ '--no-sandbox' ] } }, singleRun: true, browserNoActivityTimeout: 100000, restartOnFileChange: true });
};
But i get error:
Browserslist: caniuse-lite is outdated. Please run next command
npm update
HeadlessChrome 80.0.3987 (Windows 10.0.0) TimeoutService should navigate to index after 15 Seconds FAILED
StaticInjectorError(Platform: core)[TimeoutService -> Idle]:
NullInjectorError: No provider for Idle!
NullInjectorError: StaticInjectorError(DynamicTestModule)[TimeoutService -> Idle]:
at NullInjector.get (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:855:1)
at resolveToken (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:17513:1)
at tryResolveToken (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:17439:1)
at StaticInjector.get (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:17265:1)
at resolveToken (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:17513:1)
at tryResolveToken (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:17439:1)
at StaticInjector.get (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:17265:1)
at resolveNgModuleDep (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:30392:1)
at _createClass (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:30464:1)
at _createProviderInstance (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:30425:1)
TypeError: Cannot read property 'setIdleTime' of undefined
at Object. (http://localhost:9876/_karma_webpack_/src/core/services/timeout/timeout.service.spec.ts:26:17)
at ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/node_modules/zone.js/dist/zone-evergreen.js:359:1)
at ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/node_modules/zone.js/dist/zone-testing.js:308:1)
at ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/node_modules/zone.js/dist/zone-evergreen.js:358:1)
at Zone.run (http://localhost:9876/_karma_webpack_/node_modules/zone.js/dist/zone-evergreen.js:124:1)
at runInTestZone (http://localhost:9876/_karma_webpack_/node_modules/zone.js/dist/zone-testing.js:561:1)
at Object. (http://localhost:9876/_karma_webpack_/node_modules/zone.js/dist/zone-testing.js:576:1)
HeadlessChrome 80.0.3987 (Windows 10.0.0): Executed 1 of 478 (1 FAILED) (skipped 444) (0 secs / 0.213 secs)
How can i run tests of ng-idle with karma-jasmine?
Hi
Am facing the following issue while compiling the angular2 code
Calling function 'NgIdleKeepaliveModule',
function calls are not supported. Consider replacing the function or lambda with a reference to an exported function,
resolving symbol AppModule
Looking forward to solution..
Thanks
Naga
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.