From 8d227803c0befd7c272a66ceefbcd1fe1b917a14 Mon Sep 17 00:00:00 2001 From: Ilya Stepenko <38462532+VampireAotD@users.noreply.github.com> Date: Fri, 10 Nov 2023 20:25:11 +0200 Subject: [PATCH] Refactored code --- .github/workflows/frontend-build.yml | 2 +- src/.prettierignore | 1 + .../Controllers/Anime/AnimeController.php | 2 - src/resources/js/Components/Carousel.vue | 7 +- .../js/Components/DashboardSlider.vue | 89 --------------- .../Components/DataTable/EasyTableWrapper.vue | 84 -------------- .../Telegram/TelegramLoginWidget.vue | 51 --------- .../js/Components/TelegramLoginWidget.vue | 72 ++++++++++++ .../{Theme/Switcher.vue => ThemeSwitcher.vue} | 5 +- .../js/Layouts/AuthenticatedLayout.vue | 6 +- src/resources/js/Pages/Anime/Index.vue | 101 +---------------- .../js/Pages/Anime/Partials/AddAnimeForm.vue | 32 ++++-- .../Pages/Anime/Partials/AddMethodModal.vue | 13 +++ .../js/Pages/Anime/Partials/DataTable.vue | 103 ++++++++++++++++++ src/resources/js/Pages/Anime/Show.vue | 2 +- .../js/Pages/Dashboard/Dashboard.vue | 2 +- .../Dashboard/Partials/CountPerDomain.vue | 6 +- .../Profile/Partials/IntegrationList.vue | 12 +- src/resources/js/app.ts | 11 +- src/resources/js/bootstrap.ts | 1 + .../Components/TelegramLoginWidget.test.ts | 74 +++++++++++++ .../js/tests/Components/ThemeSwitcher.test.ts | 24 ++++ .../tests/Layouts/AuthenticatedLayout.test.ts | 5 +- .../js/tests/plugins/user/authorize.test.ts | 12 +- src/resources/js/types/anime/props.ts | 18 --- .../js/types/anime/{models.ts => types.ts} | 6 + src/resources/js/types/index.d.ts | 13 +++ src/resources/js/types/telegram/enums.ts | 10 ++ src/resources/js/types/telegram/types.ts | 21 ---- .../Controllers/Anime/AnimeControllerTest.php | 2 +- src/tsconfig.json | 17 ++- 31 files changed, 403 insertions(+), 401 deletions(-) delete mode 100644 src/resources/js/Components/DashboardSlider.vue delete mode 100644 src/resources/js/Components/DataTable/EasyTableWrapper.vue delete mode 100644 src/resources/js/Components/Telegram/TelegramLoginWidget.vue create mode 100644 src/resources/js/Components/TelegramLoginWidget.vue rename src/resources/js/Components/{Theme/Switcher.vue => ThemeSwitcher.vue} (65%) create mode 100644 src/resources/js/Pages/Anime/Partials/AddMethodModal.vue create mode 100644 src/resources/js/Pages/Anime/Partials/DataTable.vue create mode 100644 src/resources/js/tests/Components/TelegramLoginWidget.test.ts create mode 100644 src/resources/js/tests/Components/ThemeSwitcher.test.ts delete mode 100644 src/resources/js/types/anime/props.ts rename src/resources/js/types/anime/{models.ts => types.ts} (83%) create mode 100644 src/resources/js/types/telegram/enums.ts diff --git a/.github/workflows/frontend-build.yml b/.github/workflows/frontend-build.yml index b4642e0f..dfdb4644 100644 --- a/.github/workflows/frontend-build.yml +++ b/.github/workflows/frontend-build.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: - node-version: [ 18.x ] + node-version: [ 20.x ] steps: - uses: actions/checkout@v4 diff --git a/src/.prettierignore b/src/.prettierignore index 1da59b79..f3d38c2c 100644 --- a/src/.prettierignore +++ b/src/.prettierignore @@ -6,3 +6,4 @@ !*.vue !*.ts !*.js +!tsconfig.json diff --git a/src/app/Http/Controllers/Anime/AnimeController.php b/src/app/Http/Controllers/Anime/AnimeController.php index 3cecfff5..b8af67e5 100644 --- a/src/app/Http/Controllers/Anime/AnimeController.php +++ b/src/app/Http/Controllers/Anime/AnimeController.php @@ -13,7 +13,6 @@ use App\Models\Anime; use App\Repositories\Anime\AnimeRepositoryInterface; use App\Repositories\Filters\ColumnFilter; -use App\Repositories\Filters\RelationFilter; use App\Repositories\Params\PaginationParams; use App\Services\AnimeService; use Illuminate\Http\RedirectResponse; @@ -40,7 +39,6 @@ public function index(IndexRequest $request): Response $filter = new PaginationParams($page, $perPage); $pagination = $this->animeRepository->withFilters([ new ColumnFilter(['id', 'title', 'episodes', 'rating', 'status']), - new RelationFilter(['image:model_id,path']), ])->paginate($filter); return Inertia::render('Anime/Index', compact('pagination')); diff --git a/src/resources/js/Components/Carousel.vue b/src/resources/js/Components/Carousel.vue index 5154a3e3..6eebd351 100644 --- a/src/resources/js/Components/Carousel.vue +++ b/src/resources/js/Components/Carousel.vue @@ -1,8 +1,7 @@ - - - - diff --git a/src/resources/js/Components/DataTable/EasyTableWrapper.vue b/src/resources/js/Components/DataTable/EasyTableWrapper.vue deleted file mode 100644 index d284b495..00000000 --- a/src/resources/js/Components/DataTable/EasyTableWrapper.vue +++ /dev/null @@ -1,84 +0,0 @@ - - - - - diff --git a/src/resources/js/Components/Telegram/TelegramLoginWidget.vue b/src/resources/js/Components/Telegram/TelegramLoginWidget.vue deleted file mode 100644 index 9eb22187..00000000 --- a/src/resources/js/Components/Telegram/TelegramLoginWidget.vue +++ /dev/null @@ -1,51 +0,0 @@ - - - - - diff --git a/src/resources/js/Components/TelegramLoginWidget.vue b/src/resources/js/Components/TelegramLoginWidget.vue new file mode 100644 index 00000000..907c3b03 --- /dev/null +++ b/src/resources/js/Components/TelegramLoginWidget.vue @@ -0,0 +1,72 @@ + + + + + diff --git a/src/resources/js/Components/Theme/Switcher.vue b/src/resources/js/Components/ThemeSwitcher.vue similarity index 65% rename from src/resources/js/Components/Theme/Switcher.vue rename to src/resources/js/Components/ThemeSwitcher.vue index dcd836b7..0840aacf 100644 --- a/src/resources/js/Components/Theme/Switcher.vue +++ b/src/resources/js/Components/ThemeSwitcher.vue @@ -1,6 +1,6 @@ -
-
-
- - Add new anime - -
- -
- - - - - - - - - - - - - - - -
-
+
+
diff --git a/src/resources/js/Pages/Anime/Partials/AddAnimeForm.vue b/src/resources/js/Pages/Anime/Partials/AddAnimeForm.vue index ac464c36..2bb77caf 100644 --- a/src/resources/js/Pages/Anime/Partials/AddAnimeForm.vue +++ b/src/resources/js/Pages/Anime/Partials/AddAnimeForm.vue @@ -4,9 +4,8 @@ import InputLabel from '@/Components/InputLabel.vue'; import InputError from '@/Components/InputError.vue'; import PrimaryButton from '@/Components/PrimaryButton.vue'; import { useForm, usePage } from '@inertiajs/vue3'; -import { useToast } from 'vue-toast-notification'; -import 'vue-toast-notification/dist/theme-sugar.css'; import { ScrapeResult } from '@/types/pusher/types'; +import { useToast } from 'primevue/usetoast'; const page = usePage(); const toast = useToast(); @@ -24,25 +23,40 @@ const addAnime = () => { onSuccess: () => { const channelName = `scraper.${page.props.auth?.user?.id}`; - toast.info(page.props.flash.message, { position: 'bottom' }); + toast.add({ + summary: page.props.flash.message, + }); + emit('added', form.url); window.echo .private(channelName) .listen('.scrape.result', (result: ScrapeResult) => { - toast.info(result.message, { - position: 'bottom', - type: result.type, + toast.add({ + summary: result.message, + severity: result.type, + closable: true, }); + window.echo.leave(channelName); }) .error(() => { - toast.error('Error while establishing Pusher connection', { - position: 'bottom', + toast.add({ + summary: 'Error while establishing Pusher connection', + severity: 'error', + closable: true, }); + window.echo.leave(channelName); }); }, + onError: (error) => { + toast.add({ + summary: error?.url ?? 'Unexpected error', + severity: 'error', + closable: true, + }); + }, onFinish: () => { form.reset(); }, @@ -77,6 +91,8 @@ const addAnime = () => {
Add
+ + diff --git a/src/resources/js/Pages/Anime/Partials/AddMethodModal.vue b/src/resources/js/Pages/Anime/Partials/AddMethodModal.vue new file mode 100644 index 00000000..b3371829 --- /dev/null +++ b/src/resources/js/Pages/Anime/Partials/AddMethodModal.vue @@ -0,0 +1,13 @@ + + + + + diff --git a/src/resources/js/Pages/Anime/Partials/DataTable.vue b/src/resources/js/Pages/Anime/Partials/DataTable.vue new file mode 100644 index 00000000..d9399238 --- /dev/null +++ b/src/resources/js/Pages/Anime/Partials/DataTable.vue @@ -0,0 +1,103 @@ + + + + + diff --git a/src/resources/js/Pages/Anime/Show.vue b/src/resources/js/Pages/Anime/Show.vue index eb17f63f..2de01dbd 100644 --- a/src/resources/js/Pages/Anime/Show.vue +++ b/src/resources/js/Pages/Anime/Show.vue @@ -1,6 +1,6 @@