fix: removes preference options db table
This commit is contained in:
41
migrations/Version20250724042107.php
Normal file
41
migrations/Version20250724042107.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20250724042107 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE preference_option DROP FOREIGN KEY FK_607C52FD81022C0
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
DROP TABLE preference_option
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
CREATE TABLE preference_option (id INT AUTO_INCREMENT NOT NULL, preference_id VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, name VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, value VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, enabled TINYINT(1) NOT NULL, INDEX IDX_607C52FD81022C0 (preference_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = ''
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE preference_option ADD CONSTRAINT FK_607C52FD81022C0 FOREIGN KEY (preference_id) REFERENCES preference (id)
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,14 +3,20 @@
|
|||||||
namespace App\Twig\Components;
|
namespace App\Twig\Components;
|
||||||
|
|
||||||
use Aimeos\Map;
|
use Aimeos\Map;
|
||||||
|
use App\User\Database\CodecList;
|
||||||
use App\User\Database\QualityList;
|
use App\User\Database\QualityList;
|
||||||
|
use App\User\Database\ResolutionList;
|
||||||
|
use App\User\Dto\PreferenceOptions;
|
||||||
|
use App\User\Dto\PreferenceOptionsFactory;
|
||||||
|
use App\User\Dto\UserPreferencesFactory;
|
||||||
use App\User\Framework\Repository\PreferencesRepository;
|
use App\User\Framework\Repository\PreferencesRepository;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Bundle\SecurityBundle\Security;
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
|
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
|
||||||
use Symfony\UX\LiveComponent\DefaultActionTrait;
|
use Symfony\UX\LiveComponent\DefaultActionTrait;
|
||||||
|
|
||||||
#[AsLiveComponent]
|
#[AsLiveComponent]
|
||||||
final class Filter
|
final class Filter extends AbstractController
|
||||||
{
|
{
|
||||||
use DefaultActionTrait;
|
use DefaultActionTrait;
|
||||||
|
|
||||||
@@ -21,15 +27,20 @@ final class Filter
|
|||||||
public array $reverseMappedQualities = [];
|
public array $reverseMappedQualities = [];
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly PreferencesRepository $preferencesRepository,
|
|
||||||
private readonly Security $security,
|
private readonly Security $security,
|
||||||
) {
|
) {
|
||||||
$this->preferences = Map::from($this->preferencesRepository->findEnabled())
|
$this->preferences = (array) PreferenceOptionsFactory::createSelectOptions();
|
||||||
->rekey(fn($element) => $element->getId())
|
$this->userPreferences = (array) UserPreferencesFactory::createFromUser($security->getUser());
|
||||||
->map(fn($element) => $element->getPreferenceOptions()->toArray())
|
|
||||||
->toArray();
|
|
||||||
$this->userPreferences = Map::from($this->security->getUser()->getUserPreferenceValues())
|
|
||||||
->toArray();
|
|
||||||
$this->reverseMappedQualities = QualityList::getAsReverseMap();
|
$this->reverseMappedQualities = QualityList::getAsReverseMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getResolutionOptions()
|
||||||
|
{
|
||||||
|
return ResolutionList::asSelectOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCodecOptions()
|
||||||
|
{
|
||||||
|
return CodecList::asSelectOptions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/User/Dto/PreferenceOptions.php
Normal file
14
src/User/Dto/PreferenceOptions.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Dto;
|
||||||
|
|
||||||
|
class PreferenceOptions
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public readonly array $resolutions,
|
||||||
|
public readonly array $codecs,
|
||||||
|
public readonly array $languages,
|
||||||
|
public readonly array $providers,
|
||||||
|
public readonly array $qualities,
|
||||||
|
) {}
|
||||||
|
}
|
||||||
23
src/User/Dto/PreferenceOptionsFactory.php
Normal file
23
src/User/Dto/PreferenceOptionsFactory.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Dto;
|
||||||
|
|
||||||
|
use App\User\Database\CodecList;
|
||||||
|
use App\User\Database\CountryLanguages;
|
||||||
|
use App\User\Database\ProviderList;
|
||||||
|
use App\User\Database\QualityList;
|
||||||
|
use App\User\Database\ResolutionList;
|
||||||
|
|
||||||
|
class PreferenceOptionsFactory
|
||||||
|
{
|
||||||
|
public static function createSelectOptions(): PreferenceOptions
|
||||||
|
{
|
||||||
|
return new PreferenceOptions(
|
||||||
|
resolutions: ResolutionList::asSelectOptions(),
|
||||||
|
codecs: CodecList::asSelectOptions(),
|
||||||
|
languages: CountryLanguages::asSelectOptions(),
|
||||||
|
providers: ProviderList::asSelectOptions(),
|
||||||
|
qualities: QualityList::asSelectOptions(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
value="{{ app.user.userPreferenceValues["resolution"] }}"
|
value="{{ app.user.userPreferenceValues["resolution"] }}"
|
||||||
>
|
>
|
||||||
<option value="">n/a</option>
|
<option value="">n/a</option>
|
||||||
{% for option in this.preferences['resolution'] %}
|
{% for name, value in this.resolutionOptions %}
|
||||||
<option value="{{ option.value }}"
|
<option value="{{ value }}"
|
||||||
{{ option.value == this.userPreferences['resolution'] ? 'selected' }}
|
{{ value == this.userPreferences['resolution'] ? 'selected' }}
|
||||||
>{{ option.name }}</option>
|
>{{ name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
@@ -26,10 +26,10 @@
|
|||||||
Codec
|
Codec
|
||||||
<select id="codec" data-result-filter-target="codec" class="px-1 py-0.5 bg-stone-100 text-sm text-gray-800 rounded-md">
|
<select id="codec" data-result-filter-target="codec" class="px-1 py-0.5 bg-stone-100 text-sm text-gray-800 rounded-md">
|
||||||
<option value="">n/a</option>
|
<option value="">n/a</option>
|
||||||
{% for option in this.preferences['codec'] %}
|
{% for name, value in this.codecOptions %}
|
||||||
<option value="{{ option.value }}"
|
<option value="{{ value }}"
|
||||||
{{ option.value == this.userPreferences['codec'] ? 'selected' }}
|
{{ value == this.userPreferences['codec'] ? 'selected' }}
|
||||||
>{{ option.name }}</option>
|
>{{ name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
|||||||
Reference in New Issue
Block a user