92 lines
4.5 KiB
PHP
92 lines
4.5 KiB
PHP
<?= $this->extend('layouts/main') ?>
|
|
|
|
<?= $this->section('content') ?>
|
|
<header class="cb-page-header cb-page-header--center">
|
|
<div>
|
|
<h1 class="cb-page-title">Data Sources</h1>
|
|
<p class="cb-page-subtitle">Manage secure connections to databases, APIs, and CSV files.</p>
|
|
</div>
|
|
<a href="<?= base_url('datasource/create') ?>" class="btn cb-page-primary-btn">+ New Data Source</a>
|
|
</header>
|
|
|
|
<div class="cb-page-body">
|
|
<?php if (session()->getFlashdata('success')): ?>
|
|
<div class="alert alert-success"><?= esc(session()->getFlashdata('success')) ?></div>
|
|
<?php endif; ?>
|
|
<?php if (session()->getFlashdata('error')): ?>
|
|
<div class="alert alert-danger"><?= esc(session()->getFlashdata('error')) ?></div>
|
|
<?php endif; ?>
|
|
|
|
<div class="cb-table-shell">
|
|
<div class="table-responsive">
|
|
<table class="table cb-data-table align-middle">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Type</th>
|
|
<th>Status</th>
|
|
<th>Last Tested</th>
|
|
<th class="text-end">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if ($dataSources === []): ?>
|
|
<tr>
|
|
<td colspan="5" class="text-center text-muted py-5">No data sources yet. Create your first connection.</td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
|
|
<?php foreach ($dataSources as $source): ?>
|
|
<?php
|
|
$status = (string) ($source['status'] ?? 'untested');
|
|
$typeIcon = match ((string) $source['type']) {
|
|
'mysql', 'postgresql' => 'storage',
|
|
'mongodb' => 'hub',
|
|
'rest_api' => 'api',
|
|
'csv' => 'table_chart',
|
|
default => 'database',
|
|
};
|
|
?>
|
|
<tr>
|
|
<td>
|
|
<div class="cb-cell-name"><?= esc($source['name']) ?></div>
|
|
<div class="cb-cell-sub"><?= esc($source['host'] ?: $source['api_base_url'] ?: $source['csv_file_path'] ?: '-') ?></div>
|
|
</td>
|
|
<td>
|
|
<span class="material-symbols-outlined align-middle me-1" style="font-size: 18px;"><?= esc($typeIcon) ?></span>
|
|
<span class="text-capitalize"><?= esc(str_replace('_', ' ', $source['type'])) ?></span>
|
|
</td>
|
|
<td>
|
|
<?php if ($status === 'connected'): ?>
|
|
<span class="cb-badge-connected"><?= esc(ucfirst($status)) ?></span>
|
|
<?php elseif ($status === 'failed'): ?>
|
|
<span class="badge rounded-pill bg-danger-subtle text-danger"><?= esc(ucfirst($status)) ?></span>
|
|
<?php else: ?>
|
|
<span class="badge rounded-pill bg-secondary-subtle text-secondary"><?= esc(ucfirst($status)) ?></span>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td class="text-muted small"><?= esc($source['last_tested_at'] ?? '-') ?></td>
|
|
<td class="text-end">
|
|
<div class="cb-table-actions">
|
|
<a href="<?= base_url('datasource/view/' . $source['id']) ?>" class="cb-action-btn cb-action-btn--ghost">View</a>
|
|
<form method="post" action="<?= base_url('datasource/test') ?>" class="d-inline">
|
|
<?= csrf_field() ?>
|
|
<input type="hidden" name="id" value="<?= (int) $source['id'] ?>">
|
|
<button type="submit" class="cb-action-btn cb-action-btn--test">Test</button>
|
|
</form>
|
|
<a href="<?= base_url('datasource/edit/' . $source['id']) ?>" class="cb-action-btn cb-action-btn--edit">Edit</a>
|
|
<form method="post" action="<?= base_url('datasource/delete/' . $source['id']) ?>" class="d-inline" onsubmit="return confirm('Delete this data source?');">
|
|
<?= csrf_field() ?>
|
|
<button type="submit" class="cb-action-btn cb-action-btn--delete">Delete</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?= $this->endSection() ?>
|