72 lines
2.9 KiB
PHP
72 lines
2.9 KiB
PHP
@extends('layouts.main')
|
|
|
|
@section('breadcrumbs')
|
|
{{-- {{ Breadcrumbs::render(request()->route()->getName()) }} --}}
|
|
@endsection
|
|
|
|
@section('content')
|
|
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
|
|
|
<form
|
|
action="{{ isset($daftarPustaka->id) ? route('daftar-pustaka.update', $daftarPustaka->id) : route('daftar-pustaka.store') }}"
|
|
method="POST">
|
|
@csrf
|
|
<div class="card border border-agi-100 pb-2.5">
|
|
<div class="card-header bg-agi-50" id="basic_settings">
|
|
<h3 class="card-title">
|
|
{{ $daftarPustaka->judul ?? '' }}
|
|
</h3>
|
|
<div class="flex items-center gap-2">
|
|
<a href="{{ route('daftar-pustaka.index') }}" class="btn btn-xs btn-info"><i
|
|
class="ki-filled ki-exit-left"></i> Back</a>
|
|
</div>
|
|
</div>
|
|
<div class="card-body grid gap-5">
|
|
<div
|
|
class=" min-w-3xl w-[1280px] h-[768px]">
|
|
<div class="p-4 h-full flex flex-col">
|
|
<div class="flex justify-between items-center mb-4">
|
|
<button type="button" id="downloadBtn" class="btn btn-primary btn-sm">
|
|
<i class="ki-duotone ki-cloud-download me-1"><span class="path1"></span><span
|
|
class="path2"></span></i>
|
|
Download File
|
|
</button>
|
|
</div>
|
|
<div id="previewContent" class="flex-grow"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="border border-t">
|
|
</div>
|
|
<div>
|
|
{{ $daftarPustaka->deskripsi ?? '' }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
@endsection
|
|
|
|
@push('scripts')
|
|
<script src="{{ asset('vendor/pdfobject.min.js') }}"></script>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
let url = @json($daftarPustaka->attachment);
|
|
console.log(url);
|
|
|
|
const fileExtension = url.split('.').pop().toLowerCase();
|
|
const previewContent = document.getElementById('previewContent');
|
|
|
|
if (['pdf'].includes(fileExtension)) {
|
|
PDFObject.embed(url, "#previewContent");
|
|
} else if (['jpg', 'jpeg', 'png', 'gif'].includes(fileExtension)) {
|
|
previewContent.innerHTML =
|
|
`<img src="${url}" alt="Preview" class="max-w-full max-h-full object-contain">`;
|
|
} else {
|
|
previewContent.innerHTML = '<p class="text-center">Unsupported file type</p>';
|
|
}
|
|
});
|
|
</script>
|
|
@endpush
|