diff --git a/.env.example b/.env.example index aaf8f7e5..c8049e0e 100644 --- a/.env.example +++ b/.env.example @@ -33,8 +33,8 @@ MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null -NEXMO_KEY=4587feffd # Votre Clé Nexmo API -NEXMO_SECRET=54dasf4e8fa4s4fd4f5s # Votre Mot de passe Nexmo API +NEXMO_KEY= # Votre Clé Nexmo API +NEXMO_SECRET= # Votre Mot de passe Nexmo API PUSHER_APP_ID= PUSHER_APP_KEY= diff --git a/app/GoogleDriveFile.php b/app/GoogleDriveFile.php index 495bd2f4..9ab0b2ca 100644 --- a/app/GoogleDriveFile.php +++ b/app/GoogleDriveFile.php @@ -3,9 +3,25 @@ namespace App; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Storage; +use League\Flysystem\FileNotFoundException; +use mysql_xdevapi\Exception; class GoogleDriveFile extends Model { + protected $primaryKey = 'id'; // or null + + public $incrementing = false; + + // In Laravel 6.0+ make sure to also set $keyType + protected $keyType = 'string'; + + protected $casts = [ + 'rank_permission' => 'array', + 'job_permission' => 'array', + 'user_permission' => 'array', + ]; + public static function icon($extension) { $icon = "fas fa-file"; @@ -37,4 +53,204 @@ class GoogleDriveFile extends Model } return $icon; } + + public static function checkConfig() + { + $configNull = (\Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_CLIENT_ID')) != "" && \Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_CLIENT_SECRET')) != "" && \Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_REFRESH_TOKEN')) != "" && \Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_FOLDER_ID')) != ""); + $configOk = true; + + if ($configNull) + { + try { + \Storage::cloud()->listContents("/", false); + } + catch (\Exception $e) + { + $configOk = false; + } + } + + return $configNull && $configOk; + } + + public static function findByName($name) + { + return GoogleDriveFile::where('name','=',$name)->get()->first(); + } + + public static function findByPath($path) + { + return GoogleDriveFile::where('path','=',$path)->get()->first(); + } + + public static function findByPathInDrive($path,$current_directory = '/') + { + if ($path != "") + { + $exploded_path = explode('/',$path); + if ($exploded_path[0] == "") + { + array_splice($exploded_path,0,1); + } + $contents = collect(Storage::cloud()->listContents($current_directory, false)); + + $dir = $contents->where('type', '=', 'dir') + ->where('name', '=', $exploded_path[0]) + ->first(); + + if ( ! $dir) + { + return false; + } + else + { + array_splice($exploded_path,0,1); + $newPath = implode('/',$exploded_path); + if ($newPath == "") + { + return $dir['basename']; + } + else + { + return GoogleDriveFile::findByPathInDrive($newPath,$dir['basename']); + } + } + } + return true; + } + + public static function createByPathInDrive($path,$current_directory = '/') + { + if ($path != "") + { + $exploded_path = explode('/',$path); + $size = count($exploded_path); + if ($size > 1) + { + $parent = self::findByName($exploded_path[$size-2]); + \Storage::cloud()->createDir($parent->id.'/'.$exploded_path[$size-1]); + } + else + { + \Storage::cloud()->createDir('/'.$exploded_path[$size-1]); + } + return self::findByPathInDrive($path); + } + return false; + } + + public function setPermission($subject, $value) + { + $explodedSubject = explode('.',$subject); + $subject = $explodedSubject[0]; + $id = $explodedSubject[1]; + + $permission = null; + if ($subject == 'rank') + { + $permission = $this->rank_permission; + } + elseif ($subject == 'job') + { + $permission = $this->job_permission; + } + elseif ($subject == 'user') + { + $permission = $this->user_permission; + } + + [$id] = $value; + + if ($subject == 'rank') + { + $this->rank_permission = $permission; + } + elseif ($subject == 'job') + { + $this->job_permission = $permission; + } + elseif ($subject == 'user') + { + $this->user_permission = $permission; + } + $this->save(); + } + + public function getAllPermission($subject) + { + $permission = null; + if ($subject == 'rank') + { + $permission = $this->rank_permission; + } + elseif ($subject == 'job') + { + $permission = $this->job_permission; + } + elseif ($subject == 'user') + { + $permission = $this->user_permission; + } + + return $permission; + } + + public function getPermission($subject) + { + $explodedSubject = explode('.',$subject); + $subject = $explodedSubject[0]; + $id = $explodedSubject[1]; + + if (isset($this->getAllPermission($subject)[$id])) + { + return $this->getAllPermission($subject)[$id]; + } + else + { + return ''; + } + } + + public function canUser($user, $permission = 'r') + { + if (strpos($this->getPermission('rank.0'),$permission) !== false) + { + return true; + } + if (strpos($this->getPermission('user.'.$user->id),$permission) === false) + { + if (strpos($this->getPermission('job.'.$user->job->id),$permission) === false) + { + if (strpos($this->getPermission('rank.'.$user->rank->id),$permission) === false) + { + return false; + } + + } + } + return true; + } + + public function canAuthUser($perm = 'r') + { + return $this->canUser(\Auth::user(),$perm); + } + + public static function getPermForUser($folder,$user,$perm = 'r') + { + $dir = \App\GoogleDriveFile::find($folder); + if ($dir == null) + { + return false; + } + else + { + return $dir->canUser($user,$perm); + } + } + + public static function getPermForAuthUser($folder,$perm = 'r') + { + return self::getPermForUser($folder,\Auth::user(),$perm); + } } diff --git a/app/Http/Controllers/GoogleDriveController.php b/app/Http/Controllers/GoogleDriveController.php index 505e804f..4200201e 100644 --- a/app/Http/Controllers/GoogleDriveController.php +++ b/app/Http/Controllers/GoogleDriveController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\GoogleDriveFile; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; use Psy\Util\Str; @@ -245,9 +246,6 @@ class GoogleDriveController extends Controller $contents = collect(Storage::cloud()->listContents($folder, $recursive)); } - //dd($contents); - //$meta = collect(Storage::cloud()->listContents($folder, true)); - //dd($meta); return view('admin.files.Google Drive.explorer',['directories' => $contents->where('type', '=', 'dir')->sortByDesc('name'), 'files' => $contents->where('type', '=', 'file'), 'currentDir' => $folder]); } @@ -256,7 +254,7 @@ class GoogleDriveController extends Controller $error = []; if(\App\Config::getData('is_Google_Drive_enabled') == "true") { - if ($this->checkConfig()) + if (GoogleDriveFile::checkConfig()) { $structure = $this->getFileStructure(); $this->checkStructure($structure,'/','/',$error); @@ -273,61 +271,135 @@ class GoogleDriveController extends Controller return $error; } - public function checkStructure($structure,$parent,$id,&$error) + public function checkStructure() { - $mydir = $this->listLockDirectory($id); + $structure = $this->getFileStructure(); - foreach ($structure as $key => $value) + foreach ($structure as $directory => $value) { - $found = false; - $newDirID = null; - $p = null; - foreach ($mydir as $dir) + $basename = GoogleDriveFile::findByPathInDrive($directory); + if ($basename == false) { - $p = $dir['basename']; - if ($dir['extension'] == $key) + $basename = GoogleDriveFile::createByPathInDrive($directory); + } + + $googleDriveFile = GoogleDriveFile::findByPath($directory); + if ($googleDriveFile == null) + { + $googleDriveFile = new GoogleDriveFile(); + $googleDriveFile->id = $basename; + $googleDriveFile->type = 'directory'; + $googleDriveFile->rank_permission = $value['rank']; + $googleDriveFile->job_permission = []; + $googleDriveFile->user_permission = []; + $googleDriveFile->path = $directory; + $name = explode('/',$directory); + $googleDriveFile->name = $name[count($name)-1]; + $googleDriveFile->save(); + } + else + { + if ($googleDriveFile->id != $basename) { - $found = true; - $newDirID = $dir['basename']; - break; + $googleDriveFile->id = $basename; + $googleDriveFile->save(); } } - if (!$found) - { - array_push($error,'Dossier 🔒.'.$key.' manquant... Le dossier a été créer'); - \Storage::cloud()->createDir($parent.'/🔒.'.$key); - $tempdir = $this->listLockDirectory($parent); - $p = $tempdir->where('extension','=',$key)->first()['basename']; - } - if ($value != []) - { - $this->checkStructure($value,$p,$newDirID,$error); - } } } + public function editPermission($folder) + { + $f = GoogleDriveFile::find($folder); + if ($f == null) + { + $metadata = \Storage::cloud()->getMetadata($folder); + $f = new GoogleDriveFile(); + $f->id = $folder; + $f->type = 'directory'; + $f->name = $metadata['name']; + $f->rank_permission = [1 => 'rwp']; + $f->job_permission = []; + $f->user_permission = []; + $f->path = $this->recreatePath($folder); + $f->save(); + } + return view('admin.files.Google Drive.permission',['dir' => $f]); + } + public function getFileStructure() { return collect([ - 'Privé' => [ - 'Cadet' => [], - 'ETAMAS' => [], - 'Officier' => [], - 'Staff' => [ - 'Guide' => [] - ] + '🔒.Privé' => [ + 'rank' => [1 => 'rwp'], + 'job' => [], + 'user' => [] ], - 'Publique' => [ - 'Fichier' => [], - 'Image' => [] + '🔒.Privé/🔒.Cadet' => [ + 'rank' => [1 => 'rwp'], + 'job' => [], + 'user' => [] + ], + '🔒.Privé/🔒.ETAMAS' => [ + 'rank' => [1 => 'rwp'], + 'job' => [], + 'user' => [] + ], + '🔒.Privé/🔒.Officier' => [ + 'rank' => [1 => 'rwp'], + 'job' => [], + 'user' => [] + ], + '🔒.Privé/🔒.Staff' => [ + 'rank' => [1 => 'rwp'], + 'job' => [], + 'user' => [] + ], + '🔒.Privé/🔒.Staff/🔒.Guide' => [ + 'rank' => [1 => 'rwp'], + 'job' => [], + 'user' => [] + ], + '🔒.Publique' => [ + 'rank' => [1 => 'rwp',0 => 'r'], + 'job' => [], + 'user' => [] + ], + '🔒.Publique/🔒.Fichier' => [ + 'rank' => [1 => 'rwp',0 => 'r'], + 'job' => [], + 'user' => [] + ], + '🔒.Publique/🔒.Image' => [ + 'rank' => [1 => 'rwp',0 => 'r'], + 'job' => [], + 'user' => [] + ], + '🔒.Système' => [ + 'rank' => [1 => 'rwp'], + 'job' => [], + 'user' => [] + ], + '🔒.Système/🔒.Fichier' => [ + 'rank' => [1 => 'rwp'], + 'job' => [], + 'user' => [] + ], + '🔒.Système/🔒.Image' => [ + 'rank' => [1 => 'rwp'], + 'job' => [], + 'user' => [] + ], + '🔒.Système/🔒.Image/🔒.Nouvelle' => [ + 'rank' => [1 => 'rwp'], + 'job' => [], + 'user' => [] + ], + '🔒.Système/🔒.Image/🔒.Profil' => [ + 'rank' => [1 => 'rwp'], + 'job' => [], + 'user' => [] ], - 'Système' => [ - 'Fichier' => [], - 'Image' => [ - 'Nouvelle' => [], - 'Profil' => [] - ] - ] ]); } @@ -340,24 +412,70 @@ class GoogleDriveController extends Controller return $dir; } - public function checkConfig() + public function recreatePath($folder) { - $configNull = (\Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_CLIENT_ID')) != "" && \Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_CLIENT_SECRET')) != "" && \Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_REFRESH_TOKEN')) != "" && \Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_FOLDER_ID')) != ""); - $configOk = true; - - if ($configNull) + $path = []; + $name = []; + $directories = collect(json_decode($this->getPathArray(),true)); + foreach ($directories as $dir) { - try { - $contents = collect(Storage::cloud()->listContents("/", false)); - } - catch (\Exception $e) + $path[$dir['basename']] = $dir['dirname']; + $name[$dir['basename']] = $dir['name']; + } + $realPath = $name[$folder]; + $foo = $folder; + while ($foo != "") + { + $bar = explode('/',$path[$foo]); + $foo = $bar[count($bar)-1]; + if ($foo != "") { - $configOk = false; + $realPath = $name[$foo].'/'.$realPath; } } + return $realPath; + } - return $configNull && $configOk; + public function editPermissionModal($folder,$subject,$id) + { + $dir = GoogleDriveFile::find($folder); + $foo = null; + $perm = null; + if ($subject == 'rank') + { + if ($id == 0) + { + $foo = new \App\Rank(); + $foo->name = "Utilisateur non authentifié"; + $foo->id = 0; + if (isset($dir->rank_permission[$id])) + { + $perm = $dir->rank_permission[$id]; + } + else + { + $perm = ""; + } + } + else + { + $foo = \App\Rank::find($id); + $perm = $dir->rank_permission[$id]; + } + } + elseif ($subject == 'job') + { + $foo = \App\Job::find($id); + $perm = $dir->job_permission[$id]; + } + else + { + $foo = \App\User::find($id); + $perm = $dir->user_permission[$id]; + } + return view('admin.files.Google Drive.permission.edit',['folder' => $dir,'subject' => $foo,'perm' => $perm,'s' => $subject]); } + } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 649e7b55..75cf88dd 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -62,5 +62,6 @@ class Kernel extends HttpKernel 'staff' => \App\Http\Middleware\AccesStaff::class, 'admin' => \App\Http\Middleware\AccesAdmin::class, 'perm' => \App\Http\Middleware\CheckPerm::class, + 'fileperm' => \App\Http\Middleware\CheckFilePerm::class, ]; } diff --git a/app/Http/Middleware/CheckFilePerm.php b/app/Http/Middleware/CheckFilePerm.php new file mode 100644 index 00000000..d4234769 --- /dev/null +++ b/app/Http/Middleware/CheckFilePerm.php @@ -0,0 +1,62 @@ +d); + if ($dir != null) + { + if (\Auth::check()) + { + if ($dir->canUser(\Auth::user(),$permission) == false) + { + clog('navigate','danger','Vous n\'avez pas la permission d\'accéder a ce fichier',\Auth::user()->id); + return redirect('/admin')->with('error','Vous n\'avez pas la permission d\'accéder a ce fichier'); + } + } + else + { + if (strpos($dir->getPermission('rank.0'),$permission) === false) + { + clog('navigate','danger','Un utilisateur non authentifié a tenter de télécharger un fichier privé','0'); + abort(401,'Vous n\'avez pas la permission d\'accéder a ce fichier'); + } + } + return $next($request); + } + if (\Auth::check()) + { + if (\Auth::user()->permission('config_edit')) + { + return $next($request); + } + } + abort(401,'Vous n\'avez pas la permission d\'accéder a ce fichier'); + } + abort(500); + } + else + { + clog('navigate','danger','Google Drive n\'est pas activé ou les identifiants sont incorrect',\Auth::user()->id); + return redirect('/admin')->with('error','Google Drive n\'est pas activé ou les identifiants sont incorrect'); + } + } +} diff --git a/app/Http/helpers.php b/app/Http/helpers.php index 27040d95..53df07dc 100644 --- a/app/Http/helpers.php +++ b/app/Http/helpers.php @@ -48,6 +48,7 @@ function clog(string $type,string $result,string $event,$user_id = null,$obj_typ $log->user_id = \Auth::User()->id; } + if ($obj_type != null) { $log->logable_type = $obj_type; diff --git a/composer.json b/composer.json index fef011c9..28efb949 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,7 @@ "php": "^7.2", "barryvdh/laravel-dompdf": "^0.8.4", "barryvdh/laravel-ide-helper": "v2.6.6", + "davejamesmiller/laravel-breadcrumbs": "5.3.1", "fideloper/proxy": "^4.0", "guzzlehttp/guzzle": "^6.3", "laravel/framework": "^6.0", diff --git a/composer.lock b/composer.lock index d7541ca9..c05ca5ee 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "57f87b1252c823a7d2a41bf3f850e726", + "content-hash": "1f2a06232956fd23a3faa4bba05f8f95", "packages": [ { "name": "barryvdh/laravel-dompdf", @@ -483,6 +483,65 @@ ], "time": "2020-03-01T12:26:26+00:00" }, + { + "name": "davejamesmiller/laravel-breadcrumbs", + "version": "5.3.1", + "source": { + "type": "git", + "url": "https://github.com/davejamesmiller/laravel-breadcrumbs.git", + "reference": "40a73bc9b32fbbee18938dc92228dea161365245" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/davejamesmiller/laravel-breadcrumbs/zipball/40a73bc9b32fbbee18938dc92228dea161365245", + "reference": "40a73bc9b32fbbee18938dc92228dea161365245", + "shasum": "" + }, + "require": { + "facade/ignition-contracts": "^1.0", + "illuminate/support": "^5.6|^6.0", + "illuminate/view": "^5.6|^6.0", + "php": ">=7.1.3" + }, + "require-dev": { + "orchestra/testbench": "^3.6", + "php-coveralls/php-coveralls": "^1.0", + "phpunit/phpunit": "^7.0|^8.0", + "spatie/phpunit-snapshot-assertions": "^2.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "DaveJamesMiller\\Breadcrumbs\\BreadcrumbsServiceProvider" + ], + "aliases": { + "Breadcrumbs": "DaveJamesMiller\\Breadcrumbs\\Facades\\Breadcrumbs" + } + } + }, + "autoload": { + "psr-4": { + "DaveJamesMiller\\Breadcrumbs\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dave James Miller", + "email": "dave@davejamesmiller.com" + } + ], + "description": "A simple Laravel-style way to create breadcrumbs.", + "homepage": "https://github.com/davejamesmiller/laravel-breadcrumbs", + "keywords": [ + "laravel" + ], + "time": "2019-10-20T18:25:39+00:00" + }, { "name": "dnoegel/php-xdg-base-dir", "version": "v0.1.1", @@ -1073,6 +1132,50 @@ ], "time": "2020-02-13T22:36:52+00:00" }, + { + "name": "facade/ignition-contracts", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/facade/ignition-contracts.git", + "reference": "f445db0fb86f48e205787b2592840dd9c80ded28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/facade/ignition-contracts/zipball/f445db0fb86f48e205787b2592840dd9c80ded28", + "reference": "f445db0fb86f48e205787b2592840dd9c80ded28", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Facade\\IgnitionContracts\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://flareapp.io", + "role": "Developer" + } + ], + "description": "Solution contracts for Ignition", + "homepage": "https://github.com/facade/ignition-contracts", + "keywords": [ + "contracts", + "flare", + "ignition" + ], + "time": "2019-08-30T14:06:08+00:00" + }, { "name": "fideloper/proxy", "version": "4.3.0", diff --git a/config/breadcrumbs.php b/config/breadcrumbs.php new file mode 100644 index 00000000..d6acba13 --- /dev/null +++ b/config/breadcrumbs.php @@ -0,0 +1,75 @@ + 'breadcrumbs::bootstrap4', + + /* + |-------------------------------------------------------------------------- + | Breadcrumbs File(s) + |-------------------------------------------------------------------------- + | + | The file(s) where breadcrumbs are defined. e.g. + | + | - base_path('routes/breadcrumbs.php') + | - glob(base_path('breadcrumbs/*.php')) + | + */ + + 'files' => base_path('routes/breadcrumbs.php'), + + /* + |-------------------------------------------------------------------------- + | Exceptions + |-------------------------------------------------------------------------- + | + | Determine when to throw an exception. + | + */ + + // When route-bound breadcrumbs are used but the current route doesn't have a name (UnnamedRouteException) + 'unnamed-route-exception' => false, + + // When route-bound breadcrumbs are used and the matching breadcrumb doesn't exist (InvalidBreadcrumbException) + 'missing-route-bound-breadcrumb-exception' => false, + + // When a named breadcrumb is used but doesn't exist (InvalidBreadcrumbException) + 'invalid-named-breadcrumb-exception' => true, + + /* + |-------------------------------------------------------------------------- + | Classes + |-------------------------------------------------------------------------- + | + | Subclass the default classes for more advanced customisations. + | + */ + + // Manager + 'manager-class' => DaveJamesMiller\Breadcrumbs\BreadcrumbsManager::class, + + // Generator + 'generator-class' => DaveJamesMiller\Breadcrumbs\BreadcrumbsGenerator::class, + +]; diff --git a/database/migrations/2020_03_17_163558_create_google_drive_file_table.php b/database/migrations/2020_03_17_163558_create_google_drive_file_table.php new file mode 100644 index 00000000..b614ee24 --- /dev/null +++ b/database/migrations/2020_03_17_163558_create_google_drive_file_table.php @@ -0,0 +1,38 @@ +string('id'); + $table->index('id'); + $table->string('type'); + $table->string('name'); + $table->string('path')->default(''); + $table->string('rank_permission'); + $table->string('job_permission'); + $table->string('user_permission'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('google_drive_file'); + } +} diff --git a/public/css/custom.css b/public/css/custom.css index 9a08cf67..ac524cb8 100644 --- a/public/css/custom.css +++ b/public/css/custom.css @@ -57,6 +57,10 @@ cursor: pointer; } +.no-cursor { + cursor: default; +} + .word-wrap { white-space: normal; word-break: break-word; @@ -140,7 +144,7 @@ top: 36px; left: 36px; width: 0; - height: 0; + height: 0;progress-bar opacity: 1; } 100% { @@ -1816,3 +1820,16 @@ td{ h2 { text-transform: capitalize !important; } + +.breadcrumb { + margin: auto; + background-color: transparent; +} + +.navbar-wrapper { + max-width: 75%; +} +.progress-bar-top { + margin-bottom: -4px; + border-radius: 6px 6px 0px 0px; +} \ No newline at end of file diff --git a/public/images/C-CMS.png b/public/images/C-CMS.png new file mode 100644 index 00000000..2a7972a9 Binary files /dev/null and b/public/images/C-CMS.png differ diff --git a/public/images/C-CMS_G.png b/public/images/C-CMS_G.png new file mode 100644 index 00000000..36823492 Binary files /dev/null and b/public/images/C-CMS_G.png differ diff --git a/public/js/plugins/drive-explorer.js b/public/js/plugins/drive-explorer.js index 29b6d35e..b362f2ec 100644 --- a/public/js/plugins/drive-explorer.js +++ b/public/js/plugins/drive-explorer.js @@ -1,8 +1,9 @@ -var folderHistory = []; +var folderHistory = false; var path = ''; var currentFolder = ''; var folderGoBack = []; - +var permissionModalHtml = null; +var progressBar = 0; function init(folder) { loadFolder(folder); @@ -10,18 +11,32 @@ function init(folder) } function loadHistory() { + updateProgressBar(progressBar+5); + let btnBack = $('#backbtn'); + btnBack.prop('disabled','true'); $.ajax({ type: 'GET', url: '/api/drive/patharray?api_token=' + api_token, success: function (rawpath) { + updateProgressBar(progressBar+30); var path = JSON.parse(rawpath); Object.keys(path).forEach(function (item) { var dir = path[item].dirname.split('/'); folderGoBack[path[item].basename] = dir[dir.length - 1]; }); + folderHistory = true; + updateProgressBar(progressBar+10); + if(!currentFolder == '' || !currentFolder == 'root') + { + btnBack.removeAttr('disabled'); + } + updateProgressBar(progressBar+5); }, error: function () { - showNotification('error', 'Impossible de charger la hiérachie des dossiers', 'top', 'center') + if (folderHistory) + { + showNotification('error', 'Impossible de charger la hiérachie des dossiers', 'top', 'center') + } } }); } @@ -30,26 +45,35 @@ function loadFolder(folder) { if (folder != undefined) { showLoader(); + updateProgressBar(progressBar+5); $.ajax({ type: 'GET', url: '/api/drive/folders/'+folder+'?api_token=' + api_token, success: function (template) { // Load Explorer Content + updateProgressBar(progressBar+30); $(".drive-explorer").html(template); currentFolder = folder; window.history.pushState("object or string", "Page Title", "/admin/drive/"+folder); + updateProgressBar(progressBar+5); hideLoader(); $('.currentDir').attr('value',folder); - if(currentFolder == '' || currentFolder == 'root') + if (folderHistory) { - $('#backbtn').prop('disabled','true'); - } - else - { - $('#backbtn').removeAttr('disabled'); + if((currentFolder == '' || currentFolder == 'root')) + { + $('#backbtn').prop('disabled','true'); + } + else + { + console.log('wtf'); + console.log(folderGoBack); + $('#backbtn').removeAttr('disabled'); + } } + updateProgressBar(progressBar+10); }, error: function () { showNotification('error', 'Impossible de charger le dossier '+folder, 'top', 'center') @@ -123,3 +147,38 @@ function deleteFolder(folder) function refreshFolder() { loadFolder(currentFolder); } + +function editPermission(folder,subject,id) +{ + $('#permissionModal').on('hidden.bs.modal', function (e) { + $('#permissionModalHtml').html(permissionModalHtml); + }); + + $.ajax({ + type: 'GET', + url: '/api/drive/'+folder+'/permission/'+subject+'/'+id+'?api_token=' + api_token, + success: function (modal) { + permissionModalHtml = $('#permissionModalHtml').html(); + $('#permissionModalHtml').html(modal); + $('#permissionModal').modal('show'); + }, + error: function () { + showNotification('error', 'Impossible de charger le dossier '+folder, 'top', 'center') + } + }); +} + +function updateProgressBar(value) +{ + progressBar = value; + let bar = $('#progress-bar'); + bar.css('width',value+"%"); + if (progressBar >= 100) + { + $('.progress').fadeOut(1500); + } + else + { + $('.progress').fadeIn(650); + } +} diff --git a/resources/custom.css b/resources/custom.css index 9a08cf67..ac524cb8 100644 --- a/resources/custom.css +++ b/resources/custom.css @@ -57,6 +57,10 @@ cursor: pointer; } +.no-cursor { + cursor: default; +} + .word-wrap { white-space: normal; word-break: break-word; @@ -140,7 +144,7 @@ top: 36px; left: 36px; width: 0; - height: 0; + height: 0;progress-bar opacity: 1; } 100% { @@ -1816,3 +1820,16 @@ td{ h2 { text-transform: capitalize !important; } + +.breadcrumb { + margin: auto; + background-color: transparent; +} + +.navbar-wrapper { + max-width: 75%; +} +.progress-bar-top { + margin-bottom: -4px; + border-radius: 6px 6px 0px 0px; +} \ No newline at end of file diff --git a/resources/views/admin/configs/perso.blade.php b/resources/views/admin/configs/perso.blade.php index 2484d716..e8cc80d1 100644 --- a/resources/views/admin/configs/perso.blade.php +++ b/resources/views/admin/configs/perso.blade.php @@ -4,7 +4,7 @@
-

