Skip to content

Commit 7095f43

Browse files
committed
Adding CheckIn Link Generator
1 parent a488a7d commit 7095f43

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Pckgd
2+
# Title: Check-in Link Generator
3+
# Description: Kiosks can be configured to sign in automatically with credentials computed by this script.
4+
# Updates from: GitHub/TenthPres/TouchPointScripts/CheckinLinkGenerator/CheckinLinkGenerator.py
5+
# Author: James at Tenth
6+
7+
global model, q
8+
9+
# get profiles
10+
profs = q.QuerySql("SELECT TOP 100 * FROM CheckinProfiles ORDER BY Name")
11+
12+
profileOpts = []
13+
for p in profs:
14+
profileOpts.append('<option value="{0}">{1}</option>'.format(p.Name.lower(), p.Name))
15+
16+
# language=html
17+
print('''
18+
19+
<div class="form-group">
20+
<label class="control-label" for="cam">Camera</label>
21+
<select class="form-control" data-bind="value: cam" name="cam">
22+
<option value="none">None</option>
23+
<option value="user">User / Front</option>
24+
<option value="environment">Environment / Back</option>
25+
</select>
26+
</div>
27+
28+
<div class="form-group">
29+
<label class="control-label" for="kioskName">Kiosk Name</label>
30+
<input class="form-control" data-bind="value: name" name="kioskName" type="text" />
31+
</div>
32+
33+
<div class="form-group">
34+
<label class="control-label" for="profile">Profile</label>
35+
<select class="form-control" data-bind="value: profile" name="profile">
36+
%s
37+
</select>
38+
</div>
39+
40+
<div class="form-group">
41+
<label class="control-label" for="user">Username</label>
42+
<input class="form-control" data-bind="value: user" name="user" type="text" />
43+
</div>
44+
45+
<div class="form-group">
46+
<label class="control-label" for="pass">Password</label>
47+
<input class="form-control" data-bind="value: pass" name="pass" type="password" />
48+
</div>
49+
50+
<div class="form-group">
51+
<label class="control-label" for="outputUrl">Configured Check-in URL</label>
52+
<input class="form-control" data-bind="value: outputUrl, click: copyContent" name="outputUrl" type="text" />
53+
</div>
54+
55+
''' % ('\n'.join(profileOpts)))
56+
57+
58+
# language=html
59+
print('''
60+
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.5.0/knockout-min.js"></script>
61+
<script>
62+
63+
function LinkGenModel(){
64+
this.host = "%s";
65+
this.cam = ko.observable("none");
66+
this.name = ko.observable("");
67+
this.profile = ko.observable("");
68+
this.user = ko.observable("");
69+
this.pass = ko.observable("");
70+
71+
let model = this;
72+
73+
this.outputUrl = ko.computed(function() {
74+
let url = model.host + "/CheckIn?";
75+
if (model.cam() && model.cam() !== "none") { // cam is optional
76+
url += "cam=" + encodeURIComponent(model.cam()) + "&";
77+
}
78+
if (!model.name()) {
79+
return ""
80+
} else {
81+
url += "name=" + encodeURIComponent(model.name()) + "&";
82+
}
83+
if (model.profile()) {
84+
url += "profile=" + encodeURIComponent(model.profile()) + "&";
85+
}
86+
if (!model.user() || !model.pass()) {
87+
return ""
88+
} else {
89+
let credentials = model.user() + ":" + model.pass();
90+
let encodedCreds = btoa(credentials);
91+
url += "cred=" + encodeURIComponent(encodedCreds);
92+
}
93+
return url;
94+
});
95+
96+
this.copyContent = function() {
97+
let copyText = model.outputUrl();
98+
if (!copyText) {
99+
return;
100+
}
101+
navigator.clipboard.writeText(copyText).then(function() {
102+
swal("Copied the URL to clipboard.");
103+
}, function(err) {
104+
console.warn("Could not copy text: ", err);
105+
});
106+
};
107+
}
108+
109+
ko.applyBindings(new LinkGenModel());
110+
111+
</script>''' % (model.CmsHost))

0 commit comments

Comments
 (0)