@muraai/mnl-commons 0.1.0-alpha-a04cfbd → 0.1.0-alpha-0abf887

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 (72) hide show
  1. package/esm2020/lib/commons.module.mjs +140 -0
  2. package/esm2020/lib/components/header/header.component.mjs +32 -0
  3. package/esm2020/lib/components/highlighter/highlighter.component.mjs +24 -0
  4. package/esm2020/lib/components/language-menu/language-menu.component.mjs +36 -0
  5. package/esm2020/lib/components/login/login.component.mjs +56 -0
  6. package/esm2020/lib/components/menu/menu.component.mjs +69 -0
  7. package/esm2020/lib/components/profile/profile.component.mjs +44 -0
  8. package/esm2020/lib/material.module.mjs +60 -0
  9. package/{esm2015/lib/model/log-levels.model.js → esm2020/lib/model/log-levels.model.mjs} +0 -0
  10. package/{esm2015/lib/model/menu-data.model.js → esm2020/lib/model/menu-data.model.mjs} +0 -0
  11. package/{esm2015/lib/model/translation-resource.js → esm2020/lib/model/translation-resource.mjs} +0 -0
  12. package/{esm2015/lib/model/user-model.js → esm2020/lib/model/user-model.mjs} +0 -0
  13. package/esm2020/lib/pipes/app-config-pipe.mjs +20 -0
  14. package/esm2020/lib/pipes/time-ago-pipe.mjs +43 -0
  15. package/esm2020/lib/pipes/user-fullname-pipe.mjs +34 -0
  16. package/esm2020/lib/pipes/user-initials-pipe.mjs +48 -0
  17. package/esm2020/lib/services/app.config.service.mjs +41 -0
  18. package/esm2020/lib/services/local-storage.service.mjs +48 -0
  19. package/esm2020/lib/services/locale.service.mjs +89 -0
  20. package/esm2020/lib/services/log.service.mjs +89 -0
  21. package/esm2020/lib/services/user-profile.service.mjs +36 -0
  22. package/{esm2015/lib/utils/object-utils.js → esm2020/lib/utils/object-utils.mjs} +0 -0
  23. package/{esm2015/muraai-mnl-commons.js → esm2020/muraai-mnl-commons.mjs} +0 -0
  24. package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
  25. package/fesm2015/muraai-mnl-commons.mjs +914 -0
  26. package/fesm2015/muraai-mnl-commons.mjs.map +1 -0
  27. package/fesm2020/muraai-mnl-commons.mjs +911 -0
  28. package/fesm2020/muraai-mnl-commons.mjs.map +1 -0
  29. package/{muraai-mnl-commons.d.ts → index.d.ts} +1 -0
  30. package/lib/commons.module.d.ts +19 -0
  31. package/lib/components/header/header.component.d.ts +3 -0
  32. package/lib/components/highlighter/highlighter.component.d.ts +3 -0
  33. package/lib/components/language-menu/language-menu.component.d.ts +3 -0
  34. package/lib/components/login/login.component.d.ts +5 -2
  35. package/lib/components/menu/menu.component.d.ts +3 -0
  36. package/lib/components/profile/profile.component.d.ts +3 -0
  37. package/lib/material.module.d.ts +14 -2
  38. package/lib/pipes/app-config-pipe.d.ts +3 -0
  39. package/lib/pipes/time-ago-pipe.d.ts +3 -0
  40. package/lib/pipes/user-fullname-pipe.d.ts +3 -0
  41. package/lib/pipes/user-initials-pipe.d.ts +3 -0
  42. package/lib/services/app.config.service.d.ts +3 -0
  43. package/lib/services/local-storage.service.d.ts +7 -0
  44. package/lib/services/locale.service.d.ts +3 -0
  45. package/lib/services/log.service.d.ts +4 -1
  46. package/lib/services/user-profile.service.d.ts +3 -0
  47. package/package.json +22 -10
  48. package/theming.scss +6 -6
  49. package/bundles/muraai-mnl-commons.umd.js +0 -1270
  50. package/bundles/muraai-mnl-commons.umd.js.map +0 -1
  51. package/bundles/muraai-mnl-commons.umd.min.js +0 -17
  52. package/bundles/muraai-mnl-commons.umd.min.js.map +0 -1
  53. package/esm2015/lib/commons.module.js +0 -104
  54. package/esm2015/lib/components/header/header.component.js +0 -27
  55. package/esm2015/lib/components/highlighter/highlighter.component.js +0 -21
  56. package/esm2015/lib/components/language-menu/language-menu.component.js +0 -35
  57. package/esm2015/lib/components/login/login.component.js +0 -48
  58. package/esm2015/lib/components/menu/menu.component.js +0 -62
  59. package/esm2015/lib/components/profile/profile.component.js +0 -35
  60. package/esm2015/lib/material.module.js +0 -31
  61. package/esm2015/lib/pipes/app-config-pipe.js +0 -19
  62. package/esm2015/lib/pipes/time-ago-pipe.js +0 -43
  63. package/esm2015/lib/pipes/user-fullname-pipe.js +0 -30
  64. package/esm2015/lib/pipes/user-initials-pipe.js +0 -44
  65. package/esm2015/lib/services/app.config.service.js +0 -44
  66. package/esm2015/lib/services/local-storage.service.js +0 -17
  67. package/esm2015/lib/services/locale.service.js +0 -94
  68. package/esm2015/lib/services/log.service.js +0 -91
  69. package/esm2015/lib/services/user-profile.service.js +0 -40
  70. package/fesm2015/muraai-mnl-commons.js +0 -813
  71. package/fesm2015/muraai-mnl-commons.js.map +0 -1
  72. package/muraai-mnl-commons.metadata.json +0 -1
