Code Monkey home page Code Monkey logo

alertifybundle's People

Contributors

adpdsr avatar alexislefebvre avatar bfoucher avatar bitdeli-chef avatar charlie-lucas avatar damienalexandre avatar fcpauldiaz avatar gregumo avatar jibbarth avatar juliensnz avatar lenybernard avatar llaville avatar nyholm avatar paulandrieux avatar thomasbeaujean avatar vincent-chapron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alertifybundle's Issues

Bootstrap 3.*

Is it planned to update the bundle to use the newest version of Bootstrap ?

Do not version external libraries

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 ?

Dependency error with ~2.0

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)

Implements tests

  • Dependency injection (parameters and services drived by configuration)
  • Helper (each shortcut method will correctly add what is expected in the correct FlashBag)
  • SessionHandler (what is in session is handled as well to be transformed into some template)
  • Listener (on kernel.response, we correctly inject the templates into the page to show alerts ex. https://github.com/symfony/web-profiler-bundle/blob/2.8/Tests/EventListener/WebDebugToolbarListenerTest.php)
  • TwigExtension (we can render alerts directly in twig thanks to this extension)

Master version on packagist

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

xliff translation missing id attribute

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?

the setFlash() method

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 :)

AlertifySessionHandler trigger a session_start even on stateless URL

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:

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;
if ($hasBody && !$hasMetaRefresh && !$isRedirectResponse || $forceInject) {
if ($response->getStatusCode() === 204) {
throw new IncompatibleStatusCodeException();
}
$alertify = $this->alertifySessionHandler->handle($this->session, $this->twig);

If there is a </body> tag, alertifySessionHandler gets called:

$flashes = $session->getFlashBag()->all();

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.

Suggestion

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.

Overriding Templates

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

Handle asynchronous alerts (with queue system)

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 ...

AlertifyBundle with WebPack in Symfony 5.2

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:

  • the notificationFx.js file tells me that Modernizrn is not defined.
  • modernizr.custom.js: documentElement on null

On the other hand everything works normally when I include in static like this.

Thank you in advance!

Question using SF 3.4

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.