profile 3 user & dashboard admin guru
This commit is contained in:
parent
7f81522b85
commit
d554186fc1
|
|
@ -7,7 +7,6 @@
|
|||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Models\Admin;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
|
|
@ -17,7 +16,7 @@ public function edit()
|
|||
return view('admin.profile.edit', compact('admin'));
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
public function updateAjax(Request $request)
|
||||
{
|
||||
$admin = Auth::guard('admin')->user();
|
||||
|
||||
|
|
@ -41,17 +40,23 @@ public function update(Request $request)
|
|||
$data['password'] = Hash::make($request->password);
|
||||
}
|
||||
|
||||
$fotoUrl = null;
|
||||
if ($request->hasFile('foto_profil')) {
|
||||
if ($admin->foto_profil && Storage::disk('public')->exists($admin->foto_profil)) {
|
||||
Storage::disk('public')->delete($admin->foto_profil);
|
||||
}
|
||||
$path = $request->file('foto_profil')->store('foto_profil/admin', 'public');
|
||||
$data['foto_profil'] = $path;
|
||||
$fotoUrl = Storage::url($path);
|
||||
}
|
||||
|
||||
$admin->update($data);
|
||||
|
||||
return redirect()->route('admin.profile.edit')
|
||||
->with('success', 'Profil berhasil diperbarui!');
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Profil berhasil diperbarui!',
|
||||
'foto_url' => $fotoUrl ?? ($admin->foto_profil ? Storage::url($admin->foto_profil) : null),
|
||||
'username' => $admin->fresh()->username,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,13 +10,7 @@
|
|||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
public function edit()
|
||||
{
|
||||
$guru = Auth::guard('guru')->user();
|
||||
return view('guru.profile.edit', compact('guru'));
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
public function updateAjax(Request $request)
|
||||
{
|
||||
$guru = Auth::guard('guru')->user();
|
||||
|
||||
|
|
@ -31,7 +25,8 @@ public function update(Request $request)
|
|||
'foto_profil.max' => 'Ukuran foto maksimal 2MB.',
|
||||
]);
|
||||
|
||||
$data = [];
|
||||
$data = [];
|
||||
$fotoUrl = null;
|
||||
|
||||
if ($request->filled('password')) {
|
||||
$data['password'] = Hash::make($request->password);
|
||||
|
|
@ -43,13 +38,17 @@ public function update(Request $request)
|
|||
}
|
||||
$path = $request->file('foto_profil')->store('foto_profil/guru', 'public');
|
||||
$data['foto_profil'] = $path;
|
||||
$fotoUrl = Storage::url($path);
|
||||
}
|
||||
|
||||
if (!empty($data)) {
|
||||
$guru->update($data);
|
||||
}
|
||||
|
||||
return redirect()->route('guru.profile.edit')
|
||||
->with('success', 'Profil berhasil diperbarui!');
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Profil berhasil diperbarui!',
|
||||
'foto_url' => $fotoUrl ?? ($guru->foto_profil ? Storage::url($guru->foto_profil) : null),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,11 +5,12 @@
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Leaderboard;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class LeaderboardController extends Controller
|
||||
{
|
||||
public function index()
|
||||
private function getData()
|
||||
{
|
||||
$siswa = Auth::guard('siswa')->user();
|
||||
|
||||
|
|
@ -19,7 +20,6 @@ public function index()
|
|||
? $now->year . '/' . ($now->year + 1)
|
||||
: ($now->year - 1) . '/' . $now->year;
|
||||
|
||||
// Top leaderboard kelas siswa ini
|
||||
$leaderboard = Leaderboard::with('siswa')
|
||||
->where('id_kelas', $siswa->id_kelas)
|
||||
->where('semester', $semester)
|
||||
|
|
@ -27,20 +27,33 @@ public function index()
|
|||
->orderBy('total_exp', 'desc')
|
||||
->get()
|
||||
->map(function ($item, $i) {
|
||||
$fotoProfil = optional($item->siswa)->foto_profil;
|
||||
return [
|
||||
'ranking' => $i + 1,
|
||||
'nama' => optional($item->siswa)->nama ?? '-',
|
||||
'nisn' => optional($item->siswa)->nisn ?? '-',
|
||||
'exp' => $item->total_exp,
|
||||
'id_siswa'=> $item->id_siswa,
|
||||
'ranking' => $i + 1,
|
||||
'nama' => optional($item->siswa)->nama ?? '-',
|
||||
'nisn' => optional($item->siswa)->nisn ?? '-',
|
||||
'exp' => $item->total_exp,
|
||||
'id_siswa' => $item->id_siswa,
|
||||
'foto_profil' => $fotoProfil,
|
||||
'foto_url' => $fotoProfil ? Storage::url($fotoProfil) : null,
|
||||
];
|
||||
});
|
||||
|
||||
// Posisi siswa yang login
|
||||
$myRank = $leaderboard->firstWhere('id_siswa', $siswa->id_siswa);
|
||||
|
||||
return view('siswa.leaderboard.index', compact(
|
||||
'leaderboard', 'myRank', 'semester', 'tahunAjaran'
|
||||
));
|
||||
return compact('leaderboard', 'myRank', 'semester', 'tahunAjaran');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = $this->getData();
|
||||
return view('siswa.leaderboard.index', $data);
|
||||
}
|
||||
|
||||
// Endpoint JSON untuk polling real-time
|
||||
public function json()
|
||||
{
|
||||
$data = $this->getData();
|
||||
return response()->json($data);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,13 +10,7 @@
|
|||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
public function edit()
|
||||
{
|
||||
$siswa = Auth::guard('siswa')->user();
|
||||
return view('siswa.profile.edit', compact('siswa'));
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
public function updateAjax(Request $request)
|
||||
{
|
||||
$siswa = Auth::guard('siswa')->user();
|
||||
|
||||
|
|
@ -31,28 +25,30 @@ public function update(Request $request)
|
|||
'foto_profil.max' => 'Ukuran foto maksimal 2MB.',
|
||||
]);
|
||||
|
||||
$data = [];
|
||||
$data = [];
|
||||
$fotoUrl = null;
|
||||
|
||||
// Update password
|
||||
if ($request->filled('password')) {
|
||||
$data['password'] = Hash::make($request->password);
|
||||
}
|
||||
|
||||
// Update foto profil
|
||||
if ($request->hasFile('foto_profil')) {
|
||||
// Hapus foto lama jika ada
|
||||
if ($siswa->foto_profil && Storage::disk('public')->exists($siswa->foto_profil)) {
|
||||
Storage::disk('public')->delete($siswa->foto_profil);
|
||||
}
|
||||
$path = $request->file('foto_profil')->store('foto_profil/siswa', 'public');
|
||||
$data['foto_profil'] = $path;
|
||||
$fotoUrl = Storage::url($path);
|
||||
}
|
||||
|
||||
if (!empty($data)) {
|
||||
$siswa->update($data);
|
||||
}
|
||||
|
||||
return redirect()->route('siswa.profile.edit')
|
||||
->with('success', 'Profil berhasil diperbarui!');
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Profil berhasil diperbarui!',
|
||||
'foto_url' => $fotoUrl ?? ($siswa->foto_profil ? Storage::url($siswa->foto_profil) : null),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,28 +2,270 @@
|
|||
|
||||
@section('title', 'Dashboard Admin')
|
||||
|
||||
@push('styles')
|
||||
<style>
|
||||
/* ── PAGE ── */
|
||||
.dash-header { margin-bottom: 28px; }
|
||||
.dash-title { font-size: 22px; font-weight: 800; color: #0f1f3d; margin-bottom: 2px; }
|
||||
.dash-sub { font-size: 13px; color: #94a3b8; }
|
||||
|
||||
/* ── STAT CARDS ── */
|
||||
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 28px; }
|
||||
|
||||
.stat-card {
|
||||
border-radius: 20px;
|
||||
padding: 24px 22px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
cursor: default;
|
||||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||
animation: fadeUp 0.4s ease both;
|
||||
}
|
||||
|
||||
.stat-card:hover { transform: translateY(-4px); box-shadow: 0 16px 40px rgba(0,0,0,0.12); }
|
||||
|
||||
.stat-card:nth-child(1) { background: linear-gradient(135deg, #fff7e6, #ffe4b2); animation-delay: 0s; }
|
||||
.stat-card:nth-child(2) { background: linear-gradient(135deg, #e8fff3, #b8f5d4); animation-delay: 0.07s; }
|
||||
.stat-card:nth-child(3) { background: linear-gradient(135deg, #eef4ff, #c5d9ff); animation-delay: 0.14s; }
|
||||
.stat-card:nth-child(4) { background: linear-gradient(135deg, #ffeef4, #ffc5db); animation-delay: 0.21s; }
|
||||
|
||||
.stat-card::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 120px; height: 120px;
|
||||
border-radius: 50%;
|
||||
opacity: 0.15;
|
||||
right: -30px; bottom: -30px;
|
||||
}
|
||||
|
||||
.stat-card:nth-child(1)::after { background: #f97316; }
|
||||
.stat-card:nth-child(2)::after { background: #22c55e; }
|
||||
.stat-card:nth-child(3)::after { background: #2b8ef3; }
|
||||
.stat-card:nth-child(4)::after { background: #ec4899; }
|
||||
|
||||
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 10px; }
|
||||
.stat-card:nth-child(1) .stat-label { color: #c2651a; }
|
||||
.stat-card:nth-child(2) .stat-label { color: #15803d; }
|
||||
.stat-card:nth-child(3) .stat-label { color: #1d5fb8; }
|
||||
.stat-card:nth-child(4) .stat-label { color: #be185d; }
|
||||
|
||||
.stat-num { font-size: 42px; font-weight: 800; line-height: 1; color: #0f1f3d; }
|
||||
|
||||
.stat-icon {
|
||||
position: absolute; top: 20px; right: 20px;
|
||||
width: 42px; height: 42px; border-radius: 12px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
font-size: 20px;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.stat-card:nth-child(1) .stat-icon { background: rgba(249,115,22,0.15); }
|
||||
.stat-card:nth-child(2) .stat-icon { background: rgba(34,197,94,0.15); }
|
||||
.stat-card:nth-child(3) .stat-icon { background: rgba(43,142,243,0.15); }
|
||||
.stat-card:nth-child(4) .stat-icon { background: rgba(236,72,153,0.15); }
|
||||
|
||||
/* ── BOTTOM ROW ── */
|
||||
.dash-bottom { display: grid; grid-template-columns: 1fr 340px; gap: 20px; }
|
||||
|
||||
/* Card container */
|
||||
.dash-card {
|
||||
background: white;
|
||||
border-radius: 20px;
|
||||
border: 1.5px solid #e8f0fb;
|
||||
padding: 24px;
|
||||
box-shadow: 0 4px 20px rgba(43,142,243,0.06);
|
||||
animation: fadeUp 0.4s ease 0.28s both;
|
||||
}
|
||||
|
||||
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
|
||||
.card-title { font-size: 15px; font-weight: 700; color: #0f1f3d; }
|
||||
.card-badge { font-size: 11px; font-weight: 700; background: #e8f4ff; color: #2b8ef3; padding: 3px 10px; border-radius: 99px; }
|
||||
|
||||
/* Chart */
|
||||
.chart-wrap { position: relative; height: 240px; }
|
||||
|
||||
/* Challenge list */
|
||||
.challenge-item {
|
||||
background: #f8faff;
|
||||
border-radius: 14px;
|
||||
padding: 14px 16px;
|
||||
margin-bottom: 10px;
|
||||
border-left: 4px solid #2b8ef3;
|
||||
transition: all 0.2s;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.challenge-item:nth-child(2) { border-left-color: #22c55e; }
|
||||
.challenge-item:nth-child(3) { border-left-color: #f97316; }
|
||||
|
||||
.challenge-item:hover { background: #eef4ff; transform: translateX(3px); }
|
||||
|
||||
.ch-kelas { font-size: 12px; font-weight: 700; color: #2b8ef3; margin-bottom: 3px; }
|
||||
.challenge-item:nth-child(2) .ch-kelas { color: #16a34a; }
|
||||
.challenge-item:nth-child(3) .ch-kelas { color: #ea580c; }
|
||||
|
||||
.ch-judul { font-size: 13px; font-weight: 600; color: #0f1f3d; margin-bottom: 3px; }
|
||||
.ch-meta { font-size: 11px; color: #94a3b8; }
|
||||
|
||||
.btn-add-challenge {
|
||||
display: flex; align-items: center; justify-content: center; gap: 6px;
|
||||
width: 100%; padding: 11px;
|
||||
background: white; border: 2px dashed #dbeeff;
|
||||
border-radius: 12px; color: #2b8ef3; font-size: 13px; font-weight: 700;
|
||||
text-decoration: none; margin-top: 4px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.btn-add-challenge:hover { background: #e8f4ff; border-color: #2b8ef3; color: #2b8ef3; }
|
||||
|
||||
@keyframes fadeUp {
|
||||
from { opacity: 0; transform: translateY(16px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.stat-grid { grid-template-columns: repeat(2, 1fr); }
|
||||
.dash-bottom { grid-template-columns: 1fr; }
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
<div class="container mt-5">
|
||||
<h1 class="mb-4 fw-bold text-primary">Dashboard Admin</h1>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-3">
|
||||
<div class="card text-center shadow-sm">
|
||||
<div class="card-body">
|
||||
<h5>Total Guru</h5>
|
||||
<p class="fs-3 fw-bold text-success">12</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@php
|
||||
use Carbon\Carbon;
|
||||
$greeting = Carbon::now()->hour < 12 ? 'Selamat Pagi' : (Carbon::now()->hour < 17 ? 'Selamat Siang' : 'Selamat Malam');
|
||||
@endphp
|
||||
|
||||
<div class="col-md-4 mb-3">
|
||||
<div class="card text-center shadow-sm">
|
||||
<div class="card-body">
|
||||
<h5>Total Siswa</h5>
|
||||
<p class="fs-3 fw-bold text-primary">230</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dash-header">
|
||||
<div class="dash-title">{{ $greeting }}, {{ Auth::guard('admin')->user()->username ?? 'Admin' }} 👋</div>
|
||||
<div class="dash-sub">{{ Carbon::now()->isoFormat('dddd, D MMMM Y') }}</div>
|
||||
</div>
|
||||
|
||||
{{-- STAT CARDS --}}
|
||||
<div class="stat-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">👨🏫</div>
|
||||
<div class="stat-label">Total Guru</div>
|
||||
<div class="stat-num">{{ $totalGuru }}</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">🏫</div>
|
||||
<div class="stat-label">Total Kelas</div>
|
||||
<div class="stat-num">{{ $totalKelas }}</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">👨🎓</div>
|
||||
<div class="stat-label">Total Siswa</div>
|
||||
<div class="stat-num">{{ $totalSiswa }}</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">📚</div>
|
||||
<div class="stat-label">Total Mapel</div>
|
||||
<div class="stat-num">{{ $totalMapel }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- BOTTOM: Chart + Challenge --}}
|
||||
<div class="dash-bottom">
|
||||
|
||||
{{-- Bar Chart --}}
|
||||
<div class="dash-card">
|
||||
<div class="card-head">
|
||||
<div class="card-title">Total Siswa Berdasarkan Kelas</div>
|
||||
<span class="card-badge">{{ $chartData->count() }} Kelas</span>
|
||||
</div>
|
||||
<div class="chart-wrap">
|
||||
<canvas id="kelasChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Challenge Terbaru --}}
|
||||
<div class="dash-card">
|
||||
<div class="card-head">
|
||||
<div class="card-title">Challenge Terbaru</div>
|
||||
<a href="{{ route('admin.challenge.index') }}" class="card-badge" style="text-decoration:none">Lihat Semua →</a>
|
||||
</div>
|
||||
|
||||
@forelse($latestChallenges as $ch)
|
||||
<div class="challenge-item">
|
||||
<div class="ch-kelas">
|
||||
{{ $ch->kelas->pluck('nama_kelas')->join(', ') ?: 'Semua Kelas' }}
|
||||
</div>
|
||||
<div class="ch-judul">{{ $ch->judul_challenge }}</div>
|
||||
<div class="ch-meta">
|
||||
{{ $ch->soal->count() }} Soal
|
||||
@if($ch->tenggat_waktu)
|
||||
· Tenggat: {{ \Carbon\Carbon::parse($ch->tenggat_waktu)->isoFormat('D MMM Y') }}
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<div style="text-align:center;padding:24px;color:#94a3b8;font-size:13px;">
|
||||
Belum ada challenge dibuat.
|
||||
</div>
|
||||
@endforelse
|
||||
|
||||
<a href="{{ route('admin.challenge.create') }}" class="btn-add-challenge">
|
||||
+ Tambahkan Challenge Baru
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
|
||||
<script>
|
||||
const labels = @json($chartData->pluck('nama_kelas'));
|
||||
const values = @json($chartData->pluck('siswa_count'));
|
||||
|
||||
const colors = [
|
||||
'rgba(43,142,243,0.8)',
|
||||
'rgba(34,197,94,0.8)',
|
||||
'rgba(249,115,22,0.8)',
|
||||
'rgba(168,85,247,0.8)',
|
||||
'rgba(236,72,153,0.8)',
|
||||
'rgba(234,179,8,0.8)',
|
||||
];
|
||||
|
||||
const ctx = document.getElementById('kelasChart').getContext('2d');
|
||||
new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: 'Jumlah Siswa',
|
||||
data: values,
|
||||
backgroundColor: labels.map((_, i) => colors[i % colors.length]),
|
||||
borderRadius: 10,
|
||||
borderSkipped: false,
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
plugins: {
|
||||
legend: { display: false },
|
||||
tooltip: {
|
||||
callbacks: {
|
||||
label: ctx => ` ${ctx.parsed.y} siswa`
|
||||
}
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
grid: { color: '#f1f5f9' },
|
||||
ticks: { font: { family: 'Poppins', size: 11 }, color: '#94a3b8' }
|
||||
},
|
||||
x: {
|
||||
grid: { display: false },
|
||||
ticks: { font: { family: 'Poppins', size: 11 }, color: '#64748b' }
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
|
@ -3,44 +3,109 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<title>@yield('title', 'Admin Panel')</title>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
body { font-family: 'Poppins', sans-serif; background-color: #f8f9fa; margin: 0; }
|
||||
body { font-family: 'Poppins', sans-serif; background-color: #f5f9ff; margin: 0; }
|
||||
.admin-wrapper { display: flex; min-height: 100vh; }
|
||||
|
||||
.sidebar { width: 260px; background: #ffffff; border-right: 2px solid #e6f0ff; padding: 30px 20px; display: flex; flex-direction: column; }
|
||||
.sidebar-logo { text-align: center; margin-bottom: 40px; }
|
||||
.sidebar-logo img { width: 90px; }
|
||||
.sidebar-menu { display: flex; flex-direction: column; }
|
||||
/* ── SIDEBAR ── */
|
||||
.sidebar {
|
||||
width: 260px;
|
||||
background: #ffffff;
|
||||
border-right: 2px solid #e6f0ff;
|
||||
padding: 30px 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transition: width 0.3s ease, padding 0.3s ease;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.sidebar-link { display: flex; align-items: center; gap: 12px; padding: 12px 18px; margin-bottom: 12px; border-radius: 12px; color: #64748b; text-decoration: none; font-weight: 500; transition: all 0.2s ease; }
|
||||
.sidebar.collapsed { width: 0; padding: 0; border-right: none; }
|
||||
|
||||
.sidebar-logo { text-align: center; margin-bottom: 40px; white-space: nowrap; }
|
||||
.sidebar-logo img { width: 90px; }
|
||||
.sidebar-menu { display: flex; flex-direction: column; white-space: nowrap; }
|
||||
|
||||
.sidebar-link { display: flex; align-items: center; gap: 12px; padding: 12px 18px; margin-bottom: 6px; border-radius: 12px; color: #64748b; text-decoration: none; font-weight: 500; font-size: 14px; transition: all 0.2s ease; }
|
||||
.sidebar-link:hover { background: #e6f0ff; color: #1d4ed8; }
|
||||
.sidebar-link.active { background: #e6f0ff; color: #1d4ed8; }
|
||||
.sidebar-icon { width: 20px; height: 20px; flex-shrink: 0; }
|
||||
|
||||
.sidebar-section { font-size: 10px; font-weight: 700; color: #94a3b8; letter-spacing: 1px; text-transform: uppercase; padding: 4px 18px; margin-bottom: 6px; margin-top: 6px; }
|
||||
.sidebar-logout { margin-top: auto; }
|
||||
.sidebar-logout button { width: 100%; border: none; background: transparent; color: #ef4444; font-weight: 600; padding: 10px; text-align: left; }
|
||||
.sidebar-section { font-size: 10px; font-weight: 700; color: #94a3b8; letter-spacing: 1px; text-transform: uppercase; padding: 4px 18px; margin: 8px 0 4px; white-space: nowrap; }
|
||||
.sidebar-logout { margin-top: auto; padding-top: 16px; border-top: 1px solid #f1f5f9; }
|
||||
.sidebar-logout button { width: 100%; border: none; background: transparent; color: #ef4444; font-weight: 600; font-size: 14px; padding: 10px 18px; text-align: left; border-radius: 12px; cursor: pointer; display: flex; align-items: center; gap: 12px; transition: background 0.2s; }
|
||||
.sidebar-logout button:hover { background: #fef2f2; }
|
||||
|
||||
.main { flex: 1; background: #f5f9ff; display: flex; flex-direction: column; }
|
||||
/* ── TOGGLE BUTTON ── */
|
||||
.sidebar-toggle-btn {
|
||||
position: fixed; top: 50%; transform: translateY(-50%);
|
||||
left: 260px; z-index: 1000;
|
||||
width: 22px; height: 48px;
|
||||
background: #2b8ef3; border: none;
|
||||
border-radius: 0 10px 10px 0;
|
||||
cursor: pointer;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
transition: left 0.3s ease, background 0.2s;
|
||||
box-shadow: 2px 0 8px rgba(43,142,243,0.3);
|
||||
}
|
||||
.sidebar-toggle-btn:hover { background: #1a7ae0; }
|
||||
.sidebar-toggle-btn.collapsed { left: 0; }
|
||||
.toggle-arrow { width: 12px; height: 12px; fill: none; stroke: white; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.3s ease; }
|
||||
.sidebar-toggle-btn.collapsed .toggle-arrow { transform: rotate(180deg); }
|
||||
|
||||
.topbar { background: #2b8ef3; margin: 20px; padding: 16px 24px; border-radius: 16px; color: white; display: flex; justify-content: space-between; align-items: center; }
|
||||
.topbar-left { font-weight: 600; font-size: 16px; }
|
||||
/* ── MAIN ── */
|
||||
.main { flex: 1; background: #f5f9ff; display: flex; flex-direction: column; min-width: 0; }
|
||||
|
||||
.topbar { background: #2b8ef3; margin: 20px; padding: 16px 24px; border-radius: 16px; color: white; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 8px 24px rgba(43,142,243,0.25); }
|
||||
.topbar-left { font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 10px; }
|
||||
.topbar-right { display: flex; align-items: center; gap: 14px; }
|
||||
.topbar-icon { width: 24px; height: 24px; cursor: pointer; }
|
||||
|
||||
.topbar-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,0.5); cursor: pointer; transition: border-color 0.2s; display: block; }
|
||||
.topbar-avatar:hover { border-color: white; }
|
||||
|
||||
.topbar-avatar-icon { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.2); border: 2px solid rgba(255,255,255,0.4); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.2s; flex-shrink: 0; text-decoration: none; }
|
||||
.topbar-avatar-icon:hover { background: rgba(255,255,255,0.3); }
|
||||
.topbar-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,0.5); cursor: pointer; transition: all 0.2s; display: block; }
|
||||
.topbar-avatar:hover { border-color: white; transform: scale(1.05); }
|
||||
.topbar-avatar-icon { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.2); border: 2px solid rgba(255,255,255,0.4); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.2s; flex-shrink: 0; }
|
||||
.topbar-avatar-icon:hover { background: rgba(255,255,255,0.35); }
|
||||
.topbar-avatar-icon svg { width: 20px; height: 20px; stroke: white; }
|
||||
|
||||
.content { padding: 20px 30px; flex: 1; }
|
||||
.content { padding: 0 28px 28px; flex: 1; }
|
||||
|
||||
/* ── PROFILE MODAL ── */
|
||||
.profile-modal-overlay { position: fixed; inset: 0; background: rgba(15,31,61,0.45); backdrop-filter: blur(4px); z-index: 9999; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
|
||||
.profile-modal-overlay.show { opacity: 1; pointer-events: all; }
|
||||
.profile-modal { background: white; border-radius: 24px; width: 100%; max-width: 440px; padding: 32px; box-shadow: 0 24px 60px rgba(0,0,0,0.18); transform: translateY(20px) scale(0.97); transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1); position: relative; max-height: 90vh; overflow-y: auto; }
|
||||
.profile-modal-overlay.show .profile-modal { transform: translateY(0) scale(1); }
|
||||
.modal-close { position: absolute; top: 18px; right: 18px; width: 32px; height: 32px; border-radius: 50%; background: #f1f5f9; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s; }
|
||||
.modal-close:hover { background: #e2e8f0; }
|
||||
.modal-close svg { width: 16px; height: 16px; stroke: #64748b; }
|
||||
.modal-title { font-size: 18px; font-weight: 800; color: #0d1b2e; margin-bottom: 4px; }
|
||||
.modal-subtitle { font-size: 13px; color: #94a3b8; margin-bottom: 22px; }
|
||||
.foto-upload-area { display: flex; align-items: center; gap: 18px; background: #f8fafc; border-radius: 14px; padding: 14px 18px; margin-bottom: 18px; border: 1.5px dashed #e2e8f0; transition: border-color 0.2s; }
|
||||
.foto-upload-area:hover { border-color: #2b8ef3; }
|
||||
.foto-circle { width: 68px; height: 68px; border-radius: 50%; overflow: hidden; background: #e6f0ff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: 3px solid #dbeeff; }
|
||||
.foto-circle img { width: 100%; height: 100%; object-fit: cover; }
|
||||
.foto-circle svg { width: 34px; height: 34px; stroke: #2b8ef3; }
|
||||
.foto-info p { font-size: 12px; color: #94a3b8; margin: 0 0 7px; }
|
||||
.btn-pilih-foto { display: inline-block; background: #e6f0ff; color: #2b8ef3; font-size: 12px; font-weight: 700; padding: 7px 15px; border-radius: 8px; cursor: pointer; border: none; transition: background 0.2s; }
|
||||
.btn-pilih-foto:hover { background: #dbeeff; }
|
||||
.modal-field { margin-bottom: 13px; }
|
||||
.modal-label { display: block; font-size: 11px; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
|
||||
.modal-label span { color: #94a3b8; font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 10px; margin-left: 4px; }
|
||||
.modal-input { width: 100%; background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 10px; padding: 10px 13px; font-size: 14px; font-family: 'Poppins', sans-serif; color: #1e293b; outline: none; transition: all 0.2s; }
|
||||
.modal-input:focus { border-color: #2b8ef3; background: white; box-shadow: 0 0 0 3px rgba(43,142,243,0.1); }
|
||||
.modal-input:disabled { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; }
|
||||
.modal-divider { border: none; border-top: 1px solid #f1f5f9; margin: 16px 0; }
|
||||
.btn-save-modal { width: 100%; background: linear-gradient(135deg,#2b8ef3,#1a7ae0); color: white; border: none; border-radius: 12px; padding: 13px; font-size: 14px; font-weight: 700; font-family: 'Poppins', sans-serif; cursor: pointer; transition: all 0.2s; box-shadow: 0 6px 18px rgba(43,142,243,0.3); }
|
||||
.btn-save-modal:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(43,142,243,0.35); }
|
||||
.btn-save-modal:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
|
||||
.modal-toast { border-radius: 10px; padding: 10px 14px; font-size: 13px; font-weight: 500; margin-bottom: 13px; display: none; }
|
||||
.modal-toast.success { background: #f0fdf4; border: 1.5px solid #86efac; color: #166534; display: block; }
|
||||
.modal-toast.error { background: #fef2f2; border: 1.5px solid #fca5a5; color: #991b1b; display: block; }
|
||||
</style>
|
||||
|
||||
@stack('styles')
|
||||
|
|
@ -48,7 +113,7 @@
|
|||
<body>
|
||||
<div class="admin-wrapper">
|
||||
|
||||
<aside class="sidebar">
|
||||
<aside class="sidebar" id="mainSidebar">
|
||||
<div class="sidebar-logo">
|
||||
<img src="{{ asset('images/logo/logosmk.png') }}" alt="Logo SMK">
|
||||
</div>
|
||||
|
|
@ -91,29 +156,31 @@
|
|||
|
||||
<form action="{{ route('admin.logout') }}" method="POST" class="sidebar-logout">
|
||||
@csrf
|
||||
<button type="submit">Logout</button>
|
||||
<button type="submit">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></svg>
|
||||
Logout
|
||||
</button>
|
||||
</form>
|
||||
</aside>
|
||||
|
||||
<button class="sidebar-toggle-btn" id="sidebarToggleBtn">
|
||||
<svg class="toggle-arrow" viewBox="0 0 24 24"><polyline points="15 18 9 12 15 6"></polyline></svg>
|
||||
</button>
|
||||
|
||||
<div class="main">
|
||||
<header class="topbar">
|
||||
<div class="topbar-left">
|
||||
👋 Hai, {{ Auth::guard('admin')->user()->username ?? 'Admin' }}
|
||||
👋 Hai, <span id="topbar-username">{{ Auth::guard('admin')->user()->username ?? 'Admin' }}</span>
|
||||
</div>
|
||||
<div class="topbar-right">
|
||||
<img src="{{ asset('images/icon/sidebar/notif.png') }}" class="topbar-icon" alt="Notification">
|
||||
|
||||
@php $admin = Auth::guard('admin')->user(); @endphp
|
||||
@if($admin->foto_profil)
|
||||
<a href="{{ route('admin.profile.edit') }}">
|
||||
<img src="{{ Storage::url($admin->foto_profil) }}" class="topbar-avatar" alt="Profil">
|
||||
</a>
|
||||
<img src="{{ Storage::url($admin->foto_profil) }}" class="topbar-avatar" id="topbar-foto" onclick="openProfileModal()" alt="Profil">
|
||||
@else
|
||||
<a href="{{ route('admin.profile.edit') }}" class="topbar-avatar-icon">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="12" cy="8" r="4"/><path d="M4 20c0-4 3.6-7 8-7s8 3 8 7"/>
|
||||
</svg>
|
||||
</a>
|
||||
<div class="topbar-avatar-icon" id="topbar-foto-icon" onclick="openProfileModal()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="4"/><path d="M4 20c0-4 3.6-7 8-7s8 3 8 7"/></svg>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</header>
|
||||
|
|
@ -124,7 +191,153 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{{-- PROFILE MODAL --}}
|
||||
<div class="profile-modal-overlay" id="profileModalOverlay" onclick="closeOnOverlay(event)">
|
||||
<div class="profile-modal">
|
||||
<button class="modal-close" onclick="closeProfileModal()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
||||
</button>
|
||||
<div class="modal-title">Edit Profil</div>
|
||||
<div class="modal-subtitle">Perbarui foto, username, dan password</div>
|
||||
<div id="modal-toast" class="modal-toast"></div>
|
||||
<form id="profile-form" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="foto-upload-area">
|
||||
<div class="foto-circle">
|
||||
@if($admin->foto_profil)
|
||||
<img src="{{ Storage::url($admin->foto_profil) }}" id="modal-foto-preview" alt="">
|
||||
@else
|
||||
<svg id="modal-foto-icon" viewBox="0 0 24 24" fill="none" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="4"/><path d="M4 20c0-4 3.6-7 8-7s8 3 8 7"/></svg>
|
||||
<img src="" id="modal-foto-preview" alt="" style="display:none">
|
||||
@endif
|
||||
</div>
|
||||
<div class="foto-info">
|
||||
<p>JPG, PNG, WEBP · Maks. 2MB</p>
|
||||
<label for="modal-foto-input" class="btn-pilih-foto">Pilih Foto</label>
|
||||
<input type="file" name="foto_profil" id="modal-foto-input" accept="image/*" style="display:none">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-field">
|
||||
<label class="modal-label">Username</label>
|
||||
<input type="text" name="username" class="modal-input" value="{{ $admin->username }}" required>
|
||||
</div>
|
||||
<hr class="modal-divider">
|
||||
<div class="modal-field">
|
||||
<label class="modal-label">Password Baru <span>(kosongkan jika tidak ingin mengubah)</span></label>
|
||||
<input type="password" name="password" class="modal-input" placeholder="Password baru" autocomplete="new-password">
|
||||
</div>
|
||||
<div class="modal-field">
|
||||
<label class="modal-label">Konfirmasi Password</label>
|
||||
<input type="password" name="password_confirmation" class="modal-input" placeholder="Ulangi password baru" autocomplete="new-password">
|
||||
</div>
|
||||
<button type="submit" class="btn-save-modal" id="btn-save">Simpan Perubahan</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
// ── Sidebar toggle ──
|
||||
const sidebar = document.getElementById('mainSidebar');
|
||||
const toggleBtn = document.getElementById('sidebarToggleBtn');
|
||||
const SIDEBAR_W = 260;
|
||||
|
||||
function updateToggle(isCollapsed) {
|
||||
toggleBtn.style.left = isCollapsed ? '0px' : SIDEBAR_W + 'px';
|
||||
isCollapsed ? toggleBtn.classList.add('collapsed') : toggleBtn.classList.remove('collapsed');
|
||||
}
|
||||
|
||||
toggleBtn.addEventListener('click', function () {
|
||||
const isCollapsed = sidebar.classList.contains('collapsed');
|
||||
sidebar.classList.toggle('collapsed');
|
||||
updateToggle(!isCollapsed);
|
||||
localStorage.setItem('adminSidebarOpen', isCollapsed ? 'true' : 'false');
|
||||
});
|
||||
|
||||
// Restore state — admin/guru default OPEN
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
const saved = localStorage.getItem('adminSidebarOpen');
|
||||
if (saved === 'false') {
|
||||
sidebar.classList.add('collapsed');
|
||||
updateToggle(true);
|
||||
} else {
|
||||
updateToggle(false);
|
||||
}
|
||||
});
|
||||
|
||||
// ── Profile Modal ──
|
||||
function openProfileModal() {
|
||||
document.getElementById('profileModalOverlay').classList.add('show');
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
|
||||
function closeProfileModal() {
|
||||
document.getElementById('profileModalOverlay').classList.remove('show');
|
||||
document.body.style.overflow = '';
|
||||
const toast = document.getElementById('modal-toast');
|
||||
toast.className = 'modal-toast'; toast.textContent = '';
|
||||
}
|
||||
|
||||
function closeOnOverlay(e) {
|
||||
if (e.target === document.getElementById('profileModalOverlay')) closeProfileModal();
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', e => { if (e.key === 'Escape') closeProfileModal(); });
|
||||
|
||||
document.getElementById('modal-foto-input').addEventListener('change', function () {
|
||||
const file = this.files[0]; if (!file) return;
|
||||
const url = URL.createObjectURL(file);
|
||||
const preview = document.getElementById('modal-foto-preview');
|
||||
const icon = document.getElementById('modal-foto-icon');
|
||||
preview.src = url; preview.style.display = 'block';
|
||||
if (icon) icon.style.display = 'none';
|
||||
});
|
||||
|
||||
document.getElementById('profile-form').addEventListener('submit', async function (e) {
|
||||
e.preventDefault();
|
||||
const btn = document.getElementById('btn-save');
|
||||
const toast = document.getElementById('modal-toast');
|
||||
btn.disabled = true; btn.textContent = 'Menyimpan...';
|
||||
const formData = new FormData(this);
|
||||
try {
|
||||
const res = await fetch('{{ route("admin.profile.update") }}', {
|
||||
method: 'POST',
|
||||
headers: { 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content },
|
||||
body: formData,
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.success) {
|
||||
if (data.foto_url) {
|
||||
const topbarFoto = document.getElementById('topbar-foto');
|
||||
const topbarIcon = document.getElementById('topbar-foto-icon');
|
||||
if (topbarFoto) { topbarFoto.src = data.foto_url + '?t=' + Date.now(); }
|
||||
else if (topbarIcon) {
|
||||
const img = document.createElement('img');
|
||||
img.src = data.foto_url + '?t=' + Date.now();
|
||||
img.className = 'topbar-avatar'; img.id = 'topbar-foto';
|
||||
img.onclick = openProfileModal; img.alt = 'Profil';
|
||||
topbarIcon.replaceWith(img);
|
||||
}
|
||||
const mp = document.getElementById('modal-foto-preview');
|
||||
const mi = document.getElementById('modal-foto-icon');
|
||||
if (mp) { mp.src = data.foto_url; mp.style.display = 'block'; }
|
||||
if (mi) mi.style.display = 'none';
|
||||
}
|
||||
if (data.username) document.getElementById('topbar-username').textContent = data.username;
|
||||
toast.className = 'modal-toast success'; toast.textContent = '✓ ' + data.message;
|
||||
this.querySelector('[name="password"]').value = '';
|
||||
this.querySelector('[name="password_confirmation"]').value = '';
|
||||
} else {
|
||||
const errors = data.errors ? Object.values(data.errors).flat().join(' · ') : 'Terjadi kesalahan.';
|
||||
toast.className = 'modal-toast error'; toast.textContent = errors;
|
||||
}
|
||||
} catch (err) {
|
||||
toast.className = 'modal-toast error'; toast.textContent = 'Gagal terhubung ke server.';
|
||||
} finally {
|
||||
btn.disabled = false; btn.textContent = 'Simpan Perubahan';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@stack('scripts')
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -2,47 +2,192 @@
|
|||
|
||||
@section('title', 'Dashboard Guru')
|
||||
|
||||
@push('styles')
|
||||
<style>
|
||||
.dash-header { margin-bottom: 28px; }
|
||||
.dash-title { font-size: 22px; font-weight: 800; color: #0f1f3d; margin-bottom: 2px; }
|
||||
.dash-sub { font-size: 13px; color: #94a3b8; }
|
||||
|
||||
/* STAT CARDS */
|
||||
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 28px; }
|
||||
|
||||
.stat-card {
|
||||
border-radius: 20px; padding: 28px 24px;
|
||||
position: relative; overflow: hidden;
|
||||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||
animation: fadeUp 0.4s ease both;
|
||||
}
|
||||
|
||||
.stat-card:hover { transform: translateY(-4px); box-shadow: 0 16px 40px rgba(0,0,0,0.12); }
|
||||
|
||||
.stat-card:nth-child(1) { background: linear-gradient(135deg, #eef4ff, #c5d9ff); animation-delay: 0s; }
|
||||
.stat-card:nth-child(2) { background: linear-gradient(135deg, #e8fff3, #b8f5d4); animation-delay: 0.07s; }
|
||||
.stat-card:nth-child(3) { background: linear-gradient(135deg, #fff7e6, #ffe4b2); animation-delay: 0.14s; }
|
||||
|
||||
.stat-card::after { content: ''; position: absolute; width: 120px; height: 120px; border-radius: 50%; opacity: 0.15; right: -30px; bottom: -30px; }
|
||||
.stat-card:nth-child(1)::after { background: #2b8ef3; }
|
||||
.stat-card:nth-child(2)::after { background: #22c55e; }
|
||||
.stat-card:nth-child(3)::after { background: #f97316; }
|
||||
|
||||
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 10px; }
|
||||
.stat-card:nth-child(1) .stat-label { color: #1d5fb8; }
|
||||
.stat-card:nth-child(2) .stat-label { color: #15803d; }
|
||||
.stat-card:nth-child(3) .stat-label { color: #c2651a; }
|
||||
|
||||
.stat-num { font-size: 42px; font-weight: 800; line-height: 1; color: #0f1f3d; }
|
||||
.stat-icon { position: absolute; top: 20px; right: 20px; width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; opacity: 0.7; }
|
||||
.stat-card:nth-child(1) .stat-icon { background: rgba(43,142,243,0.15); }
|
||||
.stat-card:nth-child(2) .stat-icon { background: rgba(34,197,94,0.15); }
|
||||
.stat-card:nth-child(3) .stat-icon { background: rgba(249,115,22,0.15); }
|
||||
|
||||
/* INFO CARD */
|
||||
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; animation: fadeUp 0.4s ease 0.25s both; }
|
||||
|
||||
.dash-card { background: white; border-radius: 20px; border: 1.5px solid #e8f0fb; padding: 24px; box-shadow: 0 4px 20px rgba(43,142,243,0.06); }
|
||||
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
|
||||
.card-title { font-size: 15px; font-weight: 700; color: #0f1f3d; }
|
||||
.card-badge { font-size: 11px; font-weight: 700; background: #e8f4ff; color: #2b8ef3; padding: 3px 10px; border-radius: 99px; text-decoration: none; }
|
||||
.card-badge:hover { background: #dbeeff; color: #2b8ef3; }
|
||||
|
||||
/* Mapel list */
|
||||
.mapel-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; margin-bottom: 8px; background: #f8faff; transition: background 0.2s; }
|
||||
.mapel-item:hover { background: #eef4ff; }
|
||||
.mapel-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
|
||||
.mapel-name { font-size: 13px; font-weight: 600; color: #1e293b; flex: 1; }
|
||||
.mapel-kelas { font-size: 11px; color: #94a3b8; }
|
||||
|
||||
/* Quick links */
|
||||
.quick-link {
|
||||
display: flex; align-items: center; gap: 14px;
|
||||
padding: 14px 16px; border-radius: 14px;
|
||||
background: #f8faff; border: 1.5px solid #e8f0fb;
|
||||
text-decoration: none; margin-bottom: 10px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.quick-link:hover { background: #eef4ff; border-color: #2b8ef3; transform: translateX(4px); }
|
||||
.ql-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
|
||||
.ql-title { font-size: 13px; font-weight: 700; color: #0f1f3d; margin-bottom: 1px; }
|
||||
.ql-desc { font-size: 11px; color: #94a3b8; }
|
||||
.ql-arrow { margin-left: auto; color: #94a3b8; font-size: 16px; }
|
||||
|
||||
@keyframes fadeUp {
|
||||
from { opacity: 0; transform: translateY(16px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.stat-grid { grid-template-columns: 1fr 1fr; }
|
||||
.info-grid { grid-template-columns: 1fr; }
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
<div class="container mt-5">
|
||||
|
||||
<h1 class="mb-4 fw-bold text-primary">Dashboard Guru</h1>
|
||||
@php
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Mengajar;
|
||||
$guru = Auth::guard('guru')->user();
|
||||
$greeting = Carbon::now()->hour < 12 ? 'Selamat Pagi' : (Carbon::now()->hour < 17 ? 'Selamat Siang' : 'Selamat Malam');
|
||||
|
||||
<div class="row">
|
||||
// Ambil mengajar dengan relasi mapel & kelas
|
||||
$mengajars = Mengajar::with(['mapel', 'kelas'])
|
||||
->where('id_guru', $guru->id_guru)
|
||||
->get();
|
||||
@endphp
|
||||
|
||||
<div class="col-md-4 mb-3">
|
||||
<div class="card text-center shadow-sm">
|
||||
<div class="card-body">
|
||||
<h5>Total Kelas Diampu</h5>
|
||||
<p class="fs-3 fw-bold text-success">
|
||||
{{ $totalKelas }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dash-header">
|
||||
<div class="dash-title">{{ $greeting }}, {{ $guru->nama ?? 'Guru' }} 👋</div>
|
||||
<div class="dash-sub">{{ Carbon::now()->isoFormat('dddd, D MMMM Y') }}</div>
|
||||
</div>
|
||||
|
||||
{{-- STAT CARDS --}}
|
||||
<div class="stat-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">🏫</div>
|
||||
<div class="stat-label">Kelas Diampu</div>
|
||||
<div class="stat-num">{{ $totalKelas }}</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">📚</div>
|
||||
<div class="stat-label">Mata Pelajaran</div>
|
||||
<div class="stat-num">{{ $totalMapel }}</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">👨🎓</div>
|
||||
<div class="stat-label">Siswa Diajar</div>
|
||||
<div class="stat-num">{{ $totalSiswa }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- INFO GRID --}}
|
||||
<div class="info-grid">
|
||||
|
||||
{{-- Daftar Mengajar --}}
|
||||
<div class="dash-card">
|
||||
<div class="card-head">
|
||||
<div class="card-title">Mata Pelajaran & Kelas</div>
|
||||
<a href="{{ route('guru.mapel.index') }}" class="card-badge">Lihat Semua →</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 mb-3">
|
||||
<div class="card text-center shadow-sm">
|
||||
<div class="card-body">
|
||||
<h5>Total Mata Pelajaran</h5>
|
||||
<p class="fs-3 fw-bold text-primary">
|
||||
{{ $totalMapel }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@php $dotColors = ['#2b8ef3','#22c55e','#f97316','#a855f7','#ec4899','#eab308']; @endphp
|
||||
|
||||
@forelse($mengajars->take(6) as $i => $m)
|
||||
<div class="mapel-item">
|
||||
<div class="mapel-dot" style="background:{{ $dotColors[$i % count($dotColors)] }}"></div>
|
||||
<div class="mapel-name">{{ optional($m->mapel)->nama_mapel ?? '-' }}</div>
|
||||
<div class="mapel-kelas">{{ optional($m->kelas)->nama_kelas ?? '-' }}</div>
|
||||
</div>
|
||||
@empty
|
||||
<div style="text-align:center;padding:20px;color:#94a3b8;font-size:13px;">
|
||||
Belum ada data mengajar.
|
||||
</div>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
{{-- Quick Links --}}
|
||||
<div class="dash-card">
|
||||
<div class="card-head">
|
||||
<div class="card-title">Akses Cepat</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 mb-3">
|
||||
<div class="card text-center shadow-sm">
|
||||
<div class="card-body">
|
||||
<h5>Total Siswa Diajar</h5>
|
||||
<p class="fs-3 fw-bold text-warning">
|
||||
{{ $totalSiswa }}
|
||||
</p>
|
||||
</div>
|
||||
<a href="{{ route('guru.mapel.index') }}" class="quick-link">
|
||||
<div class="ql-icon" style="background:#e8f4ff">📖</div>
|
||||
<div>
|
||||
<div class="ql-title">Upload Materi</div>
|
||||
<div class="ql-desc">Tambah modul belajar untuk siswa</div>
|
||||
</div>
|
||||
</div>
|
||||
<span class="ql-arrow">›</span>
|
||||
</a>
|
||||
|
||||
<a href="{{ route('guru.mapel.index') }}" class="quick-link">
|
||||
<div class="ql-icon" style="background:#eefaf3">📝</div>
|
||||
<div>
|
||||
<div class="ql-title">Buat Tugas</div>
|
||||
<div class="ql-desc">Buat dan kelola tugas kelas</div>
|
||||
</div>
|
||||
<span class="ql-arrow">›</span>
|
||||
</a>
|
||||
|
||||
<a href="{{ route('guru.tugas.history') }}" class="quick-link">
|
||||
<div class="ql-icon" style="background:#fff7e6">📋</div>
|
||||
<div>
|
||||
<div class="ql-title">History Tugas</div>
|
||||
<div class="ql-desc">Lihat pengumpulan tugas siswa</div>
|
||||
</div>
|
||||
<span class="ql-arrow">›</span>
|
||||
</a>
|
||||
|
||||
<a href="{{ route('guru.leaderboard.index') }}" class="quick-link">
|
||||
<div class="ql-icon" style="background:#f5eeff">🏆</div>
|
||||
<div>
|
||||
<div class="ql-title">Leaderboard</div>
|
||||
<div class="ql-desc">Pantau peringkat EXP kelas</div>
|
||||
</div>
|
||||
<span class="ql-arrow">›</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@endsection
|
||||
|
|
@ -3,41 +3,81 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<title>@yield('title', 'Panel Guru')</title>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
body { font-family: 'Poppins', sans-serif; background-color: #f8f9fa; margin: 0; }
|
||||
body { font-family: 'Poppins', sans-serif; background-color: #f5f9ff; margin: 0; }
|
||||
.wrapper { display: flex; min-height: 100vh; }
|
||||
|
||||
.sidebar { width: 260px; background: #ffffff; border-right: 2px solid #e6f0ff; padding: 30px 20px; display: flex; flex-direction: column; }
|
||||
.sidebar-logo { text-align: center; margin-bottom: 40px; }
|
||||
.sidebar { width: 260px; background: #ffffff; border-right: 2px solid #e6f0ff; padding: 30px 20px; display: flex; flex-direction: column; transition: width 0.3s ease, padding 0.3s ease; overflow: hidden; flex-shrink: 0; }
|
||||
.sidebar.collapsed { width: 0; padding: 0; border-right: none; }
|
||||
.sidebar-logo { text-align: center; margin-bottom: 40px; white-space: nowrap; }
|
||||
.sidebar-logo img { width: 90px; }
|
||||
|
||||
.sidebar-link { display: flex; align-items: center; gap: 12px; padding: 12px 18px; margin-bottom: 12px; border-radius: 12px; color: #64748b; text-decoration: none; font-weight: 500; transition: all 0.2s ease; }
|
||||
.sidebar-link { display: flex; align-items: center; gap: 12px; padding: 12px 18px; margin-bottom: 6px; border-radius: 12px; color: #64748b; text-decoration: none; font-weight: 500; font-size: 14px; transition: all 0.2s ease; white-space: nowrap; }
|
||||
.sidebar-link:hover { background: #e6f0ff; color: #1d4ed8; }
|
||||
.sidebar-link.active { background: #e6f0ff; color: #1d4ed8; }
|
||||
.sidebar-icon { width: 20px; height: 20px; flex-shrink: 0; }
|
||||
.sidebar-logout { margin-top: auto; }
|
||||
.sidebar-logout { margin-top: auto; padding-top: 16px; border-top: 1px solid #f1f5f9; }
|
||||
.sidebar-logout button { width: 100%; border: none; background: transparent; color: #ef4444; font-weight: 600; font-size: 14px; padding: 10px 18px; text-align: left; border-radius: 12px; cursor: pointer; display: flex; align-items: center; gap: 12px; transition: background 0.2s; }
|
||||
.sidebar-logout button:hover { background: #fef2f2; }
|
||||
|
||||
.main { flex: 1; background: #f5f9ff; display: flex; flex-direction: column; }
|
||||
.sidebar-toggle-btn { position: fixed; top: 50%; transform: translateY(-50%); left: 260px; z-index: 1000; width: 22px; height: 48px; background: #2b8ef3; border: none; border-radius: 0 10px 10px 0; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: left 0.3s ease, background 0.2s; box-shadow: 2px 0 8px rgba(43,142,243,0.3); }
|
||||
.sidebar-toggle-btn:hover { background: #1a7ae0; }
|
||||
.sidebar-toggle-btn.collapsed { left: 0; }
|
||||
.toggle-arrow { width: 12px; height: 12px; fill: none; stroke: white; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.3s ease; }
|
||||
.sidebar-toggle-btn.collapsed .toggle-arrow { transform: rotate(180deg); }
|
||||
|
||||
.topbar { background: #2b8ef3; margin: 20px; padding: 16px 24px; border-radius: 16px; color: white; display: flex; justify-content: space-between; align-items: center; }
|
||||
.main { flex: 1; background: #f5f9ff; display: flex; flex-direction: column; min-width: 0; }
|
||||
.topbar { background: #2b8ef3; margin: 20px; padding: 16px 24px; border-radius: 16px; color: white; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 8px 24px rgba(43,142,243,0.25); }
|
||||
.topbar-left { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
|
||||
.topbar-waving { width: 26px; height: 26px; }
|
||||
.topbar-right { display: flex; align-items: center; gap: 14px; }
|
||||
.topbar-icon { width: 24px; height: 24px; cursor: pointer; }
|
||||
|
||||
.topbar-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,0.5); cursor: pointer; transition: border-color 0.2s; display: block; }
|
||||
.topbar-avatar:hover { border-color: white; }
|
||||
|
||||
.topbar-avatar-icon { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.2); border: 2px solid rgba(255,255,255,0.4); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.2s; flex-shrink: 0; text-decoration: none; }
|
||||
.topbar-avatar-icon:hover { background: rgba(255,255,255,0.3); }
|
||||
.topbar-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,0.5); cursor: pointer; transition: all 0.2s; display: block; }
|
||||
.topbar-avatar:hover { border-color: white; transform: scale(1.05); }
|
||||
.topbar-avatar-icon { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.2); border: 2px solid rgba(255,255,255,0.4); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.2s; flex-shrink: 0; }
|
||||
.topbar-avatar-icon:hover { background: rgba(255,255,255,0.35); }
|
||||
.topbar-avatar-icon svg { width: 20px; height: 20px; stroke: white; }
|
||||
|
||||
.content { padding: 20px 30px; flex: 1; }
|
||||
.content { padding: 0 28px 28px; flex: 1; }
|
||||
|
||||
/* MODAL */
|
||||
.profile-modal-overlay { position: fixed; inset: 0; background: rgba(15,31,61,0.45); backdrop-filter: blur(4px); z-index: 9999; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
|
||||
.profile-modal-overlay.show { opacity: 1; pointer-events: all; }
|
||||
.profile-modal { background: white; border-radius: 24px; width: 100%; max-width: 440px; padding: 32px; box-shadow: 0 24px 60px rgba(0,0,0,0.18); transform: translateY(20px) scale(0.97); transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1); position: relative; max-height: 90vh; overflow-y: auto; }
|
||||
.profile-modal-overlay.show .profile-modal { transform: translateY(0) scale(1); }
|
||||
.modal-close { position: absolute; top: 18px; right: 18px; width: 32px; height: 32px; border-radius: 50%; background: #f1f5f9; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s; }
|
||||
.modal-close:hover { background: #e2e8f0; }
|
||||
.modal-close svg { width: 16px; height: 16px; stroke: #64748b; }
|
||||
.modal-title { font-size: 18px; font-weight: 800; color: #0d1b2e; margin-bottom: 4px; }
|
||||
.modal-subtitle { font-size: 13px; color: #94a3b8; margin-bottom: 22px; }
|
||||
.foto-upload-area { display: flex; align-items: center; gap: 18px; background: #f8fafc; border-radius: 14px; padding: 14px 18px; margin-bottom: 18px; border: 1.5px dashed #e2e8f0; transition: border-color 0.2s; }
|
||||
.foto-upload-area:hover { border-color: #2b8ef3; }
|
||||
.foto-circle { width: 68px; height: 68px; border-radius: 50%; overflow: hidden; background: #e6f0ff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: 3px solid #dbeeff; }
|
||||
.foto-circle img { width: 100%; height: 100%; object-fit: cover; }
|
||||
.foto-circle svg { width: 34px; height: 34px; stroke: #2b8ef3; }
|
||||
.foto-info p { font-size: 12px; color: #94a3b8; margin: 0 0 7px; }
|
||||
.btn-pilih-foto { display: inline-block; background: #e6f0ff; color: #2b8ef3; font-size: 12px; font-weight: 700; padding: 7px 15px; border-radius: 8px; cursor: pointer; border: none; transition: background 0.2s; }
|
||||
.btn-pilih-foto:hover { background: #dbeeff; }
|
||||
.modal-field { margin-bottom: 13px; }
|
||||
.modal-label { display: block; font-size: 11px; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
|
||||
.modal-label span { color: #94a3b8; font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 10px; margin-left: 4px; }
|
||||
.modal-input { width: 100%; background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 10px; padding: 10px 13px; font-size: 14px; font-family: 'Poppins', sans-serif; color: #1e293b; outline: none; transition: all 0.2s; }
|
||||
.modal-input:focus { border-color: #2b8ef3; background: white; box-shadow: 0 0 0 3px rgba(43,142,243,0.1); }
|
||||
.modal-input:disabled { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; }
|
||||
.modal-divider { border: none; border-top: 1px solid #f1f5f9; margin: 16px 0; }
|
||||
.btn-save-modal { width: 100%; background: linear-gradient(135deg,#2b8ef3,#1a7ae0); color: white; border: none; border-radius: 12px; padding: 13px; font-size: 14px; font-weight: 700; font-family: 'Poppins', sans-serif; cursor: pointer; transition: all 0.2s; box-shadow: 0 6px 18px rgba(43,142,243,0.3); }
|
||||
.btn-save-modal:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(43,142,243,0.35); }
|
||||
.btn-save-modal:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
|
||||
.modal-toast { border-radius: 10px; padding: 10px 14px; font-size: 13px; font-weight: 500; margin-bottom: 13px; display: none; }
|
||||
.modal-toast.success { background: #f0fdf4; border: 1.5px solid #86efac; color: #166534; display: block; }
|
||||
.modal-toast.error { background: #fef2f2; border: 1.5px solid #fca5a5; color: #991b1b; display: block; }
|
||||
</style>
|
||||
|
||||
@stack('styles')
|
||||
|
|
@ -45,10 +85,8 @@
|
|||
<body>
|
||||
<div class="wrapper">
|
||||
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-logo">
|
||||
<img src="{{ asset('images/logo/logosmk.png') }}" alt="Logo">
|
||||
</div>
|
||||
<aside class="sidebar" id="mainSidebar">
|
||||
<div class="sidebar-logo"><img src="{{ asset('images/logo/logosmk.png') }}" alt="Logo"></div>
|
||||
|
||||
<a href="{{ route('guru.dashboard') }}" class="sidebar-link {{ request()->routeIs('guru.dashboard') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/home.png') }}" class="sidebar-icon"><span>Dashboard</span>
|
||||
|
|
@ -71,10 +109,17 @@
|
|||
|
||||
<form action="{{ route('guru.logout') }}" method="POST" class="sidebar-logout">
|
||||
@csrf
|
||||
<button type="submit" class="btn btn-danger w-100">Logout</button>
|
||||
<button type="submit">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></svg>
|
||||
Logout
|
||||
</button>
|
||||
</form>
|
||||
</aside>
|
||||
|
||||
<button class="sidebar-toggle-btn" id="sidebarToggleBtn">
|
||||
<svg class="toggle-arrow" viewBox="0 0 24 24"><polyline points="15 18 9 12 15 6"></polyline></svg>
|
||||
</button>
|
||||
|
||||
<div class="main">
|
||||
<header class="topbar">
|
||||
<div class="topbar-left">
|
||||
|
|
@ -83,18 +128,13 @@
|
|||
</div>
|
||||
<div class="topbar-right">
|
||||
<img src="{{ asset('images/icon/sidebar/notif.png') }}" class="topbar-icon" alt="Notification">
|
||||
|
||||
@php $guru = Auth::guard('guru')->user(); @endphp
|
||||
@if($guru->foto_profil)
|
||||
<a href="{{ route('guru.profile.edit') }}">
|
||||
<img src="{{ Storage::url($guru->foto_profil) }}" class="topbar-avatar" alt="Profil">
|
||||
</a>
|
||||
<img src="{{ Storage::url($guru->foto_profil) }}" class="topbar-avatar" id="topbar-foto" onclick="openProfileModal()" alt="Profil">
|
||||
@else
|
||||
<a href="{{ route('guru.profile.edit') }}" class="topbar-avatar-icon">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="12" cy="8" r="4"/><path d="M4 20c0-4 3.6-7 8-7s8 3 8 7"/>
|
||||
</svg>
|
||||
</a>
|
||||
<div class="topbar-avatar-icon" id="topbar-foto-icon" onclick="openProfileModal()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="4"/><path d="M4 20c0-4 3.6-7 8-7s8 3 8 7"/></svg>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</header>
|
||||
|
|
@ -103,9 +143,155 @@
|
|||
@yield('content')
|
||||
</main>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{-- PROFILE MODAL --}}
|
||||
<div class="profile-modal-overlay" id="profileModalOverlay" onclick="closeOnOverlay(event)">
|
||||
<div class="profile-modal">
|
||||
<button class="modal-close" onclick="closeProfileModal()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
||||
</button>
|
||||
<div class="modal-title">Edit Profil</div>
|
||||
<div class="modal-subtitle">Perbarui foto profil dan password</div>
|
||||
<div id="modal-toast" class="modal-toast"></div>
|
||||
<form id="profile-form" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="foto-upload-area">
|
||||
<div class="foto-circle">
|
||||
@if($guru->foto_profil)
|
||||
<img src="{{ Storage::url($guru->foto_profil) }}" id="modal-foto-preview" alt="">
|
||||
@else
|
||||
<svg id="modal-foto-icon" viewBox="0 0 24 24" fill="none" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="4"/><path d="M4 20c0-4 3.6-7 8-7s8 3 8 7"/></svg>
|
||||
<img src="" id="modal-foto-preview" alt="" style="display:none">
|
||||
@endif
|
||||
</div>
|
||||
<div class="foto-info">
|
||||
<p>JPG, PNG, WEBP · Maks. 2MB</p>
|
||||
<label for="modal-foto-input" class="btn-pilih-foto">Pilih Foto</label>
|
||||
<input type="file" name="foto_profil" id="modal-foto-input" accept="image/*" style="display:none">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-field">
|
||||
<label class="modal-label">NIP <span>(tidak dapat diubah)</span></label>
|
||||
<input type="text" class="modal-input" value="{{ $guru->nip }}" disabled>
|
||||
</div>
|
||||
<div class="modal-field">
|
||||
<label class="modal-label">Nama Lengkap <span>(tidak dapat diubah)</span></label>
|
||||
<input type="text" class="modal-input" value="{{ $guru->nama }}" disabled>
|
||||
</div>
|
||||
<hr class="modal-divider">
|
||||
<div class="modal-field">
|
||||
<label class="modal-label">Password Baru <span>(kosongkan jika tidak ingin mengubah)</span></label>
|
||||
<input type="password" name="password" class="modal-input" placeholder="Password baru" autocomplete="new-password">
|
||||
</div>
|
||||
<div class="modal-field">
|
||||
<label class="modal-label">Konfirmasi Password</label>
|
||||
<input type="password" name="password_confirmation" class="modal-input" placeholder="Ulangi password baru" autocomplete="new-password">
|
||||
</div>
|
||||
<button type="submit" class="btn-save-modal" id="btn-save">Simpan Perubahan</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
const sidebar = document.getElementById('mainSidebar');
|
||||
const toggleBtn = document.getElementById('sidebarToggleBtn');
|
||||
const SIDEBAR_W = 260;
|
||||
|
||||
function updateToggle(isCollapsed) {
|
||||
toggleBtn.style.left = isCollapsed ? '0px' : SIDEBAR_W + 'px';
|
||||
isCollapsed ? toggleBtn.classList.add('collapsed') : toggleBtn.classList.remove('collapsed');
|
||||
}
|
||||
|
||||
toggleBtn.addEventListener('click', function () {
|
||||
const isCollapsed = sidebar.classList.contains('collapsed');
|
||||
sidebar.classList.toggle('collapsed');
|
||||
updateToggle(!isCollapsed);
|
||||
localStorage.setItem('guruSidebarOpen', isCollapsed ? 'true' : 'false');
|
||||
});
|
||||
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
const saved = localStorage.getItem('guruSidebarOpen');
|
||||
if (saved === 'false') {
|
||||
sidebar.classList.add('collapsed');
|
||||
updateToggle(true);
|
||||
} else {
|
||||
updateToggle(false);
|
||||
}
|
||||
});
|
||||
|
||||
function openProfileModal() {
|
||||
document.getElementById('profileModalOverlay').classList.add('show');
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
|
||||
function closeProfileModal() {
|
||||
document.getElementById('profileModalOverlay').classList.remove('show');
|
||||
document.body.style.overflow = '';
|
||||
const toast = document.getElementById('modal-toast');
|
||||
toast.className = 'modal-toast'; toast.textContent = '';
|
||||
}
|
||||
|
||||
function closeOnOverlay(e) {
|
||||
if (e.target === document.getElementById('profileModalOverlay')) closeProfileModal();
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', e => { if (e.key === 'Escape') closeProfileModal(); });
|
||||
|
||||
document.getElementById('modal-foto-input').addEventListener('change', function () {
|
||||
const file = this.files[0]; if (!file) return;
|
||||
const url = URL.createObjectURL(file);
|
||||
const preview = document.getElementById('modal-foto-preview');
|
||||
const icon = document.getElementById('modal-foto-icon');
|
||||
preview.src = url; preview.style.display = 'block';
|
||||
if (icon) icon.style.display = 'none';
|
||||
});
|
||||
|
||||
document.getElementById('profile-form').addEventListener('submit', async function (e) {
|
||||
e.preventDefault();
|
||||
const btn = document.getElementById('btn-save');
|
||||
const toast = document.getElementById('modal-toast');
|
||||
btn.disabled = true; btn.textContent = 'Menyimpan...';
|
||||
const formData = new FormData(this);
|
||||
try {
|
||||
const res = await fetch('{{ route("guru.profile.update") }}', {
|
||||
method: 'POST',
|
||||
headers: { 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content },
|
||||
body: formData,
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.success) {
|
||||
if (data.foto_url) {
|
||||
const topbarFoto = document.getElementById('topbar-foto');
|
||||
const topbarIcon = document.getElementById('topbar-foto-icon');
|
||||
if (topbarFoto) { topbarFoto.src = data.foto_url + '?t=' + Date.now(); }
|
||||
else if (topbarIcon) {
|
||||
const img = document.createElement('img');
|
||||
img.src = data.foto_url + '?t=' + Date.now();
|
||||
img.className = 'topbar-avatar'; img.id = 'topbar-foto';
|
||||
img.onclick = openProfileModal; img.alt = 'Profil';
|
||||
topbarIcon.replaceWith(img);
|
||||
}
|
||||
const mp = document.getElementById('modal-foto-preview');
|
||||
const mi = document.getElementById('modal-foto-icon');
|
||||
if (mp) { mp.src = data.foto_url; mp.style.display = 'block'; }
|
||||
if (mi) mi.style.display = 'none';
|
||||
}
|
||||
toast.className = 'modal-toast success'; toast.textContent = '✓ ' + data.message;
|
||||
this.querySelector('[name="password"]').value = '';
|
||||
this.querySelector('[name="password_confirmation"]').value = '';
|
||||
} else {
|
||||
const errors = data.errors ? Object.values(data.errors).flat().join(' · ') : 'Terjadi kesalahan.';
|
||||
toast.className = 'modal-toast error'; toast.textContent = errors;
|
||||
}
|
||||
} catch (err) {
|
||||
toast.className = 'modal-toast error'; toast.textContent = 'Gagal terhubung ke server.';
|
||||
} finally {
|
||||
btn.disabled = false; btn.textContent = 'Simpan Perubahan';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@stack('scripts')
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -3,153 +3,88 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<title>@yield('title', 'Siswa Panel')</title>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Poppins', sans-serif;
|
||||
background-color: #f8f9fa;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.siswa-wrapper {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* ===== SIDEBAR ===== */
|
||||
.sidebar {
|
||||
width: 260px;
|
||||
background: #ffffff;
|
||||
border-right: 2px solid #e6f0ff;
|
||||
padding: 30px 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transition: width 0.3s ease, padding 0.3s ease;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.sidebar.collapsed {
|
||||
width: 0;
|
||||
padding: 0;
|
||||
border-right: none;
|
||||
}
|
||||
body { font-family: 'Poppins', sans-serif; background-color: #f8f9fa; margin: 0; }
|
||||
.siswa-wrapper { display: flex; min-height: 100vh; position: relative; }
|
||||
|
||||
.sidebar { width: 260px; background: #ffffff; border-right: 2px solid #e6f0ff; padding: 30px 20px; display: flex; flex-direction: column; transition: width 0.3s ease, padding 0.3s ease; overflow: hidden; flex-shrink: 0; }
|
||||
.sidebar.collapsed { width: 0; padding: 0; border-right: none; }
|
||||
.sidebar-logo { text-align: center; margin-bottom: 40px; white-space: nowrap; }
|
||||
.sidebar-logo img { width: 90px; }
|
||||
|
||||
.sidebar-menu { display: flex; flex-direction: column; white-space: nowrap; }
|
||||
|
||||
.sidebar-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px 18px;
|
||||
margin-bottom: 12px;
|
||||
border-radius: 12px;
|
||||
color: #64748b;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.sidebar-link { display: flex; align-items: center; gap: 12px; padding: 12px 18px; margin-bottom: 12px; border-radius: 12px; color: #64748b; text-decoration: none; font-weight: 500; transition: all 0.2s ease; }
|
||||
.sidebar-link:hover { background: #e6f0ff; color: #1d4ed8; }
|
||||
.sidebar-link.active { background: #e6f0ff; color: #1d4ed8; }
|
||||
|
||||
.sidebar-icon { width: 20px; height: 20px; flex-shrink: 0; }
|
||||
.sidebar-logout { margin-top: auto; }
|
||||
.sidebar-logout button { width: 100%; border: none; background: transparent; color: #ef4444; font-weight: 600; padding: 10px; text-align: left; }
|
||||
|
||||
/* ===== TOGGLE BUTTON ===== */
|
||||
.sidebar-toggle-btn {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
left: 260px;
|
||||
z-index: 1000;
|
||||
width: 22px;
|
||||
height: 48px;
|
||||
background: #2b8ef3;
|
||||
border: none;
|
||||
border-radius: 0 10px 10px 0;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: left 0.3s ease, background 0.2s ease;
|
||||
box-shadow: 2px 0 8px rgba(43, 142, 243, 0.3);
|
||||
}
|
||||
|
||||
.sidebar-toggle-btn { position: fixed; top: 50%; transform: translateY(-50%); left: 260px; z-index: 1000; width: 22px; height: 48px; background: #2b8ef3; border: none; border-radius: 0 10px 10px 0; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: left 0.3s ease; box-shadow: 2px 0 8px rgba(43,142,243,0.3); }
|
||||
.sidebar-toggle-btn:hover { background: #1a7ae0; }
|
||||
.sidebar-toggle-btn.collapsed { left: 0; }
|
||||
|
||||
.toggle-arrow {
|
||||
width: 12px; height: 12px;
|
||||
fill: none;
|
||||
stroke: white;
|
||||
stroke-width: 2.5;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.toggle-arrow { width: 12px; height: 12px; fill: none; stroke: white; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.3s ease; }
|
||||
.sidebar-toggle-btn.collapsed .toggle-arrow { transform: rotate(180deg); }
|
||||
|
||||
/* ===== MAIN ===== */
|
||||
.main { flex: 1; background: #f5f9ff; display: flex; flex-direction: column; transition: all 0.3s ease; min-width: 0; }
|
||||
|
||||
/* TOPBAR */
|
||||
.topbar {
|
||||
background: #2b8ef3;
|
||||
margin: 20px;
|
||||
padding: 16px 24px;
|
||||
border-radius: 16px;
|
||||
color: white;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.main { flex: 1; background: #f5f9ff; display: flex; flex-direction: column; min-width: 0; }
|
||||
|
||||
.topbar { background: #2b8ef3; margin: 20px; padding: 16px 24px; border-radius: 16px; color: white; display: flex; justify-content: space-between; align-items: center; }
|
||||
.topbar-left { font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 10px; }
|
||||
.topbar-right { display: flex; align-items: center; gap: 14px; }
|
||||
.topbar-icon { width: 24px; height: 24px; cursor: pointer; }
|
||||
|
||||
/* Foto profil di topbar */
|
||||
.topbar-avatar {
|
||||
width: 36px; height: 36px;
|
||||
border-radius: 50%;
|
||||
object-fit: cover;
|
||||
border: 2px solid rgba(255,255,255,0.5);
|
||||
cursor: pointer;
|
||||
transition: border-color 0.2s;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.topbar-avatar:hover { border-color: white; }
|
||||
|
||||
.topbar-avatar-icon {
|
||||
width: 36px; height: 36px;
|
||||
border-radius: 50%;
|
||||
background: rgba(255,255,255,0.2);
|
||||
border: 2px solid rgba(255,255,255,0.4);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.topbar-avatar-icon:hover { background: rgba(255,255,255,0.3); }
|
||||
.topbar-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,0.5); cursor: pointer; transition: all 0.2s; display: block; }
|
||||
.topbar-avatar:hover { border-color: white; transform: scale(1.05); }
|
||||
.topbar-avatar-icon { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.2); border: 2px solid rgba(255,255,255,0.4); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.2s; flex-shrink: 0; }
|
||||
.topbar-avatar-icon:hover { background: rgba(255,255,255,0.35); }
|
||||
.topbar-avatar-icon svg { width: 20px; height: 20px; stroke: white; }
|
||||
|
||||
.content { padding: 20px 30px; flex: 1; }
|
||||
|
||||
/* ── MODAL ── */
|
||||
.profile-modal-overlay { position: fixed; inset: 0; background: rgba(15,31,61,0.45); backdrop-filter: blur(4px); z-index: 9999; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
|
||||
.profile-modal-overlay.show { opacity: 1; pointer-events: all; }
|
||||
.profile-modal { background: white; border-radius: 24px; width: 100%; max-width: 440px; padding: 32px; box-shadow: 0 24px 60px rgba(0,0,0,0.18); transform: translateY(20px) scale(0.97); transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1); position: relative; max-height: 90vh; overflow-y: auto; }
|
||||
.profile-modal-overlay.show .profile-modal { transform: translateY(0) scale(1); }
|
||||
|
||||
.modal-close { position: absolute; top: 18px; right: 18px; width: 32px; height: 32px; border-radius: 50%; background: #f1f5f9; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s; }
|
||||
.modal-close:hover { background: #e2e8f0; }
|
||||
.modal-close svg { width: 16px; height: 16px; stroke: #64748b; }
|
||||
|
||||
.modal-title { font-size: 18px; font-weight: 800; color: #0d1b2e; margin-bottom: 4px; }
|
||||
.modal-subtitle { font-size: 13px; color: #94a3b8; margin-bottom: 22px; }
|
||||
|
||||
.foto-upload-area { display: flex; align-items: center; gap: 18px; background: #f8fafc; border-radius: 14px; padding: 14px 18px; margin-bottom: 18px; border: 1.5px dashed #e2e8f0; transition: border-color 0.2s; }
|
||||
.foto-upload-area:hover { border-color: #2b8ef3; }
|
||||
.foto-circle { width: 68px; height: 68px; border-radius: 50%; overflow: hidden; background: #e6f0ff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: 3px solid #dbeeff; }
|
||||
.foto-circle img { width: 100%; height: 100%; object-fit: cover; }
|
||||
.foto-circle svg { width: 34px; height: 34px; stroke: #2b8ef3; }
|
||||
.foto-info p { font-size: 12px; color: #94a3b8; margin: 0 0 7px; }
|
||||
.btn-pilih-foto { display: inline-block; background: #e6f0ff; color: #2b8ef3; font-size: 12px; font-weight: 700; padding: 7px 15px; border-radius: 8px; cursor: pointer; border: none; transition: background 0.2s; }
|
||||
.btn-pilih-foto:hover { background: #dbeeff; }
|
||||
|
||||
.modal-field { margin-bottom: 13px; }
|
||||
.modal-label { display: block; font-size: 11px; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
|
||||
.modal-label span { color: #94a3b8; font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 10px; margin-left: 4px; }
|
||||
.modal-input { width: 100%; background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 10px; padding: 10px 13px; font-size: 14px; font-family: 'Poppins', sans-serif; color: #1e293b; outline: none; transition: all 0.2s; }
|
||||
.modal-input:focus { border-color: #2b8ef3; background: white; box-shadow: 0 0 0 3px rgba(43,142,243,0.1); }
|
||||
.modal-input:disabled { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; }
|
||||
|
||||
.modal-divider { border: none; border-top: 1px solid #f1f5f9; margin: 16px 0; }
|
||||
|
||||
.btn-save-modal { width: 100%; background: linear-gradient(135deg,#2b8ef3,#1a7ae0); color: white; border: none; border-radius: 12px; padding: 13px; font-size: 14px; font-weight: 700; font-family: 'Poppins', sans-serif; cursor: pointer; transition: all 0.2s; box-shadow: 0 6px 18px rgba(43,142,243,0.3); }
|
||||
.btn-save-modal:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(43,142,243,0.35); }
|
||||
.btn-save-modal:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
|
||||
|
||||
.modal-toast { border-radius: 10px; padding: 10px 14px; font-size: 13px; font-weight: 500; margin-bottom: 13px; display: none; }
|
||||
.modal-toast.success { background: #f0fdf4; border: 1.5px solid #86efac; color: #166534; display: block; }
|
||||
.modal-toast.error { background: #fef2f2; border: 1.5px solid #fca5a5; color: #991b1b; display: block; }
|
||||
</style>
|
||||
|
||||
@stack('styles')
|
||||
|
|
@ -162,70 +97,52 @@
|
|||
<div class="sidebar-logo">
|
||||
<img src="{{ asset('images/logo/logosmk.png') }}" alt="Logo SMK">
|
||||
</div>
|
||||
|
||||
<nav class="sidebar-menu">
|
||||
<a href="{{ route('siswa.dashboard') }}"
|
||||
class="sidebar-link {{ request()->routeIs('siswa.dashboard') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/home.png') }}" class="sidebar-icon" alt="">
|
||||
<span>Dashboard</span>
|
||||
<a href="{{ route('siswa.dashboard') }}" class="sidebar-link {{ request()->routeIs('siswa.dashboard') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/home.png') }}" class="sidebar-icon" alt=""><span>Dashboard</span>
|
||||
</a>
|
||||
<a href="{{ route('siswa.materi.index') }}"
|
||||
class="sidebar-link {{ request()->routeIs('siswa.materi*') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/mapel.png') }}" class="sidebar-icon" alt="">
|
||||
<span>Materi</span>
|
||||
<a href="{{ route('siswa.materi.index') }}" class="sidebar-link {{ request()->routeIs('siswa.materi*') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/mapel.png') }}" class="sidebar-icon" alt=""><span>Materi</span>
|
||||
</a>
|
||||
<a href="{{ route('siswa.tugas.index') }}"
|
||||
class="sidebar-link {{ request()->routeIs('siswa.tugas*') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/siswa.png') }}" class="sidebar-icon" alt="">
|
||||
<span>Tugas</span>
|
||||
<a href="{{ route('siswa.tugas.index') }}" class="sidebar-link {{ request()->routeIs('siswa.tugas*') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/siswa.png') }}" class="sidebar-icon" alt=""><span>Tugas</span>
|
||||
</a>
|
||||
<a href="{{ route('siswa.challenge.index') }}"
|
||||
class="sidebar-link {{ request()->routeIs('siswa.challenge*') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/challenge.png') }}" class="sidebar-icon" alt="">
|
||||
<span>Challenge</span>
|
||||
<a href="{{ route('siswa.challenge.index') }}" class="sidebar-link {{ request()->routeIs('siswa.challenge*') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/challenge.png') }}" class="sidebar-icon" alt=""><span>Challenge</span>
|
||||
</a>
|
||||
<a href="{{ route('siswa.leaderboard.index') }}"
|
||||
class="sidebar-link {{ request()->routeIs('siswa.leaderboard*') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/lb.png') }}" class="sidebar-icon" alt="">
|
||||
<span>Leaderboard</span>
|
||||
<a href="{{ route('siswa.leaderboard.index') }}" class="sidebar-link {{ request()->routeIs('siswa.leaderboard*') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/lb.png') }}" class="sidebar-icon" alt=""><span>Leaderboard</span>
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
<form action="{{ route('siswa.logout') }}" method="POST" class="sidebar-logout">
|
||||
@csrf
|
||||
<button type="submit" class="btn btn-danger w-100">Logout</button>
|
||||
</form>
|
||||
</aside>
|
||||
|
||||
<button class="sidebar-toggle-btn collapsed" id="sidebarToggleBtn" title="Toggle Sidebar">
|
||||
<svg class="toggle-arrow" viewBox="0 0 24 24">
|
||||
<polyline points="15 18 9 12 15 6"></polyline>
|
||||
</svg>
|
||||
<button class="sidebar-toggle-btn collapsed" id="sidebarToggleBtn">
|
||||
<svg class="toggle-arrow" viewBox="0 0 24 24"><polyline points="15 18 9 12 15 6"></polyline></svg>
|
||||
</button>
|
||||
|
||||
<div class="main" id="mainContent">
|
||||
|
||||
<header class="topbar">
|
||||
<div class="topbar-left">
|
||||
👋 Hai, {{ Auth::guard('siswa')->user()->nama ?? 'Siswa' }}
|
||||
</div>
|
||||
|
||||
<div class="topbar-right">
|
||||
<img src="{{ asset('images/icon/sidebar/notif.png') }}" class="topbar-icon" alt="Notification">
|
||||
|
||||
{{-- Foto profil atau icon default --}}
|
||||
@php $siswa = Auth::guard('siswa')->user(); @endphp
|
||||
@if($siswa->foto_profil)
|
||||
<a href="{{ route('siswa.profile.edit') }}">
|
||||
<img src="{{ Storage::url($siswa->foto_profil) }}"
|
||||
class="topbar-avatar" alt="Profil">
|
||||
</a>
|
||||
<img src="{{ Storage::url($siswa->foto_profil) }}"
|
||||
class="topbar-avatar" id="topbar-foto"
|
||||
onclick="openProfileModal()" alt="Profil">
|
||||
@else
|
||||
<a href="{{ route('siswa.profile.edit') }}" class="topbar-avatar-icon">
|
||||
<div class="topbar-avatar-icon" id="topbar-foto-icon" onclick="openProfileModal()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="12" cy="8" r="4"/><path d="M4 20c0-4 3.6-7 8-7s8 3 8 7"/>
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</header>
|
||||
|
|
@ -236,23 +153,179 @@ class="topbar-avatar" alt="Profil">
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{{-- PROFILE MODAL --}}
|
||||
<div class="profile-modal-overlay" id="profileModalOverlay" onclick="closeOnOverlay(event)">
|
||||
<div class="profile-modal">
|
||||
|
||||
<button class="modal-close" onclick="closeProfileModal()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div class="modal-title">Edit Profil</div>
|
||||
<div class="modal-subtitle">Perbarui foto profil dan password</div>
|
||||
|
||||
<div id="modal-toast" class="modal-toast"></div>
|
||||
|
||||
<form id="profile-form" enctype="multipart/form-data">
|
||||
@csrf
|
||||
|
||||
<div class="foto-upload-area">
|
||||
<div class="foto-circle">
|
||||
@if($siswa->foto_profil)
|
||||
<img src="{{ Storage::url($siswa->foto_profil) }}" id="modal-foto-preview" alt="">
|
||||
@else
|
||||
<svg id="modal-foto-icon" viewBox="0 0 24 24" fill="none" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="12" cy="8" r="4"/><path d="M4 20c0-4 3.6-7 8-7s8 3 8 7"/>
|
||||
</svg>
|
||||
<img src="" id="modal-foto-preview" alt="" style="display:none">
|
||||
@endif
|
||||
</div>
|
||||
<div class="foto-info">
|
||||
<p>JPG, PNG, WEBP · Maks. 2MB</p>
|
||||
<label for="modal-foto-input" class="btn-pilih-foto">Pilih Foto</label>
|
||||
<input type="file" name="foto_profil" id="modal-foto-input" accept="image/*" style="display:none">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-field">
|
||||
<label class="modal-label">NISN <span>(tidak dapat diubah)</span></label>
|
||||
<input type="text" class="modal-input" value="{{ $siswa->nisn }}" disabled>
|
||||
</div>
|
||||
|
||||
<div class="modal-field">
|
||||
<label class="modal-label">Nama Lengkap <span>(tidak dapat diubah)</span></label>
|
||||
<input type="text" class="modal-input" value="{{ $siswa->nama }}" disabled>
|
||||
</div>
|
||||
|
||||
<hr class="modal-divider">
|
||||
|
||||
<div class="modal-field">
|
||||
<label class="modal-label">Password Baru <span>(kosongkan jika tidak ingin mengubah)</span></label>
|
||||
<input type="password" name="password" class="modal-input" placeholder="Password baru" autocomplete="new-password">
|
||||
</div>
|
||||
|
||||
<div class="modal-field">
|
||||
<label class="modal-label">Konfirmasi Password</label>
|
||||
<input type="password" name="password_confirmation" class="modal-input" placeholder="Ulangi password baru" autocomplete="new-password">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn-save-modal" id="btn-save">Simpan Perubahan</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
const sidebar = document.getElementById('mainSidebar');
|
||||
const toggleBtn = document.getElementById('sidebarToggleBtn');
|
||||
const SIDEBAR_W = 260;
|
||||
// Sidebar toggle
|
||||
const sidebar = document.getElementById('mainSidebar');
|
||||
const toggleBtn = document.getElementById('sidebarToggleBtn');
|
||||
const SIDEBAR_W = 260;
|
||||
|
||||
function updateTogglePosition(isCollapsed) {
|
||||
toggleBtn.style.left = isCollapsed ? '0px' : SIDEBAR_W + 'px';
|
||||
isCollapsed ? toggleBtn.classList.add('collapsed') : toggleBtn.classList.remove('collapsed');
|
||||
function updateTogglePosition(isCollapsed) {
|
||||
toggleBtn.style.left = isCollapsed ? '0px' : SIDEBAR_W + 'px';
|
||||
isCollapsed ? toggleBtn.classList.add('collapsed') : toggleBtn.classList.remove('collapsed');
|
||||
}
|
||||
|
||||
toggleBtn.addEventListener('click', function () {
|
||||
const isCollapsed = sidebar.classList.contains('collapsed');
|
||||
sidebar.classList.toggle('collapsed');
|
||||
updateTogglePosition(!isCollapsed);
|
||||
});
|
||||
|
||||
// Modal
|
||||
function openProfileModal() {
|
||||
document.getElementById('profileModalOverlay').classList.add('show');
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
|
||||
function closeProfileModal() {
|
||||
document.getElementById('profileModalOverlay').classList.remove('show');
|
||||
document.body.style.overflow = '';
|
||||
const toast = document.getElementById('modal-toast');
|
||||
toast.className = 'modal-toast';
|
||||
toast.textContent = '';
|
||||
}
|
||||
|
||||
function closeOnOverlay(e) {
|
||||
if (e.target === document.getElementById('profileModalOverlay')) closeProfileModal();
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', e => { if (e.key === 'Escape') closeProfileModal(); });
|
||||
|
||||
// Foto preview
|
||||
document.getElementById('modal-foto-input').addEventListener('change', function () {
|
||||
const file = this.files[0];
|
||||
if (!file) return;
|
||||
const url = URL.createObjectURL(file);
|
||||
const preview = document.getElementById('modal-foto-preview');
|
||||
const icon = document.getElementById('modal-foto-icon');
|
||||
preview.src = url;
|
||||
preview.style.display = 'block';
|
||||
if (icon) icon.style.display = 'none';
|
||||
});
|
||||
|
||||
// AJAX submit
|
||||
document.getElementById('profile-form').addEventListener('submit', async function (e) {
|
||||
e.preventDefault();
|
||||
const btn = document.getElementById('btn-save');
|
||||
const toast = document.getElementById('modal-toast');
|
||||
btn.disabled = true;
|
||||
btn.textContent = 'Menyimpan...';
|
||||
|
||||
const formData = new FormData(this);
|
||||
|
||||
try {
|
||||
const res = await fetch('{{ route("siswa.profile.update") }}', {
|
||||
method: 'POST',
|
||||
headers: { 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content },
|
||||
body: formData,
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
|
||||
if (data.success) {
|
||||
if (data.foto_url) {
|
||||
const topbarFoto = document.getElementById('topbar-foto');
|
||||
const topbarFotoIcon = document.getElementById('topbar-foto-icon');
|
||||
|
||||
if (topbarFoto) {
|
||||
topbarFoto.src = data.foto_url + '?t=' + Date.now();
|
||||
} else if (topbarFotoIcon) {
|
||||
const img = document.createElement('img');
|
||||
img.src = data.foto_url + '?t=' + Date.now();
|
||||
img.className = 'topbar-avatar';
|
||||
img.id = 'topbar-foto';
|
||||
img.onclick = openProfileModal;
|
||||
img.alt = 'Profil';
|
||||
topbarFotoIcon.replaceWith(img);
|
||||
}
|
||||
|
||||
const modalPreview = document.getElementById('modal-foto-preview');
|
||||
const modalIcon = document.getElementById('modal-foto-icon');
|
||||
if (modalPreview) { modalPreview.src = data.foto_url; modalPreview.style.display = 'block'; }
|
||||
if (modalIcon) modalIcon.style.display = 'none';
|
||||
}
|
||||
|
||||
toast.className = 'modal-toast success';
|
||||
toast.textContent = '✓ ' + data.message;
|
||||
this.querySelector('[name="password"]').value = '';
|
||||
this.querySelector('[name="password_confirmation"]').value = '';
|
||||
|
||||
} else {
|
||||
const errors = data.errors ? Object.values(data.errors).flat().join(' · ') : 'Terjadi kesalahan.';
|
||||
toast.className = 'modal-toast error';
|
||||
toast.textContent = errors;
|
||||
}
|
||||
} catch (err) {
|
||||
toast.className = 'modal-toast error';
|
||||
toast.textContent = 'Gagal terhubung ke server.';
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
btn.textContent = 'Simpan Perubahan';
|
||||
}
|
||||
|
||||
toggleBtn.addEventListener('click', function () {
|
||||
const isCollapsed = sidebar.classList.contains('collapsed');
|
||||
sidebar.classList.toggle('collapsed');
|
||||
updateTogglePosition(!isCollapsed);
|
||||
localStorage.setItem('sidebarOpen', isCollapsed ? 'true' : 'false');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@stack('scripts')
|
||||
|
|
|
|||
|
|
@ -10,16 +10,9 @@
|
|||
.podium-wrap { display: flex; align-items: flex-end; justify-content: center; gap: 12px; margin-bottom: 32px; }
|
||||
.podium-item { display: flex; flex-direction: column; align-items: center; gap: 8px; }
|
||||
|
||||
.podium-avatar {
|
||||
border-radius: 50%;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
font-size: 22px; font-weight: 800; color: white;
|
||||
position: relative; overflow: hidden; flex-shrink: 0;
|
||||
width: 56px; height: 56px;
|
||||
}
|
||||
|
||||
.podium-avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; color: white; position: relative; overflow: hidden; flex-shrink: 0; width: 56px; height: 56px; }
|
||||
.podium-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
|
||||
.podium-crown { position: absolute; top: -16px; font-size: 18px; z-index: 1; }
|
||||
.podium-crown { position: absolute; top: -16px; font-size: 18px; z-index: 1; pointer-events: none; }
|
||||
|
||||
.rank-1 .podium-avatar { background: linear-gradient(135deg,#f59e0b,#d97706); width:68px; height:68px; font-size:26px; }
|
||||
.rank-2 .podium-avatar { background: linear-gradient(135deg,#94a3b8,#64748b); }
|
||||
|
|
@ -36,14 +29,17 @@
|
|||
.my-rank-banner { background:linear-gradient(135deg,#667eea,#764ba2); border-radius:16px; padding:16px 20px; color:white; display:flex; align-items:center; gap:16px; margin-bottom:20px; }
|
||||
.my-rank-avatar { width:48px; height:48px; border-radius:50%; object-fit:cover; border:2px solid rgba(255,255,255,0.5); flex-shrink:0; }
|
||||
.my-rank-avatar-placeholder { width:48px; height:48px; border-radius:50%; background:rgba(255,255,255,0.2); display:flex; align-items:center; justify-content:center; font-size:20px; font-weight:800; flex-shrink:0; }
|
||||
.my-rank-num { font-size:36px; font-weight:800; line-height:1; }
|
||||
.my-rank-info { flex:1; }
|
||||
.my-rank-num { font-size:36px; font-weight:800; line-height:1; }
|
||||
.my-rank-info { flex:1; }
|
||||
.my-rank-label { font-size:12px; opacity:0.8; margin-bottom:2px; }
|
||||
.my-rank-nama { font-size:16px; font-weight:700; }
|
||||
.my-rank-exp { font-size:13px; opacity:0.9; }
|
||||
|
||||
.custom-card { background:white; border-radius:20px; border:2px solid #e5e5e5; padding:22px; }
|
||||
.section-title { font-size:15px; font-weight:700; color:#1e293b; margin-bottom:16px; }
|
||||
.section-title { font-size:15px; font-weight:700; color:#1e293b; margin-bottom:16px; display:flex; align-items:center; justify-content:space-between; }
|
||||
|
||||
.live-dot { width:8px; height:8px; border-radius:50%; background:#22c55e; box-shadow:0 0 6px #22c55e; animation: pulse 2s ease-in-out infinite; display:inline-block; margin-right:6px; }
|
||||
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.5;transform:scale(0.8)} }
|
||||
|
||||
.lb-row { display:flex; align-items:center; gap:12px; padding:10px 14px; border-radius:12px; margin-bottom:8px; transition:background 0.15s; }
|
||||
.lb-row:hover { background:#f8fafc; }
|
||||
|
|
@ -75,125 +71,172 @@
|
|||
|
||||
<span class="semester-badge">Semester {{ $semester }} · {{ $tahunAjaran }}</span>
|
||||
|
||||
@if($leaderboard->isEmpty())
|
||||
<div class="empty-state">
|
||||
<div style="font-size:52px;margin-bottom:12px">📊</div>
|
||||
<p style="font-size:15px;font-weight:600;color:#475569">Belum ada data leaderboard.</p>
|
||||
<p style="font-size:13px">Kerjakan challenge untuk masuk leaderboard!</p>
|
||||
{{-- Container di-render real-time via JavaScript --}}
|
||||
<div id="leaderboard-container">
|
||||
<div style="text-align:center;padding:40px;color:#94a3b8;">
|
||||
<div style="font-size:32px;margin-bottom:8px">⏳</div>
|
||||
<p style="font-size:13px">Memuat data...</p>
|
||||
</div>
|
||||
@else
|
||||
</div>
|
||||
|
||||
@php
|
||||
$top3 = $leaderboard->take(3);
|
||||
$first = $top3->firstWhere('ranking', 1);
|
||||
$second = $top3->firstWhere('ranking', 2);
|
||||
$third = $top3->firstWhere('ranking', 3);
|
||||
@endphp
|
||||
@endsection
|
||||
|
||||
@if($first)
|
||||
<div class="podium-wrap">
|
||||
@push('scripts')
|
||||
<script>
|
||||
const currentSiswaId = {{ $siswaLogin->id_siswa }};
|
||||
const jsonUrl = '{{ route("siswa.leaderboard.json") }}';
|
||||
|
||||
@if($second)
|
||||
<div class="podium-item rank-2">
|
||||
<div class="podium-avatar">
|
||||
@if(!empty($second['foto_profil']))
|
||||
<img src="{{ Storage::url($second['foto_profil']) }}" alt="">
|
||||
@else
|
||||
{{ strtoupper(substr($second['nama'], 0, 1)) }}
|
||||
@endif
|
||||
</div>
|
||||
<div class="podium-name">{{ $second['nama'] }}</div>
|
||||
<div class="podium-exp">⭐ {{ number_format($second['exp']) }}</div>
|
||||
<div class="podium-bar">2</div>
|
||||
</div>
|
||||
@endif
|
||||
function avatarHtml(item, size = 'normal') {
|
||||
const isLarge = size === 'large';
|
||||
const w = isLarge ? 48 : 36;
|
||||
const fontSize = isLarge ? 20 : 14;
|
||||
|
||||
<div class="podium-item rank-1">
|
||||
<div class="podium-avatar">
|
||||
<span class="podium-crown">👑</span>
|
||||
@if(!empty($first['foto_profil']))
|
||||
<img src="{{ Storage::url($first['foto_profil']) }}" alt="">
|
||||
@else
|
||||
{{ strtoupper(substr($first['nama'], 0, 1)) }}
|
||||
@endif
|
||||
</div>
|
||||
<div class="podium-name">{{ $first['nama'] }}</div>
|
||||
<div class="podium-exp">⭐ {{ number_format($first['exp']) }}</div>
|
||||
<div class="podium-bar">1</div>
|
||||
</div>
|
||||
if (item.foto_url) {
|
||||
const cls = isLarge ? 'my-rank-avatar' : 'lb-avatar';
|
||||
return `<img src="${item.foto_url}?t=${Date.now()}" class="${cls}" alt="">`;
|
||||
}
|
||||
|
||||
@if($third)
|
||||
<div class="podium-item rank-3">
|
||||
<div class="podium-avatar">
|
||||
@if(!empty($third['foto_profil']))
|
||||
<img src="{{ Storage::url($third['foto_profil']) }}" alt="">
|
||||
@else
|
||||
{{ strtoupper(substr($third['nama'], 0, 1)) }}
|
||||
@endif
|
||||
</div>
|
||||
<div class="podium-name">{{ $third['nama'] }}</div>
|
||||
<div class="podium-exp">⭐ {{ number_format($third['exp']) }}</div>
|
||||
<div class="podium-bar">3</div>
|
||||
</div>
|
||||
@endif
|
||||
const initial = item.nama ? item.nama.charAt(0).toUpperCase() : '?';
|
||||
if (isLarge) {
|
||||
return `<div class="my-rank-avatar-placeholder">${initial}</div>`;
|
||||
}
|
||||
return `<div class="lb-avatar-placeholder">${initial}</div>`;
|
||||
}
|
||||
|
||||
</div>
|
||||
@endif
|
||||
function podiumAvatarHtml(item, rankClass) {
|
||||
if (item.foto_url) {
|
||||
return `<img src="${item.foto_url}?t=${Date.now()}" alt="" style="width:100%;height:100%;object-fit:cover;border-radius:50%;">`;
|
||||
}
|
||||
return item.nama ? item.nama.charAt(0).toUpperCase() : '?';
|
||||
}
|
||||
|
||||
@if($myRank)
|
||||
<div class="my-rank-banner">
|
||||
@if(!empty($myRank['foto_profil']))
|
||||
<img src="{{ Storage::url($myRank['foto_profil']) }}" class="my-rank-avatar" alt="">
|
||||
@else
|
||||
<div class="my-rank-avatar-placeholder">{{ strtoupper(substr($myRank['nama'], 0, 1)) }}</div>
|
||||
@endif
|
||||
<div class="my-rank-num">#{{ $myRank['ranking'] }}</div>
|
||||
<div class="my-rank-info">
|
||||
<div class="my-rank-label">Posisimu saat ini</div>
|
||||
<div class="my-rank-nama">{{ $myRank['nama'] }}</div>
|
||||
<div class="my-rank-exp">⭐ {{ number_format($myRank['exp']) }} EXP</div>
|
||||
</div>
|
||||
<div style="font-size:32px">🎯</div>
|
||||
</div>
|
||||
@endif
|
||||
function rankBadge(ranking) {
|
||||
if (ranking === 1) return '🥇';
|
||||
if (ranking === 2) return '🥈';
|
||||
if (ranking === 3) return '🥉';
|
||||
return ranking;
|
||||
}
|
||||
|
||||
<div class="custom-card">
|
||||
<p class="section-title">📋 Semua Peringkat</p>
|
||||
function rankClass(ranking) {
|
||||
if (ranking === 1) return 'gold';
|
||||
if (ranking === 2) return 'silver';
|
||||
if (ranking === 3) return 'bronze';
|
||||
return '';
|
||||
}
|
||||
|
||||
@foreach($leaderboard as $item)
|
||||
@php
|
||||
$isMe = $item['id_siswa'] === $siswaLogin->id_siswa;
|
||||
$rankClass = match($item['ranking']) { 1=>'gold', 2=>'silver', 3=>'bronze', default=>'' };
|
||||
@endphp
|
||||
<div class="lb-row {{ $isMe ? 'highlight' : '' }}">
|
||||
<div class="lb-rank {{ $rankClass }}">
|
||||
@if($item['ranking'] === 1) 🥇
|
||||
@elseif($item['ranking'] === 2) 🥈
|
||||
@elseif($item['ranking'] === 3) 🥉
|
||||
@else {{ $item['ranking'] }}
|
||||
@endif
|
||||
</div>
|
||||
function renderLeaderboard(data) {
|
||||
const { leaderboard, myRank } = data;
|
||||
|
||||
@if(!empty($item['foto_profil']))
|
||||
<img src="{{ Storage::url($item['foto_profil']) }}" class="lb-avatar" alt="">
|
||||
@else
|
||||
<div class="lb-avatar-placeholder">{{ strtoupper(substr($item['nama'], 0, 1)) }}</div>
|
||||
@endif
|
||||
if (!leaderboard || leaderboard.length === 0) {
|
||||
document.getElementById('leaderboard-container').innerHTML = `
|
||||
<div class="empty-state">
|
||||
<div style="font-size:52px;margin-bottom:12px">📊</div>
|
||||
<p style="font-size:15px;font-weight:600;color:#475569">Belum ada data leaderboard.</p>
|
||||
<p style="font-size:13px">Kerjakan challenge untuk masuk leaderboard!</p>
|
||||
</div>`;
|
||||
return;
|
||||
}
|
||||
|
||||
<div style="flex:1">
|
||||
<div class="lb-nama">
|
||||
{{ $item['nama'] }}
|
||||
@if($isMe)
|
||||
<span style="background:#c4b5fd;color:#4c1d95;font-size:10px;padding:2px 7px;border-radius:99px;font-weight:700;margin-left:4px">Kamu</span>
|
||||
@endif
|
||||
const first = leaderboard.find(x => x.ranking === 1);
|
||||
const second = leaderboard.find(x => x.ranking === 2);
|
||||
const third = leaderboard.find(x => x.ranking === 3);
|
||||
|
||||
// Podium
|
||||
let podiumHtml = '';
|
||||
if (first) {
|
||||
podiumHtml = `<div class="podium-wrap">`;
|
||||
|
||||
if (second) podiumHtml += `
|
||||
<div class="podium-item rank-2">
|
||||
<div class="podium-avatar">${podiumAvatarHtml(second)}</div>
|
||||
<div class="podium-name">${second.nama}</div>
|
||||
<div class="podium-exp">⭐ ${Number(second.exp).toLocaleString('id')}</div>
|
||||
<div class="podium-bar">2</div>
|
||||
</div>`;
|
||||
|
||||
podiumHtml += `
|
||||
<div class="podium-item rank-1">
|
||||
<div class="podium-avatar">
|
||||
<span class="podium-crown">👑</span>
|
||||
${podiumAvatarHtml(first)}
|
||||
</div>
|
||||
<div class="lb-nisn">{{ $item['nisn'] }}</div>
|
||||
</div>
|
||||
<div class="lb-exp">⭐ {{ number_format($item['exp']) }}</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
<div class="podium-name">${first.nama}</div>
|
||||
<div class="podium-exp">⭐ ${Number(first.exp).toLocaleString('id')}</div>
|
||||
<div class="podium-bar">1</div>
|
||||
</div>`;
|
||||
|
||||
@endif
|
||||
if (third) podiumHtml += `
|
||||
<div class="podium-item rank-3">
|
||||
<div class="podium-avatar">${podiumAvatarHtml(third)}</div>
|
||||
<div class="podium-name">${third.nama}</div>
|
||||
<div class="podium-exp">⭐ ${Number(third.exp).toLocaleString('id')}</div>
|
||||
<div class="podium-bar">3</div>
|
||||
</div>`;
|
||||
|
||||
@endsection
|
||||
podiumHtml += `</div>`;
|
||||
}
|
||||
|
||||
// My rank banner
|
||||
let bannerHtml = '';
|
||||
if (myRank) {
|
||||
bannerHtml = `
|
||||
<div class="my-rank-banner">
|
||||
${avatarHtml(myRank, 'large')}
|
||||
<div class="my-rank-num">#${myRank.ranking}</div>
|
||||
<div class="my-rank-info">
|
||||
<div class="my-rank-label">Posisimu saat ini</div>
|
||||
<div class="my-rank-nama">${myRank.nama}</div>
|
||||
<div class="my-rank-exp">⭐ ${Number(myRank.exp).toLocaleString('id')} EXP</div>
|
||||
</div>
|
||||
<div style="font-size:32px">🎯</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
// Table rows
|
||||
let rowsHtml = leaderboard.map(item => {
|
||||
const isMe = item.id_siswa === currentSiswaId;
|
||||
return `
|
||||
<div class="lb-row ${isMe ? 'highlight' : ''}">
|
||||
<div class="lb-rank ${rankClass(item.ranking)}">${rankBadge(item.ranking)}</div>
|
||||
${avatarHtml(item)}
|
||||
<div style="flex:1">
|
||||
<div class="lb-nama">
|
||||
${item.nama}
|
||||
${isMe ? '<span style="background:#c4b5fd;color:#4c1d95;font-size:10px;padding:2px 7px;border-radius:99px;font-weight:700;margin-left:4px">Kamu</span>' : ''}
|
||||
</div>
|
||||
<div class="lb-nisn">${item.nisn}</div>
|
||||
</div>
|
||||
<div class="lb-exp">⭐ ${Number(item.exp).toLocaleString('id')}</div>
|
||||
</div>`;
|
||||
}).join('');
|
||||
|
||||
document.getElementById('leaderboard-container').innerHTML = `
|
||||
${podiumHtml}
|
||||
${bannerHtml}
|
||||
<div class="custom-card">
|
||||
<p class="section-title">
|
||||
<span>📋 Semua Peringkat</span>
|
||||
<span><span class="live-dot"></span><span style="font-size:11px;color:#22c55e;font-weight:600">Live</span></span>
|
||||
</p>
|
||||
${rowsHtml}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
// Polling setiap 10 detik
|
||||
async function pollLeaderboard() {
|
||||
try {
|
||||
const res = await fetch(jsonUrl);
|
||||
const data = await res.json();
|
||||
renderLeaderboard(data);
|
||||
} catch (e) {
|
||||
// Diam-diam gagal, coba lagi nanti
|
||||
}
|
||||
}
|
||||
|
||||
// Mulai polling
|
||||
setInterval(pollLeaderboard, 10000);
|
||||
|
||||
// Load langsung saat halaman buka
|
||||
pollLeaderboard();
|
||||
</script>
|
||||
@endpush
|
||||
|
|
@ -88,8 +88,8 @@
|
|||
return view('admin.notif');
|
||||
})->name('notif');
|
||||
|
||||
Route::get('/profile', [AdminProfileController::class, 'edit'])->name('profile.edit');
|
||||
Route::put('/profile', [AdminProfileController::class, 'update'])->name('profile.update');
|
||||
Route::get('/profile', [AdminProfileController::class, 'edit'])->name('profile.edit');
|
||||
Route::post('/profile', [AdminProfileController::class, 'updateAjax'])->name('profile.update');
|
||||
|
||||
// ── GURU ──────────────────────────────────────────────
|
||||
Route::get('/guru/kelas-by-mapel', [AdminGuruController::class, 'getKelasByMapel'])
|
||||
|
|
@ -154,8 +154,8 @@
|
|||
Route::get('/tugas/{id}/detail', [GuruMapelController::class, 'detailTugas'])->name('tugas.detail');
|
||||
Route::delete('/tugas/{id}', [GuruMapelController::class, 'destroyTugas'])->name('tugas.destroy');
|
||||
|
||||
Route::get('/profile', [GuruProfileController::class, 'edit'])->name('profile.edit');
|
||||
Route::put('/profile', [GuruProfileController::class, 'update'])->name('profile.update');
|
||||
Route::get('/profile', [GuruProfileController::class, 'edit'])->name('profile.edit');
|
||||
Route::post('/profile', [GuruProfileController::class, 'updateAjax'])->name('profile.update');
|
||||
|
||||
// LOGOUT GURU
|
||||
Route::post('/logout', [GuruLoginController::class, 'logout'])->name('logout');
|
||||
|
|
@ -185,10 +185,11 @@
|
|||
|
||||
//LEADERBOARD SISWA
|
||||
Route::get('/leaderboard', [SiswaLeaderboardController::class, 'index'])->name('leaderboard.index');
|
||||
Route::get('/leaderboard/json', [SiswaLeaderboardController::class, 'json'])->name('leaderboard.json');
|
||||
|
||||
//PROFILE SISWA
|
||||
Route::get('/profile', [SiswaProfileController::class, 'edit'])->name('profile.edit');
|
||||
Route::put('/profile', [SiswaProfileController::class, 'update'])->name('profile.update');
|
||||
Route::get('/profile', [SiswaProfileController::class, 'edit'])->name('profile.edit');
|
||||
Route::post('/profile', [SiswaProfileController::class, 'updateAjax'])->name('profile.update');
|
||||
|
||||
// LOGOUT SISWA
|
||||
Route::post('/logout', [SiswaLoginController::class, 'logout'])->name('logout');
|
||||
|
|
|
|||
Loading…
Reference in New Issue