Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix the fucken extra space at bottom

minor

update localforage

replace localforage with idb-keyval

removes 55kb “547 > 492”

optimization

…

- fix ff backspace btn
- finalize the new cache lib

v2.3.0

v2.6.0
  • Loading branch information
ctf0 committed Mar 21, 2018
1 parent 6ac9a52 commit a0a96ce
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 66 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
- install dependencies

```bash
yarn add vue vue-ls vue-tippy@v1 vue2-filters vue-bounty vue-notif vue-clipboard2 vue-awesome vue-touch@next axios dropzone cropperjs keycode babel-preset-es2015-node6 babel-preset-stage-2
yarn add vue vue-ls vue-tippy@v1 vue2-filters vue-bounty vue-notif vue-clipboard2 vue-awesome vue-touch@next idb-keyval axios dropzone cropperjs keycode babel-preset-es2015-node6 babel-preset-stage-2
# or
npm install vue vue-ls vue-tippy@v1 vue2-filters vue-bounty vue-notif vue-clipboard2 vue-awesome vue-touch@next axios dropzone cropperjs keycode babel-preset-es2015-node6 babel-preset-stage-2 --save
npm install vue vue-ls vue-tippy@v1 vue2-filters vue-bounty vue-notif vue-clipboard2 vue-awesome vue-touch@next idb-keyval axios dropzone cropperjs keycode babel-preset-es2015-node6 babel-preset-stage-2 --save
```

- add this one liner to your main js file and run `npm run watch` to compile your `js/css` files.
Expand Down
File renamed without changes.
6 changes: 2 additions & 4 deletions src/Controllers/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class MediaController extends Controller
protected $folderChars;
protected $ignoreFiles;
protected $LMF;
protected $lockedList;
protected $sanitizedText;
protected $storageDisk;
protected $storageDiskInfo;
Expand All @@ -42,7 +41,6 @@ public function __construct(Carbon $carbon)
$this->unallowedMimes = array_get($config, 'unallowed_mimes');
$this->LMF = array_get($config, 'last_modified_format');
$this->db = app('db')->connection('mediamanager')->table('locked');
$this->lockedList = $this->db->pluck('path');
$this->storageDiskInfo = config("filesystems.disks.{$this->fileSystem}");
$this->zipCacheStore = app('cache')->store('mediamanager');

Expand Down Expand Up @@ -77,7 +75,7 @@ public function get_files(Request $request)
}

