Update TGBeta.ps1
This commit is contained in:
286
TGBeta.ps1
286
TGBeta.ps1
@@ -387,10 +387,10 @@ function GetHtmlContent {
|
|||||||
.logo-container {
|
.logo-container {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
background-color: #1e1e1e; /* Matches the background color */
|
background-color: #1e1e1e;
|
||||||
}
|
}
|
||||||
.logo-container img {
|
.logo-container img {
|
||||||
max-width: 300px; /* Adjust size as needed */
|
max-width: 300px;
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
.container {
|
.container {
|
||||||
@@ -494,7 +494,7 @@ function GetHtmlContent {
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="logo-container">
|
<div class="logo-container">
|
||||||
<img src="https://git.svstools.com/syelle/Logo/raw/branch/main/SVS_Logo.png" alt="SVS Logo">
|
<img src="https://git.svstools.com/syelle/Logo/raw/branch/main/SVS_Logo.png" alt="SVS Logo">
|
||||||
</div>
|
</div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@@ -565,21 +565,7 @@ function GetHtmlContent {
|
|||||||
<br><br>
|
<br><br>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="n8nPasswordContainer" style="display: none;">
|
|
||||||
<label for="n8nPassword">Enter n8n Password:</label><br>
|
|
||||||
<input type="password" id="n8nPassword" class="password-input" placeholder="Enter N8N Password">
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<div id="DattoRMMContainer" style="display: none;">
|
|
||||||
<label for="dattoRmmDropdown">Select a Datto RMM site:</label><br>
|
|
||||||
<select id="dattoRmmDropdown" class="dropdown">
|
|
||||||
<option value="">Fetching sites...</option>
|
|
||||||
$siteOptions
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="button-group">
|
<div class="button-group">
|
||||||
<button class="install-button" id="fetchSitesButton" onclick="fetchSites()" disabled>Fetch
|
|
||||||
Sites</button>
|
|
||||||
<button class="install-button" onclick="triggerInstall()">Install</button>
|
<button class="install-button" onclick="triggerInstall()">Install</button>
|
||||||
<button class="exit-button" onclick="endSession()">Exit</button>
|
<button class="exit-button" onclick="endSession()">Exit</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -589,261 +575,65 @@ function GetHtmlContent {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function toggleOnboardCheckboxes(selectedCheckbox) {
|
function toggleOnboardCheckboxes(selectAllCheckbox) {
|
||||||
const checkboxes = document.querySelectorAll('#onboardTab input[type="checkbox"]');
|
const checkboxes = document.querySelectorAll('.checkbox-group input[type="checkbox"]');
|
||||||
const dattoRMMCheckbox = document.getElementById('installDattoRMMCheckbox');
|
|
||||||
const optionsContainer = document.getElementById('dattoRMMOptionsContainer');
|
|
||||||
const n8nPasswordContainer = document.getElementById('n8nPasswordContainer');
|
|
||||||
const dattoRMMContainer = document.getElementById('DattoRMMContainer');
|
|
||||||
|
|
||||||
checkboxes.forEach(checkbox => {
|
checkboxes.forEach(checkbox => {
|
||||||
if (checkbox !== selectedCheckbox) {
|
if (checkbox !== selectAllCheckbox) {
|
||||||
checkbox.checked = selectedCheckbox.checked;
|
checkbox.checked = selectAllCheckbox.checked;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (dattoRMMCheckbox.checked) {
|
appendLog(selectAllCheckbox.checked ? "All checkboxes selected." : "All checkboxes deselected.", "cyan");
|
||||||
optionsContainer.style.display = 'block';
|
|
||||||
n8nPasswordContainer.style.display = 'block';
|
|
||||||
dattoRMMContainer.style.display = 'block';
|
|
||||||
} else {
|
|
||||||
optionsContainer.style.display = 'none';
|
|
||||||
n8nPasswordContainer.style.display = 'none';
|
|
||||||
dattoRMMContainer.style.display = 'none';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleDattoRMMOptions() {
|
function toggleDattoRMMOptions() {
|
||||||
const checkbox = document.getElementById('installDattoRMMCheckbox');
|
const dattoRMMCheckbox = document.getElementById('installDattoRMMCheckbox');
|
||||||
const optionsContainer = document.getElementById('dattoRMMOptionsContainer');
|
const optionsContainer = document.getElementById('dattoRMMOptionsContainer');
|
||||||
const n8nPasswordContainer = document.getElementById('n8nPasswordContainer');
|
optionsContainer.style.display = dattoRMMCheckbox.checked ? 'block' : 'none';
|
||||||
const DattoRMMContainer = document.getElementById('DattoRMMContainer');
|
appendLog(dattoRMMCheckbox.checked ? "Datto RMM options shown." : "Datto RMM options hidden.", "cyan");
|
||||||
|
|
||||||
optionsContainer.style.display = checkbox.checked ? 'block' : 'none';
|
|
||||||
n8nPasswordContainer.style.display = checkbox.checked ? 'block' : 'none';
|
|
||||||
DattoRMMContainer.style.display = checkbox.checked ? 'block' : 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
const tabButtons = document.querySelectorAll('.tab-button');
|
|
||||||
const tabContents = document.querySelectorAll('.tab-content');
|
|
||||||
const logArea = document.getElementById('logArea');
|
|
||||||
const fetchSitesButton = document.getElementById('fetchSitesButton');
|
|
||||||
const n8nPasswordInput = document.getElementById('n8nPassword');
|
|
||||||
|
|
||||||
tabButtons.forEach(button => {
|
|
||||||
button.addEventListener('click', () => {
|
|
||||||
tabButtons.forEach(btn => {
|
|
||||||
btn.classList.remove('active');
|
|
||||||
btn.setAttribute('aria-expanded', 'false');
|
|
||||||
});
|
|
||||||
tabContents.forEach(tab => tab.classList.remove('active'));
|
|
||||||
button.classList.add('active');
|
|
||||||
button.setAttribute('aria-expanded', 'true');
|
|
||||||
document.getElementById(button.dataset.tab).classList.add('active');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
n8nPasswordInput.addEventListener('input', () => {
|
|
||||||
fetchSitesButton.disabled = n8nPasswordInput.value.length < 4;
|
|
||||||
});
|
|
||||||
// Trigger fetchSites() on Enter key press
|
|
||||||
n8nPasswordInput.addEventListener('keydown', (event) => {
|
|
||||||
if (event.key === 'Enter' && n8nPasswordInput.value.length >= 4) {
|
|
||||||
fetchSites(); // Call the fetchSites function
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
async function fetchSites() {
|
|
||||||
const password = document.getElementById('n8nPassword').value;
|
|
||||||
const dropdown = document.getElementById('dattoRmmDropdown');
|
|
||||||
|
|
||||||
if (!password) {
|
|
||||||
appendLog("Please enter the n8n password.", "red");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
appendLog("Fetching sites...", "yellow");
|
|
||||||
|
|
||||||
const response = await fetch('/getn8npw', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({ password })
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error('Failed to fetch sites. Please try again.');
|
|
||||||
}
|
|
||||||
|
|
||||||
const sites = await response.json();
|
|
||||||
dropdown.innerHTML = '';
|
|
||||||
|
|
||||||
sites.forEach(site => {
|
|
||||||
const option = document.createElement('option');
|
|
||||||
// Adjust property names based on your actual data
|
|
||||||
option.value = site.UID;
|
|
||||||
option.textContent = site.Name;
|
|
||||||
dropdown.appendChild(option);
|
|
||||||
});
|
|
||||||
|
|
||||||
appendLog("Sites fetched successfully, please select a site!", "green");
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
dropdown.innerHTML = '<option value="">Fetching sites failed</option>';
|
|
||||||
appendLog('Error:' + error.message, "red");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function triggerInstall() {
|
function triggerInstall() {
|
||||||
const dropdown = document.getElementById('dattoRmmDropdown');
|
const checkboxes = document.querySelectorAll('.checkbox-group input[type="checkbox"]:checked');
|
||||||
const UID = dropdown && dropdown.options[dropdown.selectedIndex]
|
const selectedCheckboxes = Array.from(checkboxes).map(checkbox => checkbox.id);
|
||||||
? dropdown.options[dropdown.selectedIndex].value
|
|
||||||
: null;
|
|
||||||
const Name = dropdown && dropdown.options[dropdown.selectedIndex]
|
|
||||||
? dropdown.options[dropdown.selectedIndex].text
|
|
||||||
: "Unknown Site";
|
|
||||||
|
|
||||||
const setSVSPowerplan = document.querySelector('input[name="setSVSPowerplan"]');
|
if (selectedCheckboxes.includes('installDattoRMMCheckbox')) {
|
||||||
const installSVSMSPModule = document.querySelector('input[name="installSVSMSPModule"]');
|
const dattoRMMOptions = document.querySelectorAll('input[name="dattoRMMOption"]:checked');
|
||||||
const installDattoRMM = document.querySelector('input[name="installDattoRMM"]');
|
const dattoRMMValues = Array.from(dattoRMMOptions).map(option => option.value);
|
||||||
const installCyberQP = document.querySelector('input[name="installCyberQP"]');
|
|
||||||
const installSplashtop = document.querySelector('input[name="installSplashtop"]');
|
|
||||||
const installSVSHelpDesk = document.querySelector('input[name="installSVSHelpDesk"]');
|
|
||||||
const installSVSWatchtower = document.querySelector('input[name="installSVSWatchtower"]');
|
|
||||||
const installThreatLocker = document.querySelector('input[name="installThreatLocker"]');
|
|
||||||
const installRocketCyber = document.querySelector('input[name="installRocketCyber"]');
|
|
||||||
|
|
||||||
// Ensure UID is selected before proceeding
|
|
||||||
if (!UID) {
|
|
||||||
appendLog("Please select a site from the dropdown.", "red");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Install DattoRMM if checked
|
|
||||||
if (installDattoRMM.checked) {
|
|
||||||
const DattoRMMCheckbox = document.querySelectorAll('input[name="dattoRMMOption"]:checked');
|
|
||||||
appendLog("Installing selected site RMM...", "cyan");
|
|
||||||
|
|
||||||
const checkedValues = Array.from(DattoRMMCheckbox).map(c => c.value);
|
|
||||||
|
|
||||||
const payload = {
|
|
||||||
checkedValues, // Array of selected checkbox values
|
|
||||||
UID, // Selected site UID
|
|
||||||
Name // Selected site name
|
|
||||||
};
|
|
||||||
|
|
||||||
fetch('/installrmm', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify(payload)
|
|
||||||
})
|
|
||||||
.then(() => appendLog("Datto RMM installation triggered successfully.", "green"))
|
|
||||||
.catch(error => appendLog(`Error installing Datto RMM: ${error.message}`, "red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute lower-priority tasks sequentially
|
|
||||||
if (setSVSPowerplan.checked) {
|
|
||||||
fetch('/SetSVSPowerplan', { method: 'GET' })
|
|
||||||
.then(() => appendLog("SVS Powerplan set successfully.", "green"))
|
|
||||||
.catch(error => appendLog(`Error setting SVS Powerplan: ${error.message}`, "red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (installSVSMSPModule.checked) {
|
|
||||||
fetch('/installSVSMSPModule', { method: 'GET' })
|
|
||||||
.then(() => appendLog("SVSMSP Module installed successfully.", "green"))
|
|
||||||
.catch(error => appendLog(`Error installing SVSMSP Module: ${error.message}`, "red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (installCyberQP.checked) {
|
|
||||||
fetch('/installCyberQP', { method: 'GET' })
|
|
||||||
.then(() => appendLog("CyberQP installed successfully.", "green"))
|
|
||||||
.catch(error => appendLog(`Error installing CyberQP: ${error.message}`, "red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (installSplashtop.checked) {
|
|
||||||
fetch('/installSplashtop', { method: 'GET' })
|
|
||||||
.then(() => appendLog("Splashtop installed successfully.", "green"))
|
|
||||||
.catch(error => appendLog(`Error installing Splashtop: ${error.message}`, "red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (installSVSHelpDesk.checked) {
|
|
||||||
fetch('/installSVSHelpDesk', { method: 'GET' })
|
|
||||||
.then(() => appendLog("SVS HelpDesk installed successfully.", "green"))
|
|
||||||
.catch(error => appendLog(`Error installing SVS HelpDesk: ${error.message}`, "red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (installSVSWatchtower.checked) {
|
|
||||||
fetch('/installSVSWatchtower', { method: 'GET' })
|
|
||||||
.then(() => appendLog("SVS Watchtower installed successfully.", "green"))
|
|
||||||
.catch(error => appendLog(`Error installing SVS Watchtower: ${error.message}`, "red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (installThreatLocker.checked) {
|
|
||||||
fetch('/installThreatLocker', { method: 'GET' })
|
|
||||||
.then(() => appendLog("ThreatLocker installed successfully.", "green"))
|
|
||||||
.catch(error => appendLog(`Error installing ThreatLocker: ${error.message}`, "red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (installRocketCyber.checked) {
|
|
||||||
fetch('/installRocketCyber', { method: 'GET' })
|
|
||||||
.then(() => appendLog("RocketCyber installed successfully.", "green"))
|
|
||||||
.catch(error => appendLog(`Error installing RocketCyber: ${error.message}`, "red"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
appendLog(`Installing Datto RMM with options: ${dattoRMMValues.join(', ')}`, "cyan");
|
||||||
|
// Perform the Datto RMM installation logic here
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedCheckboxes.forEach(id => {
|
||||||
|
appendLog(`Task ${id} triggered.`, "green");
|
||||||
|
// Add specific logic for each checkbox task
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function appendLog(message, color = "white") {
|
||||||
|
const logArea = document.getElementById('logArea');
|
||||||
|
const logEntry = document.createElement('p');
|
||||||
|
logEntry.textContent = message;
|
||||||
|
logEntry.style.color = color;
|
||||||
|
logArea.appendChild(logEntry);
|
||||||
|
}
|
||||||
|
|
||||||
function endSession() {
|
function endSession() {
|
||||||
appendLog("Session ended. Closing application...", "yellow");
|
appendLog("Session ended. Closing application...", "yellow");
|
||||||
fetch('/quit', { method: 'GET' })
|
fetch('/quit', { method: 'GET' })
|
||||||
.then(response => {
|
.then(() => {
|
||||||
if (!response.ok) {
|
window.close();
|
||||||
throw new Error('Failed to end session');
|
})
|
||||||
}
|
.catch(error => {
|
||||||
window.close();
|
appendLog(`Error ending session: ${error.message}`, "red");
|
||||||
})
|
});
|
||||||
.catch(error => {
|
|
||||||
appendLog("Error ending session: " + error.message, "red");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendLog(message, color = "white") {
|
|
||||||
const log = document.createElement('p');
|
|
||||||
log.style.color = color;
|
|
||||||
log.textContent = message;
|
|
||||||
document.getElementById('logArea').appendChild(log);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// 3) POLL THE SERVER LOGS (NEW)
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
let lastLogCount = 0;
|
|
||||||
async function fetchLogs() {
|
|
||||||
try {
|
|
||||||
const resp = await fetch('/getLogs');
|
|
||||||
if (!resp.ok) return;
|
|
||||||
const logs = await resp.json(); // array of {Timestamp, Level, Message}
|
|
||||||
|
|
||||||
// Append only new messages
|
|
||||||
for (let i = lastLogCount; i < logs.length; i++) {
|
|
||||||
// We'll display each new line in "white" or a color of your choice
|
|
||||||
appendLog(logs[i].Message, "white");
|
|
||||||
}
|
|
||||||
lastLogCount = logs.length;
|
|
||||||
} catch (err) {
|
|
||||||
console.error("Error fetching logs:", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Poll logs every 3 seconds (feel free to adjust)
|
|
||||||
setInterval(fetchLogs, 3000);
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
"@
|
"@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user