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

angular-table-searcher

v5.0.5

Published

This is an angular table searcher. it helps to use keys provided to search through a list of objects and if no keys are provided, it searches for the occurrence of the input value. it also makes request to endpoint if url is provided for backend search.

Downloads

5

Readme

AngularTableSearcher (Angular ^5...)

This is an angular table searcher. it helps to use keys provided to search through a list of objects and if no keys are provided, it searches for the occurrence of the input value. it also makes request to endpoint if url is provided for backend search.

Release Note

Due to compatibility issues in Angular 4 & 5, we will maintain all:

Angular 4 from 4.0.0 and above.
Angular 5 from 5.0.0 and above.

Dependencies

npm install font-awesome --save

Read up on how to setup font-awesome in your application.

Installation

npm install --save angular-table-searcher

Usage in Application

Follow the instruction below to use angular-table-searcher.

import {AngularTableSearcherModule} from 'angular-table-searcher';

Add AngularTableSearcherModule.forRoot() in AppModule or Other Modules using AngularTableSearcherModule

Notice:

path: full path of the api url to call for search option.
from: the key the eventService will use in mapping when data has responded from angular-table-seacher. (from key must be unique to every component using searcher)
data: (paginated response), this must be the first data rendered from the component which information are picked to enable searching.
searchKeys: Keys to tell the AngularTableSearcher to use to filter data but can be empty array to search all through object and its child.
searchType: We have three search types which can be from backend, table, table not found with backend.
placeholder: What to display in the input field as a message
buttonColor: The background color of the table seacher.
borderColor: The border-bottom color of the table seacher.
queryField: The field name to pass search value into. such as search will be search='value entered'

A sample AngularTableSearcher built url for searching will be http://localhost:8088/api/organizations?search=olanipekun'

*.component.ts

Add/refactor the following code to the appropriate places in your component.ts

searching

  Searching can either be done with enter or button click after value has been supplied.

Response

The response from angular-table-searcher is an object of type:

{
result: Object | Array,
data: Array // data passed down to table-searcher.
}
import {Component, OnInit} from '@angular/core';
import {HttpClient} from "@angular/common/http";
import 'rxjs/add/operator/map';
import {EventsService, TableSearcherTypesEnum} from "angular-table-searcher";
import {TableSearcherInterface} from "./table-searcher/table-searcher.interface";
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  title = 'app';
   public tableSearcher: TableSearcherInterface<Object> = {
     path: 'http://localhost:8088/api/organizations',
     searchType: TableSearcherTypesEnum.EMPTY_TABLE_APPLY_BACKEND,
     searchKeys: ['name', 'email'], // can be empty array to enable deep searching
     borderColor: '',
     buttonColor: '',
     queryField: 'search',
     data: null,
     placeholder: 'Filter information...',
     from: 'search_organizations'
   };

  constructor(private eventsService: EventsService, private http: HttpClient) {
    this.eventsService.on(this.tableSearcher.from, (res) => {
      // Note that table will response from table searcher will respond with result and data,
      // the result is the searched item while data is the previous data passed down to it.
      // the result can be of array or object.
      // if result is an array, that is the final result
      // but if result is object, it denotes a backend response, so you can drill down to pick the searched result depending on your api response.
      // console.log('response=', res);
      this.tableSearcher.data = (res['result'].constructor === Array) ? res['result'] : res['result'].data['data']; // update table data in view
    });
  }
  private getOrganizations() {
    this.http.get(this.tableSearcher.path)
      .subscribe(
      (res) => {
        this.tableSearcher.data = res['data']['data'];
      },
      (err) => {

      }
    );
  }

  ngOnInit() {
    this.getOrganizations();
  }
}


      

*.component.html

Add this below the table you want it to paginate data from backend.

<div style="width: 30%; margin: 10px auto;" *ngIf="tableSearcher.data">
<app-table-searcher [allSettings]="tableSearcher"></app-table-searcher>
<table width="100%" class="table table-striped table-responsive">
  <tr>
    <td>#</td>
    <td>Name</td>
  </tr>

  <tr *ngFor="let page of tableSearcher.data; let i = index;">
    <td>{{(i + 1)}}</td>
    <td>{{page?.name}}</td>
  </tr>

</table>


</div>

Backend expected request

Your backend will expect

queryField: any type to search information

Build as a package

npm run pack-build

Publish to npm

npm publish dist