File

projects/congarevenuecloud/elements/src/shared/services/exception.service.ts

Description

The service is used to show the toaster message based on the message type.

Usage

Example :
import { ExceptionService, AObjectService} from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
constructor( private exceptionService: ExceptionService)
}
// or
export class MyService extends AObjectService {
private exceptionService: ExceptionService = this.injector.get(ExceptionService);
}

Index

Methods

Constructor

constructor(cartService: CartService, constraintRuleService: ConstraintRuleService, promotionService: PromotionService, toastr: ToastrService, translateService: TranslateService, apiService: ApiService)
Parameters :
Name Type Optional
cartService CartService No
constraintRuleService ConstraintRuleService No
promotionService PromotionService No
toastr ToastrService No
translateService TranslateService No
apiService ApiService No

Methods

clearToast
clearToast()

Clear all toaster.

Example:

Example :
import { ExceptionService } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{

clearToast(){
this.exceptionService.clearToast();
}
}
Returns : void
showError
showError(error: CartError | Error | string, title: string, data?: any, positionClass: ToasterPosition, timeOut: number, closeButton: boolean, disableTimeOut: boolean)

Show error message in the toaster.

Example:

Example :
import { ExceptionService, CartError } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{

showError(error: CartError | Error | string){
this.exceptionService.showError(error);
}
}

key which updates whenever language change.

Parameters :
Name Type Optional Default value Description
error CartError | Error | string No

message is of type Error or CartError or string,

title string No 'ERROR.APPLICATION_ERROR_TOASTR_TITLE'

success title on the toaser.

data any Yes

is optional; required to return stream of translated values of a key which updates whenever language change.

positionClass ToasterPosition No ToasterPosition.BOTTOM_LEFT

class to position the toaster, use ToasterPosition enum.

timeOut number No 5000

set the timeOut to close the toaster.

closeButton boolean No false

boolean value when set to true 'x' icon will be enabled to close the toaster. By default it is false.

disableTimeOut boolean No false

boolean value when set to true ignore timeout and keeps the toaster. By default it is false.

Returns : void
showInfo
showInfo(message: string, title: string, data?: any, positionClass: ToasterPosition, timeOut: number, closeButton: boolean, disableTimeOut: boolean, progressBar: boolean, tapToDismiss: boolean)

Show info message in the toaster.

Example:

Example :
import { ExceptionService } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{

showInfo(message: string){
this.exceptionService.showInfo(message);
}
}

key which updates whenever language change.

Parameters :
Name Type Optional Default value Description
message string No

info message to be displayed on the toaster.

title string No 'COMMON.INFO_ALERT'

info title on the toaser.

data any Yes

is optional; required to return stream of translated values of a key which updates whenever language change.

positionClass ToasterPosition No ToasterPosition.BOTTOM_LEFT

class to position the toaster, use ToasterPosition enum.

timeOut number No 5000

set the timeOut to close the toaster.

closeButton boolean No false

boolean value when set to true 'x' icon will be enabled to close the toaster. By default it is false.

disableTimeOut boolean No false

boolean value when set to true ignores the timeout and keeps the toaster. By default it is false.

progressBar boolean No false

boolean value when set to true visually indicates the toaster timing before it closes.

tapToDismiss boolean No true

boolean value when set to true ensures the the toaster is dismissed on click event.

Returns : void
showSuccess
showSuccess(message: string, title: string, data?: any, positionClass: ToasterPosition, timeOut: number, closeButton: boolean, disableTimeOut: boolean)

Show success message in the toaster.

Example:

Example :
import { ExceptionService } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{

showSuccess(message: string){
this.exceptionService.showSuccess(message);
}
}

key which updates whenever language change.

Parameters :
Name Type Optional Default value Description
message string No

success message to be displayed on the toaster.

title string No 'SUCCESS.TITLE'

success title on the toaser.

data any Yes

is optional; required to return stream of translated values of a key which updates whenever language change.

positionClass ToasterPosition No ToasterPosition.BOTTOM_LEFT

class to position the toaster, use ToasterPosition enum.

timeOut number No 5000

set the timeOut to close the toaster.

closeButton boolean No false

boolean value when set to true 'x' icon will be enabled to close the toaster. By default it is false.

disableTimeOut boolean No false

boolean value when set to true ignore timeout and keeps the toaster. By default it is false.

Returns : void
showWarning
showWarning(message: string, title: string, data?: any, positionClass: ToasterPosition, timeOut: number, closeButton: boolean, disableTimeOut: boolean)

Show warning message in the toaster.

Example:

Example :
import { ExceptionService } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{

showWarning(message: string){
this.exceptionService.showWarning(message);
}
}

key which updates whenever language change.

Parameters :
Name Type Optional Default value Description
message string No

warning message to be displayed on the toaster.

title string No 'COMMON.INFO_ALERT'

warning title on the toaser.

data any Yes

is optional; required to return stream of translated values of a key which updates whenever language change.

positionClass ToasterPosition No ToasterPosition.BOTTOM_LEFT

class to position the toaster, use ToasterPosition enum.

timeOut number No 5000

set the timeOut to close the toaster.

closeButton boolean No false

boolean value when set to true 'x' icon will be enabled to close the toaster. By default it is false.

disableTimeOut boolean No false

boolean value when set to true ignore timeout and keeps the toaster. By default it is false.

Returns : void

results matching ""

    No results matching ""