troopers / alertifybundle Goto Github PK
View Code? Open in Web Editor NEWHarmonize notifications in your Symfony app.
License: MIT License
Harmonize notifications in your Symfony app.
License: MIT License
Is it planned to update the bundle to use the newest version of Bootstrap ?
Instead of having a large number of potential unused libraries in each project we setup alertify, I suggest to use front system (like bower, npm, yarn) to manage front libraries such as toastr, notiejs, pushjs...
Doing this will be less "automagic" while every library won't be already in the projet's assets and we won't be able to load dynamically with assetic/injector-bundle
.
Some reactions ?
We shouldn't have to add these lines :
<script type="text/javascript">var confirmUrl = "{{ path('Alertify_Confirm') }}";</script>
<script src="{{ asset('bundles/avawesomealertify/js/confirm.js') }}"></script>
When we change modal width, that modal is not centered.
Victoire 2.2 requires the ~2.0
version.
I can't install this version when simulating a fresh Symfony 2.8 installation :
$ composer require symfony/symfony:"2.8.*" --no-update
./composer.json has been created
$ composer require troopers/alertify-bundle:~2.0
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- troopers/alertify-bundle 2.0.3 requires friendsofsymfony/jsrouting-bundle 2.0.*@dev -> satisfiable by friendsofsymfony/jsrouting-bundle[2.0.0-alpha1, 2.0.x-dev] but these conflict with your requirements or minimum-stability.
- troopers/alertify-bundle 2.0.2 requires friendsofsymfony/jsrouting-bundle 2.0.*@dev -> satisfiable by friendsofsymfony/jsrouting-bundle[2.0.0-alpha1, 2.0.x-dev] but these conflict with your requirements or minimum-stability.
- troopers/alertify-bundle 2.0.1 requires friendsofsymfony/jsrouting-bundle 2.0.*@dev -> satisfiable by friendsofsymfony/jsrouting-bundle[2.0.0-alpha1, 2.0.x-dev] but these conflict with your requirements or minimum-stability.
- troopers/alertify-bundle 2.0.0 requires friendsofsymfony/jsrouting-bundle 2.0.*@dev -> satisfiable by friendsofsymfony/jsrouting-bundle[2.0.0-alpha1, 2.0.x-dev] but these conflict with your requirements or minimum-stability.
- Installation request for troopers/alertify-bundle ~2.0 -> satisfiable by troopers/alertify-bundle[2.0.0, 2.0.1, 2.0.2, 2.0.3].
Installation failed, reverting ./composer.json to its original content.
It looks like AlertifyBundle (2.0.3
) is requiring a dev
version of FOSJsRoutingBundle and that it break dependencies.
FOSJsRoutingBundle does not provide any stable release: https://packagist.org/packages/friendsofsymfony/jsrouting-bundle
Maybe we can try to change the required version, as suggested here: FriendsOfSymfony/FOSJsRoutingBundle#240 (comment)
Hi,
I'm trying to use your bundle in my app backoffice, but there are a lot of new features like the labels translation in the Master branch.
But I cant reach it from packagist and I cant find how to do this in the documentation.
I got the 2.3 version with packagist and composer.
Thanks
on symfony 2.5.5
after removing id attribute i have following error
issue https://forge.typo3.org/issues/33971
An exception has been thrown during the rendering of a template ("[ERROR 1868] Element '{urn:oasis:names:tc:xliff:document:1.2}trans-unit': The attribute 'id' is required but missing. (in /home/darek/public_html/cklocal/web/ - line 5, column 0)
Could you recover it?
hi,
I just wanted to say that the setFlash methode is no longer supported by symfony2 and it was replaced by the getFlashBag()->add(..).
this is just a suggestion for updating the doc.
good job :)
I'm not very familiar with this bundle but I encountered an issue while working on a project where it's used to display notifications.
I had a simple page hit by a monitoring application (like a curl call to a page).
As the time passed, my session table was becoming very large so I started digging.
Even if my simple page was outside a Security Firewall (using a security: false
firewall),
a session was still assigned to my page. That meant every hit was creating a new session where I don't wanted to.
This is because AlertifyBundle only look at the Response:
AlertifyBundle/EventListener/AlertifyListener.php
Lines 66 to 79 in eded39a
If there is a </body>
tag, alertifySessionHandler gets called:
And this simple $session->getFlashBag()->all();
trigger a session start, whatever we want to do.
I think this may be a bug, as I don't see a valid usage of Flash Message outside of pages where a session is already started.
I think you should check for session existence before trying to load data from it.
A example implementation could be:
protected function injectAlertify(Response $response, Request $request)
{
$content = $response->getContent();
$endBodyPos = strripos($content, '</body>');
$hasBody = false !== $endBodyPos;
$hasMetaRefresh = false !== strripos($content, 'http-equiv="refresh"');
$forceInject = $response->headers->get('X-Inject-Alertify', false);
$isRedirectResponse = $response instanceof RedirectResponse;
+ $isSessionStarted = $this->session->isStarted();
+ if ($hasBody && $isSessionStarted && !$hasMetaRefresh && !$isRedirectResponse || $forceInject) {
- if ($hasBody && !$hasMetaRefresh && !$isRedirectResponse || $forceInject) {
if ($response->getStatusCode() === 204) {
throw new IncompatibleStatusCodeException();
}
$alertify = $this->alertifySessionHandler->handle($this->session, $this->twig);
if ($endBodyPos) {
$content = substr($content, 0, $endBodyPos).$alertify.substr($content, $endBodyPos);
} else {
$content .= $alertify;
}
$response->setContent($content);
}
}
What do you think? Does that sound reasonable according to the bundle features? If you agree I would be pleased to submit a Pull Request.
Cheers.
Hello,
I've just tested this bundle with toastr backend, and I've wanted to used some options that are not provided by default bundle template: Resources\views\toastr.html.twig
I used Symfony 3.4, and I overrides templates such as described in SF blog.
Checking the twig templates with console command debug:twig
I got
@TroopersAlertify - templates/bundles/TroopersAlertifyBundle
- vendor/troopers/alertify-bundle/Troopers/AlertifyBundle/Resources/views
@!TroopersAlertify - vendor/troopers/alertify-bundle/Troopers/AlertifyBundle/Resources/views
I copied the default toastr.html.twig
into templates/bundles/TroopersAlertifyBundle
folder and change it a few as follow :
{# Check & auto repair #}
{% if layout not in ['top-right', 'top-left', 'top-full-width', 'bottom-right', 'bottom-left', 'bottom-full-width'] %}
{% set layout = 'top-right' %}
{% endif %}
<script type="text/javascript">
(function() {
var delay;
delay = function(ms, func) {
return setTimeout(func, ms);
};
//
toastr.options = {
positionClass : 'toast-{{ layout }}', //top-right, top-left, top-full-width, bottom-right, bottom-left, bottom-full-width
closeButton : {{ options.closeButton|default('false') }},
debug : {{ options.debug|default('false') }},
onclick : {{ options.onclick|default('null') }},
showDuration : {{ options.showDuration|default('20000') }},
hideDuration : {{ options.hideDuration|default('1000') }},
timeOut : {{ options.timeOut|default('5000') }},
extendedTimeOut: {{ options.extendedTimeOut|default('1000') }},
showEasing : '{{ options.showEasing|default('swing') }}',
hideEasing : '{{ options.hideEasing|default('linear') }}',
showMethod : '{{ options.showMethod|default('fadeIn') }}',
hideMethod : '{{ options.hideMethod|default('fadeOut') }}',
progressBar : {{ options.progressBar|default('false') }},
containerId : '{{ options.containerId|default('toast-container') }}'
};
var body = "{{ body|replace({'\r\n|\n|\r': '<br/>'})|raw|trans({}, translationDomain|default('messages')) }}";
delay({% if timeout is defined and timeout != null %} {{ timeout }}{% else %} 1000{% endif %} , function() {
return toastr.{{ type }}(body,"{{ title|default(("alert."~type~".label")|trans({}, translationDomain|default('messages'))) }}");
});
}).call(this);
</script>
The template was not used until I change a little syntax call in vendor/troopers/alertify-bundle/Troopers/AlertifyBundle/Handler/AlertifySessionHandler.php
, line 58
With version 3.0.9 (installed under Symfony 3.4.6) we have
$renders[$type.$key] = $twig->render(
- 'TroopersAlertifyBundle::'.$parameters['engine'].'.html.twig',
+ '@TroopersAlertify/'.$parameters['engine'].'.html.twig'
$parameters
)
Did I missed something, or just misunderstood how to custom it ?
Thanks in advance
Laurent
How cool is that ?
push.js
We could imagine a system to automatically inject external notifications. Today, alerts are only used to say something you just did at the moment. But what if we use a message queuing system like RabbitMQ and we want to warn the user that the treatment is completed ...
Hello,
I use codrops-notification for style.
I tried to use webpack Encore with the bundle. I manage to compile and load my web page without errors. However in the console I have errors in red:
On the other hand everything works normally when I include in static like this.
Thank you in advance!
It is possible please to make this bundle compatible with the last version of sensio/framework-extra-bundle (^6.1).
Tanks for advance.
Let's continus these project !
Today, to make alerts pop, we need to add this line in the layout:
twig
{{ app.request|alertify }}
The AlertifyKernelRequestListener would listen kernel.response
event and automatically inject needed alerts
I'm using Symfony 3.4 with AlertifyBundle, where I had to add "symfony/assetic-bundle": "^2.8"
to my composer.json
and enabled both this bundle and the assetic bundle in my AppKernel.
I added the stylesheets and javascripts content to my standard layout html.twig file and I can see that the package is capturing my flashbag alerts as the standard messages are not shown, but I am not seeing any of the Alertify alerts on the screen.
I kept the config simple, as shown here, just using defaults:
troopers_alertify:
default:
context: admin
engine: toastr
layout: bottomLeft
translationDomain: messages
assetic:
debug: '%kernel.debug%'
use_controller: '%kernel.debug%'
filters:
cssrewrite: ~
Any thoughts on what I could be missing?
My twig content is:
{% block stylesheets %}
{{ parent() }}
{% stylesheets
'@TroopersAlertifyBundle/Resources/public/toastr/css/toastr.css'
%}
<link rel="stylesheet" href="{{ asset_url }}" type="text/css" />
{% endstylesheets %}
{% endblock %}
{% block javascripts %}
{{ parent() }}
{% javascripts
'@TroopersAlertifyBundle/Resources/public/toastr/js/toastr.js'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock %}
And I use standard alerts in my Controller:
$flashbag = $this->get('session')->getFlashBag();
$flashbag->add("success", 'Success');
Thanks!
Rob
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.