<!doctype html>
<html lang="fr">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1" />
    <title>Edit Host</title>
    <style>body{font-family:system-ui,Arial;padding:20px} label{display:block;margin-top:8px} input,textarea{width:100%;padding:6px}</style>
  </head>
  <body>
    <a href="/admin">← Retour</a>
    <h2><%= host && host.id ? 'Modifier' : 'Créer' %> hôte</h2>
    <form method="post" action="/admin/save">
      <input type="hidden" name="id" value="<%= host && host.id ? host.id : '' %>" />
      <label>ID (identifiant, ex: app1)
        <input name="idInput" value="<%= host && host.id ? host.id : '' %>" required />
      </label>
      <label>Path prefix (ex: /app1)
        <input name="pathPrefix" value="<%= host && host.pathPrefix ? host.pathPrefix : '/' %>" required />
      </label>
      <label>Upstream (ex: http://localhost:8081)
        <input name="upstream" value="<%= host && host.upstream ? host.upstream : '' %>" required />
      </label>
      <fieldset style="margin-top:12px;padding:8px;border:1px solid #eee">
        <legend>OIDC (laisser vide si non utilisé)</legend>
        <label>Issuer
          <input name="oidc_issuer" value="<%= host && host.oidc ? host.oidc.issuer : '' %>" />
        </label>
        <label>Client ID
          <input name="oidc_client_id" value="<%= host && host.oidc ? host.oidc.client_id : '' %>" />
        </label>
        <label>Client Secret
          <input name="oidc_client_secret" value="<%= host && host.oidc ? host.oidc.client_secret : '' %>" />
        </label>
        <label>Redirect URI
          <input name="oidc_redirect_uri" value="<%= host && host.oidc ? host.oidc.redirect_uri : '' %>" />
        </label>
      </fieldset>
      <label style="margin-top:8px;">
        <input type="checkbox" name="mask_upstream" <%= host && host.maskUpstream ? 'checked' : '' %> /> Masquer l'upstream (réécrire URLs/ cookies)
      </label>
      <div style="margin-top:12px">
        <button type="submit">Enregistrer</button>
      </div>
    </form>
  </body>
</html>
