wip-feat: mercure alerts
This commit is contained in:
@@ -1 +1,4 @@
|
||||
FROM registry.caldwell.digital/library/php:8.4-apache
|
||||
|
||||
COPY ./bash/vhost.conf /etc/apache2/sites-enabled/vhost.conf
|
||||
RUN rm /etc/apache2/sites-enabled/000-default.conf
|
||||
|
||||
@@ -8,3 +8,13 @@ import './bootstrap.js';
|
||||
import './styles/app.css';
|
||||
|
||||
console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉');
|
||||
|
||||
let alert = document.querySelector('.alert');
|
||||
var observer = new MutationObserver(function(mutations) {
|
||||
if (document.contains(alert)) {
|
||||
observer.disconnect();
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(document, {attributes: false, childList: true, characterData: false, subtree:true});
|
||||
|
||||
|
||||
@@ -8,6 +8,16 @@
|
||||
"@symfony/ux-live-component/dist/live.min.css": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"@symfony/ux-turbo": {
|
||||
"turbo-core": {
|
||||
"enabled": true,
|
||||
"fetch": "eager"
|
||||
},
|
||||
"mercure-turbo-stream": {
|
||||
"enabled": true,
|
||||
"fetch": "eager"
|
||||
}
|
||||
}
|
||||
},
|
||||
"entrypoints": []
|
||||
|
||||
18
assets/controllers/alert_controller.js
Normal file
18
assets/controllers/alert_controller.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Controller } from '@hotwired/stimulus';
|
||||
|
||||
export default class extends Controller {
|
||||
connect() {
|
||||
let timer = setTimeout(() => {
|
||||
this.element.remove();
|
||||
},
|
||||
"3000"
|
||||
);
|
||||
|
||||
this.element.addEventListener('mouseout', () => timer = setTimeout(() => {
|
||||
this.element.remove();
|
||||
},
|
||||
"3000"
|
||||
));
|
||||
this.element.addEventListener('mouseover', () => clearTimeout(timer));
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,11 @@
|
||||
DocumentRoot /var/www/public
|
||||
DirectoryIndex /index.php
|
||||
|
||||
<LocationMatch "/hub/">
|
||||
ProxyPass http://mercure:80/
|
||||
ProxyPassReverse http://mercure:80/
|
||||
</LocationMatch>
|
||||
|
||||
<Directory /var/www/public>
|
||||
AllowOverride None
|
||||
Order Allow,Deny
|
||||
|
||||
20
compose.yml
20
compose.yml
@@ -24,6 +24,24 @@ services:
|
||||
- ./var/download:/var/download
|
||||
command: php ./bin/console messenger:consume async -v --time-limit=3600 --limit=10
|
||||
|
||||
mercure:
|
||||
image: dunglas/mercure
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:80"
|
||||
environment:
|
||||
SERVER_NAME: ':80'
|
||||
MERCURE_PUBLISHER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
||||
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
||||
MERCURE_EXTRA_DIRECTIVES: |
|
||||
cors_origins *
|
||||
anonymous
|
||||
command: /usr/bin/caddy run --config /etc/caddy/dev.Caddyfile
|
||||
volumes:
|
||||
- mercure_data:/data
|
||||
- mercure_config:/config
|
||||
|
||||
|
||||
database:
|
||||
image: mariadb:10.11.2
|
||||
ports:
|
||||
@@ -43,3 +61,5 @@ services:
|
||||
|
||||
volumes:
|
||||
mysql:
|
||||
mercure_data:
|
||||
mercure_config:
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"symfony/flex": "^2",
|
||||
"symfony/form": "7.2.*",
|
||||
"symfony/framework-bundle": "7.2.*",
|
||||
"symfony/mercure-bundle": "^0.3.9",
|
||||
"symfony/messenger": "7.2.*",
|
||||
"symfony/runtime": "7.2.*",
|
||||
"symfony/security-bundle": "7.2.*",
|
||||
@@ -30,6 +31,7 @@
|
||||
"symfony/twig-bundle": "7.2.*",
|
||||
"symfony/ux-icons": "^2.24",
|
||||
"symfony/ux-live-component": "^2.24",
|
||||
"symfony/ux-turbo": "^2.24",
|
||||
"symfony/ux-twig-component": "^2.24",
|
||||
"symfony/yaml": "7.2.*",
|
||||
"symfonycasts/tailwind-bundle": "^0.10.0",
|
||||
|
||||
479
composer.lock
generated
479
composer.lock
generated
@@ -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": "740c22e45c004ece09230b2bb113e949",
|
||||
"packages": [
|
||||
{
|
||||
"name": "1tomany/data-uri",
|
||||
@@ -1421,6 +1421,79 @@
|
||||
},
|
||||
"time": "2025-01-24T11:45:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "lcobucci/jwt",
|
||||
"version": "5.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/lcobucci/jwt.git",
|
||||
"reference": "a835af59b030d3f2967725697cf88300f579088e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/lcobucci/jwt/zipball/a835af59b030d3f2967725697cf88300f579088e",
|
||||
"reference": "a835af59b030d3f2967725697cf88300f579088e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-openssl": "*",
|
||||
"ext-sodium": "*",
|
||||
"php": "~8.2.0 || ~8.3.0 || ~8.4.0",
|
||||
"psr/clock": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"infection/infection": "^0.29",
|
||||
"lcobucci/clock": "^3.2",
|
||||
"lcobucci/coding-standard": "^11.0",
|
||||
"phpbench/phpbench": "^1.2",
|
||||
"phpstan/extension-installer": "^1.2",
|
||||
"phpstan/phpstan": "^1.10.7",
|
||||
"phpstan/phpstan-deprecation-rules": "^1.1.3",
|
||||
"phpstan/phpstan-phpunit": "^1.3.10",
|
||||
"phpstan/phpstan-strict-rules": "^1.5.0",
|
||||
"phpunit/phpunit": "^11.1"
|
||||
},
|
||||
"suggest": {
|
||||
"lcobucci/clock": ">= 3.2"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Lcobucci\\JWT\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Luís Cobucci",
|
||||
"email": "lcobucci@gmail.com",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "A simple library to work with JSON Web Token and JSON Web Signature",
|
||||
"keywords": [
|
||||
"JWS",
|
||||
"jwt"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/lcobucci/jwt/issues",
|
||||
"source": "https://github.com/lcobucci/jwt/tree/5.5.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/lcobucci",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://www.patreon.com/lcobucci",
|
||||
"type": "patreon"
|
||||
}
|
||||
],
|
||||
"time": "2025-01-26T21:29:45+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nihilarr/parse-torrent-name",
|
||||
"version": "v0.0.1",
|
||||
@@ -2548,6 +2621,62 @@
|
||||
},
|
||||
"time": "2023-04-04T09:50:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/link",
|
||||
"version": "2.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/link.git",
|
||||
"reference": "84b159194ecfd7eaa472280213976e96415433f7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/link/zipball/84b159194ecfd7eaa472280213976e96415433f7",
|
||||
"reference": "84b159194ecfd7eaa472280213976e96415433f7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.0.0"
|
||||
},
|
||||
"suggest": {
|
||||
"fig/link-util": "Provides some useful PSR-13 utilities"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Link\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interfaces for HTTP links",
|
||||
"homepage": "https://github.com/php-fig/link",
|
||||
"keywords": [
|
||||
"http",
|
||||
"http-link",
|
||||
"link",
|
||||
"psr",
|
||||
"psr-13",
|
||||
"rest"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-fig/link/tree/2.0.1"
|
||||
},
|
||||
"time": "2021-03-11T23:00:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
"version": "3.0.2",
|
||||
@@ -4656,6 +4785,173 @@
|
||||
],
|
||||
"time": "2025-03-28T13:32:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/mercure",
|
||||
"version": "v0.6.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/mercure.git",
|
||||
"reference": "304cf84609ef645d63adc65fc6250292909a461b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/mercure/zipball/304cf84609ef645d63adc65fc6250292909a461b",
|
||||
"reference": "304cf84609ef645d63adc65fc6250292909a461b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1.3",
|
||||
"symfony/deprecation-contracts": "^2.0|^3.0|^4.0",
|
||||
"symfony/http-client": "^4.4|^5.0|^6.0|^7.0",
|
||||
"symfony/http-foundation": "^4.4|^5.0|^6.0|^7.0",
|
||||
"symfony/polyfill-php80": "^1.22",
|
||||
"symfony/web-link": "^4.4|^5.0|^6.0|^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"lcobucci/jwt": "^3.4|^4.0|^5.0",
|
||||
"symfony/event-dispatcher": "^4.4|^5.0|^6.0|^7.0",
|
||||
"symfony/http-kernel": "^4.4|^5.0|^6.0|^7.0",
|
||||
"symfony/phpunit-bridge": "^5.2|^6.0|^7.0",
|
||||
"symfony/stopwatch": "^4.4|^5.0|^6.0|^7.0",
|
||||
"twig/twig": "^2.0|^3.0|^4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/stopwatch": "Integration with the profiler performances"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
"url": "https://github.com/dunglas/mercure",
|
||||
"name": "dunglas/mercure"
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-main": "0.6.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Mercure\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kévin Dunglas",
|
||||
"email": "dunglas@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Mercure Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"mercure",
|
||||
"push",
|
||||
"sse",
|
||||
"updates"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/symfony/mercure/issues",
|
||||
"source": "https://github.com/symfony/mercure/tree/v0.6.5"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/dunglas",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/mercure",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-04-08T12:51:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/mercure-bundle",
|
||||
"version": "v0.3.9",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/mercure-bundle.git",
|
||||
"reference": "77435d740b228e9f5f3f065b6db564f85f2cdb64"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/mercure-bundle/zipball/77435d740b228e9f5f3f065b6db564f85f2cdb64",
|
||||
"reference": "77435d740b228e9f5f3f065b6db564f85f2cdb64",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"lcobucci/jwt": "^3.4|^4.0|^5.0",
|
||||
"php": ">=7.1.3",
|
||||
"symfony/config": "^4.4|^5.0|^6.0|^7.0",
|
||||
"symfony/dependency-injection": "^4.4|^5.4|^6.0|^7.0",
|
||||
"symfony/http-kernel": "^4.4|^5.0|^6.0|^7.0",
|
||||
"symfony/mercure": "^0.6.1",
|
||||
"symfony/web-link": "^4.4|^5.0|^6.0|^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^4.3.7|^5.0|^6.0|^7.0",
|
||||
"symfony/stopwatch": "^4.3.7|^5.0|^6.0|^7.0",
|
||||
"symfony/ux-turbo": "*",
|
||||
"symfony/var-dumper": "^4.3.7|^5.0|^6.0|^7.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/messenger": "To use the Messenger integration"
|
||||
},
|
||||
"type": "symfony-bundle",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "0.3.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Bundle\\MercureBundle\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kévin Dunglas",
|
||||
"email": "dunglas@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony MercureBundle",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"mercure",
|
||||
"push",
|
||||
"sse",
|
||||
"updates"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/symfony/mercure-bundle/issues",
|
||||
"source": "https://github.com/symfony/mercure-bundle/tree/v0.3.9"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/dunglas",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/mercure-bundle",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-05-31T09:07:18+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/messenger",
|
||||
"version": "v7.2.5",
|
||||
@@ -7070,6 +7366,104 @@
|
||||
],
|
||||
"time": "2025-03-12T08:41:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/ux-turbo",
|
||||
"version": "v2.24.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/ux-turbo.git",
|
||||
"reference": "22954300bd0b01ca46f17c7890ea15138d9cf67f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/ux-turbo/zipball/22954300bd0b01ca46f17c7890ea15138d9cf67f",
|
||||
"reference": "22954300bd0b01ca46f17c7890ea15138d9cf67f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1",
|
||||
"symfony/stimulus-bundle": "^2.9.1"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/flex": "<1.13"
|
||||
},
|
||||
"require-dev": {
|
||||
"dbrekelmans/bdi": "dev-main",
|
||||
"doctrine/doctrine-bundle": "^2.4.3",
|
||||
"doctrine/orm": "^2.8 | 3.0",
|
||||
"phpstan/phpstan": "^1.10",
|
||||
"symfony/asset-mapper": "^6.4|^7.0",
|
||||
"symfony/debug-bundle": "^5.4|^6.0|^7.0",
|
||||
"symfony/expression-language": "^5.4|^6.0|^7.0",
|
||||
"symfony/form": "^5.4|^6.0|^7.0",
|
||||
"symfony/framework-bundle": "^6.4|^7.0",
|
||||
"symfony/mercure-bundle": "^0.3.7",
|
||||
"symfony/messenger": "^5.4|^6.0|^7.0",
|
||||
"symfony/panther": "^2.1",
|
||||
"symfony/phpunit-bridge": "^5.4|^6.0|^7.0",
|
||||
"symfony/process": "^5.4|6.3.*|^7.0",
|
||||
"symfony/property-access": "^5.4|^6.0|^7.0",
|
||||
"symfony/security-core": "^5.4|^6.0|^7.0",
|
||||
"symfony/stopwatch": "^5.4|^6.0|^7.0",
|
||||
"symfony/twig-bundle": "^6.4|^7.0",
|
||||
"symfony/ux-twig-component": "^2.21",
|
||||
"symfony/web-profiler-bundle": "^5.4|^6.0|^7.0"
|
||||
},
|
||||
"type": "symfony-bundle",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
"url": "https://github.com/symfony/ux",
|
||||
"name": "symfony/ux"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\UX\\Turbo\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kévin Dunglas",
|
||||
"email": "kevin@dunglas.fr"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Hotwire Turbo integration for Symfony",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"hotwire",
|
||||
"javascript",
|
||||
"mercure",
|
||||
"symfony-ux",
|
||||
"turbo",
|
||||
"turbo-stream"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/ux-turbo/tree/v2.24.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2025-04-04T17:29:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/ux-twig-component",
|
||||
"version": "v2.24.0",
|
||||
@@ -7409,6 +7803,89 @@
|
||||
],
|
||||
"time": "2025-03-13T12:21:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/web-link",
|
||||
"version": "v7.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/web-link.git",
|
||||
"reference": "f537556a885e14a1d28f6c759d41e57e93d0a532"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/web-link/zipball/f537556a885e14a1d28f6c759d41e57e93d0a532",
|
||||
"reference": "f537556a885e14a1d28f6c759d41e57e93d0a532",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.2",
|
||||
"psr/link": "^1.1|^2.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/http-kernel": "<6.4"
|
||||
},
|
||||
"provide": {
|
||||
"psr/link-implementation": "1.0|2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/http-kernel": "^6.4|^7.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\WebLink\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kévin Dunglas",
|
||||
"email": "dunglas@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Manages links between resources",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"dns-prefetch",
|
||||
"http",
|
||||
"http2",
|
||||
"link",
|
||||
"performance",
|
||||
"prefetch",
|
||||
"preload",
|
||||
"prerender",
|
||||
"psr13",
|
||||
"push"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/web-link/tree/v7.2.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-25T14:21:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v7.2.5",
|
||||
|
||||
@@ -14,4 +14,6 @@ return [
|
||||
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
|
||||
Symfony\UX\LiveComponent\LiveComponentBundle::class => ['all' => true],
|
||||
Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true],
|
||||
Symfony\UX\Turbo\TurboBundle::class => ['all' => true],
|
||||
];
|
||||
|
||||
8
config/packages/mercure.yaml
Normal file
8
config/packages/mercure.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
mercure:
|
||||
hubs:
|
||||
default:
|
||||
url: '%env(MERCURE_URL)%'
|
||||
public_url: '%env(MERCURE_PUBLIC_URL)%'
|
||||
jwt:
|
||||
secret: '%env(MERCURE_JWT_SECRET)%'
|
||||
publish: '*'
|
||||
@@ -25,4 +25,7 @@ return [
|
||||
'@symfony/ux-live-component' => [
|
||||
'path' => './vendor/symfony/ux-live-component/assets/dist/live_controller.js',
|
||||
],
|
||||
'@hotwired/turbo' => [
|
||||
'version' => '7.3.0',
|
||||
],
|
||||
];
|
||||
|
||||
37
src/Controller/AlertController.php
Normal file
37
src/Controller/AlertController.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Mercure\HubInterface;
|
||||
use Symfony\Component\Mercure\Update;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Twig\Environment;
|
||||
|
||||
final class AlertController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
#[Autowire(service: 'twig')] private readonly Environment $renderer,
|
||||
private readonly HubInterface $hub,
|
||||
) {}
|
||||
|
||||
#[Route('/alert', name: 'app_alert')]
|
||||
public function index(): Response
|
||||
{
|
||||
$update = new Update(
|
||||
'alerts',
|
||||
$this->renderer->render('broadcast/Alert.html.twig', [
|
||||
'alert_id' => 1,
|
||||
'title' => 'Added to queue',
|
||||
'message' => 'This is a testy test!',
|
||||
])
|
||||
);
|
||||
|
||||
$this->hub->publish($update);
|
||||
return $this->json([
|
||||
'Success' => 'Published'
|
||||
]);
|
||||
}
|
||||
}
|
||||
12
src/Twig/Components/Alert.php
Normal file
12
src/Twig/Components/Alert.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Twig\Components;
|
||||
|
||||
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
|
||||
use Symfony\UX\LiveComponent\DefaultActionTrait;
|
||||
|
||||
#[AsLiveComponent]
|
||||
final class Alert
|
||||
{
|
||||
use DefaultActionTrait;
|
||||
}
|
||||
21
symfony.lock
21
symfony.lock
@@ -121,6 +121,18 @@
|
||||
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
|
||||
}
|
||||
},
|
||||
"symfony/mercure-bundle": {
|
||||
"version": "0.3",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "main",
|
||||
"version": "0.3",
|
||||
"ref": "528285147494380298f8f991ee8c47abebaf79db"
|
||||
},
|
||||
"files": [
|
||||
"config/packages/mercure.yaml"
|
||||
]
|
||||
},
|
||||
"symfony/messenger": {
|
||||
"version": "7.2",
|
||||
"recipe": {
|
||||
@@ -211,6 +223,15 @@
|
||||
"config/routes/ux_live_component.yaml"
|
||||
]
|
||||
},
|
||||
"symfony/ux-turbo": {
|
||||
"version": "2.24",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "main",
|
||||
"version": "2.20",
|
||||
"ref": "c85ff94da66841d7ff087c19cbcd97a2df744ef9"
|
||||
}
|
||||
},
|
||||
"symfony/ux-twig-component": {
|
||||
"version": "2.24",
|
||||
"recipe": {
|
||||
|
||||
5
templates/broadcast/Alert.html.twig
Normal file
5
templates/broadcast/Alert.html.twig
Normal file
@@ -0,0 +1,5 @@
|
||||
<turbo-stream action="prepend" target="alert_list">
|
||||
<template>
|
||||
<twig:Alert :title="title|default('')" :message="message" :alert_id="alert_id" data-controller="alert" />
|
||||
</template>
|
||||
</turbo-stream>
|
||||
55
templates/broadcast/Download.stream.html.twig
Normal file
55
templates/broadcast/Download.stream.html.twig
Normal file
@@ -0,0 +1,55 @@
|
||||
{# Learn how to use Turbo Streams: https://github.com/symfony/ux-turbo#broadcast-doctrine-entities-update #}
|
||||
{% block create %}
|
||||
<turbo-stream action="append" target="active_downloads">
|
||||
<template>
|
||||
<twig:DownloadListRow
|
||||
id="ad_download_{{ entity.id }}"
|
||||
data="{{ entity.id }}">
|
||||
</twig:DownloadListRow>
|
||||
</template>
|
||||
</turbo-stream>
|
||||
{% endblock %}
|
||||
|
||||
{% block update %}
|
||||
{% if entity.status != "Complete" %}
|
||||
<turbo-stream action="update" target="ad_download_{{ id }}">
|
||||
<template>
|
||||
<div class="title">{{ entity.title }}</div>
|
||||
<div class="filename">{{ entity.filename }}</div>
|
||||
<div class="status">
|
||||
<span class="pill {{ status_color_map[entity.status] }} status-badge">{{ entity.status }}</span>
|
||||
<span class="pill progress">{{ entity.progress }}%</span>
|
||||
</div>
|
||||
</template>
|
||||
</turbo-stream>
|
||||
{% else %}
|
||||
<turbo-stream action="remove" target="ad_download_{{ id }}">
|
||||
</turbo-stream>
|
||||
|
||||
<turbo-stream action="prepend" target="alert_list">
|
||||
<template>
|
||||
<li class="alert alert-success alert-dismissible" id="alert_{{ entity.id }}" data-controller="alert">
|
||||
<span class="alert-filename">{{ entity.filename }}</span> has finished downloading.
|
||||
</li>
|
||||
</template>
|
||||
</turbo-stream>
|
||||
|
||||
<turbo-stream action="prepend" target="complete_downloads_list">
|
||||
<template>
|
||||
<div class="result_group download-item" id="cd_download_{{ entity.id }}">
|
||||
<div class="title">{{ entity.title }}</div>
|
||||
<div class="filename">{{ entity.filename }}</div>
|
||||
<div class="status">
|
||||
<span class="pill {{ status_color_map[entity.status] }} status-badge">{{ entity.status }}</span>
|
||||
<span class="pill progress">{{ entity.progress }}%</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</turbo-stream>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block remove %}
|
||||
<turbo-stream action="remove" target="ad_download_{{ id }}"></turbo-stream>
|
||||
<turbo-stream action="remove" target="cd_download_{{ id }}"></turbo-stream>
|
||||
{% endblock %}
|
||||
23
templates/components/Alert.html.twig
Normal file
23
templates/components/Alert.html.twig
Normal file
@@ -0,0 +1,23 @@
|
||||
<li {{ attributes }} id="alert_{{ alert_id }}" class="alert p-4 text-green-800 border border-green-300 rounded-lg bg-green-50 dark:bg-gray-800 dark:text-green-400 dark:border-green-800" role="alert">
|
||||
<div class="flex items-center">
|
||||
<svg class="shrink-0 w-4 h-4 me-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
|
||||
</svg>
|
||||
<span class="sr-only">Info</span>
|
||||
<h3 class="text-lg font-medium">{{ title|default('') }}</h3>
|
||||
</div>
|
||||
<div class="mt-2 text-sm">
|
||||
{{ message }}
|
||||
</div>
|
||||
{# <div class="flex">#}
|
||||
{# <button type="button" class="text-white bg-green-800 hover:bg-green-900 focus:ring-4 focus:outline-none focus:ring-green-300 font-medium rounded-lg text-xs px-3 py-1.5 me-2 text-center inline-flex items-center dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800">#}
|
||||
{# <svg class="me-2 h-3 w-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 14">#}
|
||||
{# <path d="M10 0C4.612 0 0 5.336 0 7c0 1.742 3.546 7 10 7 6.454 0 10-5.258 10-7 0-1.664-4.612-7-10-7Zm0 10a3 3 0 1 1 0-6 3 3 0 0 1 0 6Z"/>#}
|
||||
{# </svg>#}
|
||||
{# View more#}
|
||||
{# </button>#}
|
||||
{# <button type="button" class="text-green-800 bg-transparent border border-green-800 hover:bg-green-900 hover:text-white focus:ring-4 focus:outline-none focus:ring-green-300 font-medium rounded-lg text-xs px-3 py-1.5 text-center dark:hover:bg-green-600 dark:border-green-600 dark:text-green-400 dark:hover:text-white dark:focus:ring-green-800" data-dismiss-target="#alert-additional-content-3" aria-label="Close">#}
|
||||
{# Dismiss#}
|
||||
{# </button>#}
|
||||
{# </div>#}
|
||||
</li>
|
||||
@@ -12,4 +12,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div {{ turbo_stream_listen('alerts') }} class="absolute top-10 right-10 size-96">
|
||||
<div >
|
||||
<ul id="alert_list">
|
||||
<twig:Alert title="Added to queue" message="Severance has been added to the queue." alert_id="alert_id" data-controller="alert" />
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
Reference in New Issue
Block a user