<?php
/**
 * View: Demo Oracle — sessions actives et operations longues.
 *
 * Portage de modules/oracle/views/report/realtime_sessions.php. La colonne
 * d'arret de session est conservee, son bouton desactive : effacer la colonne
 * laisserait croire que la fonction n'existe pas. Le tableau SQL Monitor et la
 * fenetre de confirmation d'arret sont partis avec leur gestionnaire.
 *
 * Variables : $baseUrl, $sqlDetailUrl, $settings
 */
?>

<div class="page-header" style="display:flex;align-items:center;flex-wrap:wrap;gap:.75rem">
    <h1 style="margin:0"><?= t('demo_oracle.sess_title') ?></h1>
    <div style="margin-left:auto;font-size:.82rem;color:var(--color-text-muted);display:flex;gap:1rem;align-items:center">
        <span><?= t('demo_oracle.sess_updated') ?>&nbsp;: <strong id="sess-updated">&mdash;</strong></span>
        <span><?= t('demo_oracle.sess_refresh') ?>&nbsp;: <strong id="sess-countdown">10</strong>s</span>
    </div>
</div>

<!-- Section 1 — Sessions actives -->
<div class="card" style="margin-bottom:1rem">
    <h2 style="font-size:.95rem;margin:0 0 .6rem">
        &#x1f7e2; <?= t('demo_oracle.sess_active') ?>
        <small style="font-weight:400;color:var(--color-text-muted);font-size:.78rem">
            (<?= t('demo_oracle.sess_active_hint') ?>)
        </small>
    </h2>
    <div id="sess-active-error" style="display:none" class="alert alert-error"></div>
    <div style="overflow-x:auto">
        <table class="data-table" style="font-size:.82rem">
            <thead>
                <tr>
                    <th><?= t('demo_oracle.sess_inst') ?></th>
                    <th><?= t('demo_oracle.sess_sid_ser') ?></th>
                    <th><?= t('demo_oracle.sess_schema') ?></th>
                    <th><?= t('demo_oracle.sess_sql_id') ?></th>
                    <th><?= t('demo_oracle.sess_sql_preview') ?></th>
                    <th><?= t('demo_oracle.sess_started') ?></th>
                    <th><?= t('demo_oracle.sess_duration') ?></th>
                    <th><?= t('demo_oracle.sess_wait_class') ?></th>
                    <th><?= t('demo_oracle.sess_wait_event') ?></th>
                    <th><?= t('demo_oracle.sess_kill') ?></th>
                </tr>
            </thead>
            <tbody id="sess-active-tbody">
                <tr><td colspan="10" style="color:var(--color-text-muted);text-align:center">&hellip;</td></tr>
            </tbody>
        </table>
    </div>
</div>

<!-- Section 2 — Long operations -->
<div class="card">
    <h2 style="font-size:.95rem;margin:0 0 .6rem">
        &#x23f3; <?= t('demo_oracle.sess_longops') ?>
        <small style="font-weight:400;color:var(--color-text-muted);font-size:.78rem">
            (<?= t('demo_oracle.sess_longops_hint') ?>)
        </small>
    </h2>
    <div id="sess-longops-error" style="display:none" class="alert alert-error"></div>
    <div style="overflow-x:auto">
        <table class="data-table" style="font-size:.82rem">
            <thead>
                <tr>
                    <th><?= t('demo_oracle.sess_inst') ?></th>
                    <th><?= t('demo_oracle.sess_sid_ser') ?></th>
                    <th><?= t('demo_oracle.sess_schema') ?></th>
                    <th><?= t('demo_oracle.sess_sql_id') ?></th>
                    <th><?= t('demo_oracle.sess_op_name') ?></th>
                    <th><?= t('demo_oracle.sess_target') ?></th>
                    <th><?= t('demo_oracle.sess_progress') ?></th>
                    <th><?= t('demo_oracle.sess_started') ?></th>
                    <th><?= t('demo_oracle.sess_eta') ?></th>
                    <th><?= t('demo_oracle.sess_kill') ?></th>
                </tr>
            </thead>
            <tbody id="sess-longops-tbody">
                <tr><td colspan="10" style="color:var(--color-text-muted);text-align:center">&hellip;</td></tr>
            </tbody>
        </table>
    </div>
</div>

<?php /* Le module complet affiche ici un troisieme tableau, « SQL Monitor
         en cours », et un lien par ligne vers le rapport DBMS_SQLTUNE
         correspondant. Ces rapports sont reserves a la version complete :
         ni le tableau ni les liens ne sont repris. */ ?>

<!-- PHP-injected config for external JS -->
<script>
window.DemoOracleReport = window.DemoOracleReport || {};
window.DemoOracleReport.realtimeSessions = {
    baseUrl:      <?= json_encode($baseUrl) ?>,
    sqlDetailUrl: <?= json_encode($sqlDetailUrl) ?>,
    T: {
        no_data:    <?= json_encode(t('demo_oracle.sess_no_data')) ?>,
        no_longops: <?= json_encode(t('demo_oracle.sess_no_longops')) ?>,
        kill:       <?= json_encode(t('demo_oracle.sess_kill')) ?>,
        kill_off:   <?= json_encode(t('demo_oracle.sess_kill_demo')) ?>,
        ctx_open:   <?= json_encode(t('demo_oracle.ctx_open_sql_detail')) ?>,
        ctx_copy:   <?= json_encode(t('demo_oracle.ctx_copy_sql_id')) ?>
    }
};
</script>
<script src="/modules/demo_oracle/assets/js/report-realtime-sessions.js?v=<?= filemtime(__DIR__ . '/../../assets/js/report-realtime-sessions.js') ?>"></script>