Configuration Générale

+

Apparence

@@ -27,27 +27,6 @@
@endsection -@section('breadcrumb') - -@endsection - @section('custom_scripts') + + +@endsection diff --git a/resources/views/admin/files/Google Drive/permission/edit.blade.php b/resources/views/admin/files/Google Drive/permission/edit.blade.php new file mode 100644 index 00000000..7f5ea4a3 --- /dev/null +++ b/resources/views/admin/files/Google Drive/permission/edit.blade.php @@ -0,0 +1,70 @@ + + + @csrf + @method('patch') + + + \ No newline at end of file diff --git a/resources/views/admin/ocom/index.blade.php b/resources/views/admin/ocom/index.blade.php index 5af37ff6..70ec4e88 100644 --- a/resources/views/admin/ocom/index.blade.php +++ b/resources/views/admin/ocom/index.blade.php @@ -60,7 +60,7 @@ {{$ocom->objectif_rendement}} {{$ocom->objectif_competence}} - + edit
- Modifier + Modifier
diff --git a/resources/views/admin/schedule/event/add.blade.php b/resources/views/admin/schedule/event/add.blade.php index a96e71de..89b7f805 100644 --- a/resources/views/admin/schedule/event/add.blade.php +++ b/resources/views/admin/schedule/event/add.blade.php @@ -65,10 +65,10 @@
- Remove + Remove - Select file - Change + Select file + Change diff --git a/resources/views/admin/update.blade.php b/resources/views/admin/update.blade.php index 97235b41..5b315dcc 100644 --- a/resources/views/admin/update.blade.php +++ b/resources/views/admin/update.blade.php @@ -2,6 +2,109 @@ @section('content')
+
+
+
+
+
+

