wip: ajax notifications w/ php-flasher

This commit is contained in:
2025-04-27 08:21:30 -05:00
parent a1a38cb74c
commit 48a601f58d
12 changed files with 204 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
APP_SECRET="%%app_secret%%"
DATABASE_URL="%%db_url%%"
DOWNLOAD_DIR=%%download_dir%%
REAL_DEBRID_KEY="%%rd_key%%"

View File

@@ -1,5 +1,5 @@
import { Controller } from '@hotwired/stimulus';
import flasher from '@flasher/flasher'
/*
* The following line makes this controller "lazy": it won't be downloaded until needed
* See https://github.com/symfony/stimulus-bridge#lazy-controllers
@@ -31,7 +31,7 @@ export default class extends Controller {
})
.then(res => res.json())
.then(json => {
console.log(json)
})
flasher.success(json.message);
})
}
}

View File

@@ -24,6 +24,7 @@
<copy file="${project.basedir}/.env.dist" tofile="${project.basedir}/.env.local" overwrite="true">
<filterchain>
<replacetokens begintoken="%%" endtoken="%%">
<token key="app_secret" value="${APP_SECRET}" />
<token key="db_url" value="${DATABASE_URL}" />
<token key="download_dir" value="${DOWNLOAD_DIR}" />
<token key="rd_key" value="${REAL_DEBRID_KEY}" />

View File

@@ -15,6 +15,7 @@
"nihilarr/parse-torrent-name": "^0.0.1",
"nyholm/psr7": "*",
"p3k/emoji-detector": "^1.2",
"php-flasher/flasher-symfony": "^2.1",
"php-tmdb/api": "^4.1",
"symfony/asset": "7.2.*",
"symfony/console": "7.2.*",

137
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "09d927397449bd08c7c2b96e35d2bd60",
"content-hash": "02f1ff0023fc6fb23a0307520495e75c",
"packages": [
{
"name": "1tomany/data-uri",
@@ -1780,6 +1780,141 @@
},
"time": "2024-02-19T18:29:05+00:00"
},
{
"name": "php-flasher/flasher",
"version": "v2.1.6",
"source": {
"type": "git",
"url": "https://github.com/php-flasher/flasher.git",
"reference": "054a209515d2eb1bb72467023d8614a29b5d2e60"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-flasher/flasher/zipball/054a209515d2eb1bb72467023d8614a29b5d2e60",
"reference": "054a209515d2eb1bb72467023d8614a29b5d2e60",
"shasum": ""
},
"require": {
"php": ">=8.2"
},
"type": "library",
"autoload": {
"files": [
"functions.php",
"helpers.php"
],
"psr-4": {
"Flasher\\Prime\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Younes ENNAJI",
"email": "younes.ennaji.pro@gmail.com",
"homepage": "https://www.linkedin.com/in/younes--ennaji/",
"role": "Developer"
}
],
"description": "The foundational PHP library for PHPFlasher, enabling the creation of framework-agnostic flash notifications. Ideal for building custom integrations or for use in PHP projects.",
"homepage": "https://php-flasher.io",
"keywords": [
"custom-integrations",
"flash-notifications",
"flasher-core",
"framework-agnostic",
"open-source",
"php"
],
"support": {
"issues": "https://github.com/php-flasher/php-flasher/issues",
"source": "https://github.com/php-flasher/php-flasher"
},
"funding": [
{
"url": "https://www.paypal.com/paypalme/yoeunes",
"type": "custom"
},
{
"url": "https://github.com/yoeunes",
"type": "github"
}
],
"time": "2025-02-21T20:05:00+00:00"
},
{
"name": "php-flasher/flasher-symfony",
"version": "v2.1.6",
"source": {
"type": "git",
"url": "https://github.com/php-flasher/flasher-symfony.git",
"reference": "14bd1ba6bbd1184bde0300a5b02455e886845cea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-flasher/flasher-symfony/zipball/14bd1ba6bbd1184bde0300a5b02455e886845cea",
"reference": "14bd1ba6bbd1184bde0300a5b02455e886845cea",
"shasum": ""
},
"require": {
"php": ">=8.2",
"php-flasher/flasher": "^2.1.6",
"symfony/config": "^7.0",
"symfony/console": "^7.0",
"symfony/dependency-injection": "^7.0",
"symfony/http-kernel": "^7.0"
},
"suggest": {
"symfony/translation": "To translate flash messages, title and presets",
"symfony/ux-twig-component": "To utilize and interact with flash messages components in Twig templates"
},
"type": "symfony-bundle",
"autoload": {
"psr-4": {
"Flasher\\Symfony\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Younes ENNAJI",
"email": "younes.ennaji.pro@gmail.com",
"homepage": "https://www.linkedin.com/in/younes--ennaji/",
"role": "Developer"
}
],
"description": "Integrate flash notifications into Symfony projects effortlessly with PHPFlasher. Improve user experience and application feedback loops easily.",
"homepage": "https://php-flasher.io",
"keywords": [
"flash-notifications",
"open-source",
"php",
"phpflasher",
"symfony",
"user-feedback"
],
"support": {
"issues": "https://github.com/php-flasher/php-flasher/issues",
"source": "https://github.com/php-flasher/php-flasher"
},
"funding": [
{
"url": "https://www.paypal.com/paypalme/yoeunes",
"type": "custom"
},
{
"url": "https://github.com/yoeunes",
"type": "github"
}
],
"time": "2025-02-21T20:05:00+00:00"
},
{
"name": "php-http/discovery",
"version": "1.20.0",

View File

@@ -14,4 +14,5 @@ return [
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\UX\LiveComponent\LiveComponentBundle::class => ['all' => true],
Flasher\Symfony\FlasherSymfonyBundle::class => ['all' => true],
];

View File

@@ -0,0 +1,48 @@
flasher:
# Default notification library (e.g., 'flasher', 'toastr', 'noty', 'notyf', 'sweetalert')
default: flasher
# Path to the main PHPFlasher JavaScript file
main_script: '/vendor/flasher/flasher.min.js'
# List of CSS files to style your notifications
styles:
- '/vendor/flasher/flasher.min.css'
# Set global options for all notifications (optional)
# options:
# # Time in milliseconds before the notification disappears
# timeout: 5000
# # Where the notification appears on the screen
# position: 'top-right'
# Automatically inject JavaScript and CSS assets into your HTML pages
inject_assets: true
# Enable message translation using Symfony's translation service
translate: true
# URL patterns to exclude from asset injection and flash_bag conversion
excluded_paths:
- '/^\/_profiler/'
- '/^\/_fragment/'
# Map Symfony flash message keys to notification types
flash_bag:
success: ['success']
error: ['error', 'danger']
warning: ['warning', 'alarm']
info: ['info', 'notice', 'alert']
# Set criteria to filter which notifications are displayed (optional)
# filter:
# # Maximum number of notifications to show at once
# limit: 5
# Define notification presets to simplify notification creation (optional)
# presets:
# # Example preset:
# entity_saved:
# type: 'success'
# title: 'Entity saved'
# message: 'Entity saved successfully'

View File

@@ -25,4 +25,7 @@ return [
'@symfony/ux-live-component' => [
'path' => './vendor/symfony/ux-live-component/assets/dist/live_controller.js',
],
'@flasher/flasher' => [
'version' => '2.1.5',
],
];

2
public/vendor/flasher/flasher.min.css vendored Normal file

File diff suppressed because one or more lines are too long

1
public/vendor/flasher/flasher.min.js vendored Normal file

File diff suppressed because one or more lines are too long

4
public/vendor/flasher/manifest.json vendored Normal file
View File

@@ -0,0 +1,4 @@
{
"/vendor/flasher/flasher.min.js": "/vendor/flasher/flasher.min.js?id=9a255a6680873c0d5fc3d394a2ba3195",
"/vendor/flasher/flasher.min.css": "/vendor/flasher/flasher.min.css?id=7a96e40c68626198d5128ad2fb5d77e0"
}

View File

@@ -29,6 +29,9 @@
"migrations/.gitignore"
]
},
"php-flasher/flasher-symfony": {
"version": "v2.1.6"
},
"php-http/discovery": {
"version": "1.20",
"recipe": {