Giter VIP home page Giter VIP logo

ng2-idle-example's People

Contributors

angular-cli avatar moribvndvs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ng2-idle-example's Issues

idle check service is not loading and performing function

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

Idle interupt and timeout warning

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!

ERROR Error: 'seconds' can only be 'false' or a positive number.

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.

Tests with Karma/Jasmin?

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?

Calling function 'NgIdleKeepaliveModule', function calls are not supported

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.