3.2.5

+

2019-10-19

+
+
+ STABLE +
+
+
+
+
+
+

+ Nouveauté +

    +
  • +
    +
    + +
    +
    + Ajout d'un breadcrumb +
    +
    +
  • +
  • +
    +
    + +
    +
    + Ajout de la base de donnée des cours +
    +
    +
  • +
  • +
    +
    + +
    +
    + Mise à jour des pages d'erreurs +
    +
    +
  • +
  • +
    +
    + +
    +
    + Mise à jour de l'horaire vers la version 3 +
    +
    +
  • +
  • +
    +
    + +
    +
    + Mise à jour du système de fichier vers Google Drive +
    +
    +
  • +
  • +
    +
    + +
    +
    + Mise à jour du système de permission +
    +
    +
  • +
+

+
+
+

+ Bug +

    +
  • +
    +
    + +
    +
    + Correction de multiples bugs +
    +
    +
  • +
+

+
+
+
+
+
diff --git a/resources/views/errors/401.blade.php b/resources/views/errors/401.blade.php index c6aa79dc..bdd6555f 100644 --- a/resources/views/errors/401.blade.php +++ b/resources/views/errors/401.blade.php @@ -1,90 +1,9 @@ - - - - +@extends('errors.layout') - Error - - - - - - - - -
-
-
-

