Add qwikclock_jobs card
parent
7f00efba3f
commit
afd8a0a194
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
function dispCurrent(card, current) {
|
||||
var url = card.data("apiurl");
|
||||
$.post(url, {
|
||||
username: getuser(),
|
||||
password: getAPIKey(),
|
||||
action: "getactivejob"
|
||||
}, function (resp) {
|
||||
if (resp.status == "OK") {
|
||||
if (resp.job == false) {
|
||||
current.html('<div class="btn btn-default btn-sm">None</div>');
|
||||
} else {
|
||||
current.html('<div class="btn btn-' + resp.job.color + ' btn-sm">' + resp.job.name + '</div>');
|
||||
}
|
||||
} else {
|
||||
showmsg(resp.msg, "danger");
|
||||
}
|
||||
}, "json").fail(function () {
|
||||
card.css("display", "none");
|
||||
});
|
||||
}
|
||||
|
||||
$(".card_qwikclock_jobs").each(function () {
|
||||
var card = $(this);
|
||||
$(this).find(".card_title").prepend("Jobs | ");
|
||||
var btnbin = $(this).find(".job-btn-bin");
|
||||
var current = $(this).find(".current-job");
|
||||
var url = $(this).data("apiurl");
|
||||
$.post(url, {
|
||||
username: getuser(),
|
||||
password: getAPIKey(),
|
||||
action: "getjobs"
|
||||
}, function (resp) {
|
||||
if (resp.status == "OK") {
|
||||
var jobs = resp.jobs;
|
||||
if (jobs.length > 0) {
|
||||
for (var job in jobs) {
|
||||
btnbin.append('<div class="btn job-btn btn-' + jobs[job]['color'] + '" data-jobid="' + jobs[job]['id'] + '">' + jobs[job]['name'] + '</div>');
|
||||
}
|
||||
btnbin.append('<div class="btn job-btn btn-red" data-jobid="-1"><i class="fas fa-times"></i> None</div>');
|
||||
} else {
|
||||
btnbin.html('<div class="alert alert-primary"><i class="fas fa-info-circle"></i> No jobs available.</div>');
|
||||
}
|
||||
} else {
|
||||
showmsg(resp.msg, "danger");
|
||||
}
|
||||
}, "json").fail(function () {
|
||||
card.css("display", "none");
|
||||
});
|
||||
dispCurrent(card, current);
|
||||
setInterval(function () {
|
||||
dispCurrent(card, current)
|
||||
}, 2500);
|
||||
});
|
||||
|
||||
$(".card_qwikclock_jobs").on("click", ".job-btn", function () {
|
||||
var parent = $(this).parents(".card_app");
|
||||
var current = parent.find(".current-job");
|
||||
var url = parent.data("apiurl");
|
||||
$.post(url, {
|
||||
username: getuser(),
|
||||
password: getAPIKey(),
|
||||
action: "setjob",
|
||||
job: $(this).data("jobid")
|
||||
}, function (resp) {
|
||||
if (resp.status == "OK") {
|
||||
showmsg('<i class="fas fa-check"></i> ' + resp.msg, "success");
|
||||
} else {
|
||||
showmsg('<i class="fas fa-times"></i> ' + resp.msg, "danger");
|
||||
}
|
||||
dispCurrent(parent, current);
|
||||
}, "json");
|
||||
});
|
@ -0,0 +1,23 @@
|
||||
<!--
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
-->
|
||||
<style>
|
||||
.job-btn-bin {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.job-btn {
|
||||
margin: 5px 5px;
|
||||
}
|
||||
</style>
|
||||
<h3 class="card-header" style="background-color: #2196F3; color: white;"><i class="fas fa-briefcase"></i> <span class="card_title">QwikClock | Jobs</span></h3>
|
||||
<div class="card-body">
|
||||
<p>Current Job: <span class="current-job"></span>
|
||||
<p>Select a Job:</p>
|
||||
<div class="job-btn-bin" style="width: 100%;">
|
||||
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue