mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
More work on integrating the script-task.
This commit is contained in:
parent
3aca17ea6d
commit
1b67b84369
10 changed files with 2120 additions and 14 deletions
249
views/task-schedule.handlebars
Normal file
249
views/task-schedule.handlebars
Normal file
|
@ -0,0 +1,249 @@
|
|||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="scripts/common-0.0.1.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/public/tail.DateTime/tail.datetime-default-blue.min.css" />
|
||||
<style>
|
||||
body {
|
||||
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#scriptContent {
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
}
|
||||
|
||||
#schedContentC {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
#controlBar button {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#scriptNameC {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
#scriptName {
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
#controlBar {
|
||||
padding: 5px;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
#left {
|
||||
height: 100%;
|
||||
width: 25%;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#right {
|
||||
height: 100%;
|
||||
width: 75%;
|
||||
float: right;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #036;
|
||||
}
|
||||
|
||||
#intervalListC {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
#daysListC {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.rOpt {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
#daysListC {
|
||||
display: inline-grid;
|
||||
}
|
||||
|
||||
li {
|
||||
padding: 2px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onload="doOnLoad();">
|
||||
<script type="text/javascript" src="/public/tail.DateTime/tail.datetime.min.js"></script>
|
||||
<div id="scriptTaskSchedule">
|
||||
<div id="controlBar">
|
||||
<button onclick="goSave();">Schedule</button>
|
||||
<button onclick="goCancel();">Cancel</button>
|
||||
</div>
|
||||
<div id="schedContentC">
|
||||
<div id="left">
|
||||
<span class="oTitle">Recurrence</span>
|
||||
<ul id="intervalListC">
|
||||
<li><label><input onclick="intervalSelected(this);" type="radio" checked name="recur" value="once">Once</label></li>
|
||||
<li><label><input onclick="intervalSelected(this);" type="radio" name="recur" value="minutes">Minutes</label></li>
|
||||
<li><label><input onclick="intervalSelected(this);" type="radio" name="recur" value="hourly">Hourly</label></li>
|
||||
<li><label><input onclick="intervalSelected(this);" type="radio" name="recur" value="daily">Daily</label></li>
|
||||
<li><label><input onclick="intervalSelected(this);" type="radio" name="recur" value="weekly">Weekly</label></li>
|
||||
<!-- li><label><input type="radio" name="recur" value="monthly">Monthly</label></li -->
|
||||
</ul>
|
||||
</div>
|
||||
<div id="right">
|
||||
<div class="rOpt">
|
||||
<span class="oTitle">Start: </span>
|
||||
<input type="text" class="datePick" id="startDate" value="" />
|
||||
<input type="text" class="timePick" id="startTime" value="" />
|
||||
</div>
|
||||
<div class="rOpt" id="intervalC" style="display: none;">
|
||||
<span class="oTitle">Every: </span>
|
||||
<input type="text" id="interval" value="1" /> <span id="hintText"></span>
|
||||
</div>
|
||||
<div class="rOpt" id="endC" style="display: none;">
|
||||
<span class="oTitle">End: </span>
|
||||
<input type="text" class="datePick" id="endDate" value="" />
|
||||
<input type="text" class="timePick" id="endTime" value="" />
|
||||
<label><input type="checkbox" id="endNever" checked onclick="checkEndNever(this);" /> Never</label>
|
||||
</div>
|
||||
<div class="rOpt" id="daysC" style="display: none;">
|
||||
<span class="oTitle">Days: </span>
|
||||
<ul id="daysListC">
|
||||
<li><label><input type="checkbox" name="days[]" value="0"> Sunday</label></li>
|
||||
<li><label><input type="checkbox" name="days[]" value="1"> Monday</label></li>
|
||||
<li><label><input type="checkbox" name="days[]" value="2"> Tuesday</label></li>
|
||||
<li><label><input type="checkbox" name="days[]" value="3"> Wednesday</label></li>
|
||||
<li><label><input type="checkbox" name="days[]" value="4"> Thursday</label></li>
|
||||
<li><label><input type="checkbox" name="days[]" value="5"> Friday</label></li>
|
||||
<li><label><input type="checkbox" name="days[]" value="6"> Saturday</label></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
function checkEndNever(el) {
|
||||
if (el.checked) {
|
||||
Q('endDate').value = '';
|
||||
Q('endTime').value = '';
|
||||
}
|
||||
}
|
||||
function setTimePick() {
|
||||
var d = new Date();
|
||||
document.getElementById("startDate").value = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
|
||||
document.getElementById("startTime").value = d.getHours() + ':' + d.getMinutes();
|
||||
tail.DateTime(".datePick", { position: "bottom", dateStart: Date(), timeFormat: false });
|
||||
tail.DateTime(".timePick", { position: "bottom", dateFormat: false, timeFormat: "HH:ii", timeStepMinutes: 15 });
|
||||
tail.datetime.inst[document.getElementById('endDate').getAttribute('data-tail-datetime')].on('change', function () {
|
||||
document.getElementById('endNever').checked = false;
|
||||
});
|
||||
tail.datetime.inst[document.getElementById('endTime').getAttribute('data-tail-datetime')].on('change', function () {
|
||||
document.getElementById('endNever').checked = false;
|
||||
});
|
||||
}
|
||||
|
||||
function doOnLoad() {
|
||||
try {
|
||||
if (scriptId == null) {
|
||||
alert('Page reloaded and data lost. Please re-run scheduler from the main window.');
|
||||
goCancel();
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
alert('Page reloaded and data lost. Please re-run scheduler from the main window.');
|
||||
goCancel();
|
||||
return;
|
||||
}
|
||||
setTimePick();
|
||||
}
|
||||
|
||||
function intervalSelected(el) {
|
||||
var v = el.value;
|
||||
switch (v) {
|
||||
case 'once':
|
||||
QV('intervalC', false);
|
||||
QV('endC', false);
|
||||
QV('daysC', false);
|
||||
break;
|
||||
case 'minutes':
|
||||
QV('intervalC', true);
|
||||
QV('endC', true);
|
||||
QV('daysC', false);
|
||||
QH('hintText', 'minute(s)');
|
||||
break;
|
||||
case 'hourly':
|
||||
QV('intervalC', true);
|
||||
QV('endC', true);
|
||||
QV('daysC', false);
|
||||
QH('hintText', 'hour(s)');
|
||||
break;
|
||||
case 'daily':
|
||||
QV('intervalC', true);
|
||||
QV('endC', true);
|
||||
QV('daysC', false);
|
||||
QH('hintText', 'day(s)');
|
||||
break;
|
||||
case 'weekly':
|
||||
QV('intervalC', true);
|
||||
QV('endC', true);
|
||||
QV('daysC', true);
|
||||
QH('hintText', 'week(s)');
|
||||
break;
|
||||
}
|
||||
}
|
||||
function goSave() {
|
||||
var o = {};
|
||||
var recurEls = document.getElementsByName("recur");
|
||||
recurEls.forEach(function (el) {
|
||||
if (el.checked) o.recur = el.value;
|
||||
});
|
||||
switch (o.recur) {
|
||||
case 'once':
|
||||
o.startAt = Date.parse(Q('startDate').value + ' ' + Q('startTime').value);
|
||||
o.startAt = Math.floor(o.startAt / 1000);
|
||||
break;
|
||||
case 'minutes':
|
||||
case 'hourly':
|
||||
case 'daily':
|
||||
o.startAt = Date.parse(Q('startDate').value + ' ' + Q('startTime').value);
|
||||
o.startAt = Math.floor(o.startAt / 1000);
|
||||
o.interval = Number(Q('interval').value);
|
||||
if (Q('endNever').checked) o.endAt = null;
|
||||
else {
|
||||
o.endAt = Date.parse(Q('endDate').value + ' ' + Q('endTime').value);
|
||||
o.endAt = Math.floor(o.endAt / 1000);
|
||||
}
|
||||
break;
|
||||
case 'weekly':
|
||||
o.startAt = Date.parse(Q('startDate').value + ' ' + Q('startTime').value);
|
||||
o.startAt = Math.floor(o.startAt / 1000);
|
||||
o.interval = Number(Q('interval').value);
|
||||
if (Q('endNever').checked) o.endAt = null;
|
||||
else {
|
||||
o.endAt = Date.parse(Q('endDate').value + ' ' + Q('endTime').value);
|
||||
o.endAt = Math.floor(o.endAt / 1000);
|
||||
}
|
||||
var dayEls = document.getElementsByName("days[]");
|
||||
o.dayVals = [];
|
||||
if (dayEls.length) {
|
||||
dayEls.forEach(function (de) {
|
||||
if (de.checked) o.dayVals.push(de.value);
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
o.scriptId = scriptId;
|
||||
o.nodes = nodes;
|
||||
|
||||
window.opener.schedCallback(o);
|
||||
window.close();
|
||||
}
|
||||
|
||||
function goCancel() {
|
||||
window.close();
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
73
views/task-scriptedit.handlebars
Normal file
73
views/task-scriptedit.handlebars
Normal file
|
@ -0,0 +1,73 @@
|
|||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="scripts/common-0.0.1.js"></script>
|
||||
<style>
|
||||
body {
|
||||
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#scriptContent {
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
}
|
||||
|
||||
#scriptContentC {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
#controlBar button {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#scriptNameC {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
#scriptName {
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
#controlBar {
|
||||
padding: 5px;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #036;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onload="doOnLoad();">
|
||||
<div id="scriptTaskScriptEdit">
|
||||
<div id="scriptNameC">Script Name: <input type="text" value="" id="scriptName" /></div>
|
||||
<div id="controlBar">
|
||||
<button onclick="goSave();">Save</button>
|
||||
<button onclick="goClose();">Close</button>
|
||||
</div>
|
||||
<div id="scriptContentC">
|
||||
<textarea id="scriptContent"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var scriptData = {{{scriptData}}};
|
||||
|
||||
function doOnLoad() {
|
||||
//QH('scriptContent', scriptData.content);
|
||||
Q('scriptContent').value = scriptData.content;
|
||||
Q('scriptName').value = scriptData.name;
|
||||
}
|
||||
|
||||
function goSave() {
|
||||
scriptData.content = Q('scriptContent').value;
|
||||
scriptData.name = Q('scriptName').value;
|
||||
window.opener.callback(scriptData);
|
||||
//goClose();
|
||||
}
|
||||
|
||||
function goClose() {
|
||||
window.close();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
1070
views/task-user.handlebars
Normal file
1070
views/task-user.handlebars
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue