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