401

-
-
- -
-
-
- Oups ... Vous n'avez pas l'autorisation de venir ici {{ $exception->getMessage() }}
-
-
- - - \ No newline at end of file +@section('title', __('Non autorisé')) +@section('code') + 401 +@endsection +@section('message', 'Nous sommes désolé, vous n\'avez pas l\'autorisation d\'être ici.') +@section('error',$exception->getMessage()) +@section('url','https://developer.mozilla.org/fr/docs/Web/HTTP/Status/401') diff --git a/resources/views/errors/403.blade.php b/resources/views/errors/403.blade.php new file mode 100644 index 00000000..5f47ae61 --- /dev/null +++ b/resources/views/errors/403.blade.php @@ -0,0 +1,9 @@ +@extends('errors.layout') + +@section('title', __('Accès refusé')) +@section('code') +403 +@endsection +@section('message', 'Nous sommes désolé, le serveur a compris la requête, mais refuse de l\'exécuter.') +@section('error',$exception->getMessage()) +@section('url','https://developer.mozilla.org/fr/docs/Web/HTTP/Status/403') diff --git a/resources/views/errors/404.blade.php b/resources/views/errors/404.blade.php index 15a38e3a..8881ccc8 100644 --- a/resources/views/errors/404.blade.php +++ b/resources/views/errors/404.blade.php @@ -1,90 +1,9 @@ - - - - +@extends('errors.layout') - Error - - - - - - - - -
-
-
-

