Skip to content

Commit 17df22a

Browse files
committed
fixes and small changes
1 parent f54eef7 commit 17df22a

21 files changed

+2049
-537
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: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,16 @@ export default {
210210
this.$store.dispatch('fm/toClipboard', type);
211211
212212
// show notification
213-
if(type === 'cut') {
214-
EventBus.$emit('addNotification', {status: 'success', message: 'Cut to clipboard!'});
215-
} else if(type === 'copy') {
216-
EventBus.$emit('addNotification', {status: 'success', message: 'Copied to clipboard!'});
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+
});
217223
}
218224
},
219225

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" v-if="!isRootPath">
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/mixins/manager.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ export default {
5151
},
5252

5353
/**
54-
* Check if current path is at root level
55-
*/
54+
* Check if current path is at root level
55+
* @return {boolean}
56+
*/
5657
isRootPath() {
5758
return this.$store.state.fm[this.manager].selectedDirectory === null;
58-
}
59+
},
5960
},
6061
methods: {
6162
/**
@@ -149,6 +150,10 @@ export default {
149150
this.$store.dispatch('fm/url', {
150151
disk: this.selectedDisk,
151152
path,
153+
}).then((response) => {
154+
if (response.data.result.status === 'success') {
155+
this.$store.state.fm.fileCallback(response.data.url);
156+
}
152157
});
153158

154159
return;

src/components/modals/views/Preview.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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,13 +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+
*/
100108
setImgUrl() {
101-
this.imgUrl = `${this.$store.getters['fm/settings/baseUrl']}preview?disk=${this.selectedDisk}&path=${encodeURIComponent(this.selectedItem.path)}&v=${this.selectedItem.timestamp}`;
109+
this.imgUrl = `${this.$store.getters['fm/settings/baseUrl']}preview?disk=${this.selectedDisk}&path=${encodeURIComponent(this.selectedItem.path)}&v=${this.selectedItem.timestamp}`;
102110
},
103-
closeCropper() {
111+
112+
/**
113+
* Close cropper
114+
*/
115+
closeCropper() {
104116
this.showCropperModule = false;
105117
this.setImgUrl();
106-
},
118+
},
107119
},
108120
};
109121
</script>

0 commit comments

Comments
 (0)