<?php
/* Smarty version 4.5.6, created on 2025-12-20 15:55:20
  from '/var/www/html/tivi/panel/templates/admin/monitor.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.6',
  'unifunc' => 'content_6946b8d856e585_96355621',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '555cdda46267edfe70a91c716863b4c022a2698d' => 
    array (
      0 => '/var/www/html/tivi/panel/templates/admin/monitor.tpl',
      1 => 1766236197,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_6946b8d856e585_96355621 (Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_loadInheritance();
$_smarty_tpl->inheritance->init($_smarty_tpl, true);
?>


<?php 
$_smarty_tpl->inheritance->instanceBlock($_smarty_tpl, 'Block_9189212956946b8d8563f61_76773806', "content");
?>


<?php 
$_smarty_tpl->inheritance->instanceBlock($_smarty_tpl, 'Block_2221245106946b8d856d772_08568914', "scripts");
?>

<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl, "layout.tpl");
}
/* {block "content"} */
class Block_9189212956946b8d8563f61_76773806 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'content' => 
  array (
    0 => 'Block_9189212956946b8d8563f61_76773806',
  ),
);
public function callBlock(Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_checkPlugins(array(0=>array('file'=>'/var/www/html/tivi/vendor/smarty/smarty/libs/plugins/modifier.number_format.php','function'=>'smarty_modifier_number_format',),));
?>

<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h4 class="mb-1">Monitor serwera</h4>
            <p class="text-muted mb-0">Stan systemu i zasobów</p>
        </div>
        <button type="button" class="btn btn-outline-primary" onclick="refreshStats()">
            <i class="bi bi-arrow-clockwise me-1"></i>Odśwież
        </button>
    </div>

    <!-- Główne metryki -->
    <div class="row g-4 mb-4">
        <div class="col-sm-6 col-xl-3">
            <div class="card h-100">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-start mb-3">
                        <div>
                            <h6 class="text-muted mb-1">CPU</h6>
                            <h3 class="mb-0" id="cpu-percent"><?php echo $_smarty_tpl->tpl_vars['stats']->value['cpu_percent'];?>
%</h3>
                        </div>
                        <div class="bg-primary bg-opacity-10 rounded p-2">
                            <i class="bi bi-cpu text-primary fs-4"></i>
                        </div>
                    </div>
                    <div class="progress mb-2" style="height: 6px;">
                        <div class="progress-bar bg-primary" id="cpu-bar" style="width: <?php echo $_smarty_tpl->tpl_vars['stats']->value['cpu_percent'];?>
%"></div>
                    </div>
                    <small class="text-muted">
                        Load: <span id="cpu-load"><?php echo $_smarty_tpl->tpl_vars['stats']->value['cpu_load']['1min'];?>
</span> / <?php echo $_smarty_tpl->tpl_vars['stats']->value['cpu_cores'];?>
 rdzeni
                    </small>
                </div>
            </div>
        </div>

        <div class="col-sm-6 col-xl-3">
            <div class="card h-100">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-start mb-3">
                        <div>
                            <h6 class="text-muted mb-1">Pamięć RAM</h6>
                            <h3 class="mb-0" id="mem-percent"><?php echo $_smarty_tpl->tpl_vars['stats']->value['memory']['percent'];?>
%</h3>
                        </div>
                        <div class="bg-success bg-opacity-10 rounded p-2">
                            <i class="bi bi-memory text-success fs-4"></i>
                        </div>
                    </div>
                    <div class="progress mb-2" style="height: 6px;">
                        <div class="progress-bar bg-success" id="mem-bar" style="width: <?php echo $_smarty_tpl->tpl_vars['stats']->value['memory']['percent'];?>
%"></div>
                    </div>
                    <small class="text-muted">
                        <span id="mem-used"><?php echo smarty_modifier_number_format(($_smarty_tpl->tpl_vars['stats']->value['memory']['used']/1073741824),1);?>
</span> / 
                        <?php echo smarty_modifier_number_format(($_smarty_tpl->tpl_vars['stats']->value['memory']['total']/1073741824),1);?>
 GB
                    </small>
                </div>
            </div>
        </div>

        <div class="col-sm-6 col-xl-3">
            <div class="card h-100">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-start mb-3">
                        <div>
                            <h6 class="text-muted mb-1">Dysk</h6>
                            <h3 class="mb-0" id="disk-percent"><?php echo $_smarty_tpl->tpl_vars['stats']->value['disk']['percent'];?>
%</h3>
                        </div>
                        <div class="bg-warning bg-opacity-10 rounded p-2">
                            <i class="bi bi-hdd text-warning fs-4"></i>
                        </div>
                    </div>
                    <div class="progress mb-2" style="height: 6px;">
                        <div class="progress-bar bg-warning" id="disk-bar" style="width: <?php echo $_smarty_tpl->tpl_vars['stats']->value['disk']['percent'];?>
%"></div>
                    </div>
                    <small class="text-muted">
                        <span id="disk-used"><?php echo smarty_modifier_number_format(($_smarty_tpl->tpl_vars['stats']->value['disk']['used']/1073741824),1);?>
</span> / 
                        <?php echo smarty_modifier_number_format(($_smarty_tpl->tpl_vars['stats']->value['disk']['total']/1073741824),1);?>
 GB
                    </small>
                </div>
            </div>
        </div>

        <div class="col-sm-6 col-xl-3">
            <div class="card h-100">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-start mb-3">
                        <div>
                            <h6 class="text-muted mb-1">Uptime</h6>
                            <h3 class="mb-0" id="uptime"><?php echo $_smarty_tpl->tpl_vars['stats']->value['uptime']['formatted'];?>
</h3>
                        </div>
                        <div class="bg-info bg-opacity-10 rounded p-2">
                            <i class="bi bi-clock-history text-info fs-4"></i>
                        </div>
                    </div>
                    <small class="text-muted">
                        Ostatnia aktualizacja: <span id="last-update"><?php echo $_smarty_tpl->tpl_vars['stats']->value['timestamp'];?>
</span>
                    </small>
                </div>
            </div>
        </div>
    </div>

    <div class="row g-4">
        <!-- Informacje o systemie -->
        <div class="col-lg-6">
            <div class="card h-100">
                <div class="card-header">
                    <h5 class="card-title mb-0"><i class="bi bi-info-circle me-2"></i>Informacje o systemie</h5>
                </div>
                <div class="card-body">
                    <table class="table table-sm mb-0">
                        <tr>
                            <td class="text-muted">PHP</td>
                            <td><code><?php echo $_smarty_tpl->tpl_vars['stats']->value['php_version'];?>
</code></td>
                        </tr>
                        <tr>
                            <td class="text-muted">Serwer WWW</td>
                            <td><code><?php echo $_smarty_tpl->tpl_vars['stats']->value['server_software'];?>
</code></td>
                        </tr>
                        <tr>
                            <td class="text-muted">Rdzenie CPU</td>
                            <td><?php echo $_smarty_tpl->tpl_vars['stats']->value['cpu_cores'];?>
</td>
                        </tr>
                        <tr>
                            <td class="text-muted">Load Average</td>
                            <td>
                                <?php echo $_smarty_tpl->tpl_vars['stats']->value['cpu_load']['1min'];?>
 (1m) / 
                                <?php echo $_smarty_tpl->tpl_vars['stats']->value['cpu_load']['5min'];?>
 (5m) / 
                                <?php echo $_smarty_tpl->tpl_vars['stats']->value['cpu_load']['15min'];?>
 (15m)
                            </td>
                        </tr>
                        <tr>
                            <td class="text-muted">Baza danych</td>
                            <td><?php echo smarty_modifier_number_format(($_smarty_tpl->tpl_vars['stats']->value['database']['size']/1048576),2);?>
 MB</td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>

        <!-- Statystyki aplikacji -->
        <div class="col-lg-6">
            <div class="card h-100">
                <div class="card-header">
                    <h5 class="card-title mb-0"><i class="bi bi-bar-chart me-2"></i>Statystyki aplikacji</h5>
                </div>
                <div class="card-body">
                    <div class="row text-center">
                        <div class="col-3">
                            <div class="fs-3 fw-bold text-primary"><?php echo $_smarty_tpl->tpl_vars['stats']->value['app']['users'];?>
</div>
                            <small class="text-muted">Użytkownicy</small>
                        </div>
                        <div class="col-3">
                            <div class="fs-3 fw-bold text-success"><?php echo $_smarty_tpl->tpl_vars['stats']->value['app']['devices'];?>
</div>
                            <small class="text-muted">Urządzenia</small>
                        </div>
                        <div class="col-3">
                            <div class="fs-3 fw-bold text-warning"><?php echo $_smarty_tpl->tpl_vars['stats']->value['app']['playlists'];?>
</div>
                            <small class="text-muted">Playlisty</small>
                        </div>
                        <div class="col-3">
                            <div class="fs-3 fw-bold text-info"><?php echo $_smarty_tpl->tpl_vars['stats']->value['app']['logs'];?>
</div>
                            <small class="text-muted">Logi</small>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php
}
}
/* {/block "content"} */
/* {block "scripts"} */
class Block_2221245106946b8d856d772_08568914 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'scripts' => 
  array (
    0 => 'Block_2221245106946b8d856d772_08568914',
  ),
);
public function callBlock(Smarty_Internal_Template $_smarty_tpl) {
?>

<?php echo '<script'; ?>
>
function refreshStats() {
    fetch('<?php echo $_smarty_tpl->tpl_vars['baseUrl']->value;?>
/admin/monitor-api')
        .then(r => r.json())
        .then(data => {
            if (data.success) {
                const s = data.stats;
                
                document.getElementById('cpu-percent').textContent = s.cpu_percent + '%';
                document.getElementById('cpu-bar').style.width = s.cpu_percent + '%';
                document.getElementById('cpu-load').textContent = s.cpu_load['1min'];
                
                document.getElementById('mem-percent').textContent = s.memory.percent + '%';
                document.getElementById('mem-bar').style.width = s.memory.percent + '%';
                document.getElementById('mem-used').textContent = (s.memory.used / 1073741824).toFixed(1);
                
                document.getElementById('disk-percent').textContent = s.disk.percent + '%';
                document.getElementById('disk-bar').style.width = s.disk.percent + '%';
                document.getElementById('disk-used').textContent = (s.disk.used / 1073741824).toFixed(1);
                
                document.getElementById('uptime').textContent = s.uptime.formatted;
                document.getElementById('last-update').textContent = s.timestamp;
            }
        });
}

// Auto-refresh co 30 sekund
setInterval(refreshStats, 30000);
<?php echo '</script'; ?>
>
<?php
}
}
/* {/block "scripts"} */
}
