Skip to content

Commit 0ecc5fa

Browse files
committed
bump version to 2.6.0 and add download folder functionality
1 parent 4019f60 commit 0ecc5fa

File tree

9 files changed

+300
-6
lines changed

9 files changed

+300
-6
lines changed

app/Http/Controllers/ArsipController.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use App\Models\ShareLink;
77
use Illuminate\Support\Facades\DB;
88
use Illuminate\Support\Facades\Storage;
9+
use ZipArchive;
910

1011
class ArsipController extends Controller
1112
{
@@ -90,4 +91,36 @@ public function daftarFile($token, $kak)
9091
'data' => $data,
9192
]);
9293
}
94+
95+
public function downloadFolder($token, $kak)
96+
{
97+
$tahun = ShareLink::where('token', $token)->first()->tahun;
98+
$path = $tahun.'/'.'arsip-dokumens'.'/'.$kak;
99+
$folderPath = Storage::disk('arsip')->path($path);
100+
$files = Storage::disk('arsip')->files($path);
101+
$zipFileName = uniqid().'.zip';
102+
$zipFilePath = Storage::disk('temp')->path($zipFileName);
103+
104+
if (! empty($files)) {
105+
$zip = new ZipArchive;
106+
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
107+
$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($folderPath), \RecursiveIteratorIterator::LEAVES_ONLY);
108+
foreach ($files as $file) {
109+
if (! $file->isDir()) {
110+
$relativePath = substr($file->getRealPath(), strlen($folderPath) + 1);
111+
$zip->addFile($file->getRealPath(), $relativePath);
112+
}
113+
}
114+
115+
$zip->close();
116+
}
117+
118+
return response()->download($zipFilePath)->deleteFileAfterSend(true);
119+
} else {
120+
return redirect()->back()->with([
121+
'message' => 'Folder kosong, tidak ada file untuk diunduh.',
122+
'type' => 'danger',
123+
]);
124+
}
125+
}
93126
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,5 @@
8888
},
8989
"minimum-stability": "dev",
9090
"prefer-stable": true,
91-
"version": "2.5.1"
91+
"version": "2.6.0"
9292
}

public/js/toast.min.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* Custom Simple Toast Class
3+
* Developed by: oretnom23
4+
* Please load this file with the CustomToast.css file and Google Icons
5+
*/
6+
class CustomToast{
7+
// Toast Box variable
8+
toastBox;
9+
// Toast Box Duration variable
10+
duration;
11+
// Valid Toast Icons
12+
toastIcon = {
13+
success: `<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><circle cx="12" cy="12" r="10" fill="#4caf50"/><path d="M9 16.2l-4.2-4.2L3 13.8l6 6 12-12-1.4-1.4z" fill="#fff"/></svg>`,
14+
danger: `<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><circle cx="12" cy="12" r="10" fill="#f44336"/><path d="M15 9l-6 6m0-6l6 6" stroke="#fff" stroke-width="2"/></svg>`,
15+
warning: `<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><circle cx="12" cy="12" r="10" fill="#ff9800"/><path d="M11 17h2v-2h-2v2zm0-4h2V7h-2v6z" fill="#fff"/></svg>`,
16+
info: `<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><circle cx="12" cy="12" r="10" fill="#2196f3"/><path d="M11 17h2v-2h-2v2zm0-4h2V7h-2v6z" fill="#fff"/></svg>`,
17+
};
18+
show(message="Sample Message", toastType="info", duration = 5000){
19+
// Check if toast type is valid, otherwise make info toast as the default
20+
if(!Object.keys(this.toastIcon).includes(toastType))
21+
toastType = `info`;
22+
// Creatign the Toast Box Element
23+
this.toastBox = document.createElement('div')
24+
// Adding .toast class to Toast Box Element
25+
this.toastBox.classList.add('toast', `toast-${toastType}`)
26+
// Toast box content
27+
this.toastBox.innerHTML = `<button class="toast-close-btn"><svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 96 960 960" width="24"><path d="M480 606.923 273.077 813.846q-8.615 8.615-21.231 8.615-12.615 0-21.231-8.615-8.615-8.615-8.615-21.231 0-12.615 8.615-21.231L437.077 585.692 230.154 378.769q-8.615-8.615-8.615-21.231 0-12.615 8.615-21.231 8.615-8.615 21.231-8.615 12.615 0 21.231 8.615L480 564.077l206.923-206.923q8.615-8.615 21.231-8.615 12.615 0 21.231 8.615 8.615 8.615 8.615 21.231 0 12.615-8.615 21.231L522.923 585.692l206.923 206.923q8.615 8.615 8.615 21.231 0 12.615-8.615 21.231-8.615 8.615-21.231 8.615-12.615 0-21.231-8.615L480 606.923Z"/></svg></button>
28+
<div class="toast-content-wrapper">
29+
<div class="toast-icon">
30+
${this.toastIcon[toastType]}
31+
</div>
32+
<div class="toast-message">${message}</div>
33+
<div class="toast-progress"></div>
34+
</div>`;
35+
// Set Toast Duration
36+
this.duration = duration
37+
// Update Toast Duration
38+
this.toastBox.querySelector('.toast-progress').style.animationDuration = `${this.duration / 1000}s`
39+
40+
// Remove Current Toast Notification if Exists
41+
if(document.body.querySelector('.toast') != null)
42+
document.body.querySelector('.toast').remove();
43+
// Append New Toast Notification to the document
44+
document.body.appendChild(this.toastBox)
45+
// Trigger closing duration
46+
this.triggerClose()
47+
// When Close Icon/Button is clicked event listener
48+
this.toastBox.querySelector('.toast-close-btn').addEventListener('click', e=>{
49+
e.preventDefault()
50+
// Trigger immediate closing
51+
this.triggerClose(0)
52+
})
53+
}
54+
triggerClose(closeDuration = null){
55+
// Set toast duration as the closing delay if the closing duration value is null
56+
if(closeDuration == null){
57+
closeDuration=this.duration
58+
}
59+
setTimeout(()=>{
60+
// adding closing class for closing animation
61+
this.toastBox.classList.add('closing')
62+
// trigger removing the toast notification
63+
this.closeToast()
64+
},closeDuration)
65+
}
66+
closeToast(){
67+
// Set removing toast delay
68+
setTimeout(()=>{
69+
this.toastBox.remove();
70+
}, 500)
71+
}
72+
}

