Git Product home page Git Product logo

yii2-notifications's Introduction

A complete notifications module for your Yii 2 powered application.

Latest Stable Version Total Downloads Latest Unstable Version License

This module will install it's own table, and quickly allow you to:

  • Trigger notifications to your users
  • Toast these notifications on the screen using one of the supported UI libraries
  • Manage a HTML list of notifications

Growl notification

A documentation is available in the docs folder of this repository. You can also check this live demo.

yii2-notifications's People

Contributors

drsdre avatar jsobers1331 avatar laurapagan avatar machour avatar michaelst avatar pistej avatar rathawut 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  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  avatar

yii2-notifications's Issues

Make more than one notification counter

I have success create notification, and I want to create other message notification in the same application, is this plugin able to do that?? In separate notification like Facebook notification and Facebook message notification

Make Notifications Creation Easier

It is a little annoying to have to code each kind of notification I want to send into the notification model. It seems like it would be easier to store them in a database and create a gridview to edit them.

Class 'machour\notifications\widgets\NotificationsWidget' not found

Hello,

I am going to integrate notification in backend admin, after installing widget successfully it throws me error as Class 'machour\notifications\widgets\NotificationsWidget' not found. Kindly help.
I have already include it as use machour\notifications\widgets\NotificationsWidget

composer error

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
- The requested package machour/yii2-notifications could not be found in any version, there may be a typo in the package name.

Potential causes:

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Installation failed, reverting ./composer.json to its original content.

Problem after update - new field flashed

The notification aren't shown, seems that is missing 'flashed' in the rules()
[['id', 'key_id', 'created_at'], 'safe'],
changed in
[['id', 'key_id', 'created_at', 'flashed'], 'safe'],
now it shows all the notification

Wrong model in Configuration.md

In the module config use below model:
'notificationClass' => 'app\models\Notification',

But in declaration, user below namespace:
namespace backend\components;

So it either change namespace backend\components; to namespace app\models; or change 'notificationClass' => 'app\models\Notification', to 'notificationClass' => 'backend\components\Notification',

Getting assets issue with modules

Hi i m getting below error

AssetConverter command 'lessc '/var/www/html/dev/web/assets/2b7f18ca/notifications.less' '/var/www/html/dev/web/assets/2b7f18ca/notifications.css' --no-color --source-map' failed with exit code 127:
STDOUT:

STDERR:
sh: 1: lessc: not found

how to send multiple notifications of the same type for the same user

Hello,
I want to send a multiple notifications from different users to one only admin user
but I can't add multiple notifications for the same user
Notification::notify (Notification :: KEY_NEW_MESSAGE, $admin_user, "hello");
Please can you telle me what I do??

Have good day

Problem with date format

Hi,
in the table the attribute "created at" is written as "dd/mm/yyyy" so the evaluation of the date is wrong because it suppose that the date is in the format "mm/dd/yyyy"...

we have changed NotificationController.php actionPoll():

public function actionPoll($seen = 0)
    {
        /** @var Notification $class */
        $class = $this->notificationClass;
        $models = $class::find()->where([
            'user_id' => $this->user_id,
            'seen' => $seen
        ])->all();
        $results = [];
        foreach ($models as $model) {
            /** @var Notification $model */
/*CHANGE*/
$date = \DateTime::createFromFormat('d/m/Y H:i:s', $model->created_at);
$date = $date->format('m-d-Y'); 
/*END CHANGE*/
            $results[] = [
                'id' => $model->id,
                'type' => $model->type,
                'title' => $model->getTitle(),
                'description' => $model->getDescription(),
                'url' => Url::to(['notifications/rnr', 'id' => $model->id]),
                'key' => $model->key,
                'date' =>$date
            ];
        }
        return $results;
    }

It is possible to fix the problem, formatting the date according to the Yii::$app->language or according to a parameter in the notification module section of the config file?

AssetConverter commands are not always available

Even though Yii2 includes AssetConverter, which was designed for more flexibility on project development, it represents a problem when you want to host a Yii2 project within a shared hosting, in which commands like lessc are not available.

The best will be use css and left compilation to developer environment. You can use webpack, gulp, yarn, npm or whatever you need to compile. Those alternative methods are faster for styles development, even more when they are combined with auto reload tools like browserSync.

Have notification on pop up once

If a notification hasn't been marked as seen it will get a pop up and be displayed in the drop down. After the initial pop up I don't think it should pop up on every page load until it has been seen.

The pop ups notifications dosen't show

