Update TGBeta.ps1
This commit is contained in:
50
TGBeta.ps1
50
TGBeta.ps1
@@ -349,7 +349,7 @@ try {
|
||||
}
|
||||
#endregion
|
||||
|
||||
function Get-WebhookData {
|
||||
function Get-N8nWebhookData {
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$AuthHeaderValue
|
||||
@@ -360,8 +360,6 @@ function Get-WebhookData {
|
||||
}
|
||||
try {
|
||||
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method Get
|
||||
Write-Host "Webhook response raw JSON: $($response | ConvertTo-Json -Depth 4)" -ForegroundColor Cyan
|
||||
|
||||
Write-Host "Response received successfully:" -ForegroundColor Green
|
||||
$data = $response
|
||||
$global:Comment_SVSmodule = $data._Comment_SVSmodule
|
||||
@@ -511,7 +509,7 @@ function GetHtmlContent {
|
||||
color: var(--white-color);
|
||||
}
|
||||
|
||||
#PasswordContainer {
|
||||
#n8nPasswordContainer {
|
||||
display: none;
|
||||
margin-top: 20px;
|
||||
}
|
||||
@@ -668,9 +666,9 @@ function GetHtmlContent {
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div id="PasswordContainer" style="display: none;">
|
||||
<label for="Password">Enter Password:</label><br>
|
||||
<input type="password" id="Password" class="password-input" placeholder="Enter Password">
|
||||
<div id="n8nPasswordContainer" style="display: none;">
|
||||
<label for="n8nPassword">Enter Password:</label><br>
|
||||
<input type="password" id="n8nPassword" class="password-input" placeholder="Enter Password">
|
||||
</div>
|
||||
<br>
|
||||
<div id="DattoRMMContainer" style="display: none;">
|
||||
@@ -907,15 +905,15 @@ function GetHtmlContent {
|
||||
function toggleDattoRMMVisibility() {
|
||||
const dattoRMMCheckbox = document.getElementById('installDattoRMMCheckbox');
|
||||
const optionsContainer = document.getElementById('dattoRMMOptionsContainer');
|
||||
const PasswordContainer = document.getElementById('PasswordContainer');
|
||||
const n8nPasswordContainer = document.getElementById('n8nPasswordContainer');
|
||||
const dattoRMMContainer = document.getElementById('DattoRMMContainer');
|
||||
if (dattoRMMCheckbox.checked) {
|
||||
optionsContainer.style.display = 'block';
|
||||
PasswordContainer.style.display = 'block';
|
||||
n8nPasswordContainer.style.display = 'block';
|
||||
dattoRMMContainer.style.display = 'block';
|
||||
} else {
|
||||
optionsContainer.style.display = 'none';
|
||||
PasswordContainer.style.display = 'none';
|
||||
n8nPasswordContainer.style.display = 'none';
|
||||
dattoRMMContainer.style.display = 'none';
|
||||
}
|
||||
}
|
||||
@@ -1081,19 +1079,19 @@ function GetHtmlContent {
|
||||
function toggleDattoRMMOptions() {
|
||||
const dattoRMMCheckbox = document.getElementById('installDattoRMMCheckbox');
|
||||
const optionsContainer = document.getElementById('dattoRMMOptionsContainer');
|
||||
const PasswordContainer = document.getElementById('PasswordContainer');
|
||||
const n8nPasswordContainer = document.getElementById('n8nPasswordContainer');
|
||||
const dattoRMMContainer = document.getElementById('DattoRMMContainer');
|
||||
const subCheckboxes = document.querySelectorAll('#dattoRMMOptionsContainer input[type="checkbox"]');
|
||||
if (dattoRMMCheckbox.checked) {
|
||||
optionsContainer.style.display = 'block';
|
||||
PasswordContainer.style.display = 'block';
|
||||
n8nPasswordContainer.style.display = 'block';
|
||||
dattoRMMContainer.style.display = 'block';
|
||||
subCheckboxes.forEach(subCheckbox => {
|
||||
subCheckbox.checked = true;
|
||||
});
|
||||
} else {
|
||||
optionsContainer.style.display = 'none';
|
||||
PasswordContainer.style.display = 'none';
|
||||
n8nPasswordContainer.style.display = 'none';
|
||||
dattoRMMContainer.style.display = 'none';
|
||||
subCheckboxes.forEach(subCheckbox => {
|
||||
subCheckbox.checked = false;
|
||||
@@ -1178,33 +1176,33 @@ function GetHtmlContent {
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// SECTION: Password Input and Fetch Sites Button
|
||||
// SECTION: n8n Password Input and Fetch Sites Button
|
||||
// =======================================================================
|
||||
const logArea = document.getElementById('logArea');
|
||||
const fetchSitesButton = document.getElementById('fetchSitesButton');
|
||||
const PasswordInput = document.getElementById('Password');
|
||||
PasswordInput.addEventListener('input', () => {
|
||||
fetchSitesButton.disabled = PasswordInput.value.length < 4;
|
||||
const n8nPasswordInput = document.getElementById('n8nPassword');
|
||||
n8nPasswordInput.addEventListener('input', () => {
|
||||
fetchSitesButton.disabled = n8nPasswordInput.value.length < 4;
|
||||
});
|
||||
PasswordInput.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'Enter' && PasswordInput.value.length >= 12) {
|
||||
n8nPasswordInput.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'Enter' && n8nPasswordInput.value.length >= 12) {
|
||||
fetchSites();
|
||||
}
|
||||
});
|
||||
|
||||
// =======================================================================
|
||||
// SECTION: Fetch Sites from
|
||||
// SECTION: Fetch Sites from n8n
|
||||
// =======================================================================
|
||||
async function fetchSites() {
|
||||
const password = document.getElementById('Password').value;
|
||||
const password = document.getElementById('n8nPassword').value;
|
||||
const dropdown = document.getElementById('dattoRmmDropdown');
|
||||
if (!password) {
|
||||
appendLog("Please enter the password.", "red");
|
||||
appendLog("Please enter the n8n password.", "red");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
appendLog("Fetching sites...", "yellow");
|
||||
const response = await fetch('/getpw', {
|
||||
const response = await fetch('/getn8npw', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ password })
|
||||
@@ -1420,14 +1418,14 @@ try {
|
||||
$response.OutputStream.Write($buffer, 0, $buffer.Length)
|
||||
$response.OutputStream.Close()
|
||||
}
|
||||
"/getpw" {
|
||||
"/getn8npw" {
|
||||
if ($request.HttpMethod -eq "POST") {
|
||||
try {
|
||||
$bodyStream = New-Object IO.StreamReader $request.InputStream
|
||||
$body = $bodyStream.ReadToEnd()
|
||||
$data = ConvertFrom-Json $body
|
||||
$password = $data.password
|
||||
Get-WebhookData -AuthHeaderValue $password
|
||||
Get-N8nWebhookData -AuthHeaderValue $password
|
||||
$sites = Install-DattoRMM-Helper -ApiUrl $ApiUrl -ApiKey $ApiKey -ApiSecretKey $ApiSecretKey -FetchSitesOnly
|
||||
if (-not $sites) {
|
||||
Write-Host "No sites returned. Please check the API." -ForegroundColor Red
|
||||
@@ -1444,7 +1442,7 @@ try {
|
||||
$response.OutputStream.Write($buffer, 0, $buffer.Length)
|
||||
$response.OutputStream.Close()
|
||||
} catch {
|
||||
Write-LogHybrid -Message "Error processing /getpw: $($_.Exception.Message)" -Level "Error"
|
||||
Write-LogHybrid -Message "Error processing /getn8npw: $($_.Exception.Message)" -Level "Error"
|
||||
$response.StatusCode = 500
|
||||
$buffer = [System.Text.Encoding]::UTF8.GetBytes("Error: Failed to process the request.")
|
||||
$response.OutputStream.Write($buffer, 0, $buffer.Length)
|
||||
|
||||
Reference in New Issue
Block a user