UNPKG

zettapi_client

Version:

Client side CRUD operations in angular to use with zettapi_server rest api to get started quickly in any CMS project

84 lines (71 loc) 2.37 kB
<html ng-app="demo"> <head> <title title>NgIdle Sample</title> <script src="../node_modules/angular/angular.js"></script> <script src="../angular-idle.min.js"></script> <script type="text/javascript"> var app = angular.module('demo', ['ngIdle']); app .controller('EventsCtrl', function($scope, Idle) { $scope.events = []; $scope.idle = 5; $scope.timeout = 5; $scope.$on('IdleStart', function() { addEvent({event: 'IdleStart', date: new Date()}); }); $scope.$on('IdleEnd', function() { addEvent({event: 'IdleEnd', date: new Date()}); }); $scope.$on('IdleWarn', function(e, countdown) { addEvent({event: 'IdleWarn', date: new Date(), countdown: countdown}); }); $scope.$on('IdleTimeout', function() { addEvent({event: 'IdleTimeout', date: new Date()}); }); $scope.$on('Keepalive', function() { addEvent({event: 'Keepalive', date: new Date()}); }); function addEvent(evt) { $scope.$evalAsync(function() { $scope.events.push(evt); }) } $scope.reset = function() { Idle.watch(); } $scope.$watch('idle', function(value) { if (value !== null) Idle.setIdle(value); }); $scope.$watch('timeout', function(value) { if (value !== null) Idle.setTimeout(value); }); }) .config(function(IdleProvider, KeepaliveProvider) { KeepaliveProvider.interval(10); IdleProvider.windowInterrupt('focus'); }) .run(function($rootScope, Idle, $log, Keepalive){ Idle.watch(); $log.debug('app started.'); }); </script> </head> <body ng-controller="EventsCtrl"> <div idle-countdown="countdown"> <h1>Idle and Keepalive events</h1> <button type="button" ng-click="reset()">Reset manually</button> <ul> <li ng-repeat="event in events">{{event}}</li> </ul> <div idle-countdown="countdown"> Timeout in {{countdown}} seconds. </div> <div> Change idle value <input type="number" ng-model="idle" /> </div> <div> Change timeout value <input type="number" ng-model="timeout" /> </div> </div> </body> </html>