@mosa-ng/core 17.0.0 → 19.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/fesm2022/mosa-ng-core.mjs +1448 -0
  2. package/fesm2022/mosa-ng-core.mjs.map +1 -0
  3. package/index.d.ts +5 -0
  4. package/lib/constants/local-storage.constant.d.ts +2 -0
  5. package/lib/enums/browser.enum.d.ts +9 -0
  6. package/lib/enums/content-position.enum.d.ts +11 -0
  7. package/lib/enums/i18n-supported.enum.d.ts +10 -0
  8. package/lib/enums/theme.enum.d.ts +4 -0
  9. package/{src/lib/models/api-options.model.ts → lib/models/api-options.model.d.ts} +2 -6
  10. package/{src/lib/models/dictionary-item.model.ts → lib/models/dictionary-item.model.d.ts} +1 -2
  11. package/lib/models/key-map.model.d.ts +3 -0
  12. package/{src/lib/models/logger/log-event.model.ts → lib/models/logger/log-event.model.d.ts} +0 -1
  13. package/{src/lib/models/logger/log-message-data.model.ts → lib/models/logger/log-message-data.model.d.ts} +0 -1
  14. package/{src/lib/models/logger/log.model.ts → lib/models/logger/log.model.d.ts} +0 -1
  15. package/{src/lib/models/logger/logger-config.model.ts → lib/models/logger/logger-config.model.d.ts} +0 -1
  16. package/{src/lib/models/logger/logger-default-config.model.ts → lib/models/logger/logger-default-config.model.d.ts} +0 -1
  17. package/lib/models/mosa-duration.model.d.ts +1 -0
  18. package/{src/lib/models/sieve/sieve-filter.model.ts → lib/models/sieve/sieve-filter.model.d.ts} +0 -1
  19. package/lib/models/sieve/sieve-operator.model.d.ts +69 -0
  20. package/{src/lib/models/sieve/sieve-options.model.ts → lib/models/sieve/sieve-options.model.d.ts} +0 -1
  21. package/{src/lib/mosa-core.module.ts → lib/mosa-core.module.d.ts} +10 -47
  22. package/lib/pipes/dictionary-item-pipe/dictionary-item-pipe.module.d.ts +8 -0
  23. package/lib/pipes/dictionary-item-pipe/dictionary-item.pipe.d.ts +8 -0
  24. package/lib/pipes/find-in-array/find-in-array-pipe.module.d.ts +8 -0
  25. package/lib/pipes/find-in-array/find-in-array.pipe.d.ts +7 -0
  26. package/lib/pipes/join/join-pipe.module.d.ts +8 -0
  27. package/lib/pipes/join/join.pipe.d.ts +13 -0
  28. package/lib/pipes/mosa-date-pipe/mosa-date-pipe.module.d.ts +8 -0
  29. package/lib/pipes/mosa-date-pipe/mosa-date.pipe.d.ts +18 -0
  30. package/lib/pipes/mosa-duration-pipe/mosa-duration-pipe.module.d.ts +8 -0
  31. package/lib/pipes/mosa-duration-pipe/mosa-duration.pipe.d.ts +27 -0
  32. package/lib/services/api.service.d.ts +110 -0
  33. package/lib/services/core-logger.service.d.ts +80 -0
  34. package/lib/services/guards/can-deactivate.guard.d.ts +11 -0
  35. package/lib/services/mosa-socket.service.d.ts +11 -0
  36. package/lib/services/translation/assets-i18n-loader.service.d.ts +16 -0
  37. package/lib/services/translation/custom-translate-loader.service.d.ts +9 -0
  38. package/lib/services/translation/translate-collector.service.d.ts +15 -0
  39. package/lib/utils/commons.util.d.ts +47 -0
  40. package/lib/utils/dictionary.util.d.ts +70 -0
  41. package/{src/lib/utils/item.util.ts → lib/utils/item.util.d.ts} +1 -1
  42. package/lib/utils/promise.util.d.ts +2 -0
  43. package/lib/utils/prototypes.util.d.ts +80 -0
  44. package/lib/utils/sieve.util.d.ts +71 -0
  45. package/{src/lib/utils/size.util.ts → lib/utils/size.util.d.ts} +1 -1
  46. package/package.json +21 -10
  47. package/public-api.d.ts +1 -0
  48. package/.eslintrc.json +0 -31
  49. package/ng-package.json +0 -10
  50. package/src/lib/constants/local-storage.constant.ts +0 -4
  51. package/src/lib/enums/browser.enum.ts +0 -9
  52. package/src/lib/enums/content-position.enum.ts +0 -11
  53. package/src/lib/enums/i18n-supported.enum.ts +0 -10
  54. package/src/lib/enums/theme.enum.ts +0 -4
  55. package/src/lib/models/key-map.model.ts +0 -3
  56. package/src/lib/models/mosa-duration.model.ts +0 -1
  57. package/src/lib/models/sieve/sieve-operator.model.ts +0 -69
  58. package/src/lib/pipes/dictionary-item-pipe/dictionary-item-pipe.module.ts +0 -15
  59. package/src/lib/pipes/dictionary-item-pipe/dictionary-item.pipe.ts +0 -14
  60. package/src/lib/pipes/find-in-array/find-in-array-pipe.module.ts +0 -17
  61. package/src/lib/pipes/find-in-array/find-in-array.pipe.spec.ts +0 -8
  62. package/src/lib/pipes/find-in-array/find-in-array.pipe.ts +0 -34
  63. package/src/lib/pipes/join/join-pipe.module.ts +0 -17
  64. package/src/lib/pipes/join/join.pipe.spec.ts +0 -8
  65. package/src/lib/pipes/join/join.pipe.ts +0 -20
  66. package/src/lib/pipes/mosa-date-pipe/mosa-date-pipe.module.ts +0 -14
  67. package/src/lib/pipes/mosa-date-pipe/mosa-date.pipe.ts +0 -102
  68. package/src/lib/pipes/mosa-duration-pipe/mosa-duration-pipe.module.ts +0 -13
  69. package/src/lib/pipes/mosa-duration-pipe/mosa-duration.pipe.ts +0 -106
  70. package/src/lib/services/api.service.ts +0 -270
  71. package/src/lib/services/core-logger.service.ts +0 -219
  72. package/src/lib/services/guards/can-deactivate.guard.ts +0 -18
  73. package/src/lib/services/mosa-socket.service.ts +0 -46
  74. package/src/lib/services/translation/assets-i18n-loader.service.ts +0 -67
  75. package/src/lib/services/translation/custom-translate-loader.service.ts +0 -27
  76. package/src/lib/services/translation/translate-collector.service.ts +0 -60
  77. package/src/lib/utils/commons.util.ts +0 -100
  78. package/src/lib/utils/dictionary.util.ts +0 -140
  79. package/src/lib/utils/promise.util.ts +0 -3
  80. package/src/lib/utils/prototypes.util.ts +0 -167
  81. package/src/lib/utils/sieve.util.ts +0 -169
  82. package/src/public-api.ts +0 -1
  83. package/tsconfig.lib.json +0 -16
  84. package/tsconfig.lib.prod.json +0 -10
  85. package/tsconfig.spec.json +0 -14
  86. /package/{src/lib/models/logger/log-type.model.ts → lib/models/logger/log-type.model.d.ts} +0 -0
  87. /package/{src/lib/models/logger/logger-base-config.model.ts → lib/models/logger/logger-base-config.model.d.ts} +0 -0
  88. /package/{src/lib/models/sieve/sieve-response.model.ts → lib/models/sieve/sieve-response.model.d.ts} +0 -0
  89. /package/{src/lib/models/sieve/sieve-sort.model.ts → lib/models/sieve/sieve-sort.model.d.ts} +0 -0
  90. /package/{src/lib/models/token-settings.model.ts → lib/models/token-settings.model.d.ts} +0 -0
  91. /package/{src/lib/models/transform-matrix.model.ts → lib/models/transform-matrix.model.d.ts} +0 -0
