From: Vincent Vanwaelscappel Date: Tue, 28 Mar 2023 15:32:04 +0000 (+0200) Subject: wip #5835 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=a7e3e788e558857773224955c2298d9f0eca2cfc;p=fluidbook-toolbox.git wip #5835 @2 --- diff --git a/app/Jobs/DownloadBase.php b/app/Jobs/DownloadBase.php index 17b7cc8d9..7150fb3bf 100644 --- a/app/Jobs/DownloadBase.php +++ b/app/Jobs/DownloadBase.php @@ -4,6 +4,7 @@ namespace App\Jobs; use App\Mail\DeferredDownload; use App\Models\User; +use App\Notifications\DownloadReady; use App\Services\ScormCloud; use App\Slack\Message; use App\Slack\Slack; @@ -50,6 +51,11 @@ class DownloadBase extends Base public function sendNotification($subject, $text, $actions = []) { + if ($this->getUser()->id == 5) { + $this->getUser()->notify(new DownloadReady($subject, $text, $actions)); + return; + } + if ($this->getUser()->slack) { if ($this->sendSlack($subject, $text, $actions)) { return; diff --git a/app/Notifications/DownloadReady.php b/app/Notifications/DownloadReady.php new file mode 100644 index 000000000..444b46573 --- /dev/null +++ b/app/Notifications/DownloadReady.php @@ -0,0 +1,73 @@ +subject = $subject; + $this->text = $text; + $this->actions = $actions; + } + + /** + * Get the notification's delivery channels. + * + * @param mixed $notifiable + * @return array + */ + public function via($notifiable) + { + if ($notifiable->slack) { + return ['database', FluidbookslackChannel::class]; + } else { + return ['database', 'mail']; + } + } + + /** + * Get the mail representation of the notification. + * + * @param mixed $notifiable + * @return \Illuminate\Notifications\Messages\MailMessage + */ + public function toMail($notifiable) + { + return (new MailMessage) + ->line('The introduction to the notification.') + ->action('Notification Action', url('/')) + ->line('Thank you for using our application!'); + } + + /** + * Get the array representation of the notification. + * + * @param mixed $notifiable + * @return array + */ + public function toArray($notifiable) + { + return [ + 'subject' => $this->subject, + 'text' => $this->text, + 'actions' => $this->actions, + ]; + } +} diff --git a/app/Notifications/FluidbookslackChannel.php b/app/Notifications/FluidbookslackChannel.php new file mode 100644 index 000000000..0fa714e06 --- /dev/null +++ b/app/Notifications/FluidbookslackChannel.php @@ -0,0 +1,22 @@ +toArray($notifiable); + Slack::send($notifiable->slack, $message['subject'], $message['text'], $message['actions']); + } +} diff --git a/app/Widgets.php b/app/Widgets.php index db86b9a3d..3507109ed 100644 --- a/app/Widgets.php +++ b/app/Widgets.php @@ -9,17 +9,18 @@ use Backpack\CRUD\app\Library\Widget; class Widgets { - public static function fluidbookQuoteWidgets() + public static function fluidbookQuoteWidgets($class = '', $wrapper = null) { if (can('fluidbook-quote:admin')) { $nottreated = FluidbookQuote::where('status', '0')->count(); if ($nottreated > 0 && request()->get('status', null) == null) { Widget::add([ 'type' => 'alert', - 'class' => 'alert alert-dark mb-2', + 'class' => 'alert alert-dark mb-2 ' . $class, 'heading' => __('Des demandes de devis n\'ont pas été traitées'), 'content' => __(':awaiting demandes de devis doivent être confiées à un revendeur ou un chef de projet', ['awaiting' => $nottreated]) . '.

' . __('Voir toutes les demandes à traiter') . '

', 'close_button' => false, // show close button or not + 'wrapper' => $wrapper ]); } } @@ -35,19 +36,25 @@ class Widgets } Widget::add([ 'type' => 'alert', - 'class' => 'alert alert-danger mb-2', + 'class' => 'alert alert-danger mb-2 ' . $class, 'heading' => $heading, 'content' => $content . '.

