- Moved chunk size option to .env

- Added ability into App Settings to flush application cache
- Renew password page logo fix
- removed put|patch|delete methods from axios and replaced by faking these methods to support incompatible shared hostings where you can't install php extension to support these methods.
- Getting unique_ids fix
This commit is contained in:
Peter Papp
2020-08-18 10:21:24 +02:00
parent 5c2326e492
commit 93a7542502
36 changed files with 132 additions and 68 deletions

View File

@@ -8,6 +8,7 @@ APP_DEMO=false
LOG_CHANNEL=stack LOG_CHANNEL=stack
SCOUT_DRIVER=tntsearch SCOUT_DRIVER=tntsearch
FILESYSTEM_DRIVER= FILESYSTEM_DRIVER=
CHUNK_SIZE=128
DB_CONNECTION=mysql DB_CONNECTION=mysql
DB_HOST=127.0.0.1 DB_HOST=127.0.0.1

View File

@@ -227,7 +227,7 @@ class UserController extends Controller
} }
// Validate user name // Validate user name
if ($user->name !== $request->name) abort(403); if ($user->name !== $request->input('data.name')) abort(403);
$shares = Share::where('user_id', $user->id)->get(); $shares = Share::where('user_id', $user->id)->get();

View File

@@ -59,7 +59,7 @@ class AppFunctionsController extends Controller
$users_table = Schema::hasTable('users'); $users_table = Schema::hasTable('users');
// If settings table don't exist, then run migrations // If settings table don't exist, then run migrations
if ($users_table && ! $settings_table) { if ($users_table && !$settings_table) {
Artisan::call('migrate', [ Artisan::call('migrate', [
'--force' => true '--force' => true
]); ]);
@@ -71,7 +71,7 @@ class AppFunctionsController extends Controller
// Get connection string // Get connection string
if ($upgraded && $upgraded->value !== '1.7') { if ($upgraded && $upgraded->value !== '1.7') {
$connection = 'quiet-update'; $connection = 'quiet-update';
} else if (! $upgraded) { } else if (!$upgraded) {
$connection = 'quiet-update'; $connection = 'quiet-update';
} else { } else {
$connection = $this->get_setup_status(); $connection = $this->get_setup_status();
@@ -164,4 +164,14 @@ class AppFunctionsController extends Controller
return Setting::where('name', $column)->pluck('value', 'name'); return Setting::where('name', $column)->pluck('value', 'name');
} }
/**
* Clear application cache
*/
public function flush_cache()
{
Artisan::call('cache:clear');
Artisan::call('config:clear');
Artisan::call('config:cache');
}
} }

View File

@@ -244,12 +244,12 @@ function is_editor($shared)
function get_unique_id(): int function get_unique_id(): int
{ {
// Get files and folders // Get files and folders
$folders = FileManagerFolder::withTrashed()->get(); $folders = FileManagerFolder::withTrashed()->latest();
$files = FileManagerFile::withTrashed()->get(); $files = FileManagerFile::withTrashed()->latest();
// Get last ids // Get last ids
$folders_unique = $folders->isEmpty() ? 0 : (int) $folders->last()->unique_id; $folders_unique = ! $folders->first() ? 0 : (int) $folders->first()->unique_id;
$files_unique = $files->isEmpty() ? 0 : (int) $files->last()->unique_id; $files_unique = ! $files->first() ? 0 : (int) $files->first()->unique_id;
// Count new unique id // Count new unique id
$unique_id = $folders_unique > $files_unique ? $folders_unique + 1 : $files_unique + 1; $unique_id = $folders_unique > $files_unique ? $folders_unique + 1 : $files_unique + 1;

View File

@@ -24,7 +24,7 @@ class DeleteUserRequest extends FormRequest
public function rules() public function rules()
{ {
return [ return [
'name' => 'required|string|max:255', 'data.name' => 'required|string|max:255',
]; ];
} }
} }

View File

