@muraai/mnl-commons 0.1.0 → 0.2.0-alpha-0441b22

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