From 56cd2fbde13c2fcf0d389ea2ee134f09b86efb26 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Thu, 22 May 2025 21:13:12 -0400 Subject: [PATCH] all main checbox are added with the same look as old script need to fix the DattoRMM suboptions, add the dropdown for the site --- testTaskGate.ps1 | 205 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 161 insertions(+), 44 deletions(-) diff --git a/testTaskGate.ps1 b/testTaskGate.ps1 index 017465b..c60ec05 100644 --- a/testTaskGate.ps1 +++ b/testTaskGate.ps1 @@ -9,12 +9,29 @@ $Port = 8081 # Label → user-visible text # HandlerFn → the PowerShell function to invoke # Page → which tab/page it appears on -$Global:Tasks = @( - # On-Boarding - @{ Id='setSVSPowerplan'; Name='setSVSPowerplan'; Label='Set SVS Powerplan'; HandlerFn='Set-SVSPowerPlan'; Page='onboard' }, - @{ Id='installSVSMSPModule'; Name='installSVSMSPModule'; Label='Install SVSMSP Module'; HandlerFn='Install-SVSMSPModule'; Page='onboard' }, - @{ Id='installCyberQP'; Name='installCyberQP'; Label='Install CyberQP'; HandlerFn='Install-CyberQP'; Page='onboard' }, +$Global:Tasks = @( + # On-Boarding, left column + @{ Id='setSVSPowerplan'; Name='setSVSPowerplan'; Label='Set SVS Powerplan'; HandlerFn='Set-SVSPowerPlan'; Page='onboard'; Column='left' }, + @{ Id='installSVSMSPModule'; Name='installSVSMSPModule'; Label='Install SVSMSP Module'; HandlerFn='Install-SVSMSPModule'; Page='onboard'; Column='left' }, + @{ Id='installCyberQP'; Name='installCyberQP'; Label='Install CyberQP'; HandlerFn='Install-CyberQP'; Page='onboard'; Column='left' }, + @{ Id='installSplashtop'; Name='installSplashtop'; Label='Install Splashtop'; HandlerFn='Install-Splashtop'; Page='onboard'; Column='left' }, + @{ Id='installSVSHelpDesk'; Name='installSVSHelpDesk'; Label='Install SVS HelpDesk'; HandlerFn='Install-SVSHelpDesk'; Page='onboard'; Column='left' }, + @{ Id='installThreatLocker'; Name='installThreatLocker'; Label='Install ThreatLocker'; HandlerFn='Install-ThreatLocker'; Page='onboard'; Column='left' }, + @{ Id='installRocketCyber'; Name='installRocketCyber'; Label='Install RocketCyber'; HandlerFn='Install-RocketCyber'; Page='onboard'; Column='left' }, + @{ Id='installDattoRMM'; Name='installDattoRMM'; Label='Install DattoRMM'; HandlerFn='Handle-InstallRMM'; Page='onboard'; Column='left'; + SubOptions= @( + @{ Value='inputVar'; Label='Copy Site Variables' }, + @{ Value='rmm'; Label='Install DRMM Agent' }, + @{ Value='exe'; Label='Download .exe' } + ) + }, + + + # On-Boarding, right column (optional bits) + @{ Id='enableBitLocker'; Name='EnableBitLocker'; Label='Enable BitLocker'; HandlerFn='Set-SVSBitLocker'; Page='onboard'; Column='right' }, + @{ Id='setEdgeDefaultSearch';Name='setedgedefaultsearch';Label='Set Edge Default Search';HandlerFn='set-EdgeDefaultSearchProvider';Page='onboard'; Column='right' }, + # Off-Boarding @{ Id='uninstallCyberQP'; Name='uninstallCyberQP'; Label='Uninstall CyberQP'; HandlerFn='Uninstall-CyberQP'; Page='offboard' }, @{ Id='uninstallSVSMSPModule';Name='uninstallSVSMSPModule';Label='Uninstall SVSMSP Module'; HandlerFn='Cleanup-SVSMSP'; Page='offboard' }, @@ -243,6 +260,44 @@ function Install-WingetLastPass { #region UI Generation +function Build-Checkboxes { + param($Page, $Column) + + ( + $Global:Tasks | + Where-Object Page -EQ $Page | + Where-Object Column -EQ $Column | + ForEach-Object { + # 1) render the main checkbox + $html = "" + + # 2) if this task has SubOptions, render them in a hidden container + if ($_.SubOptions) { + + Write-Host "👉 Rendering SubOptions for task $($_.Id)" + + $subHtml = ( + $_.SubOptions | ForEach-Object { + "" + } + ) -join "`n" + + $html += @" + +"@ + } + + $html + } + ) -join "`n" +} + + + function Get-UIHtml { param([string]$Page = 'onboard') @@ -338,6 +393,17 @@ $style = @' .columns-container { display:flex; gap:20px; flex-wrap:wrap; align-items:flex-start; } + + /* column styling, same as old script */ + .column { + flex: 1; /* fill available space */ + max-width: 45%; /* or whatever width you like */ + border: 2px solid var(--border-color); + border-radius: 8px; + padding: 10px; + background-color: var(--dark-gray-color); + box-shadow: 0 4px 6px rgba(0,0,0,0.3); + } .checkbox-group label { display:flex; align-items:center; margin-bottom:8px; } @@ -383,6 +449,57 @@ $style = @' {{tasksJsAll}} ]; + // ======================================================================= + // Column “Select All” toggling for On-Boarding + // ======================================================================= + function toggleColumn(col) { + const master = document.getElementById( + `selectAll${col[0].toUpperCase() + col.slice(1)}Checkbox` + ); + document + .querySelectorAll( + `#onboardTab input[type=checkbox][data-column=${col}]` + ) + .forEach(cb => (cb.checked = master.checked)); + } + + // ======================================================================= + // Un‐check “Select All” if any child is unchecked (& re‐check if all are checked) + // ======================================================================= + function updateSelectAll(col) { + const master = document.getElementById( + `selectAll${col[0].toUpperCase() + col.slice(1)}Checkbox` + ); + const children = document.querySelectorAll( + `#onboardTab input[type=checkbox][data-column=${col}]` + ); + master.checked = Array.from(children).every(cb => cb.checked); + } + + // Attach listeners on load + ['left','right'].forEach(col => { + document + .querySelectorAll(`#onboardTab input[type=checkbox][data-column=${col}]`) + .forEach(cb => cb.addEventListener('change', () => updateSelectAll(col))); + }); + + // ======================================================================= + // DattoRMM Options + // ======================================================================= + function toggleDattoRMMOptions() { + const master = document.getElementById('installDattoRMM'); + const container = document.getElementById('installDattoRMMOptionsContainer'); + if (!container) return; + container.style.display = master.checked ? 'block' : 'none'; + container.querySelectorAll('input[type="checkbox"]').forEach(cb => cb.checked = master.checked); + } + + document.addEventListener('DOMContentLoaded', () => { + const master = document.getElementById('installDattoRMM'); + if (master) master.addEventListener('change', toggleDattoRMMOptions); + }); + + // ======================================================================= // Fetch Sites Handler // ======================================================================= @@ -470,6 +587,21 @@ $htmlTemplate = @"

