all main checbox are added with the same look as old script
need to fix the DattoRMM suboptions, add the dropdown for the site
This commit is contained in:
205
testTaskGate.ps1
205
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 = "<label><input type='checkbox' id='$($_.Id)' name='$($_.Name)' data-column='$Column'> $($_.Label)</label>"
|
||||
|
||||
# 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 {
|
||||
"<label style='margin-left:20px; display:block;'>
|
||||
<input type='checkbox' name='$($_.Value)' value='$($_.Value)'> $($_.Label)
|
||||
</label>"
|
||||
}
|
||||
) -join "`n"
|
||||
|
||||
$html += @"
|
||||
<div id='${($_.Id)}OptionsContainer' style='display:none; margin-top:4px;'>
|
||||
$subHtml
|
||||
</div>
|
||||
"@
|
||||
}
|
||||
|
||||
$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 = @"
|
||||
<h2>On-Boarding</h2>
|
||||
<h3 class="subtitle">This new deployment method ensures everything is successfully deployed with greater ease!</h3>
|
||||
|
||||
<!-- 1) Dynamic task checkboxes -->
|
||||
<div class="columns-container">
|
||||
<div class="checkbox-group column">
|
||||
<h3>SVSMSP Stack</h3>
|
||||
<label><input type="checkbox" id="selectAllLeftCheckbox" onclick="toggleColumn('left')"> Select All</label>
|
||||
{{onboardLeftColumn}}
|
||||
</div>
|
||||
<div class="checkbox-group column">
|
||||
<h3>Optional</h3>
|
||||
<label><input type="checkbox" id="selectAllRightCheckbox" onclick="toggleColumn('right')"> Select All</label>
|
||||
{{onboardRightColumn}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 1) password & fetch button -->
|
||||
<div id="PasswordContainer" style="margin-bottom:1em;">
|
||||
<label for="Password">Password:</label>
|
||||
@@ -481,27 +613,7 @@ $htmlTemplate = @"
|
||||
<div id="dattoRmmContainer" style="display:none; margin-bottom:1em;">
|
||||
<label for="dattoDropdown">Select Datto Site:</label>
|
||||
<select id="dattoDropdown"></select>
|
||||
</div>
|
||||
|
||||
<!-- 3) Your other static onboarding fields ↓
|
||||
Copy/paste one of these blocks for each option you need. -->
|
||||
<div id="customerNameContainer" style="margin-bottom:1em;">
|
||||
<label for="customerName">Customer Name:</label>
|
||||
<input type="text" id="customerName" placeholder="Acme Corp" />
|
||||
</div>
|
||||
|
||||
<div id="domainJoinContainer" style="margin-bottom:1em;">
|
||||
<label>
|
||||
<input type="checkbox" id="joinDomain" />
|
||||
Join computer to domain
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- 4) Dynamic task checkboxes -->
|
||||
<div class="columns-container">
|
||||
{{onboardCheckboxes}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="offboardTab" class="tab-content">
|
||||
<h2>Off-Boarding</h2>
|
||||
@@ -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 {
|
||||
"<label><input type='checkbox' id='$($_.Id)' name='$($_.Name)'> $($_.Label)</label>"
|
||||
}) -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user