Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@btapai/ng-loading-indicator
Advanced tools
A loading indicator library for angular applications
For a quick demo, see this stackblitz
Install the package with the following script:
npm install @btapai/ng-loading-indicator
or
yarn add @btapai/ng-loading-indicator
Import the module into your main ngModule
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { LoadingIndicatorModule } from '@btapai/ng-loading-indicator';
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
LoadingIndicatorModule.forRoot(), // place it into the imports array
],
providers: [],
bootstrap: [AppComponent],
})
export class AppModule {}
Add the loading-indicator component to your app.component template
<!-- add the component to the bottom of the file -->
<btp-loading-indicator></btp-loading-indicator>
Use the method decorators to start/stop the indicator.
import { Component } from '@angular/core';
import { startLoadingIndicator, stopLoadingIndicator } from '@btapai/ng-loading-indicator';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
@startLoadingIndicator()
triggerLoadingIndicator() {
setTimeout(this.triggerLoadingIndicatorStop.bind(this), 5000);
}
@stopLoadingIndicator()
triggerLoadingIndicatorStop() {
console.log('stopped');
}
}
By default the loading-indicator is a spinner, however, by providing a custom configuration, you can customise the result.
export const DEFAULT_CONFIG: LoadingIndicatorConfig = {
size: 160, // size will determine the width and height of the indicator container (as a square)
color: '#7B1FA2', // the color you want for your indicator's background
overlayColor: 'rgba(100,100,100,0.3)', // the color you would like to use for the overlay
indicatorComponent: SpinnerComponent, // By default it is a spinner
};
The package itself contains an EllipsisComponent, which can be used as a replacement to the spinner.
To do that, just provide a specified config file in your module
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AppComponent } from './app.component';
import { LOADING_INDICATOR_CONFIG, LoadingIndicatorModule } from '@btapai/ng-loading-indicator';
import { AppRoutingModule } from './app.routing.module';
import { EllipsisComponent } from '@btapai/ng-loading-indicator';
@NgModule({
declarations: [AppComponent],
imports: [CommonModule, AppRoutingModule, LoadingIndicatorModule.forRoot()],
providers: [
{
provide: LOADING_INDICATOR_CONFIG,
useValue: {
color: 'red',
size: 160,
indicatorComponent: EllipsisComponent,
},
},
],
})
export class AppModule {}
If you would like to use your own indicator component, make sure that your component is an entryComponent, and provide it in the config:
// component:
import { Component } from '@angular/core';
@Component({
selector: 'app-loading-message',
template: `<h1>Loading...</h1>`,
styles: [``],
})
export class LoadingMessageComponent {}
// app module
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AppComponent } from './app.component';
import { LOADING_INDICATOR_CONFIG, LoadingIndicatorModule } from '@btapai/ng-loading-indicator';
import { AppRoutingModule } from './app.routing.module';
import { LoadingMessageComponent } from './loading-message.component';
@NgModule({
declarations: [AppComponent, LoadingMessageComponent],
imports: [CommonModule, AppRoutingModule, LoadingIndicatorModule.forRoot()],
entryComponents: [LoadingMessageComponent],
providers: [
{
provide: LOADING_INDICATOR_CONFIG,
useValue: {
color: 'red',
size: 160,
indicatorComponent: LoadingMessageComponent,
},
},
],
})
export class AppModule {}
In future releases, I'd like to provide more indicators in the package, and the ability to add any component as an indicator.
FAQs
A loading indicator library for angular applications
We found that @btapai/ng-loading-indicator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.