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-cli-google-contacts

v0.0.6

Published

Use ember-data to retreive google contact thru the Google Client API

Downloads

2

Readme

ember-cli-google-contacts

This addon provide access to the Google contacts of a user thru the store using the Google client library. The plan is to support updating and creating contacts too, but for now only read-access has been implemented.

Installation

  • npm install --save-dev ember-cli-google-contact
  • or, with the latest ember-cli: ember install:addon ember-cli-google-contact

Using

  • The plugin requires at least a Google client ID and optionally an API key:

    // add this to the ENV hash of config/environment.js
    social: {
      google: {
        clientId: 'xyz',
        apiKey: 'abc' // optional
        // if you want to load the library yourself with the `googleContactService.load()`,
        // set this to false. If not set or truthy, it'll automatically load with your application
        // autoLoad: true
      }
    }

    You can get an API key and client ID for your project by creating a new Google project there

  • Routes and controllers now get a googleContactService property, which you need to use in order to authenticate. Then you can use the store to retrieve the user's Google contacts.

  • To detect if the lib is authenticated, use <some controller or route>.googleContactService.get('isAuthenticated')

  • If not authenticated, you have to create a UI button with an Ember action (it has to be a button so that the action is triggered on click) resulting in the call of googleContactService.authenticate(). This method returns a promise which resolves upon authentication success or reject with the error on failure:

    {{! app/templates/contacts/index.hbs }}
    <button {{action 'authenticate'}}>authenticate</button>
    // app/routes/contacts/index.js
    export default Ember.Route.extend({
      beforeModel: function () {
        if (this.googleContactService.get('isAuthenticated')) {
          // go directly to the contacts list if the authentication has already been done
          this.transitionTo('contacts.list');
        }
      },
      actions: {
        authenticate: function () {
          this.googleContactService.authenticate().then(Ember.run.bind(this, 'transitionTo', 'contacts.list'));
        }
      }
    });
  • To get the contacts list, just use the store:

    // app/routes/contacts/list.js
    export default Ember.Route.extend({
      beforeModel: function () {
        if (!this.googleContactService.get('isAuthenticated')) {
          // if the authentication hasn't been done yet, redirect to the authenticate screen
          this.transitionTo('contacts.authenticate');
        }
      },
      model: function () {
        return this.store.find('google-contact');
      }
    });
    {{! app/templates/contacts/list.hbs }}
    <ul class="list-group contacts">
      {{#each contact in model}}
        <li class="list-group-item">
          {{#if contact.anyPhotoUrl}}
            <div class="avatar">
              <img {{bind-attr src=contact.anyPhotoUrl}}/>
            </div>
          {{/if}}
          <div class="name">{{contact.title}} - {{contact.anyEmail.address}}</div>
        </li>
      {{/each}}
    </ul>
  • A google-contact model has these properties:

    • id: The Google contact ID
    • title: display name of the contact
    • categories: an array of String for each category
    • emails: an array of {rel: String, primary: Boolean, address: String}
    • links: an array of {rel: String, type: String, href: String}
    • anyPhotoUrl: an URL to the user's avatar if any
    • anyEmail: a pointer to the primary or first available email object from emails

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