chartboard/app/Views/dashboard/index.php
2026-03-30 09:51:33 +05:30

95 lines
4.5 KiB
PHP

<?= $this->extend('layouts/main') ?>
<?= $this->section('styles') ?>
<link rel="stylesheet" href="<?= base_url('assets/css/dashboard.css') ?>">
<?= $this->endSection() ?>
<?= $this->section('content') ?>
<header class="cb-page-header cb-page-header--center">
<div>
<h1 class="cb-page-title">Dashboards</h1>
<p class="cb-page-subtitle mb-0">Compose charts, narrative text, and filters into a polished canvas for your team.</p>
</div>
<button type="button" class="btn cb-page-primary-btn" data-bs-toggle="modal" data-bs-target="#modalNewDashboard">
+&nbsp;&nbsp;New Dashboard
</button>
</header>
<div class="cb-page-body cb-dash-list-page">
<?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; ?>
<?php if (session()->get('errors')): ?>
<div class="alert alert-danger">
<?php foreach (session()->get('errors') as $e): ?>
<div><?= esc(is_array($e) ? implode(' ', $e) : (string) $e) ?></div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ($dashboards === []): ?>
<div class="cb-dash-empty text-center py-5">
<div class="cb-dash-empty-icon mx-auto mb-3">
<span class="material-symbols-outlined">space_dashboard</span>
</div>
<h2 class="h5 fw-bold">No dashboards yet</h2>
<p class="text-muted mx-auto mb-4" style="max-width:420px;">Create your first board, drop in charts from the library, and tune layout until it feels ready to share.</p>
<button type="button" class="btn cb-dash-btn-primary" data-bs-toggle="modal" data-bs-target="#modalNewDashboard">Create dashboard</button>
</div>
<?php else: ?>
<?php
$pinned = array_values(array_filter($dashboards, static fn ($d) => ! empty($d['is_pinned'])));
$rest = array_values(array_filter($dashboards, static fn ($d) => empty($d['is_pinned'])));
?>
<?php if ($pinned !== []): ?>
<p class="cb-dash-section-label">Pinned</p>
<div class="row g-3 mb-4">
<?php foreach ($pinned as $d): ?>
<?= view('dashboard/_card', ['d' => $d, 'pinned' => true]) ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ($rest !== []): ?>
<p class="cb-dash-section-label"><?= $pinned === [] ? 'All dashboards' : 'More' ?></p>
<div class="row g-3">
<?php foreach ($rest as $d): ?>
<?= view('dashboard/_card', ['d' => $d, 'pinned' => false]) ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="modal fade" id="modalNewDashboard" tabindex="-1" aria-labelledby="modalNewDashboardLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content border-0 shadow-lg cb-dash-modal">
<div class="modal-header border-0 pb-0">
<h2 class="modal-title h5 fw-bold" id="modalNewDashboardLabel">New dashboard</h2>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form action="<?= base_url('dashboard/store') ?>" method="post">
<?= csrf_field() ?>
<div class="modal-body pt-2">
<div class="mb-3">
<label class="form-label fw-semibold">Name</label>
<input type="text" name="name" class="form-control" required maxlength="200" placeholder="e.g. Executive summary" value="<?= esc(old('name') ?? '') ?>">
</div>
<div class="mb-0">
<label class="form-label fw-semibold">Description <span class="text-muted fw-normal">(optional)</span></label>
<textarea name="description" class="form-control" rows="3" maxlength="2000" placeholder="What is this board for?"><?= esc(old('description') ?? '') ?></textarea>
</div>
</div>
<div class="modal-footer border-0 pt-0">
<button type="button" class="btn btn-light border" data-bs-dismiss="modal">Cancel</button>
<button type="submit" class="btn cb-dash-btn-primary">Create &amp; open</button>
</div>
</form>
</div>
</div>
</div>
</div>
<?= $this->endSection() ?>