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

ng2-file-tree

v0.4.3

Published

Angular2 Directives for rendering Directory Tree

Downloads

64

Readme

Angular2 File Tree CircleCI

Angular2 Component for rendering directory tree

Please feel free to open issues for new features, requirements, and bug reports. This repository is developing based on requests;)

Installation

In package.json, add following lines in the dependencies block:

"font-awesome": "~4.7.0"  # Use any versions
"ng2-file-tree": "~0.4.0"

Angular2 QuickStart

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

We can import this library using SystemJS (systemjs.config.js):

// This example is following to Angular2 Quick Start Documentation

(function (global) {
  System.config({
    paths: {
      'npm:': 'node_modules/'
    },
    map: {
      app: 'app',

      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
      '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',

      'rxjs':                      'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',

      // Add this line (1/2)
      'ng2-file-tree': 'node_modules/ng2-file-tree',
    },
    packages: {
      app: {
        main: './main.js',
        defaultExtension: 'js'
      },
      rxjs: {
        defaultExtension: 'js'
      },
      'angular-in-memory-web-api': {
        main: './index.js',
        defaultExtension: 'js'
      },

      // Add this line (2/2)
      'ng2-file-tree': { defaultExtension: 'js' }
    }
  });
})(this);

Angular CLI

  1. ../node_modules/font-awesome/css/font-awesome.css to style block of angular-cli.json.
  2. ../node_modules/font-awesome/fonts/*.+(otf|eot|svg|ttf|woff|woff2) to addons block of angular-cli.json.
/* angular-cli.json  */
{
  "apps": [
    {
      "styles": [
        "../node_modules/font-awesome/css/font-awesome.css"
      ]
    }
  ],
  "addons": [
    "../node_modules/font-awesome/fonts/*.+(otf|eot|svg|ttf|woff|woff2)"
  ]
}

Usage

// app/app.module.ts

// (1/2)
import { Ng2FileTreeModule } from 'ng2-file-tree/ng2-file-tree'

@NgModule({
  imports: [ BrowserModule, Ng2FileTreeModule ], // (2/2)
  declarations: [ AppComponent ],
  bootstrap: [ AppComponent ]
})
export class AppModule { }
import { Component } from '@angular/core';

@Component({
    selector: 'my-app',
    template: `<file-tree [tree]="fileTree"
                          (onChange)="clickFileTree($event)"
                          [keyboardWatch]=true>
               </file-tree>`
})
export class AppComponent {
    fileTree = {
      "name": "photos",
      "children": [
        {
          "name": "summer",
          "children": [
            {
              "name": "june",
              "children": [
                {
                  "name": "windsurf.jpg"
                }]
            }
          ]
        }
      ]
    }

    clickFileTree(fileNode:TreeNode):void {
        console.log(fileNode);

        // Get full file path
        console.log(fileNode.getFullPath())
    }
}

Features

  • [ ] Handling keyboard event
    • [x] Move by up-arrow, down-arrow
    • [ ] Move by up-arrow, down-arrow
  • [ ] General icon support (now it's hard coded)
  • [ ] Change icons by file type (.jpg, .js, ...)
  • [ ] ....so forth

Contribution

Any reporting issues, sending pull requests, or even pushing the star button are welcome and appreciated.