I have the module perfectly configured, but the pop-ups dosen't shown:

 'notifications' => [
            'class' => 'machour\yii2\notifications\NotificationsModule',
            // Point this to your own Notification class
            // See the "Declaring your notifications" section below
            'notificationClass' => 'rce\components\Notification',
            // Allow to have notification with same (user_id, key, key_id)
            // Default to FALSE
            'allowDuplicate' => false,
            // Allow custom date formatting in database
            // 'dbDateFormat' => 'Y-m-d H:i:s',
            // This callable should return your logged in user Id
            'userId' => function() {
                return \Yii::$app->user->id;
            }
        ],

NOTE: i used the advanced template.

thanks in advance

Class 'Notification' not found

Hello I am use advanced template.
I downloaded and migrated the extension.

I put the follow code in: backend/config/main.php

'notifications' => [
            'class' => 'machour\yii2\notifications\NotificationsModule',
            // Point this to your own Notification class
            // See the "Declaring your notifications" section below
            'notificationClass' => 'backend\models\Notification',
            // Allow to have notification with same (user_id, key, key_id)
            // Default to FALSE
            'allowDuplicate' => false,
            // This callable should return your logged in user Id
            'userId' => function() {
                return \Yii::$app->user->id;
            }
        ], // notifications

I tried both 'notifications' and 'notification'

I copied and pasted Notification model example in backend/models ( Notification.php )

and then i tried code for testing in template view

Notification::notify(Notification::KEY_NEW_MESSAGE, 1, 2);

where am I wrong?

thanks

could it set don't route?

Could it set the popup notification do not route but will set the seen = true when click the notification? thanks.

growl.js slowing down page load

By including growl.js directly in the asset instead of registering it in the widget I was able to get rid of the load time of about 3s.

NotificationAsset and Font Awesome

NotificationAsset is pointing to a different location for font awesome. I get this error with your code "Class rmrevin\yii\fontawesome\cdn\AssetBundle does not exist". It seems mine installed in this location
'rmrevin\yii\fontawesome\AssetBundle', is there something I need to do so I don't have to keep fixing this when I run composer update.

Mark all as read / delete all

It is possible mark all displayed notifications as read or delete all notification at once?
One solution is: via javascript, similar function as markSeen

  • remove notifications if it's not present in server.pool response

Why is notification row only hidden and not removed permanently?

Growl Notification isn't showing on frontend

I copied the code into my main layout which was provided in https://machour.idk.tn/yii/machour/yii2-notifications/Usage.md and the PHP snippet is not working for me.

From what I can tell, XHR is being fired based on my logs:

Route 'notifications/notifications/poll'
Action 'machour\yii2\notifications\controllers\NotificationsController::actionPoll()'
Parameters [
0 => '0'
]

Edit:
The database table is being updated with the key information as provided in the component with each trigger, so i know the trigger is working.

Or is this something that only works with AdminLTE ? ( as shown in your demo)

Allow customize wrap template

In spite of the listItemTemplate is customizable it is not enough useful, because it is wrapped into a fixed div. When using, as an example, AdminLTE it can´t fit the requirements of this theme, because it requires an unordered list.

Adding a parameter like tagNameor containerTemplate can make it easy to reach.

How to send notification to multiple users?

Hello! How can I send notification for multiple users (for example, by role). I need a group of managers to see the notifications, but I can pass only one $admin_id in Notification::notify() function. Is there a way to notify all registered users, or other group of users?

Time ago shows wrong time

Hello,

I am using your plugin, but it shows server time in time ago functionality. I want to show it as my local time. Kindly provide proper solution for this.

Generic fix for ORACLE db

