/// import { EventAggregator } from "aurelia-event-aggregator"; import { ICompletedOptions } from "./ICompletedOptions"; import { ProgressOperation } from "./progressOperation"; /** * A simple progress service for tracking active asynchronous operations and showing status messages. */ export default class ProgressService { private readonly eventAggregator; static readonly inject: typeof EventAggregator[]; private static init; inProgress: boolean; private readonly nanobar; private readonly operationMap; private progress; private navigationOperation; constructor(eventAggregator: EventAggregator); /** * Start a new operation. * @returns A operations wrapper for increments or completing a progress visualization. */ start(): ProgressOperation; /** * If there's an active operation, increments it's progress display. * @param big Whether or not to increment the progress by a small (5%) or big (10%) amount */ increment(big?: boolean): number; success(message: string, title?: string, options?: ToastrOptions): void; info(message: string, title?: string, options?: ToastrOptions): void; warning(message: string, title?: string, options?: ToastrOptions): void; attempt(operation: (status: ProgressOperation) => boolean | void, options?: Partial<{ title: string; successMessage: string; }>): boolean; attemptPromise(operation: (status: ProgressOperation) => Promise, options?: Partial<{ title: string; successMessage: string; }>): Promise; error(message: Error | string, title?: string, cleanError?: boolean): void; /** * Completes the progress visualization for an operation and (optionally) displays a message. * This is not intended to be used directly, but rather internally by the return result of `start()`. * @param id The id of the operation to stop. * @param options Additional operations related to showing a status message upon completion. */ stopOperation(id: string, options?: ICompletedOptions): void; private startedNavigation(instruction); private navigationProgress(); private completedNavigation(instruction, result); private operationTimeout(); private formatError(error, cleanError?); /** * Copies a text string to a user's clipboard. TODO: Move to utilities */ private copy(text); private isPromise(target); }