Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit e0647d9

Browse files
committed
v2.2.0
1 parent 3e36b55 commit e0647d9

File tree

17 files changed

+372
-369
lines changed

17 files changed

+372
-369
lines changed

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,7 @@ return [
157157
/**
158158
* hide file extension in files list
159159
*/
160-
'hide_ext' => true,
161-
162-
/*
163-
* locked files list
164-
*/
165-
'locked_files_list' => storage_path('logs/MediaManager.php')
160+
'hide_ext' => true
166161
];
167162
```
168163

logs/v2.1.0.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.

logs/v2.2.0.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- added missing vendor/download “sorry about that”
2+
- keep visited folder active when navigating up
3+
- add animation
4+
- add swipe left/right for image preview
5+
- add swipe up/down for move & delete selected
6+
- add lock item option “check wiki for notes”
7+
- removed framework config, update your ‘webpack.mix.js’
8+
- less depend on jquery
9+
- update assets
10+
- update readme
11+
- make sure to republish the assets as new files were added.

src/Controllers/MediaController.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function get_files(Request $request)
6161
}
6262

6363
return response()->json([
64-
'locked' => file_exists($this->locked_files_list) ? include $this->locked_files_list : [],
64+
'locked' => app('db')->connection('mediamanager')->table('locked')->pluck('path'),
6565
'files' => [
6666
'path' => $folder,
6767
'items' => $this->getData($folder),
@@ -345,20 +345,12 @@ public function lock_file(Request $request)
345345
{
346346
$path = $request->path;
347347
$state = $request->state;
348-
$data = [];
348+
$db = app('db')->connection('mediamanager')->table('locked');
349349

350-
if (file_exists($this->locked_files_list)) {
351-
$data = include $this->locked_files_list;
352-
}
353-
354-
'add' == $state
355-
? array_push($data, $path)
356-
: array_splice($data, array_search($path, $data), 1);
357-
358-
$res = "<?php\n\nreturn " . var_export($data, true) . ';';
350+
'added' == $state
351+
? $db->insert(['path'=>$path])
352+
: $db->where('path', $path)->delete();
359353

360-
return app('files')->put($this->locked_files_list, $res)
361-
? response()->json(['message'=>"done $state"])
362-
: response()->json(['message'=>trans('MediaManager::messages.ajax_error')]);
354+
return response()->json(['message'=>"'$path' $state"]);
363355
}
364356
}

src/MediaManagerServiceProvider.php

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ protected function packagePublish()
3232
__DIR__ . '/config' => config_path(),
3333
], 'config');
3434

35+
// database
36+
$this->publishes([
37+
__DIR__ . '/database' => storage_path('log'),
38+
], 'db');
39+
40+
$db_info = [
41+
'driver' => 'sqlite',
42+
'database' => storage_path('logs/MediaManager.sqlite'),
43+
'prefix' => '',
44+
];
45+
config(['database.connections.mediamanager' => $db_info]);
46+
3547
// public
3648
$this->publishes([
3749
__DIR__ . '/dist' => public_path('assets/vendor/MediaManager'),
@@ -55,7 +67,6 @@ protected function packagePublish()
5567
], 'view');
5668

5769
$this->viewComp();
58-
static::create_LLD(config('mediaManager.locked_files_list'));
5970
}
6071

6172
protected function viewComp()
@@ -71,22 +82,6 @@ protected function viewComp()
7182
});
7283
}
7384

74-
/**
75-
* create locked list dir.
76-
*
77-
* @param [type] $dir [description]
78-
*
79-
* @return [type] [description]
80-
*/
81-
protected static function create_LLD($dir)
82-
{
83-
$dir_name = dirname($dir);
84-
85-
if (!app('files')->exists($dir_name)) {
86-
return app('files')->makeDirectory($dir_name, 0755, true);
87-
}
88-
}
89-
9085
/**
9186
* [autoReg description].
9287
*
@@ -115,7 +110,7 @@ protected function autoReg()
115110
// MediaManager
116111
require('dotenv').config()
117112
mix.js('resources/assets/vendor/MediaManager/js/manager.js', 'public/assets/vendor/MediaManager')
118-
.sass('resources/assets/vendor/MediaManager/sass/media-' + process.env.MIX_MM_FRAMEWORK + '.scss', 'public/assets/vendor/MediaManager/style.css')
113+
.sass('resources/assets/vendor/MediaManager/sass/media.scss', 'public/assets/vendor/MediaManager/style.css')
119114
.version();
120115
EOT;
121116

src/config/mediaManager.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,4 @@
4747
* hide file extension in files list
4848
*/
4949
'hide_ext' => true,
50-
51-
/*
52-
* locked files list
53-
*/
54-
'locked_files_list' => storage_path('logs/MediaManager.php'),
5550
];

src/database/MediaManager.sqlite

12 KB
Binary file not shown.

src/resources/assets/js/components/media.vue

Lines changed: 114 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script>
22
import Form from './mixins/form'
3-
import Ops from './mixins/ops'
43
import FileFiltration from './mixins/filtration'
54
import BulkSelect from './mixins/bulk'
65
import LockFile from './mixins/lock'
@@ -14,7 +13,6 @@ export default {
1413
name: 'media-manager',
1514
mixins: [
1615
Form,
17-
Ops,
1816
FileFiltration,
1917
BulkSelect,
2018
LockFile,
@@ -25,13 +23,15 @@ export default {
2523
Watchers
2624
],
2725
props: [
26+
'baseUrl',
2827
'inModal',
28+
'hideExt',
29+
'mediaTrans',
2930
'filesRoute',
3031
'dirsRoute',
31-
'hideExt',
32+
'lockFileRoute',
3233
'restrictPath',
33-
'restrictExt',
34-
'mediaTrans'
34+
'restrictExt'
3535
],
3636
data() {
3737
return {
@@ -90,7 +90,7 @@ export default {
9090
$('#uploadProgress').fadeIn()
9191
},
9292
totaluploadprogress(uploadProgress) {
93-
$('#uploadProgress .progress-bar').css('width', uploadProgress + '%')
93+
$('.progress-bar').css('width', uploadProgress + '%')
9494
},
9595
successmultiple(files, res) {
9696
res.data.map((item) => {
@@ -107,13 +107,14 @@ export default {
107107
this.showNotif(res, 'danger')
108108
},
109109
queuecomplete() {
110-
manager.$refs.upload.click()
110+
manager.toggleUploadPanel()
111111
$('#uploadProgress').fadeOut(() => {
112-
$('#uploadProgress .progress-bar').css('width', 0)
112+
$('.progress-bar').css('width', 0)
113113
})
114114
}
115115
})
116116
},
117+
117118
shortCuts() {
118119
$(document).keydown((e) => {
119120
@@ -163,12 +164,12 @@ export default {
163164
164165
// refresh
165166
if (keycode(e) == 'r') {
166-
this.$refs.refresh.click()
167+
this.getFiles(this.folders)
167168
}
168169
169170
// file upload
170171
if (keycode(e) == 'u') {
171-
this.$refs.upload.click()
172+
this.toggleUploadPanel()
172173
}
173174
}
174175
/* end of no bulk selection */
@@ -191,17 +192,17 @@ export default {
191192
192193
// delete file
193194
if (keycode(e) == 'delete' || keycode(e) == 'd') {
194-
this.deleteItem()
195+
this.$refs.delete.click()
195196
}
196197
197198
// move file
198199
if (this.checkForFolders() && keycode(e) == 'm') {
199-
this.moveItem()
200+
this.$refs.move.click()
200201
}
201202
202203
// lock files
203204
if (keycode(e) == 'l') {
204-
this.pushToLockedList()
205+
this.$refs.lock.click()
205206
}
206207
}
207208
/* end of with or without bulk selection */
@@ -240,6 +241,106 @@ export default {
240241
/* end of modal is visible */
241242
})
242243
},
244+
deleteItem() {
245+
if (!this.isBulkSelecting() && this.selectedFile) {
246+
if (this.selectedFileIs('folder')) {
247+
this.folderWarning = true
248+
} else {
249+
this.folderWarning = false
250+
}
251+
252+
this.$refs.confirm_delete.innerText = this.selectedFile.name
253+
}
254+
255+
if (this.bulkItemsCount) {
256+
this.bulkListFilter.some((item) => {
257+
if (this.fileTypeIs(item, 'folder')) {
258+
return this.folderWarning = true
259+
}
260+
261+
this.folderWarning = false
262+
})
263+
}
264+
265+
this.toggleModal('#confirm_delete_modal')
266+
},
267+
moveItem() {
268+
this.toggleModal('#move_file_modal')
269+
},
270+
renameItem() {
271+
this.toggleModal('#rename_file_modal')
272+
},
273+
blkSlct() {
274+
this.bulkSelect = !this.bulkSelect
275+
276+
// reset when toggled off
277+
if (this.isBulkSelecting()) {
278+
return this.clearSelected()
279+
}
280+
281+
this.bulkSelectAll = false
282+
this.clearSelected()
283+
this.resetInput('bulkList', [])
284+
this.selectFirst()
285+
},
286+
blkSlctAll() {
287+
// if no items in bulk list
288+
if (this.bulkList == 0) {
289+
// if no search query
290+
if (!this.searchFor) {
291+
this.bulkSelectAll = true
292+
this.bulkList = this.allFiles.slice(0)
293+
}
294+
295+
// if found search items
296+
if (this.searchItemsCount) {
297+
this.bulkSelectAll = true
298+
$('#files li').each(function() {
299+
$(this).trigger('click')
300+
})
301+
}
302+
}
303+
304+
// if having search + having bulk items < search found items
305+
else if (this.searchFor && this.bulkItemsCount < this.searchItemsCount) {
306+
this.resetInput('bulkList', [])
307+
this.clearSelected()
308+
309+
if (this.bulkSelectAll) {
310+
this.bulkSelectAll = false
311+
} else {
312+
this.bulkSelectAll = true
313+
$('#files li').each(function() {
314+
$(this).trigger('click')
315+
})
316+
}
317+
}
318+
319+
// if NO search + having bulk items < all items
320+
else if (!this.searchFor && this.bulkItemsCount < this.allItemsCount) {
321+
if (this.bulkSelectAll) {
322+
this.bulkSelectAll = false
323+
this.resetInput('bulkList', [])
324+
} else {
325+
this.bulkSelectAll = true
326+
this.bulkList = this.allFiles.slice(0)
327+
}
328+
329+
this.clearSelected()
330+
}
331+
332+
// otherwise
333+
else {
334+
this.bulkSelectAll = false
335+
this.resetInput('bulkList', [])
336+
this.clearSelected()
337+
}
338+
339+
// if we have items in bulk list, select first item
340+
if (this.bulkItemsCount) {
341+
this.selectedFile = this.bulkList[0]
342+
}
343+
},
243344
244345
/**
245346
* autoplay media

0 commit comments

Comments
 (0)