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

people-organigraph

v1.3.1

Published

## Dépendances L'organigraphe nécessite d'inclure le CSS de bootstrap (v3) à votre projet

Downloads

10

Readme

People Organigraph

Dépendances

L'organigraphe nécessite d'inclure le CSS de bootstrap (v3) à votre projet

L'organigraphe s'appuie également sur d'autres dépendances, qui sont directement incluses dans la librairie :

Les prochaines étapes de développement du projet seront de se débarrasser des dépendances superflues (React, Bootstrap...)

Polyfills

L'organigraphe utilise l'API fetch du navagiteur et les Promises.

Le support de ces deux API navigateur étant actuellement limité, il est fortement recommandé d'installer différents polyfills dans votre projet pour garantir un support navigateur stable, comme :

import Promise from 'promise-polyfill'; 

// To add to window
if (!window.Promise) {
  window.Promise = Promise;
}
import "whatwg-fetch";

Utiliser l'organigraphe

Installer l'organigraphe dans votre projet via npm ou yarn

yarn add people-organigraph
# ou
npm install people-organigraph

index.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <base href="/">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>People Organigraph</title>
  <!-- L'organigraphe nécessite bootstrap comme dépendance -->
  <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <!-- Import du CSS de l'organigraphe -->
  <link rel="stylesheet" href="organigraph.css">
  <style>
    /* Style le container de l'organigraph (ici en fullscreen) */
    #js-organigraph {
      position: absolute;
      overflow: hidden;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
    }
  </style>
</head>
<body>
  <!-- Le container ou l'organigraphe va être crée -->
  <div id="js-organigraph">
  </div>
</body>
</html>

application.js

import PeopleOrganigraph from 'people-organigraph';

// Crée un objet définissant les endpoint que l'organigraphe va consommer
const organigraphEndpoints = {
  graph: id => `/p/${id}/graph_json`,
  user: id => `/p/${id}/user_json`,
};

// Crée un objet définissant les liens vers lequels l'organigraphe peut renvoyer
const organigraphLinks = {
  user: id => `/p/${id}`,
};

// Initialise l'organigraphe
PeopleOrganigraph("#js-organigraph", {
  initialUserId: 1, // L'id de l'user sur lequel l'organigraphe sera initialisé
  endpoints: organigraphEndpoints, // Les endpoints
  links: organigraphLinks, // Les liens
});

API Serveur

L'organigraphe est pensé pour consommer une API REST. Il faut à minima deux endpoints :

Un endpoint graph exposant les informations d'un user et celles de ses enfants directs :

GET /api/user/1/graph

{
  "id": 1,
  "first_name": "Brennan",
  "last_name": "Hanson",
  "picture_url": "https://randomuser.me/api/portraits/men/73.jpg",
  "children": [
    {
      "id": 2,
      "first_name": "Eva",
      "last_name": "Freeman",
      "picture_url": "https://randomuser.me/api/portraits/women/94.jpg",
    },
    {
      "id": 3,
      "first_name": "Felix",
      "last_name": "Russel",
      "picture_url": "https://randomuser.me/api/portraits/men/54.jpg",
    },
  ]
}

Un endpoint user exposant les informations d'un user en particulier:

GET /api/user/2

{
  "id": 2,
  "email": "[email protected]",
  "slugged_id": "evafreeman",
  "first_name": "Eva",
  "last_name": "Freeman",
  "job_title": "Manager",
  "office_address": null,
  "entity": "GTS",
  "phone": "+33123456789",
  "picture_url": "https://randomuser.me/api/portraits/women/94.jpg",
}

Ces endpoint seront fourni à l'organigraph via l'API client

API Client

Initialiser l'organigraphe

PeopleOrganigraph(selector, options)
  • selector: (String) le sélecteur de l'élément destiné à contenir l'organigraphe
  • options (Object) un objet d'options :

Contribuer et démarrer le projet localement

Prérequis

Installer NVM pour gérer sa version de Node :

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash

(Dans le projet) Installer la version courante de Node :

nvm install

(Optionel) Installer AVN pour gérer le switch automatique de version de Node:

Config :

Pour que la démo de développement fonctionne correctement, il est nécessaire de préciser quelques valeurs dans un fichier demo/config.json :

{
  "apiUrl": "https://people.total/api/v1",
  "accessToken": "YOUR-ACCESS-TOKEN"
}
  • apiUrl: l'url de l'api
  • accesToken(optionnel): l'access token nécessaire pour s'authentifier à l'api (sera par défaut passé en paramètre d'url (?access_token=ACCESS_TOKEN)

Installation des dépendances :

Via Npm

yarn install

Développement

Lancer le serveur local :

yarn start

Le serveur est accessible sur http://localhost:3000

Compilation

Compiler le projet, et préparer un dossier /dist :

yarn build

Compiler le projet et analyser les dépendances :

yarn build:analyze

(ouvre le bundle analyzer sur http://127.0.0.1:8888/)