]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5721 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 10 Feb 2023 11:05:34 +0000 (12:05 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 10 Feb 2023 11:05:34 +0000 (12:05 +0100)
.docker/images/php/Dockerfile
app/Console/Commands/FluidbookDocumentProcess.php
app/Fluidbook/Farm.php
app/Http/Controllers/Admin/FluidbookExternalInstallServerCrudController.php [new file with mode: 0644]
app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php
app/Jobs/FluidbookDocumentFileProcess.php
app/Jobs/FluidbookDocumentUpload.php
resources/views/fields/fluidbook_composition.blade.php

index 6021a32a89ea5abb1e1a68e62436df5d3fdd8ae6..77773a127accabccf1209b47e69b3224719de78e 100644 (file)
@@ -42,6 +42,7 @@ RUN apt-get update && apt-get -y --no-install-recommends install \
         php8.1-intl \
         php8.1-memcached \
         php8.1-mysql \
+        php8.1-sqlite \
         php8.1-redis \
         php8.1-soap \
         php8.1-ssh2 \
index d4a5687bb10a12df59a9ea43f8d6f919bd509a54..705322e260f3e5f3b317299f26a2a971f9deb14f 100644 (file)
@@ -25,6 +25,7 @@ class FluidbookDocumentProcess extends CubistCommand
         $doc = FluidbookDocument::find($this->argument('id'));
         $doc->clearAllFiles();
         $user = User::withoutGlobalScope('ownerclause')->where('id', $doc->owner)->first();
-        FluidbookDocumentUpload::dispatchSync(Str::random(), $doc, $user);
+        $job = new FluidbookDocumentUpload(Str::random(), $doc, $user);
+        $job->handle(true);
     }
 }
index d93a238eb1c03a9d8a1f23feed3bb3abca902e83..9bb1fddb63121b34da889221c60b53b33fad0906 100644 (file)
@@ -11,7 +11,7 @@ class Farm
 {
     protected static $_farmServers = [
         ['name' => 'alphaville', 'host' => 'fluidbook-processfarm', 'port' => 9000, 'weight' => 24],
-        ['name' => 'brazil', 'host' => 'brazil.cubedesigners.com', 'weight' => 6],
+        //['name' => 'brazil', 'host' => 'brazil.cubedesigners.com', 'weight' => 6],
         ['name' => 'clockwork', 'host' => 'clockwork.cubedesigners.com', 'weight' => 2],
         ['name' => 'dracula', 'host' => 'dracula.cubedesigners.com', 'weight' => 3],
         ['name' => 'elephantman', 'host' => 'elephantman.cubedesigners.com', 'weight' => 1],
@@ -20,7 +20,7 @@ class Farm
         ['name' => 'her', 'host' => 'her2.cubedesigners.com', 'weight' => 4],
         ['name' => 'isleofdogs', 'host' => 'paris.cubedesigners.com', 'port' => 9458, 'weight' => 2],
         ['name' => 'jumanji', 'host' => 'paris.cubedesigners.com', 'port' => 9459, 'weight' => 2],
-        ['name' => 'kingkong', 'host' => 'kingkong.cubedesigners.com',  'weight' => 2],
+        //['name' => 'kingkong', 'host' => 'kingkong.cubedesigners.com',  'weight' => 2],
     ];
 
     protected static function _pingCache()
@@ -79,11 +79,14 @@ class Farm
         $start = microtime(true);
         $farmer = self::pickOneServer();
 
+        $path = str_replace('/protected/fluidbookpublication/docs/', '/fluidbook/docs/', $path);
+
         $params = ['page' => $page, 'format' => $format, 'resolution' => $resolution, 'withText' => $withText, 'withGraphics' => $withGraphics, 'version' => $version, 'force' => $force, 'out' => $path, 'resolutionRatio' => $resolutionRatio, 'mobileRatio' => $mobileFirstRatio];
 
         $output = self::sendRequest($farmer, 'process.php', $params);
-        if (preg_match('|/data1/extranet/www/[^\s]+|', $output, $matches)) {
-            $o = $matches[0];
+
+        if (preg_match('|^/application/fluidbook/docs/[^\s]+$|', $output, $matches)) {
+            $o = str_replace('/fluidbook/docs/', '/protected/fluidbookpublication/docs/', $matches[0]);
         } else {
             $o = $output;
         }
@@ -96,11 +99,11 @@ class Farm
         }
 
         $time = round(microtime(true) - $start, 4);
-        $log = '[' . $farmer['name'] . ']' . "\t" . date('Y-m-d H:i:s') . "\t" . $time . "\t$page|$format|$resolution|$withText|$withGraphics|$version\t$res\t" . $output . "\n";
+        $log = '[' . $farmer['name'] . ']' . "\t" . date('Y-m-d H:i:s') . "\t" . $time . "\t$page|$format|$resolution|$withText|$withGraphics|$version\t($res)\t>>" . $output . "\n";
 
         error_log($log);
 
-        return str_replace('/fluidbook/docs/', '/protected/fluidbookpublication/docs/', $res);
+        return $res;
     }
 
     public static function ping($echo = true, $force = false)
