- const monthsArr: string[] = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
- const date: Date = new Date(unixtimestamp * this.epochTime1000);
- const year: number = date.getFullYear();
- const month: string = monthsArr[date.getMonth()];
- const day: number = date.getDate();
- const hours: number = date.getHours();
- const minutes: string = '0' + date.getMinutes();
- const seconds: string = '0' + date.getSeconds();
- return month + '-' + day + '-' + year + ' ' + hours + ':' + minutes.substr(this.epochTimeMinus2) + ':'
- + seconds.substr(this.epochTimeMinus2);
+ if (!isNullOrUndefined(unixtimestamp)) {
+ const monthsArr: string[] = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
+ const date: Date = new Date(unixtimestamp * this.epochTime1000);
+ const year: number = date.getFullYear();
+ const month: string = monthsArr[date.getMonth()];
+ const day: number = date.getDate();
+ const hours: number = date.getHours();
+ const minutes: string = '0' + date.getMinutes();
+ const seconds: string = '0' + date.getSeconds();
+ // eslint-disable-next-line deprecation/deprecation
+ return month + '-' + day + '-' + year + ' ' + hours + ':' + minutes.substr(this.epochTimeMinus2) + ':'
+ // eslint-disable-next-line deprecation/deprecation
+ + seconds.substr(this.epochTimeMinus2);
+ }
+ return this.translateService.instant('NODATE');
+ }
+
+ /** convert epoch time function to No of days @public */
+ public converEpochToDays(date: string): number {
+ if (!isNullOrUndefined(date)) {
+ const today: Date = new Date();
+ const accountDate: Date = new Date(date);
+ const toasterDate: number = (accountDate.getTime() -
+ today.getTime()) / this.epochTime1000 / this.epochTime60 / this.epochTime60 / this.epochTime24;
+ if (toasterDate >= 0 || toasterDate < 1) {
+ return Math.round(toasterDate);
+ }
+ return Math.floor(toasterDate);
+ }
+ return this.translateService.instant('N/A');
+ }
+
+ /** show toaster for password & account expiry @public */
+ public showToaster(lastLogin: string, failedAttempts: string, passwordNoOfDays: string,
+ accountNoOfDays: string, passwordExpireMessage: string, accountExpireMessage: string,
+ passwordMessage: string, accountMessage: string): ActiveToast<string> {
+ this.lastLoginMessage = this.translateService.instant('PAGE.LOGIN.LASTACCESS');
+ this.failedAttemptsMessage = this.translateService.instant('PAGE.LOGIN.FAILED');
+ return this.toaster.info(this.lastLoginMessage + ':' + ' ' + lastLogin +
+ '</br>' + this.failedAttemptsMessage + ':' + ' ' + failedAttempts +
+ '</br>' + passwordExpireMessage + ' ' + passwordNoOfDays + ' ' + passwordMessage +
+ '</br>' + accountExpireMessage + ' ' + accountNoOfDays + ' ' + accountMessage,
+ this.translateService.instant('PAGE.LOGIN.LOGINHISTORY'), this.toasterSettings);
+ }
+
+ /** show toaster for password expiry @public */
+ public passwordToaster(lastLogin: string, failedAttempts: string, passwordNoOfDays: string,
+ passwordExpireMessage: string, passwordMessage: string): ActiveToast<string> {
+ this.lastLoginMessage = this.translateService.instant('PAGE.LOGIN.LASTACCESS');
+ this.failedAttemptsMessage = this.translateService.instant('PAGE.LOGIN.FAILED');
+ return this.toaster.info(this.lastLoginMessage + ':' + ' ' + lastLogin +
+ '</br>' + this.failedAttemptsMessage + ':' + ' ' + failedAttempts +
+ '</br>' + passwordExpireMessage + ' ' + passwordNoOfDays + ' ' + passwordMessage,
+ this.translateService.instant('PAGE.LOGIN.LOGINHISTORY'), this.toasterSettings);
+ }
+
+ /** show toaster for account expiry @public */
+ public accountToaster(lastLogin: string, failedAttempts: string,
+ accountNoOfDays: string, accountExpireMessage: string, accountMessage: string): ActiveToast<string> {
+ this.lastLoginMessage = this.translateService.instant('PAGE.LOGIN.LASTACCESS');
+ this.failedAttemptsMessage = this.translateService.instant('PAGE.LOGIN.FAILED');
+ return this.toaster.info(this.lastLoginMessage + ':' + ' ' + lastLogin +
+ '</br>' + this.failedAttemptsMessage + ':' + ' ' + failedAttempts +
+ '</br>' + accountExpireMessage + ' ' + accountNoOfDays + ' ' + accountMessage,
+ this.translateService.instant('PAGE.LOGIN.LOGINHISTORY'), this.toasterSettings);