From: Vincent Vanwaelscappel Date: Wed, 29 Mar 2023 16:47:08 +0000 (+0200) Subject: wip #5835 @5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=afe83b827dce3b314bbd695a62c9ecf017d59898;p=fluidbook-toolbox.git wip #5835 @5 --- diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 21ce254bc..b128bcf2c 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -25,8 +25,9 @@ class Kernel extends \Cubist\Backpack\Console\Kernel protected function schedule(Schedule $schedule) { $schedule->command('queue:prune-failed --hours=24')->daily()->at('03:50'); - $schedule->command('job:dispatch Maintenance\\\\CleanDownloads')->dailyAt('4:00'); - $schedule->command('job:dispatch Maintenance\\\\CleanFTP')->dailyAt('4:30'); + $schedule->command('job:dispatchNow Maintenance\\\\CleanDownloads')->dailyAt('4:00'); + $schedule->command('job:dispatchNow Maintenance\\\\CleanFTP')->dailyAt('4:30'); + $schedule->command('model:prune')->dailyAt('5:00'); // $schedule->command('backup:clean')->daily()->at('04:00'); // $schedule->command('backup:run')->daily()->at('05:00'); diff --git a/app/Http/Controllers/Admin/TasksController.php b/app/Http/Controllers/Admin/TasksController.php new file mode 100644 index 000000000..55d72866f --- /dev/null +++ b/app/Http/Controllers/Admin/TasksController.php @@ -0,0 +1,34 @@ +notifications; + $res = view('tasks.index', ['notifications' => clone $notifications]); + MarkUserNotificationsAsRead::dispatchSync($user)/*->delay(now()->addSeconds(15))*/; + return $res; + } + + public function countUnread() + { + return response()->json(['unread' => backpack_user()->unreadNotifications()->count()]); + } + + public function deleteNotification($id) + { + foreach (backpack_user()->notifications as $notification) { + if ($notification->id === $id) { + $notification->delete(); + } + } + } +} diff --git a/app/Jobs/Maintenance/CleanDownloads.php b/app/Jobs/Maintenance/CleanDownloads.php index 78cd628a1..d2fc1117f 100644 --- a/app/Jobs/Maintenance/CleanDownloads.php +++ b/app/Jobs/Maintenance/CleanDownloads.php @@ -4,6 +4,7 @@ namespace App\Jobs\Maintenance; use App\Jobs\Base; use Cubist\Util\Files\Files; +use Illuminate\Support\Facades\Notification; class CleanDownloads extends Base { diff --git a/app/Jobs/MarkUserNotificationsAsRead.php b/app/Jobs/MarkUserNotificationsAsRead.php new file mode 100644 index 000000000..5f4444c98 --- /dev/null +++ b/app/Jobs/MarkUserNotificationsAsRead.php @@ -0,0 +1,25 @@ +user = $user; + } + + public function handle() + { + foreach ($this->user->notifications as $notification) { + if ($notification->read_at === null) { + $notification->markAsRead(); + } + } + } +} diff --git a/app/Models/ELearningMedia.php b/app/Models/ELearningMedia.php index 3bda56cca..a455ad988 100644 --- a/app/Models/ELearningMedia.php +++ b/app/Models/ELearningMedia.php @@ -17,6 +17,7 @@ use Cubist\Scorm\Manifest; use Cubist\Scorm\Version; use Cubist\Util\Files\VirtualDirectory; use Spatie\MediaLibrary\MediaCollections\Models\Media; + // __('!! e-Learning') class ELearningMedia extends ToolboxModel { @@ -32,7 +33,7 @@ class ELearningMedia extends ToolboxModel public const MEDIA_TYPES = ['audio/mpeg', 'video/mp4', 'application/pdf']; - protected $_operations = [ImportOperation::class, PreviewOperation::class, DownloadOperation::class,ChangeownerOperation::class]; + protected $_operations = [ImportOperation::class, PreviewOperation::class, DownloadOperation::class, ChangeownerOperation::class]; public function setFields() { @@ -73,9 +74,10 @@ class ELearningMedia extends ToolboxModel public function preSave() { $file = $this->getMediaInField('file')->first(); - $spl = new \SplFileInfo($file->getPath()); - - $this->setAttribute('type', self::getType($spl->getExtension())); + if ($file !== null) { + $spl = new \SplFileInfo($file->getPath()); + $this->setAttribute('type', self::getType($spl->getExtension())); + } return parent::preSave(); } diff --git a/app/Models/Notification.php b/app/Models/Notification.php new file mode 100644 index 000000000..ffdaf3a80 --- /dev/null +++ b/app/Models/Notification.php @@ -0,0 +1,20 @@ +subDays(15)); + } +} + diff --git a/app/Models/User.php b/app/Models/User.php index 82e0f5900..81d3b92c2 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -10,5 +10,7 @@ class User extends \Cubedesigners\UserDatabase\Models\User $query->where('company', 7); $query->orderBy('enabled', 'ASC'); $query->orderBy('id', 'ASC'); + } + } diff --git a/public/packages/fluidbook/toolbox/css/style.less b/public/packages/fluidbook/toolbox/css/style.less index c2bbd6013..7bd94ff22 100644 --- a/public/packages/fluidbook/toolbox/css/style.less +++ b/public/packages/fluidbook/toolbox/css/style.less @@ -442,11 +442,29 @@ body.embeded { right: 80%; } -.user_disabled a{ +.user_disabled a { color: #999; text-decoration: line-through; } +.la-bell { + + &.unread { + position: relative; + + &:after { + content: ""; + position: absolute; + width: 5px; + height: 5px; + border-radius: 50%; + top: -1px; + right: -1px; + background-color: #f00; + } + } +} + @import "context-menu"; @import "loader"; diff --git a/resources/views/tasks/index.blade.php b/resources/views/tasks/index.blade.php new file mode 100644 index 000000000..23fc162fc --- /dev/null +++ b/resources/views/tasks/index.blade.php @@ -0,0 +1,91 @@ +{{-- __('!! Équipe') --}} +@extends(backpack_view('blank')) + +@push('after_scripts') + +@endpush + +@section('content') + + {{--

