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

Commit ddd4efc

Browse files
committed
v2.3.4
1 parent c874a5a commit ddd4efc

File tree

14 files changed

+362
-188
lines changed

14 files changed

+362
-188
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ new Vue({
6666
- dynamically hide [files](https://github.com/ctf0/Laravel-Media-Manager/wiki/Hide-Files-With-Extension)
6767
- dynamically hide [folders](https://github.com/ctf0/Laravel-Media-Manager/wiki/Hide-Folders)
6868
- toggle between `random names` & `original names` for uploaded files
69-
- download selected ***"including bulk selection"***
69+
- download selected ["including bulk selection"](https://github.com/ctf0/Laravel-Media-Manager/wiki/Download-Files-as-a-ZipFile)
7070
- directly copy selected file link
7171
- use manager [from modal with ease](https://github.com/ctf0/Laravel-Media-Manager/wiki/Use-The-Manager-From-A-Modal)
7272
- auto scroll to selected item when using (left/up, right/down, home, end)

logs/v2.3.3.txt

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

logs/v2.3.4.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Edits
2+
3+
- in image preview, click the name to copy its url.
4+
- move upload panel bg patterns to its own branch to minimize package size.
5+
- more cleanup.
6+
- uploading new items while the manager is already uploading is now disabled, also the call to update the files list will run only once at the end of the upload to minimize the load on the server.
7+
8+
# Bulk Select
9+
10+
- show total selected items size
11+
- show folders nested items count
12+
- fix not being able to manually deselect last item in bulk list
13+
- show items size when deleting + total if more than one
14+
- if you want you can now download a zip file with all the selected files instead of separate ones. https://github.com/ctf0/Laravel-Media-Manager/wiki/Download-Files-as-a-ZipFile
15+
16+
- update readme
17+
- update assets

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

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Restriction from './mixins/restriction'
88
import Utilities from './mixins/utils'
99
import Watchers from './mixins/watch'
1010
import Computed from './mixins/computed'
11+
import Download from './mixins/download'
1112
1213
import Bounty from 'vue-bounty'
1314
@@ -23,6 +24,7 @@ export default {
2324
Restriction,
2425
Utilities,
2526
Computed,
27+
Download,
2628
Watchers
2729
],
2830
props: [
@@ -75,7 +77,12 @@ export default {
7577
new_folder_name: null,
7678
new_filename: null,
7779
active_modal: null,
78-
navDirection: ''
80+
81+
navDirection: null,
82+
gradients: [
83+
'linear-gradient(45deg,#6FE594,#27A47C)',
84+
'linear-gradient(45deg,#F1467A,#FB949E)'
85+
]
7986
}
8087
},
8188
created() {
@@ -120,6 +127,7 @@ export default {
120127
let counter = 0
121128
let progress = 0
122129
let increaseBy = 0
130+
let last = null
123131
124132
new Dropzone('#new-upload', {
125133
createImageThumbnails: false,
@@ -140,22 +148,24 @@ export default {
140148
},
141149
successmultiple(files, res) {
142150
res.data.map((item) => {
143-
item.success
144-
? manager.showNotif(`${manager.trans('upload_success')} "${item.message}"`)
145-
: manager.showNotif(item.message, 'danger')
151+
if (item.success) {
152+
manager.showNotif(`${manager.trans('upload_success')} "${item.message}"`)
153+
last = item.message
154+
} else {
155+
manager.showNotif(item.message, 'danger')
156+
}
146157
})
147-
148-
res.data.length
149-
? manager.getFiles(manager.folders, null, res.data[res.data.length - 1].message)
150-
: manager.getFiles(manager.folders)
151158
},
152159
errormultiple(files, res) {
153160
manager.showNotif(res, 'danger')
154161
},
155162
queuecomplete() {
156163
manager.uploadStart = false
157-
manager.toggleUploadPanel()
158164
manager.uploadProgress = 0
165+
166+
last
167+
? manager.getFiles(manager.folders, null, last)
168+
: manager.getFiles(manager.folders)
159169
}
160170
})
161171
},
@@ -221,7 +231,7 @@ export default {
221231
222232
// file upload
223233
if (keycode(e) == 'u') {
224-
this.toggleUploadPanel()
234+
this.$refs.upload.click()
225235
}
226236
}
227237
/* end of no bulk selection */
@@ -311,8 +321,6 @@ export default {
311321
this.selectedFileIs('folder')
312322
? this.folderWarning = true
313323
: this.folderWarning = false
314-
315-
this.$refs.confirm_delete.innerText = this.selectedFile.name
316324
}
317325
318326
if (this.bulkItemsCount) {

src/resources/assets/js/components/mixins/bulk.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ export default {
1313

1414
this.bulkList.splice(this.bulkList.indexOf(file), 1)
1515

16-
// select prev item
17-
this.selectedFile = this.bulkList[this.bulkItemsCount - 1]
16+
if (this.bulkItemsCount) {
17+
// select prev item
18+
this.selectedFile = this.bulkList[this.bulkItemsCount - 1]
19+
} else {
20+
this.resetInput(['selectedFile', 'currentFileIndex'])
21+
}
1822
},
1923
selectFirstInBulkList() {
2024
let list = this.bulkList
Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,83 @@
11
export default {
22
computed: {
3+
filesList() {
4+
return this.$refs.filesList.$el.children
5+
},
36
allFiles() {
47
if (this.filteredItemsCount) {
58
return this.filterdList
69
}
710

811
return this.files.items
912
},
10-
filteredItemsCount() {
11-
if (typeof this.filterdList !== 'undefined' && this.filterdList.length > 0) {
12-
return this.filterdList.length
13-
}
14-
},
1513
allItemsCount() {
1614
if (typeof this.allFiles !== 'undefined' && this.allFiles.length > 0) {
1715
return this.allFiles.length
1816
}
1917
},
20-
filesList() {
21-
return this.$refs.filesList.$el.children
18+
filteredItemsCount() {
19+
if (typeof this.filterdList !== 'undefined' && this.filterdList.length > 0) {
20+
return this.filterdList.length
21+
}
2222
},
23+
24+
// bulk
2325
bulkItemsCount() {
2426
if (typeof this.bulkList !== 'undefined' && this.bulkList.length > 0) {
2527
return this.bulkList.length
2628
}
2729
},
28-
uploadPanelImg() {
29-
if (this.uploadToggle) {
30-
let list = this.uploadPanelImgList
31-
let url = list[Math.floor(Math.random() * list.length)]
30+
bulkItemsSize() {
31+
let count = 0
3232

33-
return {
34-
'background-image': `url("${url}")`
33+
this.bulkList.map((item) => {count += item.size})
34+
35+
return this.getFileSize(count)
36+
},
37+
bulkItemsChild() {
38+
let bulk = this.bulkItemsCount
39+
40+
if (bulk) {
41+
if (bulk == 1 && !this.selectedFileIs('folder')) {
42+
return
3543
}
44+
45+
let count = 0
46+
47+
this.bulkList.map((item) => {
48+
let list = item.items
49+
50+
if (list) {
51+
count += list
52+
}
53+
})
54+
55+
return count
3656
}
3757
},
38-
3958
// this is made so we can still use move/delete
4059
// incase we have multiple files selected
4160
// and one or more of them is locked
4261
bulkListFilter() {
4362
return this.lockedList.length
4463
? this.bulkList.filter((e) => {return !this.lockedList.includes(e.path)})
4564
: this.bulkList
65+
},
66+
67+
// upload panel
68+
uploadPanelImg() {
69+
if (this.uploadToggle) {
70+
let imgs = this.uploadPanelImgList
71+
let grds = this.gradients
72+
73+
let url = imgs[Math.floor(Math.random() * imgs.length)]
74+
let color = grds[Math.floor(Math.random() * grds.length)]
75+
76+
return {
77+
'--gradient': color,
78+
'background-image': `url("${url}")`
79+
}
80+
}
4681
}
4782
}
4883
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// for normal download
2+
require('./../../vendor/download.min')
3+
4+
// for zip download
5+
const JSZip = require('jszip')
6+
const JSZipUtils = require('jszip-utils')
7+
const FileSaver = require('file-saver')
8+
9+
export default {
10+
methods: {
11+
// download
12+
saveFile(item) {
13+
if (this.isBulkSelecting()) {
14+
return typeof JSZip != 'undefined'
15+
? this.zipFiles(this.bulkList)
16+
: this.downloadFiles(this.bulkList)
17+
}
18+
19+
this.downloadFiles([item])
20+
this.showNotif(`"${item.name}" ${this.trans('downloaded')}`)
21+
},
22+
downloadFiles(list) {
23+
list.forEach((e) => {
24+
downloadFile(e.path)
25+
})
26+
this.showNotif('All Done')
27+
},
28+
zipFiles(list) {
29+
let zip = new JSZip()
30+
let count = 0
31+
32+
let folders = this.folders
33+
let folder_name = folders.length
34+
? folders[folders.length - 1]
35+
: 'media_manager'
36+
37+
list.forEach((e) => {
38+
JSZipUtils.getBinaryContent(e.path, (err, data) => {
39+
if (err) {
40+
console.error(err)
41+
this.showNotif(this.trans('ajax_error'), 'danger')
42+
}
43+
44+
zip.file(e.name, data, {binary:true})
45+
count++
46+
47+
if (count == list.length) {
48+
zip.generateAsync({
49+
type:'blob',
50+
compression: 'DEFLATE',
51+
platform: 'UNIX'
52+
}).then((content) => {
53+
FileSaver.saveAs(content, `${folder_name}.zip`)
54+
this.showNotif(`"${folder_name}.zip" ${this.trans('downloaded')}`)
55+
})
56+
}
57+
})
58+
})
59+
}
60+
}
61+
}

src/resources/assets/js/components/mixins/form.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ export default {
33
/* Main */
44
getFiles(folders = '/', prev_folder = null, prev_file = null) {
55

6-
this.toggleLoading()
76
this.noFiles('hide')
8-
this.loadingFiles('show')
7+
8+
if (!this.loading_files) {
9+
this.toggleLoading()
10+
this.loadingFiles('show')
11+
}
12+
913
this.resetInput(['searchFor', 'sortBy', 'currentFilterName', 'selectedFile', 'currentFileIndex'])
1014

1115
if (folders !== '/') {
@@ -78,9 +82,9 @@ export default {
7882
}
7983

8084
setTimeout(() => {
81-
this.toggleInfo = true
8285
this.toggleLoading()
8386
this.loadingFiles('hide')
87+
this.toggleInfo = true
8488
}, 500)
8589

8690
// scroll to prev selected item

src/resources/assets/js/components/mixins/utils.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require('./../../vendor/download.min')
2-
31
export default {
42
methods: {
53
isLastItem(item, list) {
@@ -153,20 +151,6 @@ export default {
153151
},
154152

155153
/* Ops */
156-
// download
157-
saveFile(item) {
158-
if (this.isBulkSelecting()) {
159-
this.bulkList.forEach((e) => {
160-
downloadFile(e.path)
161-
})
162-
163-
return this.showNotif('All Done')
164-
}
165-
166-
downloadFile(item.path)
167-
return this.showNotif(`"${item.name}" ${this.trans('downloaded')}`)
168-
},
169-
170154
// copy to clipboard
171155
copyLink(path) {
172156
this.linkCopied = true

src/resources/assets/js/components/mixins/watch.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ export default {
6060
})
6161
}
6262
},
63+
uploadStart(val) {
64+
if (val) {
65+
this.toggleUploadPanel()
66+
this.toggleLoading()
67+
this.noFiles('hide')
68+
this.loadingFiles('show')
69+
}
70+
},
6371

6472
// ls
6573
randomNames(val) {

0 commit comments

Comments
 (0)