From echatellier@users.chorem.org Sun Sep 1 16:44:14 2013 From: echatellier@users.chorem.org To: jtimer-commits@list.chorem.org Subject: [Jtimer-commits] r2931 - in branches/ng-jtimer/jtimer-server/src/main: go webapp webapp/css webapp/js webapp/partials Date: Sun, 01 Sep 2013 16:44:14 +0200 Message-ID: <20130901144414.602E118E4B6@nuiton.codelutin.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3443815760052703180==" --===============3443815760052703180== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Author: echatellier Date: 2013-09-01 16:44:14 +0200 (Sun, 01 Sep 2013) New Revision: 2931 Url: http://chorem.org/projects/jtimer/repository/revisions/2931 Log: Display idle dialog when detected Modified: branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go branches/ng-jtimer/jtimer-server/src/main/webapp/css/app.css branches/ng-jtimer/jtimer-server/src/main/webapp/index.html branches/ng-jtimer/jtimer-server/src/main/webapp/js/app.js branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js branches/ng-jtimer/jtimer-server/src/main/webapp/partials/tasks.html Modified: branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go 2013-09-01 12:48:0= 8 UTC (rev 2930) +++ branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go 2013-09-01 14:44:1= 4 UTC (rev 2931) @@ -57,7 +57,7 @@ currentIdleTime :=3D reply.MsSinceUserInput fmt.Println("Idle since", currentIdleTime) =20 - msSinceUserInputString :=3D fmt.Sprintf("{idle:%d}", currentIdleTime) + msSinceUserInputString :=3D fmt.Sprintf("{\"idle\":%d}", currentIdle= Time) h.broadcast <- msSinceUserInputString } } Modified: branches/ng-jtimer/jtimer-server/src/main/webapp/css/app.css =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/ng-jtimer/jtimer-server/src/main/webapp/css/app.css 2013-09-01 1= 2:48:08 UTC (rev 2930) +++ branches/ng-jtimer/jtimer-server/src/main/webapp/css/app.css 2013-09-01 1= 4:44:14 UTC (rev 2931) @@ -14,6 +14,17 @@ background:black; color:graytext; } +div#alerts{ + position:absolute; + bottom:20px; + left:0; + width:100%; + z-index: 1000; +} +.alert { + margin-bottom: 0; +} + div#footer{ position:absolute; bottom:0; Modified: branches/ng-jtimer/jtimer-server/src/main/webapp/index.html =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/ng-jtimer/jtimer-server/src/main/webapp/index.html 2013-09-01 12= :48:08 UTC (rev 2930) +++ branches/ng-jtimer/jtimer-server/src/main/webapp/index.html 2013-09-01 14= :44:14 UTC (rev 2931) @@ -4,14 +4,19 @@ jTimer =20 + =20 =20 + + + =20 + =20 =20 Modified: branches/ng-jtimer/jtimer-server/src/main/webapp/js/app.js =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/ng-jtimer/jtimer-server/src/main/webapp/js/app.js 2013-09-01 12:= 48:08 UTC (rev 2930) +++ branches/ng-jtimer/jtimer-server/src/main/webapp/js/app.js 2013-09-01 14:= 44:14 UTC (rev 2931) @@ -200,8 +200,47 @@ }; }]; =20 +var wtWebSocketService =3D [function() { + var service =3D {}; =20 -angular.module('webtimer', ['webtimerFilters', 'ngRoute', 'ngAnimate']) + service.connect =3D function() { + if(service.ws) { return; } + + var ws =3D new WebSocket("ws://localhost:12345/jtimer"); + + ws.onopen =3D function() { + console.log('Websocket open'); + service.callback.status(true); + }; + + ws.onerror =3D function() { + console.log('Websocket error'); + }; + + ws.onclose =3D function() { + service.callback.status(false); + }; + + ws.onmessage =3D function(message) { + service.callback.message(message.data); + }; + + service.ws =3D ws; + }; + + service.send =3D function(message) { + service.ws.send(message); + }; + + service.subscribe =3D function(callback) { + service.callback =3D callback; + }; + + return service; +}]; + + +angular.module('webtimer', ['webtimerFilters', 'ngRoute', 'ngAnimate', 'ui.b= ootstrap']) .config(['$routeProvider', function($routeProvider) { $routeProvider. when('/tasks', {templateUrl: 'partials/tasks.html', controller: = TasksCtrl}). @@ -232,4 +271,5 @@ }; }) =20 - .directive('wtTreeRepeat', wtTreeRepeatDirective); + .directive('wtTreeRepeat', wtTreeRepeatDirective) + .service('wtWebsocket', wtWebSocketService); Modified: branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js 2013-0= 9-01 12:48:08 UTC (rev 2930) +++ branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js 2013-0= 9-01 14:44:14 UTC (rev 2931) @@ -1,4 +1,4 @@ -function TasksCtrl($scope, $timeout, $localStorage, $window, $document) { +function TasksCtrl($scope, $timeout, $localStorage, $window, $document, wtWe= bsocket) { =20 /** * {Boolean} vrai si on est online @@ -33,6 +33,16 @@ // {boolean} boolean qui indique si la colonne TAGS doit etre affichee $scope.showTags =3D true; =20 + // etat du client local (le serveur websocket) + $scope.webSocketClientOnline =3D false; + // le client est en =C3=A9tat d'inactivit=C3=A9 + $scope.webSocketClientIdle =3D false; + // idle modal dialog option + $scope.modalIdleOpts =3D { + backdropFade: true, + dialogFade:true + }; + /** * Met a jour la tache selectionne, si la tache selectionnee est la cour= ante * alors on met la selection a null @@ -82,8 +92,6 @@ $scope.online =3D true; }, false); =20 - - /** * Force la sauvegarde des datas * @returns {undefined} @@ -122,7 +130,6 @@ if ($scope.tree) { $scope.tree.addChild($scope.createTreeNode(newTask)); } -// $scope.createTree(); }; =20 /** @@ -136,7 +143,6 @@ node.$$open =3D true; save(); node.addChild($scope.createTreeNode(newTask)); -// $scope.createTree(); }; =20 /** @@ -157,7 +163,6 @@ // remove node in tree node.remove(); save(); -// $scope.createTree(); }; =20 /** @@ -322,11 +327,27 @@ // force the first tree creation $scope.createTree(); =20 - var conn =3D conn =3D new WebSocket("ws://localhost:12345/jtimer"); - conn.onclose =3D function(evt) { - console.log("Connection closed."); + wtWebsocket.subscribe({ + message: function(data) { + var jsData =3D JSON.parse(data); + //$scope.messages.push(message); + //$scope.$apply(); + //console.log(jsData); + if (jsData.idle) { + if (jsData.idle > 30000) { //30s + console.log("Idle detected"); + $scope.webSocketClientIdle =3D true; + $scope.$apply(); + } + } + }, + status: function(status) { + $scope.webSocketClientOnline =3D status; + } + }); + wtWebsocket.connect(); + =20 + $scope.restartFromIdleness =3D function() { + $scope.webSocketClientIdle =3D false; }; - conn.onmessage =3D function(evt) { - console.log("Message", evt.data); - }; } Modified: branches/ng-jtimer/jtimer-server/src/main/webapp/partials/tasks.html =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/ng-jtimer/jtimer-server/src/main/webapp/partials/tasks.html 2013= -09-01 12:48:08 UTC (rev 2930) +++ branches/ng-jtimer/jtimer-server/src/main/webapp/partials/tasks.html 2013= -09-01 14:44:14 UTC (rev 2931) @@ -19,6 +19,12 @@ +
+
+ Impossible de contacter le cli= ent local pour la gestion de l'inactivit=C3=A9. + T=C3=A9l=C3=A9charger le client local<= /a>. +
+
{{currentDate()}} WebTim= er @@ -82,6 +88,20 @@
+ + =20 +
+
+

Inativit=C3=A9 d=C3=A9tect=C3=A9e

+
+ Vous =C3=AAtes inactif depuis 42 minutes. + Choisissez une option pour reprendre ou arr=C3=AAter la t=C3=A2che. +
+
+ + + +
--===============3443815760052703180==--