-
-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Fix tree module (not really necessary but who knows...)
- Loading branch information
Showing
21 changed files
with
217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace App\Livewire\Components\Modules\Maintenance; | ||
|
||
use App\Models\Album; | ||
use App\Models\Configs; | ||
use App\Policies\SettingsPolicy; | ||
use Illuminate\Support\Facades\Gate; | ||
use Illuminate\View\View; | ||
use Livewire\Attributes\Locked; | ||
use Livewire\Component; | ||
|
||
/** | ||
* Maybe the album tree is broken. | ||
* We fix it here. | ||
*/ | ||
class FixTree extends Component | ||
{ | ||
#[Locked] public int|null $result = null; | ||
#[Locked] public string $path = ''; | ||
#[Locked] public array $stats; | ||
/** | ||
* Rendering of the front-end. | ||
* | ||
* @return View | ||
*/ | ||
public function render(): View | ||
{ | ||
Gate::authorize(SettingsPolicy::CAN_UPDATE, Configs::class); | ||
|
||
$query = Album::query(); | ||
|
||
$this->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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
resources/views/livewire/modules/maintenance/fix-tree.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<x-maintenance.card :disabled="$this->no_errors_found && $result === null"> | ||
<x-maintenance.h1>{{ __('maintenance.fix-tree.title') }}</x-maintenance.h1> | ||
<x-maintenance.p class=" !text-left"> | ||
{{ __('maintenance.fix-tree.Oddness') }}: {{ $stats['oddness'] }}<br/> | ||
{{ __('maintenance.fix-tree.Duplicates') }}: {{ $stats['duplicates'] }}<br/> | ||
{{ __('maintenance.fix-tree.Wrong parents') }}: {{ $stats['wrong_parent'] }}<br/> | ||
{{ __('maintenance.fix-tree.Missing parents') }}: {{ $stats['missing_parent'] }}<br/> | ||
</x-maintenance.p> | ||
<x-maintenance.button wire:click="do">{{ __('maintenance.fix-tree.button') }}</x-maintenance.button> | ||
<x-maintenance.loading /> | ||
</x-maintenance.card> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters