display FQDN keying + kiosk dropdown + dispatcher + multi-word search
This commit is contained in:
@@ -298,6 +298,42 @@ def _sync_access_methods(comp, data):
|
||||
# Computers CRUD
|
||||
# =============================================================================
|
||||
|
||||
@computers_bp.route('/display-kiosks', methods=['GET'])
|
||||
@jwt_required(optional=True)
|
||||
def list_display_kiosks():
|
||||
"""Reporting display kiosks, for the Dashboard Defaults picker.
|
||||
|
||||
Returns the computers whose type is the one gea-shopfloor-display maps to
|
||||
(default 'Kiosk'), each with its DERIVED FQDN (F<serial>.<domain>, domain
|
||||
from the display_fqdn_domain setting) so an admin picks a kiosk from a
|
||||
dropdown instead of typing an IP/FQDN. Keeps the same F<serial>.<domain>
|
||||
format as core derive_display_fqdn (duplicated to avoid a contract bump).
|
||||
"""
|
||||
from ..pctypemap import pctype_mapping
|
||||
from shopdb.api import Setting
|
||||
|
||||
display_type_name = pctype_mapping().get('gea-shopfloor-display', 'Kiosk')
|
||||
ctype = ComputerType.query.filter_by(computertype=display_type_name).first()
|
||||
if not ctype:
|
||||
return success_response([])
|
||||
domain = (Setting.get('display_fqdn_domain', 'device.geaerospace.net')
|
||||
or 'device.geaerospace.net').strip().strip('.')
|
||||
rows = (db.session.query(Computer).join(Asset)
|
||||
.filter(Computer.computertypeid == ctype.computertypeid,
|
||||
Asset.isactive == True)
|
||||
.order_by(Computer.hostname).all())
|
||||
out = []
|
||||
for comp in rows:
|
||||
serial = (comp.asset.serialnumber or '').strip() if comp.asset else ''
|
||||
out.append({
|
||||
'computerid': comp.computerid,
|
||||
'hostname': comp.hostname,
|
||||
'serialnumber': serial or None,
|
||||
'fqdn': f'F{serial}.{domain}'.lower() if serial else None,
|
||||
})
|
||||
return success_response(out)
|
||||
|
||||
|
||||
@computers_bp.route('', methods=['GET'])
|
||||
@jwt_required(optional=True)
|
||||
def list_computers():
|
||||
|
||||
@@ -111,28 +111,48 @@ try {{
|
||||
if ($shopdbConfig.BaseUrl) {{ $KioskBaseUrl = ([string]$shopdbConfig.BaseUrl).TrimEnd('/') }}
|
||||
}} catch {{}}
|
||||
|
||||
$displayTypeFile = 'C:\\Enrollment\\display-type.txt'
|
||||
if (-not (Test-Path -LiteralPath $displayTypeFile)) {{
|
||||
Write-Host "display-type.txt not found at $displayTypeFile; nothing to configure."
|
||||
# PREFERRED: resolve this display's role from the server by its FQDN, so a change
|
||||
# in Settings > Dashboard Defaults takes effect with no reimage / local edit. The
|
||||
# FQDN is F<BIOS serial>.<domain> (GE device naming); domain from HKLM
|
||||
# DisplayFqdnDomain or the default. display-role is a PUBLIC endpoint (no token).
|
||||
$path = $null
|
||||
$serial = ''
|
||||
try {{ $serial = ([string](Get-CimInstance -ClassName Win32_BIOS -ErrorAction Stop).SerialNumber).Trim() }} catch {{}}
|
||||
$fqdnDomain = 'device.geaerospace.net'
|
||||
try {{
|
||||
$ddom = Get-ItemProperty -Path 'HKLM:\\SOFTWARE\\GE\\ShopDB' -Name DisplayFqdnDomain -ErrorAction Stop
|
||||
if ($ddom.DisplayFqdnDomain) {{ $fqdnDomain = ([string]$ddom.DisplayFqdnDomain).Trim().Trim('.') }}
|
||||
}} catch {{}}
|
||||
if ($serial) {{
|
||||
$fqdn = ('F' + $serial + '.' + $fqdnDomain).ToLower()
|
||||
try {{
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
$roleUri = "$KioskBaseUrl/api/dashboarddefaults/display-role?fqdn=$([uri]::EscapeDataString($fqdn))"
|
||||
$resp = Invoke-RestMethod -Uri $roleUri -TimeoutSec 20 -ErrorAction Stop
|
||||
if ($resp -and $resp.data -and $resp.data.path) {{
|
||||
$path = [string]$resp.data.path
|
||||
Write-Host "server role for $fqdn -> $path"
|
||||
}}
|
||||
}} catch {{ Write-Host "display-role lookup failed for $fqdn : $($_.Exception.Message)" }}
|
||||
}}
|
||||
|
||||
# FALLBACK: the local display-type.txt map (offline, or no server mapping yet).
|
||||
if (-not $path) {{
|
||||
$displayTypeFile = 'C:\\Enrollment\\display-type.txt'
|
||||
if (Test-Path -LiteralPath $displayTypeFile) {{
|
||||
$displayType = (Get-Content -LiteralPath $displayTypeFile -Raw).Trim()
|
||||
if (-not [string]::IsNullOrWhiteSpace($displayType)) {{
|
||||
$matchedKey = $DisplayTypeTargets.Keys | Where-Object {{ $_ -ieq $displayType }} | Select-Object -First 1
|
||||
if ($matchedKey) {{ $path = [string]$DisplayTypeTargets[$matchedKey]; Write-Host "local display-type '$displayType' -> $path" }}
|
||||
}}
|
||||
}}
|
||||
}}
|
||||
if (-not $path) {{
|
||||
Write-Host 'No display role from server or display-type.txt; nothing to configure.'
|
||||
return
|
||||
}}
|
||||
|
||||
$displayType = (Get-Content -LiteralPath $displayTypeFile -Raw).Trim()
|
||||
if ([string]::IsNullOrWhiteSpace($displayType)) {{
|
||||
Write-Host 'display-type.txt is empty; nothing to configure.'
|
||||
return
|
||||
}}
|
||||
|
||||
# Case-insensitive lookup so 'lobby' and 'Lobby' both resolve.
|
||||
$matchedKey = $DisplayTypeTargets.Keys |
|
||||
Where-Object {{ $_ -ieq $displayType }} |
|
||||
Select-Object -First 1
|
||||
if (-not $matchedKey) {{
|
||||
Write-Host "Unknown display-type '$displayType'; known types: $($DisplayTypeTargets.Keys -join ', ')."
|
||||
return
|
||||
}}
|
||||
|
||||
$kioskUrl = "$KioskBaseUrl$($DisplayTypeTargets[$matchedKey])"
|
||||
$kioskUrl = "$KioskBaseUrl$path"
|
||||
|
||||
# Resolve msedge.exe (baked into the display image).
|
||||
$edge = $null
|
||||
|
||||
Reference in New Issue
Block a user