404

-
-
- -
-
-
- Oups ... Il n'y a malheureusement rien là {{ $exception->getMessage() }}
-
-
- - - \ No newline at end of file +@section('title', __('Page introuvable')) +@section('code') + 404 +@endsection +@section('message', 'Nous sommes désolé, la page demandée ne semble pas exister.') +@section('error',$exception->getMessage()) +@section('url','https://developer.mozilla.org/fr/docs/Web/HTTP/Status/404') diff --git a/resources/views/errors/419.blade.php b/resources/views/errors/419.blade.php new file mode 100644 index 00000000..b7f2983a --- /dev/null +++ b/resources/views/errors/419.blade.php @@ -0,0 +1,9 @@ +@extends('errors.layout') + +@section('title', __('Page expiré')) +@section('code') + 419 +@endsection +@section('message', 'Nous sommes désolé, la page a expiré.') +@section('error',$exception->getMessage()) +@section('url','') diff --git a/resources/views/errors/429.blade.php b/resources/views/errors/429.blade.php new file mode 100644 index 00000000..68db5362 --- /dev/null +++ b/resources/views/errors/429.blade.php @@ -0,0 +1,9 @@ +@extends('errors.layout') + +@section('title', __('Trop de requêtes')) +@section('code') + 429 +@endsection +@section('message', 'Nous sommes désolé, mais le client a émis trop de requêtes. ') +@section('error',$exception->getMessage()) +@section('url','https://developer.mozilla.org/fr/docs/Web/HTTP/Status/429') diff --git a/resources/views/errors/500.blade.php b/resources/views/errors/500.blade.php index 257a17f6..f90bae92 100644 --- a/resources/views/errors/500.blade.php +++ b/resources/views/errors/500.blade.php @@ -1,90 +1,10 @@ - - - - +@extends('errors.layout') - Error +@section('title', __('Erreur interne')) +@section('code') + 500 +@endsection +@section('message', 'Nous sommes désolé, le serveur a rencontré une exception.') +@section('error',$exception->getMessage()) +@section('url','https://developer.mozilla.org/fr/docs/Web/HTTP/Status/500') - - - - - - - -
-
-
-

