<dashboard version="1.1" script="git_pusher_config.js" hideEdit="true">
  <label>Git Pusher - Configuration</label>
  <description>Configuration de l'application Git Pusher</description>
  
  <row>
    <panel>
      <html>
        <style>
          .config-container {
            max-width: 900px;
            margin: 0 auto;
            padding: 30px;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
          }
          
          .config-header {
            text-align: center;
            margin-bottom: 40px;
          }
          
          .config-header h1 {
            font-size: 28px;
            color: #333;
            margin-bottom: 10px;
          }
          
          .config-header p {
            color: #666;
            font-size: 14px;
          }
          
          .config-section {
            background: white;
            border-radius: 12px;
            padding: 25px;
            margin-bottom: 25px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
          }
          
          .config-section h2 {
            font-size: 18px;
            color: #333;
            margin: 0 0 20px 0;
            padding-bottom: 10px;
            border-bottom: 2px solid #667eea;
            display: flex;
            align-items: center;
            gap: 10px;
          }
          
          .config-section h2 .icon {
            font-size: 24px;
          }
          
          .config-grid {
            display: grid;
            grid-template-columns: 1fr 2fr;
            gap: 15px;
            align-items: center;
          }
          
          .config-grid label {
            font-weight: 600;
            color: #555;
          }
          
          .config-grid input, .config-grid select {
            padding: 10px 15px;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-size: 14px;
            transition: border-color 0.3s;
          }
          
          .config-grid input:focus, .config-grid select:focus {
            outline: none;
            border-color: #667eea;
          }
          
          .config-grid input[type="checkbox"] {
            width: 20px;
            height: 20px;
          }
          
          .config-hint {
            grid-column: 2;
            font-size: 12px;
            color: #888;
            margin-top: -10px;
          }
          
          .config-actions {
            display: flex;
            justify-content: flex-end;
            gap: 15px;
            margin-top: 30px;
          }
          
          .btn {
            padding: 12px 30px;
            border: none;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
          }
          
          .btn-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
          }
          
          .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
          }
          
          .btn-secondary {
            background: #f5f5f5;
            color: #333;
          }
          
          .btn-secondary:hover {
            background: #e0e0e0;
          }
          
          .btn-danger {
            background: #f44336;
            color: white;
          }
          
          .btn-danger:hover {
            background: #d32f2f;
          }
          
          .config-message {
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 20px;
            display: none;
          }
          
          .config-message.success {
            background: #e8f5e9;
            color: #2e7d32;
            border-left: 4px solid #4caf50;
            display: block;
          }
          
          .config-message.error {
            background: #ffebee;
            color: #c62828;
            border-left: 4px solid #f44336;
            display: block;
          }
          
          .config-status {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 5px 12px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 600;
          }
          
          .config-status.connected {
            background: #e8f5e9;
            color: #2e7d32;
          }
          
          .config-status.disconnected {
            background: #ffebee;
            color: #c62828;
          }
          
          .test-btn {
            padding: 8px 15px;
            font-size: 12px;
            background: #2196F3;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
          }
          
          .test-btn:hover {
            background: #1976D2;
          }
          
          .version-badge {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 8px 16px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 600;
          }
        </style>
        
        <div class="config-container">
          <div class="config-header">
            <h1>⚙️ Configuration Git Pusher</h1>
            <p>Configurez les paramètres de l'application</p>
          </div>
          
          <div id="config-message" class="config-message"></div>
          
          <!-- Section API -->
          <div class="config-section">
            <h2><span class="icon">🌐</span> Configuration API</h2>
            <div class="config-grid">
              <label for="api-url">URL de l'API Git Pusher</label>
              <input type="text" id="api-url" placeholder="https://myprivspldev-api.example.com" />
              <span class="config-hint">L'URL du serveur Git Pusher (sans le port si proxy)</span>
              
              <label for="api-port">Port (si accès direct)</label>
              <input type="number" id="api-port" placeholder="9999" value="9999" />
              <span class="config-hint">Port utilisé si accès direct par IP (ignoré si URL de domaine)</span>
              
              <label for="use-proxy">Utiliser un proxy</label>
              <input type="checkbox" id="use-proxy" checked="checked" />
              <span class="config-hint">Coché si vous utilisez un reverse proxy (Nginx, etc.)</span>
              
              <label>Test de connexion</label>
              <div>
                <button class="test-btn" id="test-api-btn">Tester la connexion</button>
                <span id="api-status" class="config-status disconnected">● Non testé</span>
              </div>
            </div>
          </div>
          
          <!-- Section SH Deployer -->
          <div class="config-section">
            <h2><span class="icon">🚀</span> Configuration SH Deployer</h2>
            <div class="config-grid">
              <label for="deployer-enabled">Activer SH Deployer</label>
              <input type="checkbox" id="deployer-enabled" />
              <span class="config-hint">Activer le déploiement automatique vers le Search Head Cluster</span>
              
              <label for="deployer-host">Adresse du SH Deployer</label>
              <input type="text" id="deployer-host" placeholder="10.10.40.14" />
              <span class="config-hint">Adresse IP ou hostname du serveur SH Deployer</span>
              
              <label for="deployer-port">Port</label>
              <input type="number" id="deployer-port" placeholder="9998" value="9998" />
              
              <label for="deployer-token">Token d'authentification</label>
              <input type="password" id="deployer-token" placeholder="Token secret" />
              <span class="config-hint">Token configuré dans deployer_agent.py</span>
              
              <label for="deployer-use-ssl">Utiliser SSL</label>
              <input type="checkbox" id="deployer-use-ssl" checked="checked" />
              
              <label>Test de connexion</label>
              <div>
                <button class="test-btn" id="test-deployer-btn">Tester la connexion</button>
                <span id="deployer-status" class="config-status disconnected">● Non testé</span>
              </div>
            </div>
          </div>
          
          <!-- Section Licence -->
          <div class="config-section">
            <h2><span class="icon">🔐</span> Configuration Licence</h2>
            <div class="config-grid">
              <label>Statut de la licence</label>
              <div id="license-status">Chargement...</div>
              
              <label for="license-check-interval">Intervalle de vérification (heures)</label>
              <input type="number" id="license-check-interval" value="24" min="1" max="168" />
              <span class="config-hint">Fréquence de revalidation de la licence</span>
            </div>
          </div>
          
          <!-- Section Avancée -->
          <div class="config-section">
            <h2><span class="icon">🔧</span> Paramètres avancés</h2>
            <div class="config-grid">
              <label for="log-level">Niveau de log</label>
              <select id="log-level">
                <option value="INFO">INFO</option>
                <option value="DEBUG">DEBUG</option>
                <option value="WARNING">WARNING</option>
                <option value="ERROR">ERROR</option>
              </select>
              
              <label for="timeout">Timeout des requêtes (secondes)</label>
              <input type="number" id="timeout" value="30" min="5" max="300" />
              
              <label for="git-timeout">Timeout Git (secondes)</label>
              <input type="number" id="git-timeout" value="120" min="30" max="600" />
            </div>
          </div>
          
          <!-- Actions -->
          <div class="config-actions">
            <button class="btn btn-secondary" id="reset-btn">Réinitialiser</button>
            <button class="btn btn-primary" id="save-btn">💾 Sauvegarder</button>
          </div>
        </div>
        
        <div class="version-badge">Git Pusher v2.1</div>
      </html>
    </panel>
  </row>
</dashboard>