editing with shared items in public

This commit is contained in:
carodej
2020-04-28 18:06:38 +02:00
parent eb6bd646c8
commit 2614efe601
77 changed files with 1171 additions and 578 deletions

View File

@@ -3,7 +3,7 @@
/**
* A helper file for Laravel, to provide autocomplete information to your IDE
* Generated for Laravel 6.18.3 on 2020-04-27 09:19:35.
* Generated for Laravel 6.18.3 on 2020-04-28 07:53:27.
*
* This file should not be included in your code, only analyzed by your IDE!
*

View File

@@ -131,7 +131,7 @@ class BrowseController extends Controller
*
* @return array
*/
public function folder_tree() {
public function navigation_tree() {
$folders = FileManagerFolder::with('folders:id,parent_id,unique_id,name')
->where('parent_id', 0)

View File

@@ -2,387 +2,327 @@
namespace App\Http\Controllers\FileFunctions;
use App\Share;
use Illuminate\Support\Arr;
use App\Http\Requests\FileFunctions\CreateFolderRequest;
use App\Http\Requests\FileFunctions\DeleteItemRequest;
use App\Http\Requests\FileFunctions\RenameItemRequest;
use App\Http\Requests\FileFunctions\MoveItemRequest;
use App\Http\Requests\FileFunctions\UploadRequest;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Intervention\Image\ImageManagerStatic as Image;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Storage;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use App\Http\Tools\Guardian;
use App\Http\Tools\Editor;
use App\FileManagerFolder;
use App\FileManagerFile;
use Response;
use Exception;
class EditItemsController extends Controller
{
/**
* Create new folder
* Create new folder for authenticated master|editor user
*
* @param Request $request
* @return array
* @param CreateFolderRequest $request
* @return FileManagerFolder|Model
*/
public function create_folder(Request $request)
public function user_create_folder(CreateFolderRequest $request)
{
// Check permission to create folder for authenticated public editor
if ( ! $request->user()->tokenCan('master') ) {
$this->check_access($request, $request->parent_id);
// Check permission to create folder for authenticated editor
if ($request->user()->tokenCan('editor')) {
// check if shared_token cookie exist
if (!$request->hasCookie('shared_token')) abort('401');
// Get shared token
$shared = get_shared($request->cookie('shared_token'));
// Check access to requested directory
Guardian::check_item_access($request->parent_id, $shared);
}
// Validate request
$validator = Validator::make($request->all(), [
'parent_id' => 'required|integer',
'name' => 'string',
]);
// Create new folder
return Editor::create_folder($request);
}
// Return error
if ($validator->fails()) abort(400, 'Bad input');
/**
* Create new folder for guest user with edit permission
*
* @param CreateFolderRequest $request
* @param $token
* @return FileManagerFolder|Model
*/
public function guest_create_folder(CreateFolderRequest $request, $token)
{
// Get shared record
$shared = get_shared($token);
// Get parent_id from request
$parent_id = $request->parent_id === 0 ? 0 : $request->parent_id;
// Check shared permission
if (!is_editor($shared)) abort(403);
// Check access to requested directory
Guardian::check_item_access($request->parent_id, $shared);
// Create folder
$folder = FileManagerFolder::create([
'user_id' => Auth::id(),
'parent_id' => $parent_id,
'name' => $request->has('name') ? $request->input('name') : 'New Folder',
'type' => 'folder',
'unique_id' => $this->get_unique_id(),
'user_scope' => $request->user()->token()->scopes[0],
]);
// Return new folder
return $folder;
return Editor::create_folder($request, $shared);
}
/**
* Rename item name
* Rename item for authenticated master|editor user
*
* @param Request $request
* @param RenameItemRequest $request
* @param $unique_id
* @return mixed
*/
public function rename_item(Request $request, $unique_id)
public function user_rename_item(RenameItemRequest $request, $unique_id)
{
// Validate request
$validator = Validator::make($request->all(), [
'name' => 'required|string',
'type' => 'required|string',
]);
// Check permission to rename item for authenticated editor
if ($request->user()->tokenCan('editor')) {
// Return error
if ($validator->fails()) abort(400, 'Bad input');
// check if shared_token cookie exist
if (!$request->hasCookie('shared_token')) abort('401');
// Get user id
$user_id = Auth::id();
// Get shared token
$shared = get_shared($request->cookie('shared_token'));
// Update folder name
if ($request->type === 'folder') {
// Get file|folder item
$item = get_item($request->type, $unique_id, Auth::id());
$item = FileManagerFolder::where('unique_id', $unique_id)
->where('user_id', $user_id)
->firstOrFail();
// Check permission to rename for authenticated public editor
if ( ! $request->user()->tokenCan('master') ) {
$this->check_access($request, $item->unique_id);
// Check access to requested directory
if ($request->type === 'folder') {
Guardian::check_item_access($item->unique_id, $shared);
} else {
Guardian::check_item_access($item->folder_id, $shared);
}
$item->name = $request->name;
$item->save();
} else {
$item = FileManagerFile::where('unique_id', $unique_id)
->where('user_id', $user_id)
->firstOrFail();
// Check permission to rename for authenticated public editor
if ( ! $request->user()->tokenCan('master') ) {
$this->check_access($request, $item->folder_id);
}
$item->name = $request->name;
$item->save();
}
// Return updated item
return $item;
// Rename Item
return Editor::rename_item($request, $unique_id);
}
/**
* Delete item
* Rename item for guest user with edit permission
*
* @param Request $request
* @param RenameItemRequest $request
* @param $unique_id
* @throws \Exception
* @param $token
* @return mixed
*/
public function delete_item(Request $request, $unique_id)
public function guest_rename_item(RenameItemRequest $request, $unique_id, $token)
{
// Validate request
$validator = Validator::make($request->all(), [
'type' => 'required|string',
'force_delete' => 'required|boolean',
]);
// Get shared record
$shared = get_shared($token);
// Return error
if ($validator->fails()) abort(400, 'Bad input');
// Check shared permission
if (!is_editor($shared)) abort(403);
// Get user id
$user = Auth::user();
// Get file|folder item
$item = get_item($request->type, $unique_id, $shared->user_id);
// Delete folder
// Check access to requested item
if ($request->type === 'folder') {
// Get folder
$folder = FileManagerFolder::withTrashed()
->with(['folders'])
->where('user_id', $user->id)
->where('unique_id', $unique_id)
->first();
// Check permission to delete for authenticated public editor
if ( ! $request->user()->tokenCan('master') ) {
$this->check_access($request, $folder->unique_id);
}
// Force delete children files
if ($request->force_delete) {
// Get children folder ids
$child_folders = filter_folders_ids($folder->trashed_folders, 'unique_id');
// Get children files
$files = FileManagerFile::onlyTrashed()
->where('user_id', $user->id)
->whereIn('folder_id', Arr::flatten([$unique_id, $child_folders]))
->get();
// Remove all children files
foreach ($files as $file) {
// Delete file
Storage::disk('local')->delete('/file-manager/' . $file->basename);
// Delete thumbnail if exist
if (!is_null($file->thumbnail)) Storage::disk('local')->delete('/file-manager/' . $file->getOriginal('thumbnail'));
// Delete file permanently
$file->forceDelete();
}
// Delete folder record
$folder->forceDelete();
} else {
// Remove folder from user favourites
$user->favourites()->detach($unique_id);
// Soft delete folder record
$folder->delete();
}
Guardian::check_item_access($item->unique_id, $shared);
} else {
$file = FileManagerFile::withTrashed()
->where('user_id', $user->id)
->where('unique_id', $unique_id)
->first();
// Check permission to delete for authenticated public editor
if ( ! $request->user()->tokenCan('master') ) {
$this->check_access($request, $file->folder_id);
}
if ($request->force_delete) {
// Delete file
Storage::disk('local')->delete('/file-manager/' . $file->basename);
// Delete thumbnail if exist
if ($file->thumbnail) Storage::disk('local')->delete('/file-manager/' . $file->getOriginal('thumbnail'));
// Delete file permanently
$file->forceDelete();
} else {
// Soft delete file
$file->delete();
}
Guardian::check_item_access($item->folder_id, $shared);
}
// Rename item
return Editor::rename_item($request, $unique_id, $shared);
}
/**
* Upload items
* Delete item for authenticated master|editor user
*
* @param Request $request
* @return array
* @param DeleteItemRequest $request
* @param $unique_id
* @return ResponseFactory|\Illuminate\Http\Response
* @throws Exception
*/
public function upload_item(Request $request)
public function user_delete_item(DeleteItemRequest $request, $unique_id)
{
// Check permission to upload for authenticated public editor
if ( ! $request->user()->tokenCan('master') ) {
$this->check_access($request, $request->parent_id);
// Check permission to delete item for authenticated editor
if ($request->user()->tokenCan('editor')) {
// Prevent force delete for non-master users
if ($request->force_delete) abort('401');
// check if shared_token cookie exist
if (!$request->hasCookie('shared_token')) abort('401');
// Get shared token
$shared = get_shared($request->cookie('shared_token'));
// Get file|folder item
$item = get_item($request->type, $unique_id, Auth::id());
// Check access to requested directory
if ($request->type === 'folder') {
Guardian::check_item_access($item->unique_id, $shared);
} else {
Guardian::check_item_access($item->folder_id, $shared);
}
}
// Delete item
Editor::delete_item($request, $unique_id);
// Return response
return response(null, 204);
}
/**
* Delete item for guest user with edit permission
*
* @param DeleteItemRequest $request
* @param $unique_id
* @param $token
* @return ResponseFactory|\Illuminate\Http\Response
* @throws Exception
*/
public function guest_delete_item(DeleteItemRequest $request, $unique_id, $token)
{
// Get shared record
$shared = get_shared($token);
// Check shared permission
if (!is_editor($shared)) abort(403);
// Get file|folder item
$item = get_item($request->type, $unique_id, $shared->user_id);
// Check access to requested item
if ($request->type === 'folder') {
Guardian::check_item_access($item->unique_id, $shared);
} else {
Guardian::check_item_access($item->folder_id, $shared);
}
// Delete item
Editor::delete_item($request, $unique_id, $shared);
// Return response
return response(null, 204);
}
/**
* Delete file for authenticated master|editor user
*
* @param UploadRequest $request
* @return FileManagerFile|Model
*/
public function user_upload(UploadRequest $request)
{
// Check if user can upload
if (config('vuefilemanager.limit_storage_by_capacity') && user_storage_percentage() >= 100) {
abort(423, 'You exceed your storage limit!');
}
// Validate request
$validator = Validator::make($request->all(), [
'parent_id' => 'required|integer',
'file' => 'required|file',
]);
// Check permission to upload for authenticated editor
if ($request->user()->tokenCan('editor')) {
// Return error
if ($validator->fails()) abort(400, 'Bad input');
// check if shared_token cookie exist
if (!$request->hasCookie('shared_token')) abort('401');
// Get parent_id from request
$folder_id = $request->parent_id === 0 ? 0 : $request->parent_id;
$file = $request->file('file');
// Get shared token
$shared = get_shared($request->cookie('shared_token'));
// File
$filename = Str::random() . '-' . str_replace(' ', '', $file->getClientOriginalName());
$filetype = get_file_type($file);
$thumbnail = null;
$filesize = $file->getSize();
$directory = 'file-manager';
// create directory if not exist
if (!Storage::disk('local')->exists($directory)) {
Storage::disk('local')->makeDirectory($directory);
// Check access to requested directory
Guardian::check_item_access($request->parent_id, $shared);
}
// Store to disk
Storage::disk('local')->putFileAs($directory, $file, $filename, 'public');
// Return new uploaded file
return Editor::upload($request);
}
// Create image thumbnail
if ($filetype == 'image') {
/**
* Delete file for guest user with edit permission
*
* @param UploadRequest $request
* @param $token
* @return FileManagerFile|Model
*/
public function guest_upload(UploadRequest $request, $token)
{
// Get shared record
$shared = get_shared($token);
$thumbnail = 'thumbnail-' . $filename;
// Check shared permission
if (!is_editor($shared)) abort(403);
// Create intervention image
$image = Image::make($file->getRealPath())->orientate();
// Check access to requested directory
Guardian::check_item_access($request->parent_id, $shared);
$image->resize(256, null, function ($constraint) {
$constraint->aspectRatio();
})->stream();
// Return new uploaded file
$new_file = Editor::upload($request, $shared);
// Store thumbnail to s3
Storage::disk('local')->put($directory . '/' . $thumbnail, $image);
}
// Store file
$new_file = FileManagerFile::create([
'user_id' => Auth::id(),
'name' => pathinfo($file->getClientOriginalName())['filename'],
'basename' => $filename,
'folder_id' => $folder_id,
'mimetype' => $file->getClientOriginalExtension(),
'filesize' => $filesize,
'type' => $filetype,
'thumbnail' => $thumbnail,
'unique_id' => $this->get_unique_id(),
'user_scope' => $request->user()->token()->scopes[0],
]);
// Set public access url
$new_file->setPublicUrl($token);
return $new_file;
}
/**
* Move item
* Move item for authenticated master|editor user
*
* @param Request $request
* @param MoveItemRequest $request
* @param $unique_id
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
* @return ResponseFactory|\Illuminate\Http\Response
*/
public function move_item(Request $request, $unique_id)
public function user_move(MoveItemRequest $request, $unique_id)
{
// Validate request
$validator = Validator::make($request->all(), [
'to_unique_id' => 'required|integer',
'from_type' => 'required|string',
]);
// Check permission to upload for authenticated editor
if ($request->user()->tokenCan('editor')) {
// Return error
if ($validator->fails()) abort(400, 'Bad input');
// check if shared_token cookie exist
if (!$request->hasCookie('shared_token')) abort('401');
// Get user id
$user_id = Auth::id();
// Get shared token
$shared = get_shared($request->cookie('shared_token'));
if ($request->from_type === 'folder') {
// Move folder
$item = FileManagerFolder::where('user_id', $user_id)
->where('unique_id', $unique_id)
->firstOrFail();
$item->parent_id = $request->to_unique_id;
} else {
// Move file under new folder
$item = FileManagerFile::where('user_id', $user_id)
->where('unique_id', $unique_id)
->firstOrFail();
$item->folder_id = $request->to_unique_id;
// Check access to requested directory
Guardian::check_item_access($request->to_unique_id, $shared);
}
$item->update();
// Move item
Editor::move($request, $unique_id);
return response('Done!', 204);
}
/**
* Get unique id
* Move item for guest user with edit permission
*
* @return int
* @param MoveItemRequest $request
* @param $unique_id
* @param $token
* @return ResponseFactory|\Illuminate\Http\Response
*/
private function get_unique_id(): int
public function guest_move(MoveItemRequest $request, $unique_id, $token)
{
// Get files and folders
$folders = FileManagerFolder::withTrashed()->get();
$files = FileManagerFile::withTrashed()->get();
// Get shared record
$shared = get_shared($token);
// Get last ids
$folders_unique = $folders->isEmpty() ? 0 : $folders->last()->unique_id;
$files_unique = $files->isEmpty() ? 0 : $files->last()->unique_id;
// Check shared permission
if (!is_editor($shared)) abort(403);
// Count new unique id
$unique_id = $folders_unique > $files_unique ? $folders_unique + 1 : $files_unique + 1;
$moving_unique_id = $unique_id;
return $unique_id;
}
if ($request->from_type !== 'folder') {
$file = FileManagerFile::where('unique_id', $unique_id)
->where('user_id', $shared->user_id)
->firstOrFail();
/**
* Check if user has access to requested folder
*
* @param $request
*/
protected function check_access($request, $parent_id): void
{
// check if shared_token cookie exist
if (! $request->hasCookie('shared_token')) abort('401');
$moving_unique_id = $file->folder_id;
}
// Get shared token
$shared = Share::where(DB::raw('BINARY `token`'), $request->cookie('shared_token'))
->firstOrFail();
// Check access to requested item
Guardian::check_item_access([
$request->to_unique_id, $moving_unique_id
], $shared);
// Get all children folders
$foldersIds = FileManagerFolder::with('folders:id,parent_id,unique_id,name')
->where('user_id', $shared->user_id)
->where('parent_id', $shared->item_id)
->get();
// Move item
Editor::move($request, $unique_id, $shared);
// Get all authorized parent folders by shared folder as root of tree
$accessible_folder_ids = Arr::flatten([filter_folders_ids($foldersIds), $shared->item_id]);
// Check user access
if (!in_array($parent_id, $accessible_folder_ids)) abort(403);
return response('Done!', 204);
}
}

View File

@@ -89,6 +89,7 @@ class ShareController extends Controller
*
* @param $token
* @return ResponseFactory|\Illuminate\Http\Response
* @throws \Exception
*/
public function destroy($token)
{

View File

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Sharing;
use App\Http\Controllers\Controller;
use App\Http\Requests\Share\AuthenticateShareRequest;
use App\Http\Resources\ShareResource;
use App\Http\Tools\Guardian;
use Illuminate\Contracts\View\Factory;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\DB;
@@ -91,7 +92,7 @@ class FileSharingController extends Controller
$shared = Share::where('token', $request->cookie('shared_token'))->firstOrFail();
// Check if user can get directory
$this->check_folder_access($unique_id, $shared);
Guardian::check_item_access($unique_id, $shared);
// Get files and folders
list($folders, $files) = $this->get_items($unique_id, $shared);
@@ -117,7 +118,7 @@ class FileSharingController extends Controller
}
// Check if user can get directory
$this->check_folder_access($unique_id, $shared);
Guardian::check_item_access($unique_id, $shared);
// Get files and folders
list($folders, $files) = $this->get_items($unique_id, $shared);
@@ -177,24 +178,64 @@ class FileSharingController extends Controller
}
/**
* Check if user has access to requested folder
* Get navigation tree
*
* @param $folder_unique_id
* @param $shared
* @param Request $request
* @return array
*/
protected function check_folder_access($unique_id, $shared): void
public function get_private_navigation_tree(Request $request)
{
// Get all children folders
$foldersIds = FileManagerFolder::with('folders:id,parent_id,unique_id,name')
->where('user_id', $shared->user_id)
// Get sharing record
$shared = Share::where('token', $request->cookie('shared_token'))->firstOrFail();
// Check if user can get directory
Guardian::check_item_access($shared->item_id, $shared);
// Get folders
$folders = FileManagerFolder::with('folders:id,parent_id,unique_id,name')
->where('parent_id', $shared->item_id)
->get();
->where('user_id', $shared->user_id)
->get(['id', 'parent_id', 'unique_id', 'name']);
// Get all authorized parent folders by shared folder as root of tree
$accessible_folder_ids = Arr::flatten([filter_folders_ids($foldersIds), $shared->item_id]);
// Return folder tree
return [
[
'unique_id' => $shared->item_id,
'name' => __('vuefilemanager.home'),
'location' => 'public',
'folders' => $folders,
]
];
}
// Check user access
if (!in_array($unique_id, $accessible_folder_ids)) abort(401);
/**
* Get navigation tree
*
* @return array
*/
public function get_public_navigation_tree($token)
{
// Get sharing record
$shared = Share::where('token', $token)->firstOrFail();
// Check if user can get directory
Guardian::check_item_access($shared->item_id, $shared);
// Get folders
$folders = FileManagerFolder::with('folders:id,parent_id,unique_id,name')
->where('parent_id', $shared->item_id)
->where('user_id', $shared->user_id)
->get(['id', 'parent_id', 'unique_id', 'name']);
// Return folder tree
return [
[
'unique_id' => $shared->item_id,
'name' => __('vuefilemanager.home'),
'location' => 'public',
'folders' => $folders,
]
];
}
/**

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\FileFunctions;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class CreateFolderRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'parent_id' => 'required|integer',
'name' => 'string',
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\FileFunctions;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class DeleteItemRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'type' => 'required|string',
'force_delete' => 'required|boolean',
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\FileFunctions;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class MoveItemRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'to_unique_id' => 'required|integer',
'from_type' => 'required|string',
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\FileFunctions;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class RenameItemRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|string',
'type' => 'required|string',
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\FileFunctions;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class UploadRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'parent_id' => 'required|integer',
'file' => 'required|file',
];
}
}

272
app/Http/Tools/Editor.php Normal file
View File

@@ -0,0 +1,272 @@
<?php
namespace App\Http\Tools;
use App;
use App\FileManagerFile;
use App\FileManagerFolder;
use App\Http\Requests\FileFunctions\RenameItemRequest;
use App\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Intervention\Image\ImageManagerStatic as Image;
class Editor
{
/**
* Create new directory
*
* @param $request
* @param null $shared
* @return FileManagerFolder|\Illuminate\Database\Eloquent\Model
*/
public static function create_folder($request, $shared = null)
{
// Get variables
$user_scope = is_null($shared) ? $request->user()->token()->scopes[0] : 'editor';
$name = $request->has('name') ? $request->input('name') : 'New Folder';
$user_id = is_null($shared) ? Auth::id() : $shared->user_id;
// Create folder
$folder = FileManagerFolder::create([
'parent_id' => $request->parent_id,
'unique_id' => get_unique_id(),
'user_scope' => $user_scope,
'user_id' => $user_id,
'type' => 'folder',
'name' => $name,
]);
// Return new folder
return $folder;
}
/**
* Rename item name
*
* @param RenameItemRequest $request
* @param $unique_id
* @return mixed
*/
public static function rename_item($request, $unique_id, $shared = null)
{
// Get user id
$user_id = is_null($shared) ? Auth::id() : $shared->user_id;
// Get item
$item = get_item($request->type, $unique_id, $user_id);
// Rename item
$item->update([
'name' => $request->name
]);
// Return updated item
return $item;
}
/**
* Delete file or folder
*
* @param $request
* @param $unique_id
* @param null $shared
* @throws \Exception
*/
public static function delete_item($request, $unique_id, $shared = null)
{
// Get user id
$user = is_null($shared) ? Auth::user() : User::findOrFail($shared->user_id);
// Delete folder
if ($request->type === 'folder') {
// Get folder
$folder = FileManagerFolder::withTrashed()
->with(['folders'])
->where('user_id', $user->id)
->where('unique_id', $unique_id)
->first();
// TODO: delete folder shared record
// Force delete children files
if ($request->force_delete) {
// Get children folder ids
$child_folders = filter_folders_ids($folder->trashed_folders, 'unique_id');
// Get children files
$files = FileManagerFile::onlyTrashed()
->where('user_id', $user->id)
->whereIn('folder_id', Arr::flatten([$unique_id, $child_folders]))
->get();
// Remove all children files
foreach ($files as $file) {
// Delete file
Storage::disk('local')->delete('/file-manager/' . $file->basename);
// Delete thumbnail if exist
if (!is_null($file->thumbnail)) Storage::disk('local')->delete('/file-manager/' . $file->getOriginal('thumbnail'));
// Delete file permanently
$file->forceDelete();
}
// Delete folder record
$folder->forceDelete();
}
// Soft delete items
if (!$request->force_delete) {
// Remove folder from user favourites
$user->favourites()->detach($unique_id);
// Soft delete folder record
$folder->delete();
}
}
// Delete item
if ($request->type !== 'folder') {
// Get file
$file = FileManagerFile::withTrashed()
->where('user_id', $user->id)
->where('unique_id', $unique_id)
->first();
// TODO: delete file shared record
// Force delete file
if ($request->force_delete) {
// Delete file
Storage::disk('local')->delete('/file-manager/' . $file->basename);
// Delete thumbnail if exist
if ($file->thumbnail) Storage::disk('local')->delete('/file-manager/' . $file->getOriginal('thumbnail'));
// Delete file permanently
$file->forceDelete();
}
// Soft delete file
if (!$request->force_delete) {
// Soft delete file
$file->delete();
}
}
}
/**
* Upload file
*
* @param $request
* @param $unique_id
* @param null $shared
* @return FileManagerFile|\Illuminate\Database\Eloquent\Model
*/
public static function upload($request, $shared = null)
{
// Get user data
$user_scope = is_null($shared) ? $request->user()->token()->scopes[0] : 'editor';
$user_id = is_null($shared) ? Auth::id() : $shared->user_id;
// Get parent_id from request
$folder_id = $request->parent_id === 0 ? 0 : $request->parent_id;
$file = $request->file('file');
// File
$filename = Str::random() . '-' . str_replace(' ', '', $file->getClientOriginalName());
$filetype = get_file_type($file);
$filesize = $file->getSize();
$directory = 'file-manager';
$thumbnail = null;
// create directory if not exist
if (!Storage::disk('local')->exists($directory)) {
Storage::disk('local')->makeDirectory($directory);
}
// Store to disk
Storage::disk('local')->putFileAs($directory, $file, $filename, 'public');
// Create image thumbnail
if ($filetype == 'image') {
// Get thumbnail name
$thumbnail = 'thumbnail-' . $filename;
// Create intervention image
$image = Image::make($file->getRealPath())->orientate();
// Resize image
$image->resize(256, null, function ($constraint) {
$constraint->aspectRatio();
})->stream();
// Store thumbnail to disk
Storage::disk('local')->put($directory . '/' . $thumbnail, $image);
}
// Store file
$options = [
'name' => pathinfo($file->getClientOriginalName())['filename'],
'mimetype' => $file->getClientOriginalExtension(),
'unique_id' => get_unique_id(),
'user_scope' => $user_scope,
'folder_id' => $folder_id,
'thumbnail' => $thumbnail,
'basename' => $filename,
'filesize' => $filesize,
'type' => $filetype,
'user_id' => $user_id,
];
// Return new file
return FileManagerFile::create($options);
}
/**
* Move folder or file to new location
*
* @param $request
* @param $unique_id
* @param null $shared
*/
public static function move($request, $unique_id, $shared = null)
{
// Get user id
$user_id = is_null($shared) ? Auth::id() : $shared->user_id;
if ($request->from_type === 'folder') {
// Move folder
$item = FileManagerFolder::where('user_id', $user_id)
->where('unique_id', $unique_id)
->firstOrFail();
$item->update([
'parent_id' => $request->to_unique_id
]);
} else {
// Move file under new folder
$item = FileManagerFile::where('user_id', $user_id)
->where('unique_id', $unique_id)
->firstOrFail();
$item->update([
'folder_id' => $request->to_unique_id
]);
}
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Http\Tools;
use App;
use App\FileManagerFolder;
use Illuminate\Support\Arr;
class Guardian
{
/**
* Check access to requested directory
*
* @param integer|array $requested_id
* @param string $shared Shared record detail
*/
public static function check_item_access($requested_id, $shared)
{
// Get all children folders
$foldersIds = FileManagerFolder::with('folders:id,parent_id,unique_id,name')
->where('user_id', $shared->user_id)
->where('parent_id', $shared->item_id)
->get();
// Get all authorized parent folders by shared folder as root of tree
$accessible_folder_ids = Arr::flatten([filter_folders_ids($foldersIds), $shared->item_id]);
// Check user access
if ( is_array($requested_id) ) {
foreach ($requested_id as $id) {
if (!in_array($id, $accessible_folder_ids))
abort(403);
}
}
if (! is_array($requested_id)) {
if (! in_array($requested_id, $accessible_folder_ids))
abort(403);
}
}
}

View File

@@ -1,11 +1,83 @@
<?php
use App\FileManagerFile;
use App\FileManagerFolder;
use App\Share;
use ByteUnits\Metric;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Intervention\Image\ImageManagerStatic as Image;
/**
* Get folder or file item
*
* @param $type
* @param $unique_id
* @param $user_id
* @return \Illuminate\Database\Eloquent\Builder|Model
*/
function get_item($type, $unique_id, $user_id) {
if ($type === 'folder') {
// Return folder item
return FileManagerFolder::where('unique_id', $unique_id)
->where('user_id', $user_id)
->firstOrFail();
}
// Return file item
return FileManagerFile::where('unique_id', $unique_id)
->where('user_id', $user_id)
->firstOrFail();
}
/**
* Get shared token
*
* @param $token
* @return \Illuminate\Database\Eloquent\Builder|Model
*/
function get_shared($token) {
return Share::where(DB::raw('BINARY `token`'), $token)
->firstOrFail();
}
/**
* Check if shared permission is editor
*
* @param $shared
* @return bool
*/
function is_editor($shared) {
return $shared->permission === 'editor';
}
/**
* Get unique id
*
* @return int
*/
function get_unique_id(): int
{
// Get files and folders
$folders = FileManagerFolder::withTrashed()->get();
$files = FileManagerFile::withTrashed()->get();
// Get last ids
$folders_unique = $folders->isEmpty() ? 0 : $folders->last()->unique_id;
$files_unique = $files->isEmpty() ? 0 : $files->last()->unique_id;
// Count new unique id
$unique_id = $folders_unique > $files_unique ? $folders_unique + 1 : $files_unique + 1;
return $unique_id;
}
/**
* Store user avatar to storage
@@ -102,8 +174,7 @@ function get_storage_fill_percentage($used, $capacity)
*/
function user_storage_percentage()
{
$user = \Illuminate\Support\Facades\Auth::user();
$user = Auth::user();
return get_storage_fill_percentage($user->used_capacity, config('vuefilemanager.user_storage_capacity'));
}

View File

@@ -1,5 +1,97 @@
{
"/js/main.js": "/js/main.js",
"/css/app.css": "/css/app.css",
"/js/main.9a27394a2df24ee693e3.hot-update.js": "/js/main.9a27394a2df24ee693e3.hot-update.js"
"/js/main.9a27394a2df24ee693e3.hot-update.js": "/js/main.9a27394a2df24ee693e3.hot-update.js",
"/js/main.26f701f7b52599858cce.hot-update.js": "/js/main.26f701f7b52599858cce.hot-update.js",
"/js/main.5121a1dc87cc3f3442cd.hot-update.js": "/js/main.5121a1dc87cc3f3442cd.hot-update.js",
"/js/main.8b54f2c597a60d415870.hot-update.js": "/js/main.8b54f2c597a60d415870.hot-update.js",
"/js/main.53935909cecacef877d0.hot-update.js": "/js/main.53935909cecacef877d0.hot-update.js",
"/js/main.6e0d2ac0add6c3e6dc84.hot-update.js": "/js/main.6e0d2ac0add6c3e6dc84.hot-update.js",
"/js/main.bcef9d636d3dfe572ecc.hot-update.js": "/js/main.bcef9d636d3dfe572ecc.hot-update.js",
"/js/main.07de0a9dbfed267ff7b2.hot-update.js": "/js/main.07de0a9dbfed267ff7b2.hot-update.js",
"/js/main.549012c4fffc95472aa6.hot-update.js": "/js/main.549012c4fffc95472aa6.hot-update.js",
"/js/main.ea575a8d60a5a25453e4.hot-update.js": "/js/main.ea575a8d60a5a25453e4.hot-update.js",
"/js/main.880f1e5ff9834e6633ec.hot-update.js": "/js/main.880f1e5ff9834e6633ec.hot-update.js",
"/js/main.9cd0cd846091e6779623.hot-update.js": "/js/main.9cd0cd846091e6779623.hot-update.js",
"/js/main.435761e62a7eba7f7511.hot-update.js": "/js/main.435761e62a7eba7f7511.hot-update.js",
"/js/main.8ef42b97a65fa42e754c.hot-update.js": "/js/main.8ef42b97a65fa42e754c.hot-update.js",
"/js/main.801802ad6742f1431b33.hot-update.js": "/js/main.801802ad6742f1431b33.hot-update.js",
"/js/main.712419afb068ad058a73.hot-update.js": "/js/main.712419afb068ad058a73.hot-update.js",
"/js/main.559f1d43ac058be060f7.hot-update.js": "/js/main.559f1d43ac058be060f7.hot-update.js",
"/js/main.d8b716639ab25f3dc50a.hot-update.js": "/js/main.d8b716639ab25f3dc50a.hot-update.js",
"/js/main.efd3e8d2d7598c6c5ad5.hot-update.js": "/js/main.efd3e8d2d7598c6c5ad5.hot-update.js",
"/js/main.a337a75d4abd0a14c156.hot-update.js": "/js/main.a337a75d4abd0a14c156.hot-update.js",
"/js/main.40d1dab8fa1b64701590.hot-update.js": "/js/main.40d1dab8fa1b64701590.hot-update.js",
"/js/main.7fc88aadbaf4dddd1177.hot-update.js": "/js/main.7fc88aadbaf4dddd1177.hot-update.js",
"/js/main.68350763e369b5ff2093.hot-update.js": "/js/main.68350763e369b5ff2093.hot-update.js",
"/js/main.6284a84d480e86837360.hot-update.js": "/js/main.6284a84d480e86837360.hot-update.js",
"/js/main.25ee0aa3ee03e3e8b38f.hot-update.js": "/js/main.25ee0aa3ee03e3e8b38f.hot-update.js",
"/js/main.2e26a22377d42ebff156.hot-update.js": "/js/main.2e26a22377d42ebff156.hot-update.js",
"/js/main.b59bbae58419a6b486cf.hot-update.js": "/js/main.b59bbae58419a6b486cf.hot-update.js",
"/js/main.d2355590570597337ecf.hot-update.js": "/js/main.d2355590570597337ecf.hot-update.js",
"/js/main.60d4eefa65e064d28377.hot-update.js": "/js/main.60d4eefa65e064d28377.hot-update.js",
"/js/main.4167e6ccc3b10d70c878.hot-update.js": "/js/main.4167e6ccc3b10d70c878.hot-update.js",
"/js/main.1d8dd28c32fe1ebb0f90.hot-update.js": "/js/main.1d8dd28c32fe1ebb0f90.hot-update.js",
"/js/main.ad773a1236560dfa16b9.hot-update.js": "/js/main.ad773a1236560dfa16b9.hot-update.js",
"/js/main.34c776e9045fb0e219c3.hot-update.js": "/js/main.34c776e9045fb0e219c3.hot-update.js",
"/js/main.092895cf0d85296ec513.hot-update.js": "/js/main.092895cf0d85296ec513.hot-update.js",
"/js/main.a46dde16305495525978.hot-update.js": "/js/main.a46dde16305495525978.hot-update.js",
"/js/main.b9df9d4300e51d62c760.hot-update.js": "/js/main.b9df9d4300e51d62c760.hot-update.js",
"/js/main.ef40152e201f13bc6b7b.hot-update.js": "/js/main.ef40152e201f13bc6b7b.hot-update.js",
"/js/main.03e94dd396114f5ce51f.hot-update.js": "/js/main.03e94dd396114f5ce51f.hot-update.js",
"/js/main.ae8691214086a1aafe6d.hot-update.js": "/js/main.ae8691214086a1aafe6d.hot-update.js",
"/js/main.42070d8db8abc6c57f08.hot-update.js": "/js/main.42070d8db8abc6c57f08.hot-update.js",
"/js/main.ff4a9feafb80b24156ea.hot-update.js": "/js/main.ff4a9feafb80b24156ea.hot-update.js",
"/js/main.a75b114c09bd29e14d0c.hot-update.js": "/js/main.a75b114c09bd29e14d0c.hot-update.js",
"/js/main.3c80fdca8d8a4151fec5.hot-update.js": "/js/main.3c80fdca8d8a4151fec5.hot-update.js",
"/js/main.ce2a2b97c841955d6004.hot-update.js": "/js/main.ce2a2b97c841955d6004.hot-update.js",
"/js/main.32b5fdecf37fed13cd9a.hot-update.js": "/js/main.32b5fdecf37fed13cd9a.hot-update.js",
"/js/main.7a89ccb6115f0faacdfb.hot-update.js": "/js/main.7a89ccb6115f0faacdfb.hot-update.js",
"/js/main.92699644dc4433d69518.hot-update.js": "/js/main.92699644dc4433d69518.hot-update.js",
"/js/main.95ab80867410adfb44d4.hot-update.js": "/js/main.95ab80867410adfb44d4.hot-update.js",
"/js/main.15ec5d8a6721629ca107.hot-update.js": "/js/main.15ec5d8a6721629ca107.hot-update.js",
"/js/main.7c08936d73cc17d9f314.hot-update.js": "/js/main.7c08936d73cc17d9f314.hot-update.js",
"/js/main.3d44fb777bb96f9cfdb7.hot-update.js": "/js/main.3d44fb777bb96f9cfdb7.hot-update.js",
"/js/main.98249452457878999097.hot-update.js": "/js/main.98249452457878999097.hot-update.js",
"/js/main.254701868eb16ecc7ceb.hot-update.js": "/js/main.254701868eb16ecc7ceb.hot-update.js",
"/js/main.73bb5ad5ec65301443bd.hot-update.js": "/js/main.73bb5ad5ec65301443bd.hot-update.js",
"/js/main.d3e2774f2e315b7c16b5.hot-update.js": "/js/main.d3e2774f2e315b7c16b5.hot-update.js",
"/js/main.e1c6df6a9c86ceb0f997.hot-update.js": "/js/main.e1c6df6a9c86ceb0f997.hot-update.js",
"/js/main.84e6dd621e31be103cb9.hot-update.js": "/js/main.84e6dd621e31be103cb9.hot-update.js",
"/js/main.f9b77ba27f8c37a3cab6.hot-update.js": "/js/main.f9b77ba27f8c37a3cab6.hot-update.js",
"/js/main.4568b1ac1065ffb6734b.hot-update.js": "/js/main.4568b1ac1065ffb6734b.hot-update.js",
"/js/main.34dd57888d1ba88b8b51.hot-update.js": "/js/main.34dd57888d1ba88b8b51.hot-update.js",
"/js/main.427a9203ec38e951d238.hot-update.js": "/js/main.427a9203ec38e951d238.hot-update.js",
"/js/main.c0ef7695de0e2fb4df8f.hot-update.js": "/js/main.c0ef7695de0e2fb4df8f.hot-update.js",
"/js/main.d1ac8bf7abe8c3cab86f.hot-update.js": "/js/main.d1ac8bf7abe8c3cab86f.hot-update.js",
"/js/main.89cd5452893cfa0c4306.hot-update.js": "/js/main.89cd5452893cfa0c4306.hot-update.js",
"/js/main.9efa7621633482f41475.hot-update.js": "/js/main.9efa7621633482f41475.hot-update.js",
"/js/main.64f6c551250c31f1a04f.hot-update.js": "/js/main.64f6c551250c31f1a04f.hot-update.js",
"/js/main.afa8179642bbf412e95a.hot-update.js": "/js/main.afa8179642bbf412e95a.hot-update.js",
"/js/main.5c4a761e3d1b8ae3e586.hot-update.js": "/js/main.5c4a761e3d1b8ae3e586.hot-update.js",
"/js/main.0ceed72f1427b5958022.hot-update.js": "/js/main.0ceed72f1427b5958022.hot-update.js",
"/js/main.6131813f3daf3dbf18df.hot-update.js": "/js/main.6131813f3daf3dbf18df.hot-update.js",
"/js/main.1d7089edabf59ca7143b.hot-update.js": "/js/main.1d7089edabf59ca7143b.hot-update.js",
"/js/main.835a0e8499a6e9ce3eb6.hot-update.js": "/js/main.835a0e8499a6e9ce3eb6.hot-update.js",
"/js/main.34ca6eeac2f66555a259.hot-update.js": "/js/main.34ca6eeac2f66555a259.hot-update.js",
"/js/main.b103b99817043bcec0ee.hot-update.js": "/js/main.b103b99817043bcec0ee.hot-update.js",
"/js/main.2f39160d1e959ee8065e.hot-update.js": "/js/main.2f39160d1e959ee8065e.hot-update.js",
"/js/main.9ebf2fb72f11bfa290af.hot-update.js": "/js/main.9ebf2fb72f11bfa290af.hot-update.js",
"/js/main.a55c90d56d628ca5983b.hot-update.js": "/js/main.a55c90d56d628ca5983b.hot-update.js",
"/js/main.c77fe61a6e467daa6312.hot-update.js": "/js/main.c77fe61a6e467daa6312.hot-update.js",
"/js/main.2b72fda2d2b42a05b446.hot-update.js": "/js/main.2b72fda2d2b42a05b446.hot-update.js",
"/js/main.ae606d26a4b1b2344ca2.hot-update.js": "/js/main.ae606d26a4b1b2344ca2.hot-update.js",
"/js/main.5bd37eed26fa598948d5.hot-update.js": "/js/main.5bd37eed26fa598948d5.hot-update.js",
"/js/main.130254a5160e0ef992a1.hot-update.js": "/js/main.130254a5160e0ef992a1.hot-update.js",
"/js/main.5fa2ead36e925d546d3d.hot-update.js": "/js/main.5fa2ead36e925d546d3d.hot-update.js",
"/js/main.dba558d979b0090f27dd.hot-update.js": "/js/main.dba558d979b0090f27dd.hot-update.js",
"/js/main.44e728d411a734bc1a30.hot-update.js": "/js/main.44e728d411a734bc1a30.hot-update.js",
"/js/main.9301a0253ea88d48eaec.hot-update.js": "/js/main.9301a0253ea88d48eaec.hot-update.js",
"/js/main.c32533dd170b4ad36995.hot-update.js": "/js/main.c32533dd170b4ad36995.hot-update.js",
"/js/main.70d54b5f4ad55603282c.hot-update.js": "/js/main.70d54b5f4ad55603282c.hot-update.js",
"/js/main.ae3ebc3222124628f432.hot-update.js": "/js/main.ae3ebc3222124628f432.hot-update.js",
"/js/main.cd30cc7c96f7330f1e28.hot-update.js": "/js/main.cd30cc7c96f7330f1e28.hot-update.js",
"/js/main.6d71eff38004e48494e6.hot-update.js": "/js/main.6d71eff38004e48494e6.hot-update.js",
"/js/main.e0368145878abbdceab2.hot-update.js": "/js/main.e0368145878abbdceab2.hot-update.js",
"/js/main.63bc86c9bdf936a03d56.hot-update.js": "/js/main.63bc86c9bdf936a03d56.hot-update.js"
}

View File

@@ -31,13 +31,13 @@
</template>
<script>
import MobileMenu from '@/components/VueFileManagerComponents/FilesView/MobileMenu'
import ShareCreate from '@/components/VueFileManagerComponents/Others/ShareCreate'
import ShareEdit from '@/components/VueFileManagerComponents/Others/ShareEdit'
import MoveItem from '@/components/VueFileManagerComponents/Others/MoveItem'
import Vignette from '@/components/VueFileManagerComponents/Others/Vignette'
import Sidebar from '@/components/VueFileManagerComponents/Sidebar/Sidebar'
import Alert from '@/components/VueFileManagerComponents/FilesView/Alert'
import MobileMenu from '@/components/FilesView/MobileMenu'
import ShareCreate from '@/components/Others/ShareCreate'
import ShareEdit from '@/components/Others/ShareEdit'
import MoveItem from '@/components/Others/MoveItem'
import Vignette from '@/components/Others/Vignette'
import Sidebar from '@/components/Sidebar/Sidebar'
import Alert from '@/components/FilesView/Alert'
import {ResizeSensor} from 'css-element-queries'
import { includes } from 'lodash'
import {mapGetters} from 'vuex'

View File

@@ -23,7 +23,7 @@
</template>
<script>
import ButtonBase from '@/components/VueFileManagerComponents/FilesView/ButtonBase'
import ButtonBase from '@/components/FilesView/ButtonBase'
import {events} from '@/bus'
export default {

View File

@@ -46,7 +46,7 @@
<div class="toolbar-button-wrapper">
<ToolbarButton
:source="preview"
action=""
action="Change Preview"
@click.native="$store.dispatch('changePreviewType')"
/>
<ToolbarButton
@@ -62,10 +62,10 @@
</template>
<script>
import ToolbarButtonUpload from '@/components/VueFileManagerComponents/FilesView/ToolbarButtonUpload'
import UploadProgress from '@/components/VueFileManagerComponents/FilesView/UploadProgress'
import ToolbarButton from '@/components/VueFileManagerComponents/FilesView/ToolbarButton'
import SearchBar from '@/components/VueFileManagerComponents/FilesView/SearchBar'
import ToolbarButtonUpload from '@/components/FilesView/ToolbarButtonUpload'
import UploadProgress from '@/components/FilesView/UploadProgress'
import ToolbarButton from '@/components/FilesView/ToolbarButton'
import SearchBar from '@/components/FilesView/SearchBar'
import {mapGetters} from 'vuex'
import {events} from '@/bus'
@@ -97,9 +97,6 @@
preview() {
return this.FilePreviewType === 'list' ? 'th' : 'th-list'
},
isTrash() {
return this.currentFolder.location === 'trash' || this.currentFolder.location === 'trash-root'
}
},
data() {
return {
@@ -130,7 +127,8 @@
events.$emit('items:delete')
},
createFolder() {
if (! this.isTrash) this.$createFolder()
if (! this.$isThisLocation(['trash', 'trash-root']))
this.$createFolder()
}
},
created() {

View File

@@ -35,8 +35,8 @@
</template>
<script>
import ButtonUpload from '@/components/VueFileManagerComponents/FilesView/ButtonUpload'
import Spinner from '@/components/VueFileManagerComponents/FilesView/Spinner'
import ButtonUpload from '@/components/FilesView/ButtonUpload'
import Spinner from '@/components/FilesView/Spinner'
import {mapGetters} from 'vuex'
export default {

View File

@@ -83,14 +83,14 @@
</template>
<script>
import MobileToolbar from '@/components/VueFileManagerComponents/FilesView/MobileToolbar'
import MobileActions from '@/components/VueFileManagerComponents/FilesView/MobileActions'
import FileInfoPanel from '@/components/VueFileManagerComponents/FilesView/FileInfoPanel'
import FileItemList from '@/components/VueFileManagerComponents/FilesView/FileItemList'
import FileItemGrid from '@/components/VueFileManagerComponents/FilesView/FileItemGrid'
import EmptyMessage from '@/components/VueFileManagerComponents/FilesView/EmptyMessage'
import EmptyPage from '@/components/VueFileManagerComponents/FilesView/EmptyPage'
import SearchBar from '@/components/VueFileManagerComponents/FilesView/SearchBar'
import MobileToolbar from '@/components/FilesView/MobileToolbar'
import MobileActions from '@/components/FilesView/MobileActions'
import FileInfoPanel from '@/components/FilesView/FileInfoPanel'
import FileItemList from '@/components/FilesView/FileItemList'
import FileItemGrid from '@/components/FilesView/FileItemGrid'
import EmptyMessage from '@/components/FilesView/EmptyMessage'
import EmptyPage from '@/components/FilesView/EmptyPage'
import SearchBar from '@/components/FilesView/SearchBar'
import {mapGetters} from 'vuex'
import {events} from '@/bus'

View File

@@ -65,8 +65,8 @@
</template>
<script>
import FilePreview from '@/components/VueFileManagerComponents/FilesView/FilePreview'
import CopyInput from '@/components/VueFileManagerComponents/Others/Forms/CopyInput'
import FilePreview from '@/components/FilesView/FilePreview'
import CopyInput from '@/components/Others/Forms/CopyInput'
import {mapGetters} from 'vuex'
import {events} from "@/bus"

View File

@@ -7,7 +7,7 @@
>
<!--Grid preview-->
<div
:draggable="! isDeleted"
:draggable="canDrag"
@dragstart="$emit('dragstart')"
@drop="
$emit('drop')
@@ -49,11 +49,17 @@
</b>
<div class="item-info">
<!--Shared Icon-->
<div v-if="$checkPermission('master') && data.shared" class="item-shared">
<FontAwesomeIcon class="shared-icon" icon="user-friends"/>
</div>
<!--Participant owner Icon-->
<div v-if="$checkPermission('master') && data.user_scope !== 'master'" class="item-shared">
<FontAwesomeIcon class="shared-icon" icon="user-edit"/>
</div>
<!--Filesize-->
<span v-if="! isFolder" class="item-size">{{ data.filesize }}</span>
@@ -65,8 +71,8 @@
</div>
<span @click.stop="showItemActions" class="show-actions" v-if="$isMobile()">
<FontAwesomeIcon icon="ellipsis-h" class="icon-action"></FontAwesomeIcon>
</span>
<FontAwesomeIcon icon="ellipsis-h" class="icon-action"></FontAwesomeIcon>
</span>
</div>
</div>
</template>
@@ -77,7 +83,7 @@
import {events} from '@/bus'
export default {
name: 'FileItem',
name: 'FileItemGrid',
props: ['data'],
computed: {
...mapGetters(['FilePreviewType']),
@@ -91,7 +97,10 @@
return this.data.type === 'image'
},
canEditName() {
return ! this.$isMobile() && ! this.$isThisLocation(['trash', 'trash-root']) && ! this.$checkPermission('visitor')
return !this.$isMobile() && !this.$isThisLocation(['trash', 'trash-root']) && !this.$checkPermission('visitor')
},
canDrag() {
return !this.isDeleted && this.$checkPermission(['master', 'editor'])
},
timeStamp() {
return this.data.deleted_at ? this.$t('item_thumbnail.deleted_at', this.data.deleted_at) : this.data.created_at
@@ -136,7 +145,7 @@
if (this.$isMobile() && this.isFolder) {
// Go to folder
if ( this.$isThisLocation('public') ) {
if (this.$isThisLocation('public')) {
this.$store.dispatch('browseShared', [this.data, false])
} else {
this.$store.dispatch('getFolder', [this.data, false])
@@ -170,7 +179,7 @@
if (this.isFolder) {
// Go to folder
if ( this.$isThisLocation('public') ) {
if (this.$isThisLocation('public')) {
this.$store.dispatch('browseShared', [this.data, false])
} else {
this.$store.dispatch('getFolder', [this.data, false])
@@ -364,6 +373,7 @@
height: 110px;
border-radius: 5px;
margin: 0 auto;
pointer-events: none;
}
.folder-icon {

View File

@@ -1,12 +1,13 @@
<template>
<div
@click.stop="clickedItem" @dblclick="goToItem"
class="file-wrapper"
@click.stop="clickedItem"
@dblclick="goToItem"
spellcheck="false"
>
<!--List preview-->
<div
:draggable="! isDeleted"
:draggable="canDrag"
@dragstart="$emit('dragstart')"
@drop="
$emit('drop')
@@ -84,7 +85,7 @@
import {events} from '@/bus'
export default {
name: 'FileItem',
name: 'FileItemList',
props: ['data'],
computed: {
...mapGetters(['FilePreviewType']),
@@ -100,6 +101,9 @@
canEditName() {
return ! this.$isMobile() && ! this.$isThisLocation(['trash', 'trash-root']) && ! this.$checkPermission('visitor')
},
canDrag() {
return ! this.isDeleted && this.$checkPermission(['master', 'editor'])
},
timeStamp() {
return this.data.deleted_at ? this.$t('item_thumbnail.deleted_at', {time: this.data.deleted_at}) : this.data.created_at
},
@@ -169,11 +173,7 @@
// Get target classname
let itemClass = e.target.className
if (
['name', 'icon', 'file-link', 'file-icon-text'].includes(
itemClass
)
)
if (['name', 'icon', 'file-link', 'file-icon-text'].includes(itemClass))
return
},
goToItem() {
@@ -380,6 +380,7 @@
border-radius: 5px;
width: 50px;
height: 50px;
pointer-events: none;
}
}

View File

@@ -12,7 +12,7 @@
</div>
<!--ContextMenu for Base location with MASTER permission-->
<div v-if="$isThisLocation(['base', 'shared']) && $checkPermission(['master', 'editor'])" class="mobile-actions">
<div v-if="$isThisLocation(['base', 'shared', 'public']) && $checkPermission(['master', 'editor'])" class="mobile-actions">
<MobileActionButton @click.native="createFolder" icon="folder-plus">
{{ $t('context_menu.add_folder') }}
</MobileActionButton>
@@ -25,7 +25,7 @@
</div>
<!--ContextMenu for Base location with VISITOR permission-->
<div v-if="$isThisLocation(['base', 'shared']) && $checkPermission('visitor')" class="mobile-actions">
<div v-if="$isThisLocation(['base', 'shared', 'public']) && $checkPermission('visitor')" class="mobile-actions">
<MobileActionButton @click.native="switchPreview" :icon="previewIcon">
{{ previewText }}
</MobileActionButton>
@@ -37,9 +37,9 @@
</template>
<script>
import MobileActionButtonUpload from '@/components/VueFileManagerComponents/FilesView/MobileActionButtonUpload'
import MobileActionButton from '@/components/VueFileManagerComponents/FilesView/MobileActionButton'
import UploadProgress from '@/components/VueFileManagerComponents/FilesView/UploadProgress'
import MobileActionButtonUpload from '@/components/FilesView/MobileActionButtonUpload'
import MobileActionButton from '@/components/FilesView/MobileActionButton'
import UploadProgress from '@/components/FilesView/UploadProgress'
import {mapGetters} from 'vuex'
import {debounce} from 'lodash'
import {events} from '@/bus'

View File

@@ -64,7 +64,7 @@
</ul>
<!--Mobile for Base location with EDITOR permission-->
<ul v-if="$isThisLocation(['base']) && $checkPermission('editor')" class="menu-options">
<ul v-if="$isThisLocation(['base', 'public']) && $checkPermission('editor')" class="menu-options">
<li class="menu-option" @click="renameItem" v-if="fileInfoDetail">
{{ $t('context_menu.rename') }}
</li>
@@ -77,7 +77,7 @@
</ul>
<!--Mobile for Base location with VISITOR permission-->
<ul v-if="$isThisLocation(['base']) && $checkPermission('visitor')" class="menu-options">
<ul v-if="$isThisLocation(['base', 'public']) && $checkPermission('visitor')" class="menu-options">
<li class="menu-option" @click="downloadItem" v-if="! isFolder">
{{ $t('context_menu.download') }}
</li>

View File

@@ -14,8 +14,8 @@
<div class="directory-name">{{ directoryName }}</div>
<!--More Actions-->
<div class="more-actions-button" @click="showSidebarMenu">
<div class="tap-area">
<div class="more-actions-button">
<div class="tap-area" @click="showSidebarMenu" v-if="$checkPermission('master')">
<FontAwesomeIcon icon="bars" v-if="isSmallAppSize"></FontAwesomeIcon>
</div>
</div>
@@ -23,9 +23,9 @@
</template>
<script>
import ToolbarButtonUpload from '@/components/VueFileManagerComponents/FilesView/ToolbarButtonUpload'
import ToolbarButton from '@/components/VueFileManagerComponents/FilesView/ToolbarButton'
import SearchBar from '@/components/VueFileManagerComponents/FilesView/SearchBar'
import ToolbarButtonUpload from '@/components/FilesView/ToolbarButtonUpload'
import ToolbarButton from '@/components/FilesView/ToolbarButton'
import SearchBar from '@/components/FilesView/SearchBar'
import {mapGetters} from 'vuex'
import {events} from '@/bus'

View File

@@ -10,7 +10,7 @@
</template>
<script>
import ProgressBar from '@/components/VueFileManagerComponents/FilesView/ProgressBar'
import ProgressBar from '@/components/FilesView/ProgressBar'
import {mapGetters} from 'vuex'
export default {

View File

@@ -4,15 +4,15 @@
<PopupHeader :title="$t('popup_move_item.title')" />
<!--Content-->
<PopupContent type="height-limited" v-if="app && pickedItem">
<PopupContent type="height-limited" v-if="pickedItem">
<!--Show Spinner when loading folders-->
<Spinner v-if="isLoadingTree"/>
<!--Folder tree-->
<div v-if="! isLoadingTree">
<div v-if="! isLoadingTree && navigation">
<ThumbnailItem class="item-thumbnail" :item="pickedItem" info="location"/>
<TreeMenu :depth="1" :nodes="items" v-for="items in app.folders" :key="items.unique_id"/>
<TreeMenu :depth="1" :nodes="items" v-for="items in navigation" :key="items.unique_id"/>
</div>
</PopupContent>
@@ -35,14 +35,14 @@
</template>
<script>
import PopupWrapper from '@/components/VueFileManagerComponents/Others/Popup/PopupWrapper'
import PopupActions from '@/components/VueFileManagerComponents/Others/Popup/PopupActions'
import PopupContent from '@/components/VueFileManagerComponents/Others/Popup/PopupContent'
import PopupHeader from '@/components/VueFileManagerComponents/Others/Popup/PopupHeader'
import ThumbnailItem from '@/components/VueFileManagerComponents/Others/ThumbnailItem'
import ButtonBase from '@/components/VueFileManagerComponents/FilesView/ButtonBase'
import Spinner from '@/components/VueFileManagerComponents/FilesView/Spinner'
import TreeMenu from '@/components/VueFileManagerComponents/Others/TreeMenu'
import PopupWrapper from '@/components/Others/Popup/PopupWrapper'
import PopupActions from '@/components/Others/Popup/PopupActions'
import PopupContent from '@/components/Others/Popup/PopupContent'
import PopupHeader from '@/components/Others/Popup/PopupHeader'
import ThumbnailItem from '@/components/Others/ThumbnailItem'
import ButtonBase from '@/components/FilesView/ButtonBase'
import Spinner from '@/components/FilesView/Spinner'
import TreeMenu from '@/components/Others/TreeMenu'
import {mapGetters} from 'vuex'
import {events} from '@/bus'
@@ -59,7 +59,7 @@
Spinner,
},
computed: {
...mapGetters(['app']),
...mapGetters(['navigation']),
},
data() {
return {

View File

@@ -65,16 +65,16 @@
</template>
<script>
import PopupWrapper from '@/components/VueFileManagerComponents/Others/Popup/PopupWrapper'
import PopupActions from '@/components/VueFileManagerComponents/Others/Popup/PopupActions'
import PopupContent from '@/components/VueFileManagerComponents/Others/Popup/PopupContent'
import PopupWrapper from '@/components/Others/Popup/PopupWrapper'
import PopupActions from '@/components/Others/Popup/PopupActions'
import PopupContent from '@/components/Others/Popup/PopupContent'
import {ValidationProvider, ValidationObserver} from 'vee-validate/dist/vee-validate.full'
import PopupHeader from '@/components/VueFileManagerComponents/Others/Popup/PopupHeader'
import SwitchInput from '@/components/VueFileManagerComponents/Others/Forms/SwitchInput'
import SelectInput from '@/components/VueFileManagerComponents/Others/Forms/SelectInput'
import ThumbnailItem from '@/components/VueFileManagerComponents/Others/ThumbnailItem'
import CopyInput from '@/components/VueFileManagerComponents/Others/Forms/CopyInput'
import ButtonBase from '@/components/VueFileManagerComponents/FilesView/ButtonBase'
import PopupHeader from '@/components/Others/Popup/PopupHeader'
import SwitchInput from '@/components/Others/Forms/SwitchInput'
import SelectInput from '@/components/Others/Forms/SelectInput'
import ThumbnailItem from '@/components/Others/ThumbnailItem'
import CopyInput from '@/components/Others/Forms/CopyInput'
import ButtonBase from '@/components/FilesView/ButtonBase'
import {required} from 'vee-validate/dist/rules'
import {mapGetters} from 'vuex'
import {events} from '@/bus'

View File

@@ -67,17 +67,17 @@
</template>
<script>
import PopupWrapper from '@/components/VueFileManagerComponents/Others/Popup/PopupWrapper'
import PopupActions from '@/components/VueFileManagerComponents/Others/Popup/PopupActions'
import PopupContent from '@/components/VueFileManagerComponents/Others/Popup/PopupContent'
import PopupWrapper from '@/components/Others/Popup/PopupWrapper'
import PopupActions from '@/components/Others/Popup/PopupActions'
import PopupContent from '@/components/Others/Popup/PopupContent'
import {ValidationProvider, ValidationObserver} from 'vee-validate/dist/vee-validate.full'
import PopupHeader from '@/components/VueFileManagerComponents/Others/Popup/PopupHeader'
import SwitchInput from '@/components/VueFileManagerComponents/Others/Forms/SwitchInput'
import SelectInput from '@/components/VueFileManagerComponents/Others/Forms/SelectInput'
import ThumbnailItem from '@/components/VueFileManagerComponents/Others/ThumbnailItem'
import ActionButton from '@/components/VueFileManagerComponents/Others/ActionButton'
import CopyInput from '@/components/VueFileManagerComponents/Others/Forms/CopyInput'
import ButtonBase from '@/components/VueFileManagerComponents/FilesView/ButtonBase'
import PopupHeader from '@/components/Others/Popup/PopupHeader'
import SwitchInput from '@/components/Others/Forms/SwitchInput'
import SelectInput from '@/components/Others/Forms/SelectInput'
import ThumbnailItem from '@/components/Others/ThumbnailItem'
import ActionButton from '@/components/Others/ActionButton'
import CopyInput from '@/components/Others/Forms/CopyInput'
import ButtonBase from '@/components/FilesView/ButtonBase'
import {required} from 'vee-validate/dist/rules'
import {mapGetters} from 'vuex'
import {events} from '@/bus'

View File

@@ -13,7 +13,7 @@
</template>
<script>
import TreeMenu from '@/components/VueFileManagerComponents/Others/TreeMenu'
import TreeMenu from '@/components/Others/TreeMenu'
import {events} from "@/bus"
export default {

View File

@@ -73,11 +73,11 @@
</template>
<script>
import FileListItemThumbnail from '@/components/VueFileManagerComponents/Sidebar/FileListItemThumbnail'
import UserHeadline from '@/components/VueFileManagerComponents/Sidebar/UserHeadline'
import ButtonBase from '@/components/VueFileManagerComponents/FilesView/ButtonBase'
import StorageSize from '@/components/VueFileManagerComponents/Sidebar/StorageSize'
import TextLabel from '@/components/VueFileManagerComponents/Others/TextLabel'
import FileListItemThumbnail from '@/components/Sidebar/FileListItemThumbnail'
import UserHeadline from '@/components/Sidebar/UserHeadline'
import ButtonBase from '@/components/FilesView/ButtonBase'
import StorageSize from '@/components/Sidebar/StorageSize'
import TextLabel from '@/components/Others/TextLabel'
import {mapGetters} from 'vuex'
import {events} from '@/bus'

View File

@@ -9,7 +9,7 @@
</template>
<script>
import ProgressBar from '@/components/VueFileManagerComponents/FilesView/ProgressBar'
import ProgressBar from '@/components/FilesView/ProgressBar'
import { mapGetters } from 'vuex'
export default {

View File

@@ -5,7 +5,6 @@ import store from '@/store'
import Index from './views/Auth/SignIn'
import SignUp from './views/Auth/SignUp'
import SharedContent from './views/Shared/SharedContent'
import VerifyByPassword from './views/Shared/VerifyByPassword'
import ForgottenPassword from './views/Auth/ForgottenPassword'
import CreateNewPassword from './views/Auth/CreateNewPassword'

View File

@@ -1,6 +1,6 @@
const defaultState = {
fileInfoPanelVisible: localStorage.getItem('file_info_visibility') == 'true' || false,
FilePreviewType: localStorage.getItem('FilePreviewType') || 'list',
FilePreviewType: localStorage.getItem('preview_type') || 'list',
appSize: undefined,
config: undefined,
}
@@ -20,8 +20,8 @@ const actions = {
} else {
if ( this.$isThisLocation('public') ) {
dispatch('browseShared', [this.currentFolder(), false, true])
if ( getters.currentFolder.location === 'public' ) {
dispatch('browseShared', [getters.currentFolder, false, true])
} else {
dispatch('getFolder', [getters.currentFolder, false, true])
}

View File

@@ -1,7 +1,7 @@
import axios from 'axios'
import {events} from '@/bus'
import router from '@/router'
import { includes } from 'lodash'
import {includes} from 'lodash'
import i18n from '@/i18n/index'
const defaultState = {
@@ -11,6 +11,7 @@ const defaultState = {
homeDirectory: undefined,
uploadingFileProgress: 0,
filesViewWidth: undefined,
navigation: undefined,
isSearching: false,
browseHistory: [],
isLoading: true,
@@ -22,7 +23,7 @@ const actions = {
events.$emit('show:content')
// Go to files view
if ( ! includes(['Files', 'SharedContent'], router.currentRoute.name) ) {
if (!includes(['Files', 'SharedContent'], router.currentRoute.name)) {
router.push({name: 'Files'})
}
@@ -42,7 +43,7 @@ const actions = {
location: folder.deleted_at || folder.location === 'trash' ? 'trash' : 'base'
}
let url = currentFolder.location === 'trash' ?'/folders/' + currentFolder.unique_id + '?trash=true' : '/folders/' + currentFolder.unique_id
let url = currentFolder.location === 'trash' ? '/folders/' + currentFolder.unique_id + '?trash=true' : '/folders/' + currentFolder.unique_id
axios
.get(context.getters.api + url)
@@ -76,9 +77,9 @@ const actions = {
router.push({name: 'Files'})
}
if (! back) context.commit('FLUSH_BROWSER_HISTORY')
context.commit('FLUSH_DATA')
context.commit('LOADING_STATE', true)
if (!back) context.commit('FLUSH_BROWSER_HISTORY')
context.commit('FLUSH_DATA')
context.commit('LOADING_STATE', true)
// Create shared object for history
let trash = {
@@ -113,9 +114,9 @@ const actions = {
router.push({name: 'Files'})
}
if (! back) context.commit('FLUSH_BROWSER_HISTORY')
context.commit('FLUSH_DATA')
context.commit('LOADING_STATE', true)
if (!back) context.commit('FLUSH_BROWSER_HISTORY')
context.commit('FLUSH_DATA')
context.commit('LOADING_STATE', true)
// Create trash object for history
let trash = {
@@ -177,9 +178,46 @@ const actions = {
})
})
},
getFolderTree: ({commit, getters}) => {
return new Promise((resolve, reject) => {
// Get route
let route = undefined
if (getters.sharedDetail && getters.sharedDetail.protected)
route = '/api/navigation/private'
else if (getters.sharedDetail && ! getters.sharedDetail.protected)
route = '/api/navigation/public/' + router.currentRoute.params.token
else
route = '/api/navigation'
axios
.get(route)
.then(response => {
resolve(response)
commit('UPDATE_FOLDER_TREE', response.data)
})
.catch((error) => {
reject(error)
// Show error message
events.$emit('alert:open', {
title: i18n.t('popup_error.title'),
message: i18n.t('popup_error.message'),
})
})
})
},
}
const mutations = {
UPDATE_FOLDER_TREE(state, tree) {
state.navigation = tree
},
LOADING_STATE(state, val) {
state.isLoading = val
},
@@ -274,6 +312,7 @@ const getters = {
currentFolder: state => state.currentFolder,
browseHistory: state => state.browseHistory,
isSearching: state => state.isSearching,
navigation: state => state.navigation,
isLoading: state => state.isLoading,
data: state => state.data,
}

View File

@@ -1,11 +1,19 @@
import axios from 'axios'
import {events} from '@/bus'
import i18n from '@/i18n/index'
import router from '@/router'
import {events} from '@/bus'
import axios from 'axios'
const actions = {
moveItem: ({commit, getters}, [item_from, to_item]) => {
// Get route
let route = getters.sharedDetail && ! getters.sharedDetail.protected
? '/api/move/' + item_from.unique_id + '/public/' + router.currentRoute.params.token
: '/api/move/' + item_from.unique_id
axios
.patch(getters.api + '/move-item/' + item_from.unique_id, {
.patch(route, {
from_type: item_from.type,
to_unique_id: to_item.unique_id
})
@@ -16,11 +24,15 @@ const actions = {
.catch(() => isSomethingWrong())
},
createFolder: ({commit, getters}, folderName) => {
const parent_id = getters.currentFolder ? getters.currentFolder.unique_id : 0
// Get route
let route = getters.sharedDetail && ! getters.sharedDetail.protected
? '/api/create-folder/public/' + router.currentRoute.params.token
: '/api/create-folder'
axios
.post(getters.api + '/create-folder', {
parent_id: parent_id,
.post(route, {
parent_id: getters.currentFolder.unique_id,
name: folderName
})
.then(response => {
@@ -34,8 +46,13 @@ const actions = {
if (getters.permission === 'master' && data.type === 'folder')
commit('UPDATE_NAME_IN_FAVOURITES', data)
// Get route
let route = getters.sharedDetail && ! getters.sharedDetail.protected
? '/api/rename-item/' + data.unique_id + '/public/' + router.currentRoute.params.token
: '/api/rename-item/' + data.unique_id
axios
.patch(getters.api + '/rename-item/' + data.unique_id, {
.patch(route, {
name: data.name,
type: data.type,
})
@@ -46,8 +63,14 @@ const actions = {
},
uploadFiles: ({commit, getters}, files) => {
return new Promise((resolve, reject) => {
// Get route
let route = getters.sharedDetail && ! getters.sharedDetail.protected
? '/api/upload/public/' + router.currentRoute.params.token
: '/api/upload'
axios
.post(getters.api + '/upload-file', files, {
.post(route, files, {
headers: {
'Content-Type': 'multipart/form-data'
},
@@ -114,8 +137,13 @@ const actions = {
// Remove file preview
commit('CLEAR_FILEINFO_DETAIL')
// Get route
let route = getters.sharedDetail && ! getters.sharedDetail.protected
? '/api/remove-item/' + data.unique_id + '/public/' + router.currentRoute.params.token
: '/api/remove-item/' + data.unique_id
axios
.delete(getters.api + '/remove-item/' + data.unique_id, {
.delete(route, {
data: {
type: data.type,
force_delete: data.deleted_at ? true : false

View File

@@ -68,37 +68,12 @@ const actions = {
})
})
},
getFolderTree: (context) => {
return new Promise((resolve, reject) => {
axios
.get(context.getters.api + '/folder-tree')
.then(response => {
resolve(response)
context.commit('UPDATE_FOLDER_TREE', response.data)
})
.catch((error) => {
reject(error)
// Show error message
events.$emit('alert:open', {
title: i18n.t('popup_error.title'),
message: i18n.t('popup_error.message'),
})
})
})
},
}
const mutations = {
RETRIEVE_APP_DATA(state, app) {
state.app = app
},
UPDATE_FOLDER_TREE(state, tree) {
state.app.folders = tree
},
SET_PERMISSION(state, role) {
state.permission = role
},

View File

@@ -66,10 +66,10 @@
</template>
<script>
import AuthContentWrapper from '@/components/VueFileManagerComponents/Auth/AuthContentWrapper'
import AuthContentWrapper from '@/components/Auth/AuthContentWrapper'
import {ValidationProvider, ValidationObserver} from 'vee-validate/dist/vee-validate.full'
import AuthContent from '@/components/VueFileManagerComponents/Auth/AuthContent'
import AuthButton from '@/components/VueFileManagerComponents/Auth/AuthButton'
import AuthContent from '@/components/Auth/AuthContent'
import AuthButton from '@/components/Auth/AuthButton'
import {required} from 'vee-validate/dist/rules'
import {mapGetters} from 'vuex'
import axios from 'axios'

View File

@@ -42,10 +42,10 @@
</template>
<script>
import AuthContentWrapper from '@/components/VueFileManagerComponents/Auth/AuthContentWrapper'
import AuthContentWrapper from '@/components/Auth/AuthContentWrapper'
import {ValidationProvider, ValidationObserver} from 'vee-validate/dist/vee-validate.full'
import AuthContent from '@/components/VueFileManagerComponents/Auth/AuthContent'
import AuthButton from '@/components/VueFileManagerComponents/Auth/AuthButton'
import AuthContent from '@/components/Auth/AuthContent'
import AuthButton from '@/components/Auth/AuthButton'
import {required} from 'vee-validate/dist/rules'
import {mapGetters} from 'vuex'
import axios from 'axios'

View File

@@ -60,10 +60,10 @@
</template>
<script>
import AuthContentWrapper from '@/components/VueFileManagerComponents/Auth/AuthContentWrapper'
import AuthContentWrapper from '@/components/Auth/AuthContentWrapper'
import {ValidationProvider, ValidationObserver} from 'vee-validate/dist/vee-validate.full'
import AuthContent from '@/components/VueFileManagerComponents/Auth/AuthContent'
import AuthButton from '@/components/VueFileManagerComponents/Auth/AuthButton'
import AuthContent from '@/components/Auth/AuthContent'
import AuthButton from '@/components/Auth/AuthButton'
import {required} from 'vee-validate/dist/rules'
import {mapGetters} from 'vuex'
import axios from 'axios'

View File

@@ -66,10 +66,10 @@
</template>
<script>
import AuthContentWrapper from '@/components/VueFileManagerComponents/Auth/AuthContentWrapper'
import AuthContentWrapper from '@/components/Auth/AuthContentWrapper'
import {ValidationProvider, ValidationObserver} from 'vee-validate/dist/vee-validate.full'
import AuthContent from '@/components/VueFileManagerComponents/Auth/AuthContent'
import AuthButton from '@/components/VueFileManagerComponents/Auth/AuthButton'
import AuthContent from '@/components/Auth/AuthContent'
import AuthButton from '@/components/Auth/AuthButton'
import {required} from 'vee-validate/dist/rules'
import {mapGetters} from 'vuex'
import axios from 'axios'

View File

@@ -7,9 +7,9 @@
</template>
<script>
import DesktopToolbar from '@/components/VueFileManagerComponents/FilesView/DesktopToolbar'
import FileBrowser from '@/components/VueFileManagerComponents/FilesView/FileBrowser'
import ContextMenu from '@/components/VueFileManagerComponents/FilesView/ContextMenu'
import DesktopToolbar from '@/components/FilesView/DesktopToolbar'
import FileBrowser from '@/components/FilesView/FileBrowser'
import ContextMenu from '@/components/FilesView/ContextMenu'
import {ResizeSensor} from 'css-element-queries'
import {mapGetters} from 'vuex'
import {events} from '@/bus'

View File

@@ -74,10 +74,10 @@
<script>
import {ValidationProvider, ValidationObserver} from 'vee-validate/dist/vee-validate.full'
import UserImageInput from '@/components/VueFileManagerComponents/Others/UserImageInput'
import ButtonBase from '@/components/VueFileManagerComponents/FilesView/ButtonBase'
import PageHeader from '@/components/VueFileManagerComponents/Others/PageHeader'
import ThemeLabel from '@/components/VueFileManagerComponents/Others/ThemeLabel'
import UserImageInput from '@/components/Others/UserImageInput'
import ButtonBase from '@/components/FilesView/ButtonBase'
import PageHeader from '@/components/Others/PageHeader'
import ThemeLabel from '@/components/Others/ThemeLabel'
import {required} from 'vee-validate/dist/rules'
import {mapGetters} from 'vuex'
import {debounce} from 'lodash'

View File

@@ -44,6 +44,9 @@
</div>
<div v-if="sharedDetail.type === 'folder'" @contextmenu.prevent.capture="contextMenu($event, undefined)" @click="fileViewClick">
<!--Move item setup-->
<MoveItem />
<!--Mobile Menu-->
<MobileMenu/>
@@ -61,18 +64,19 @@
</template>
<script>
import DesktopToolbar from '@/components/VueFileManagerComponents/FilesView/DesktopToolbar'
import DesktopToolbar from '@/components/FilesView/DesktopToolbar'
import {ValidationProvider, ValidationObserver} from 'vee-validate/dist/vee-validate.full'
import FileItemGrid from '@/components/VueFileManagerComponents/FilesView/FileItemGrid'
import FileBrowser from '@/components/VueFileManagerComponents/FilesView/FileBrowser'
import ContextMenu from '@/components/VueFileManagerComponents/FilesView/ContextMenu'
import ButtonBase from '@/components/VueFileManagerComponents/FilesView/ButtonBase'
import MobileMenu from '@/components/VueFileManagerComponents/FilesView/MobileMenu'
import AuthContent from '@/components/VueFileManagerComponents/Auth/AuthContent'
import AuthButton from '@/components/VueFileManagerComponents/Auth/AuthButton'
import Spinner from '@/components/VueFileManagerComponents/FilesView/Spinner'
import Vignette from '@/components/VueFileManagerComponents/Others/Vignette'
import Alert from '@/components/VueFileManagerComponents/FilesView/Alert'
import FileItemGrid from '@/components/FilesView/FileItemGrid'
import FileBrowser from '@/components/FilesView/FileBrowser'
import ContextMenu from '@/components/FilesView/ContextMenu'
import ButtonBase from '@/components/FilesView/ButtonBase'
import MobileMenu from '@/components/FilesView/MobileMenu'
import AuthContent from '@/components/Auth/AuthContent'
import AuthButton from '@/components/Auth/AuthButton'
import Spinner from '@/components/FilesView/Spinner'
import MoveItem from '@/components/Others/MoveItem'
import Vignette from '@/components/Others/Vignette'
import Alert from '@/components/FilesView/Alert'
import {required} from 'vee-validate/dist/rules'
import {ResizeSensor} from 'css-element-queries'
import {mapGetters} from 'vuex'
@@ -92,6 +96,7 @@
AuthButton,
MobileMenu,
ButtonBase,
MoveItem,
required,
Vignette,
Spinner,

View File

@@ -1,88 +0,0 @@
<template>
<AuthContentWrapper ref="auth">
<!--Verify share link by password-->
<AuthContent name="password" :visible="true">
</AuthContent>
</AuthContentWrapper>
</template>
<script>
import AuthContentWrapper from '@/components/VueFileManagerComponents/Auth/AuthContentWrapper'
import {ValidationProvider, ValidationObserver} from 'vee-validate/dist/vee-validate.full'
import AuthContent from '@/components/VueFileManagerComponents/Auth/AuthContent'
import AuthButton from '@/components/VueFileManagerComponents/Auth/AuthButton'
import {required} from 'vee-validate/dist/rules'
import {mapGetters} from 'vuex'
import axios from 'axios'
export default {
name: 'SharedContent',
components: {
AuthContentWrapper,
ValidationProvider,
ValidationObserver,
AuthContent,
AuthButton,
required,
},
computed: {
...mapGetters(['config']),
},
data() {
return {
checkedAccount: undefined,
password: 'tvojpenis',
isLoading: false,
}
},
methods: {
async sharedProtected() {
// Validate fields
const isValid = await this.$refs.sharedProtected.validate();
if (!isValid) return;
// Start loading
this.isLoading = true
// Send request to get verify account
axios
.post('/api/shared/authenticate/' + this.$route.params.token, {
password: this.password
})
.then(response => {
// End loading
this.isLoading = false
// Commit shared item options
this.$store.commit('SET_PERMISSION', response.data.permission)
// Redirect to file browser page
this.$router.push({name: 'SharedContent', params: {token: this.$route.params.token}})
})
.catch(error => {
if (error.response.status == 401) {
this.$refs.sharedProtected.setErrors({
'Password': [error.response.data.message]
});
}
// End loading
this.isLoading = false
})
},
},
}
</script>
<style scoped lang="scss">
@import "@assets/app.scss";
@import '@assets/vue-file-manager/_forms';
@import '@assets/vue-file-manager/_auth';
</style>

View File

@@ -19,6 +19,20 @@
// Public routes
Route::group(['middleware' => ['api']], function () {
// Edit Functions
Route::delete('/remove-item/{unique_id}/public/{token}', 'FileFunctions\EditItemsController@guest_delete_item');
Route::patch('/rename-item/{unique_id}/public/{token}', 'FileFunctions\EditItemsController@guest_rename_item');
Route::post('/create-folder/public/{token}', 'FileFunctions\EditItemsController@guest_create_folder');
Route::patch('/move/{unique_id}/public/{token}', 'FileFunctions\EditItemsController@guest_move');
Route::post('/upload/public/{token}', 'FileFunctions\EditItemsController@guest_upload');
// Sharing page browsing
Route::get('/folders/{unique_id}/public/{token}', 'Sharing\FileSharingController@get_public_folders');
Route::get('/navigation/public/{token}', 'Sharing\FileSharingController@get_public_navigation_tree');
Route::post('/shared/authenticate/{token}', 'Sharing\FileSharingController@authenticate');
Route::get('/files/{token}/public', 'Sharing\FileSharingController@file_public');
Route::get('/shared/{token}', 'FileFunctions\ShareController@show');
// User reset password
Route::post('/password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');
Route::post('/password/reset', 'Auth\ResetPasswordController@reset');
@@ -27,12 +41,6 @@ Route::group(['middleware' => ['api']], function () {
Route::post('/user/check', 'Auth\AuthController@check_account');
Route::post('/user/register', 'Auth\AuthController@register');
Route::post('/user/login', 'Auth\AuthController@login');
// Sharing
Route::get('/folders/{unique_id}/public/{token}', 'Sharing\FileSharingController@get_public_folders');
Route::post('/shared/authenticate/{token}', 'Sharing\FileSharingController@authenticate');
Route::get('/files/{token}/public', 'Sharing\FileSharingController@file_public');
Route::get('/shared/{token}', 'FileFunctions\ShareController@show');
});
// User master Routes
@@ -45,15 +53,12 @@ Route::group(['middleware' => ['auth:api', 'auth.cookie', 'scope:master']], func
// Browse
Route::get('/file-detail/{unique_id}', 'FileBrowser\BrowseController@file_detail');
Route::get('/navigation', 'FileBrowser\BrowseController@navigation_tree');
Route::get('/folders/{unique_id}', 'FileBrowser\BrowseController@folder');
Route::get('/folder-tree', 'FileBrowser\BrowseController@folder_tree');
Route::get('/shared-all', 'FileBrowser\BrowseController@shared');
Route::get('/search', 'FileBrowser\BrowseController@search');
Route::get('/trash', 'FileBrowser\BrowseController@trash');
// Edit functions
Route::patch('/move-item/{unique_id}', 'FileFunctions\EditItemsController@move_item');
// Trash
Route::patch('/restore-item/{unique_id}', 'FileFunctions\TrashController@restore');
Route::delete('/empty-trash', 'FileFunctions\TrashController@clear');
@@ -76,6 +81,7 @@ Route::group(['middleware' => ['auth:api', 'auth.cookie', 'scope:visitor,editor'
// Browse folders & files
Route::get('/folders/{unique_id}/private', 'Sharing\FileSharingController@get_private_folders');
Route::get('/navigation/private', 'Sharing\FileSharingController@get_private_navigation_tree');
Route::get('/files/private', 'Sharing\FileSharingController@file_private');
});
@@ -83,8 +89,9 @@ Route::group(['middleware' => ['auth:api', 'auth.cookie', 'scope:visitor,editor'
Route::group(['middleware' => ['auth:api', 'auth.cookie', 'scope:master,editor']], function () {
// Edit items
Route::delete('/remove-item/{unique_id}', 'FileFunctions\EditItemsController@delete_item');
Route::patch('/rename-item/{unique_id}', 'FileFunctions\EditItemsController@rename_item');
Route::post('/create-folder', 'FileFunctions\EditItemsController@create_folder');
Route::post('/upload-file', 'FileFunctions\EditItemsController@upload_item');
Route::delete('/remove-item/{unique_id}', 'FileFunctions\EditItemsController@user_delete_item');
Route::patch('/rename-item/{unique_id}', 'FileFunctions\EditItemsController@user_rename_item');
Route::post('/create-folder', 'FileFunctions\EditItemsController@user_create_folder');
Route::patch('/move/{unique_id}', 'FileFunctions\EditItemsController@user_move');
Route::post('/upload', 'FileFunctions\EditItemsController@user_upload');
});