From fd3cab2ddc8715546e0f2dc4ded12e4f192aac1e Mon Sep 17 00:00:00 2001 From: ctf0 Date: Sat, 9 Nov 2019 23:20:24 +0200 Subject: [PATCH] v3.5.0 - remove browser caching to give chance to new features - data are now being paginated and loaded on scroll, check https://github.com/ctf0/Laravel-Media-Manager/issues/104 - fix lots of weird styling - config, rdme, wiki are updated --- README.md | 9 ++- logs/v3.4.3.txt | 2 - logs/v3.5.0.txt | 4 ++ src/Controllers/MediaController.php | 27 ++++---- src/Controllers/Modules/GetContent.php | 30 +++++++- src/config/mediaManager.php | 7 +- .../js/components/globalSearch/panel.vue | 10 +-- .../imageEditor/filters/controls.vue | 25 ++++--- .../assets/js/components/imageEditor/main.vue | 42 +++++++---- .../assets/js/components/manager.vue | 5 +- .../js/components/utils/image-lazyLoading.vue | 2 +- src/resources/assets/js/modules/computed.js | 2 +- src/resources/assets/js/modules/filtration.js | 5 +- src/resources/assets/js/modules/folder.js | 5 +- src/resources/assets/js/modules/form.js | 42 +++++++++-- src/resources/assets/js/modules/player.js | 7 +- src/resources/assets/js/modules/selection.js | 2 +- src/resources/assets/js/modules/upload.js | 5 +- src/resources/assets/js/modules/utils.js | 5 ++ src/resources/assets/js/modules/watch.js | 12 ++-- src/resources/assets/js/webworkers/audio.js | 2 +- src/resources/assets/sass/manager.scss | 4 +- .../assets/sass/modules/global-search.scss | 69 +++++++++++-------- src/resources/assets/sass/partials/utils.scss | 4 ++ src/resources/views/_manager.blade.php | 3 + 25 files changed, 219 insertions(+), 111 deletions(-) delete mode 100644 logs/v3.4.3.txt create mode 100644 logs/v3.5.0.txt diff --git a/README.md b/README.md index 3d2cdf0..702899a 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ - [install dependencies](https://github.com/ctf0/Laravel-Media-Manager/wiki/Packages-In-Use) ```bash - yarn add vue vue-ls vue-async-computed vue-list-rendered vue-image-compare2 vue-tippy@v1 vue2-filters vue-input-autowidth vue-notif vue-clipboard2 vue-awesome@v2 vue-touch@next vue-focuspoint-component axios dropzone cropperjs keycode lottie-web plyr fuse.js + yarn add vue vue-ls vue-infinite-loading vue-async-computed vue-list-rendered vue-image-compare2 vue-tippy@v1 vue2-filters vue-input-autowidth vue-notif vue-clipboard2 vue-awesome@v2 vue-touch@next vue-focuspoint-component axios dropzone cropperjs keycode lottie-web plyr fuse.js ``` - add this one liner to your main js file and run `npm run watch` to compile your `js/css` files. @@ -98,7 +98,7 @@ * parentheses () * comma , */ - 'allowed_fileNames_chars' => '\._-\'\s\(\),', + 'allowed_fileNames_chars' => '\._\-\'\s\(\),', /* * remove any folder special chars except @@ -185,6 +185,11 @@ * Locked items table name (defaults to "locked") */ 'table_locked' => 'locked', + + /* + * loaded chunk amount "pagination" + */ + 'pagination_amount' => 50, ]; ``` diff --git a/logs/v3.4.3.txt b/logs/v3.4.3.txt deleted file mode 100644 index 3f3b788..0000000 --- a/logs/v3.4.3.txt +++ /dev/null @@ -1,2 +0,0 @@ -- some cleanup -- more options for upload preview, check https://github.com/ctf0/Laravel-Media-Manager/wiki/Preview-Files-Before-Uploading \ No newline at end of file diff --git a/logs/v3.5.0.txt b/logs/v3.5.0.txt new file mode 100644 index 0000000..ff88b3c --- /dev/null +++ b/logs/v3.5.0.txt @@ -0,0 +1,4 @@ +- remove browser caching to give chance to new features +- data are now being paginated and loaded on scroll, check https://github.com/ctf0/Laravel-Media-Manager/issues/104 +- fix lots of weird styling +- config, rdme, wiki are updated \ No newline at end of file diff --git a/src/Controllers/MediaController.php b/src/Controllers/MediaController.php index 638a94b..17cb31d 100755 --- a/src/Controllers/MediaController.php +++ b/src/Controllers/MediaController.php @@ -53,11 +53,13 @@ public function __construct() $this->unallowedMimes = $config['unallowed_mimes']; $this->LMF = $config['last_modified_format']; $this->GFI = $config['get_folder_info'] ?? true; + $this->pag_amount = $config['pagination_amount'] ?? 50; $this->storageDisk = app('filesystem')->disk($this->fileSystem); $this->storageDiskInfo = app('config')->get("filesystems.disks.{$this->fileSystem}"); $this->baseUrl = $this->storageDisk->url('/'); - $this->db = app('db')->connection($config['database_connection'] ?? 'mediamanager')->table($config['table_locked'] ?? 'locked'); + $this->db = app('db')->connection($config['database_connection'] ?? 'mediamanager') + ->table($config['table_locked'] ?? 'locked'); $this->storageDisk->addPlugin(new ListWith()); } @@ -74,16 +76,17 @@ public function index() public function globalSearch() { - return collect($this->getFolderContent('/', true))->reject(function ($item) { // remove unwanted - return preg_grep($this->ignoreFiles, [$item['path']]) || $item['type'] == 'dir'; - })->map(function ($file) { - return $file = [ - 'name' => $file['basename'], - 'type' => $file['mimetype'], - 'path' => $this->resolveUrl($file['path']), - 'dir' => $file['dirname'] != '' ? $file['dirname'] : '/', - 'last_modified_formated' => $this->getItemTime($file['timestamp']), - ]; - })->values()->all(); + return collect($this->getFolderContent('/', true)) + ->reject(function ($item) { // remove unwanted + return preg_grep($this->ignoreFiles, [$item['path']]) || $item['type'] == 'dir'; + })->map(function ($file) { + return $file = [ + 'name' => $file['basename'], + 'type' => $file['mimetype'], + 'path' => $this->resolveUrl($file['path']), + 'dir' => $file['dirname'] != '' ? $file['dirname'] : '/', + 'last_modified_formated' => $this->getItemTime($file['timestamp']), + ]; + })->values()->all(); } } diff --git a/src/Controllers/Modules/GetContent.php b/src/Controllers/Modules/GetContent.php index c5f23a3..e67f0b6 100644 --- a/src/Controllers/Modules/GetContent.php +++ b/src/Controllers/Modules/GetContent.php @@ -3,9 +3,37 @@ namespace ctf0\MediaManager\Controllers\Moduels; use Illuminate\Http\Request; +use Illuminate\Support\Collection; +use Illuminate\Pagination\Paginator; +use Illuminate\Pagination\LengthAwarePaginator; trait GetContent { + /** + * helper to paginate array. + * + * @param [type] $items + * @param int $perPage + * @param [type] $page + */ + public function paginate($items, $perPage = 10, $page = null) + { + $pageName = 'page'; + $page = $page ?: (Paginator::resolveCurrentPage($pageName) ?: 1); + $items = $items instanceof Collection ? $items : Collection::make($items); + + return new LengthAwarePaginator( + $items->forPage($page, $perPage)->values(), + $items->count(), + $perPage, + $page, + [ + 'path' => Paginator::resolveCurrentPath(), + 'pageName' => $pageName, + ] + ); + } + /** * get files in path. * @@ -28,7 +56,7 @@ public function getFiles(Request $request) 'dirs' => $this->getDirectoriesList($request->dirs), 'files' => [ 'path' => $folder, - 'items' => $this->getData($folder), + 'items' => $this->paginate($this->getData($folder), $this->pag_amount), ], ]); } diff --git a/src/config/mediaManager.php b/src/config/mediaManager.php index f3fede3..a3af21e 100644 --- a/src/config/mediaManager.php +++ b/src/config/mediaManager.php @@ -26,7 +26,7 @@ * parentheses () * comma , */ - 'allowed_fileNames_chars' => '\._-\'\s\(\),', + 'allowed_fileNames_chars' => '\._\-\'\s\(\),', /* * remove any folder special chars except @@ -113,4 +113,9 @@ * Locked items table name (defaults to "locked") */ 'table_locked' => 'locked', + + /* + * loaded chunk amount "pagination" + */ + 'pagination_amount' => 50, ]; diff --git a/src/resources/assets/js/components/globalSearch/panel.vue b/src/resources/assets/js/components/globalSearch/panel.vue index 94011ce..c6c9588 100644 --- a/src/resources/assets/js/components/globalSearch/panel.vue +++ b/src/resources/assets/js/components/globalSearch/panel.vue @@ -31,7 +31,7 @@ + class="columns is-multiline m-0">
  • { - this.$refs.search.focus() - }) + this.$nextTick(() => this.$refs.search.focus()) } else { this.$nextTick(() => { this.noData = false @@ -220,9 +218,7 @@ export default { this.getList() if (!this.firstRun) { - this.$nextTick(() => { - this.firstRun = true - }) + this.$nextTick(() => this.firstRun = true) } }, firstRun(val) { diff --git a/src/resources/assets/js/components/imageEditor/filters/controls.vue b/src/resources/assets/js/components/imageEditor/filters/controls.vue index 0f870ed..79599b3 100644 --- a/src/resources/assets/js/components/imageEditor/filters/controls.vue +++ b/src/resources/assets/js/components/imageEditor/filters/controls.vue @@ -1,25 +1,31 @@