' . __('Voir toutes les demandes en attente') . '

', 'close_button' => false, // show close button or not + 'wrapper' => $wrapper ]); } } - public static function teamWidgets() + public static function teamWidgets($wrapper = null, $class = '', $heading = '') { - Widget::add([ - 'type' => 'view', - 'view' => 'team.leave.calendar', - ]); + if (can('team-leave:read')) { + Widget::add([ + 'type' => 'view', + 'view' => 'team.leave.calendar', + 'wrapper' => $wrapper, + 'class' => $class, + 'heading' => $heading, + ]); + } } } diff --git a/database/migrations/2013_04_09_062329_create_revisions_table.php b/database/migrations/2013_04_09_062329_create_revisions_table.php new file mode 100644 index 000000000..fdd5b1e88 --- /dev/null +++ b/database/migrations/2013_04_09_062329_create_revisions_table.php @@ -0,0 +1,37 @@ +increments('id'); + $table->string('revisionable_type'); + $table->integer('revisionable_id'); + $table->integer('user_id')->nullable(); + $table->string('key'); + $table->text('old_value')->nullable(); + $table->text('new_value')->nullable(); + $table->timestamps(); + + $table->index(array('revisionable_id', 'revisionable_type')); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('revisions'); + } +} diff --git a/database/migrations/2020_02_26_163358_create_permission_tables.php b/database/migrations/2020_02_26_163358_create_permission_tables.php new file mode 100644 index 000000000..1f8507468 --- /dev/null +++ b/database/migrations/2020_02_26_163358_create_permission_tables.php @@ -0,0 +1,102 @@ +bigIncrements('id'); + $table->string('name'); + $table->string('guard_name'); + $table->timestamps(); + }); + + Schema::create($tableNames['roles'], function (Blueprint $table) { + $table->bigIncrements('id'); + $table->string('name'); + $table->string('guard_name'); + $table->timestamps(); + }); + + Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames) { + $table->unsignedBigInteger('permission_id'); + + $table->string('model_type'); + $table->unsignedBigInteger($columnNames['model_morph_key']); + $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index'); + + $table->foreign('permission_id') + ->references('id') + ->on($tableNames['permissions']) + ->onDelete('cascade'); + + $table->primary(['permission_id', $columnNames['model_morph_key'], 'model_type'], + 'model_has_permissions_permission_model_type_primary'); + }); + + Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames) { + $table->unsignedBigInteger('role_id'); + + $table->string('model_type'); + $table->unsignedBigInteger($columnNames['model_morph_key']); + $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index'); + + $table->foreign('role_id') + ->references('id') + ->on($tableNames['roles']) + ->onDelete('cascade'); + + $table->primary(['role_id', $columnNames['model_morph_key'], 'model_type'], + 'model_has_roles_role_model_type_primary'); + }); + + Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) { + $table->unsignedBigInteger('permission_id'); + $table->unsignedBigInteger('role_id'); + + $table->foreign('permission_id') + ->references('id') + ->on($tableNames['permissions']) + ->onDelete('cascade'); + + $table->foreign('role_id') + ->references('id') + ->on($tableNames['roles']) + ->onDelete('cascade'); + + $table->primary(['permission_id', 'role_id'], 'role_has_permissions_permission_id_role_id_primary'); + }); + + app('cache') + ->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null) + ->forget(config('permission.cache.key')); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + $tableNames = config('permission.table_names'); + + Schema::drop($tableNames['role_has_permissions']); + Schema::drop($tableNames['model_has_roles']); + Schema::drop($tableNames['model_has_permissions']); + Schema::drop($tableNames['roles']); + Schema::drop($tableNames['permissions']); + } +} diff --git a/database/migrations/2020_02_26_163414_create_media_table.php b/database/migrations/2020_02_26_163414_create_media_table.php new file mode 100644 index 000000000..139ec8066 --- /dev/null +++ b/database/migrations/2020_02_26_163414_create_media_table.php @@ -0,0 +1,38 @@ +bigIncrements('id'); + $table->morphs('model'); + $table->string('collection_name'); + $table->string('name'); + $table->string('file_name'); + $table->string('mime_type')->nullable(); + $table->string('disk'); + $table->unsignedBigInteger('size'); + $table->json('manipulations'); + $table->json('custom_properties'); + $table->json('responsive_images'); + $table->unsignedInteger('order_column')->nullable(); + $table->nullableTimestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down() + { + Schema::dropIfExists('media'); + } +} diff --git a/database/migrations/2021_11_22_085139_create_jobs_table.php b/database/migrations/2021_11_22_085139_create_jobs_table.php new file mode 100644 index 000000000..1be9e8a80 --- /dev/null +++ b/database/migrations/2021_11_22_085139_create_jobs_table.php @@ -0,0 +1,36 @@ +bigIncrements('id'); + $table->string('queue')->index(); + $table->longText('payload'); + $table->unsignedTinyInteger('attempts'); + $table->unsignedInteger('reserved_at')->nullable(); + $table->unsignedInteger('available_at'); + $table->unsignedInteger('created_at'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('jobs'); + } +} diff --git a/database/migrations/2023_03_28_171252_create_notifications_table.php b/database/migrations/2023_03_28_171252_create_notifications_table.php new file mode 100644 index 000000000..9797596dc --- /dev/null +++ b/database/migrations/2023_03_28_171252_create_notifications_table.php @@ -0,0 +1,35 @@ +uuid('id')->primary(); + $table->string('type'); + $table->morphs('notifiable'); + $table->text('data'); + $table->timestamp('read_at')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('notifications'); + } +} diff --git a/resources/views/team/leave/calendar.blade.php b/resources/views/team/leave/calendar.blade.php index 4b1658e0d..9ef38c85a 100644 --- a/resources/views/team/leave/calendar.blade.php +++ b/resources/views/team/leave/calendar.blade.php @@ -2,7 +2,16 @@ @@ -27,9 +36,13 @@ format: 'ics' } ], - locale: 'fr', + locale: '{{backpack_user()->locale}}', }); calendar.render(); }); -
+@if($widget['heading']) +

{{$widget['heading']}}

+@endif +
+ diff --git a/resources/views/vendor/backpack/base/dashboard.blade.php b/resources/views/vendor/backpack/base/dashboard.blade.php index f01aa31b3..89b72e3da 100644 --- a/resources/views/vendor/backpack/base/dashboard.blade.php +++ b/resources/views/vendor/backpack/base/dashboard.blade.php @@ -3,28 +3,7 @@ @php \App\Widgets::fluidbookQuoteWidgets(); - $widgets['before_content'][] = [ - 'type' => 'jumbotron', - 'heading' => trans('backpack::base.welcome'), - 'content' => trans('backpack::base.use_sidebar'), - 'button_link' => backpack_url('logout'), - 'button_text' => trans('backpack::base.logout'), - ]; -@endphp -@section('content') - {{--
--}} - {{--
--}} - {{--
--}} - {{--
--}} - {{--
{{ trans('backpack::base.login_status') }}
--}} - {{--
--}} + \App\Widgets::teamWidgets(['class' => 'col-sm-4 leave-calendar-wrapper'],'dashboard',__('Planning de l\'équipe')); - {{--
{{ trans('backpack::base.logged_in') }}
--}} - {{--
--}} - {{-- Permissions: {{ backpack_user()->getAllPermissions()}}
--}} - {{--
Roles: {{ backpack_user()->getRoleNames()->implode('name',', ') }}
--}} - {{--
--}} - {{--
--}} - {{--
--}} -@endsection +@endphp 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 684322f3f..9202dd0e7 100644 --- a/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php +++ b/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php @@ -32,6 +32,9 @@ + @can('files:read') @endcan - @can('fluibook-translate:write') + @can('fluidbook-translate:write')