1.2.0 • Published 3 years ago

angular-dadan-sdk v1.2.0

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

Angular Dadan SDK

A lightweight Angular package used for checking, validating, and manipulating Google Dadan Extension with Angular.

Install

npm install angular-dadan-sdk
Or
yarn add angular-dadan-sdk

Usage

In app.module.ts import the following

import { VideosModule } from 'angular-dadan-sdk';// our package
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    VideosModule //our module
  ],
  providers: [],
  bootstrap: [AppComponent]
});
export class AppModule { }

In app.component.html add the record button component with props

<lib-record-video-button
  (onSuccess)="handleResponse($event)"
  (onFailure)="handleResponse($event)"
  title="Select Video"
  type="select"
  buttonClass="dd__record__button__default__class"
  [buttonStyle]="{ color: '#1e3799', 'font-size': '15px' }"
  [showSvg]="true"
  [showPreview]="true"
  [copyToClipboard]="true"
>
</lib-record-video-button>

In app.component.ts add the following

export class AppComponent {
  title = 'angular-sample';
  public videos : any[]; // selected videos from extension
  constructor(){
    this.videos = []; // initial state
  }
  handleResponse($eventResult : any):void{ // handles selected or recorded videos
    const {success, data, message} = $eventResult;
    if (success) {
      if (data) {
        this.videos = data; //
        }
      } else {
        this.videos = [];//
        console.log(message);
      }
  }

}

the handleResponse function , is a callback function which accept object with three parameters

handleResponse($eventResult : any): void {
    const {success, data, message} = $eventResult;
    if (success) {
        // only false when user close extension
        if (data) {
            // represnts the selected videos , or recorded video object after stop recording
        this.videos = data;
            }
        } else {
        this.videos = [];
        console.error(message); //User Closed Extension
        }
    }

Record Button Props

ParameterTypeDescription
typestringRequired. either record or select , else will show error
titlestringOptional. button title
buttonClassstringOptional. the default class , or your custom class
buttonStyleobjectOptional. the default style , or your custom style as string
showSvgbooleanOptional. to show Svg icon in button
showPreviewbooleanOptional. to show preview dialog of recorded video
copyToClipboardbooleanOptional. to notify user that video shared url was copied to clipboard as toast message

License

MIT

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago