mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-13 08:45:01 +00:00
Merge branch 'upload-limit'
# Conflicts: # app/Http/Helpers/helpers.php # config/vuefilemanager.php # public/chunks/app-others.js # public/chunks/files~chunks/shared-files~chunks/shared-page~chunks/trash.js # public/js/main.js # public/mix-manifest.json # resources/js/components/FilesView/FileItemList.vue # resources/js/components/FilesView/FilePreview.vue # resources/js/helpers.js # resources/js/store/modules/fileFunctions.js
This commit is contained in:
@@ -355,6 +355,25 @@ function format_gigabytes($gigabytes)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format string to formated megabytes string
|
||||||
|
*
|
||||||
|
* @param $megabytes
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function format_megabytes($megabytes)
|
||||||
|
{
|
||||||
|
if ($megabytes >= 1000) {
|
||||||
|
return $megabytes / 1000 . 'GB';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($megabytes >= 1000000) {
|
||||||
|
return $megabytes / 1000000 . 'TB';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $megabytes . 'MB';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert megabytes to bytes
|
* Convert megabytes to bytes
|
||||||
*
|
*
|
||||||
@@ -495,6 +514,7 @@ function get_file_type($file_mimetype)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get file type from mimetype
|
* Get file type from mimetype
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -328,8 +328,20 @@ class Editor
|
|||||||
$disk_file_name = basename('chunks/' . $file->getClientOriginalName(), '.part');
|
$disk_file_name = basename('chunks/' . $file->getClientOriginalName(), '.part');
|
||||||
$temp_filename = $file->getClientOriginalName();
|
$temp_filename = $file->getClientOriginalName();
|
||||||
|
|
||||||
|
// File Path
|
||||||
|
$file_path = config('filesystems.disks.local.root') . '/chunks/' . $temp_filename;\
|
||||||
|
|
||||||
// Generate file
|
// Generate file
|
||||||
File::append(config('filesystems.disks.local.root') . '/chunks/' . $temp_filename, $file->get());
|
File::append($file_path, $file->get());
|
||||||
|
|
||||||
|
// Size of file
|
||||||
|
$file_size = File::size($file_path);
|
||||||
|
|
||||||
|
// Size of limit
|
||||||
|
$limit = get_setting('upload_limit');
|
||||||
|
|
||||||
|
// File size handling
|
||||||
|
if( $limit && $file_size > format_bytes($limit)) abort(413);
|
||||||
|
|
||||||
// If last then process file
|
// If last then process file
|
||||||
if ($request->boolean('is_last')) {
|
if ($request->boolean('is_last')) {
|
||||||
|
|||||||
@@ -15,15 +15,15 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--If is file or image, then link item-->
|
<!--If is file or image, then link item-->
|
||||||
<span v-if="isFile" class="file-icon-text">
|
<span v-if="isFile || (isImage && !data.thumbnail)" class="file-icon-text">
|
||||||
{{ data.mimetype }}
|
{{ data.mimetype }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<!--Folder thumbnail-->
|
<!--Folder thumbnail-->
|
||||||
<FontAwesomeIcon v-if="isFile" class="file-icon" icon="file"/>
|
<FontAwesomeIcon v-if="isFile || (isImage && !data.thumbnail)" class="file-icon" icon="file"/>
|
||||||
|
|
||||||
<!--Image thumbnail-->
|
<!--Image thumbnail-->
|
||||||
<img loading="lazy" v-if="isImage" class="image" :src="data.thumbnail" :alt="data.name"/>
|
<img loading="lazy" v-if="isImage && data.thumbnail" class="image" :src="data.thumbnail" :alt="data.name"/>
|
||||||
|
|
||||||
<!--Else show only folder icon-->
|
<!--Else show only folder icon-->
|
||||||
<FontAwesomeIcon v-if="isFolder" :class="{'is-deleted': isDeleted}" class="folder-icon" icon="folder"/>
|
<FontAwesomeIcon v-if="isFolder" :class="{'is-deleted': isDeleted}" class="folder-icon" icon="folder"/>
|
||||||
|
|||||||
@@ -16,15 +16,15 @@
|
|||||||
<!--Thumbnail for item-->
|
<!--Thumbnail for item-->
|
||||||
<div class="icon-item">
|
<div class="icon-item">
|
||||||
<!--If is file or image, then link item-->
|
<!--If is file or image, then link item-->
|
||||||
<span v-if="isFile" class="file-icon-text">
|
<span v-if="isFile || (isImage && !data.thumbnail)" class="file-icon-text">
|
||||||
{{ data.mimetype | limitCharacters }}
|
{{ data.mimetype | limitCharacters }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<!--Folder thumbnail-->
|
<!--Folder thumbnail-->
|
||||||
<FontAwesomeIcon v-if="isFile" class="file-icon" icon="file"/>
|
<FontAwesomeIcon v-if="isFile || (isImage && !data.thumbnail)" class="file-icon" icon="file"/>
|
||||||
|
|
||||||
<!--Image thumbnail-->
|
<!--Image thumbnail-->
|
||||||
<img loading="lazy" v-if="isImage" class="image" :src="data.thumbnail" :alt="data.name"/>
|
<img loading="lazy" v-if="isImage && data.thumbnail" class="image" :src="data.thumbnail" :alt="data.name"/>
|
||||||
|
|
||||||
<!--Else show only folder icon-->
|
<!--Else show only folder icon-->
|
||||||
<FontAwesomeIcon v-if="isFolder" :class="{ 'is-deleted': isDeleted }" class="folder-icon" icon="folder"/>
|
<FontAwesomeIcon v-if="isFolder" :class="{ 'is-deleted': isDeleted }" class="folder-icon" icon="folder"/>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="canBePreview" class="preview">
|
<div v-if="canBePreview" class="preview">
|
||||||
<img v-if="fileInfoDetail[0].type == 'image'" :src="fileInfoDetail[0].thumbnail" :alt="fileInfoDetail[0].name" />
|
<img v-if="fileInfoDetail[0].type == 'image' && fileInfoDetail[0].thumbnail" :src="fileInfoDetail[0].thumbnail" :alt="fileInfoDetail[0].name" />
|
||||||
<audio v-else-if="fileInfoDetail[0].type == 'audio'" :src="fileInfoDetail[0].file_url" controlsList="nodownload" controls></audio>
|
<audio v-else-if="fileInfoDetail[0].type == 'audio'" :src="fileInfoDetail[0].file_url" controlsList="nodownload" controls></audio>
|
||||||
<video v-else-if="fileInfoDetail[0].type == 'video'" controlsList="nodownload" disablePictureInPicture playsinline controls>
|
<video v-else-if="fileInfoDetail[0].type == 'video'" controlsList="nodownload" disablePictureInPicture playsinline controls>
|
||||||
<source :src="fileInfoDetail[0].file_url" type="video/mp4">
|
<source :src="fileInfoDetail[0].file_url" type="video/mp4">
|
||||||
|
|||||||
Vendored
+233
-210
@@ -1,275 +1,279 @@
|
|||||||
import i18n from '@/i18n/index'
|
import i18n from '@/i18n/index'
|
||||||
import store from './store/index'
|
import store from './store/index'
|
||||||
import { debounce, includes } from 'lodash'
|
import {debounce, includes} from "lodash";
|
||||||
import { events } from './bus'
|
import {events} from './bus'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
|
|
||||||
const Helpers = {
|
const Helpers = {
|
||||||
install(Vue) {
|
install(Vue) {
|
||||||
|
|
||||||
Vue.prototype.$updateText = debounce(function(route, name, value) {
|
Vue.prototype.$updateText = debounce(function (route, name, value) {
|
||||||
|
|
||||||
let enableEmptyInput = ['mimetypes_blacklist', 'google_analytics']
|
let enableEmptyInput = ['mimetypes_blacklist' , 'google_analytics' , 'upload_limit']
|
||||||
|
|
||||||
if (value === '' && !enableEmptyInput.includes(name)) return
|
if (value === '' && !enableEmptyInput.includes(name)) return
|
||||||
|
|
||||||
axios.post(this.$store.getters.api + route, { name, value, _method: 'patch' })
|
|
||||||
.catch(error => {
|
|
||||||
events.$emit('alert:open', {
|
|
||||||
title: this.$t('popup_error.title'),
|
|
||||||
message: this.$t('popup_error.message')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}, 150)
|
|
||||||
|
|
||||||
Vue.prototype.$updateImage = function(route, name, image) {
|
|
||||||
|
|
||||||
// Create form
|
|
||||||
let formData = new FormData()
|
|
||||||
|
|
||||||
// Add image to form
|
|
||||||
formData.append('name', name)
|
|
||||||
formData.append(name, image)
|
|
||||||
formData.append('_method', 'PATCH')
|
|
||||||
|
|
||||||
axios.post(this.$store.getters.api + route, formData, {
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'multipart/form-data'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
events.$emit('alert:open', {
|
|
||||||
title: this.$t('popup_error.title'),
|
|
||||||
message: this.$t('popup_error.message')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$scrollTop = function() {
|
|
||||||
var container = document.getElementById('vue-file-manager')
|
|
||||||
|
|
||||||
if (container) {
|
|
||||||
container.scrollTop = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$getImage = function(source) {
|
|
||||||
return source ? this.$store.getters.config.host + '/' + source : ''
|
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$getCreditCardBrand = function(brand) {
|
|
||||||
return `/assets/icons/${brand}.svg`
|
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$getInvoiceLink = function(customer, id) {
|
|
||||||
return '/invoice/' + customer + '/' + id
|
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$openImageOnNewTab = function(source) {
|
|
||||||
let win = window.open(source, '_blank')
|
|
||||||
|
|
||||||
win.focus()
|
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$handleUploading = async function(files, parent_id) {
|
|
||||||
|
|
||||||
let fileBuffer = []
|
|
||||||
|
|
||||||
// Append the file list to fileBuffer array
|
axios.post(this.$store.getters.api + route, {name, value, _method: 'patch'})
|
||||||
Array.prototype.push.apply(fileBuffer, files)
|
.catch(error => {
|
||||||
|
events.$emit('alert:open', {
|
||||||
|
title: this.$t('popup_error.title'),
|
||||||
|
message: this.$t('popup_error.message'),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}, 150)
|
||||||
|
|
||||||
|
Vue.prototype.$updateImage = function (route, name, image) {
|
||||||
|
|
||||||
|
// Create form
|
||||||
|
let formData = new FormData()
|
||||||
|
|
||||||
|
// Add image to form
|
||||||
|
formData.append('name', name)
|
||||||
|
formData.append(name, image)
|
||||||
|
formData.append('_method', 'PATCH')
|
||||||
|
|
||||||
|
axios.post(this.$store.getters.api + route, formData, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
events.$emit('alert:open', {
|
||||||
|
title: this.$t('popup_error.title'),
|
||||||
|
message: this.$t('popup_error.message'),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
Vue.prototype.$scrollTop = function () {
|
||||||
|
var container = document.getElementById('vue-file-manager')
|
||||||
|
|
||||||
|
if (container) {
|
||||||
|
container.scrollTop = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Vue.prototype.$getImage = function (source) {
|
||||||
|
return source ? this.$store.getters.config.host + '/' + source : ''
|
||||||
|
}
|
||||||
|
|
||||||
|
Vue.prototype.$getCreditCardBrand = function (brand) {
|
||||||
|
return `/assets/icons/${brand}.svg`
|
||||||
|
}
|
||||||
|
|
||||||
|
Vue.prototype.$getInvoiceLink = function (customer, id) {
|
||||||
|
return '/invoice/' + customer + '/' + id
|
||||||
|
}
|
||||||
|
|
||||||
|
Vue.prototype.$openImageOnNewTab = function (source) {
|
||||||
|
let win = window.open(source, '_blank')
|
||||||
|
|
||||||
|
win.focus()
|
||||||
|
}
|
||||||
|
|
||||||
|
Vue.prototype.$createFolder = function (folderName) {
|
||||||
|
this.$store.dispatch('createFolder', folderName)
|
||||||
|
}
|
||||||
|
|
||||||
|
Vue.prototype.$handleUploading = async function (files, parent_id) {
|
||||||
|
|
||||||
|
let fileBuffer = []
|
||||||
|
|
||||||
let fileSucceed = 0
|
// Append the file list to fileBuffer array
|
||||||
|
Array.prototype.push.apply(fileBuffer, files);
|
||||||
|
|
||||||
// Update files count in progressbar
|
let fileSucceed = 0
|
||||||
store.commit('UPDATE_FILE_COUNT_PROGRESS', {
|
|
||||||
current: fileSucceed,
|
|
||||||
total: files.length
|
|
||||||
})
|
|
||||||
|
|
||||||
// Reset upload progress to 0
|
// Update files count in progressbar
|
||||||
store.commit('UPLOADING_FILE_PROGRESS', 0)
|
store.commit('UPDATE_FILE_COUNT_PROGRESS', {
|
||||||
|
current: fileSucceed,
|
||||||
|
total: files.length
|
||||||
|
})
|
||||||
|
|
||||||
// Get parent id
|
// Reset upload progress to 0
|
||||||
let parentFolder = this.$store.getters.currentFolder ? this.$store.getters.currentFolder.unique_id : 0
|
store.commit('UPLOADING_FILE_PROGRESS', 0)
|
||||||
let rootFolder = parent_id ? parent_id : parentFolder
|
|
||||||
|
|
||||||
// Upload files
|
// Get parent id
|
||||||
do {
|
let parentFolder = this.$store.getters.currentFolder ? this.$store.getters.currentFolder.unique_id : 0
|
||||||
let file = fileBuffer.shift(),
|
let rootFolder = parent_id ? parent_id : parentFolder
|
||||||
chunks = []
|
|
||||||
|
|
||||||
// Calculate ceils
|
// Upload files
|
||||||
let size = this.$store.getters.config.chunkSize,
|
do {
|
||||||
chunksCeil = Math.ceil(file.size / size)
|
let file = fileBuffer.shift(),
|
||||||
|
chunks = []
|
||||||
|
|
||||||
// Create chunks
|
// Calculate ceils
|
||||||
for (let i = 0; i < chunksCeil; i++) {
|
let size = this.$store.getters.config.chunkSize,
|
||||||
chunks.push(file.slice(
|
chunksCeil = Math.ceil(file.size / size);
|
||||||
i * size, Math.min(i * size + size, file.size), file.type
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set Data
|
// Create chunks
|
||||||
let formData = new FormData(),
|
for (let i = 0; i < chunksCeil; i++) {
|
||||||
uploadedSize = 0,
|
chunks.push(file.slice(
|
||||||
isNotGeneralError = true,
|
i * size, Math.min(i * size + size, file.size), file.type
|
||||||
striped_name = file.name.replace(/[^A-Za-z 0-9 \.,\?""!@#\$%\^&\*\(\)-_=\+;:<>\/\\\|\}\{\[\]`~]*/g, ''),
|
));
|
||||||
filename = Array(16).fill(0).map(x => Math.random().toString(36).charAt(2)).join('') + '-' + striped_name + '.part'
|
}
|
||||||
|
|
||||||
do {
|
// Set Data
|
||||||
let isLast = chunks.length === 1,
|
let formData = new FormData(),
|
||||||
chunk = chunks.shift(),
|
uploadedSize = 0,
|
||||||
attempts = 0
|
isNotGeneralError = true,
|
||||||
|
striped_name = file.name.replace(/[^A-Za-z 0-9 \.,\?""!@#\$%\^&\*\(\)-_=\+;:<>\/\\\|\}\{\[\]`~]*/g, ''),
|
||||||
|
filename = Array(16).fill(0).map(x => Math.random().toString(36).charAt(2)).join('') + '-' + striped_name + '.part'
|
||||||
|
|
||||||
// Set form data
|
do {
|
||||||
formData.set('file', chunk, filename)
|
let isLast = chunks.length === 1,
|
||||||
formData.set('parent_id', rootFolder)
|
chunk = chunks.shift(),
|
||||||
formData.set('is_last', isLast)
|
attempts = 0
|
||||||
|
|
||||||
// Upload chunks
|
// Set form data
|
||||||
do {
|
formData.set('file', chunk, filename);
|
||||||
await store.dispatch('uploadFiles', {
|
formData.set('parent_id', rootFolder)
|
||||||
form: formData,
|
formData.set('is_last', isLast);
|
||||||
fileSize: file.size,
|
|
||||||
totalUploadedSize: uploadedSize
|
|
||||||
}).then(() => {
|
|
||||||
uploadedSize = uploadedSize + chunk.size
|
|
||||||
}).catch((error) => {
|
|
||||||
|
|
||||||
// Count attempts
|
// Upload chunks
|
||||||
attempts++
|
do {
|
||||||
|
await store.dispatch('uploadFiles', {
|
||||||
|
form: formData,
|
||||||
|
fileSize: file.size,
|
||||||
|
totalUploadedSize: uploadedSize
|
||||||
|
}).then(() => {
|
||||||
|
uploadedSize = uploadedSize + chunk.size
|
||||||
|
}).catch((error) => {
|
||||||
|
|
||||||
// Break uploading proccess
|
// Count attempts
|
||||||
if (error.response.status === 500)
|
attempts++
|
||||||
isNotGeneralError = false
|
|
||||||
|
|
||||||
//Break if mimetype of file is in blacklist
|
// Break uploading proccess
|
||||||
if (error.response.status === 415)
|
if (error.response.status === 500)
|
||||||
isNotGeneralError = false
|
isNotGeneralError = false
|
||||||
|
|
||||||
// Show Error
|
//Break if mimetype of file is in blacklist
|
||||||
if (attempts === 3)
|
if(error.response.status === 415)
|
||||||
this.$isSomethingWrong()
|
isNotGeneralError = false
|
||||||
})
|
|
||||||
} while (isNotGeneralError && attempts !== 0 && attempts !== 3)
|
|
||||||
|
|
||||||
} while (isNotGeneralError && chunks.length !== 0)
|
// Show Error
|
||||||
|
if (attempts === 3)
|
||||||
|
this.$isSomethingWrong()
|
||||||
|
})
|
||||||
|
} while (isNotGeneralError && attempts !== 0 && attempts !== 3)
|
||||||
|
|
||||||
fileSucceed++
|
} while (isNotGeneralError && chunks.length !== 0)
|
||||||
|
|
||||||
// Progress file log
|
fileSucceed++
|
||||||
store.commit('UPDATE_FILE_COUNT_PROGRESS', {
|
|
||||||
current: fileSucceed,
|
|
||||||
total: files.length
|
|
||||||
})
|
|
||||||
|
|
||||||
} while (fileBuffer.length !== 0)
|
// Progress file log
|
||||||
|
store.commit('UPDATE_FILE_COUNT_PROGRESS', {
|
||||||
|
current: fileSucceed,
|
||||||
|
total: files.length
|
||||||
|
})
|
||||||
|
|
||||||
store.commit('UPDATE_FILE_COUNT_PROGRESS', undefined)
|
} while (fileBuffer.length !== 0)
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$uploadFiles = async function(files) {
|
store.commit('UPDATE_FILE_COUNT_PROGRESS', undefined)
|
||||||
|
}
|
||||||
|
|
||||||
if (files.length == 0) return
|
Vue.prototype.$uploadFiles = async function (files) {
|
||||||
|
|
||||||
if (!this.$checkFileMimetype(files)) return
|
if (files.length == 0) return
|
||||||
|
|
||||||
this.$handleUploading(files, undefined)
|
if (!this.$checkFileMimetype(files)) return
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$uploadExternalFiles = async function(event, parent_id) {
|
this.$handleUploading(files, undefined)
|
||||||
|
}
|
||||||
|
|
||||||
// Prevent submit empty files
|
Vue.prototype.$uploadExternalFiles = async function (event, parent_id) {
|
||||||
if (event.dataTransfer.items.length == 0) return
|
|
||||||
|
|
||||||
// Get files
|
// Prevent submit empty files
|
||||||
let files = [...event.dataTransfer.items].map(item => item.getAsFile())
|
if (event.dataTransfer.items.length == 0) return
|
||||||
|
|
||||||
this.$handleUploading(files, parent_id)
|
// Get files
|
||||||
}
|
let files = [...event.dataTransfer.items].map(item => item.getAsFile());
|
||||||
|
|
||||||
Vue.prototype.$downloadFile = function(url, filename) {
|
this.$handleUploading(files, parent_id)
|
||||||
var anchor = document.createElement('a')
|
}
|
||||||
|
|
||||||
anchor.href = url
|
Vue.prototype.$downloadFile = function (url, filename) {
|
||||||
|
var anchor = document.createElement('a')
|
||||||
|
|
||||||
anchor.download = filename
|
anchor.href = url
|
||||||
|
|
||||||
document.body.appendChild(anchor)
|
anchor.download = filename
|
||||||
|
|
||||||
anchor.click()
|
document.body.appendChild(anchor)
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$closePopup = function() {
|
anchor.click()
|
||||||
events.$emit('popup:close')
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$isThisRoute = function(route, locations) {
|
Vue.prototype.$closePopup = function () {
|
||||||
|
events.$emit('popup:close')
|
||||||
|
}
|
||||||
|
|
||||||
return includes(locations, route.name)
|
Vue.prototype.$isThisRoute = function (route, locations) {
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$isThisLocation = function(location) {
|
return includes(locations, route.name)
|
||||||
|
}
|
||||||
|
|
||||||
// Get current location
|
Vue.prototype.$isThisLocation = function (location) {
|
||||||
let currentLocation = store.getters.currentFolder && store.getters.currentFolder.location ? store.getters.currentFolder.location : undefined
|
|
||||||
|
|
||||||
// Check if type is object
|
// Get current location
|
||||||
if (typeof location === 'Object' || location instanceof Object) {
|
let currentLocation = store.getters.currentFolder && store.getters.currentFolder.location ? store.getters.currentFolder.location : undefined
|
||||||
return includes(location, currentLocation)
|
|
||||||
|
|
||||||
} else {
|
// Check if type is object
|
||||||
return currentLocation === location
|
if (typeof location === 'Object' || location instanceof Object) {
|
||||||
}
|
return includes(location, currentLocation)
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$checkPermission = function(type) {
|
} else {
|
||||||
|
return currentLocation === location
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let currentPermission = store.getters.permission
|
Vue.prototype.$checkPermission = function (type) {
|
||||||
|
|
||||||
// Check if type is object
|
let currentPermission = store.getters.permission
|
||||||
if (typeof type === 'Object' || type instanceof Object) {
|
|
||||||
return includes(type, currentPermission)
|
|
||||||
|
|
||||||
} else {
|
// Check if type is object
|
||||||
return currentPermission === type
|
if (typeof type === 'Object' || type instanceof Object) {
|
||||||
}
|
return includes(type, currentPermission)
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$isMobile = function() {
|
} else {
|
||||||
const toMatch = [
|
return currentPermission === type
|
||||||
/Android/i,
|
}
|
||||||
/webOS/i,
|
}
|
||||||
/iPhone/i,
|
|
||||||
/iPad/i,
|
|
||||||
/iPod/i,
|
|
||||||
/BlackBerry/i,
|
|
||||||
/Windows Phone/i
|
|
||||||
]
|
|
||||||
|
|
||||||
return toMatch.some(toMatchItem => {
|
Vue.prototype.$isMobile = function () {
|
||||||
return navigator.userAgent.match(toMatchItem)
|
const toMatch = [
|
||||||
})
|
/Android/i,
|
||||||
}
|
/webOS/i,
|
||||||
|
/iPhone/i,
|
||||||
|
/iPad/i,
|
||||||
|
/iPod/i,
|
||||||
|
/BlackBerry/i,
|
||||||
|
/Windows Phone/i
|
||||||
|
]
|
||||||
|
|
||||||
Vue.prototype.$isMinimalScale = function() {
|
return toMatch.some(toMatchItem => {
|
||||||
let sizeType = store.getters.filesViewWidth
|
return navigator.userAgent.match(toMatchItem)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return sizeType === 'minimal-scale'
|
Vue.prototype.$isMinimalScale = function () {
|
||||||
}
|
let sizeType = store.getters.filesViewWidth
|
||||||
|
|
||||||
Vue.prototype.$isCompactScale = function() {
|
return sizeType === 'minimal-scale'
|
||||||
let sizeType = store.getters.filesViewWidth
|
}
|
||||||
|
|
||||||
return sizeType === 'compact-scale'
|
Vue.prototype.$isCompactScale = function () {
|
||||||
}
|
let sizeType = store.getters.filesViewWidth
|
||||||
|
|
||||||
Vue.prototype.$isFullScale = function() {
|
return sizeType === 'compact-scale'
|
||||||
let sizeType = store.getters.filesViewWidth
|
}
|
||||||
|
|
||||||
return sizeType === 'full-scale'
|
Vue.prototype.$isFullScale = function () {
|
||||||
}
|
let sizeType = store.getters.filesViewWidth
|
||||||
|
|
||||||
|
return sizeType === 'full-scale'
|
||||||
|
}
|
||||||
|
|
||||||
Vue.prototype.$isSomethingWrong = function() {
|
Vue.prototype.$isSomethingWrong = function() {
|
||||||
events.$emit('alert:open', {
|
events.$emit('alert:open', {
|
||||||
@@ -300,6 +304,25 @@ const Helpers = {
|
|||||||
}
|
}
|
||||||
return validated
|
return validated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vue.prototype.$checkUploadLimit = function (files) {
|
||||||
|
let uploadLimit = store.getters.config.uploadLimit
|
||||||
|
let validate = true
|
||||||
|
|
||||||
|
for (let i = 0 ; i<files.length; i++ ) {
|
||||||
|
if(uploadLimit != 0 && files[i].size > uploadLimit) {
|
||||||
|
validate = false
|
||||||
|
events.$emit('alert:open', {
|
||||||
|
emoji: '😟😟😟',
|
||||||
|
title: i18n.t('popup_upload_limit.title'),
|
||||||
|
message: i18n.t('popup_upload_limit.message', {uploadLimit: store.getters.config.uploadLimitFormatted}),
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return validate
|
||||||
|
}
|
||||||
|
|
||||||
Vue.prototype.$getDataByLocation = function() {
|
Vue.prototype.$getDataByLocation = function() {
|
||||||
|
|
||||||
let folder = store.getters.currentFolder
|
let folder = store.getters.currentFolder
|
||||||
|
|||||||
@@ -211,6 +211,9 @@
|
|||||||
"username_plac": "输入您的邮件用户名"
|
"username_plac": "输入您的邮件用户名"
|
||||||
},
|
},
|
||||||
"others": {
|
"others": {
|
||||||
|
"upload_limit": "Upload Limit",
|
||||||
|
"upload_limit_plac": "Type your upload limit in MB",
|
||||||
|
"upload_limit_help": "If you want to set max file size limit on single upload, add size of your limit in MB. E.g. 100 means 100 MB and 2 000 means 2 000 MB limit.",
|
||||||
"mimetypes_blacklist": "Mimetypes Blacklist",
|
"mimetypes_blacklist": "Mimetypes Blacklist",
|
||||||
"mimetypes_blacklist_plac":"Add mimetypes to Blacklist" ,
|
"mimetypes_blacklist_plac":"Add mimetypes to Blacklist" ,
|
||||||
"mimetypes_blacklist_help" :"If you want to prevent upload some type of files, just add them to blacklist like this: x-php,mp3,jpeg <br/> Use a comma between each mimetype. Don't use a dot before mimetypes." ,
|
"mimetypes_blacklist_help" :"If you want to prevent upload some type of files, just add them to blacklist like this: x-php,mp3,jpeg <br/> Use a comma between each mimetype. Don't use a dot before mimetypes." ,
|
||||||
@@ -518,8 +521,12 @@
|
|||||||
},
|
},
|
||||||
"title": "选择付款方式"
|
"title": "选择付款方式"
|
||||||
},
|
},
|
||||||
|
"popup_upload_limit": {
|
||||||
|
"title": "You exceed upload limit on single file",
|
||||||
|
"message": "Size of your uploaded file exceed the upload limit ({uploadLimit})."
|
||||||
|
},
|
||||||
"popup_mimetypes_blacklist": {
|
"popup_mimetypes_blacklist": {
|
||||||
"title": "Oh no",
|
"title": "You are trying to upload unsupported file type",
|
||||||
"message": "File of this type ({mimetype}) is not allowed to upload."
|
"message": "File of this type ({mimetype}) is not allowed to upload."
|
||||||
},
|
},
|
||||||
"popup_zipping": {
|
"popup_zipping": {
|
||||||
|
|||||||
@@ -213,6 +213,9 @@
|
|||||||
"username_plac": "Type your mail username"
|
"username_plac": "Type your mail username"
|
||||||
},
|
},
|
||||||
"others": {
|
"others": {
|
||||||
|
"upload_limit": "Upload Limit",
|
||||||
|
"upload_limit_plac": "Type your upload limit in MB",
|
||||||
|
"upload_limit_help": "If you want to set max file size limit on single upload, add size of your limit in MB. E.g. 100 means 100 MB and 2 000 means 2 000 MB limit.",
|
||||||
"mimetypes_blacklist": "Mimetypes Blacklist",
|
"mimetypes_blacklist": "Mimetypes Blacklist",
|
||||||
"mimetypes_blacklist_plac":"Add mimetypes to Blacklist" ,
|
"mimetypes_blacklist_plac":"Add mimetypes to Blacklist" ,
|
||||||
"mimetypes_blacklist_help" :"If you want to prevent upload some type of files, just add them to blacklist like this: x-php,mp3,jpeg <br/> Use a comma between each mimetype. Don't use a dot before mimetypes." ,
|
"mimetypes_blacklist_help" :"If you want to prevent upload some type of files, just add them to blacklist like this: x-php,mp3,jpeg <br/> Use a comma between each mimetype. Don't use a dot before mimetypes." ,
|
||||||
@@ -520,8 +523,12 @@
|
|||||||
},
|
},
|
||||||
"title": "Choose Payment Method"
|
"title": "Choose Payment Method"
|
||||||
},
|
},
|
||||||
|
"popup_upload_limit": {
|
||||||
|
"title": "You exceed upload limit on single file",
|
||||||
|
"message": "Size of your uploaded file exceed the upload limit ({uploadLimit})."
|
||||||
|
},
|
||||||
"popup_mimetypes_blacklist": {
|
"popup_mimetypes_blacklist": {
|
||||||
"title": "Oh No",
|
"title": "You are trying to upload unsupported file type",
|
||||||
"message": "File of this type ({mimetype}) is not allowed to upload."
|
"message": "File of this type ({mimetype}) is not allowed to upload."
|
||||||
},
|
},
|
||||||
"popup_delete_card": {
|
"popup_delete_card": {
|
||||||
|
|||||||
@@ -213,6 +213,9 @@
|
|||||||
"username_plac": "Zadajte svoje používateľské meno pre poštu"
|
"username_plac": "Zadajte svoje používateľské meno pre poštu"
|
||||||
},
|
},
|
||||||
"others": {
|
"others": {
|
||||||
|
"upload_limit": "Limit nahrávania",
|
||||||
|
"upload_limit_plac": "Pridajte veľkosť limitu v MB",
|
||||||
|
"upload_limit_help": "Ak chcete nastaviť limit pre nahrávane jedneho súboru, pridajte veľkosť vášho limitu v MB.",
|
||||||
"mimetypes_blacklist": "Čierna listina mimetypov",
|
"mimetypes_blacklist": "Čierna listina mimetypov",
|
||||||
"mimetypes_blacklist_plac":"Pridajte mimetypy do Čiernej listiny",
|
"mimetypes_blacklist_plac":"Pridajte mimetypy do Čiernej listiny",
|
||||||
"mimetypes_blacklist_help" :"Ak chcete zakázať nahrávanie niektorých typov súborov, jednoducho ich pridajte na čiernu listinu, príklad: x-php, mp3, jpeg <br/> Medzi mimetypmi použite čiarku. Nevkladajte bodku pred mimetyp." ,
|
"mimetypes_blacklist_help" :"Ak chcete zakázať nahrávanie niektorých typov súborov, jednoducho ich pridajte na čiernu listinu, príklad: x-php, mp3, jpeg <br/> Medzi mimetypmi použite čiarku. Nevkladajte bodku pred mimetyp." ,
|
||||||
@@ -520,8 +523,12 @@
|
|||||||
},
|
},
|
||||||
"title": "Vyberte si metódu platby"
|
"title": "Vyberte si metódu platby"
|
||||||
},
|
},
|
||||||
|
"popup_upload_limit": {
|
||||||
|
"title": "Je nám to ľúto",
|
||||||
|
"message": "Veľkosť nahravaného súboru prekročila limit pre nahraávane súbory ({uploadLimit})"
|
||||||
|
},
|
||||||
"popup_mimetypes_blacklist": {
|
"popup_mimetypes_blacklist": {
|
||||||
"title": "Ospravelnujume sa",
|
"title": "Ospravedlňujeme sa",
|
||||||
"message": "Nieje povolené nahrávať tento typ súboru ({mimetype})."
|
"message": "Nieje povolené nahrávať tento typ súboru ({mimetype})."
|
||||||
},
|
},
|
||||||
"popup_zipping": {
|
"popup_zipping": {
|
||||||
|
|||||||
@@ -89,6 +89,15 @@
|
|||||||
<small class="input-help" v-html="$t('admin_settings.others.mimetypes_blacklist_help')"></small>
|
<small class="input-help" v-html="$t('admin_settings.others.mimetypes_blacklist_help')"></small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="block-wrapper">
|
||||||
|
<label>{{ $t('admin_settings.others.upload_limit') }}:</label>
|
||||||
|
<ValidationProvider tag="div" mode="passive" class="input-wrapper" name="Upload Limit" v-slot="{ errors }">
|
||||||
|
<input @input="$updateText('/settings', 'upload_limit', app.uploadLimit)" v-model="app.uploadLimit" :placeholder="$t('admin_settings.others.upload_limit_plac')" type="number" min="0" step="1" :class="{'is-error': errors[0]}"/>
|
||||||
|
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
|
||||||
|
</ValidationProvider>
|
||||||
|
<small class="input-help" v-html="$t('admin_settings.others.upload_limit_help')"></small>
|
||||||
|
</div>
|
||||||
|
|
||||||
<FormLabel class="mt-70">
|
<FormLabel class="mt-70">
|
||||||
{{ $t('admin_settings.others.section_cache') }}
|
{{ $t('admin_settings.others.section_cache') }}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
@@ -163,7 +172,7 @@
|
|||||||
mounted() {
|
mounted() {
|
||||||
axios.get('/api/settings', {
|
axios.get('/api/settings', {
|
||||||
params: {
|
params: {
|
||||||
column: 'contact_email|google_analytics|storage_default|registration|storage_limitation|mimetypes_blacklist'
|
column: 'contact_email|google_analytics|storage_default|registration|storage_limitation|mimetypes_blacklist|upload_limit'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
@@ -175,7 +184,8 @@
|
|||||||
defaultStorage: response.data.storage_default,
|
defaultStorage: response.data.storage_default,
|
||||||
userRegistration: parseInt(response.data.registration),
|
userRegistration: parseInt(response.data.registration),
|
||||||
storageLimitation: parseInt(response.data.storage_limitation),
|
storageLimitation: parseInt(response.data.storage_limitation),
|
||||||
mimetypesBlacklist : response.data.mimetypes_blacklist
|
mimetypesBlacklist : response.data.mimetypes_blacklist,
|
||||||
|
uploadLimit: response.data.upload_limit
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,8 @@
|
|||||||
storageDefaultSpace: {{ isset($settings->storage_default) ? $settings->storage_default : 5 }},
|
storageDefaultSpace: {{ isset($settings->storage_default) ? $settings->storage_default : 5 }},
|
||||||
storageDefaultSpaceFormatted: '{{ isset($settings->storage_default) ? format_gigabytes($settings->storage_default) : format_gigabytes(5) }}',
|
storageDefaultSpaceFormatted: '{{ isset($settings->storage_default) ? format_gigabytes($settings->storage_default) : format_gigabytes(5) }}',
|
||||||
mimetypesBlacklist: '{{ isset($settings->mimetypes_blacklist) ? $settings->mimetypes_blacklist: null}}',
|
mimetypesBlacklist: '{{ isset($settings->mimetypes_blacklist) ? $settings->mimetypes_blacklist: null}}',
|
||||||
|
uploadLimit: {{ isset($settings->upload_limit) ? format_bytes($settings->upload_limit) : 'undefined' }},
|
||||||
|
uploadLimitFormatted: '{{ isset($settings->upload_limit) ? format_megabytes($settings->upload_limit) : null }}',
|
||||||
|
|
||||||
hasAuthCookie: {{ Cookie::has('token') ? 1 : 0 }},
|
hasAuthCookie: {{ Cookie::has('token') ? 1 : 0 }},
|
||||||
isSaaS: {{ isset($settings->license) && $settings->license === 'Extended' ? 1 : 0 }},
|
isSaaS: {{ isset($settings->license) && $settings->license === 'Extended' ? 1 : 0 }},
|
||||||
|
|||||||
Reference in New Issue
Block a user