dashboarddefaults: pick a kiosk from a dropdown (auto-fill FQDN) + Location wording
Adds GET /api/computers/display-kiosks - the displays that reported in (Kiosk type), each with its derived FQDN (F<serial>.<domain>). The Dashboard Defaults form gets a kiosk dropdown that fills the FQDN so admins pick a display instead of typing an IP; IP stays an optional manual field. Table shows FQDN or IP. 'Business Unit' label -> 'Location' on this page + the settings nav.
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():
|
||||
|
||||
Reference in New Issue
Block a user