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

ngx-spa-utilities

v18.2.5

Published

<a href="https://github.com/khanhvuongnh/AngularLibrary"> <div style="text-align: center;"> <img class="mx-auto center-block d-block" src="https://raw.githubusercontent.com/khanhvuongnh/AngularLibrary/master/src/assets/imgs/logo.jpg" alt="ngx-spa-

Downloads

71

Readme

This library was generated with Angular CLI version 14.0.0.

Installation

Install ngx-spa-utilities from npm:

npm install bootstrap notiflix ngx-spa-utilities

Install ngx-spa-utilities from yarn:

yarn add bootstrap notiflix ngx-spa-utilities

Destroy Service

@Component({
  ...
  providers: [DestroyService]
})
export class ProductComponent implements OnInit {

  constructor(
    private cartService: CartService,
    private destroy: DestroyService) { }

  ngOnInit(): void {
    this.cartService.getCart()
      .pipe(takeUntil(this.destroy.destroyed$))
      .subscribe({...});
  }
}

Notiflix Service

@Component({
  ...
})
export class AppComponent implements OnInit {

  constructor(private notiflixService: NgxNotiflixService) { }

  ngOnInit(): void {
    // Change it to your nice customization
    this.notiflixService.init({
      okButton: 'Okie',
      cancelButton: 'Oh No',
      loadingSvgUrl: 'assets/img/loading.svg',
      loadingType: 'custom',
      loadingColor: '#ff5549',
      fontFamily: 'Roboto',
      notifyOptions: {
        position: 'center-top',
      },
    });

    // Fire to show a success notification
    this.notiflixService.notifySuccess('Hello, World.');
  }

All Functions

// Init
init(): void

// Notify
notifySuccess(): void
notifyError(): void
notifyWarning(): void
notifyInfo(): void

// Confirm
confirmSuccess(): void
confirmError(): void
confirmWarning(): void
confirmInfo(): void

// Ask
askSuccess(): void
askError(): void
askWarning(): void
askInfo(): void

// Promt
promptSuccess(): void
promptError(): void
promptWarning(): void
promptInfo(): void

// Report
reportSuccess(): void
reportError(): void
reportInfo(): void
reportWarning(): void

// Loading
showLoading(): void
hideLoading(): void

// Block
showBlock(): void
hideBlock(): void

Interfaces

export interface NotiflixCustom {
  okButton?: string;
  cancelButton?: string;
  loadingSvgUrl?: string;
  loadingType?: "standard" | "hourglass" | "circle" | "arrows" | "dots" | "pulse" | "custom";
  loadingColor?: string;
  fontFamily?: string;
  notifyOptions?: Notiflix.INotifyOptions;
  confirmOptions?: Notiflix.IConfirmOptions;
  loadingOptions?: Notiflix.ILoadingOptions;
  reportOptions?: Notiflix.IReportOptions;
  blockOptions?: Notiflix.IBlockOptions;
}

Function Utilitity

@Component({...})
export class ProductComponent implements OnInit {
  id: string = '';

  constructor(private fu: FunctionUtility) { }

  ngOnInit(): void {
    this.id = this.fu.nextID();
  }
}

All Functions

today(): string
nextID(): string
toSeq(input: Date): string
toStringDate(input: Date): string
toStringTime(input: Date): string
toStringDateTime(input: Date): string
toStringYearMonth(input: Date): string
toStringShortMonth(input: Date): string
getParentUrl(url: string, backLevel: number = 1): string
toStringLeadingZeros(input: number, targetLength: number): string

toDate(input: string): Date
toUTCDate(input: Date): Date
toEndDate(input: Date): Date
toBeginDate(input: Date): Date
toLastDateOfYear(input: Date): Date
toLastDateOfMonth(input: Date): Date
toFirstDateOfYear(input: Date): Date
toFirstDateOfMonth(input: Date): Date

toParams(formValue: any): HttpParams

toFormData(formValue: any): FormData

calculatePagination(pagination: Pagination): void

Key Value Utility

export interface KeyValueUtility {
  key?: any;
  value?: string;
  value_vi?: string;
  value_en?: string;
  value_zh?: string;
  optional?: any;
}

Operation Result

export interface OperationResult {
  error?: string;
  isSuccess?: boolean;
  data?: any;
}

Pagination Utility

export interface Pagination {
  totalCount: number;
  totalPage: number;
  pageNumber: number;
  pageSize: number;
  skip: number;
  isPaging: boolean;
}

export interface PaginationParam {
  pageNumber: number;
  pageSize: number;
  isPaging: boolean;
}

export class PaginationResult<T> {
  result: T[] = [];
  pagination: Pagination = <Pagination>{};
}

Media Uploader

Installation

In angular.json:

{
  ...
  "architect": {
    "build": {
      "options": {
        "assets": [
          "src/favicon.ico",
          "src/assets",
          {
            "glob": "**/*",
            "input": "node_modules/ngx-spa-utilities/assets",
            "output": "assets"
          }
        ],
        "styles": [
          "node_modules/bootstrap/scss/bootstrap.scss",
          "node_modules/notiflix/dist/notiflix-3.2.7.min.css",
          "src/styles.scss"
        ],
        "scripts": [
          "node_modules/bootstrap/dist/js/bootstrap.bundle.min.js",
          "node_modules/notiflix/dist/notiflix-3.2.7.min.js"
        ]
      }
    }
  }
  ...
}

In *.module.ts:

import { MediaUploaderComponent } from 'ngx-spa-utilities';

@NgModule({
  imports: [
    ...
    MediaUploaderComponent,
    ...
  ]
})

In *.component.html:

<media-uploader
  #mediaUploader
  [src]="modal.src"
  [height]="10"
  [maxSize]="50000"
  [copy]="true"
  [crop]="true"
  [remove]="true"
  [preview]="true"
  [disabled]="false"
  [confirmRemove]="true"
  [accept]="'.jpg, .jpeg, .png, .svg'"
  [(file)]="modal.file"
  (result)="handleResult($event)"
>
</media-uploader>

In *.component.ts:

@Component({...})
export class AppComponent implements OnInit {
  @ViewChild('mediaUploader') mediaUploader!: MediaUploaderComponent;

  model: Model = <Model>{};

  constructor(private service: MediaUploaderService) {
  }

  ngOnInit(): void {
    this.service.notificationTitle = {
      ...this.service.notificationTitle,
      Delete: "Usuń przedmiot?"
    };
    this.service.notificationMessage = {
      ...this.service.notificationMessage,
      Delete: "Bạn có chắc chắn muốn xoá không?",
      DeleteFailed: "削除に失敗しました!",
      DeleteSuccessful: "Eliminazione riuscita!",
    }
  }

  handleResult(event: OperationResult): void {
    // Do something here...
  }

  reset(): void {
    // Reset uploader
    this.mediaUploader.reset();

    // Do something here...
  }
}

interface Model {
  src: string;
  file: File;
}