Update samy.ps1
This commit is contained in:
230
samy.ps1
230
samy.ps1
@@ -9,6 +9,7 @@ Invoke-installprinters you can uncomment whatif in the function
|
|||||||
|
|
||||||
# SAMY asset config (change branch or base once and it updates everything)
|
# SAMY asset config (change branch or base once and it updates everything)
|
||||||
$Script:SamyBranch = 'beta' # or 'main'
|
$Script:SamyBranch = 'beta' # or 'main'
|
||||||
|
line 268 - 281
|
||||||
|
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Script Automation Monkey (SAMY) is a unified MSP assistant that automates onboarding, headless offboarding,
|
Script Automation Monkey (SAMY) is a unified MSP assistant that automates onboarding, headless offboarding,
|
||||||
@@ -283,6 +284,9 @@ $ConfirmPreference = 'None'
|
|||||||
$Script:SamyFaviconUrl = "$Script:SamyRepoBase/$Script:SamyBranch/SVS_Favicon.ico"
|
$Script:SamyFaviconUrl = "$Script:SamyRepoBase/$Script:SamyBranch/SVS_Favicon.ico"
|
||||||
$Script:SamyCssUrl = "$Script:SamyRepoBase/$Script:SamyBranch/samy.css?raw=1"
|
$Script:SamyCssUrl = "$Script:SamyRepoBase/$Script:SamyBranch/samy.css?raw=1"
|
||||||
$Script:SamyJsUrl = "$Script:SamyRepoBase/$Script:SamyBranch/samy.js?raw=1"
|
$Script:SamyJsUrl = "$Script:SamyRepoBase/$Script:SamyBranch/samy.js?raw=1"
|
||||||
|
$Script:SamyHtmlUrl = "$Script:SamyRepoBase/$Script:SamyBranch/samy.html?raw=1"
|
||||||
|
$Script:SamyHintText = ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Initialize a global in-memory log cache
|
# Initialize a global in-memory log cache
|
||||||
@@ -1094,11 +1098,24 @@ function Get-UIHtml {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# 3) Pull CSS/JS from Gitea and inline them
|
# 3) Pull CSS/JS/HTML from Gitea and inline them
|
||||||
#
|
#
|
||||||
$cssContent = Get-RemoteText -Url $Script:SamyCssUrl
|
$cssContent = Get-RemoteText -Url $Script:SamyCssUrl
|
||||||
$jsContent = Get-RemoteText -Url $Script:SamyJsUrl
|
$jsContent = Get-RemoteText -Url $Script:SamyJsUrl
|
||||||
|
$htmlTemplate = Get-RemoteText -Url $Script:SamyHtmlUrl
|
||||||
|
|
||||||
|
|
||||||
|
if (-not $htmlTemplate) {
|
||||||
|
# Hard fail or fallback, your call.
|
||||||
|
# This keeps the UI from becoming blank if the repo is unreachable.
|
||||||
|
Write-LogHybrid "UI template download failed. Returning minimal error page." Error UI -LogToEvent
|
||||||
|
return "<html><body style='font-family:Segoe UI; padding:20px; background:#111; color:#ddd;'>
|
||||||
|
<h2>SAMY UI template unavailable</h2>
|
||||||
|
<p>Could not download samy.html from repo.</p>
|
||||||
|
</body></html>"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optional: inject background override into CSS (same as you had)
|
||||||
if ($cssContent) {
|
if ($cssContent) {
|
||||||
$cssContent += @"
|
$cssContent += @"
|
||||||
|
|
||||||
@@ -1109,211 +1126,18 @@ function Get-UIHtml {
|
|||||||
"@
|
"@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# 4) HTML template - **no external link/script src** anymore, all inlined
|
# 4) Replace placeholders (unchanged vs your version)
|
||||||
#
|
|
||||||
$htmlTemplate = @"
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
||||||
<title>Script Automation Monkey</title>
|
|
||||||
<link rel="icon" href="$Script:SamyFaviconUrl">
|
|
||||||
|
|
||||||
<style>
|
|
||||||
$cssContent
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="logo-container">
|
|
||||||
<!-- SVS Logo (left) -->
|
|
||||||
<div class="logo-left">
|
|
||||||
<img src="$Script:SamyTopLogoUrl" alt="SVS Logo">
|
|
||||||
{{moduleVersion}}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Centered rotating tagline -->
|
|
||||||
<div id="tagline" class="tagline">
|
|
||||||
Script Automation Monkey (Yeah!)
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Big red line under tagline -->
|
|
||||||
<div id="samyHint" class="samy-hint"></div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div class="sidebar">
|
|
||||||
<button class="tab-button" data-tab="onboardTab">On-Boarding</button>
|
|
||||||
<button class="tab-button" data-tab="offboardTab">Off-Boarding</button>
|
|
||||||
<button class="tab-button" data-tab="tweaksTab">Tweaks</button>
|
|
||||||
<button class="tab-button" data-tab="SVSAppsTab">SVS APPs</button>
|
|
||||||
<button class="tab-button" data-tab="devicesTab">Devices</button>
|
|
||||||
|
|
||||||
<div id="status-box" style="margin-top: 1em; font-family: monospace;"></div>
|
|
||||||
</div>
|
|
||||||
<div class="content">
|
|
||||||
<div id="onboardTab" class="tab-content">
|
|
||||||
<h2>On-Boarding</h2>
|
|
||||||
<h3 class="subtitle">This new deployment method ensures everything is successfully deployed with greater ease!</h3>
|
|
||||||
|
|
||||||
<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}}
|
|
||||||
|
|
||||||
<!-- Rename Computer Option -->
|
|
||||||
<div class="option">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="chkRenameComputer" data-column="right">
|
|
||||||
Rename Computer
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="renameComputerBlock" style="display:none; margin-left: 24px; margin-top: 6px;">
|
|
||||||
<label for="txtNewComputerName">New computer name:</label>
|
|
||||||
<input type="text" id="txtNewComputerName" placeholder="e.g. CORP-LAP-123" />
|
|
||||||
<small style="display:block; margin-top:4px;">
|
|
||||||
(Max 15 chars; letters, numbers, and hyphens only.)
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="PasswordContainer" style="display:none; margin-bottom:1em;">
|
|
||||||
<label for="Password">Enter Password:</label>
|
|
||||||
<div style="display:flex; gap:5px;">
|
|
||||||
<input type="password" id="Password" placeholder="Enter Password" style="flex:1;" />
|
|
||||||
<button onclick="fetchSites()" class="go-button">GO!</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="dattoRmmContainer" style="display:none; margin-bottom:1em;">
|
|
||||||
<label for="dattoDropdown">Select a Datto RMM site:</label>
|
|
||||||
<select id="dattoDropdown" style="width:100%;">
|
|
||||||
<option disabled selected>Fetching sites...</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div> <!-- end onboardTab -->
|
|
||||||
|
|
||||||
<div id="offboardTab" class="tab-content">
|
|
||||||
<h2>Off-Boarding</h2>
|
|
||||||
<div class="columns-container">
|
|
||||||
<div class="checkbox-group column">
|
|
||||||
<h3>Remove Stack</h3>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="offboardSelectAll" onclick="toggleOffboardAll()">
|
|
||||||
Select All
|
|
||||||
</label>
|
|
||||||
{{offboardCheckboxes}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="tweaksTab" class="tab-content">
|
|
||||||
<h2>Tweaks</h2>
|
|
||||||
<div class="columns-container">
|
|
||||||
<div class="checkbox-group column">
|
|
||||||
<h3>Tweaks</h3>
|
|
||||||
{{tweaksCheckboxes}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="SVSAppsTab" class="tab-content">
|
|
||||||
<h2>SVS APPs</h2>
|
|
||||||
<div class="columns-container">
|
|
||||||
<div class="checkbox-group column">
|
|
||||||
<h3>Applications</h3>
|
|
||||||
{{appsCheckboxes}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- NEW: Devices tab for printers and future stuff -->
|
|
||||||
<div id="devicesTab" class="tab-content">
|
|
||||||
<h2>Devices</h2>
|
|
||||||
<h3 class="subtitle">Manage printers and other client devices.</h3>
|
|
||||||
|
|
||||||
<!-- Printer password + fetch -->
|
|
||||||
<div id="printerPasswordContainer" style="margin-bottom:1em;">
|
|
||||||
<label for="PrinterPassword">Enter Printer Password:</label>
|
|
||||||
<div style="display:flex; gap:5px;">
|
|
||||||
<input type="password"
|
|
||||||
id="PrinterPassword"
|
|
||||||
placeholder="Enter printer password"
|
|
||||||
style="flex:1;" />
|
|
||||||
<button onclick="fetchPrinters()" class="go-button">Get Printers</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Client code dropdown -->
|
|
||||||
<div id="printerClientContainer" style="display:none; margin-bottom:1em;">
|
|
||||||
<label for="printerClientDropdown">Select Client:</label>
|
|
||||||
<select id="printerClientDropdown" style="width:100%;">
|
|
||||||
<option disabled selected>Fetch printers first...</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Printer checkbox list -->
|
|
||||||
<div id="printerListContainer" style="display:none; margin-bottom:1em;">
|
|
||||||
<label>Printers for selected client:</label>
|
|
||||||
<small style="display:block; margin-bottom:4px; opacity:0.8;">
|
|
||||||
Check the printers to install, and mark one as "Make default" (optional).
|
|
||||||
</small>
|
|
||||||
|
|
||||||
<div id="printerCheckboxContainer"
|
|
||||||
style="max-height:200px; overflow-y:auto; border:1px solid #444; padding:6px; border-radius:4px;">
|
|
||||||
<!-- Populated by JS -->
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button id="installPrintersButton"
|
|
||||||
class="btn btn-success"
|
|
||||||
style="margin-top:8px;"
|
|
||||||
onclick="installSelectedPrinters()">
|
|
||||||
Install Selected Printers
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Tiny inline bridge: pass dynamic data, then inline JS from Gitea -->
|
|
||||||
<script>
|
|
||||||
window.SAMY_TASKS = [
|
|
||||||
{{tasksJsAll}}
|
|
||||||
];
|
|
||||||
|
|
||||||
window.SAMY_DEFAULT_PAGE = "{{defaultPage}}";
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$jsContent
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<!-- Floating button group -->
|
|
||||||
<div class="fixed-buttons">
|
|
||||||
<button class="exit-button" onclick="endSession()">Exit</button>
|
|
||||||
<button class="run-button" onclick="triggerInstall()">Run Selected</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
"@
|
|
||||||
|
|
||||||
#
|
|
||||||
# 5) Replace placeholders (unchanged vs your version)
|
|
||||||
#
|
#
|
||||||
$html = $htmlTemplate
|
$html = $htmlTemplate
|
||||||
|
|
||||||
|
$html = $html.Replace('{{CssContent}}', $cssContent)
|
||||||
|
$html = $html.Replace('{{JsContent}}', $jsContent)
|
||||||
|
|
||||||
|
$html = $html.Replace('{{SamyFaviconUrl}}', $Script:SamyFaviconUrl)
|
||||||
|
$html = $html.Replace('{{SamyTopLogoUrl}}', $Script:SamyTopLogoUrl)
|
||||||
|
$html = $html.Replace('{{SamyHintText}}', $Script:SamyHintText)
|
||||||
|
|
||||||
$html = $html.Replace('{{moduleVersion}}', (Get-ModuleVersionHtml))
|
$html = $html.Replace('{{moduleVersion}}', (Get-ModuleVersionHtml))
|
||||||
$html = $html.Replace('{{onboardLeftColumn}}', $onboardLeft)
|
$html = $html.Replace('{{onboardLeftColumn}}', $onboardLeft)
|
||||||
$html = $html.Replace('{{onboardRightColumn}}', $onboardRight)
|
$html = $html.Replace('{{onboardRightColumn}}', $onboardRight)
|
||||||
|
|||||||
Reference in New Issue
Block a user