From 04d24931ef8d7024b037ebfb48972b908a61672a Mon Sep 17 00:00:00 2001 From: ildyria Date: Sat, 6 Apr 2024 18:18:42 +0200 Subject: [PATCH] add Fix tree module (not really necessary but who knows...) --- .../Modules/Maintenance/FixTree.php | 61 +++++++++++++++++++ lang/cz/maintenance.php | 8 +++ lang/de/maintenance.php | 8 +++ lang/el/maintenance.php | 8 +++ lang/en/maintenance.php | 8 +++ lang/es/maintenance.php | 8 +++ lang/fr/maintenance.php | 8 +++ lang/hu/maintenance.php | 8 +++ lang/it/maintenance.php | 8 +++ lang/nl/maintenance.php | 8 +++ lang/no/maintenance.php | 8 +++ lang/pl/maintenance.php | 8 +++ lang/pt/maintenance.php | 8 +++ lang/ru/maintenance.php | 8 +++ lang/sk/maintenance.php | 8 +++ lang/sv/maintenance.php | 8 +++ lang/vi/maintenance.php | 8 +++ lang/zh_CN/maintenance.php | 8 +++ lang/zh_TW/maintenance.php | 8 +++ .../modules/maintenance/fix-tree.blade.php | 11 ++++ .../livewire/pages/maintenance.blade.php | 1 + 21 files changed, 217 insertions(+) create mode 100644 app/Livewire/Components/Modules/Maintenance/FixTree.php create mode 100644 resources/views/livewire/modules/maintenance/fix-tree.blade.php diff --git a/app/Livewire/Components/Modules/Maintenance/FixTree.php b/app/Livewire/Components/Modules/Maintenance/FixTree.php new file mode 100644 index 00000000000..eb4ff84334e --- /dev/null +++ b/app/Livewire/Components/Modules/Maintenance/FixTree.php @@ -0,0 +1,61 @@ +stats = $query->countErrors(); + + return view('livewire.modules.maintenance.fix-tree'); + } + + /** + * Clean the path from all files excluding $this->skip. + * + * @return void + */ + public function do(): void + { + Gate::authorize(SettingsPolicy::CAN_UPDATE, Configs::class); + + $query = Album::query(); + $this->result = $query->fixTree(); + } + + /** + * Check whether there are files to be removed. + * If not, we will not display the module to reduce complexity. + * + * @return bool + */ + public function getNoErrorsFoundProperty(): bool + { + return 0 === ($this->stats['oddness'] ?? 0) + ($this->stats['duplicates'] ?? 0) + ($this->stats['wrong_parent'] ?? 0) + ($this->stats['missing_parent'] ?? 0); + } +} diff --git a/lang/cz/maintenance.php b/lang/cz/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/cz/maintenance.php +++ b/lang/cz/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/de/maintenance.php b/lang/de/maintenance.php index 22b38fd3b3c..3d1217317c5 100644 --- a/lang/de/maintenance.php +++ b/lang/de/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/el/maintenance.php b/lang/el/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/el/maintenance.php +++ b/lang/el/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/en/maintenance.php b/lang/en/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/en/maintenance.php +++ b/lang/en/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/es/maintenance.php b/lang/es/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/es/maintenance.php +++ b/lang/es/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/fr/maintenance.php b/lang/fr/maintenance.php index e353ab6bab8..e27109afa96 100644 --- a/lang/fr/maintenance.php +++ b/lang/fr/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Supprimer le contenu de %s', 'button' => 'Nettoyer', ], + 'fix-tree' => [ + 'title' => 'Statistique d’arbres', + 'Oddness' => 'Imparité', + 'Duplicates' => 'Duplicata', + 'Wrong parents' => 'Mauvais parents', + 'Missing parents' => 'Parents manquants', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimisation de la base de donnée', 'description' => 'Si vous remarquez que votre installation est devenue lente, il est possible que votre base de donnée n’ai pas les index requis.', diff --git a/lang/hu/maintenance.php b/lang/hu/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/hu/maintenance.php +++ b/lang/hu/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/it/maintenance.php b/lang/it/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/it/maintenance.php +++ b/lang/it/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/nl/maintenance.php b/lang/nl/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/nl/maintenance.php +++ b/lang/nl/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/no/maintenance.php b/lang/no/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/no/maintenance.php +++ b/lang/no/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/pl/maintenance.php b/lang/pl/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/pl/maintenance.php +++ b/lang/pl/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/pt/maintenance.php b/lang/pt/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/pt/maintenance.php +++ b/lang/pt/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/ru/maintenance.php b/lang/ru/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/ru/maintenance.php +++ b/lang/ru/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/sk/maintenance.php b/lang/sk/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/sk/maintenance.php +++ b/lang/sk/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/sv/maintenance.php b/lang/sv/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/sv/maintenance.php +++ b/lang/sv/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/vi/maintenance.php b/lang/vi/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/vi/maintenance.php +++ b/lang/vi/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/zh_CN/maintenance.php b/lang/zh_CN/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/zh_CN/maintenance.php +++ b/lang/zh_CN/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/lang/zh_TW/maintenance.php b/lang/zh_TW/maintenance.php index 5bc3ac40847..d18becc8430 100644 --- a/lang/zh_TW/maintenance.php +++ b/lang/zh_TW/maintenance.php @@ -14,6 +14,14 @@ 'description' => 'Remove all contents from %s', 'button' => 'Clean', ], + 'fix-tree' => [ + 'title' => 'Tree statistics', + 'Oddness' => 'Oddness', + 'Duplicates' => 'Duplicates', + 'Wrong parents' => 'Wrong parents', + 'Missing parents' => 'Missing parents', + 'button' => 'Fix tree', + ], 'optimize' => [ 'title' => 'Optimize Database', 'description' => 'If you notice slowdown in your installation, it may be because your database does not diff --git a/resources/views/livewire/modules/maintenance/fix-tree.blade.php b/resources/views/livewire/modules/maintenance/fix-tree.blade.php new file mode 100644 index 00000000000..dddf182679b --- /dev/null +++ b/resources/views/livewire/modules/maintenance/fix-tree.blade.php @@ -0,0 +1,11 @@ + + {{ __('maintenance.fix-tree.title') }} + + {{ __('maintenance.fix-tree.Oddness') }}: {{ $stats['oddness'] }}
+ {{ __('maintenance.fix-tree.Duplicates') }}: {{ $stats['duplicates'] }}
+ {{ __('maintenance.fix-tree.Wrong parents') }}: {{ $stats['wrong_parent'] }}
+ {{ __('maintenance.fix-tree.Missing parents') }}: {{ $stats['missing_parent'] }}
+
+ {{ __('maintenance.fix-tree.button') }} + +
\ No newline at end of file diff --git a/resources/views/livewire/pages/maintenance.blade.php b/resources/views/livewire/pages/maintenance.blade.php index 90083b65d99..484873eb781 100644 --- a/resources/views/livewire/pages/maintenance.blade.php +++ b/resources/views/livewire/pages/maintenance.blade.php @@ -16,6 +16,7 @@ +