return response()->json([
'locked' => $this->lockedList,
'locked' => $this->db->pluck('path'),
'dirs' => $this->dirsList($request->dirs),
'files' => [
'path' => $folder,
Expand Down Expand Up @@ -460,7 +458,7 @@ public function delete_file(Request $request)
if ($type == 'folder') {
// check for files in lock list
foreach ($this->storageDisk->allFiles($file_name) as $file) {
if (in_array($this->resolveUrl($file), $this->lockedList->toArray())) {
if (in_array($this->resolveUrl($file), $this->db->pluck('path')->toArray())) {
$fullCacheClear = true;
$result[] = [
'success' => false,
Expand Down
4 changes: 2 additions & 2 deletions src/resources/assets/js/components/imageEditor/cropper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ import 'cropperjs/dist/cropper.css'
export default {
components: {Camann},
props: ['url', 'cropTrans', 'route'],
props: ['url', 'translations', 'route'],
data() {
return {
imageCropper: null,
Expand Down Expand Up @@ -395,7 +395,7 @@ export default {
return this.dragMode == val
},
trans(val) {
return this.cropTrans[val]
return this.translations[val]
},
// filters
Expand Down
42 changes: 23 additions & 19 deletions src/resources/assets/js/components/media.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default {
props: [
'config',
'inModal',
'mediaTrans',
'translations',
'filesRoute',
'dirsRoute',
'lockFileRoute',
Expand Down Expand Up @@ -134,6 +134,8 @@ export default {
},
shortCuts(e) {
let key = keycode(e)
if (!(this.isLoading || e.altKey || e.ctrlKey || e.metaKey)) {
// when modal isnt visible
if (!this.activeModal) {
Expand All @@ -143,12 +145,13 @@ export default {
if (!this.isBulkSelecting()) {
// open folder
if (keycode(e) == 'enter' && this.selectedFile) {
if (key == 'enter' && this.selectedFile) {
this.openFolder(this.selectedFile)
}
// go up a dir
if (keycode(e) == 'backspace' && this.folders.length) {
if (key == 'backspace' && this.folders.length) {
e.preventDefault()
this.goToPrevFolder()
}
Expand All @@ -157,7 +160,7 @@ export default {
this.navigation(e)
if (
keycode(e) == 'space' &&
key == 'space' &&
e.target == document.body &&
(
this.selectedFileIs('video') ||
Expand Down Expand Up @@ -186,21 +189,21 @@ export default {
}
// image editor
if (keycode(e) == 'e') {
if (key == 'e') {
this.$refs.editor.click()
}
}
// end of when there are files
// refresh
if (keycode(e) == 'r') {
if (key == 'r') {
if (!this.$refs.refresh.$el.disabled && !this.isLoading) {
this.refresh()
}
}
// file upload
if (keycode(e) == 'u') {
if (key == 'u') {
this.$refs.upload.click()
}
}
Expand All @@ -209,7 +212,7 @@ export default {
// with or without bulk selection
if (this.allItemsCount) {
// bulk select
if (keycode(e) == 'b') {
if (key == 'b') {
if (this.searchFor && this.searchItemsCount == 0) {
return
}
Expand All @@ -219,47 +222,47 @@ export default {
if (this.isBulkSelecting()) {
// add all to bulk list
if (keycode(e) == 'a') {
if (key == 'a') {
this.$refs.bulkSelectAll.click()
}
// cancel bulk selection
if (keycode(e) == 'esc') {
if (key == 'esc') {
this.$refs.bulkSelect.click()
}
}
// delete file
if (keycode(e) == 'delete' || keycode(e) == 'd') {
if (key == 'delete' || key == 'd') {
this.$refs.delete.click()
}
// move file
if (this.checkForFolders && keycode(e) == 'm') {
if (this.checkForFolders && key == 'm') {
this.$refs.move.click()
}
// lock files
if (keycode(e) == 'l') {
if (key == 'l') {
this.$refs.lock.click()
}
// set visibility
if (keycode(e) == 'v') {
if (key == 'v') {
this.$refs.vis.click()
}
}
/* end of with or without bulk selection */
// toggle file details sidebar
if (keycode(e) == 't') {
if (key == 't') {
this.toggleInfoPanel()
}
}
/* end of search is not focused */
// cancel search
else if (keycode(e) == 'esc') {
else if (key == 'esc') {
this.resetInput('searchFor')
}
}
Expand All @@ -269,7 +272,7 @@ export default {
else {
if (this.isActiveModal('preview_modal')) {
// hide lb
if (keycode(e) == 'space') {
if (key == 'space') {
e.preventDefault()
this.toggleModal()
}
Expand All @@ -278,7 +281,7 @@ export default {
}
// hide lb
if (keycode(e) == 'esc') {
if (key == 'esc') {
this.toggleModal()
}
}
Expand Down Expand Up @@ -344,6 +347,7 @@ export default {
}
}
}
}
},
render() {}
}
</script>
13 changes: 4 additions & 9 deletions src/resources/assets/js/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,10 @@ axios.defaults.headers.common = {
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
'X-Requested-With': 'XMLHttpRequest'
}
axios.interceptors.response.use((response) => {return response}, (error) => {return Promise.reject(error.response)})

// storage
window.localforage = require('./packages/localforage.min.js')
localforage.config({
name: 'ctf0-Media_Manager',
storeName: 'cached',
description: 'laravel-media-manager cache store'
})
axios.interceptors.response.use(
(response) => {return response},
(error) => {return Promise.reject(error.response)}
)

// vue-awesome
require('./modules/icons')
Expand Down
3 changes: 2 additions & 1 deletion src/resources/assets/js/mixins/media-modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default {
this.$parent[this.item] = path
}
})
}
},
render() {}
}
</script>
22 changes: 14 additions & 8 deletions src/resources/assets/js/modules/cache.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { Store, set, get, del, clear } from 'idb-keyval'
const idbKeyVal = new Store(
'ctf0-Media_Manager', // db
'laravel-media-manager' // store
)

export default {
methods: {
// local storage
Expand All @@ -18,12 +24,12 @@ export default {

// cache
cacheResponse(value) {
return localforage.setItem(this.cacheName, value).catch((err) => {
console.warn('localforage.setItem', err)
return set(this.cacheName, value, idbKeyVal).catch((err) => {
console.warn('cacheStore.setItem', err)
})
},
getCachedResponse() {
return localforage.getItem(this.cacheName)
return get(this.cacheName, idbKeyVal)
},
removeCachedResponse(destination = null) {
let cacheName = this.cacheName
Expand All @@ -43,17 +49,17 @@ export default {
: [cacheName]

items.forEach((one) => {
return localforage.removeItem(one).then(() => {
console.log(`${one} cache is cleared!`)
return del(one, idbKeyVal).then(() => {
console.log(`${one} ${this.trans('clear_cache')}`)
}).catch((err) => {
console.warn('localforage.removeItem', err)
console.warn('cacheStore.removeItem', err)
})
})
},
clearCache(showNotif = true) {
localforage.clear().then(() => {
clear(idbKeyVal).then(() => {
if (showNotif) {
this.showNotif('Cache Cleared')
this.showNotif(this.trans('clear_cache'))
}

setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/resources/assets/js/modules/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ export default {
this.ajaxError()
})
},

// visibility
SetVisibilityForm(event) {
let list = this.bulkItemsCount
Expand Down
10 changes: 6 additions & 4 deletions src/resources/assets/js/modules/selected.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,22 @@ export default {

/* Navigation */
navigation(e) {
let key = keycode(e)

// go to prev item
if (keycode(e) == 'left' || keycode(e) == 'up') {
if (key == 'left' || key == 'up') {
e.preventDefault()
this.goToPrev()
}

// go to next item
if (keycode(e) == 'right' || keycode(e) == 'down') {
if (key == 'right' || key == 'down') {
e.preventDefault()
this.goToNext()
}

// go to last item
if (keycode(e) == 'end') {
if (key == 'end') {
e.preventDefault()
this.imageSlideDirection = 'next'

Expand All @@ -131,7 +133,7 @@ export default {
}

// go to first item
if (keycode(e) == 'home') {
if (key == 'home') {
e.preventDefault()
this.imageSlideDirection = 'prev'
this.scrollToFile(this.$refs.file_0)
Expand Down
2 changes: 1 addition & 1 deletion src/resources/assets/js/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default {
return index > 0 ? name.substring(index + 1) : null
},
trans(key) {
return this.mediaTrans[key]
return this.translations[key]
},

/* Toggle */
Expand Down
7 changes: 0 additions & 7 deletions src/resources/assets/js/packages/localforage.min.js

This file was deleted.

Loading

0 comments on commit a0a96ce

Please sign in to comment.