For more compatibility of the extension can tell you some fix needed for ORACLE database:

  • in the matching of "boolean" value we must use 1/0 because in ORACLE boolean doesn't exist. The migration tool convert an attribute set as $this->boolean() in Numer(1,0) #[36] (ref. issue 36)

  • I have ovverride the notify() function also because for ORACLE the Expression NOW() doesn't exist, so first I replaced it with SYSDATE() that is suited for ORACLE but I can suggest you to use "new Expression('CURRENT_TIMESTAMP')".

  • In the migration I also need to change "created_at" attribute from dateTime to date() because dateTime() is converted into TIMESTAMP and the models return a datetime like this "18-LUG-17 17:53:09,000000", it is possible to have TIMESTAMP with precision 0 in ORACLE that returns "18-LUG-17 17:53:09" but I have not figured out how to set precision 0 in the migration ($this->dateTime(0) doesn't work)

Glad if this can help improve compatibiliy of the extension.

Throws error message after successful configuration

Hello,

I have done with successful configuration of notification. But when i call notification it returns below error
{name: "Invalid Configuration", message: "The table does not exist: {{%message}}", code: 0,…}

Error when i follow the url created by the widget

src="/final_yii/frontend/web/assets/ceb237c3/notifications.js"
src="/final_yii/frontend/web/assets/9b91480a/js/noty/packaged/jquery.noty.packaged.min.js"
jQuery(document).ready(function () {
Notifications({url:"/final_yii/frontend/web/index.php/notifications/notifications/poll",theme:"noty",timeout:"2000",delay:"5000"});
});

The url is not working.

ReflectionException
Class machour\yii2\notifications\Notifications does not exist

1. in /var/www/html/final_yii/vendor/yiisoft/yii2/di/Container.php at line 415
406407408409410411412413414415416417418419420421422423424

     * @return array the dependencies of the specified class.
     */
    protected function getDependencies($class)
    {
        if (isset($this->_reflections[$class])) {
            return [$this->_reflections[$class], $this->_dependencies[$class]];
        }

        $dependencies = [];
        $reflection = new ReflectionClass($class);

        $constructor = $reflection->getConstructor();
        if ($constructor !== null) {
            foreach ($constructor->getParameters() as $param) {
                if ($param->isDefaultValueAvailable()) {
                    $dependencies[] = $param->getDefaultValue();
                } else {
                    $c = $param->getClass();
                    $dependencies[] = Instance::of($c === null ? null : $c->getName());

Problem with language of jquery.timeago

Hi, we have an app with Yii::$app->language set as "it-IT".
The problem is that the file "jquery.timeago.it.js" is not read because the extension search for "jquery.timeago.it-IT.js".

It is possible to fix the problem?

PostgreSQL ERROR: operator does not exist: boolean = integer

I'm using PostgreSQL and for boolean column query like:
SELECT * FROM "notification" WHERE ("user_id"=1) AND ((seen=0) OR (flashed=0)) ORDER BY "created_at"
should be
SELECT * FROM "notification" WHERE ("user_id"=1) AND ((seen=false) OR (flashed=false)) ORDER BY "created_at"
or
SELECT * FROM "notification" WHERE ("user_id"=1) AND ((seen='0') OR (flashed='0')) ORDER BY "created_at"
otherwise got error: "operator does not exist: boolean = integer".

Simply using notifications

Hello! I'm beginner in using your great notifications, so my case is:
i adapt notifications for my project and just try to use them - create db table (My SQL), class Notification in app\components and create several notifications in my layout:
`<?php // $message was just created by the logged in user, and sent to $recipient_id
$message = new Message();
$message->task_id = 7;
$message->user_id = 6;
$message->admin_id = 3;
$message->text = "new msg for user notify.";
$message->save();
Notification::notify(Notification::KEY_NEW_MESSAGE, 6, $message->id);

        // You may also use the following static methods to set the notification type:
        Notification::warning(Notification::KEY_NEW_MESSAGE, 6, $message->id);
        //    Notification::success(Notification::ORDER_PLACED, $admin_id, $order->id);
        Notification::error(Notification::KEY_NO_DISK_SPACE, 6);
        //widget
        NotificationsWidget::widget([
            'theme' => NotificationsWidget::THEME_GROWL,
            'clientOptions' => [
                'location' => 'br',
            ],
            'counters' => [
                '.notifications-header-count',
                '.notifications-icon-count'
            ],
            'markAllSeenSelector' => '#notification-seen-all',
            'listSelector' => '#notifications',
        ]); ?>
        <li class="dropdown notifications-menu">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                <i class="fa fa-bell-o"></i>
                <span class="label label-warning notifications-icon-count">0</span>
            </a>
            <ul class="dropdown-menu">
                <li class="header">You have <span class="notifications-header-count">0</span> notifications</li>
                <li>
                    <ul class="menu">
                        <div id="notifications"></div>
                    </ul>
                </li>
                <li class="footer"><a href="#">View all</a> / <a href="#" id="notification-seen-all">Mark all as
                        seen</a></li>
            </ul>
        </li>`

But when i load the user page - have ZERO notifications on screen - in table all in
screenshot from 2017-11-24 21-43-29
.
Please. help realize notifications --- i just want to show new notifications and write loop for new )
Thank you for response!

Notification redirecting to the wrong action

I my Notification class I have on return in the getRoute() method:
return ['customer/view', 'id' => $this->key_id];

But when I click in the notification I am redirected to:
index.php?r=notifications%2Fcustomer%2Fview&id=513
And, because of this, I'm gettig 404 error. How can I solve this problem?

message model and meet model

thank you provider yii2-notifications for us, i used it at mess,
i have a question: no message model and meet model
i don't know how to create it and do not konw the data_model structure.

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.