Browse Source

Add groups for quick access

master
Skylar Ittner 4 years ago
parent
commit
d8d4c9e436
  1. 67
      js/login.js
  2. 2
      js/settings.js
  3. 23
      js/setup.js
  4. 4
      pages/login.html
  5. 15
      pages/setup.html

67
js/login.js

@ -51,33 +51,40 @@ function codelogin(code) {
}
function loadQuickLogin() {
$.post(accounthubapi, {
key: apikey,
gid: 4,
action: "getusersbygroup",
get: "detail"
}, function (resp) {
if (resp.status == "OK") {
var userhtml = "";
for (var user in resp.users) {
var u = resp.users[user];
userhtml += '<div class="col-4 col-lg-3 quick-user" data-uid="' + u["uid"] + '" data-username="' + u["username"] + '" data-name="' + u["name"] + '">\n'
+ '<i class="far fa-user fa-3x"></i>\n'
+ '<br />\n'
+ u["name"] + "\n"
+ '</div>\n';
if (!isNaN(group)) {
$.post(accounthubapi, {
key: apikey,
gid: group,
action: "getusersbygroup",
get: "detail"
}, function (resp) {
if (resp.status == "OK") {
var userhtml = "";
for (var user in resp.users) {
var u = resp.users[user];
userhtml += '<div class="col-4 col-lg-3 quick-user" data-uid="' + u["uid"] + '" data-username="' + u["username"] + '" data-name="' + u["name"] + '">\n'
+ '<i class="far fa-user fa-3x"></i>\n'
+ '<br />\n'
+ u["name"] + "\n"
+ '</div>\n';
}
$("#userlist .row").html(userhtml);
$(".quick-user").click(function () {
setuser($(this).data("username"));
setname($(this).data("name"));
setuid($(this).data("uid"));
openScreen("home");
});
} else {
$("#quickaccess_tab").tab("dispose");
$("#userpass_tab").tab("show");
}
$("#userlist .row").html(userhtml);
$(".quick-user").click(function () {
setuser($(this).data("username"));
setname($(this).data("name"));
setuid($(this).data("uid"));
openScreen("home");
});
} else {
showmsg(resp.msg, "danger");
}
}, "json");
}, "json");
} else {
$("#quickaccess_tab").tab("dispose");
$("#quickaccess_tab").css("display", "none");
$("#userpass_tab").tab("show");
}
}
$("#userpassloginbtn").click(function () {
@ -87,14 +94,6 @@ $("#userpassloginbtn").click(function () {
userpasslogin(user, pass);
}
});
function quicklogin(uid) {
var quickuser =
setuser(resp.data.username);
setname(resp.data.name);
setuid(resp.data.uid);
openScreen("home");
}
$("#mobilecodeloginbtn").click(function () {
var code = $("#code").val();

2
js/settings.js

@ -7,6 +7,7 @@
var accounthubapi = localStorage.getItem("apiurl");
var apikey = localStorage.getItem("apikey");
var group = localStorage.getItem("group");
var kioskmode = localStorage.getItem("kioskmode") == "true" ? true : false;
var largebtns = localStorage.getItem("largebtns") == "true" ? true : false;
@ -41,6 +42,7 @@ function validateSettings(callback) {
function reloadSettings() {
accounthubapi = localStorage.getItem("apiurl");
apikey = localStorage.getItem("apikey");
group = localStorage.getItem("group");
kioskmode = localStorage.getItem("kioskmode");
largebtns = localStorage.getItem("largebtns");
}

23
js/setup.js

@ -4,11 +4,34 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
function dlGroups() {
localStorage.setItem("apiurl", $("#url").val());
localStorage.setItem("apikey", $("#key").val());
reloadSettings();
$.post(accounthubapi, {
key: apikey,
action: "getgroups"
}, function (data) {
if (data.status == "OK") {
var options = "";
for (var group in data.groups) {
var g = data.groups[group];
options += '<option value="' + g["id"] + '"' + (options == "" ? " selected" : "") + '>' + g["name"] + '</option>\n';
}
$("#group").append(options);
} else {
showmsg("Error", "danger", "Something is wrong. Check the settings you entered.");
}
}, "json").fail(function () {
showmsg("Error", "danger", "Something is wrong. Check the settings you entered.");
});
}
$("#settings_form").submit(function (event) {
event.preventDefault();
localStorage.setItem("apiurl", $("#url").val());
localStorage.setItem("apikey", $("#key").val());
localStorage.setItem("group", $("#group").val());
localStorage.setItem("kioskmode", $("#kioskmode").is(":checked") ? true : null);
localStorage.setItem("largebtns", $("#largebtns").is(":checked") ? true : null);
reloadSettings();

4
pages/login.html

@ -5,10 +5,10 @@
<h3 class="card-header"><i class="fas fa-lock"></i> Login</h3>
<ul class="nav nav-tabs justify-content-center">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#userlist">Quick Access</a>
<a class="nav-link active" data-toggle="tab" href="#userlist" id="quickaccess_tab">Quick Access</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#userpass">Username/Password</a>
<a class="nav-link" data-toggle="tab" href="#userpass" id="userpass_tab">Username/Password</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#mobilecode">Mobile Code</a>

15
pages/setup.html

@ -17,11 +17,22 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
<form id="settings_form">
<div class="input-group">
<span class="input-group-addon"><i class="fas fa-server"></i></span>
<input type="text" class="form-control" id="url" placeholder="AccountHub API URL" />
<input type="text" class="form-control" id="url" placeholder="AccountHub API URL" required />
</div>
<div class="input-group">
<span class="input-group-addon"><i class="fas fa-key"></i></span>
<input type="text" class="form-control" id="key" placeholder="API Key" />
<input type="text" class="form-control" id="key" placeholder="API Key" required />
</div>
<div class="input-group">
<span class="input-group-addon"><i class="fas fa-users"></i></span>
<select class="form-control" id="group">
<option value="">Select a Quick Access Group</option>
</select>
<span class="input-group-btn">
<span class="btn btn-primary" id="dlgroupsbtn" onclick="dlGroups();">
<i class="fas fa-download"></i> Get Groups
</span>
</span>
</div>
<br />
<div class="form-check">

Loading…
Cancel
Save