Autostart-Funktionalität implementiert: Crontab-Syntax, Scheduler und UI-Integration
This commit is contained in:
@ -157,12 +157,21 @@ class PCManager {
|
||||
</td>
|
||||
<td>${new Date(pc.created_at).toLocaleDateString('de-DE')}</td>
|
||||
<td>
|
||||
<div class="mb-1">
|
||||
<small class="text-muted">
|
||||
<i class="fas fa-clock"></i> Autostart:
|
||||
${pc.autostart_enabled ?
|
||||
`<span class="text-success">${this.escapeHtml(pc.autostart_cron || '30 7 * * Mon-Fri')}</span>` :
|
||||
'<span class="text-muted">Deaktiviert</span>'
|
||||
}
|
||||
</small>
|
||||
</div>
|
||||
<div class="btn-group" role="group">
|
||||
<button class="btn btn-success btn-sm" onclick="pcManager.wakePC(${pc.id})"
|
||||
title="PC aufwecken">
|
||||
<i class="fas fa-power-off"></i> Aufwecken
|
||||
</button>
|
||||
<button class="btn btn-warning btn-sm" onclick="pcManager.editPC(${pc.id}, '${this.escapeHtml(pc.name)}', '${this.escapeHtml(pc.mac)}', '${this.escapeHtml(pc.ip || '')}')"
|
||||
<button class="btn btn-warning btn-sm" onclick="pcManager.editPC(${pc.id}, '${this.escapeHtml(pc.name)}', '${this.escapeHtml(pc.mac)}', '${this.escapeHtml(pc.ip || '')}', '${this.escapeHtml(pc.autostart_cron || '')}', ${pc.autostart_enabled})"
|
||||
title="PC bearbeiten">
|
||||
<i class="fas fa-edit"></i> Bearbeiten
|
||||
</button>
|
||||
@ -183,9 +192,11 @@ class PCManager {
|
||||
const name = document.getElementById('pcName').value.trim();
|
||||
const mac = document.getElementById('macAddress').value.trim();
|
||||
const ip = document.getElementById('ipAddress').value.trim();
|
||||
const autostartCron = document.getElementById('autostartCron').value.trim();
|
||||
const autostartEnabled = document.getElementById('autostartEnabled').checked;
|
||||
|
||||
if (!name || !mac || !ip) {
|
||||
this.showNotification('Warnung', 'Bitte füllen Sie alle Felder aus', 'warning');
|
||||
this.showNotification('Warnung', 'Bitte füllen Sie alle Pflichtfelder aus', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -195,7 +206,13 @@ class PCManager {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ name, mac, ip })
|
||||
body: JSON.stringify({
|
||||
name,
|
||||
mac,
|
||||
ip,
|
||||
autostart_cron: autostartCron || '30 7 * * Mon-Fri',
|
||||
autostart_enabled: autostartEnabled
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
@ -212,12 +229,14 @@ class PCManager {
|
||||
}
|
||||
}
|
||||
|
||||
editPC(id, name, mac, ip) {
|
||||
editPC(id, name, mac, ip, autostartCron, autostartEnabled) {
|
||||
// Modal mit PC-Daten füllen
|
||||
document.getElementById('editPCId').value = id;
|
||||
document.getElementById('editPCName').value = name;
|
||||
document.getElementById('editMACAddress').value = mac;
|
||||
document.getElementById('editIPAddress').value = ip;
|
||||
document.getElementById('editAutostartCron').value = autostartCron || '30 7 * * Mon-Fri';
|
||||
document.getElementById('editAutostartEnabled').checked = autostartEnabled || false;
|
||||
|
||||
// Modal öffnen
|
||||
const editModal = new bootstrap.Modal(document.getElementById('editPCModal'));
|
||||
@ -229,9 +248,11 @@ class PCManager {
|
||||
const name = document.getElementById('editPCName').value.trim();
|
||||
const mac = document.getElementById('editMACAddress').value.trim();
|
||||
const ip = document.getElementById('editIPAddress').value.trim();
|
||||
const autostartCron = document.getElementById('editAutostartCron').value.trim();
|
||||
const autostartEnabled = document.getElementById('editAutostartEnabled').checked;
|
||||
|
||||
if (!name || !mac || !ip) {
|
||||
this.showNotification('Warnung', 'Bitte füllen Sie alle Felder aus', 'warning');
|
||||
this.showNotification('Warnung', 'Bitte füllen Sie alle Pflichtfelder aus', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -241,7 +262,13 @@ class PCManager {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ name, mac, ip })
|
||||
body: JSON.stringify({
|
||||
name,
|
||||
mac,
|
||||
ip,
|
||||
autostart_cron: autostartCron || '30 7 * * Mon-Fri',
|
||||
autostart_enabled: autostartEnabled
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
Reference in New Issue
Block a user