filesysteme

This commit is contained in:
Mathieu Lagacé
2020-09-12 10:13:21 -04:00
parent ae00c9e7e0
commit b3f471e6e9
21 changed files with 952 additions and 1221 deletions

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Contracts\Filesystem\Cloud;
class initDrive extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'drive:init';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Initialize drive';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
\Storage::cloud()->createDir('Systeme');
\Storage::cloud()->createDir('Systeme/Fichier');
\Storage::cloud()->createDir('Systeme/Fichier/PlanDeCours');
\Storage::cloud()->createDir('Systeme/Fichier/MessageDeLaSemaine');
\Storage::cloud()->createDir('Prive');
\Storage::cloud()->createDir('Prive/Cadet');
\Storage::cloud()->createDir('Prive/ETAMAS');
\Storage::cloud()->createDir('Prive/Officier');
\Storage::cloud()->createDir('Prive/Staff');
\Storage::cloud()->createDir('Prive/Staff/Guide');
\Storage::cloud()->createDir('Prive/Staff/Instruction');
\Storage::cloud()->createDir('Publique');
\Storage::cloud()->createDir('Publique/Fichier');
\Storage::cloud()->createDir('Publique/Image');
return "Drive is initialized";
}
}

View File

@@ -41,12 +41,21 @@ class FilesController extends Controller
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
* @param string $id
* @return void
*/
public function show($id)
public function show($path)
{
//
$file_rules = \DB::table('acl_rules')->where('path','=',$path)->get()->all();
if ($file_rules != []) {
dd($file_rules);
}
dd(dirname($path));
$path_rules = \DB::table('acl_rules')->where('path','=',dirname($path))->get()->all();
if ($path_rules != []) {
}
return abort(404);
}
/**

View File

@@ -0,0 +1,72 @@
<?php
namespace App\Services;
use Alexusmai\LaravelFileManager\Services\ACLService\ACLRepository;
/**
* Class DBACLRepository
*
* @package Alexusmai\LaravelFileManager\Services\ACLService
*/
class DBACLRepository implements ACLRepository
{
/**
* Get user ID
*
* @return mixed
*/
public function getUserID()
{
return \Auth::id();
}
public function getUserRank()
{
return \Auth::user()->rank_id;
}
public function getUserJobs()
{
return \Auth::user()->job_id;
}
/**
* Get ACL rules list for user
*
* @return array
*/
public function getRules(): array
{
$rules = \DB::table('acl_rules')
->where('user_id', $this->getUserID())
->get(['disk', 'path', 'access'])
->map(function ($item) {
return get_object_vars($item);
})
->all();
$rank_rules = \DB::table('acl_rules')
->where('rank_id', $this->getUserRank())
->get(['disk', 'path', 'access'])
->map(function ($item) {
return get_object_vars($item);
})
->all();
$job_rules = \DB::table('acl_rules')
->where('job_id', $this->getUserJobs())
->get(['disk', 'path', 'access'])
->map(function ($item) {
return get_object_vars($item);
})
->all();
$all_rules = \DB::table('acl_rules')
->where('user_id', '=','*')
->get(['disk', 'path', 'access'])
->map(function ($item) {
return get_object_vars($item);
})
->all();
$rules = array_merge($rules,$rank_rules,$job_rules,$all_rules);
return $rules;
}
}

View File