diff --git a/app/Http/Controllers/Admin/FluidbookExternalInstallServerCrudController.php b/app/Http/Controllers/Admin/FluidbookExternalInstallServerCrudController.php
new file mode 100644 (file)
index 0000000..36b55a5
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+class FluidbookExternalInstallServerCrudController extends \Cubist\Backpack\Magic\Controllers\CubistMagicController
+{
+    use \Cubist\Backpack\Magic\Operations\CreateOperation;
+       use \Cubist\Backpack\Http\Controllers\Operations\CloneEditOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
+       use \Cubist\Backpack\Http\Controllers\Operations\BulkPublishOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\CloneOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\BulkCloneOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\BulkDeleteOperation;
+       use \Cubist\Backpack\Http\Controllers\Operations\ReviseOperation;
+       
+
+
+    /*
+       __('serveur')
+       __('serveurs')
+       */
+
+    protected $_modelNamespace = 'App\Models\FluidbookExternalInstallServer';
+    protected $_routeURL = 'fluidbook-external-install-server';
+    protected $_singular = 'serveur';
+    protected $_plural = 'serveurs';
+    protected $_oneInstance= false;
+}
index facf3807ddedf28094968d01180d2ad9fe81dd80..a819e542edefe160f8640b2ba0ef652a7e09790b 100644 (file)
@@ -57,7 +57,7 @@ trait CompositionOperation
         $document->owner = backpack_user()->id;
         $document->save();
         move_uploaded_file($file->getPathname(), Files::mkdir($document->path()) . 'original.pdf');
-        FluidbookDocumentUpload::updateProgression($uploadID, __('Mise en file d\'attente du traitement du document'), 1.2);
+        FluidbookDocumentUpload::updateProgression($uploadID, $document->id, __('Mise en file d\'attente du traitement du document'), 1.2);
         FluidbookDocumentUpload::dispatch($uploadID, $document, backpack_user(), request('fluidbook_id', null));
         return response()->json(['uploadID' => $uploadID, 'document' => $document->id]);
     }
index 970032b840f89731930d0e978fe174079041e288..cff10bacb5f80ecd4be4d32a652addf92077d3b7 100644 (file)
@@ -14,9 +14,12 @@ class FluidbookDocumentFileProcess extends Base
     protected $withText;
     protected $withGraphics;
     protected $version;
-    protected $force;
+    protected $forceCheck;
+    protected $forceProcess;
 
-    public function __construct($document, $page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html', $force = false)
+    protected $finish = false;
+
+    public function __construct($document, $page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html', $forceCheck = false, $forceProcess = false)
     {
         $this->onQueue('fluidbookprocess');
         $this->document = $document;
@@ -26,12 +29,15 @@ class FluidbookDocumentFileProcess extends Base
         $this->withGraphics = $withGraphics;
         $this->withText = $withText;
         $this->version = $version;
-        $this->force = $force;
+        $this->forceCheck = $forceCheck || $forceProcess;
+        $this->forceProcess = $forceProcess;
     }
 
     public function handle()
     {
-        $this->document->getFile($this->page, $this->format, $this->resolution, $this->withText, $this->withGraphics, $this->version, $this->force);
+        $this->finish = false;
+        echo $this->document->getFile($this->page, $this->format, $this->resolution, $this->withText, $this->withGraphics, $this->version, $this->forceCheck, $this->forceProcess) . "\n";
+        $this->finish = true;
     }
 
     /**
@@ -39,6 +45,16 @@ class FluidbookDocumentFileProcess extends Base
      */
     public function isDone()
     {
-        return $this->document->hasFile($this->page, $this->format, $this->resolution, $this->withText, $this->withGraphics, $this->version);
+        return $this->finish || $this->isOK();
+    }
+
+    public function isOK()
+    {
+        return $this->document->hasFile($this->page, $this->format, $this->resolution, $this->withText, $this->withGraphics, $this->version, $this->forceCheck);
+    }
+
+    public function isError()
+    {
+        return $this->finish && !$this->isOK();
     }
 }
index c5e007bbd3ac2e77996ee02ba13376cd289dc47d..09a02826286caafb9fdd6e6fe52d63de5f065755 100644 (file)
@@ -34,15 +34,19 @@ class FluidbookDocumentUpload extends Base
         $this->setUser($user);
     }
 
-    public function handle()
+    public function handle($sync = false)
     {
-        FluidbookDocumentUpload::updateProgression($this->uploadID, __('Début du traitement du document'), 1.25);
-        $this->document->processUpload($this->uploadID, false);
+        try {
+            FluidbookDocumentUpload::updateProgression($this->uploadID, $this->document->id, __('Début du traitement du document'), 1.25);
+            $this->document->processUpload($this->uploadID, $sync);
+        } catch (\Exception $e) {
+            error_log($e);
+        }
     }
 
-    public static function updateProgression($id, $message, $progress)
+    public static function updateProgression($id, $document_id, $message, $progress)
     {
-        Cache::put('FluidbookDocumentUpload_' . $id, ['message' => $message, 'progress' => $progress]);
+        Cache::put('FluidbookDocumentUpload_' . $id, ['message' => $message, 'document' => $document_id, 'progress' => $progress]);
     }
 
     public static function getProgression($id)
index f4385bb51cbc8896722c924efc9df6ad156852fd..d1e18df57c04db2a9b01a56fbcd9b5a9c09b90a9 100644 (file)
                     $.ajax({
                         url: '{{backpack_url($entry->getOption('name').'/uploadProgress')}}' + '/' + uploadID,
                         success: function (data) {
-                            showProgressBar(data.message, parseFloat(data.progress), uploadID);
+                            let message = data.message;
+                            if (data.document) {
+                                message += '<br><i style="font-size: 80%;opacity: 0.6">Document #' + data.document + '</i>';
+                            }
+                            showProgressBar(message, parseFloat(data.progress), uploadID);
                         }
                     });
                 }
                         $('body').append('<div id="compositionProgress"><div><span></span><progress data-progress="" data-step="0" value="0" max="100"></progress></div></div>');
                     }
                     if (message !== '' && progress > 0) {
-                        $("#compositionProgress span").text(message);
+                        $("#compositionProgress span").html(message);
                         if ($("#compositionProgress progress").attr('data-progress') == progress) {
                             return;
                         }