Skip to content

Commit a51fbce

Browse files
committed
Add NFC management
1 parent a2ef448 commit a51fbce

File tree

6 files changed

+49
-4
lines changed

6 files changed

+49
-4
lines changed

app/public/connection/connection.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ buckutt.controller('Connection', [
1212
'Device',
1313
'GetLogin',
1414
'jwtHelper',
15-
function($scope, $location, $http, GetUser, GetDevice, GetDevicePoint, Notifier, User, Device, GetLogin, jwtHelper) {
15+
'Socket',
16+
function($scope, $location, $http, GetUser, GetDevice, GetDevicePoint, Notifier, User, Device, GetLogin, jwtHelper, Socket) {
1617
$scope.userPin = '';
1718
$scope.savedId = '';
1819

20+
Socket.on('card', function(data) {
21+
$scope.cardId = data;
22+
$scope.pressEnter();
23+
});
24+
1925
$scope.pressEnter = function() {
2026
var cardId = $scope.cardId.replace(/(\s+)?.$/, '');
2127
if(cardId != "") {

app/public/factories/socket.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
buckutt.factory('Socket', function ($rootScope, config) {
4+
var socket = io.connect('http://localhost:'+config.deviceId.port);
5+
return {
6+
on: function (eventName, callback) {
7+
socket.on(eventName, function () {
8+
var args = arguments;
9+
$rootScope.$apply(function () {
10+
callback.apply(socket, args);
11+
});
12+
});
13+
},
14+
emit: function (eventName, data, callback) {
15+
socket.emit(eventName, data, function () {
16+
var args = arguments;
17+
$rootScope.$apply(function () {
18+
if (callback) {
19+
callback.apply(socket, args);
20+
}
21+
});
22+
})
23+
}
24+
};
25+
});

app/public/index.html

+2
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ <h4 id="modalNotifierTitle" class="modal-title"></h4>
4545
<script src="static/vendor/moment/locale/fr.js"></script>
4646
<script src="static/vendor/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>
4747
<script src="static/vendor/devbridge-autocomplete/dist/jquery.autocomplete.min.js"></script>
48+
<script src="static/vendor/socket.io-client/socket.io.js"></script>
4849

4950
<script src="app.js"></script>
5051
<script src="config.js"></script>
5152

5253
<script src="directives/autofocus.js"></script>
5354
<script src="directives/enter.js"></script>
5455
<script src="factories/notifier.js"></script>
56+
<script src="factories/socket.js"></script>
5557
<script src="providers/user.js"></script>
5658
<script src="providers/device.js"></script>
5759
<script src="resources/userTools.js"></script>

app/public/waiter/waiter.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ buckutt.controller('Waiter', [
1010
'Device',
1111
'User',
1212
'Notifier',
13-
function($scope, $location, $timeout, GetUser, GetId, GetGroups, Device, User, Notifier) {
13+
'Socket',
14+
function($scope, $location, $timeout, GetUser, GetId, GetGroups, Device, User, Notifier, Socket) {
1415
if(!User.hasRight('waiter', Device.getDevicePoint())) {
1516
Notifier('Erreur', 'error', 3);
1617
User.logout();
@@ -19,6 +20,11 @@ buckutt.controller('Waiter', [
1920

2021
$scope.cardId = '';
2122
$scope.lastBuyerData = User.getLastBuyerData();
23+
24+
Socket.on('card', function(data) {
25+
$scope.cardId = data;
26+
$scope.pressEnter();
27+
});
2228

2329
$scope.pressEnter = function() {
2430
var cardId = $scope.cardId.replace(/(\s+)?.$/, '');

bower.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "buckutt",
33
"version": "0.0.0",
4-
"homepage": "https://github.com/ungdev/BuckUTT-client",
4+
"homepage": "https://github.com/buckutt/BuckUTT-Client",
55
"authors": [
66
"Lucas Soulier <[email protected]>"
77
],
@@ -29,6 +29,7 @@
2929
"angular-route": "~1.3.11",
3030
"angular-resource": "~1.3.11",
3131
"angular-jwt": "*",
32-
"fontawesome": "~4.3.0"
32+
"fontawesome": "~4.3.0",
33+
"socket.io-client": "~1.4.6"
3334
}
3435
}

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"description": "Client du systeme de paiement electronique",
55
"dependencies": {
66
"http-proxy": "^1.10.1",
7+
"forever": "^0.11.1",
78
"node-static": "^0.7.6"
9+
},
10+
"scripts": {
11+
"start": "./node_modules/forever/bin/forever start ./app/server.js ",
12+
"stop": "./node_modules/forever/bin/forever stopall "
813
}
914
}

0 commit comments

Comments
 (0)