@@ -6,6 +6,7 @@
"type": "project",
"require": {
"php": "^7.4",
"alexusmai/laravel-file-manager": "^2.5",
"barryvdh/laravel-dompdf": "^0.8.4",
"barryvdh/laravel-ide-helper": "2.7.0",
"davejamesmiller/laravel-breadcrumbs": "5.3.2",
@@ -18,7 +19,7 @@
"laravel/telescope": "^3.5",
"laravel/tinker": "^2.0",
"laravel/ui": "^2.0",
"nao-pon/flysystem-google-drive": "^1.1",
"league/flysystem-aws-s3-v3": "^1.0",
"nexmo/client": "^2.0",
"pragmarx/version": "^1.2",
"pusher/pusher-php-server": "~4.0"

877
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -63,7 +63,7 @@ return [
|
*/
'version' => "3.2.5.",
'version' => "3.2.6.",
/*
|--------------------------------------------------------------------------

168
config/file-manager.php Normal file
View File

@@ -0,0 +1,168 @@
<?php
use Alexusmai\LaravelFileManager\Services\ConfigService\DefaultConfigRepository;
use Alexusmai\LaravelFileManager\Services\ACLService\ConfigACLRepository;
return [
/**
* Set Config repository
*
* Default - DefaultConfigRepository get config from this file
*/
'configRepository' => DefaultConfigRepository::class,
/**
* ACL rules repository
*
* Default - ConfigACLRepository (see rules in - aclRules)
*/
'aclRepository' => \App\Services\DBACLRepository::class,
//********* Default configuration for DefaultConfigRepository **************
/**
* LFM Route prefix
* !!! WARNING - if you change it, you should compile frontend with new prefix(baseUrl) !!!
*/
'routePrefix' => 'file-manager',
/**
* List of disk names that you want to use
* (from config/filesystems)
*/
'diskList' => ['storage'],
/**
* Default disk for left manager
*
* null - auto select the first disk in the disk list
*/
'leftDisk' => null,
/**
* Default disk for right manager
*
* null - auto select the first disk in the disk list
*/
'rightDisk' => null,
/**
* Default path for left manager
*
* null - root directory
*/
'leftPath' => null,
/**
* Default path for right manager
*
* null - root directory
*/
'rightPath' => null,
/**
* Image cache ( Intervention Image Cache )
*
* set null, 0 - if you don't need cache (default)
* if you want use cache - set the number of minutes for which the value should be cached
*/
'cache' => null,
/**
* File manager modules configuration
*
* 1 - only one file manager window
* 2 - one file manager window with directories tree module
* 3 - two file manager windows
*/
'windowsConfig' => 2,
/**
* File upload - Max file size in KB
*
* null - no restrictions
*/
'maxUploadFileSize' => null,
/**
* File upload - Allow these file types
*
* [] - no restrictions
*/
'allowFileTypes' => [],
/**
* Show / Hide system files and folders
*/
'hiddenFiles' => true,
/***************************************************************************
* Middleware
*
* Add your middleware name to array -> ['web', 'auth', 'admin']
* !!!! RESTRICT ACCESS FOR NON ADMIN USERS !!!!
*/
'middleware' => ['web','auth'],
/***************************************************************************
* ACL mechanism ON/OFF
*
* default - false(OFF)
*/
'acl' => true,
/**
* Hide files and folders from file-manager if user doesn't have access
*
* ACL access level = 0
*/
'aclHideFromFM' => true,
/**
* ACL strategy
*
* blacklist - Allow everything(access - 2 - r/w) that is not forbidden by the ACL rules list
*
* whitelist - Deny anything(access - 0 - deny), that not allowed by the ACL rules list
*/
'aclStrategy' => 'whitelist',
/**
* ACL Rules cache
*
* null or value in minutes
*/
'aclRulesCache' => null,
//********* Default configuration for DefaultConfigRepository END **********
/***************************************************************************
* ACL rules list - used for default ACL repository (ConfigACLRepository)
*
* 1 it's user ID
* null - for not authenticated user
*
* 'disk' => 'disk-name'
*
* 'path' => 'folder-name'
* 'path' => 'folder1*' - select folder1, folder12, folder1/sub-folder, ...
* 'path' => 'folder2/*' - select folder2/sub-folder,... but not select folder2 !!!
* 'path' => 'folder-name/file-name.jpg'
* 'path' => 'folder-name/*.jpg'
*
* * - wildcard
*
* access: 0 - deny, 1 - read, 2 - read/write
*/
'aclRules' => [
null => [
//['disk' => 'public', 'path' => '/', 'access' => 2],
],
1 => [
//['disk' => 'public', 'path' => 'images/arch*.jpg', 'access' => 2],
//['disk' => 'public', 'path' => 'files/*', 'access' => 1],
],
],
];

View File

@@ -26,7 +26,7 @@ return [
|
*/
'cloud' => env('FILESYSTEM_CLOUD', 'google'),
'cloud' => env('FILESYSTEM_CLOUD', 'storage'),
/*
|--------------------------------------------------------------------------
@@ -48,22 +48,15 @@ return [
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'storage' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
],
'google' => [
'driver' => 'google',
'clientId' => '',
'clientSecret' => '',
'refreshToken' => '',
'folderId' => '',
// 'teamDriveId' => env('GOOGLE_DRIVE_TEAM_DRIVE_ID'),
],
],
];

View File

@@ -5,7 +5,7 @@ current:
major: 3
minor: 2
patch: 5
prerelease: 15-g8158f8a8
prerelease: 16-gd8e36b84
buildmetadata: ''
commit: 41845
timestamp:

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class MakeAclRulesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('acl_rules', function (Blueprint $table) {
$table->increments('id');
$table->string('user_id')->nullable();
$table->string('rank_id')->nullable();
$table->string('job_id')->nullable();
$table->string('disk');
$table->string('path');
$table->tinyInteger('access');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('acl_rules');
}
}

View File

@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Seeder;
class ACLTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('acl_rules')->insert([
[
'user_id' => '*',
'rank_id' => '0',
'job_id' => '0',
'disk' => 'storage',
'path' => '/',
'access' => '1'
],
[
'user_id' => '*',
'rank_id' => '0',
'job_id' => '0',
'disk' => 'storage',
'path' => 'Publique',
'access' => '1'
],
[
'user_id' => '*',
'rank_id' => '0',
'job_id' => '0',
'disk' => 'storage',
'path' => 'Publique/*',
'access' => '1'
],
[
'user_id' => '0',
'rank_id' => '1',
'job_id' => '0',
'disk' => 'storage',
'path' => '*',
'access' => '1'
],
]);
}
}

View File

@@ -18,6 +18,7 @@ class DatabaseSeeder extends Seeder
UsersTableSeeder::class,
ComplementaryActivitiesSeeder::class,
EventTypeSeeder::class,
ACLTableSeeder::class,
]);
}
}

View File

@@ -1,114 +0,0 @@
<table class="table table-hover table-responsive dt-responsive material-datatables w-100 d-sm-table" id="table">
<thead class="thead-dark">
<tr>
<td class="text-center explorerType"><strong>#</strong></td>
<td class="text-left">Nom</td>
<td class="text-center">Dernière modification</td>
<td class="td-actions text-right">
@if($permission['p'])
<div class="dropdown">
<div id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-ellipsis-v fa-2x ml-3 text-gray" style="margin-right: .8rem !important;cursor: pointer;margin-top: -10px;margin-bottom: -6px"></i>
</div>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="/admin/drive/{{$currentDir}}/permission">
<i class="fas fa-lock mr-2"></i></i>Permission
</a>
<a class="dropdown-item text-danger" onclick="deleteFolder('{{ $currentDir }}')">
<i class="fas fa-trash-alt mr-2"></i>Supprimer
</a>
</div>
</div>
@else
<i class="fas fa-lock text-danger mr-2" data-toggle="tooltip" data-placement="left" title="Vous n'avez pas les permissions nécessaires pour modifier ce dossier"></i>
@endif
</td>
</tr>
</thead>
<tbody>
@foreach($directories as $directory)
@php
$read = \App\GoogleDriveFile::getPermForAuthUser($directory['basename'],'r');
$manage = \App\GoogleDriveFile::getPermForAuthUser($directory['basename'],'p');
@endphp
<tr class="context-menu-one">
@if($read)
<td onclick="loadFolder('{{$directory['basename']}}')" style="cursor: pointer;" >
<i class="fas fa-folder fa-2x"></i>
</td>
@else
<td>
<i class="fas fa-folder fa-2x text-muted"></i>
</td>
@endif
<td @if($read) onclick="loadFolder('{{$directory['basename']}}')" style="cursor: pointer;" @else class="text-muted" @endif>{{$directory['name']}}</td>
<td @if($read) class="text-center" onclick="loadFolder('{{$directory['basename']}}')" style="cursor: pointer;" @else class="text-center text-muted" @endif ><span data-toggle="tooltip" data-placement="bottom" title="{{date('r',$directory['timestamp'])}}">{{strftime('%e %b %Y',$directory['timestamp'])}}</span></td>
<td class="td-actions text-right">
@if($manage)
<div class="dropdown">
<div id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-ellipsis-v fa-2x ml-3 text-gray" style="margin-right: .8rem !important;cursor: pointer;"></i>
</div>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="/admin/drive/{{$directory['basename']}}/permission">
<i class="fas fa-lock mr-2"></i>Permission
</a>
<a class="dropdown-item text-danger" onclick="deleteFolder('{{ $directory['basename'] }}')">
<i class="fas fa-trash-alt mr-2"></i>Supprimer
</a>
</div>
</div>
@else
@if(!$read)
<i class="fas fa-lock text-danger mr-2" data-toggle="tooltip" data-placement="left" title="Vous n'avez pas les permissions nécessaires pour modifier ce dossier"></i>
@endif
@endif
</td>
</tr>
@endforeach
@foreach($files as $file)
<tr onclick="showfile('{{$file['basename']}}')" style="cursor: pointer;">
<td><i class="{{ \App\GoogleDriveFile::icon($file['extension']) }} fa-2x"></i></td>
<td>{{$file['name']}}</td>
<td class="text-center"><span data-toggle="tooltip" data-placement="bottom" title="{{date('r',$file['timestamp'])}}">{{strftime('%e %b %Y',$file['timestamp'])}}</span></td>
<td class="td-actions text-right">
<i id="fa-{{$file['basename']}}" class="fas fa-angle-down fa-2x pr-2 text-gray"></i>
</td>
</tr>
<tr id="{{$file['basename']}}" class="d-none">
<td style="border-top: none" colspan="4">
<div class="row">
<div class="col-md-2">
Type : {{$file['type']}} / {{$file['extension']}}
</div>
<div class="col-md-2">
Taille : {{GetSizeName($file['size'])}}
</div>
<div class="col-md-4">
Permission : rw
</div>
<div class="col-md-4 text-right">
<a href="/file/get?f={{urlencode($file['name'])}}&d={{$file['dirname']}}" rel="tooltip" class="btn btn-info">
<i class="material-icons">cloud_download</i>
</a>
<button onclick="deleteFile('{{$file['name']}}','{{$file['dirname']}}')" rel="tooltip" class="btn btn-danger text-white">
<i class="material-icons">delete</i>
</button>
</div>
</div>
</td>
</tr>
@endforeach
@if(count($directories) == 0 && count($files) == 0)
<tr>
<td colspan="4" class="text-center m-2">
Le dossier est vide
</td>
</tr>
@endif
</tbody>
</table>
<small class="float-right mr-4">Dernière mise à jour {{date('r')}}</small>
<script>
updateHeader('{{$permission['p']}}');
</script>

View File

@@ -1,19 +0,0 @@
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>

View File

@@ -1,149 +0,0 @@
@extends('layouts.admin.main')
@section('content')
<div class="card">
<div class="progress progress-bar-top">
<div id="progress-bar" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>
</div>
<div class="row ml-3 mr-3 mt-3">
<div class="col-sm-1 d-inline-flex">
<button id="backbtn" type="button" onclick="goBack()" class="btn btn-secondary" style="border-radius: 50% !important; width: 3.5rem;height: 3.5rem;margin-bottom: -10px;margin-top: -2px" disabled><i class="fas fa-arrow-left fa-2x" aria-hidden="true" style="margin-left: -0.6rem;"></i></button>
<button id="refreshbtn" type="button" onclick="refreshFolder()" class="border-0 bg-transparent ml-3 hover-spin cursor active-spin no-outline" style="margin-bottom: -10px;margin-top: -2px;font-size: 1.1rem"><i class="fas fa-sync-alt"></i></button>
</div>
<div class="col-md-4 col-sm d-flex justify-content-end offset-md-7 mt-2 mt-sm-0">
<div class="dropdown mr-md-2 d-none" id="createDropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-plus"></i> Nouveau
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" data-toggle="modal" data-target="#createFolderModal"><i class="fas fa-folder mr-3"></i> Dossier</a>
</div>
</div>
<div class="dropdown d-none" id="uploadDropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-upload"></i> Téléverser
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" data-toggle="modal" data-target="#uploadFileModal"><i class="fas fa-file mr-3"></i> Fichier</a>
</div>
</div>
</div>
</div>
<div id="loader" class="w-100 h-100" style="background-color: #0000007a;position: absolute; z-index: 5;display: none;border-radius: 6px">
<div class="d-flex h-100" style="justify-content: center; align-items: center;">
@loaderDot
</div>
</div>
<div class="card-body mt-0">
<div class="drive-explorer" style="min-height: 10rem"></div>
</div>
</div>
<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="createFileModal" id="createFileModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Créer un fichier</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form action="/file/create" method="post">
@csrf
<input class="d-none currentDir" type="text" name="currentDir">
<div class="modal-body">
<div class="form-group">
<label for="exampleFormControlInput1">Nom du fichier</label>
<input type="text" class="form-control" id="name" name="name" placeholder="fichier.txt">
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Créer</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button>
</div>
</form>
</div>
</div>
</div>
<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="createFolderModal" id="createFolderModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Créer un dossier</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form action="/folder/create" method="post">
@csrf
<input class="d-none currentDir" type="text" name="currentDir">
<div class="modal-body">
<div class="form-group">
<label for="exampleFormControlInput1">Nom du dossier</label>
<input type="text" class="form-control" id="name" name="name">
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Créer</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button>
</div>
</form>
</div>
</div>
</div>
<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="uploadFileModal" id="uploadFileModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Téléverser une fichier</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form action="/file/upload" method="POST" enctype="multipart/form-data">
@csrf
<input class="d-none currentDir" type="text" name="currentDir">
<div class="modal-body">
<div class="form-group bmd-form-group is-filled">
<label class="label-control bmd-label-static">Fichier à téléverser (Max 50Mo)</label>
<div class="fileinput fileinput-new input-group" data-provides="fileinput" style="display: flex !important;">
<div class="form-control" data-trigger="fileinput">
<span class="fileinput-filename"></span>
</div>
<span class="input-group-append">
<span class="input-group-text fileinput-exists" data-dismiss="fileinput">Supprimer</span>
<span class="input-group-text btn-file">
<span class="fileinput-new">Parcourir</span>
<span class="fileinput-exists">Modifier</span>
<input type="file" name="fichier">
</span>
</span>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Téléverser</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button>
</div>
</form>
</div>
</div>
</div>
@endsection
@section('breadcrumb')
Fichier / Google Drive
@endsection
@section('custom_scripts')
<script src="/js/plugins/jquery.ui.position.min.js"></script>
<script src="/js/plugins/jquery.contextMenu.min.js"></script>
<script src="/js/plugins/drive-explorer.js"></script>
<script>
@if(isset($mode))
init("{{$folder}}","{{$mode}}");
@else
init("{{$folder}}");
@endif
</script>
@endsection

View File

@@ -1,266 +0,0 @@
@extends('layouts.admin.main')
@section('content')
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h4 class="card-title">Permission du dossier: {{$dir->name}}</h4>
<p class="category">/{{$dir->path}}</p>
</div>
<div class="card-body">
<h5>Permission des grades</h5>
<table class="table table-striped table-responsive w-100">
<thead class="table-dark">
<tr class="text-center">
<td class="text-left" style="width: 25%">Grade</td>
<td >Lecture</td>
<td>Écriture</td>
<td>Gestion</td>
<td style="width: 6rem;">
<button class="btn btn-primary btn-fab btn-fab-mini btn-round m-0" onclick="addPermission('{{$dir->id}}','rank')">
<i class="material-icons">add</i>
</button>
</td>
</tr>
</thead>
<tbody>
<tr class="text-center">
<td class="text-left">
Utilisateur non authentifié
</td>
<td>
@if(isset($dir->rank_permission[0]))
@if(strpos($dir->rank_permission[0],'r') !== false)
<i class="fas fa-check-circle fa-2x text-success"></i>
@else
<i class="fas fa-times-circle fa-2x text-danger"></i>
@endif
@else
<i class="fas fa-times-circle fa-2x text-danger"></i>
@endif
</td>
<td>
@if(isset($dir->rank_permission[0]))
@if(strpos($dir->rank_permission[0],'w') !== false)
<i class="fas fa-check-circle fa-2x text-success"></i>
@else
<i class="fas fa-times-circle fa-2x text-danger"></i>
@endif
@else
<i class="fas fa-times-circle fa-2x text-danger"></i>
@endif
</td>
<td>
@if(isset($dir->rank_permission[0]))
@if(strpos($dir->rank_permission[0],'p') !== false)
<i class="fas fa-check-circle fa-2x text-success"></i>
@else
<i class="fas fa-times-circle fa-2x text-danger"></i>
@endif
@else
<i class="fas fa-times-circle fa-2x text-danger"></i>
@endif
</td>
<td class="text-right">
<button class="btn btn-primary btn-fab btn-fab-mini btn-round" onclick="editPermission('{{$dir->id}}','rank','0')">
<i class="material-icons">edit</i>
</button>
<button class="btn btn-danger btn-fab btn-fab-mini btn-round no-cursor" disabled data-toggle="tooltip" data-placement="bottom" title="Vous ne pouvez pas supprimer les permissions des utilisteurs non authentifié">
<i class="material-icons">delete</i>
</button>
</td>
</tr>
@foreach($dir->rank_permission as $key => $rank)
@if($key != 0)
<tr class="text-center">
<td class="text-left">
{{\App\Rank::find($key)->name}}
</td>
<td>
@if(strpos($rank,'r') !== false)
<i class="fas fa-check-circle fa-2x text-success"></i>
@else
<i class="fas fa-times-circle fa-2x text-danger"></i>
@endif
</td>
<td>
@if(strpos($rank,'w') !== false)
<i class="fas fa-check-circle fa-2x text-success"></i>
@else
<i class="fas fa-times-circle fa-2x text-danger"></i>
@endif
</td>
<td>
@if(strpos($rank,'p') !== false)
<i class="fas fa-check-circle fa-2x text-success"></i>
@else
<i class="fas fa-times-circle fa-2x text-danger"></i>
@endif
</td>
<td class="text-right">
<button class="btn btn-primary btn-fab btn-fab-mini btn-round" onclick="editPermission('{{$dir->id}}','rank','{{$key}}')">
<i class="material-icons">edit</i>
</button>
<button class="btn btn-danger btn-fab btn-fab-mini btn-round" onclick="deletePermission('{{$dir->id}}','rank','{{$key}}')">
<i class="material-icons">delete</i>
</button>
</td>
</tr>
@endif
@endforeach
</tbody>
</table>
<h5 class="mt-5">Permission des postes</h5>
<table class="table table-striped table-responsive w-100">
<thead class="table-dark">
<tr class="text-center">
<td class="text-left" style="width: 25%">Poste</td>
<td >Lecture</td>
<td>Écriture</td>
<td>Gestion</td>
<td style="width: 6rem;">
<button class="btn btn-primary btn-fab btn-fab-mini btn-round m-0" onclick="addPermission('{{$dir->id}}','job')">
<i class="material-icons">add</i>
</button>
</td>
</tr>
</thead>
<tbody>
@if(count($dir->job_permission) < 1)
<tr>
<td colspan="5" class="text-center">
Aucune permission de poste
</td>
</tr>
@endif
@foreach($dir->job_permission as $key => $rank)
<tr class="text-center">
<td class="text-left">
{{\App\Job::find($key)->name}}
</td>
<td>
@if(strpos($rank,'r') !== false)
<i class="fas fa-check-circle fa-2x text-success"></i>
@else
<i class="fas fa-times-circle fa-2x text-danger"></i>
@endif
</td>
<td>
@if(strpos($rank,'w') !== false)
<i class="fas fa-check-circle fa-2x text-success"></i>
@else
<i class="fas fa-times-circle fa-2x text-danger"></i>
@endif
</td>
<td>
@if(strpos($rank,'p') !== false)
<i class="fas fa-check-circle fa-2x text-success"></i>
@else
<i class="fas fa-times-circle fa-2x text-danger"></i>
@endif
</td>
<td class="text-right">
<button class="btn btn-primary btn-fab btn-fab-mini btn-round" onclick="editPermission('{{$dir->id}}','job','{{$key}}')">
<i class="material-icons">edit</i>
</button>
<button class="btn btn-danger btn-fab btn-fab-mini btn-round" onclick="deletePermission('{{$dir->id}}','job','{{$key}}')">
<i class="material-icons">delete</i>
</button>
</td>
</tr>
@endforeach
</tbody>
</table>
<h5 class="mt-5">Permission des utilisateurs</h5>
<table class="table table-striped table-responsive w-100">
<thead class="table-dark">
<tr class="text-center">
<td class="text-left" style="width: 25%">Utilisateurs</td>
<td >Lecture</td>
<td>Écriture</td>
<td>Gestion</td>
<td style="width: 6rem;">
<button class="btn btn-primary btn-fab btn-fab-mini btn-round m-0" onclick="addPermission('{{$dir->id}}','user')">
<i class="material-icons">add</i>
</button>
</td>
</tr>
</thead>
<tbody>
@if(count($dir->user_permission) < 1)
<tr>
<td colspan="5" class="text-center">
Aucune permission d'utilisateur
</td>
</tr>
@endif
@foreach($dir->user_permission as $key => $rank)
<tr class="text-center">
<td class="text-left">
{{\App\User::find($key)->fullname()}}
</td>
<td>
@if(strpos($rank,'r') !== false)
<i class="fas fa-check-circle fa-2x text-success"></i>
@else
<i class="fas fa-times-circle fa-2x text-danger"></i>
@endif
</td>
<td>
@if(strpos($rank,'w') !== false)
<i class="fas fa-check-circle fa-2x text-success"></i>
@else
<i class="fas fa-times-circle fa-2x text-danger"></i>
@endif
</td>
<td>
@if(strpos($rank,'p') !== false)
<i class="fas fa-check-circle fa-2x text-success"></i>
@else
<i class="fas fa-times-circle fa-2x text-danger"></i>
@endif
</td>
<td class="text-right">
<button class="btn btn-primary btn-fab btn-fab-mini btn-round" onclick="editPermission('{{$dir->id}}','user','{{$key}}')">
<i class="material-icons">edit</i>
</button>
<button class="btn btn-danger btn-fab btn-fab-mini btn-round" onclick="deletePermission('{{$dir->id}}','user','{{$key}}')">
<i class="material-icons">delete</i>
</button>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
@csrf
<button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bd-example-modal-lg">Large modal</button>
<div id="permissionModal" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content" id="permissionModalHtml">
<div class="modal-header">
<h5 class="modal-title">Chargement ...</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
@loaderDot
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" disabled>Sauvegarder</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button>
</div>
</div>
</div>
</div>
@endsection
@section('custom_scripts')
<script src="/js/plugins/jquery.ui.position.min.js"></script>
<script src="/js/plugins/jquery.contextMenu.min.js"></script>
<script src="/js/plugins/drive-explorer.js"></script>
@endsection

View File

@@ -1,81 +0,0 @@
<div class="modal-header">
<h5 class="modal-title">Modification des permissions</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form action="/admin/drive/{{$folder->id}}/addpermission/{{$s}}" method="post">
<input id="csrf" type="hidden" name="_token" value="">
@method('patch')
<div class="modal-body">
<div class="row">
<div class="col-md-3">
@if($s == 'rank')
<select class="selectpicker" name="id" data-style="btn btn-primary btn-round" title="Grade" required>
@foreach($list as $l)
<option value="{{$l->id}}">{{$l->name}}</option>
@endforeach
</select>
@elseif($s == 'job')
<select class="selectpicker" name="id" data-style="btn btn-primary btn-round" title="Poste" required>
@foreach($list as $l)
<option value="{{$l->id}}">{{$l->name}}</option>
@endforeach
</select>
@else
<select class="selectpicker" name="id" data-style="btn btn-primary btn-round" title="Utilisateur" required>
@foreach($list as $l)
<option value="{{$l->id}}">{{$l->fullname()}}</option>
@endforeach
</select>
@endif
</div>
<div class="col-md-3">
<div class="togglebutton row">
<div class="col-3">
<label>
<input name="read" type="checkbox">
<span class="toggle"></span>
</label>
</div>
<div class="col">
<label>Peux consulter les fichiers a l'intérieur du dossier</label>
</div>
</div>
</div>
<div class="col-md-3">
<div class="togglebutton row">
<div class="col-3">
<label>
<input name="write" type="checkbox">
<span class="toggle"></span>
</label>
</div>
<div class="col">
<label>Peux modifier les fichiers a l'intérieur du dossier</label>
</div>
</div>
</div>
<div class="col-md-3">
<div class="togglebutton row">
<div class="col-3">
<label>
<input name="perm" type="checkbox">
<span class="toggle"></span>
</label>
</div>
<div class="col">
<label>Peux gérer le dossier</label>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Sauvegarder</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button>
</div>
<script>
$('select').selectpicker();
</script>
</form>

View File

@@ -1,70 +0,0 @@
<div class="modal-header">
<h5 class="modal-title">Modification des permissions</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form action="/admin/drive/{{$folder->id}}/permission/{{$s}}/{{$subject->id}}" method="post">
<input id="csrf" type="hidden" name="_token" value="">
@method('patch')
<div class="modal-body">
<div class="row">
<div class="col-md-3">
@switch($s)
@case('rank')
Grade : {{$subject->name}}
@break
@case('job')
Poste : {{$subject->name}}
@break
@case('user')
Utilisateur : {{$subject->fullname()}}
@break
@endswitch
</div>
<div class="col-md-3">
<div class="togglebutton row">
<div class="col-3">
<label>
<input name="read" type="checkbox" @if(strpos($perm,'r') !== false) checked @endif>
<span class="toggle"></span>
</label>
</div>
<div class="col">
<label>Peux consulter les fichiers a l'intérieur du dossier</label>
</div>
</div>
</div>
<div class="col-md-3">
<div class="togglebutton row">
<div class="col-3">
<label>
<input name="write" type="checkbox" @if(strpos($perm,'w') !== false) checked @endif>
<span class="toggle"></span>
</label>
</div>
<div class="col">
<label>Peux modifier les fichiers a l'intérieur du dossier</label>
</div>
</div>
</div>
<div class="col-md-3">
<div class="togglebutton row">
<div class="col-3">
<label>
<input name="perm" type="checkbox" @if(strpos($perm,'p') !== false) checked @endif>
<span class="toggle"></span>
</label>
</div>
<div class="col">
<label>Peux gérer le dossier</label>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Sauvegarder</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button>
</div>
</form>

View File

@@ -1,154 +1,17 @@
@extends('layouts.admin.main')
@section('content')
<div class="col-md-12">
<div class="card">
<div class="card-header">
<strong class="card-title">Fichiers <a href="#"><i class="fa fa-question-circle" aria-hidden="true"></i>
</a></strong>
</div>
<div class="card-body">
<div class="content">
<p>Les fichiers si dessous sont disponible autant dans l'espace administration que dans l'espace cadet cadre.</p>
<table class="table table-striped dt-responsive material-datatables" id="table" style="width:100%">
<thead>
<tr>
<th>Nom</th>
<th>Catégorie</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Plan de cours Vierge</td>
<td>Plan de cours</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1i1a0sjI8I3nzt4mlcLvznjqYF-12JgfQ">Télécharger</a></td>
</tr>
<tr>
<td>Mini Ordre Operation Projet Soirée Journée Vierge</td>
<td>Ordre d'opération</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1sqkeUp-djZDjltitGvjR0efMQgyB_sos">Télécharger</a></td>
</tr>
<tr>
<td>Mini Ordre Operation Vierge</td>
<td>Ordre d'opération</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1RjSSwK9NIVUFbHKlu0hbkK5IeTnAFWq9">Télécharger</a></td>
</tr>
<tr>
<td>Liste des tenues</td>
<td>Tenues</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1JUXaPQhHGJffE7CTnB1BAkqwM8g9t8ef">Télécharger</a></td>
</tr>
<tr>
<td>Cadet commandant</td>
<td>Énoncé de fonction</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1DdI9eOptKarpApsUdO-6gkDFYtD6DHi8">Télécharger</a></td>
</tr>
<tr>
<td>Cadet commandant adjoint</td>
<td>Énoncé de fonction</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1jDuKQzY3Dam0J9mSGDWiv2I1agDYacRm">Télécharger</a></td>
</tr>
<tr>
<td>Chef entrainement</td>
<td>Énoncé de fonction</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=12p8rGhSZloPFurD--RZO9KQVoRmXAEnE">Télécharger</a></td>
</tr>
<tr>
<td>Instructeur sénior</td>
<td>Énoncé de fonction</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=13fNufhR2hYhKgeiHUo0W_V-vF_W8SPkC">Télécharger</a></td>
</tr>
<tr>
<td>Instructeur</td>
<td>Énoncé de fonction</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1Y1gEsNP7mz2SmJPwxi7YUfpxgioJKvR0">Télécharger</a></td>
</tr>
<tr>
<td>Assistant Instructeur</td>
<td>Énoncé de fonction</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1BxKj0J20QZ5hVQ1womwS8GUWvuq-VsJy">Télécharger</a></td>
</tr>
<tr>
<td>Commandant de section</td>
<td>Énoncé de fonction</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1jOmyNFZ2rSOwCFjcoABx6VFcvEMKCf73">Télécharger</a></td>
</tr>
<tr>
<td>Commandant de la garde</td>
<td>Énoncé de fonction</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=18T3rQQ-RN551meOGGPD8Ni2wbpvKNfYz">Télécharger</a></td>
</tr>
<tr>
<td>Commandant adjoint de section</td>
<td>Énoncé de fonction</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1A5NkPhSJ5E-bIPiLRwa7VAOXQrrHIzn6">Télécharger</a></td>
</tr>
<tr>
<td>Commandant adjoint de garde</td>
<td>Énoncé de fonction</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1ncphhTpBm9uhq0isGFNzDs_-TRPrxfKw">Télécharger</a></td>
</tr>
<tr>
<td>Cadet cadre de la logistique</td>
<td>Énoncé de fonction</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1PcmlegtAqmdX2ufGQMubkNxfkrCcSIge">Télécharger</a></td>
</tr>
<tr>
<td>Cadet cadre de l'administration</td>
<td>Énoncé de fonction</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1haEG9jSabp10VtI7EV2OyLctn9-63T8G">Télécharger</a></td>
</tr>
<tr>
<td>Commandant adjoint de section</td>
<td>Énoncé de fonction</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1A5NkPhSJ5E-bIPiLRwa7VAOXQrrHIzn6">Télécharger</a></td>
</tr>
<tr>
<td>Information NECPC</td>
<td>Divers</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1KG0IoPxpqctqqVwCfM0WyKq4y6RDBtUJ">Télécharger</a></td>
</tr>
<tr>
<td>Évaluation pratique sur la coordination dun ordre dopération sur le terrain</td>
<td>Divers</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=1AAPB7IdpIw8UGJwIoTNQZ3cg9ODfWrAp">Télécharger</a></td>
</tr>
<tr>
<td>RENCONTRE PRÉILIMINAIRE DINSTRUCTION</td>
<td>Divers</td>
<td><a class="btn btn-primary btn-block" href="https://drive.google.com/uc?export=download&amp;id=16lT4YzNjGWd2SFmgSbmj1LcPG9cDkkyo">Télécharger</a></td>
</tr>
<tr>
<td>Liste nominal des cadets</td>
<td>Divers</td>
<td><a class="btn btn-primary btn-block" href="{{\App\Config::getData('cadet_list')}}">Télécharger</a></td>
</tr>
</tbody>
</table>
</div>
<div style="height: 600px;">
<div id="fm"></div>
</div>
</div>
</div>
@endsection
@section('breadcrumb')
Fichier / Autres
Fichier / Explorer
@endsection
@section('custom_scripts')
<script>
$(document).ready(function() {
$('#table').DataTable({
"lengthMenu": [[25, 50, -1], [25, 50, "All"]],
"ordering" : false,
"rowGroup": {
dataSrc: 1
},
"columnDefs": [
{ "visible": false, "targets": 1 }
]
});
} );
</script>
<script src="{{ asset('vendor/file-manager/js/file-manager.js') }}"></script>
@endsection

View File

@@ -35,6 +35,7 @@
<link rel="stylesheet" href="/js/plugins/fontawesome-icon-picker/fontawesome-iconpicker.css">
<link rel="stylesheet" href="/css/monolith.min.css"/>
<link rel="stylesheet" href="/css/contextLoader.min.css">
<link rel="stylesheet" href="{{ asset('vendor/file-manager/css/file-manager.css') }}">
<!-- Custom CSS -->
<link rel="stylesheet" href="/css/custom.css">

View File

@@ -30,7 +30,8 @@ Route::get('/activity/{id}', 'ComplementaryActivityController@show');
Route::get('/picture/{id}', 'PictureController@show');
Route::get('/pictures', 'PictureController@index');
Route::get('/file/get', 'GoogleDriveController@getFile')->middleware('fileperm:file,r');
Route::get('/api/files/{path}', 'FilesController@show')->where('path','.*');
/** Setup */
Route::get('/admin/setup', 'AdminController@setup')->middleware('auth')->name('admin.setup');
@@ -188,25 +189,13 @@ Route::middleware(['auth', 'firstlogin'])->name('admin.')->group(function () {
Route::post('/admin/course/{id}/lessonPlan', 'CourseController@updateLessonPlan')->middleware('courseperm:edit');
/** Files */
Route::post('/file/create', 'GoogleDriveController@createFile')->middleware('fileperm:folder,w');
Route::post('/file/upload', 'GoogleDriveController@uploadFile')->middleware('fileperm:folder,w');
Route::post('/folder/create', 'GoogleDriveController@createFolder')->middleware('fileperm:folder,w');
Route::get('/file/delete', 'GoogleDriveController@deleteFile')->middleware('perm:file_delete')->middleware('fileperm:folder,w');
Route::get('/folder/delete', 'GoogleDriveController@deleteDir')->middleware('perm:file_delete')->middleware('fileperm:folder,w');
Route::get('/admin/files', 'FilesController@index')->middleware('perm:file_see')->name('files');
Route::get('/admin/files', 'FilesController@index')->name('files');
Route::get('/admin/files/cadet', 'FilesController@cadet')->middleware('perm:file_see')->name('files.cadet')->middleware('fileperm:folder,r');
Route::get('/admin/files/staff', 'FilesController@staff')->middleware('perm:file_see')->name('files.staff')->middleware('fileperm:folder,r');
Route::get('/admin/files/etamas', 'FilesController@etamas')->middleware('perm:file_see')->name('files.etamas')->middleware('fileperm:folder,r');
Route::get('/admin/files/officier', 'FilesController@officier')->middleware('perm:file_see')->name('files.officier')->middleware('fileperm:folder,r');
Route::get('/admin/files/publique', 'FilesController@publique')->middleware('perm:file_see')->name('files.publique')->middleware('fileperm:folder,r');
Route::get('/admin/drive/{folder?}', 'GoogleDriveController@index')->middleware('fileperm:folder,r', 'perm:drive_see')->name('drive');
Route::get('/admin/folder/{folder?}', 'GoogleDriveController@index')->middleware('fileperm:folder,r')->name('drive');
Route::get('/admin/drive/{folder}/permission', 'GoogleDriveController@editPermission')->middleware('fileperm:folder,p')->name('drive.permission');
Route::patch('/admin/drive/{folder}/permission/{subject}/{id}', 'GoogleDriveController@patchPermission')->middleware('perm:file_see', 'fileperm:folder,p');
Route::get('/admin/drive/{folder}/deletepermission/{subject}/{id}', 'GoogleDriveController@deletePermission')->middleware('perm:file_see', 'fileperm:folder,p');
Route::patch('/admin/drive/{folder}/addpermission/{subject}', 'GoogleDriveController@addPermission')->middleware('perm:file_see', 'fileperm:folder,p');
/** OCOM */
Route::get('/admin/ocom', 'OCOMController@index')->name('ocom')->middleware('perm:instruction_db_ocom_see');