resources/views/arsip-per-detail.blade.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@
2121
<td class="is-actions-cell">
2222
<div class="buttons is-right">
2323
<a target="_blank" href="{{ route('arsip-per-kak', ['token' => $token, 'coa' => $item->id]) }}">
24-
<button class="button is-small is-primary" type="button">Link</button>
24+
<button class="button is-small is-primary" type="button">
25+
<span class="icon">
26+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
27+
<path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" />
28+
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
29+
</svg>
30+
</span>
31+
</button>
2532
</a>
2633
</div>
2734
</td>

resources/views/arsip-per-kak.blade.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,35 @@
1515
<td class="is-actions-cell">
1616
<div class="buttons is-right">
1717
<a target="_blank" href="{{ route('daftar-file', ['token' => $token, 'kak' => $item->id]) }}">
18-
<button class="button is-small is-primary" type="button">Link</button>
18+
<button class="button is-small is-primary" type="button">
19+
<span class="icon">
20+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
21+
<path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" />
22+
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
23+
</svg>
24+
</span>
25+
</button>
26+
</a>
27+
<a href="{{ route('download-folder', ['token' => $token, 'kak' => $item->id]) }}">
28+
<button class="button is-small is-info jb-modal" data-target="sample-modal" type="button">
29+
<span class="icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
30+
<path stroke-linecap="round" stroke-linejoin="round" d="m9 13.5 3 3m0 0 3-3m-3 3v-6m1.06-4.19-2.12-2.12a1.5 1.5 0 0 0-1.061-.44H4.5A2.25 2.25 0 0 0 2.25 6v12a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 18V9a2.25 2.25 0 0 0-2.25-2.25h-5.379a1.5 1.5 0 0 1-1.06-.44Z" />
31+
</svg>
32+
</span>
33+
</button>
1934
</a>
2035
</div>
2136
</td>
37+
2238
</tr>
2339
@endforeach
2440
</tbody>
2541
</table>
26-
@endsection
42+
@endsection
43+
@section('toasr')
44+
@if(session('message') && session('type'))
45+
<script>
46+
new CustomToast().show("{{ session('message') }}", "{{ session('type') }}", 10000);
47+
</script>
48+
@endif
49+
@endsection

resources/views/arsip-per-kro.blade.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
<td class="is-actions-cell">
1515
<div class="buttons is-right">
1616
<a target="_blank" href="{{ route('arsip-per-detail', ['token' => $token, 'kro' => $item->KRO]) }}">
17-
<button class="button is-small is-primary" type="button">Link</button>
17+
<button class="button is-small is-primary" type="button">
18+
<span class="icon">
19+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
20+
<path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" />
21+
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
22+
</svg>
23+
</span>
24+
</button>
1825
</a>
1926
</div>
2027
</td>