package/.eslintrc.json DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "extends": "../../.eslintrc.json",
3
- "parserOptions": {
4
- "project": "**/tsconfig.json"
5
- },
6
- "overrides": [
7
- {
8
- "files": [
9
- "*.ts"
10
- ],
11
- "rules": {
12
- "@angular-eslint/component-selector": [
13
- "error",
14
- {
15
- "type": "element",
16
- "prefix": "mosa",
17
- "style": "kebab-case"
18
- }
19
- ],
20
- "@angular-eslint/directive-selector": [
21
- "error",
22
- {
23
- "type": "attribute",
24
- "prefix": "mosa",
25
- "style": "camelCase"
26
- }
27
- ]
28
- }
29
- }
30
- ]
31
- }
package/ng-package.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "../../dist/@mosa-ng/core",
4
- "lib": {
5
- "entryFile": "src/public-api.ts"
6
- },
7
- "assets": [
8
- "src/assets"
9
- ]
10
- }
@@ -1,4 +0,0 @@
1
- import { I18nSupported } from '../enums/i18n-supported.enum';
2
-
3
- export const MOSA_MERGED_TRANSLATION = (lang: string): string => `mosa_${ lang }_merged_${ location.host }`;
4
- export const MOSA_FALLBACK_TRANSLATION = `mosa_${ I18nSupported.enUS }_merged_${ location.host }`;
@@ -1,9 +0,0 @@
1
- export enum Browser {
2
- chrome,
3
- firefox,
4
- internetExplorer,
5
- opera,
6
- edge,
7
- safari,
8
- other,
9
- }
@@ -1,11 +0,0 @@
1
- export enum ContentPosition {
2
- top = 'top',
3
- topLeft = 'top-left',
4
- topRight = 'top-right',
5
- bottom = 'bottom',
6
- bottomLeft = 'bottom-left',
7
- bottomRight = 'bottom-right',
8
- center = 'center',
9
- centerLeft = 'center-left',
10
- centerRight = 'center-right',
11
- }
@@ -1,10 +0,0 @@
1
- export enum I18nSupported {
2
- enUS = 'en-US',
3
- deDE = 'de-DE',
4
- deCH = 'de-CH',
5
- deAT = 'de-AT',
6
- enGB = 'en-GB',
7
- frFR = 'fr-FR',
8
- esES = 'es-ES',
9
- ptPT = 'pt-PT',
10
- }
@@ -1,4 +0,0 @@
1
- export enum Theme {
2
- light,
3
- dark,
4
- }
@@ -1,3 +0,0 @@
1
- export interface IKeyMap<T> {
2
- [ key: string | number ]: T;
3
- }
@@ -1 +0,0 @@
1
- export type MosaDurationFormat = 'auto' | 'days' | 'hours' | 'minutes' | 'seconds';
@@ -1,69 +0,0 @@
1
- /**
2
- * Sieve operator for filtering
3
- * @see https://github.com/Biarity/Sieve#operators
4
- */
5
- export type SieveOperator =
6
- /**
7
- * Equals
8
- */
9
- '==' |
10
- /**
11
- * Not equals
12
- */
13
- '!=' |
14
- /**
15
- * Greater than
16
- */
17
- '>' |
18
- /**
19
- * Less than
20
- */
21
- '<' |
22
- /**
23
- * Greater than or equal to
24
- */
25
- '>=' |
26
- /**
27
- * Less than or equal to
28
- */
29
- '<=' |
30
- /**
31
- * Contains
32
- */
33
- '@=' |
34
- /**
35
- * Starts with
36
- */
37
- '_=' |
38
- /**
39
- * Does not Contains
40
- */
41
- '!@=' |
42
- /**
43
- * Does not Starts with
44
- */
45
- '!_=' |
46
- /**
47
- * Case-insensitive string Contains
48
- */
49
- '@=*' |
50
- /**
51
- * Case-insensitive string Starts with
52
- */
53
- '_=*' |
54
- /**
55
- * Case-insensitive string Equals
56
- */
57
- '==*' |
58
- /**
59
- * Case-insensitive string Not equals
60
- */
61
- '!=*' |
62
- /**
63
- * Case-insensitive string does not Contains
64
- */
65
- '!@=*' |
66
- /**
67
- * Case-insensitive string does not Starts with
68
- */
69
- '!_=*';
@@ -1,15 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import { NgModule } from '@angular/core';
3
- import { DictionaryItemPipe } from './dictionary-item.pipe';
4
-
5
- @NgModule({
6
- declarations: [ DictionaryItemPipe ],
7
- imports: [
8
- CommonModule,
9
- ],
10
- exports: [
11
- DictionaryItemPipe,
12
- ],
13
- })
14
- export class DictionaryItemPipeModule {
15
- }
@@ -1,14 +0,0 @@
1
- import { Pipe, PipeTransform } from '@angular/core';
2
- import { Dictionary } from '../../utils/dictionary.util';
3
-
4
- @Pipe({
5
- name: 'dictionaryItem',
6
- })
7
- export class DictionaryItemPipe implements PipeTransform {
8
-
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- public transform(key: any, dictionary: Dictionary<any, any>): string {
11
- return dictionary.get(key)?.value;
12
- }
13
-
14
- }
@@ -1,17 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import { NgModule } from '@angular/core';
3
- import { FindInArrayPipe } from './find-in-array.pipe';
4
-
5
- @NgModule({
6
- declarations: [
7
- FindInArrayPipe,
8
- ],
9
- imports: [
10
- CommonModule,
11
- ],
12
- exports: [
13
- FindInArrayPipe,
14
- ],
15
- })
16
- export class FindInArrayPipeModule {
17
- }
@@ -1,8 +0,0 @@
1
- import { FindInArrayPipe } from './find-in-array.pipe';
2
-
3
- describe('FindInArrayPipe', (): void => {
4
- it('create an instance', (): void => {
5
- const pipe: FindInArrayPipe = new FindInArrayPipe();
6
- void expect(pipe).toBeTruthy();
7
- });
8
- });
@@ -1,34 +0,0 @@
1
- import { Pipe, PipeTransform } from '@angular/core';
2
-
3
- @Pipe({
4
- name: 'findInArray',
5
- })
6
- export class FindInArrayPipe implements PipeTransform {
7
-
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- public transform<T>(searchValue: any, array: T[], searchKey: keyof T, returnElements?: (keyof T)[]): any {
10
- // Return if array is empty or null
11
- if (!array || !array.length) {
12
- return null;
13
- }
14
-
15
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
- const foundItem: T = array.find((val: T): boolean => (searchKey ? val[ searchKey as keyof T ] : val) === searchValue);
17
- if (!foundItem) {
18
- return null;
19
- }
20
-
21
- // Return whole item
22
- if (!returnElements) {
23
- return foundItem;
24
- }
25
-
26
- if (returnElements.length === 1) {
27
- return foundItem[ returnElements[ 0 ] ];
28
- }
29
-
30
- // Return given values to the keys
31
- return returnElements.map((val: keyof T) => foundItem[ val as keyof T ]);
32
- }
33
-
34
- }
@@ -1,17 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import { NgModule } from '@angular/core';
3
- import { JoinPipe } from './join.pipe';
4
-
5
-
6
- @NgModule({
7
- declarations: [
8
- JoinPipe,
9
- ],
10
- exports: [
11
- JoinPipe,
12
- ],
13
- imports: [
14
- CommonModule,
15
- ],
16
- })
17
- export class JoinPipeModule { }
@@ -1,8 +0,0 @@
1
- import { JoinPipe } from './join.pipe';
2
-
3
- describe('JoinPipe', (): void => {
4
- it('create an instance', (): void => {
5
- const pipe: JoinPipe = new JoinPipe();
6
- void expect(pipe).toBeTruthy();
7
- });
8
- });
@@ -1,20 +0,0 @@
1
- import { Pipe, PipeTransform } from '@angular/core';
2
-
3
- @Pipe({
4
- name: 'join',
5
- })
6
- export class JoinPipe implements PipeTransform {
7
-
8
- /**
9
- * Join array by separator
10
- * @param array
11
- * @param returnField
12
- * @param separator
13
- */
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- public transform(array: any[], returnField: any, separator: string = ', '): string {
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- return array.map((val: any): string => returnField ? val[ returnField ] : val).join(separator);
18
- }
19
-
20
- }
@@ -1,14 +0,0 @@
1
- import { CommonModule, DatePipe } from '@angular/common';
2
- import { NgModule } from '@angular/core';
3
- import { MosaDatePipe } from './mosa-date.pipe';
4
-
5
- @NgModule({
6
- declarations: [ MosaDatePipe ],
7
- imports: [
8
- CommonModule,
9
- ],
10
- exports: [ MosaDatePipe ],
11
- providers: [ DatePipe ],
12
- })
13
- export class MosaDatePipeModule {
14
- }
@@ -1,102 +0,0 @@
1
- import { DatePipe } from '@angular/common';
2
- import { Pipe, PipeTransform } from '@angular/core';
3
- import { TranslateService } from '@ngx-translate/core';
4
- import { BehaviorSubject, Observable } from 'rxjs';
5
- import { map } from 'rxjs/operators';
6
-
7
- @Pipe({
8
- name: 'mosaDate',
9
- })
10
- export class MosaDatePipe implements PipeTransform {
11
-
12
- private readonly store$: BehaviorSubject<number>;
13
- private templates: Record<string, string>;
14
-
15
- constructor(
16
- private readonly myTranslateService: TranslateService,
17
- private readonly myDatePipe: DatePipe,
18
- ) {
19
- this.store$ = new BehaviorSubject<number>(null);
20
- this.updateTemplates();
21
- setInterval((): void => {
22
- this.store$.next(new Date().getTime());
23
- }, 10);
24
- this.myTranslateService.onLangChange.subscribe((): void => {
25
- this.updateTemplates();
26
- this.store$.next(new Date().getTime());
27
- });
28
- }
29
-
30
- public transform(date: string | Date, mode: 'full' | 'timeSince' | 'date' = 'timeSince'): Observable<string> {
31
- return this.store$.pipe(map((currentDate: number): string => this.calcDate(currentDate, date, mode)));
32
- }
33
-
34
- private calcDate(currentDate: number, date: string | Date, mode: 'full' | 'timeSince' | 'date'): string {
35
- let parsed: number;
36
- if (date instanceof Date) {
37
- parsed = new Date(date.toString()).getTime();
38
- } else {
39
- parsed = new Date(date).getTime();
40
- }
41
-
42
- if (!currentDate) {
43
- currentDate = new Date().getTime();
44
- }
45
-
46
- const convertedDate = this.myDatePipe.transform(parsed, 'dd. MMM. yyyy hh:mm aaa');
47
- if (mode === 'full' || mode === 'timeSince') {
48
- const seconds = ((currentDate - parsed) * .001) >> 0;
49
- const minutes = seconds / 60;
50
- const hours = minutes / 60;
51
- const days = hours / 24;
52
- const years = days / 365;
53
-
54
- const timeSince: string = this.templates[ 'prefix' ] + (
55
- seconds < 60 && this.template('seconds', seconds) ||
56
- seconds < 120 && this.template('minute', 1) ||
57
- minutes < 60 && this.template('minutes', minutes) ||
58
- minutes < 120 && this.template('hour', 1) ||
59
- hours < 24 && this.template('hours', hours) ||
60
- hours < 42 && this.template('day', 1) ||
61
- days < 30 && this.template('days', days) ||
62
- days < 45 && this.template('month', 1) ||
63
- days < 365 && this.template('months', days / 30) ||
64
- years < 1.5 && this.template('year', 1) ||
65
- this.template('years', years)
66
- ) + this.templates[ 'prefix' ];
67
-
68
- if (mode === 'timeSince') {
69
- return timeSince;
70
- }
71
-
72
- if (mode === 'full') {
73
- return `${convertedDate} (${timeSince})`;
74
- }
75
- }
76
-
77
- return convertedDate;
78
- }
79
-
80
- private template(key: string, val: number): string {
81
- return this.templates[ key ] && this.templates[ key ].replace(/%d/i, String(Math.abs(Math.round(val))));
82
- }
83
-
84
- private updateTemplates(): void {
85
- this.templates = {
86
- prefix: this.myTranslateService.instant('mosa.pipes.timeSince.prefix'),
87
- suffix: this.myTranslateService.instant('mosa.pipes.timeSince.suffix'),
88
- seconds: this.myTranslateService.instant('mosa.pipes.timeSince.seconds'),
89
- minute: this.myTranslateService.instant('mosa.pipes.timeSince.minute'),
90
- minutes: this.myTranslateService.instant('mosa.pipes.timeSince.minutes'),
91
- hour: this.myTranslateService.instant('mosa.pipes.timeSince.hour'),
92
- hours: this.myTranslateService.instant('mosa.pipes.timeSince.hours'),
93
- day: this.myTranslateService.instant('mosa.pipes.timeSince.day'),
94
- days: this.myTranslateService.instant('mosa.pipes.timeSince.days'),
95
- month: this.myTranslateService.instant('mosa.pipes.timeSince.month'),
96
- months: this.myTranslateService.instant('mosa.pipes.timeSince.months'),
97
- year: this.myTranslateService.instant('mosa.pipes.timeSince.year'),
98
- years: this.myTranslateService.instant('mosa.pipes.timeSince.years'),
99
- };
100
- }
101
-
102
- }
@@ -1,13 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import { NgModule } from '@angular/core';
3
- import { MosaDurationPipe } from './mosa-duration.pipe';
4
-
5
- @NgModule({
6
- declarations: [ MosaDurationPipe ],
7
- imports: [
8
- CommonModule,
9
- ],
10
- exports: [ MosaDurationPipe ],
11
- })
12
- export class MosaDurationPipeModule {
13
- }
@@ -1,106 +0,0 @@
1
- import { Pipe, PipeTransform } from '@angular/core';
2
- import { TranslateService } from '@ngx-translate/core';
3
- import { BehaviorSubject, Observable } from 'rxjs';
4
- import { map } from 'rxjs/operators';
5
- import { MosaDurationFormat } from '../../models/mosa-duration.model';
6
-
7
- @Pipe({
8
- name: 'mosaDuration',
9
- })
10
- export class MosaDurationPipe implements PipeTransform {
11
-
12
- private readonly store$: BehaviorSubject<number>;
13
- private readonly interval: NodeJS.Timeout;
14
-
15
- constructor(
16
- private readonly myTranslateService: TranslateService,
17
- ) {
18
- this.store$ = new BehaviorSubject<number>(new Date().getTime());
19
- this.interval = setInterval(() => {
20
- this.store$.next(new Date().getTime());
21
- }, 1000);
22
- this.myTranslateService.onLangChange.subscribe((): void => {
23
- this.store$.next(new Date().getTime());
24
- });
25
- }
26
-
27
- /**
28
- * Converts a timestamp to a duration in the given format
29
- * @param millis
30
- * @param format
31
- * @returns
32
- * auto: 15000 -> 15 seconds
33
- * seconds: 15000 -> 15 seconds
34
- * minutes: 60000 -> 1 minute
35
- * hours: 7200000 -> 2 hours
36
- * days: 172800000 -> 2 days
37
- */
38
- public transform(millis: number, format: MosaDurationFormat = 'auto'): Observable<string> {
39
- return this.store$.pipe(
40
- map((currentDate: number): string => {
41
- if (!millis) {
42
- clearInterval(this.interval);
43
- return null;
44
- }
45
-
46
- if (millis - currentDate < 0) {
47
- clearInterval(this.interval);
48
- return null;
49
- }
50
-
51
- return this.calcDuration(currentDate, millis, format);
52
- }),
53
- );
54
- }
55
-
56
-
57
- private getTranslation(num: number, format: MosaDurationFormat): string {
58
- if (num === 1) {
59
- return `${ num.toFixed(0) } ${ this.myTranslateService.instant(`mosa.commons.dateTime[${ format }].label`) }`;
60
- }
61
- return `${ num.toFixed(0) } ${ this.myTranslateService.instant(`mosa.commons.dateTime[${ format }].plural.label`) }`;
62
- }
63
-
64
-
65
- private calcDuration(currentDate: number, millis: number, format: MosaDurationFormat): string {
66
- millis = millis - currentDate;
67
-
68
- const seconds: number = millis / 1000;
69
- if (format === 'seconds') {
70
- return this.getTranslation(seconds, 'seconds');
71
- }
72
-
73
- const minutes: number = seconds / 60;
74
- if (format === 'minutes') {
75
- return this.getTranslation(minutes, 'minutes');
76
- }
77
-
78
- const hours: number = minutes / 60;
79
- if (format === 'hours') {
80
- return this.getTranslation(hours, 'hours');
81
- }
82
-
83
- const days: number = hours / 24;
84
- if (format === 'days') {
85
- return this.getTranslation(days, 'days');
86
- }
87
-
88
- if (format === 'auto') {
89
- if (seconds < 60) {
90
- return this.getTranslation(seconds, 'seconds');
91
- }
92
-
93
- if (minutes < 60) {
94
- return this.getTranslation(minutes, 'minutes');
95
- }
96
-
97
- if (hours < 24) {
98
- return this.getTranslation(hours, 'hours');
99
- }
100
-
101
- return this.getTranslation(days, 'days');
102
- }
103
-
104
- return null;
105
- }
106
- }