{{__('Tâches en cours')}}

--}} +

{{__('Notifications')}}

+ + {{-- --}} + {{-- --}} + {{-- --}} + {{-- --}} + {{-- --}} + {{-- --}} + {{-- --}} + {{-- --}} + + + @if(!$notifications || !count($notifications)) + {{__('Aucune notification')}} + @endif + @foreach($notifications as $id=>$notification) + read_at===null) class="unread" @endif> + + + + + + + @endforeach + +
{{__('Bulletin')}}{{__('Date')}}
{{$notification->data['subject']}}
+
    + @foreach($notification->data['actions'] as $label=>$url) +
  • {{$label}} : {{$url}}
  • + @endforeach +
+
{{$notification->created_at}} + +
+@endsection + + diff --git a/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php b/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php index 9202dd0e7..f4e2d9edc 100644 --- a/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php +++ b/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php @@ -6,6 +6,7 @@ $state=(backpack_user()->getToolboxSetting('sidebar_'.$id,$default)=='1')?' open':''; return 'class="nav-item nav-dropdown'.$state.'" data-sidebar-id="'.$id.'"'; } + @endphp @push('after_scripts') @endpush @@ -33,7 +52,7 @@ class='nav-icon la la-dashboard'>{{ trans('backpack::base.dashboard') }} @can('files:read') diff --git a/routes/web.php b/routes/web.php index 079110f27..ac7d215fb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -22,6 +22,9 @@ Route::group([ Route::get('fluidbookthemepreview/{id}-burger.jpg', 'FluidbookThemePreviewController@previewBurger'); Route::get('fluidbookthemepreview/{id}-menu.jpg', 'FluidbookThemePreviewController@previewMenu'); Route::get('fluidbookthemepreview/{id}.jpg', 'FluidbookThemePreviewController@preview'); + Route::get('tasks', 'TasksController@index'); + Route::get('tasks/countUnread', 'TasksController@countUnread'); + Route::delete('tasks/notification/{id}', 'TasksController@deleteNotification'); }); Route::group([