-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathscan_vm.js
80 lines (65 loc) · 1.96 KB
/
scan_vm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
function ScanViewModel(settingsVM, qrServer, scannerServices) {
var self = this;
this.lastCheckInResultModel = new CheckInResultsModel();
this.settingsPageViewModel = settingsVM;
this.server = qrServer;
this.scannerServices = scannerServices;
this.isScanning = ko.observable(false);
this.updateStatistics = function() {
self.server.updateStatistics(
self.settingsPageViewModel.endpoint(),
self.settingsPageViewModel.apiKey(),
self.settingsPageViewModel.selectedEvent(),
self.lastCheckInResultModel
);
}
this.scanAndCheckInTicket = function(applicationVM) {
if (self.server.isMakingRequest()) {
return;
}
self.isScanning(true);
var ticketToken = null;
self.scannerServices.scan(
function(result) {
if (!result.cancelled) {
ticketToken = result.text;
self.server.checkInTicket(
self.settingsPageViewModel.endpoint(),
self.settingsPageViewModel.apiKey(),
self.settingsPageViewModel.selectedEvent(),
ticketToken,
self.lastCheckInResultModel
);
}
},
function(error) {
alertWrapper("Scan failed: " + error);
}
);
self.isScanning(false);
}
this.manualCheckin = function() {
self.server.manualCheckin(
self.settingsPageViewModel.endpoint(),
self.settingsPageViewModel.apiKey(),
self.settingsPageViewModel.selectedEvent(),
self.lastCheckInResultModel
);
}
this.passOut = function() {
self.server.passOut(
self.settingsPageViewModel.endpoint(),
self.settingsPageViewModel.apiKey(),
self.settingsPageViewModel.selectedEvent(),
self.lastCheckInResultModel
);
}
this.passIn = function() {
self.server.passIn(
self.settingsPageViewModel.endpoint(),
self.settingsPageViewModel.apiKey(),
self.settingsPageViewModel.selectedEvent(),
self.lastCheckInResultModel
);
}
}