resources/views/arsip/layout.blade.php

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<title>Arsip Dokumen - {{ $level }}</title>
88
<link rel="stylesheet" href="{{ asset('css/bulma.min.css') }}">
99
<link rel="stylesheet" href="{{ asset('css/main.min.css') }}">
10+
<script type="text/javascript" src="{{ asset('js/toast.min.js') }}"></script>
1011
<style type="text/css">
1112
h1.title, h3.subtitle {
1213
text-align: center;
@@ -20,6 +21,147 @@
2021
.is-main h3.subtitle {
2122
font-size: 2rem;
2223
}
24+
/**
25+
* Custom Simple Toast Stylesheet
26+
* Developed by: oretnom23
27+
* Please load this file with the CustomToast.js file and Google Icons
28+
*/
29+
.toast {
30+
position: fixed;
31+
top: 25px;
32+
right: 25px;
33+
width: 300px;
34+
background: #fff;
35+
padding: 0.5em 0.35em;
36+
border-left: 4px solid #b7b7b7;
37+
border-radius: 4px;
38+
box-shadow: -1px 1px 10px #00000057;
39+
z-index: 1023;
40+
animation: leftToRight .5s ease-in-out forwards;
41+
transform: translateX(110%);
42+
}
43+
.toast.closing{
44+
animation: RightToLeft .5s ease-in-out forwards;
45+
}
46+
.toast-progress {
47+
position: absolute;
48+
display: block;
49+
bottom: 0;
50+
left: 0;
51+
height: 4px;
52+
width: 100%;
53+
background: #b7b7b7;
54+
animation: Toastprogress 3s ease-in-out forwards;
55+
}
56+
@keyframes leftToRight {
57+
0%{
58+
transform: translateX(110%);
59+
}
60+
75%{
61+
transform: translateX(-10%);
62+
}
63+
100%{
64+
transform: translateX(0%);
65+
}
66+
}
67+
@keyframes RightToLeft {
68+
0%{
69+
transform: translateX(0%);
70+
}
71+
25%{
72+
transform: translateX(-10%);
73+
}
74+
100%{
75+
transform: translateX(110%);
76+
}
77+
}
78+
@keyframes Toastprogress {
79+
0%{
80+
width: 100%;
81+
}
82+
100%{
83+
width: 0%;
84+
}
85+
}
86+
button.toast-close-btn {
87+
outline: none;
88+
background: none;
89+
border: none;
90+
float: right;
91+
cursor: pointer;
92+
}
93+
button.toast-close-btn>span,
94+
button.toast-close-btn>i{
95+
font-size:1.2rem;
96+
color:#747474;
97+
font-weight: 500;
98+
}
99+
button.toast-close-btn:hover>span,
100+
button.toast-close-btn:hover>i{
101+
color:#585858;
102+
}
103+
.toast-content-wrapper {
104+
display: flex;
105+
/* margin-top: 1rem; */
106+
justify-content: space-evenly;
107+
align-items: start;
108+
}
109+
.toast-icon {
110+
padding: 0.35rem 0.5rem;
111+
}
112+
.toast-message {
113+
font-size: .9rem;
114+
color: #424242;
115+
padding: 0.15rem 0.5rem;
116+
}
117+
118+
/* success toast */
119+
.toast.toast-success{
120+
border-color: #03e05f;
121+
}
122+
.toast.toast-success .toast-progress{
123+
background-color: #088d3f;
124+
}
125+
.toast.toast-success .toast-icon>span,
126+
.toast.toast-success .toast-icon>i{
127+
color: #26c468;
128+
}
129+
130+
/* danger toast */
131+
.toast.toast-danger{
132+
border-color: #ff3f3f;
133+
}
134+
.toast.toast-danger .toast-progress{
135+
background-color: #d63030;
136+
}
137+
.toast.toast-danger .toast-icon>span,
138+
.toast.toast-danger .toast-icon>i{
139+
color: #ff3f3f;
140+
}
141+
142+
/* info toast */
143+
.toast.toast-info{
144+
border-color: #5fbdfc;
145+
}
146+
.toast.toast-info .toast-progress{
147+
background-color: #4b9fd8;
148+
}
149+
.toast.toast-info .toast-icon>span,
150+
.toast.toast-info .toast-icon>i{
151+
color: #5fbdfc;
152+
}
153+
154+
/* warning toast */
155+
.toast.toast-warning{
156+
border-color: #c99e25;
157+
}
158+
.toast.toast-warning .toast-progress{
159+
background-color: #bb9223;
160+
}
161+
.toast.toast-warning .toast-icon>span,
162+
.toast.toast-warning .toast-icon>i{
163+
color: #c99e25;
164+
}
23165
</style>
24166
</head>
25167
<body>
@@ -41,5 +183,6 @@
41183
</div>
42184
</div>
43185
</section>
186+
@yield('toasr')
44187
</body>
45188
</html>

resources/views/daftar-file.blade.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@
1919
<td class="is-actions-cell">
2020
<div class="buttons is-right">
2121
<a target="_blank" href="{{ \Illuminate\Support\Facades\Storage::disk('arsip')->url($item) }}">
22-
<button class="button is-small is-primary" type="button">Link</button>
22+
<button class="button is-small is-primary" type="button">
23+
<span class="icon">
24+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
25+
<path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" />
26+
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
27+
</svg>
28+
</span>
29+
</button>
2330
</a>
2431
</div>
2532
</td>

routes/web.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@
2626
->name('arsip-per-kak');
2727
Route::get('/arsip-dokumen/{token}/kak/{kak}', [ArsipController::class, 'daftarFile'])
2828
->name('daftar-file');
29+
Route::get('/download-folder/{token}/kak/{kak}', [ArsipController::class, 'downloadFolder'])
30+
->name('download-folder');
2931
});

0 commit comments

Comments
 (0)