On-Boarding

This new deployment method ensures everything is successfully deployed with greater ease!

+ +
+
+

SVSMSP Stack

+ + {{onboardLeftColumn}} +
+
+

Optional

+ + {{onboardRightColumn}} +
+
+ +
@@ -481,27 +613,7 @@ $htmlTemplate = @" - - -
- - -
- -
- -
- - -
- {{onboardCheckboxes}} -
-
+

Off-Boarding

@@ -540,31 +652,36 @@ $htmlTemplate = @" # # 4) Build the checkbox HTML and tasks JS from $Global:Tasks # - $build = { - param($page) - ($Global:Tasks | Where Page -EQ $page | ForEach-Object { - "" - }) -join "`n" - } - $onboard = & $build 'onboard' - $offboard = & $build 'offboard' - $tweaks = & $build 'tweaks' - $apps = & $build 'SVSApps' - $tasksJsAll = ($Global:Tasks | ForEach-Object { - " { id: '$($_.Id)', handler: '/$($_.Name)', label: '$($_.Label)' }" - }) -join ",`n" + # On-boarding now has two columns: + $onboardLeft = Build-Checkboxes -Page 'onboard' -Column 'left' + $onboardRight = Build-Checkboxes -Page 'onboard' -Column 'right' + + # Off-boarding, Tweaks, SVSApps stay one-column: + $offboard = Build-Checkboxes -Page 'offboard' -Column '' + $tweaks = Build-Checkboxes -Page 'tweaks' -Column '' + $apps = Build-Checkboxes -Page 'SVSApps' -Column '' + + # Tasks JS array (fixed) + $tasksJsAll = ( + $Global:Tasks | ForEach-Object { + " { id: '$($_.Id)', handler: '/$($_.Name)', label: '$($_.Label)' }" + } + ) -join ",`n" + # # 5) Inject into template # $html = $htmlTemplate - $html = $html.Replace('{{onboardCheckboxes}}', $onboard) + $html = $html.Replace('{{onboardLeftColumn}}', $onboardLeft) + $html = $html.Replace('{{onboardRightColumn}}', $onboardRight) $html = $html.Replace('{{offboardCheckboxes}}', $offboard) - $html = $html.Replace('{{tweaksCheckboxes}}', $tweaks) - $html = $html.Replace('{{appsCheckboxes}}', $apps) - $html = $html.Replace('{{tasksJsAll}}', $tasksJsAll) - $html = $html.Replace('{{defaultPage}}', $Page) + $html = $html.Replace('{{tweaksCheckboxes}}', $tweaks) + $html = $html.Replace('{{appsCheckboxes}}', $apps) + $html = $html.Replace('{{tasksJsAll}}', $tasksJsAll) + $html = $html.Replace('{{defaultPage}}', $Page) + return $html }