Skip to content

Commit b59ed88

Browse files
committed
laravel-admin 2.0
1 parent ca1960f commit b59ed88

File tree

5 files changed

+282
-360
lines changed

5 files changed

+282
-360
lines changed

resources/views/list.blade.php

+99-123
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
.files>li>.file-select {
1212
position: absolute;
13-
top: -4px;
13+
top: -7px;
1414
left: -1px;
1515
}
1616
@@ -61,35 +61,26 @@
6161
6262
</style>
6363

64-
<script data-exec-on-popstate>
64+
<script>
6565
66-
$(function () {
67-
$('.file-delete').click(function () {
66+
var deleteFiles = function (files) {
67+
68+
if (!files.length) {
69+
return;
70+
}
6871
69-
var path = $(this).data('path');
70-
71-
swal({
72-
title: "{{ trans('admin.delete_confirm') }}",
73-
type: "warning",
74-
showCancelButton: true,
75-
confirmButtonColor: "#DD6B55",
76-
confirmButtonText: "{{ trans('admin.confirm') }}",
77-
showLoaderOnConfirm: true,
78-
closeOnConfirm: false,
79-
cancelButtonText: "{{ trans('admin.cancel') }}",
72+
$.admin.confirm({
73+
title: $.admin.trans('delete_confirm'),
8074
preConfirm: function() {
8175
return new Promise(function(resolve) {
82-
8376
$.ajax({
8477
method: 'delete',
8578
url: '{{ $url['delete'] }}',
8679
data: {
87-
'files[]':[path],
88-
_token:LA.token
80+
'files[]': files,
8981
},
9082
success: function (data) {
91-
$.pjax.reload('#pjax-container');
92-
83+
$.admin.reload();
9384
resolve(data);
9485
}
9586
});
@@ -100,12 +91,23 @@
10091
var data = result.value;
10192
if (typeof data === 'object') {
10293
if (data.status) {
103-
swal(data.message, '', 'success');
94+
$.admin.toastr.success(data.message);
10495
} else {
105-
swal(data.message, '', 'error');
96+
$.admin.toastr.error(data.message);
10697
}
10798
}
10899
});
100+
};
101+
102+
$('.file-delete').click(function () {
103+
deleteFiles([$(this).data('path')]);
104+
});
105+
106+
$('.file-delete-multiple').click(function () {
107+
var files = $(".file-select input:checked").map(function(){
108+
return $(this).val();
109+
}).toArray();
110+
deleteFiles(files);
109111
});
110112
111113
$('#moveModal').on('show.bs.modal', function (event) {
@@ -139,16 +141,15 @@
139141
data: {
140142
path: path,
141143
'new': name,
142-
_token:LA.token,
143144
},
144145
success: function (data) {
145-
$.pjax.reload('#pjax-container');
146+
$.admin.reload();
146147
147148
if (typeof data === 'object') {
148149
if (data.status) {
149-
toastr.success(data.message);
150+
$.admin.toastr.success(data.message);
150151
} else {
151-
toastr.error(data.message);
152+
$.admin.toastr.error(data.message);
152153
}
153154
}
154155
}
@@ -173,13 +174,13 @@
173174
data: formData,
174175
async: false,
175176
success: function (data) {
176-
$.pjax.reload('#pjax-container');
177+
$.admin.reload();
177178
178179
if (typeof data === 'object') {
179180
if (data.status) {
180-
toastr.success(data.message);
181+
$.admin.toastr.success(data.message);
181182
} else {
182-
toastr.error(data.message);
183+
$.admin.toastr.error(data.message);
183184
}
184185
}
185186
},
@@ -198,137 +199,112 @@ function closeModal() {
198199
}
199200
200201
$('.media-reload').click(function () {
201-
$.pjax.reload('#pjax-container');
202+
$.admin.reload();
202203
});
203204
204205
$('.goto-url button').click(function () {
205206
var path = $('.goto-url input').val();
206-
$.pjax({container:'#pjax-container', url: '{{ $url['index'] }}?path=' + path });
207+
$.admin.redirect('{{ $url['index'] }}?path=' + path);
207208
});
208209
209-
$('.file-select>input').iCheck({checkboxClass:'icheckbox_minimal-blue'});
210-
211-
$('.file-delete-multiple').click(function () {
212-
var files = $(".file-select input:checked").map(function(){
213-
return $(this).val();
214-
}).toArray();
215-
216-
if (!files.length) {
217-
return;
210+
$('.files-select-all').on('change', function(event) {
211+
if (this.checked) {
212+
$('.grid-row-checkbox').prop('checked', true);
213+
} else {
214+
$('.grid-row-checkbox').prop('checked', false);
218215
}
216+
});
219217
220-
swal({
221-
title: "{{ trans('admin.delete_confirm') }}",
222-
type: "warning",
223-
showCancelButton: true,
224-
confirmButtonColor: "#DD6B55",
225-
confirmButtonText: "{{ trans('admin.confirm') }}",
226-
showLoaderOnConfirm: true,
227-
closeOnConfirm: false,
228-
cancelButtonText: "{{ trans('admin.cancel') }}",
229-
preConfirm: function() {
230-
return new Promise(function(resolve) {
231-
232-
$.ajax({
233-
method: 'delete',
234-
url: '{{ $url['delete'] }}',
235-
data: {
236-
'files[]': files,
237-
_token:LA.token
238-
},
239-
success: function (data) {
240-
$.pjax.reload('#pjax-container');
241-
242-
resolve(data);
243-
}
244-
});
218+
$('.file-select input').on('change', function () {
219+
if (this.checked) {
220+
$(this).closest('tr').css('background-color', '#ffffd5');
221+
} else {
222+
$(this).closest('tr').css('background-color', '');
223+
}
224+
});
245225
246-
});
247-
}
248-
}).then(function (result) {
249-
var data = result.value;
250-
if (typeof data === 'object') {
251-
if (data.status) {
252-
swal(data.message, '', 'success');
253-
} else {
254-
swal(data.message, '', 'error');
255-
}
256-
}
257-
});
226+
$('.file-select-all input').on('change', function () {
227+
if (this.checked) {
228+
$('.file-select input').prop('checked', true);
229+
} else {
230+
$('.file-select input').prop('checked', false);
231+
}
258232
});
259-
});
260233
234+
$('table>tbody>tr').mouseover(function () {
235+
$(this).find('.btn-group').removeClass('d-none');
236+
}).mouseout(function () {
237+
$(this).find('.btn-group').addClass('d-none');
238+
});
261239
</script>
262240

263241
<div class="row">
264242
<!-- /.col -->
265-
<div class="col-md-12">
266-
<div class="box box-primary">
267-
268-
<div class="box-body no-padding">
243+
<div class="col-12">
244+
<div class="card card-@color card-outline">
245+
246+
<div class="card-header">
247+
<div class="card-tools">
248+
<div class="input-group float-right goto-url" style="width: 350px;">
249+
<input type="text" name="path" class="form-control" value="{{ '/'.trim($url['path'], '/') }}">
250+
<div class="input-group-append">
251+
<button type="submit" class="btn btn-default"><i class="fas fa-arrow-right"></i></button>
252+
</div>
253+
</div>
254+
</div>
255+
<div class="float-left d-flex">
269256

270-
<div class="mailbox-controls with-border">
271257
<div class="btn-group">
272258
<a href="" type="button" class="btn btn-default btn media-reload" title="Refresh">
273-
<i class="fa fa-refresh"></i>
259+
<i class="fas fa-sync"></i>
274260
</a>
275261
<a type="button" class="btn btn-default btn file-delete-multiple" title="Delete">
276-
<i class="fa fa-trash-o"></i>
262+
<i class="fas fa-trash"></i>
277263
</a>
278264
</div>
279265
<!-- /.btn-group -->
280-
<label class="btn btn-default btn"{{-- data-toggle="modal" data-target="#uploadModal"--}}>
281-
<i class="fa fa-upload"></i>&nbsp;&nbsp;{{ trans('admin.upload') }}
266+
267+
<label class="btn btn-default mb-0 ml-1">
268+
<i class="fas fa-upload"></i>&nbsp;&nbsp;{{ trans('admin.upload') }}
282269
<form action="{{ $url['upload'] }}" method="post" class="file-upload-form" enctype="multipart/form-data" pjax-container>
283-
<input type="file" name="files[]" class="hidden file-upload" multiple>
270+
<input type="file" name="files[]" class="d-none file-upload" multiple>
284271
<input type="hidden" name="dir" value="{{ $url['path'] }}" />
285272
{{ csrf_field() }}
286273
</form>
287274
</label>
288275

289276
<!-- /.btn-group -->
290-
<a class="btn btn-default btn" data-toggle="modal" data-target="#newFolderModal">
291-
<i class="fa fa-folder"></i>&nbsp;&nbsp;{{ trans('admin.new_folder') }}
277+
<a class="btn btn-default btn ml-1" data-toggle="modal" data-target="#newFolderModal">
278+
<i class="fas fa-folder"></i>&nbsp;&nbsp;{{ trans('admin.new_folder') }}
292279
</a>
293280

294-
<div class="btn-group">
295-
<a href="{{ route('media-index', ['path' => $url['path'], 'view' => 'table']) }}" class="btn btn-default {{ request('view') == 'table' ? 'active' : '' }}"><i class="fa fa-list"></i></a>
296-
<a href="{{ route('media-index', ['path' => $url['path'], 'view' => 'list']) }}" class="btn btn-default {{ request('view') == 'list' ? 'active' : '' }}"><i class="fa fa-th"></i></a>
297-
</div>
298-
299-
{{--<form action="{{ $url['index'] }}" method="get" pjax-container>--}}
300-
<div class="input-group input-group-sm pull-right goto-url" style="width: 250px;">
301-
<input type="text" name="path" class="form-control pull-right" value="{{ '/'.trim($url['path'], '/') }}">
302-
303-
<div class="input-group-btn">
304-
<button type="submit" class="btn btn-default"><i class="fa fa-arrow-right"></i></button>
305-
</div>
281+
<div class="btn-group ml-1">
282+
<a href="{{ route('media-index', ['path' => $url['path'], 'view' => 'table']) }}" class="btn btn-default active"><i class="fas fa-list"></i></a>
283+
<a href="{{ route('media-index', ['path' => $url['path'], 'view' => 'list']) }}" class="btn btn-default"><i class="fas fa-th"></i></a>
306284
</div>
307-
{{--</form>--}}
308-
309285
</div>
310-
311-
<!-- /.mailbox-read-message -->
312286
</div>
287+
313288
<!-- /.box-body -->
314-
<div class="box-footer">
315-
<ol class="breadcrumb" style="margin-bottom: 10px;">
289+
<div class="box-body">
290+
<ol class="breadcrumb m-2">
316291

317-
<li><a href="{{ route('media-index') }}"><i class="fa fa-th-large"></i> </a></li>
292+
<li class="breadcrumb-item"><a href="{{ route('media-index') }}"><i class="far fa-folder-open"></i> </a></li>
318293

319294
@foreach($nav as $item)
320-
<li><a href="{{ $item['url'] }}"> {{ $item['name'] }}</a></li>
295+
<li class="breadcrumb-item"><a href="{{ $item['url'] }}"> {{ $item['name'] }}</a></li>
321296
@endforeach
322297
</ol>
323-
<ul class="files clearfix">
298+
<ul class="files clearfix m-3">
324299

325300
@if (empty($list))
326301
<li style="height: 200px;border: none;"></li>
327302
@else
328303
@foreach($list as $item)
329304
<li>
330-
<span class="file-select">
331-
<input type="checkbox" value="{{ $item['name'] }}"/>
305+
<span class="file-select icheck-@color d-inline">
306+
<input type="checkbox" value="{{ $item['name'] }}" id="@id"/>
307+
<label for='@id'></label>
332308
</span>
333309

334310
{!! $item['preview'] !!}
@@ -345,15 +321,15 @@ function closeModal() {
345321
<span class="caret"></span>
346322
<span class="sr-only">Toggle Dropdown</span>
347323
</button>
348-
<ul class="dropdown-menu" role="menu">
349-
<li><a href="#" class="file-rename" data-toggle="modal" data-target="#moveModal" data-name="{{ $item['name'] }}">Rename & Move</a></li>
350-
<li><a href="#" class="file-delete" data-path="{{ $item['name'] }}">Delete</a></li>
324+
<div class="dropdown-menu" role="menu">
325+
<a href="#" class="file-rename dropdown-item" data-toggle="modal" data-target="#moveModal" data-name="{{ $item['name'] }}">Rename & Move</a>
326+
<a href="#" class="file-delete dropdown-item" data-path="{{ $item['name'] }}">Delete</a>
351327
@unless($item['isDir'])
352-
<li><a target="_blank" href="{{ $item['download'] }}">Download</a></li>
328+
<a target="_blank" class="dropdown-item" href="{{ $item['download'] }}">Download</a>
353329
@endunless
354-
<li class="divider"></li>
355-
<li><a href="#" data-toggle="modal" data-target="#urlModal" data-url="{{ $item['url'] }}">Url</a></li>
356-
</ul>
330+
<div role="separator" class="dropdown-divider"></div>
331+
<a href="#" data-toggle="modal" class="dropdown-item" data-target="#urlModal" data-url="{{ $item['url'] }}">Url</a>
332+
</div>
357333
</div>
358334
</span>
359335
</div>
@@ -374,8 +350,8 @@ function closeModal() {
374350
<div class="modal-dialog" role="document">
375351
<div class="modal-content">
376352
<div class="modal-header">
353+
<h5 class="modal-title" id="moveModalLabel">Rename & Move</h5>
377354
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
378-
<h4 class="modal-title" id="moveModalLabel">Rename & Move</h4>
379355
</div>
380356
<form id="file-move">
381357
<div class="modal-body">
@@ -398,8 +374,8 @@ function closeModal() {
398374
<div class="modal-dialog" role="document">
399375
<div class="modal-content">
400376
<div class="modal-header">
377+
<h5 class="modal-title" id="urlModalLabel">Url</h5>
401378
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
402-
<h4 class="modal-title" id="urlModalLabel">Url</h4>
403379
</div>
404380
<div class="modal-body">
405381
<div class="form-group">
@@ -417,8 +393,8 @@ function closeModal() {
417393
<div class="modal-dialog" role="document">
418394
<div class="modal-content">
419395
<div class="modal-header">
396+
<h5 class="modal-title" id="newFolderModalLabel">New folder</h5>
420397
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
421-
<h4 class="modal-title" id="newFolderModalLabel">New folder</h4>
422398
</div>
423399
<form id="new-folder">
424400
<div class="modal-body">

0 commit comments

Comments
 (0)