import { Inject, Injectable } from '../decorators' import {FeedbackOptions} from './feedback.component' @Injectable('feedbackService') export default class FeedbackService { constructor( @Inject('$rootScope') private $rootScope: ng.IRootScopeService, @Inject('translateFactory') private translateFactory ) {} /** * Displays a feedback containing the provided message on the page. * * @param options.type * Indicates the color of the feedback and text. Possible options are: * - `success` - green (default) * - `danger` - red * - `warning` - orange * - `info` - blue * * @param options.manualClose * If true, the feedback will stay on screen until the user closes it. * Defaults to false (the feedback will disappear in 5 seconds). * * @param options.clipboardContents * The text that will be used to copy to clipboard * * @param options.copyLinkText * The text that will be used as tag to copy text to clipboard * * @param options.copySuccessMessage * The message that will be displayed when the text is copied to the clipboard * * @param options.autoCopyContents * The text that will be used to auto copy to clipboard * */ show(message: string, options: FeedbackOptions = {}) { this.$rootScope.$emit('showFeedback', { alertMessage: message, type: options.type || 'success', manualClose: options.manualClose || false, clipboardContents: options.clipboardContents || false, copyLinkText: options.copyLinkText || this.translateFactory.instant('JSUI.COPY_LINK_TEXT'), copySuccessMessage: options.copySuccessMessage || this.translateFactory.instant('JSUI.COPY_TO_CLIPBOARD'), autoCopyContents: options.autoCopyContents || false, trustAsHtml: options.trustAsHtml || false }) } }