export enum EN_UINotificationType {
  info = 1,
  warn = 2
}
export class UINotification {

  message: string;
  type: EN_UINotificationType;
  isActive: boolean;
  createdTimestamp: Date;
  displayedTimestamp: Date;
  finishedTimestamp: Date;
  duration: number;
  id: number;

  constructor(message: string, type: EN_UINotificationType, duration: number, id: number) {
    this.message = message;
    this.isActive = true;
    this.type = type;
    this.createdTimestamp = new Date();
    this.duration = duration;
    this.id = id;
  }

  public stopMessage(): void {
    this.finishedTimestamp = new Date();
    this.isActive = false;
  }

  public durationExpired(timeInSeconds: number) {
    if (this.displayedTimestamp && this.duration > 0) {
      if (timeInSeconds >= this.displayedTimestamp.getTime() + this.duration) {
        return true;
      }
    }
    return false;
  }

  public getStyleColor(): string {
    if (this.type === EN_UINotificationType.info) {
      return 'secondary';
    } else {
      return 'primary';
    }
  }
}
