Skip to content

Commit 73fad58

Browse files
committed
Merge branch 'release/v2.2.3'
2 parents 96020be + 17df22a commit 73fad58

22 files changed

+2078
-532
lines changed

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
VUE_APP_AXIOS_BASE_URL=
1+
VUE_APP_LFM_AXIOS_BASE_URL=
2+
VUE_APP_LFM_CSRF_TOKEN=

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,17 @@ Vue.use(FileManager, {
5656
store, // required
5757
5858
// not required params
59-
headers: {'Authorization': 'Bearer ...'}, // add header
60-
// OR
61-
headers: {'X-CSRF-TOKEN': 'token'}, // overwrite default header Axios
59+
60+
headers: {
61+
'X-Requested-With': 'XMLHttpRequest',
62+
'Authorization': 'Bearer ...'
63+
},
64+
// default headers example
65+
headers: {
66+
'X-Requested-With': 'XMLHttpRequest',
67+
'X-CSRF-TOKEN': 'set laravel csrf token here...'
68+
},
69+
6270
baseUrl: 'http://my_url:80/file-manager/', // overwrite base url Axios
6371
windowsConfig: 2,
6472
lang: 'de', // set language
@@ -73,12 +81,6 @@ Vue.use(FileManager, {
7381
}
7482
```
7583

76-
In development mode you can change base url for application - add this param in your laravel .env file
77-
78-
```
79-
MIX_LFM_BASE_URL=http://my-url.loc/file-manager/
80-
```
81-
8284
Now vue component is registered and you can use it in your app
8385
```
8486
<file-manager></file-manager>
@@ -93,4 +95,14 @@ Don't forget add a csrf token to head block in your Laravel view and add bootstr
9395
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
9496
```
9597

98+
You can use [environment variables](https://laravel.com/docs/mix#environment-variables)
99+
100+
```
101+
// set baseUrl
102+
MIX_LFM_BASE_URL=http://my-url.loc/file-manager/
103+
104+
// if you don't want to use csrf-token - you can off it
105+
MIX_LFM_CSRF_TOKEN=OFF
106+
```
107+
96108
Warning! Package use axios (Promise) - use babel-polyfill for ie11

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "laravel-file-manager",
3-
"version": "2.2.2",
3+
"version": "2.2.3",
44
"description": "File manager for Laravel",
55
"keywords": [
66
"laravel",

src/FileManager.vue

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
/* eslint-disable import/no-duplicates, no-param-reassign */
3535
import { mapState } from 'vuex';
3636
// Axios
37-
import HTTP from './http/init-axios';
37+
import HTTP from './http/axios';
3838
import EventBus from './eventBus';
3939
// Components
4040
import Navbar from './components/blocks/Navbar.vue';
@@ -67,8 +67,8 @@ export default {
6767
}),
6868
},
6969
created() {
70-
// init base url
71-
this.$store.commit('fm/settings/initBaseUrl');
70+
// initiate Axios settings - baseUrl and headers
71+
this.$store.commit('fm/settings/initAxiosSettings');
7272
7373
// add axios request interceptor
7474
this.requestInterceptor();
@@ -98,17 +98,10 @@ export default {
9898
requestInterceptor() {
9999
HTTP.interceptors.request.use((config) => {
100100
// overwrite base url
101-
if (this.$store.getters['fm/settings/baseUrl'] !== config.baseURL) {
102-
config.baseURL = this.$store.getters['fm/settings/baseUrl'];
103-
}
101+
config.baseURL = this.$store.getters['fm/settings/baseUrl'];
104102
105103
// overwrite headers
106-
const newHeaders = this.$store.state.fm.settings.headers;
107-
108-
if (newHeaders) {
109-
Object.keys(newHeaders)
110-
.forEach((key) => { config.headers[key] = newHeaders[key]; });
111-
}
104+
config.headers = this.$store.getters['fm/settings/headers'];
112105
113106
// loading spinner +
114107
this.$store.commit('fm/messages/addLoading');

src/components/blocks/Navbar.vue

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,30 @@
3636
disabled
3737
v-if="uploading"
3838
v-bind:title="lang.btn.upload">
39-
<i class="fas fa-download"></i>
39+
<i class="fas fa-upload"></i>
4040
</button>
4141
<button type="button" class="btn btn-secondary"
4242
v-else
4343
v-on:click="showModal('Upload')"
4444
v-bind:title="lang.btn.upload">
45-
<i class="fas fa-download"></i>
45+
<i class="fas fa-upload"></i>
4646
</button>
4747
<button type="button" class="btn btn-secondary"
48+
v-bind:disabled="!isAnyItemSelected"
4849
v-on:click="showModal('Delete')"
4950
v-bind:title="lang.btn.delete">
5051
<i class="fas fa-trash-alt"></i>
5152
</button>
5253
</div>
5354
<div class="btn-group" role="group">
5455
<button type="button" class="btn btn-secondary"
56+
v-bind:disabled="!isAnyItemSelected"
5557
v-bind:title="lang.btn.copy"
5658
v-on:click="toClipboard('copy')">
5759
<i class="fas fa-copy"></i>
5860
</button>
5961
<button type="button" class="btn btn-secondary"
62+
v-bind:disabled="!isAnyItemSelected"
6063
v-bind:title="lang.btn.cut"
6164
v-on:click="toClipboard('cut')">
6265
<i class="fas fa-cut"></i>
@@ -106,6 +109,7 @@
106109

107110
<script>
108111
import translate from './../../mixins/translate';
112+
import EventBus from './../../eventBus';
109113
110114
export default {
111115
mixins: [translate],
@@ -135,6 +139,15 @@ export default {
135139
this.$store.state.fm[this.activeManager].history.length - 1;
136140
},
137141
142+
/**
143+
* Is any files or directories selected?
144+
* @returns {boolean}
145+
*/
146+
isAnyItemSelected() {
147+
return this.$store.state.fm[this.activeManager].selected.files.length > 0 ||
148+
this.$store.state.fm[this.activeManager].selected.directories.length > 0;
149+
},
150+
138151
/**
139152
* Manager view type - grid or table
140153
* @returns {default.computed.viewType|(function())|string}
@@ -195,6 +208,19 @@ export default {
195208
*/
196209
toClipboard(type) {
197210
this.$store.dispatch('fm/toClipboard', type);
211+
212+
// show notification
213+
if (type === 'cut') {
214+
EventBus.$emit('addNotification', {
215+
status: 'success',
216+
message: this.lang.notifications.cutToClipboard,
217+
});
218+
} else if (type === 'copy') {
219+
EventBus.$emit('addNotification', {
220+
status: 'success',
221+
message: this.lang.notifications.copyToClipboard,
222+
});
223+
}
198224
},
199225
200226
/**

src/components/manager/GridView.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="fm-grid">
33
<div class="d-flex align-content-start flex-wrap">
4-
<div class="fm-grid-item text-center" v-on:click="levelUp">
4+
<div v-if="!isRootPath" v-on:click="levelUp" class="fm-grid-item text-center" >
55
<div class="fm-item-icon">
66
<i class="fas fa-level-up-alt fa-5x pb-2"></i>
77
</div>
@@ -38,7 +38,7 @@
3838
<template v-else-if="thisImage(file.extension)">
3939
<img class="img-thumbnail"
4040
v-bind:alt="file.filename"
41-
v-bind:src="createImgUrl(file.path)">
41+
v-bind:src="createImgUrl(file.path, file.timestamp)">
4242
</template>
4343
<template v-else>
4444
<i class="far fa-5x pb-2"
@@ -105,10 +105,11 @@ export default {
105105
/**
106106
* Create url for image
107107
* @param path
108+
* @param timestamp
108109
* @returns {string}
109110
*/
110-
createImgUrl(path) {
111-
return `${this.$store.getters['fm/settings/baseUrl']}thumbnails?disk=${this.disk}&path=${path}`;
111+
createImgUrl(path, timestamp) {
112+
return `${this.$store.getters['fm/settings/baseUrl']}thumbnails?disk=${this.disk}&path=${path}&v=${timestamp}`;
112113
},
113114
},
114115
};

src/components/manager/TableView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</tr>
4343
</thead>
4444
<tbody>
45-
<tr>
45+
<tr v-if="!isRootPath">
4646
<td colspan="4" class="fm-content-item" v-on:click="levelUp">
4747
<i class="fas fa-level-up-alt"></i>
4848
</td>

src/components/manager/mixins/manager.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ export default {
4949
acl() {
5050
return this.$store.state.fm.settings.acl;
5151
},
52+
53+
/**
54+
* Check if current path is at root level
55+
* @return {boolean}
56+
*/
57+
isRootPath() {
58+
return this.$store.state.fm[this.manager].selectedDirectory === null;
59+
},
5260
},
5361
methods: {
5462
/**
@@ -142,6 +150,10 @@ export default {
142150
this.$store.dispatch('fm/url', {
143151
disk: this.selectedDisk,
144152
path,
153+
}).then((response) => {
154+
if (response.data.result.status === 'success') {
155+
this.$store.state.fm.fileCallback(response.data.url);
156+
}
145157
});
146158

147159
return;

src/components/modals/views/Preview.vue

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<template v-if="showCropperModule">
1414
<cropper-module v-bind:imgUrl="imgUrl"
1515
v-bind:maxHeight="maxHeight"
16-
v-on:closeCropper="showCropperModule = false"></cropper-module>
16+
v-on:closeCropper="closeCropper"></cropper-module>
1717
</template>
1818
<template v-else>
1919
<img v-bind:src="imgUrl"
@@ -53,7 +53,7 @@ export default {
5353
},
5454
created() {
5555
// Create image URL
56-
this.imgUrl = `${this.$store.getters['fm/settings/baseUrl']}preview?disk=${this.selectedDisk}&path=${encodeURIComponent(this.selectedItem.path)}`;
56+
this.setImgUrl();
5757
},
5858
computed: {
5959
/**
@@ -72,6 +72,10 @@ export default {
7272
return this.$store.getters['fm/selectedItems'][0];
7373
},
7474
75+
/**
76+
* Show modal footer
77+
* @return boolean
78+
*/
7579
showFooter() {
7680
return this.canCrop(this.selectedItem.extension) && !this.showCropperModule;
7781
},
@@ -97,6 +101,21 @@ export default {
97101
canCrop(extension) {
98102
return this.$store.state.fm.settings.cropExtensions.includes(extension.toLowerCase());
99103
},
104+
105+
/**
106+
* Set image URL
107+
*/
108+
setImgUrl() {
109+
this.imgUrl = `${this.$store.getters['fm/settings/baseUrl']}preview?disk=${this.selectedDisk}&path=${encodeURIComponent(this.selectedItem.path)}&v=${this.selectedItem.timestamp}`;
110+
},
111+
112+
/**
113+
* Close cropper
114+
*/
115+
closeCropper() {
116+
this.showCropperModule = false;
117+
this.setImgUrl();
118+
},
100119
},
101120
};
102121
</script>

0 commit comments

Comments
 (0)