Skip to content

Commit

Permalink
Update vue stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
pkly committed Feb 12, 2024
1 parent 1034e26 commit b855541
Show file tree
Hide file tree
Showing 25 changed files with 725 additions and 18 deletions.
57 changes: 57 additions & 0 deletions migrations/Version20240212183141.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?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 Version20240212183141 extends AbstractMigration
{
public function getDescription(): string
{
return 'Symfony 7 update, with new entities n so on.';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE footer_link (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, url VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL, priority SMALLINT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE link_block (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, title VARCHAR(255) NOT NULL, description VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE sub_link_block (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, url VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL, link_block_id INT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_6B58312447E2C5 ON sub_link_block (link_block_id)');
$this->addSql('ALTER TABLE sub_link_block ADD CONSTRAINT FK_6B58312447E2C5 FOREIGN KEY (link_block_id) REFERENCES link_block (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE mascot_group ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE mascot_group ALTER directories TYPE JSON USING (directories::JSON)');
$this->addSql('COMMENT ON COLUMN mascot_group.directories IS \'\'');
$this->addSql('ALTER TABLE rss__group ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE rss__result ADD created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL');
$this->addSql('ALTER TABLE rss__result ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE rss__result ALTER seen_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
$this->addSql('COMMENT ON COLUMN rss__result.seen_at IS \'\'');
$this->addSql('ALTER TABLE rss__search ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE sub_link_block DROP CONSTRAINT FK_6B58312447E2C5');
$this->addSql('DROP TABLE footer_link');
$this->addSql('DROP TABLE link_block');
$this->addSql('DROP TABLE sub_link_block');
$this->addSql('ALTER TABLE mascot_group ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE mascot_group ALTER directories TYPE TEXT');
$this->addSql('COMMENT ON COLUMN mascot_group.directories IS \'(DC2Type:array)\'');
$this->addSql('ALTER TABLE rss__group ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE rss__search ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE rss__result DROP created_at');
$this->addSql('ALTER TABLE rss__result ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE rss__result ALTER seen_at TYPE DATE');
$this->addSql('COMMENT ON COLUMN rss__result.seen_at IS \'(DC2Type:date_immutable)\'');
}
}
17 changes: 16 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"pinia": "^2.1.7",
"pinia-plugin-persistedstate": "^3.2.1",
"vue": "^3.4.15",
"vue-router": "^4.2.5"
"vue-router": "^4.2.5",
"vue-safe-teleport": "^0.1.2"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.3.3",
Expand Down
7 changes: 7 additions & 0 deletions src/Controller/Admin/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\Controller\Admin;

use App\Entity\FooterLink;
use App\Entity\LinkBlock;
use App\Entity\MascotGroup;
use App\Entity\Rss\Group;
use App\Entity\Rss\Result;
Expand Down Expand Up @@ -38,6 +40,11 @@ public function configureMenuItems(): iterable
yield MenuItem::linkToCrud('Groups', 'fa fa-home', Group::class);
yield MenuItem::linkToCrud('Results', 'fa fa-home', Result::class);
yield MenuItem::linkToCrud('Searches', 'fa fa-home', Search::class);

yield MenuItem::section();

yield MenuItem::linkToCrud('Link blocks', 'fa fa-home', LinkBlock::class);
yield MenuItem::linkToCrud('Footer links', 'fa fa-home', FooterLink::class);
}

public function configureCrud(): Crud
Expand Down
29 changes: 29 additions & 0 deletions src/Controller/Admin/FooterLinkCrudController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Controller\Admin;

use App\Entity\FooterLink;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;

class FooterLinkCrudController extends AbstractCrudController
{
#[\Override]
public static function getEntityFqcn(): string
{
return FooterLink::class;
}

#[\Override]
public function configureFields(string $pageName): iterable
{
yield IdField::new('id')
->hideOnForm();

yield TextField::new('url');
yield TextField::new('title');
yield NumberField::new('priority');
}
}
35 changes: 35 additions & 0 deletions src/Controller/Admin/LinkBlockCrudController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\Controller\Admin;

use App\Entity\LinkBlock;
use App\Form\SubLinkBlockType;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\CollectionField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;

class LinkBlockCrudController extends AbstractCrudController
{

#[\Override]
public static function getEntityFqcn(): string
{
return LinkBlock::class;
}

#[\Override]
public function configureFields(string $pageName): iterable
{
yield IdField::new('id')
->hideOnForm();

yield TextField::new('title');
yield TextField::new('description');
yield CollectionField::new('subLinkBlocks')
->setEntryType(SubLinkBlockType::class)
->setFormTypeOption('by_reference', false)
->allowAdd()
->allowDelete();
}
}
24 changes: 24 additions & 0 deletions src/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Controller;

use App\Entity\Rss\Result;
use App\Repository\FooterLinkRepository;
use App\Repository\LinkBlockRepository;
use App\Repository\Rss\ResultRepository;
use App\Service\MascotService;
use App\Service\QBitTorrentService;
Expand Down Expand Up @@ -68,4 +70,26 @@ public function getPageTitles(
): JsonResponse {
return $this->json($service->getTitles());
}

#[Route('/footer-links', name: 'footer_links', methods: ['GET'])]
public function getFooterLinks(
FooterLinkRepository $repository
): JsonResponse {
return $this->json($repository->findBy([], ['priority' => 'DESC']), context: [
AbstractNormalizer::GROUPS => [
'api',
],
]);
}

#[Route('/link-blocks', name: 'link_blocks', methods: ['GET'])]
public function getLinkBlocks(
LinkBlockRepository $repository
): JsonResponse {
return $this->json($repository->findAll(), context: [
AbstractNormalizer::GROUPS => [
'api',
],
]);
}
}
72 changes: 72 additions & 0 deletions src/Entity/FooterLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace App\Entity;

use App\Repository\FooterLinkRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;

#[ORM\Entity(repositoryClass: FooterLinkRepository::class)]
class FooterLink
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private int|null $id = null;

#[ORM\Column(length: 255)]
#[Groups('api')]
private string|null $url = null;

#[ORM\Column(length: 255)]
#[Groups('api')]
private string|null $title = null;

#[ORM\Column(type: Types::SMALLINT)]
private int|null $priority = null;

public function getId(): int|null
{
return $this->id;
}

public function getUrl(): string|null
{
return $this->url;
}

public function setUrl(
string $url
): static {
$this->url = $url;

return $this;
}

public function getTitle(): string|null
{
return $this->title;
}

public function setTitle(
string $title
): static {
$this->title = $title;

return $this;
}

public function getPriority(): int|null
{
return $this->priority;
}

public function setPriority(
int $priority
): static {
$this->priority = $priority;

return $this;
}
}
Loading

0 comments on commit b855541

Please sign in to comment.