]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5835 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 28 Mar 2023 15:32:04 +0000 (17:32 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 28 Mar 2023 15:32:04 +0000 (17:32 +0200)
12 files changed:
app/Jobs/DownloadBase.php
app/Notifications/DownloadReady.php [new file with mode: 0644]
app/Notifications/FluidbookslackChannel.php [new file with mode: 0644]
app/Widgets.php
database/migrations/2013_04_09_062329_create_revisions_table.php [new file with mode: 0644]
database/migrations/2020_02_26_163358_create_permission_tables.php [new file with mode: 0644]
database/migrations/2020_02_26_163414_create_media_table.php [new file with mode: 0644]
database/migrations/2021_11_22_085139_create_jobs_table.php [new file with mode: 0644]
database/migrations/2023_03_28_171252_create_notifications_table.php [new file with mode: 0644]
resources/views/team/leave/calendar.blade.php
resources/views/vendor/backpack/base/dashboard.blade.php
resources/views/vendor/backpack/base/inc/sidebar_content.blade.php

index 17b7cc8d95d251dfe56e10c8e2fc080a3cf680a0..7150fb3bfc027cb71318235061fddf7ad99f40ac 100644 (file)
@@ -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 (file)
index 0000000..444b465
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+
+namespace App\Notifications;
+
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Notifications\Messages\MailMessage;
+use Illuminate\Notifications\Notification;
+
+class DownloadReady extends Notification
+{
+    use Queueable;
+
+    protected $subject;
+    protected $text;
+    protected $actions = [];
+
+    /**
+     * Create a new notification instance.
+     *
+     * @return void
+     */
+    public function __construct($subject = '', $text = '', $actions = [])
+    {
+        $this->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 (file)
index 0000000..0fa714e
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Notifications;
+
+use App\Slack\Slack;
+use Illuminate\Notifications\Notification;
+
+class FluidbookslackChannel
+{
+    /**
+     * Send the given notification.
+     *
+     * @param mixed $notifiable
+     * @param \Illuminate\Notifications\Notification $notification
+     * @return void
+     */
+    public function send($notifiable, Notification $notification)
+    {
+        $message = $notification->toArray($notifiable);
+        Slack::send($notifiable->slack, $message['subject'], $message['text'], $message['actions']);
+    }
+}
index db86b9a3d99a780bf3d929747479ebafd951ee8a..3507109ed535b1733365a801754937640a290b79 100644 (file)
@@ -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]) . '. <p><a class="btn btn-primary" href="' . backpack_url('fluidbook-quote?status=0') . '">' . __('Voir toutes les demandes à traiter') . '</a></p>',
                     '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 . '. <p><a class="btn btn-warning" href="' . backpack_url('fluidbook-quote?status=1') . '">' . __('Voir toutes les demandes en attente') . '</a></p>',
                 '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 (file)
index 0000000..fdd5b1e
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+
+class CreateRevisionsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('revisions', function ($table) {
+            $table->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 (file)
index 0000000..1f85074
--- /dev/null
@@ -0,0 +1,102 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreatePermissionTables extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        $tableNames = config('permission.table_names');
+        $columnNames = config('permission.column_names');
+
+        Schema::create($tableNames['permissions'], function (Blueprint $table) {
+            $table->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 (file)
index 0000000..139ec80
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateMediaTable extends Migration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up()
+    {
+        Schema::create('media', function (Blueprint $table) {
+            $table->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 (file)
index 0000000..1be9e8a
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateJobsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('jobs', function (Blueprint $table) {
+            $table->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 (file)
index 0000000..9797596
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateNotificationsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('notifications', function (Blueprint $table) {
+            $table->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');
+    }
+}
index 4b1658e0da47d4ac31082216f40841cfa2b40d33..9ef38c85a7ca86b2fc362f9afc8c07e39cac73e5 100644 (file)
@@ -2,7 +2,16 @@
 <style>
     #leave-calendar {
         max-width: 600px;
-        margin: 40px auto;
+        margin: 40px 0;
+    }
+    #leave-calendar.dashboard{
+        max-width: none;
+    }
+
+    .leave-calendar-wrapper{
+        background-color: #ffffff;
+        padding: 20px;
+        border-radius: 2px;
     }
 </style>
 <link href='https://cdn.jsdelivr.net/npm/fullcalendar@5.11.3/main.min.css' rel='stylesheet'/>
                     format: 'ics'
                 }
             ],
-            locale: 'fr',
+            locale: '{{backpack_user()->locale}}',
         });
         calendar.render();
     });
 </script>
-<div id='leave-calendar'></div>
+@if($widget['heading'])
+    <h4 class="leave-calendar">{{$widget['heading']}}</h4>
+@endif
+<div id='leave-calendar' class="{{$widget['class']}}"></div>
+
index f01aa31b3918c33ea7bf90b381b402b7bbf4978d..89b72e3da61e301b145141fa24804f0cae209d4a 100644 (file)
@@ -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')
-    {{--    <div class="row">--}}
-    {{--        <div class="col-md-12">--}}
-    {{--            <div class="box">--}}
-    {{--                <div class="box-header with-border">--}}
-    {{--                    <div class="box-title">{{ trans('backpack::base.login_status') }}</div>--}}
-    {{--                </div>--}}
+    \App\Widgets::teamWidgets(['class' => 'col-sm-4 leave-calendar-wrapper'],'dashboard',__('Planning de l\'équipe'));
 
-    {{--                <div class="box-body">{{ trans('backpack::base.logged_in') }}</div>--}}
-    {{--                <div class="box-body">--}}
-    {{--                    Permissions: {{ backpack_user()->getAllPermissions()}}</div>--}}
-    {{--                <div class="box-body">Roles: {{ backpack_user()->getRoleNames()->implode('name',', ') }}</div>--}}
-    {{--            </div>--}}
-    {{--        </div>--}}
-    {{--    </div>--}}
-@endsection
+@endphp
 
index 684322f3f3572fa58197062c04da0755651ea18b..9202dd0e749e48019ea20e6e65ede3e844a7bc09 100644 (file)
@@ -32,6 +32,9 @@
 <li class="nav-item"><a class="nav-link" href="{{ backpack_url('dashboard') }}"><i
             class='nav-icon la la-dashboard'></i>{{ trans('backpack::base.dashboard') }}
     </a></li>
+<li class="nav-item"><a class="nav-link" href="{{ backpack_url('tasks') }}"><i
+            class='nav-icon la la-bell'></i>{{ __('Tâches et notifications') }}
+    </a></li>
 
 @can('files:read')
     <li class="nav-item"><a class="nav-link" href="{{ backpack_url('file') }}"><i
@@ -83,7 +86,7 @@
                 <li class="nav-item"><a class="nav-link" href="{{ backpack_url('fluidbook-collection') }}"><i
                             class="la la-university nav-icon"></i> {{__('Collections')}}</a></li>
             @endcan
-            @can('fluibook-translate:write')
+            @can('fluidbook-translate:write')
                 <li class="nav-item"><a class="nav-link"
                                         href='{{ backpack_url('fluidbook-translate/1/edit/?locale=en') }}'><i
                             class='la la-language nav-icon'></i>