@@ -25,8 +25,8 @@ class DeleteItemRequest extends FormRequest
public function rules() public function rules()
{ {
return [ return [
'type' => 'required|string', 'data.type' => 'required|string',
'force_delete' => 'required|boolean', 'data.force_delete' => 'required|boolean',
]; ];
} }
} }

View File

@@ -36,11 +36,12 @@ class Editor
$user_scope = is_null($shared) ? $request->user()->token()->scopes[0] : 'editor'; $user_scope = is_null($shared) ? $request->user()->token()->scopes[0] : 'editor';
$name = $request->has('name') ? $request->input('name') : 'New Folder'; $name = $request->has('name') ? $request->input('name') : 'New Folder';
$user_id = is_null($shared) ? Auth::id() : $shared->user_id; $user_id = is_null($shared) ? Auth::id() : $shared->user_id;
$unique_id = get_unique_id();
// Create folder // Create folder
$folder = FileManagerFolder::create([ $folder = FileManagerFolder::create([
'parent_id' => $request->parent_id, 'parent_id' => $request->parent_id,
'unique_id' => get_unique_id(), 'unique_id' => $unique_id,
'user_scope' => $user_scope, 'user_scope' => $user_scope,
'user_id' => $user_id, 'user_id' => $user_id,
'type' => 'folder', 'type' => 'folder',
@@ -257,6 +258,7 @@ class Editor
if ($request->boolean('is_last')) { if ($request->boolean('is_last')) {
$disk_local = Storage::disk('local'); $disk_local = Storage::disk('local');
$unique_id = get_unique_id();
// Get user data // Get user data
$user_scope = is_null($shared) ? $request->user()->token()->scopes[0] : 'editor'; $user_scope = is_null($shared) ? $request->user()->token()->scopes[0] : 'editor';
@@ -275,20 +277,6 @@ class Editor
// Move finished file from chunk to file-manager directory // Move finished file from chunk to file-manager directory
$disk_local->move('chunks/' . $temp_filename, 'file-manager/' . $disk_file_name); $disk_local->move('chunks/' . $temp_filename, 'file-manager/' . $disk_file_name);
// Store file
$options = [
'mimetype' => get_file_type_from_mimetype($file_mimetype),
'type' => get_file_type($file_mimetype),
'folder_id' => $request->parent_id,
'name' => $user_file_name,
'unique_id' => get_unique_id(),
'basename' => $disk_file_name,
'user_scope' => $user_scope,
'thumbnail' => $thumbnail,
'filesize' => $file_size,
'user_id' => $user_id,
];
// Move files to external storage // Move files to external storage
if (!is_storage_driver(['local'])) { if (!is_storage_driver(['local'])) {
@@ -299,6 +287,20 @@ class Editor
self::move_to_external_storage($disk_file_name, $thumbnail); self::move_to_external_storage($disk_file_name, $thumbnail);
} }
// Store file
$options = [
'mimetype' => get_file_type_from_mimetype($file_mimetype),
'type' => get_file_type($file_mimetype),
'folder_id' => $request->parent_id,
'name' => $user_file_name,
'unique_id' => $unique_id,
'basename' => $disk_file_name,
'user_scope' => $user_scope,
'thumbnail' => $thumbnail,
'filesize' => $file_size,
'user_id' => $user_id,
];
// Return new file // Return new file
return FileManagerFile::create($options); return FileManagerFile::create($options);
} }

View File

@@ -2,8 +2,8 @@
return [ return [
'version' => '1.7.5', 'version' => '1.7.6',
// Define size of chunk uploaded by MB. E.g. integer 128 means chunk size will be 128MB. // Define size of chunk uploaded by MB. E.g. integer 128 means chunk size will be 128MB.
'chunk_size' => '128', 'chunk_size' => env('CHUNK_SIZE', '128'),
]; ];

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
public/js/main.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -142,7 +142,9 @@
// Send delete request // Send delete request
axios axios
.delete('/api/share/' + this.pickedItem.shared.token) .post('/api/share/' + this.pickedItem.shared.token, {
_method: 'delete'
})
.then(() => { .then(() => {
// Remove item from file browser // Remove item from file browser
if ( this.isSharedLocation ) { if ( this.isSharedLocation ) {
@@ -182,10 +184,11 @@
// Send request to get share link // Send request to get share link
axios axios
.patch('/api/share/' + this.shareOptions.token, { .post('/api/share/' + this.shareOptions.token, {
permission: this.shareOptions.permission, permission: this.shareOptions.permission,
protected: this.shareOptions.isProtected, protected: this.shareOptions.isProtected,
password: this.shareOptions.password ? this.shareOptions.password : undefined, password: this.shareOptions.password ? this.shareOptions.password : undefined,
_method: 'patch'
}) })
.then(response => { .then(response => {

View File

@@ -11,7 +11,7 @@ const Helpers = {
if (value === '') return if (value === '') return
axios.patch(this.$store.getters.api + route, {name, value}) axios.post(this.$store.getters.api + route, {name, value, _method: 'patch'})
.catch(error => { .catch(error => {
events.$emit('alert:open', { events.$emit('alert:open', {
title: this.$t('popup_error.title'), title: this.$t('popup_error.title'),

View File

@@ -13,9 +13,10 @@ const actions = {
: '/api/move/' + item_from.unique_id : '/api/move/' + item_from.unique_id
axios axios
.patch(route, { .post(route, {
from_type: item_from.type, from_type: item_from.type,
to_unique_id: to_item.unique_id to_unique_id: to_item.unique_id,
_method: 'patch'
}) })
.then(() => { .then(() => {
commit('REMOVE_ITEM', item_from.unique_id) commit('REMOVE_ITEM', item_from.unique_id)
@@ -62,9 +63,10 @@ const actions = {
: '/api/rename-item/' + data.unique_id : '/api/rename-item/' + data.unique_id
axios axios
.patch(route, { .post(route, {
name: data.name, name: data.name,
type: data.type, type: data.type,
_method: 'patch'
}) })
.then(response => { .then(response => {
commit('CHANGE_ITEM_NAME', response.data) commit('CHANGE_ITEM_NAME', response.data)
@@ -155,9 +157,10 @@ const actions = {
commit('CLEAR_FILEINFO_DETAIL') commit('CLEAR_FILEINFO_DETAIL')
axios axios
.patch(getters.api + '/restore-item/' + item.unique_id, { .post(getters.api + '/restore-item/' + item.unique_id, {
type: item.type, type: item.type,
to_home: restoreToHome, to_home: restoreToHome,
_method: 'patch'
}) })
.catch(() => isSomethingWrong()) .catch(() => isSomethingWrong())
}, },
@@ -182,11 +185,12 @@ const actions = {
: '/api/remove-item/' + data.unique_id : '/api/remove-item/' + data.unique_id
axios axios
.delete(route, { .post(route, {
_method: 'delete',
data: { data: {
type: data.type, type: data.type,
force_delete: data.deleted_at ? true : false force_delete: data.deleted_at ? true : false,
} },
}) })
.then(() => { .then(() => {
@@ -214,7 +218,9 @@ const actions = {
commit('LOADING_STATE', {loading: true, data: []}) commit('LOADING_STATE', {loading: true, data: []})
axios axios
.delete(getters.api + '/empty-trash') .post(getters.api + '/empty-trash', {
_method: 'delete'
})
.then(() => { .then(() => {
commit('LOADING_STATE', {loading: false, data: []}) commit('LOADING_STATE', {loading: false, data: []})
events.$emit('scrollTop') events.$emit('scrollTop')

View File

@@ -66,7 +66,9 @@ const actions = {
context.commit('REMOVE_ITEM_FROM_FAVOURITES', folder) context.commit('REMOVE_ITEM_FROM_FAVOURITES', folder)
axios axios
.delete(context.getters.api + '/folders/favourites/' + folder.unique_id) .post(context.getters.api + '/folders/favourites/' + folder.unique_id, {
_method: 'delete'
})
.catch(() => { .catch(() => {
// Show error message // Show error message
events.$emit('alert:open', { events.$emit('alert:open', {

View File

@@ -135,7 +135,9 @@
// Send request to get verify account // Send request to get verify account
axios axios
.put('/api/settings/email', this.mail) .post('/api/settings/email', this.mail, {
_method: 'put'
})
.then(() => { .then(() => {
events.$emit('toaster', { events.$emit('toaster', {

View File

@@ -57,7 +57,9 @@
</div> </div>
</div> </div>
<FormLabel class="mt-70">{{ $t('admin_settings.others.section_others') }}</FormLabel> <FormLabel class="mt-70">
{{ $t('admin_settings.others.section_others') }}
</FormLabel>
<div class="block-wrapper"> <div class="block-wrapper">
<label>{{ $t('admin_settings.others.contact_email') }}:</label> <label>{{ $t('admin_settings.others.contact_email') }}:</label>
<ValidationProvider tag="div" mode="passive" class="input-wrapper" name="Contact Email" <ValidationProvider tag="div" mode="passive" class="input-wrapper" name="Contact Email"
@@ -77,6 +79,16 @@
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span> <span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
</ValidationProvider> </ValidationProvider>
</div> </div>
<FormLabel class="mt-70">
Application Cache
</FormLabel>
<InfoBox>
Did you change anything in your .env file or change your stripe credentials? Then clear your cache.
</InfoBox>
<ButtonBase @click.native="flushCache" type="submit" button-style="theme" class="submit-button">
Clear Cache
</ButtonBase>
</div> </div>
</PageTabGroup> </PageTabGroup>
</PageTab> </PageTab>
@@ -95,6 +107,7 @@
import PageTab from '@/components/Others/Layout/PageTab' import PageTab from '@/components/Others/Layout/PageTab'
import InfoBox from '@/components/Others/Forms/InfoBox' import InfoBox from '@/components/Others/Forms/InfoBox'
import {required} from 'vee-validate/dist/rules' import {required} from 'vee-validate/dist/rules'
import {events} from '@/bus'
import axios from 'axios' import axios from 'axios'
export default { export default {
@@ -126,6 +139,17 @@
}, },
} }
}, },
methods: {
flushCache() {
axios.get('/api/flush-cache')
.then(() => {
events.$emit('toaster', {
type: 'success',
message: 'Your cache was successfully deleted.',
})
})
}
},
mounted() { mounted() {
axios.get('/api/settings', { axios.get('/api/settings', {
params: { params: {

View File

@@ -710,7 +710,9 @@
// Send request to get verify account // Send request to get verify account
axios axios
.put('/api/settings/stripe', this.stripeCredentials) .post('/api/settings/stripe', this.stripeCredentials, {
_method: 'put'
})
.then(() => { .then(() => {
// End loading // End loading

View File

@@ -70,11 +70,12 @@
this.isSendingRequest = true this.isSendingRequest = true
axios axios
.delete(this.$store.getters.api + '/plans/' + this.$route.params.id, .post(this.$store.getters.api + '/plans/' + this.$route.params.id,
{ {
data: { data: {
name: this.planName name: this.planName
} },
_method: 'delete'
} }
) )
.then(() => { .then(() => {

View File

@@ -73,11 +73,12 @@
this.isSendingRequest = true this.isSendingRequest = true
axios axios
.delete(this.$store.getters.api + '/users/' + this.$route.params.id + '/delete', .post(this.$store.getters.api + '/users/' + this.$route.params.id + '/delete',
{ {
data: { data: {
name: this.userName name: this.userName
} },
_method: 'delete'
} }
) )
.then((response) => { .then((response) => {

View File

@@ -188,10 +188,11 @@
// Send request to get user reset link // Send request to get user reset link
axios axios
.patch(this.$store.getters.api + '/users/' + this.$route.params.id + '/role', { .post(this.$store.getters.api + '/users/' + this.$route.params.id + '/role', {
attributes: { attributes: {
role: this.userRole, role: this.userRole,
} },
_method: 'patch'
}) })
.then(() => { .then(() => {

View File

@@ -96,10 +96,11 @@
// Send request to get user reset link // Send request to get user reset link
axios axios
.patch(this.$store.getters.api + '/users/' + this.$route.params.id + '/capacity', { .post(this.$store.getters.api + '/users/' + this.$route.params.id + '/capacity', {
attributes: { attributes: {
storage_capacity: this.capacity storage_capacity: this.capacity
} },
_method: 'patch'
}) })
.then(() => { .then(() => {

View File

@@ -56,7 +56,9 @@
<!--Password reset successfully--> <!--Password reset successfully-->
<AuthContent name="password-reset-successfully" :visible="false"> <AuthContent name="password-reset-successfully" :visible="false">
<img class="logo" :src="config.app_logo" :alt="config.app_name"> <img v-if="config.app_logo" class="logo" :src="config.app_logo" :alt="config.app_name">
<b v-if="! config.app_logo" class="auth-logo-text">{{ config.app_name }}</b>
<h1>{{ $t('page_forgotten_password.pass_reseted_title') }}</h1> <h1>{{ $t('page_forgotten_password.pass_reseted_title') }}</h1>
<h2>{{ $t('page_forgotten_password.pass_reseted_subtitle') }}</h2> <h2>{{ $t('page_forgotten_password.pass_reseted_subtitle') }}</h2>

View File

@@ -30,7 +30,9 @@
<!--Password reset link sended--> <!--Password reset link sended-->
<AuthContent name="password-reset-link-sended" :visible="false"> <AuthContent name="password-reset-link-sended" :visible="false">
<img class="logo" :src="config.app_logo" :alt="config.app_name"> <img v-if="config.app_logo" class="logo" :src="config.app_logo" :alt="config.app_name">
<b v-if="! config.app_logo" class="auth-logo-text">{{ config.app_name }}</b>
<h1>{{ $t('page_forgotten_password.pass_sennded_title') }}</h1> <h1>{{ $t('page_forgotten_password.pass_sennded_title') }}</h1>
<h2>{{ $t('page_forgotten_password.pass_sennded_subtitle') }}</h2> <h2>{{ $t('page_forgotten_password.pass_sennded_subtitle') }}</h2>

View File

@@ -48,7 +48,7 @@
import axios from 'axios' import axios from 'axios'
export default { export default {
name: 'Profile', name: 'Password',
components: { components: {
PageTabGroup, PageTabGroup,
FormLabel, FormLabel,

View File

@@ -193,7 +193,9 @@
this.deletingID = data.id this.deletingID = data.id
axios.delete('/api/user/payment-cards/' + data.id) axios.post('/api/user/payment-cards/' + data.id, {
_method: 'delete'
})
.then(() => { .then(() => {
// Get payments card // Get payments card
@@ -215,8 +217,9 @@
if (data.operation === 'set-as-default-credit-card') { if (data.operation === 'set-as-default-credit-card') {
axios.patch('/api/user/payment-cards/' + data.id, { axios.post('/api/user/payment-cards/' + data.id, {
default: 1 default: 1,
_method: 'patch'
}) })
.then(() => { .then(() => {

View File

@@ -167,6 +167,7 @@ Route::group(['middleware' => ['auth:api', 'auth.master', 'auth.admin', 'scope:m
Route::put('/settings/stripe', 'SettingController@set_stripe'); Route::put('/settings/stripe', 'SettingController@set_stripe');
Route::patch('/settings', 'SettingController@update'); Route::patch('/settings', 'SettingController@update');
Route::get('/settings', 'SettingController@show'); Route::get('/settings', 'SettingController@show');
Route::get('/flush-cache', 'AppFunctionsController@flush_cache');
}); });
// Protected sharing routes for authenticated user // Protected sharing routes for authenticated user