@@ -1,813 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { NgModule, EventEmitter, Component, ViewEncapsulation, Input, Output, Injectable, Inject, InjectionToken, Pipe, APP_INITIALIZER } from '@angular/core';
3
- import { MatButtonModule } from '@angular/material/button';
4
- import { MatListModule } from '@angular/material/list';
5
- import { MatIconModule } from '@angular/material/icon';
6
- import { MatInputModule } from '@angular/material/input';
7
- import { MatFormFieldModule } from '@angular/material/form-field';
8
- import { MatCardModule } from '@angular/material/card';
9
- import { FormsModule, ReactiveFormsModule, FormGroup, FormControl, Validators } from '@angular/forms';
10
- import { MatMenuModule } from '@angular/material/menu';
11
- import * as i4 from '@angular/common';
12
- import { DOCUMENT, DatePipe, registerLocaleData, CommonModule } from '@angular/common';
13
- import * as i1 from '@angular/common/http';
14
- import { HttpClient } from '@angular/common/http';
15
- import localeAR from '@angular/common/locales/ar';
16
- import localeDE from '@angular/common/locales/de';
17
- import localeFR from '@angular/common/locales/fr';
18
- import { FlexLayoutModule } from '@angular/flex-layout';
19
- import { MatToolbarModule } from '@angular/material/toolbar';
20
- import * as i2 from '@ngx-translate/core';
21
- import { TranslateService, TranslateModule, TranslateLoader } from '@ngx-translate/core';
22
- import { __awaiter } from 'tslib';
23
- import { DomSanitizer } from '@angular/platform-browser';
24
- import { MultiTranslateHttpLoader } from 'ngx-translate-multi-http-loader';
25
- import { formatDistance } from 'date-fns';
26
- import differenceInDays from 'date-fns/differenceInDays';
27
- import { Subject } from 'rxjs';
28
-
29
- function modules() {
30
- return [
31
- MatButtonModule,
32
- MatCardModule,
33
- MatFormFieldModule,
34
- MatIconModule,
35
- MatInputModule,
36
- MatListModule,
37
- FormsModule,
38
- ReactiveFormsModule,
39
- MatMenuModule,
40
- ];
41
- }
42
- class MaterialModule {
43
- }
44
- MaterialModule.decorators = [
45
- { type: NgModule, args: [{
46
- imports: modules(),
47
- exports: modules()
48
- },] }
49
- ];
50
-
51
- class HeaderComponent {
52
- constructor() {
53
- this.menuButonClickEvent = new EventEmitter();
54
- this.logoClick = new EventEmitter();
55
- }
56
- menuClick(event) {
57
- this.menuButonClickEvent.emit(event);
58
- }
59
- onLogoClick(event) {
60
- this.logoClick.emit(event);
61
- }
62
- }
63
- HeaderComponent.decorators = [
64
- { type: Component, args: [{
65
- selector: 'mnl-header',
66
- template: "<mat-toolbar *ngIf=\"header\" color=\"{{header.toolbarColor }}\">\n <mat-toolbar-row>\n <div fxLayout fxLayoutAlign=\"start center\">\n <button mat-icon-button *ngIf=\"header.showMenuIcon\">\n <mat-icon (click)=\"menuClick($event)\">menu</mat-icon>\n </button>\n <img class=\"mnl-logo\" (click)=\"onLogoClick($event)\" src=\"{{header.logo}}\">\n <span>{{header.name}}</span>\n </div>\n <div fxLayoutAlign=\"end center\" fxFlex>\n <ng-content select=`[mnl-header-content]`></ng-content>\n </div>\n </mat-toolbar-row>\n</mat-toolbar>",
67
- encapsulation: ViewEncapsulation.None,
68
- styles: [".mnl-logo{margin-right:15px}"]
69
- },] }
70
- ];
71
- HeaderComponent.propDecorators = {
72
- header: [{ type: Input }],
73
- menuButonClickEvent: [{ type: Output }],
74
- logoClick: [{ type: Output }]
75
- };
76
-
77
- class HighlighterComponent {
78
- constructor() {
79
- this.height = '40px';
80
- this.width = '4px';
81
- this.enabled = true;
82
- }
83
- }
84
- HighlighterComponent.decorators = [
85
- { type: Component, args: [{
86
- selector: 'mnl-highlighter',
87
- template: "<div [ngClass]=\"{'mnl-bg-primary' : enabled}\" [ngStyle]=\" {'height': height, 'width' : width}\"></div>",
88
- styles: [""]
89
- },] }
90
- ];
91
- HighlighterComponent.propDecorators = {
92
- height: [{ type: Input }],
93
- width: [{ type: Input }],
94
- enabled: [{ type: Input }]
95
- };
96
-
97
- class ObjectUtils {
98
- /**
99
- * Gets a value from an object by composed key
100
- * ObjectUtils.getValue({ item: { nodeType: 'cm:folder' }}, 'item.nodeType') ==> 'cm:folder'
101
- */
102
- static getValue(target, key) {
103
- if (!target) {
104
- return undefined;
105
- }
106
- const keys = key.split('.');
107
- key = '';
108
- do {
109
- key += keys.shift();
110
- const value = target[key];
111
- if (value !== undefined && (typeof value === 'object' || !keys.length)) {
112
- target = value;
113
- key = '';
114
- }
115
- else if (!keys.length) {
116
- target = undefined;
117
- }
118
- else {
119
- key += '.';
120
- }
121
- } while (keys.length);
122
- return target;
123
- }
124
- static merge(...objects) {
125
- const result = {};
126
- objects.forEach((source) => {
127
- Object.keys(source).forEach((prop) => {
128
- if (prop in result && Array.isArray(result[prop])) {
129
- result[prop] = result[prop].concat(source[prop]);
130
- }
131
- else if (prop in result && typeof result[prop] === 'object') {
132
- result[prop] = ObjectUtils.merge(result[prop], source[prop]);
133
- }
134
- else {
135
- result[prop] = source[prop];
136
- }
137
- });
138
- });
139
- return result;
140
- }
141
- }
142
-
143
- class AppConfigService {
144
- constructor(http) {
145
- this.http = http;
146
- this.config = null;
147
- }
148
- /**
149
- * Use to get the data found in the file (config file)
150
- */
151
- get(key, defaultValue) {
152
- const result = ObjectUtils.getValue(this.config, key);
153
- return (result === undefined ? defaultValue : result);
154
- }
155
- /**
156
- * This method:
157
- * Loads "config.json" to get all variables (e.g.: 'app.config.json')
158
- */
159
- load() {
160
- return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
161
- const configUrl = `assets/app.config.json`;
162
- yield this.http.get(configUrl).subscribe((data) => {
163
- this.config = Object.assign({}, this.config, data || {});
164
- resolve(this.config);
165
- }, () => {
166
- resolve(this.config);
167
- });
168
- }));
169
- }
170
- }
171
- AppConfigService.ɵprov = i0.ɵɵdefineInjectable({ factory: function AppConfigService_Factory() { return new AppConfigService(i0.ɵɵinject(i1.HttpClient)); }, token: AppConfigService, providedIn: "root" });
172
- AppConfigService.decorators = [
173
- { type: Injectable, args: [{
174
- providedIn: 'root',
175
- },] }
176
- ];
177
- AppConfigService.ctorParameters = () => [
178
- { type: HttpClient }
179
- ];
180
-
181
- class LocalStorageService {
182
- set(key, value) {
183
- localStorage.setItem(key, value);
184
- }
185
- get(key) {
186
- return localStorage.getItem(key);
187
- }
188
- }
189
- LocalStorageService.ɵprov = i0.ɵɵdefineInjectable({ factory: function LocalStorageService_Factory() { return new LocalStorageService(); }, token: LocalStorageService, providedIn: "root" });
190
- LocalStorageService.decorators = [
191
- { type: Injectable, args: [{
192
- providedIn: 'root'
193
- },] }
194
- ];
195
-
196
- class UserProfileService {
197
- constructor(appConfigService, localStorageService) {
198
- this.appConfigService = appConfigService;
199
- this.localStorageService = localStorageService;
200
- this.userPrefix = '';
201
- }
202
- getApplicationId() {
203
- return this.appConfigService.get('applicationId') ? this.appConfigService.get('applicationId') : '';
204
- }
205
- setUserPrefix(userPrefix) {
206
- this.userPrefix = userPrefix;
207
- }
208
- getUserPrefix() {
209
- return this.userPrefix ? this.userPrefix : '';
210
- }
211
- setLocale(locale) {
212
- this.localStorageService.set(this.getApplicationId() + this.userPrefix + UserProfileService.LOCALE_PREFIX, locale);
213
- }
214
- getLocale() {
215
- return this.localStorageService.get(this.getApplicationId() + this.userPrefix + UserProfileService.LOCALE_PREFIX);
216
- }
217
- }
218
- UserProfileService.LOCALE_PREFIX = '____locale';
219
- UserProfileService.ɵprov = i0.ɵɵdefineInjectable({ factory: function UserProfileService_Factory() { return new UserProfileService(i0.ɵɵinject(AppConfigService), i0.ɵɵinject(LocalStorageService)); }, token: UserProfileService, providedIn: "root" });
220
- UserProfileService.decorators = [
221
- { type: Injectable, args: [{
222
- providedIn: 'root'
223
- },] }
224
- ];
225
- UserProfileService.ctorParameters = () => [
226
- { type: AppConfigService },
227
- { type: LocalStorageService }
228
- ];
229
-
230
- /** @dynamic */
231
- class LocaleService {
232
- constructor(config, translate, userProfileService, document) {
233
- this.config = config;
234
- this.translate = translate;
235
- this.userProfileService = userProfileService;
236
- this.document = document;
237
- this.languages = [];
238
- this.initUserLanguage();
239
- }
240
- initUserLanguage() {
241
- this.setActiveLocale(this.getActiveLocale() || this.getDefaultLocale());
242
- }
243
- setTextOrientation(direction) {
244
- document.body.setAttribute('dir', direction);
245
- }
246
- getTextOrientation() {
247
- return document.body.getAttribute('dir');
248
- }
249
- getLanguages() {
250
- this.languages = this.config.get('languages');
251
- if (!this.languages) {
252
- this.languages = [
253
- {
254
- key: 'fr',
255
- label: 'French',
256
- direction: 'ltr',
257
- },
258
- {
259
- key: 'de',
260
- label: 'German',
261
- direction: 'ltr',
262
- },
263
- {
264
- key: 'en',
265
- label: 'English',
266
- direction: 'ltr',
267
- },
268
- {
269
- key: 'ar',
270
- label: 'Arabic',
271
- direction: 'rtl',
272
- },
273
- ];
274
- }
275
- return this.languages;
276
- }
277
- getDefaultLocale() {
278
- this.locale = this.userProfileService.getLocale();
279
- if (!this.locale) {
280
- this.locale = this.config.get('locale')
281
- ? this.config.get('locale')
282
- : this.translate.getBrowserLang()
283
- ? this.translate.getBrowserLang()
284
- : 'en';
285
- }
286
- return this.getLanguages().find((e) => e.key === this.locale);
287
- }
288
- getActiveLocale() {
289
- if (this.userProfileService.getLocale()) {
290
- return this.getLanguages().find((e) => e.key === this.userProfileService.getLocale());
291
- }
292
- }
293
- setActiveLocale(locale) {
294
- if (locale) {
295
- this.translate.use(locale.key);
296
- this.setTextOrientation(locale.direction);
297
- this.userProfileService.setLocale(locale.key);
298
- }
299
- }
300
- }
301
- LocaleService.ɵprov = i0.ɵɵdefineInjectable({ factory: function LocaleService_Factory() { return new LocaleService(i0.ɵɵinject(AppConfigService), i0.ɵɵinject(i2.TranslateService), i0.ɵɵinject(UserProfileService), i0.ɵɵinject(i4.DOCUMENT)); }, token: LocaleService, providedIn: "root" });
302
- LocaleService.decorators = [
303
- { type: Injectable, args: [{
304
- providedIn: 'root',
305
- },] }
306
- ];
307
- LocaleService.ctorParameters = () => [
308
- { type: AppConfigService },
309
- { type: TranslateService },
310
- { type: UserProfileService },
311
- { type: Document, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
312
- ];
313
-
314
- class LanguageMenuComponent {
315
- constructor(localeService) {
316
- this.localeService = localeService;
317
- this.showLocaleKeyAsLabel = false;
318
- this.showLocaleAsLabel = false;
319
- this.languages = [];
320
- }
321
- ngOnInit() {
322
- this.languages = this.localeService.getLanguages();
323
- this.localeService.setActiveLocale(this.locale);
324
- }
325
- onChangeLanguage(language) {
326
- this.localeService.setActiveLocale(language);
327
- }
328
- get locale() {
329
- return this.localeService.getActiveLocale() || this.localeService.getDefaultLocale();
330
- }
331
- }
332
- LanguageMenuComponent.decorators = [
333
- { type: Component, args: [{
334
- selector: 'mnl-language-menu',
335
- template: "<button id=\"mnl-locale-button\" mat-menu-item [matMenuTriggerFor]=\"languageMenu\">\n <ng-container *ngIf=\"showLocaleKeyAsLabel || showLocaleAsLabel; else defaultLabel\">\n <div *ngIf=\"showLocaleKeyAsLabel\">{{ locale.key | uppercase }}</div>\n <div *ngIf=\"showLocaleAsLabel\">{{ locale.label }}</div>\n </ng-container>\n <ng-template #defaultLabel>\n <mat-icon>language</mat-icon>\n {{ \"MNL.LANGUAGE-SELECTOR.LANGUAGES\" | translate }}\n </ng-template>\n</button>\n<mat-menu #languageMenu=\"matMenu\">\n <button\n mat-menu-item\n *ngFor=\"let language of languages\"\n (click)=\"onChangeLanguage(language)\"\n id=\"langMenu\"\n >\n {{ language.label }}\n </button>\n</mat-menu>\n",
336
- styles: [""]
337
- },] }
338
- ];
339
- LanguageMenuComponent.ctorParameters = () => [
340
- { type: LocaleService }
341
- ];
342
- LanguageMenuComponent.propDecorators = {
343
- showLocaleKeyAsLabel: [{ type: Input }],
344
- showLocaleAsLabel: [{ type: Input }]
345
- };
346
-
347
- class LoginComponent {
348
- constructor(sanitizer) {
349
- this.sanitizer = sanitizer;
350
- this.title = '';
351
- this.logoImageUrl = './assets/images/logo.png';
352
- this.backgroundImageUrl = './assets/images/background.jpg';
353
- this.disabled = false;
354
- this.login = new EventEmitter();
355
- }
356
- ngOnInit() {
357
- this.initForm();
358
- }
359
- initForm() {
360
- this.formGroup = new FormGroup({
361
- username: new FormControl('', [Validators.required]),
362
- password: new FormControl('', [Validators.required])
363
- });
364
- }
365
- onSubmit() {
366
- if (this.formGroup.valid) {
367
- this.login.emit(this.formGroup.value);
368
- }
369
- }
370
- getBackgroundImageUrl() {
371
- return this.sanitizer.bypassSecurityTrustStyle(`url(${this.backgroundImageUrl})`);
372
- }
373
- }
374
- LoginComponent.decorators = [
375
- { type: Component, args: [{
376
- selector: 'mnl-login',
377
- template: "<div fxLayoutAlign=\"center center\" class=\"mnl-login-container\" fxFlexFill [style.background-image]=\"getBackgroundImageUrl()\">\n <mat-card class=\"mnl-login-card\">\n <form fxLayoutAlign=\"stretch\" fxLayout=\"column\" [formGroup]=\"formGroup\" (ngSubmit)=\"onSubmit()\">\n <mat-card-header fxLayoutAlign=\"center center\">\n <mat-card-title>\n <img *ngIf=\"logoImageUrl\" src=\"{{logoImageUrl}}\">\n </mat-card-title>\n </mat-card-header>\n <h3 fxLayoutAlign=\"center center\" class=\"mnl-login-title\" *ngIf=\"title\">{{title | translate}}</h3>\n <mat-form-field fxFlex=\"100\">\n <input id=\"username\" matInput placeholder=\"{{'MNL.LOGIN.USERNAME' | translate}}\"\n formControlName=\"username\">\n </mat-form-field>\n\n <mat-form-field fxFlex=\"100\">\n <input id=\"password\" matInput type=\"password\" placeholder=\"{{'MNL.LOGIN.PASSWORD' | translate}}\"\n formControlName=\"password\">\n </mat-form-field>\n <mat-card-actions fxLayoutAlign=\"center center\">\n <button id=\"loginButton\" mat-raised-button color=\"accent\" [disabled]=\"disabled || !formGroup.valid\"\n type=\"submit\"> {{'MNL.LOGIN.LOGIN_BUTTON' | translate}}</button>\n </mat-card-actions>\n\n </form>\n </mat-card>\n</div>",
378
- styles: [".mnl-login-card{min-width:260px}.mnl-login-container{background-size:cover}.mnl-login-title{opacity:.6}"]
379
- },] }
380
- ];
381
- LoginComponent.ctorParameters = () => [
382
- { type: DomSanitizer }
383
- ];
384
- LoginComponent.propDecorators = {
385
- title: [{ type: Input }],
386
- logoImageUrl: [{ type: Input }],
387
- backgroundImageUrl: [{ type: Input }],
388
- disabled: [{ type: Input }],
389
- login: [{ type: Output }]
390
- };
391
-
392
- class MenuComponent {
393
- constructor() {
394
- this.menuClick = new EventEmitter();
395
- }
396
- onMenuClick(menu) {
397
- if (this.hasSubMenu(menu)) {
398
- this.openMenu(menu);
399
- this.onSubMenuClick(menu.subMenus[0], menu);
400
- }
401
- else {
402
- this.deSelectMenus(this.menuData);
403
- this.selectMenu(menu);
404
- this.menuClick.emit(menu);
405
- }
406
- }
407
- onSubMenuClick(subMenu, menu) {
408
- this.deSelectMenus(this.menuData);
409
- this.selectMenu(menu);
410
- this.selectMenu(subMenu);
411
- this.menuClick.emit(subMenu);
412
- }
413
- deSelectMenus(menus) {
414
- if (menus) {
415
- for (const menu of menus) {
416
- if (menu.selected) {
417
- menu.selected = false;
418
- }
419
- this.deSelectMenus(menu.subMenus);
420
- }
421
- }
422
- }
423
- selectMenu(menu) {
424
- if (menu) {
425
- menu.selected = true;
426
- }
427
- }
428
- hasSubMenu(menu) {
429
- return menu.subMenus && menu.subMenus.length > 0;
430
- }
431
- toggleMenu(menu, event) {
432
- menu.expanded = !menu.expanded;
433
- if (event) {
434
- event.stopPropagation();
435
- }
436
- }
437
- openMenu(menu) {
438
- menu.expanded = true;
439
- }
440
- }
441
- MenuComponent.decorators = [
442
- { type: Component, args: [{
443
- selector: 'mnl-menu',
444
- template: "<mat-nav-list *ngFor=\"let menu of menuData\">\n <a mat-list-item fxLayout=\"row\" (click)=\"onMenuClick(menu)\" id=\"mnl-menu-anchor\">\n <mnl-highlighter [enabled]=\"menu.selected\"></mnl-highlighter>\n <mat-icon *ngIf=\"menu.icon; else svgTemplate \">{{menu.icon}}</mat-icon>\n <ng-template #svgTemplate>\n <mat-icon svgIcon=\"{{menu.svgIcon}}\"> </mat-icon>\n </ng-template>\n <span class=\"mnl-menu\" id=\"mnl-menu\">{{menu.name | translate }}</span>\n <mat-icon class=\"mnl-menu-button\" *ngIf=\"menu.subMenus\" (click)=\"toggleMenu(menu, $event)\"\n [ngClass]=\"{'mnl-rotated' : menu.expanded}\">expand_more</mat-icon>\n </a>\n <ng-container *ngFor=\"let sub of menu.subMenus\">\n <a mat-list-item fxLayout=\"row\" class=\"mnl-submenu\" [class.mnl-expanded]=\"menu.expanded\" *ngIf=\"menu.expanded\"\n (click)=\"onSubMenuClick(sub, menu)\" fxLayout=\"row\" id=\"mnl-submenu-anchor\">\n <mnl-highlighter [enabled]=\"sub.selected\"></mnl-highlighter>\n <mat-icon>{{sub.icon}}</mat-icon>\n <span class=\"mnl-menu\" id=\"mnl-submenu\">{{sub.name | translate }}</span>\n </a>\n </ng-container>\n</mat-nav-list>",
445
- styles: [".mnl-submenu{overflow-y:hidden;transition:transform .3s ease;transform:scaleY(0);transform-origin:top;padding-left:15px!important}.mnl-submenu.mnl-expanded{transform:scaleY(1)}.mnl-menu{margin-top:5px;margin-left:10px;margin-right:10px}.mnl-menu-button{transition:.3s ease-in-out;transform:rotate(0deg);margin-top:3px;margin-left:25px}.mnl-menu-button.mnl-rotated{transform:rotate(180deg)}"]
446
- },] }
447
- ];
448
- MenuComponent.propDecorators = {
449
- menuData: [{ type: Input }],
450
- menuClick: [{ type: Output }]
451
- };
452
-
453
- class ProfileComponent {
454
- constructor() {
455
- this.showDisplayName = true;
456
- this.userInitialClick = new EventEmitter();
457
- this.profileMenuClick = new EventEmitter();
458
- }
459
- onUserInitialClick(event) {
460
- this.userInitialClick.emit(event);
461
- }
462
- ngOnChanges(changes) {
463
- if (changes && changes.userProfileDetails && changes.userProfileDetails.currentValue
464
- && changes.userProfileDetails.currentValue.firstName && changes.userProfileDetails.currentValue.lastName
465
- && changes.userProfileDetails.currentValue.email) {
466
- this.hasUserDetails = true;
467
- }
468
- else {
469
- this.hasUserDetails = false;
470
- }
471
- }
472
- }
473
- ProfileComponent.decorators = [
474
- { type: Component, args: [{
475
- selector: 'mnl-user-profile',
476
- template: "<div id=\"mnl-profile-container\" fxLayoutGap=\"10px\">\n <span\n *ngIf=\"showDisplayName && hasUserDetails\"\n id=\"mnl-userinfo-name\"\n fxHide.xs\n >{{ userProfileDetails | mnlUserFullName }}</span\n >\n <button\n *ngIf=\"hasUserDetails\"\n id=\"mnl-initials-button\"\n mat-raised-button\n (click)=\"onUserInitialClick($event)\"\n mat-icon-button\n >\n {{ userProfileDetails | mnlUserInitialPipe }}\n </button>\n\n <button\n *ngIf=\"!hasUserDetails\"\n id=\"mnl-user-icon-button\"\n mat-raised-button\n (click)=\"onUserInitialClick($event)\"\n mat-icon-button\n >\n <mat-icon>person</mat-icon>\n </button>\n</div>\n",
477
- styles: ["#mnl-initials-button{border-radius:20px}"]
478
- },] }
479
- ];
480
- ProfileComponent.propDecorators = {
481
- userProfileDetails: [{ type: Input }],
482
- showDisplayName: [{ type: Input }],
483
- userInitialClick: [{ type: Output }],
484
- profileMenuClick: [{ type: Output }]
485
- };
486
-
487
- const MNL_TRANSLATION_RESOURCE = new InjectionToken('Translation Resource');
488
- function translationLoaderFactory(http, resources) {
489
- if (!resources) {
490
- resources = [];
491
- }
492
- else if (!resources.length) {
493
- resources = [resources];
494
- }
495
- resources.push({ prefix: './assets/mnl-commons/i18n/', suffix: '.json' });
496
- return new MultiTranslateHttpLoader(http, resources);
497
- }
498
-
499
- class AppConfigPipe {
500
- constructor(config) {
501
- this.config = config;
502
- }
503
- transform(value, defaultValue) {
504
- return this.config.get(value) || defaultValue || '';
505
- }
506
- }
507
- AppConfigPipe.decorators = [
508
- { type: Pipe, args: [{
509
- name: 'mnlAppConfig'
510
- },] }
511
- ];
512
- AppConfigPipe.ctorParameters = () => [
513
- { type: AppConfigService }
514
- ];
515
-
516
- class TimeAgoPipe {
517
- constructor(appConfigService, userProfileService) {
518
- this.appConfigService = appConfigService;
519
- this.userProfileService = userProfileService;
520
- this.defaultLocale = TimeAgoPipe.DEFAULT_LOCALE;
521
- this.defaultDateTimeFormat = TimeAgoPipe.DEFAULT_DATE_TIME_FORMAT;
522
- }
523
- transform(value, dateTimeFormat, locale) {
524
- if (value) {
525
- const currentLocale = this.userProfileService.getLocale();
526
- const currentDateTimeFormat = this.appConfigService.get('dateTimeFormat');
527
- const requiredLocale = locale || currentLocale || this.defaultLocale;
528
- const requiredDateTimeFormat = dateTimeFormat || currentDateTimeFormat || this.defaultDateTimeFormat;
529
- if (differenceInDays(new Date(), new Date(value)) > 7) {
530
- const datePipe = new DatePipe(requiredLocale);
531
- return datePipe.transform(value, requiredDateTimeFormat);
532
- }
533
- return formatDistance(new Date(value), new Date(), {
534
- includeSeconds: true,
535
- addSuffix: true,
536
- });
537
- }
538
- return '';
539
- }
540
- }
541
- TimeAgoPipe.DEFAULT_LOCALE = 'en-US';
542
- TimeAgoPipe.DEFAULT_DATE_TIME_FORMAT = 'dd/MM/yyyy HH:mm';
543
- TimeAgoPipe.decorators = [
544
- { type: Pipe, args: [{
545
- name: 'mnlTimeAgo',
546
- },] }
547
- ];
548
- TimeAgoPipe.ctorParameters = () => [
549
- { type: AppConfigService },
550
- { type: UserProfileService }
551
- ];
552
-
553
- class UserFullnamePipe {
554
- transform(value) {
555
- let fullName = '';
556
- if (!this.isEmptyObject(value)) {
557
- if (value.firstName && value.lastName) {
558
- fullName = value.firstName + ' ' + value.lastName;
559
- }
560
- else if (!value.firstName && value.lastName) {
561
- fullName = value.lastName;
562
- }
563
- else if (value.firstName && !value.lastName) {
564
- fullName = value.firstName;
565
- }
566
- else if (!value.firstName && !value.lastName) {
567
- fullName = value.email;
568
- }
569
- }
570
- return fullName;
571
- }
572
- isEmptyObject(data) {
573
- return (data && (Object.keys(data).length === 0));
574
- }
575
- }
576
- UserFullnamePipe.decorators = [
577
- { type: Pipe, args: [{
578
- name: 'mnlUserFullName'
579
- },] }
580
- ];
581
-
582
- class UserInitialPipe {
583
- transform(value) {
584
- let userInitials = '';
585
- if (!this.isEmptyObject(value)) {
586
- if (value.firstName && value.lastName) {
587
- userInitials = value.firstName.substring(0, 1).toUpperCase() + value.lastName.substring(0, 1).toUpperCase();
588
- }
589
- else if (!value.firstName && value.lastName) {
590
- userInitials = this.getUserInitials(value.lastName);
591
- }
592
- else if (value.firstName && !value.lastName) {
593
- userInitials = this.getUserInitials(value.firstName);
594
- }
595
- else if (!value.firstName && !value.lastName) {
596
- userInitials = value.email.substring(0, 1).toUpperCase();
597
- }
598
- }
599
- return userInitials;
600
- }
601
- isEmptyObject(data) {
602
- return (data && (Object.keys(data).length === 0));
603
- }
604
- getUserInitials(name) {
605
- let userInitial = '';
606
- if (this.hasWhiteSpace(name.trim())) {
607
- const data = name.split(/\s+/);
608
- userInitial = data[0].substring(0, 1).toUpperCase() + data[1].substring(0, 1).toUpperCase();
609
- }
610
- else {
611
- userInitial = name.trim().substring(0, 1).toUpperCase();
612
- }
613
- return userInitial;
614
- }
615
- hasWhiteSpace(data) {
616
- return /\s/g.test(data);
617
- }
618
- }
619
- UserInitialPipe.decorators = [
620
- { type: Pipe, args: [{
621
- name: 'mnlUserInitialPipe'
622
- },] }
623
- ];
624
-
625
- class LogLevelsEnum extends Number {
626
- }
627
- LogLevelsEnum.TRACE = 5;
628
- LogLevelsEnum.DEBUG = 1;
629
- LogLevelsEnum.INFO = 2;
630
- LogLevelsEnum.WARN = 3;
631
- LogLevelsEnum.ERROR = 4;
632
- LogLevelsEnum.SILENT = 0;
633
- let logLevels = [
634
- { level: LogLevelsEnum.TRACE, name: 'TRACE' },
635
- { level: LogLevelsEnum.DEBUG, name: 'DEBUG' },
636
- { level: LogLevelsEnum.INFO, name: 'INFO' },
637
- { level: LogLevelsEnum.WARN, name: 'WARN' },
638
- { level: LogLevelsEnum.ERROR, name: 'ERROR' },
639
- { level: LogLevelsEnum.SILENT, name: 'SILENT' }
640
- ];
641
-
642
- // tslint:disable: no-console
643
- class LogService {
644
- constructor(appConfigService) {
645
- this.appConfigService = appConfigService;
646
- this.onMessage = new Subject();
647
- }
648
- get currentLogLevel() {
649
- const configLevel = this.appConfigService.get('logLevel');
650
- if (configLevel) {
651
- return this.getLogLevel(configLevel);
652
- }
653
- return LogLevelsEnum.ERROR;
654
- }
655
- error(message, ...optionalParams) {
656
- if (this.currentLogLevel >= LogLevelsEnum.ERROR) {
657
- this.messageBus(message, 'ERROR');
658
- console.error(message, ...optionalParams);
659
- }
660
- }
661
- debug(message, ...optionalParams) {
662
- if (this.currentLogLevel >= LogLevelsEnum.DEBUG) {
663
- this.messageBus(message, 'DEBUG');
664
- console.debug(message, ...optionalParams);
665
- }
666
- }
667
- info(message, ...optionalParams) {
668
- if (this.currentLogLevel >= LogLevelsEnum.INFO) {
669
- this.messageBus(message, 'INFO');
670
- console.info(message, ...optionalParams);
671
- }
672
- }
673
- log(message, ...optionalParams) {
674
- if (this.currentLogLevel >= LogLevelsEnum.TRACE) {
675
- this.messageBus(message, 'LOG');
676
- console.log(message, ...optionalParams);
677
- }
678
- }
679
- trace(message, ...optionalParams) {
680
- if (this.currentLogLevel >= LogLevelsEnum.TRACE) {
681
- this.messageBus(message, 'TRACE');
682
- console.trace(message, ...optionalParams);
683
- }
684
- }
685
- warn(message, ...optionalParams) {
686
- if (this.currentLogLevel >= LogLevelsEnum.WARN) {
687
- this.messageBus(message, 'WARN');
688
- console.warn(message, ...optionalParams);
689
- }
690
- }
691
- assert(test, message, ...optionalParams) {
692
- if (this.currentLogLevel !== LogLevelsEnum.SILENT) {
693
- this.messageBus(message, 'ASSERT');
694
- console.assert(test, message, ...optionalParams);
695
- }
696
- }
697
- group(groupTitle, ...optionalParams) {
698
- if (this.currentLogLevel !== LogLevelsEnum.SILENT) {
699
- console.group(groupTitle, ...optionalParams);
700
- }
701
- }
702
- groupEnd() {
703
- if (this.currentLogLevel !== LogLevelsEnum.SILENT) {
704
- console.groupEnd();
705
- }
706
- }
707
- getLogLevel(level) {
708
- const referencedLevel = logLevels.find((currentLevel) => {
709
- return currentLevel.name.toLocaleLowerCase() === level.toLocaleLowerCase();
710
- });
711
- return referencedLevel ? referencedLevel.level : 4;
712
- }
713
- messageBus(message, logLevel) {
714
- this.onMessage.next({ text: message, type: logLevel });
715
- }
716
- }
717
- LogService.ɵprov = i0.ɵɵdefineInjectable({ factory: function LogService_Factory() { return new LogService(i0.ɵɵinject(AppConfigService)); }, token: LogService, providedIn: "root" });
718
- LogService.decorators = [
719
- { type: Injectable, args: [{
720
- providedIn: 'root'
721
- },] }
722
- ];
723
- LogService.ctorParameters = () => [
724
- { type: AppConfigService }
725
- ];
726
-
727
- registerLocaleData(localeFR);
728
- registerLocaleData(localeDE);
729
- registerLocaleData(localeAR);
730
- const ɵ0 = translationLoaderFactory;
731
- class CommonsModule {
732
- static forRoot() {
733
- return {
734
- ngModule: CommonsModule,
735
- providers: [
736
- {
737
- provide: APP_INITIALIZER,
738
- useFactory: loadConfig,
739
- deps: [
740
- AppConfigService,
741
- UserProfileService,
742
- LocalStorageService,
743
- LogService,
744
- LocaleService,
745
- ],
746
- multi: true,
747
- },
748
- ],
749
- };
750
- }
751
- static forChild() {
752
- return {
753
- ngModule: CommonsModule,
754
- };
755
- }
756
- }
757
- CommonsModule.decorators = [
758
- { type: NgModule, args: [{
759
- declarations: [
760
- HeaderComponent,
761
- MenuComponent,
762
- HighlighterComponent,
763
- AppConfigPipe,
764
- LoginComponent,
765
- LanguageMenuComponent,
766
- ProfileComponent,
767
- UserInitialPipe,
768
- TimeAgoPipe,
769
- UserFullnamePipe,
770
- ],
771
- imports: [
772
- CommonModule,
773
- MatToolbarModule,
774
- FlexLayoutModule,
775
- MaterialModule,
776
- TranslateModule.forRoot({
777
- loader: {
778
- provide: TranslateLoader,
779
- useFactory: ɵ0,
780
- deps: [HttpClient, MNL_TRANSLATION_RESOURCE],
781
- },
782
- }),
783
- ],
784
- exports: [
785
- HeaderComponent,
786
- MenuComponent,
787
- HighlighterComponent,
788
- AppConfigPipe,
789
- LanguageMenuComponent,
790
- LoginComponent,
791
- ProfileComponent,
792
- UserInitialPipe,
793
- TimeAgoPipe,
794
- UserFullnamePipe,
795
- TranslateModule,
796
- ],
797
- },] }
798
- ];
799
- function loadConfig(config) {
800
- const conf = () => config.load();
801
- return conf;
802
- }
803
-
804
- /*
805
- * Public API Surface of mnl-commons
806
- */
807
-
808
- /**
809
- * Generated bundle index. Do not edit.
810
- */
811
-
812
- export { AppConfigPipe, AppConfigService, CommonsModule, HeaderComponent, HighlighterComponent, LanguageMenuComponent, LocalStorageService, LocaleService, LogLevelsEnum, LogService, LoginComponent, MNL_TRANSLATION_RESOURCE, MaterialModule, MenuComponent, ProfileComponent, TimeAgoPipe, UserFullnamePipe, UserInitialPipe, UserProfileService, loadConfig, logLevels, modules, translationLoaderFactory, ɵ0 };
813
- //# sourceMappingURL=muraai-mnl-commons.js.map