npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-notification-hub

v1.1.3

Published

A persistent notification center for your ember apps.

Downloads

23

Readme

Cover Image Demo Gif Build Status Code Climate Ember Observer Score

ember-notification-hub

A small, flat design notifciation hub for your Ember app. Stick it to the top or bottom of your page. Show your users what asynchronous actions are pending, failed or completed.

Why? Most notification add-ons for ember do not take a promise interface, have a compact way to show many asychronous task results or persist them across sessions.

Live Demo

Features

  • View status of multiple, in-progress async actions
  • Notification results stored to local storage for persistence across sessions
  • Post notifications of synchronous actions
  • Collapsed view shows # of tasks failed and succeeded and most recent task details
  • Send async notifications as Promises
  • JSON API friendly error handling
  • Multiple error reason
  • Sweet aninmations! 🍬
  • Minimal dependencies - Installs Roberto Fonts
  • Uses parts of Materializecss but doesn't muddle up your CSS
  • Ember 2.0 Friendly

Installation

Install Package

ember install ember-notification-hub

Place Component

Ember notification hub can either be mounted to the top or the bottom of your application. For the bottom of your app do:

{{ember-notification-center bottom="-25px" openBottom="0px" left="20%" width="60%" pullDown=false}}

Where bottom is the CSS bottom position of the notification bar when it is collapsed, openBottom is the CSS bottom opsition when the hub is opened and pullDown indicates the orientation of the notificatio hub. The variable left and width sets their respective CSS properties for horizontal placement and width.

For mounting the hub to the top of your application use the top and openTop variables with pullDown=true do:

{{ember-notification-center top="-25px" openTop="0px" left="20%" width="60%" pullDown=true}}

Sending a Notification

To send a notification to the hub, the add-on installs the emberNotificationCenter service. Inject this to any Ember object you want to send the notificaiton from:

Asynchronous Task Notifcations

Using the promise-based pushNotification API you can give immediate feedback to users by giving a short description of the asynchronous task and a promise that resolves when the task is complete:

Example: Arbitrary Notification

The add-on expects that if your async notification fails to reject the promise with an array of error objects. An error object contains a code and title field as show in testFail.

export default Ember.Controller.extend({
    emberNotificationCenter: Ember.inject.service(),
    actions: {
        testFail: function () {
            this.get('emberNotificationCenter').pushNotification({
                title: 'Test Async Action 1',
                description: 'This shows an asynchronous notification with a promise'
            }, new Ember.RSVP.Promise((resolve, reject) => {
                setTimeout(() => {
                    reject([{
                        code: '404 Bad Request',
                        title: 'You must boogy before riding'
                    },
                    {
                        code: '403 Not Authorized',
                        title: 'Who do you think you are?'
                    }]);
                }, 3000);
            }));
        },
        testPass: function () {
            this.get('emberNotificationCenter').pushNotification({
                title: 'Test Async Action 1',
                description: 'This shows successful asynchronous notification with a promise'
            }, new Ember.RSVP.Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve();
                }, 3000);
            }));
        }
    }
});

Example: Committing a DS.Model

Because the add-on is designed to handle Ember JSON API adapter errors, querying your backend through Ember Data Store will automatically render errors that occur from your server, without doing any extra work:

this.get('emberNotificationCenter').pushNotification({
    title: 'Committing Model',
    description: 'Your model will be updated with the lastest info!'
}, myModel.save());

Synchronous Task Notifications

These are notifications that do not render status of a notification based on a promise. The add-on assumes whatever action already successfully completed. You use the same pushNotification interface, but just omit the promise like so:

Example: A Simple Synchornous Notification

this.get('emberNotificationCenter').pushNotification({
    title: 'You did it!',
    description: 'This thing that required no time was completed successfully.'
});

Persistence

This addon uses ember-localstorage-adapter to save notification results between application lifecycles. When a notificatin is still Pending it will not be saved. We assume that you will prevent users from leaving your application until a Pending notification is complete.

Stuff Installed

Dependencies

  • Ember Local Storage Adapter

Installed Ember Components

The following Ember components are added to your application after install:

  • Service emberNotificationCenter - Used to push notifications from anywhere in your app
  • Component emberNotificationCenter - The notification hub
  • Component emberNotificationPullOut - Internally used by the notification hub to show individual notifications
  • Model emberNotificationLocalNotification - Used to store notifications
  • Model emberNotificationLocalError - Used to store notification failure reasons

Running the Demo App

git clone https://github.com/vmpowerio/ember-notification-hub
cd ember-notification-hub
ember server

Visit your app at http://localhost:4200.

Running Tests

  • npm test (Runs ember try:testall to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://ember-cli.com/.

Aknowledgements

  • Materializecss Project for the Notificaitons Collection
  • The Polymer Project for the Spinner

License

MIT