500

-
-
- -
-
-
- Oups ... Le serveur n'aime pas ça, svp laisser lui le temps de soufler {{ $exception->getMessage() }}
-
-
- - - \ No newline at end of file diff --git a/resources/views/errors/503.blade.php b/resources/views/errors/503.blade.php new file mode 100644 index 00000000..541ea11e --- /dev/null +++ b/resources/views/errors/503.blade.php @@ -0,0 +1,9 @@ +@extends('errors.layout') + +@section('title', __('Service indisponible')) +@section('code') + 503 +@endsection +@section('message', 'Nous sommes désolé, mais le service est temporairement indisponible ou en maintenance.') +@section('error',$exception->getMessage()) +@section('url','https://developer.mozilla.org/fr/docs/Web/HTTP/Status/503') \ No newline at end of file diff --git a/resources/views/errors/layout.blade.php b/resources/views/errors/layout.blade.php new file mode 100644 index 00000000..39ff71a7 --- /dev/null +++ b/resources/views/errors/layout.blade.php @@ -0,0 +1,194 @@ + + + + + + + + + + @yield('title') - C-CMS + + + + + + + + + + + + + + + + + + +
+ + {{ Breadcrumbs::render() }} +
+
+

Oops! @yield('title')

+

@yield('code')

+ + + +
+

@yield('message')

+

@yield('error')

+
+
+ + + + diff --git a/resources/views/layouts/admin/header.blade.php b/resources/views/layouts/admin/header.blade.php index aee8ac07..0b4bb47b 100644 --- a/resources/views/layouts/admin/header.blade.php +++ b/resources/views/layouts/admin/header.blade.php @@ -13,7 +13,7 @@ foreach (Auth::user()->unreadNotifications as $notification) { view_list
- @yield('breadcrumb') + {{ Breadcrumbs::render() }}