UNPKG

113 kBJavaScriptView Raw
1import { ɵɵdefineInjectable, Injectable, ɵɵinject, Component, Input, Directive, forwardRef, EventEmitter, Output, Host, ContentChild, HostListener, ElementRef, Optional, Pipe, NgModule, SecurityContext, NgZone } from '@angular/core';
2import { faSort, faSortUp, faSortDown } from '@fortawesome/free-solid-svg-icons';
3import { NG_VALIDATORS, FormsModule } from '@angular/forms';
4import { FaIconComponent } from '@fortawesome/angular-fontawesome';
5import { TranslateService } from '@ngx-translate/core';
6import { Subject, Observable } from 'rxjs';
7import { takeUntil, share, filter, map } from 'rxjs/operators';
8import { CommonModule, DatePipe } from '@angular/common';
9import { NgbActiveModal, NgbModal, NgbModule } from '@ng-bootstrap/ng-bootstrap';
10import { TranslateHttpLoader } from '@ngx-translate/http-loader';
11import { DomSanitizer } from '@angular/platform-browser';
12
13/*
14 Copyright 2013-2020 the original author or authors from the JHipster project.
15
16 This file is part of the JHipster project, see https://www.jhipster.tech/
17 for more information.
18
19 Licensed under the Apache License, Version 2.0 (the "License");
20 you may not use this file except in compliance with the License.
21 You may obtain a copy of the License at
22
23 http://www.apache.org/licenses/LICENSE-2.0
24
25 Unless required by applicable law or agreed to in writing, software
26 distributed under the License is distributed on an "AS IS" BASIS,
27 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28 See the License for the specific language governing permissions and
29 limitations under the License.
30 */
31class JhiModuleConfig {
32 constructor() {
33 this.sortIcon = faSort;
34 this.sortAscIcon = faSortUp;
35 this.sortDescIcon = faSortDown;
36 this.i18nEnabled = false;
37 this.defaultI18nLang = 'en';
38 this.noi18nMessage = 'translation-not-found';
39 this.alertAsToast = false;
40 this.alertTimeout = 5000;
41 this.classBadgeTrue = 'badge badge-success';
42 this.classBadgeFalse = 'badge badge-danger';
43 this.classTrue = 'fa fa-lg fa-check text-success';
44 this.classFalse = 'fa fa-lg fa-times text-danger';
45 }
46}
47JhiModuleConfig.ɵprov = ɵɵdefineInjectable({ factory: function JhiModuleConfig_Factory() { return new JhiModuleConfig(); }, token: JhiModuleConfig, providedIn: "root" });
48JhiModuleConfig.decorators = [
49 { type: Injectable, args: [{
50 providedIn: 'root'
51 },] }
52];
53
54/*
55 Copyright 2013-2020 the original author or authors from the JHipster project.
56
57 This file is part of the JHipster project, see https://www.jhipster.tech/
58 for more information.
59
60 Licensed under the Apache License, Version 2.0 (the "License");
61 you may not use this file except in compliance with the License.
62 You may obtain a copy of the License at
63
64 http://www.apache.org/licenses/LICENSE-2.0
65
66 Unless required by applicable law or agreed to in writing, software
67 distributed under the License is distributed on an "AS IS" BASIS,
68 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
69 See the License for the specific language governing permissions and
70 limitations under the License.
71 */
72class JhiConfigService {
73 constructor(moduleConfig) {
74 this.CONFIG_OPTIONS = Object.assign(Object.assign({}, new JhiModuleConfig()), moduleConfig);
75 }
76 getConfig() {
77 return this.CONFIG_OPTIONS;
78 }
79}
80JhiConfigService.ɵprov = ɵɵdefineInjectable({ factory: function JhiConfigService_Factory() { return new JhiConfigService(ɵɵinject(JhiModuleConfig)); }, token: JhiConfigService, providedIn: "root" });
81JhiConfigService.decorators = [
82 { type: Injectable, args: [{
83 providedIn: 'root'
84 },] }
85];
86JhiConfigService.ctorParameters = () => [
87 { type: JhiModuleConfig }
88];
89
90/*
91 Copyright 2013-2020 the original author or authors from the JHipster project.
92
93 This file is part of the JHipster project, see https://www.jhipster.tech/
94 for more information.
95
96 Licensed under the Apache License, Version 2.0 (the "License");
97 you may not use this file except in compliance with the License.
98 You may obtain a copy of the License at
99
100 http://www.apache.org/licenses/LICENSE-2.0
101
102 Unless required by applicable law or agreed to in writing, software
103 distributed under the License is distributed on an "AS IS" BASIS,
104 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
105 See the License for the specific language governing permissions and
106 limitations under the License.
107 */
108/**
109 * A component that will take care of item count statistics of a pagination.
110 */
111class JhiItemCountComponent {
112 constructor(config) {
113 this.i18nEnabled = config.CONFIG_OPTIONS.i18nEnabled;
114 }
115 /**
116 * "translate-values" JSON of the template
117 */
118 i18nValues() {
119 const first = (this.page - 1) * this.itemsPerPage === 0 ? 1 : (this.page - 1) * this.itemsPerPage + 1;
120 const second = this.page * this.itemsPerPage < this.total ? this.page * this.itemsPerPage : this.total;
121 return {
122 first,
123 second,
124 total: this.total
125 };
126 }
127}
128JhiItemCountComponent.decorators = [
129 { type: Component, args: [{
130 selector: 'jhi-item-count',
131 template: `
132 <div *ngIf="i18nEnabled; else noI18n" class="info jhi-item-count" jhiTranslate="global.item-count" [translateValues]="i18nValues()">
133 /* [attr.translateValues] is used to get entire values in tests */
134 </div>
135 <ng-template #noI18n class="info jhi-item-count">
136 Showing
137 {{ (page - 1) * itemsPerPage == 0 ? 1 : (page - 1) * itemsPerPage + 1 }}
138 - {{ page * itemsPerPage < total ? page * itemsPerPage : total }} of {{ total }} items.
139 </ng-template>
140 `
141 },] }
142];
143JhiItemCountComponent.ctorParameters = () => [
144 { type: JhiConfigService }
145];
146JhiItemCountComponent.propDecorators = {
147 page: [{ type: Input }],
148 total: [{ type: Input }],
149 itemsPerPage: [{ type: Input }]
150};
151
152/*
153 Copyright 2013-2020 the original author or authors from the JHipster project.
154
155 This file is part of the JHipster project, see https://www.jhipster.tech/
156 for more information.
157
158 Licensed under the Apache License, Version 2.0 (the "License");
159 you may not use this file except in compliance with the License.
160 You may obtain a copy of the License at
161
162 http://www.apache.org/licenses/LICENSE-2.0
163
164 Unless required by applicable law or agreed to in writing, software
165 distributed under the License is distributed on an "AS IS" BASIS,
166 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
167 See the License for the specific language governing permissions and
168 limitations under the License.
169 */
170/**
171 * This component can be used to display a boolean value by defining the @Input attributes
172 * If an attribute is not provided, default values will be applied (see JhiModuleConfig class)
173 * Have a look at the following examples
174 *
175 * * * * * * * * * * * * * * * * * * * * * * * * * * * *
176 *
177 * <jhi-boolean [value]="inputBooleanVariable"></jhi-boolean>
178 *
179 * - Display a green check when inputBooleanVariable is true
180 * - Display a red cross when inputBooleanVariable is false
181 *
182 * * * * * * * * * * * * * * * * * * * * * * * * * * * *
183 *
184 * <jhi-boolean
185 * [value]="inputBooleanVariable">
186 * classTrue="fa fa-lg fa-check text-primary"
187 * classFalse="fa fa-lg fa-times text-warning"
188 * </jhi-boolean>
189 *
190 * - Display a blue check when inputBooleanVariable is true
191 * - Display an orange cross when inputBooleanVariable is false
192 *
193 * * * * * * * * * * * * * * * * * * * * * * * * * * * *
194 *
195 * <jhi-boolean
196 * [value]="inputBooleanVariable">
197 * classTrue="fa fa-lg fa-check"
198 * classFalse=""
199 * </jhi-boolean>
200 *
201 * - Display a black check when inputBooleanVariable is true
202 * - Do not display anything when inputBooleanVariable is false
203 *
204 * * * * * * * * * * * * * * * * * * * * * * * * * * * *
205 *
206 * <jhi-boolean
207 * [value]="inputBooleanVariable"
208 * [textTrue]="'userManagement.activated' | translate"
209 * textFalse="deactivated">
210 * </jhi-boolean>
211 *
212 * - Display a green badge when inputBooleanVariable is true
213 * - Display a red badge when inputBooleanVariable is false
214 *
215 * * * * * * * * * * * * * * * * * * * * * * * * * * * *
216 *
217 * <jhi-boolean
218 * [value]="user.activated"
219 * classTrue="badge badge-warning"
220 * classFalse="badge badge-info"
221 * [textTrue]="'userManagement.activated' | translate"
222 * textFalse="deactivated">
223 * </jhi-boolean>
224 *
225 * - Display an orange badge and write 'activated' when inputBooleanVariable is true
226 * - Display a blue badge and write 'deactivated' when inputBooleanVariable is false
227 */
228class JhiBooleanComponent {
229 constructor(configService) {
230 this.config = configService.getConfig();
231 }
232 ngOnInit() {
233 if (this.textTrue === undefined) {
234 if (this.classTrue === undefined) {
235 this.classTrue = this.config.classTrue;
236 }
237 }
238 else {
239 if (this.classTrue === undefined) {
240 this.classTrue = this.config.classBadgeTrue;
241 }
242 }
243 if (this.textFalse === undefined) {
244 if (this.classFalse === undefined) {
245 this.classFalse = this.config.classFalse;
246 }
247 }
248 else {
249 if (this.classFalse === undefined) {
250 this.classFalse = this.config.classBadgeFalse;
251 }
252 }
253 }
254}
255JhiBooleanComponent.decorators = [
256 { type: Component, args: [{
257 selector: 'jhi-boolean',
258 template: `
259 <span [ngClass]="value ? classTrue : classFalse" [innerHtml]="value ? textTrue : textFalse"> </span>
260 `
261 },] }
262];
263JhiBooleanComponent.ctorParameters = () => [
264 { type: JhiConfigService }
265];
266JhiBooleanComponent.propDecorators = {
267 value: [{ type: Input }],
268 classTrue: [{ type: Input }],
269 classFalse: [{ type: Input }],
270 textTrue: [{ type: Input }],
271 textFalse: [{ type: Input }]
272};
273
274/*
275 Copyright 2013-2020 the original author or authors from the JHipster project.
276
277 This file is part of the JHipster project, see https://www.jhipster.tech/
278 for more information.
279
280 Licensed under the Apache License, Version 2.0 (the "License");
281 you may not use this file except in compliance with the License.
282 You may obtain a copy of the License at
283
284 http://www.apache.org/licenses/LICENSE-2.0
285
286 Unless required by applicable law or agreed to in writing, software
287 distributed under the License is distributed on an "AS IS" BASIS,
288 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
289 See the License for the specific language governing permissions and
290 limitations under the License.
291 */
292
293/*
294 Copyright 2013-2020 the original author or authors from the JHipster project.
295
296 This file is part of the JHipster project, see https://www.jhipster.tech/
297 for more information.
298
299 Licensed under the Apache License, Version 2.0 (the "License");
300 you may not use this file except in compliance with the License.
301 You may obtain a copy of the License at
302
303 http://www.apache.org/licenses/LICENSE-2.0
304
305 Unless required by applicable law or agreed to in writing, software
306 distributed under the License is distributed on an "AS IS" BASIS,
307 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
308 See the License for the specific language governing permissions and
309 limitations under the License.
310 */
311function numberOfBytes(base64String) {
312 function endsWith(suffix, str) {
313 return str.includes(suffix, str.length - suffix.length);
314 }
315 function paddingSize(value) {
316 if (endsWith('==', value)) {
317 return 2;
318 }
319 if (endsWith('=', value)) {
320 return 1;
321 }
322 return 0;
323 }
324 return (base64String.length / 4) * 3 - paddingSize(base64String);
325}
326
327/*
328 Copyright 2013-2020 the original author or authors from the JHipster project.
329
330 This file is part of the JHipster project, see https://www.jhipster.tech/
331 for more information.
332
333 Licensed under the Apache License, Version 2.0 (the "License");
334 you may not use this file except in compliance with the License.
335 You may obtain a copy of the License at
336
337 http://www.apache.org/licenses/LICENSE-2.0
338
339 Unless required by applicable law or agreed to in writing, software
340 distributed under the License is distributed on an "AS IS" BASIS,
341 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
342 See the License for the specific language governing permissions and
343 limitations under the License.
344 */
345class JhiMaxbytesValidatorDirective {
346 constructor() { }
347 validate(c) {
348 return c.value && numberOfBytes(c.value) > this.jhiMaxbytes
349 ? {
350 maxbytes: {
351 valid: false
352 }
353 }
354 : null;
355 }
356}
357JhiMaxbytesValidatorDirective.decorators = [
358 { type: Directive, args: [{
359 selector: '[jhiMaxbytes][ngModel]',
360 // eslint-disable-next-line @typescript-eslint/no-use-before-define
361 providers: [{ provide: NG_VALIDATORS, useExisting: forwardRef(() => JhiMaxbytesValidatorDirective), multi: true }]
362 },] }
363];
364JhiMaxbytesValidatorDirective.ctorParameters = () => [];
365JhiMaxbytesValidatorDirective.propDecorators = {
366 jhiMaxbytes: [{ type: Input }]
367};
368
369/*
370 Copyright 2013-2020 the original author or authors from the JHipster project.
371
372 This file is part of the JHipster project, see https://www.jhipster.tech/
373 for more information.
374
375 Licensed under the Apache License, Version 2.0 (the "License");
376 you may not use this file except in compliance with the License.
377 You may obtain a copy of the License at
378
379 http://www.apache.org/licenses/LICENSE-2.0
380
381 Unless required by applicable law or agreed to in writing, software
382 distributed under the License is distributed on an "AS IS" BASIS,
383 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
384 See the License for the specific language governing permissions and
385 limitations under the License.
386 */
387class JhiMinbytesValidatorDirective {
388 constructor() { }
389 validate(c) {
390 return c.value && numberOfBytes(c.value) < this.jhiMinbytes
391 ? {
392 minbytes: {
393 valid: false
394 }
395 }
396 : null;
397 }
398}
399JhiMinbytesValidatorDirective.decorators = [
400 { type: Directive, args: [{
401 selector: '[jhiMinbytes][ngModel]',
402 // eslint-disable-next-line @typescript-eslint/no-use-before-define
403 providers: [{ provide: NG_VALIDATORS, useExisting: forwardRef(() => JhiMinbytesValidatorDirective), multi: true }]
404 },] }
405];
406JhiMinbytesValidatorDirective.ctorParameters = () => [];
407JhiMinbytesValidatorDirective.propDecorators = {
408 jhiMinbytes: [{ type: Input }]
409};
410
411/*
412 Copyright 2013-Present the original author or authors from the JHipster project.
413
414 This file is part of the JHipster project, see https://www.jhipster.tech/
415 for more information.
416
417 Licensed under the Apache License, Version 2.0 (the "License");
418 you may not use this file except in compliance with the License.
419 You may obtain a copy of the License at
420
421 http://www.apache.org/licenses/LICENSE-2.0
422
423 Unless required by applicable law or agreed to in writing, software
424 distributed under the License is distributed on an "AS IS" BASIS,
425 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
426 See the License for the specific language governing permissions and
427 limitations under the License.
428 */
429class JhiMaxValidatorDirective {
430 constructor() { }
431 validate(c) {
432 return c.value === undefined || c.value === null || c.value <= this.jhiMax
433 ? null
434 : {
435 max: {
436 valid: false
437 }
438 };
439 }
440}
441JhiMaxValidatorDirective.decorators = [
442 { type: Directive, args: [{
443 selector: '[jhiMax][ngModel]',
444 // eslint-disable-next-line @typescript-eslint/no-use-before-define
445 providers: [{ provide: NG_VALIDATORS, useExisting: forwardRef(() => JhiMaxValidatorDirective), multi: true }]
446 },] }
447];
448JhiMaxValidatorDirective.ctorParameters = () => [];
449JhiMaxValidatorDirective.propDecorators = {
450 jhiMax: [{ type: Input }]
451};
452
453/*
454 Copyright 2013-Present the original author or authors from the JHipster project.
455
456 This file is part of the JHipster project, see https://www.jhipster.tech/
457 for more information.
458
459 Licensed under the Apache License, Version 2.0 (the "License");
460 you may not use this file except in compliance with the License.
461 You may obtain a copy of the License at
462
463 http://www.apache.org/licenses/LICENSE-2.0
464
465 Unless required by applicable law or agreed to in writing, software
466 distributed under the License is distributed on an "AS IS" BASIS,
467 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
468 See the License for the specific language governing permissions and
469 limitations under the License.
470 */
471class JhiMinValidatorDirective {
472 constructor() { }
473 validate(c) {
474 return c.value === undefined || c.value === null || c.value >= this.jhiMin
475 ? null
476 : {
477 min: {
478 valid: false
479 }
480 };
481 }
482}
483JhiMinValidatorDirective.decorators = [
484 { type: Directive, args: [{
485 selector: '[jhiMin][ngModel]',
486 // eslint-disable-next-line @typescript-eslint/no-use-before-define
487 providers: [{ provide: NG_VALIDATORS, useExisting: forwardRef(() => JhiMinValidatorDirective), multi: true }]
488 },] }
489];
490JhiMinValidatorDirective.ctorParameters = () => [];
491JhiMinValidatorDirective.propDecorators = {
492 jhiMin: [{ type: Input }]
493};
494
495/*
496 Copyright 2013-2020 the original author or authors from the JHipster project.
497
498 This file is part of the JHipster project, see https://www.jhipster.tech/
499 for more information.
500
501 Licensed under the Apache License, Version 2.0 (the "License");
502 you may not use this file except in compliance with the License.
503 You may obtain a copy of the License at
504
505 http://www.apache.org/licenses/LICENSE-2.0
506
507 Unless required by applicable law or agreed to in writing, software
508 distributed under the License is distributed on an "AS IS" BASIS,
509 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
510 See the License for the specific language governing permissions and
511 limitations under the License.
512 */
513class JhiSortDirective {
514 constructor() {
515 this.predicateChange = new EventEmitter();
516 this.ascendingChange = new EventEmitter();
517 }
518 sort(field) {
519 this.ascending = field !== this.predicate ? true : !this.ascending;
520 this.predicate = field;
521 this.predicateChange.emit(field);
522 this.ascendingChange.emit(this.ascending);
523 this.callback();
524 }
525}
526JhiSortDirective.decorators = [
527 { type: Directive, args: [{
528 selector: '[jhiSort]'
529 },] }
530];
531JhiSortDirective.ctorParameters = () => [];
532JhiSortDirective.propDecorators = {
533 predicate: [{ type: Input }],
534 ascending: [{ type: Input }],
535 callback: [{ type: Input }],
536 predicateChange: [{ type: Output }],
537 ascendingChange: [{ type: Output }]
538};
539
540/*
541 Copyright 2013-2020 the original author or authors from the JHipster project.
542
543 This file is part of the JHipster project, see https://www.jhipster.tech/
544 for more information.
545
546 Licensed under the Apache License, Version 2.0 (the "License");
547 you may not use this file except in compliance with the License.
548 You may obtain a copy of the License at
549
550 http://www.apache.org/licenses/LICENSE-2.0
551
552 Unless required by applicable law or agreed to in writing, software
553 distributed under the License is distributed on an "AS IS" BASIS,
554 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
555 See the License for the specific language governing permissions and
556 limitations under the License.
557 */
558class JhiSortByDirective {
559 constructor(jhiSort, configService) {
560 this.jhiSort = jhiSort;
561 this.jhiSort = jhiSort;
562 const config = configService.getConfig();
563 this.sortIcon = config.sortIcon;
564 this.sortAscIcon = config.sortAscIcon;
565 this.sortDescIcon = config.sortDescIcon;
566 }
567 ngAfterContentInit() {
568 if (this.jhiSort.predicate && this.jhiSort.predicate !== '_score' && this.jhiSort.predicate === this.jhiSortBy) {
569 this.updateIconDefinition(this.iconComponent, this.jhiSort.ascending ? this.sortAscIcon : this.sortDescIcon);
570 this.jhiSort.activeIconComponent = this.iconComponent;
571 }
572 }
573 onClick() {
574 if (this.jhiSort.predicate && this.jhiSort.predicate !== '_score') {
575 this.jhiSort.sort(this.jhiSortBy);
576 this.updateIconDefinition(this.jhiSort.activeIconComponent, this.sortIcon);
577 this.updateIconDefinition(this.iconComponent, this.jhiSort.ascending ? this.sortAscIcon : this.sortDescIcon);
578 this.jhiSort.activeIconComponent = this.iconComponent;
579 }
580 }
581 updateIconDefinition(iconComponent, icon) {
582 if (iconComponent) {
583 iconComponent.icon = icon.iconName;
584 iconComponent.render();
585 }
586 }
587}
588JhiSortByDirective.decorators = [
589 { type: Directive, args: [{
590 selector: '[jhiSortBy]'
591 },] }
592];
593JhiSortByDirective.ctorParameters = () => [
594 { type: JhiSortDirective, decorators: [{ type: Host }] },
595 { type: JhiConfigService }
596];
597JhiSortByDirective.propDecorators = {
598 jhiSortBy: [{ type: Input }],
599 iconComponent: [{ type: ContentChild, args: [FaIconComponent, { static: true },] }],
600 onClick: [{ type: HostListener, args: ['click',] }]
601};
602
603/*
604 Copyright 2013-2020 the original author or authors from the JHipster project.
605
606 This file is part of the JHipster project, see https://www.jhipster.tech/
607 for more information.
608
609 Licensed under the Apache License, Version 2.0 (the "License");
610 you may not use this file except in compliance with the License.
611 You may obtain a copy of the License at
612
613 http://www.apache.org/licenses/LICENSE-2.0
614
615 Unless required by applicable law or agreed to in writing, software
616 distributed under the License is distributed on an "AS IS" BASIS,
617 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
618 See the License for the specific language governing permissions and
619 limitations under the License.
620 */
621
622/*
623 Copyright 2013-2020 the original author or authors from the JHipster project.
624
625 This file is part of the JHipster project, see https://www.jhipster.tech/
626 for more information.
627
628 Licensed under the Apache License, Version 2.0 (the "License");
629 you may not use this file except in compliance with the License.
630 You may obtain a copy of the License at
631
632 http://www.apache.org/licenses/LICENSE-2.0
633
634 Unless required by applicable law or agreed to in writing, software
635 distributed under the License is distributed on an "AS IS" BASIS,
636 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
637 See the License for the specific language governing permissions and
638 limitations under the License.
639 */
640class JhiLanguageService {
641 constructor(translateService, configService) {
642 this.translateService = translateService;
643 this.configService = configService;
644 this.currentLang = 'en';
645 }
646 init() {
647 const config = this.configService.getConfig();
648 this.currentLang = config.defaultI18nLang;
649 this.translateService.setDefaultLang(this.currentLang);
650 this.translateService.use(this.currentLang);
651 }
652 changeLanguage(languageKey) {
653 this.currentLang = languageKey;
654 this.configService.CONFIG_OPTIONS.defaultI18nLang = languageKey;
655 this.translateService.use(this.currentLang);
656 }
657 /**
658 * @deprecated Will be removed when releasing generator-jhipster v7
659 */
660 getCurrent() {
661 return Promise.resolve(this.currentLang);
662 }
663 getCurrentLanguage() {
664 return this.currentLang;
665 }
666}
667JhiLanguageService.ɵprov = ɵɵdefineInjectable({ factory: function JhiLanguageService_Factory() { return new JhiLanguageService(ɵɵinject(TranslateService), ɵɵinject(JhiConfigService)); }, token: JhiLanguageService, providedIn: "root" });
668JhiLanguageService.decorators = [
669 { type: Injectable, args: [{
670 providedIn: 'root'
671 },] }
672];
673JhiLanguageService.ctorParameters = () => [
674 { type: TranslateService },
675 { type: JhiConfigService }
676];
677
678/*
679 Copyright 2013-2020 the original author or authors from the JHipster project.
680
681 This file is part of the JHipster project, see https://www.jhipster.tech/
682 for more information.
683
684 Licensed under the Apache License, Version 2.0 (the "License");
685 you may not use this file except in compliance with the License.
686 You may obtain a copy of the License at
687
688 http://www.apache.org/licenses/LICENSE-2.0
689
690 Unless required by applicable law or agreed to in writing, software
691 distributed under the License is distributed on an "AS IS" BASIS,
692 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
693 See the License for the specific language governing permissions and
694 limitations under the License.
695 */
696/**
697 * A wrapper directive on top of the translate pipe as the inbuilt translate directive from ngx-translate is too verbose and buggy
698 */
699class JhiTranslateDirective {
700 constructor(configService, el, translateService) {
701 this.configService = configService;
702 this.el = el;
703 this.translateService = translateService;
704 this.directiveDestroyed = new Subject();
705 }
706 ngOnInit() {
707 const enabled = this.configService.getConfig().i18nEnabled;
708 if (enabled) {
709 this.translateService.onLangChange.pipe(takeUntil(this.directiveDestroyed)).subscribe(() => {
710 this.getTranslation();
711 });
712 }
713 }
714 ngOnChanges() {
715 const enabled = this.configService.getConfig().i18nEnabled;
716 if (enabled) {
717 this.getTranslation();
718 }
719 }
720 ngOnDestroy() {
721 this.directiveDestroyed.next();
722 this.directiveDestroyed.complete();
723 }
724 getTranslation() {
725 this.translateService
726 .get(this.jhiTranslate, this.translateValues)
727 .pipe(takeUntil(this.directiveDestroyed))
728 .subscribe(value => {
729 this.el.nativeElement.innerHTML = value;
730 }, () => {
731 return `${this.configService.getConfig().noi18nMessage}[${this.jhiTranslate}]`;
732 });
733 }
734}
735JhiTranslateDirective.decorators = [
736 { type: Directive, args: [{
737 selector: '[jhiTranslate]'
738 },] }
739];
740JhiTranslateDirective.ctorParameters = () => [
741 { type: JhiConfigService },
742 { type: ElementRef },
743 { type: TranslateService, decorators: [{ type: Optional }] }
744];
745JhiTranslateDirective.propDecorators = {
746 jhiTranslate: [{ type: Input }],
747 translateValues: [{ type: Input }]
748};
749
750class JhiMissingTranslationHandler {
751 constructor(configService) {
752 this.configService = configService;
753 }
754 handle(params) {
755 const key = params.key;
756 return `${this.configService.getConfig().noi18nMessage}[${key}]`;
757 }
758}
759
760/*
761 Copyright 2013-2020 the original author or authors from the JHipster project.
762
763 This file is part of the JHipster project, see https://www.jhipster.tech/
764 for more information.
765
766 Licensed under the Apache License, Version 2.0 (the "License");
767 you may not use this file except in compliance with the License.
768 You may obtain a copy of the License at
769
770 http://www.apache.org/licenses/LICENSE-2.0
771
772 Unless required by applicable law or agreed to in writing, software
773 distributed under the License is distributed on an "AS IS" BASIS,
774 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
775 See the License for the specific language governing permissions and
776 limitations under the License.
777 */
778
779/*
780 Copyright 2013-2020 the original author or authors from the JHipster project.
781
782 This file is part of the JHipster project, see https://www.jhipster.tech/
783 for more information.
784
785 Licensed under the Apache License, Version 2.0 (the "License");
786 you may not use this file except in compliance with the License.
787 You may obtain a copy of the License at
788
789 http://www.apache.org/licenses/LICENSE-2.0
790
791 Unless required by applicable law or agreed to in writing, software
792 distributed under the License is distributed on an "AS IS" BASIS,
793 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
794 See the License for the specific language governing permissions and
795 limitations under the License.
796 */
797class JhiThreadModalComponent {
798 constructor(activeModal) {
799 this.activeModal = activeModal;
800 this.threadDumpAll = 0;
801 this.threadDumpBlocked = 0;
802 this.threadDumpRunnable = 0;
803 this.threadDumpTimedWaiting = 0;
804 this.threadDumpWaiting = 0;
805 }
806 ngOnInit() {
807 this.threadDump.forEach(value => {
808 if (value.threadState === 'RUNNABLE') {
809 this.threadDumpRunnable += 1;
810 }
811 else if (value.threadState === 'WAITING') {
812 this.threadDumpWaiting += 1;
813 }
814 else if (value.threadState === 'TIMED_WAITING') {
815 this.threadDumpTimedWaiting += 1;
816 }
817 else if (value.threadState === 'BLOCKED') {
818 this.threadDumpBlocked += 1;
819 }
820 });
821 this.threadDumpAll = this.threadDumpRunnable + this.threadDumpWaiting + this.threadDumpTimedWaiting + this.threadDumpBlocked;
822 }
823 getBadgeClass(threadState) {
824 if (threadState === 'RUNNABLE') {
825 return 'badge-success';
826 }
827 else if (threadState === 'WAITING') {
828 return 'badge-info';
829 }
830 else if (threadState === 'TIMED_WAITING') {
831 return 'badge-warning';
832 }
833 else if (threadState === 'BLOCKED') {
834 return 'badge-danger';
835 }
836 }
837}
838JhiThreadModalComponent.decorators = [
839 { type: Component, args: [{
840 selector: 'jhi-thread-modal',
841 template: `
842 <div class="modal-header">
843 <h4 class="modal-title" jhiTranslate="metrics.jvm.threads.dump.title">Threads dump</h4>
844 <button type="button" class="close" (click)="activeModal.dismiss('closed')">&times;</button>
845 </div>
846 <div class="modal-body">
847 <span class="badge badge-primary" (click)="threadDumpFilter = {}">
848 All&nbsp;<span class="badge badge-pill badge-default">{{ threadDumpAll }}</span> </span
849 >&nbsp;
850 <span class="badge badge-success" (click)="threadDumpFilter = { threadState: 'RUNNABLE' }">
851 Runnable&nbsp;<span class="badge badge-pill badge-default">{{ threadDumpRunnable }}</span> </span
852 >&nbsp;
853 <span class="badge badge-info" (click)="threadDumpFilter = { threadState: 'WAITING' }"
854 >Waiting&nbsp;<span class="badge badge-pill badge-default">{{ threadDumpWaiting }}</span></span
855 >&nbsp;
856 <span class="badge badge-warning" (click)="threadDumpFilter = { threadState: 'TIMED_WAITING' }">
857 Timed Waiting&nbsp;<span class="badge badge-pill badge-default">{{ threadDumpTimedWaiting }}</span> </span
858 >&nbsp;
859 <span class="badge badge-danger" (click)="threadDumpFilter = { threadState: 'BLOCKED' }"
860 >Blocked&nbsp;<span class="badge badge-pill badge-default">{{ threadDumpBlocked }}</span></span
861 >&nbsp;
862 <div class="mt-2">&nbsp;</div>
863 Filter
864 <input type="text" [(ngModel)]="threadDumpFilter" class="form-control" />
865 <div class="pad" *ngFor="let entry of (threadDump | pureFilter: threadDumpFilter:'lockName' | keys)">
866 <h6>
867 <span class="badge" [ngClass]="getBadgeClass(entry.value.threadState)">{{ entry.value.threadState }}</span
868 >&nbsp;{{ entry.value.threadName }}
869 (ID
870 {{ entry.value.threadId }})
871 <a (click)="entry.show = !entry.show" href="javascript:void(0);">
872 <span [hidden]="entry.show" jhiTranslate="metrics.jvm.threads.dump.show">Show StackTrace</span>
873 <span [hidden]="!entry.show" jhiTranslate="metrics.jvm.threads.dump.hide">Hide StackTrace</span>
874 </a>
875 </h6>
876 <div class="card" [hidden]="!entry.show">
877 <div class="card-body">
878 <div *ngFor="let st of (entry.value.stackTrace | keys)" class="break">
879 <samp
880 >{{ st.value.className }}.{{ st.value.methodName }}(<code
881 >{{ st.value.fileName }}:{{ st.value.lineNumber }}</code
882 >)</samp
883 >
884 <span class="mt-1"></span>
885 </div>
886 </div>
887 </div>
888 <table class="table table-sm table-responsive">
889 <thead>
890 <tr>
891 <th jhiTranslate="metrics.jvm.threads.dump.blockedtime">Blocked Time</th>
892 <th jhiTranslate="metrics.jvm.threads.dump.blockedcount">Blocked Count</th>
893 <th jhiTranslate="metrics.jvm.threads.dump.waitedtime">Waited Time</th>
894 <th jhiTranslate="metrics.jvm.threads.dump.waitedcount">Waited Count</th>
895 <th jhiTranslate="metrics.jvm.threads.dump.lockname">Lock Name</th>
896 </tr>
897 </thead>
898 <tbody>
899 <tr>
900 <td>{{ entry.value.blockedTime }}</td>
901 <td>{{ entry.value.blockedCount }}</td>
902 <td>{{ entry.value.waitedTime }}</td>
903 <td>{{ entry.value.waitedCount }}</td>
904 <td class="thread-dump-modal-lock" title="{{ entry.value.lockName }}">
905 <code>{{ entry.value.lockName }}</code>
906 </td>
907 </tr>
908 </tbody>
909 </table>
910 </div>
911 </div>
912 <div class="modal-footer">
913 <button type="button" class="btn btn-secondary float-left" data-dismiss="modal" (click)="activeModal.dismiss('closed')">
914 Done
915 </button>
916 </div>
917 `
918 },] }
919];
920JhiThreadModalComponent.ctorParameters = () => [
921 { type: NgbActiveModal }
922];
923
924/*
925 Copyright 2013-2020 the original author or authors from the JHipster project.
926
927 This file is part of the JHipster project, see https://www.jhipster.tech/
928 for more information.
929
930 Licensed under the Apache License, Version 2.0 (the "License");
931 you may not use this file except in compliance with the License.
932 You may obtain a copy of the License at
933
934 http://www.apache.org/licenses/LICENSE-2.0
935
936 Unless required by applicable law or agreed to in writing, software
937 distributed under the License is distributed on an "AS IS" BASIS,
938 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
939 See the License for the specific language governing permissions and
940 limitations under the License.
941 */
942class JhiJvmMemoryComponent {
943}
944JhiJvmMemoryComponent.decorators = [
945 { type: Component, args: [{
946 selector: 'jhi-jvm-memory',
947 template: `
948 <h4 jhiTranslate="metrics.jvm.memory.title">Memory</h4>
949 <div *ngIf="!updating">
950 <div *ngFor="let entry of (jvmMemoryMetrics | keys)">
951 <span *ngIf="entry.value.max != -1; else other">
952 <span>{{ entry.key }}</span> ({{ entry.value.used / 1048576 | number: '1.0-0' }}M /
953 {{ entry.value.max / 1048576 | number: '1.0-0' }}M)
954 </span>
955 <div>Committed : {{ entry.value.committed / 1048576 | number: '1.0-0' }}M</div>
956 <ng-template #other
957 ><span
958 ><span>{{ entry.key }}</span> {{ entry.value.used / 1048576 | number: '1.0-0' }}M</span
959 >
960 </ng-template>
961 <ngb-progressbar
962 *ngIf="entry.value.max != -1"
963 type="success"
964 [value]="(100 * entry.value.used) / entry.value.max"
965 [striped]="true"
966 [animated]="false"
967 >
968 <span>{{ (entry.value.used * 100) / entry.value.max | number: '1.0-0' }}%</span>
969 </ngb-progressbar>
970 </div>
971 </div>
972 `
973 },] }
974];
975JhiJvmMemoryComponent.propDecorators = {
976 jvmMemoryMetrics: [{ type: Input }],
977 updating: [{ type: Input }]
978};
979
980/*
981 Copyright 2013-2020 the original author or authors from the JHipster project.
982
983 This file is part of the JHipster project, see https://www.jhipster.tech/
984 for more information.
985
986 Licensed under the Apache License, Version 2.0 (the "License");
987 you may not use this file except in compliance with the License.
988 You may obtain a copy of the License at
989
990 http://www.apache.org/licenses/LICENSE-2.0
991
992 Unless required by applicable law or agreed to in writing, software
993 distributed under the License is distributed on an "AS IS" BASIS,
994 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
995 See the License for the specific language governing permissions and
996 limitations under the License.
997 */
998class JhiJvmThreadsComponent {
999 constructor(modalService) {
1000 this.modalService = modalService;
1001 }
1002 ngOnInit() {
1003 this.threadStats = {
1004 threadDumpRunnable: 0,
1005 threadDumpWaiting: 0,
1006 threadDumpTimedWaiting: 0,
1007 threadDumpBlocked: 0,
1008 threadDumpAll: 0
1009 };
1010 this.threadData.forEach(value => {
1011 if (value.threadState === 'RUNNABLE') {
1012 this.threadStats.threadDumpRunnable += 1;
1013 }
1014 else if (value.threadState === 'WAITING') {
1015 this.threadStats.threadDumpWaiting += 1;
1016 }
1017 else if (value.threadState === 'TIMED_WAITING') {
1018 this.threadStats.threadDumpTimedWaiting += 1;
1019 }
1020 else if (value.threadState === 'BLOCKED') {
1021 this.threadStats.threadDumpBlocked += 1;
1022 }
1023 });
1024 this.threadStats.threadDumpAll =
1025 this.threadStats.threadDumpRunnable +
1026 this.threadStats.threadDumpWaiting +
1027 this.threadStats.threadDumpTimedWaiting +
1028 this.threadStats.threadDumpBlocked;
1029 }
1030 open() {
1031 const modalRef = this.modalService.open(JhiThreadModalComponent);
1032 modalRef.componentInstance.threadDump = this.threadData;
1033 }
1034}
1035JhiJvmThreadsComponent.decorators = [
1036 { type: Component, args: [{
1037 selector: 'jhi-jvm-threads',
1038 template: `
1039 <h4 jhiTranslate="metrics.jvm.threads.title">Threads</h4>
1040 <span><span jhiTranslate="metrics.jvm.threads.runnable">Runnable</span> {{ threadStats.threadDumpRunnable }}</span>
1041 <ngb-progressbar
1042 [value]="threadStats.threadDumpRunnable"
1043 [max]="threadStats.threadDumpAll"
1044 [striped]="true"
1045 [animated]="false"
1046 type="success"
1047 >
1048 <span>{{ (threadStats.threadDumpRunnable * 100) / threadStats.threadDumpAll | number: '1.0-0' }}%</span>
1049 </ngb-progressbar>
1050 <span><span jhiTranslate="metrics.jvm.threads.timedwaiting">Timed Waiting</span> ({{ threadStats.threadDumpTimedWaiting }})</span>
1051 <ngb-progressbar
1052 [value]="threadStats.threadDumpTimedWaiting"
1053 [max]="threadStats.threadDumpAll"
1054 [striped]="true"
1055 [animated]="false"
1056 type="warning"
1057 >
1058 <span>{{ (threadStats.threadDumpTimedWaiting * 100) / threadStats.threadDumpAll | number: '1.0-0' }}%</span>
1059 </ngb-progressbar>
1060 <span><span jhiTranslate="metrics.jvm.threads.waiting">Waiting</span> ({{ threadStats.threadDumpWaiting }})</span>
1061 <ngb-progressbar
1062 [value]="threadStats.threadDumpWaiting"
1063 [max]="threadStats.threadDumpAll"
1064 [striped]="true"
1065 [animated]="false"
1066 type="warning"
1067 >
1068 <span>{{ (threadStats.threadDumpWaiting * 100) / threadStats.threadDumpAll | number: '1.0-0' }}%</span>
1069 </ngb-progressbar>
1070 <span><span jhiTranslate="metrics.jvm.threads.blocked">Blocked</span> ({{ threadStats.threadDumpBlocked }})</span>
1071 <ngb-progressbar
1072 [value]="threadStats.threadDumpBlocked"
1073 [max]="threadStats.threadDumpAll"
1074 [striped]="true"
1075 [animated]="false"
1076 type="success"
1077 >
1078 <span>{{ (threadStats.threadDumpBlocked * 100) / threadStats.threadDumpAll | number: '1.0-0' }}%</span>
1079 </ngb-progressbar>
1080 <div>Total: {{ threadStats.threadDumpAll }}</div>
1081 <button class="hand btn btn-primary btn-sm" (click)="open()" data-toggle="modal" data-target="#threadDump">
1082 <span>Expand</span>
1083 </button>
1084 `
1085 },] }
1086];
1087JhiJvmThreadsComponent.ctorParameters = () => [
1088 { type: NgbModal }
1089];
1090JhiJvmThreadsComponent.propDecorators = {
1091 threadData: [{ type: Input }]
1092};
1093
1094/*
1095 Copyright 2013-2020 the original author or authors from the JHipster project.
1096
1097 This file is part of the JHipster project, see https://www.jhipster.tech/
1098 for more information.
1099
1100 Licensed under the Apache License, Version 2.0 (the "License");
1101 you may not use this file except in compliance with the License.
1102 You may obtain a copy of the License at
1103
1104 http://www.apache.org/licenses/LICENSE-2.0
1105
1106 Unless required by applicable law or agreed to in writing, software
1107 distributed under the License is distributed on an "AS IS" BASIS,
1108 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1109 See the License for the specific language governing permissions and
1110 limitations under the License.
1111 */
1112class JhiMetricsCacheComponent {
1113 filterNaN(input) {
1114 if (isNaN(input)) {
1115 return 0;
1116 }
1117 return input;
1118 }
1119}
1120JhiMetricsCacheComponent.decorators = [
1121 { type: Component, args: [{
1122 selector: 'jhi-metrics-cache',
1123 template: `
1124 <h3 jhiTranslate="metrics.cache.title">Cache statistics</h3>
1125 <div class="table-responsive" *ngIf="!updating">
1126 <table class="table table-striped">
1127 <thead>
1128 <tr>
1129 <th jhiTranslate="metrics.cache.cachename">Cache name</th>
1130 <th class="text-right" data-translate="metrics.cache.hits">Cache Hits</th>
1131 <th class="text-right" data-translate="metrics.cache.misses">Cache Misses</th>
1132 <th class="text-right" data-translate="metrics.cache.gets">Cache Gets</th>
1133 <th class="text-right" data-translate="metrics.cache.puts">Cache Puts</th>
1134 <th class="text-right" data-translate="metrics.cache.removals">Cache Removals</th>
1135 <th class="text-right" data-translate="metrics.cache.evictions">Cache Evictions</th>
1136 <th class="text-right" data-translate="metrics.cache.hitPercent">Cache Hit %</th>
1137 <th class="text-right" data-translate="metrics.cache.missPercent">Cache Miss %</th>
1138 </tr>
1139 </thead>
1140 <tbody>
1141 <tr *ngFor="let entry of (cacheMetrics | keys)">
1142 <td>{{ entry.key }}</td>
1143 <td class="text-right">{{ entry.value['cache.gets.hit'] }}</td>
1144 <td class="text-right">{{ entry.value['cache.gets.miss'] }}</td>
1145 <td class="text-right">{{ entry.value['cache.gets.hit'] + entry.value['cache.gets.miss'] }}</td>
1146 <td class="text-right">{{ entry.value['cache.puts'] }}</td>
1147 <td class="text-right">{{ entry.value['cache.removals'] }}</td>
1148 <td class="text-right">{{ entry.value['cache.evictions'] }}</td>
1149 <td class="text-right">
1150 {{
1151 filterNaN(
1152 (100 * entry.value['cache.gets.hit']) / (entry.value['cache.gets.hit'] + entry.value['cache.gets.miss'])
1153 ) | number: '1.0-4'
1154 }}
1155 </td>
1156 <td class="text-right">
1157 {{
1158 filterNaN(
1159 (100 * entry.value['cache.gets.miss']) /
1160 (entry.value['cache.gets.hit'] + entry.value['cache.gets.miss'])
1161 ) | number: '1.0-4'
1162 }}
1163 </td>
1164 </tr>
1165 </tbody>
1166 </table>
1167 </div>
1168 `
1169 },] }
1170];
1171JhiMetricsCacheComponent.propDecorators = {
1172 cacheMetrics: [{ type: Input }],
1173 updating: [{ type: Input }]
1174};
1175
1176/*
1177 Copyright 2013-2020 the original author or authors from the JHipster project.
1178
1179 This file is part of the JHipster project, see https://www.jhipster.tech/
1180 for more information.
1181
1182 Licensed under the Apache License, Version 2.0 (the "License");
1183 you may not use this file except in compliance with the License.
1184 You may obtain a copy of the License at
1185
1186 http://www.apache.org/licenses/LICENSE-2.0
1187
1188 Unless required by applicable law or agreed to in writing, software
1189 distributed under the License is distributed on an "AS IS" BASIS,
1190 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1191 See the License for the specific language governing permissions and
1192 limitations under the License.
1193 */
1194class JhiMetricsDatasourceComponent {
1195 filterNaN(input) {
1196 if (isNaN(input)) {
1197 return 0;
1198 }
1199 return input;
1200 }
1201}
1202JhiMetricsDatasourceComponent.decorators = [
1203 { type: Component, args: [{
1204 selector: 'jhi-metrics-datasource',
1205 template: `
1206 <h3 jhiTranslate="metrics.datasource.title">DataSource statistics (time in millisecond)</h3>
1207 <div class="table-responsive" *ngIf="!updating">
1208 <table class="table table-striped">
1209 <thead>
1210 <tr>
1211 <th>
1212 <span jhiTranslate="metrics.datasource.usage">Connection Pool Usage</span> (active:
1213 {{ datasourceMetrics.active.value }}, min: {{ datasourceMetrics.min.value }}, max:
1214 {{ datasourceMetrics.max.value }}, idle: {{ datasourceMetrics.idle.value }})
1215 </th>
1216 <th class="text-right" jhiTranslate="metrics.datasource.count">Count</th>
1217 <th class="text-right" jhiTranslate="metrics.datasource.mean">Mean</th>
1218 <th class="text-right" jhiTranslate="metrics.servicesstats.table.min">Min</th>
1219 <th class="text-right" jhiTranslate="metrics.servicesstats.table.p50">p50</th>
1220 <th class="text-right" jhiTranslate="metrics.servicesstats.table.p75">p75</th>
1221 <th class="text-right" jhiTranslate="metrics.servicesstats.table.p95">p95</th>
1222 <th class="text-right" jhiTranslate="metrics.servicesstats.table.p99">p99</th>
1223 <th class="text-right" jhiTranslate="metrics.datasource.max">Max</th>
1224 </tr>
1225 </thead>
1226 <tbody>
1227 <tr>
1228 <td>Acquire</td>
1229 <td class="text-right">{{ datasourceMetrics.acquire.count }}</td>
1230 <td class="text-right">{{ filterNaN(datasourceMetrics.acquire.mean) | number: '1.0-2' }}</td>
1231 <td class="text-right">{{ datasourceMetrics.acquire['0.0'] | number: '1.0-3' }}</td>
1232 <td class="text-right">{{ datasourceMetrics.acquire['0.5'] | number: '1.0-3' }}</td>
1233 <td class="text-right">{{ datasourceMetrics.acquire['0.75'] | number: '1.0-3' }}</td>
1234 <td class="text-right">{{ datasourceMetrics.acquire['0.95'] | number: '1.0-3' }}</td>
1235 <td class="text-right">{{ datasourceMetrics.acquire['0.99'] | number: '1.0-3' }}</td>
1236 <td class="text-right">{{ filterNaN(datasourceMetrics.acquire.max) | number: '1.0-2' }}</td>
1237 </tr>
1238 <tr>
1239 <td>Creation</td>
1240 <td class="text-right">{{ datasourceMetrics.creation.count }}</td>
1241 <td class="text-right">{{ filterNaN(datasourceMetrics.creation.mean) | number: '1.0-2' }}</td>
1242 <td class="text-right">{{ datasourceMetrics.creation['0.0'] | number: '1.0-3' }}</td>
1243 <td class="text-right">{{ datasourceMetrics.creation['0.5'] | number: '1.0-3' }}</td>
1244 <td class="text-right">{{ datasourceMetrics.creation['0.75'] | number: '1.0-3' }}</td>
1245 <td class="text-right">{{ datasourceMetrics.creation['0.95'] | number: '1.0-3' }}</td>
1246 <td class="text-right">{{ datasourceMetrics.creation['0.99'] | number: '1.0-3' }}</td>
1247 <td class="text-right">{{ filterNaN(datasourceMetrics.creation.max) | number: '1.0-2' }}</td>
1248 </tr>
1249 <tr>
1250 <td>Usage</td>
1251 <td class="text-right">{{ datasourceMetrics.usage.count }}</td>
1252 <td class="text-right">{{ filterNaN(datasourceMetrics.usage.mean) | number: '1.0-2' }}</td>
1253 <td class="text-right">{{ datasourceMetrics.usage['0.0'] | number: '1.0-3' }}</td>
1254 <td class="text-right">{{ datasourceMetrics.usage['0.5'] | number: '1.0-3' }}</td>
1255 <td class="text-right">{{ datasourceMetrics.usage['0.75'] | number: '1.0-3' }}</td>
1256 <td class="text-right">{{ datasourceMetrics.usage['0.95'] | number: '1.0-3' }}</td>
1257 <td class="text-right">{{ datasourceMetrics.usage['0.99'] | number: '1.0-3' }}</td>
1258 <td class="text-right">{{ filterNaN(datasourceMetrics.usage.max) | number: '1.0-2' }}</td>
1259 </tr>
1260 </tbody>
1261 </table>
1262 </div>
1263 `
1264 },] }
1265];
1266JhiMetricsDatasourceComponent.propDecorators = {
1267 datasourceMetrics: [{ type: Input }],
1268 updating: [{ type: Input }]
1269};
1270
1271/*
1272 Copyright 2013-2020 the original author or authors from the JHipster project.
1273
1274 This file is part of the JHipster project, see https://www.jhipster.tech/
1275 for more information.
1276
1277 Licensed under the Apache License, Version 2.0 (the "License");
1278 you may not use this file except in compliance with the License.
1279 You may obtain a copy of the License at
1280
1281 http://www.apache.org/licenses/LICENSE-2.0
1282
1283 Unless required by applicable law or agreed to in writing, software
1284 distributed under the License is distributed on an "AS IS" BASIS,
1285 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1286 See the License for the specific language governing permissions and
1287 limitations under the License.
1288 */
1289class JhiMetricsEndpointsRequestsComponent {
1290}
1291JhiMetricsEndpointsRequestsComponent.decorators = [
1292 { type: Component, args: [{
1293 selector: 'jhi-metrics-endpoints-requests',
1294 template: `
1295 <h3>Endpoints requests (time in millisecond)</h3>
1296 <div class="table-responsive" *ngIf="!updating">
1297 <table class="table table-striped">
1298 <thead>
1299 <tr>
1300 <th>Method</th>
1301 <th>Endpoint url</th>
1302 <th class="text-right">Count</th>
1303 <th class="text-right">Mean</th>
1304 </tr>
1305 </thead>
1306 <tbody>
1307 <ng-container *ngFor="let entry of (endpointsRequestsMetrics | keys)">
1308 <tr *ngFor="let method of (entry.value | keys)">
1309 <td>{{ method.key }}</td>
1310 <td>{{ entry.key }}</td>
1311 <td class="text-right">{{ method.value.count }}</td>
1312 <td class="text-right">{{ method.value.mean | number: '1.0-3' }}</td>
1313 </tr>
1314 </ng-container>
1315 </tbody>
1316 </table>
1317 </div>
1318 `
1319 },] }
1320];
1321JhiMetricsEndpointsRequestsComponent.propDecorators = {
1322 endpointsRequestsMetrics: [{ type: Input }],
1323 updating: [{ type: Input }]
1324};
1325
1326/*
1327 Copyright 2013-2020 the original author or authors from the JHipster project.
1328
1329 This file is part of the JHipster project, see https://www.jhipster.tech/
1330 for more information.
1331
1332 Licensed under the Apache License, Version 2.0 (the "License");
1333 you may not use this file except in compliance with the License.
1334 You may obtain a copy of the License at
1335
1336 http://www.apache.org/licenses/LICENSE-2.0
1337
1338 Unless required by applicable law or agreed to in writing, software
1339 distributed under the License is distributed on an "AS IS" BASIS,
1340 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1341 See the License for the specific language governing permissions and
1342 limitations under the License.
1343 */
1344class JhiMetricsGarbageCollectorComponent {
1345}
1346JhiMetricsGarbageCollectorComponent.decorators = [
1347 { type: Component, args: [{
1348 selector: 'jhi-metrics-garbagecollector',
1349 template: `
1350 <div class="row">
1351 <div class="col-md-4">
1352 <div *ngIf="garbageCollectorMetrics">
1353 <span>
1354 GC Live Data Size/GC Max Data Size ({{
1355 garbageCollectorMetrics['jvm.gc.live.data.size'] / 1048576 | number: '1.0-0'
1356 }}M / {{ garbageCollectorMetrics['jvm.gc.max.data.size'] / 1048576 | number: '1.0-0' }}M)</span
1357 >
1358 <ngb-progressbar
1359 [max]="garbageCollectorMetrics['jvm.gc.max.data.size']"
1360 [value]="garbageCollectorMetrics['jvm.gc.live.data.size']"
1361 [striped]="true"
1362 [animated]="false"
1363 type="success"
1364 >
1365 <span
1366 >{{
1367 (100 * garbageCollectorMetrics['jvm.gc.live.data.size']) / garbageCollectorMetrics['jvm.gc.max.data.size']
1368 | number: '1.0-2'
1369 }}%</span
1370 >
1371 </ngb-progressbar>
1372 </div>
1373 </div>
1374 <div class="col-md-4">
1375 <div *ngIf="garbageCollectorMetrics">
1376 <span>
1377 GC Memory Promoted/GC Memory Allocated ({{
1378 garbageCollectorMetrics['jvm.gc.memory.promoted'] / 1048576 | number: '1.0-0'
1379 }}M / {{ garbageCollectorMetrics['jvm.gc.memory.allocated'] / 1048576 | number: '1.0-0' }}M)</span
1380 >
1381 <ngb-progressbar
1382 [max]="garbageCollectorMetrics['jvm.gc.memory.allocated']"
1383 [value]="garbageCollectorMetrics['jvm.gc.memory.promoted']"
1384 [striped]="true"
1385 [animated]="false"
1386 type="success"
1387 >
1388 <span
1389 >{{
1390 (100 * garbageCollectorMetrics['jvm.gc.memory.promoted']) /
1391 garbageCollectorMetrics['jvm.gc.memory.allocated'] | number: '1.0-2'
1392 }}%</span
1393 >
1394 </ngb-progressbar>
1395 </div>
1396 </div>
1397 <div class="col-md-4">
1398 <div class="row" *ngIf="garbageCollectorMetrics">
1399 <div class="col-md-9">Classes loaded</div>
1400 <div class="col-md-3 text-right">{{ garbageCollectorMetrics.classesLoaded }}</div>
1401 </div>
1402 <div class="row" *ngIf="garbageCollectorMetrics">
1403 <div class="col-md-9">Classes unloaded</div>
1404 <div class="col-md-3 text-right">{{ garbageCollectorMetrics.classesUnloaded }}</div>
1405 </div>
1406 </div>
1407 <div class="table-responsive" *ngIf="!updating && garbageCollectorMetrics">
1408 <table class="table table-striped">
1409 <thead>
1410 <tr>
1411 <th></th>
1412 <th class="text-right" jhiTranslate="metrics.servicesstats.table.count">Count</th>
1413 <th class="text-right" jhiTranslate="metrics.servicesstats.table.mean">Mean</th>
1414 <th class="text-right" jhiTranslate="metrics.servicesstats.table.min">Min</th>
1415 <th class="text-right" jhiTranslate="metrics.servicesstats.table.p50">p50</th>
1416 <th class="text-right" jhiTranslate="metrics.servicesstats.table.p75">p75</th>
1417 <th class="text-right" jhiTranslate="metrics.servicesstats.table.p95">p95</th>
1418 <th class="text-right" jhiTranslate="metrics.servicesstats.table.p99">p99</th>
1419 <th class="text-right" jhiTranslate="metrics.servicesstats.table.max">Max</th>
1420 </tr>
1421 </thead>
1422 <tbody>
1423 <tr>
1424 <td>jvm.gc.pause</td>
1425 <td class="text-right">{{ garbageCollectorMetrics['jvm.gc.pause'].count }}</td>
1426 <td class="text-right">{{ garbageCollectorMetrics['jvm.gc.pause'].mean | number: '1.0-3' }}</td>
1427 <td class="text-right">{{ garbageCollectorMetrics['jvm.gc.pause']['0.0'] | number: '1.0-3' }}</td>
1428 <td class="text-right">{{ garbageCollectorMetrics['jvm.gc.pause']['0.5'] | number: '1.0-3' }}</td>
1429 <td class="text-right">{{ garbageCollectorMetrics['jvm.gc.pause']['0.75'] | number: '1.0-3' }}</td>
1430 <td class="text-right">{{ garbageCollectorMetrics['jvm.gc.pause']['0.95'] | number: '1.0-3' }}</td>
1431 <td class="text-right">{{ garbageCollectorMetrics['jvm.gc.pause']['0.99'] | number: '1.0-3' }}</td>
1432 <td class="text-right">{{ garbageCollectorMetrics['jvm.gc.pause'].max | number: '1.0-3' }}</td>
1433 </tr>
1434 </tbody>
1435 </table>
1436 </div>
1437 </div>
1438 `
1439 },] }
1440];
1441JhiMetricsGarbageCollectorComponent.propDecorators = {
1442 garbageCollectorMetrics: [{ type: Input }],
1443 updating: [{ type: Input }]
1444};
1445
1446/*
1447 Copyright 2013-2020 the original author or authors from the JHipster project.
1448
1449 This file is part of the JHipster project, see https://www.jhipster.tech/
1450 for more information.
1451
1452 Licensed under the Apache License, Version 2.0 (the "License");
1453 you may not use this file except in compliance with the License.
1454 You may obtain a copy of the License at
1455
1456 http://www.apache.org/licenses/LICENSE-2.0
1457
1458 Unless required by applicable law or agreed to in writing, software
1459 distributed under the License is distributed on an "AS IS" BASIS,
1460 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1461 See the License for the specific language governing permissions and
1462 limitations under the License.
1463 */
1464class JhiMetricsHttpRequestComponent {
1465 filterNaN(input) {
1466 if (isNaN(input)) {
1467 return 0;
1468 }
1469 return input;
1470 }
1471}
1472JhiMetricsHttpRequestComponent.decorators = [
1473 { type: Component, args: [{
1474 selector: 'jhi-metrics-request',
1475 template: `
1476 <h3 jhiTranslate="metrics.jvm.http.title">HTTP requests (time in millisecond)</h3>
1477 <table class="table table-striped" *ngIf="!updating">
1478 <thead>
1479 <tr>
1480 <th jhiTranslate="metrics.jvm.http.table.code">Code</th>
1481 <th jhiTranslate="metrics.jvm.http.table.count">Count</th>
1482 <th class="text-right" jhiTranslate="metrics.jvm.http.table.mean">Mean</th>
1483 <th class="text-right" jhiTranslate="metrics.jvm.http.table.max">Max</th>
1484 </tr>
1485 </thead>
1486 <tbody>
1487 <tr *ngFor="let entry of (requestMetrics['percode'] | keys)">
1488 <td>{{ entry.key }}</td>
1489 <td>
1490 <ngb-progressbar
1491 [max]="requestMetrics['all'].count"
1492 [value]="entry.value.count"
1493 [striped]="true"
1494 [animated]="false"
1495 type="success"
1496 >
1497 <span>{{ entry.value.count }}</span>
1498 </ngb-progressbar>
1499 </td>
1500 <td class="text-right">
1501 {{ filterNaN(entry.value.mean) | number: '1.0-2' }}
1502 </td>
1503 <td class="text-right">{{ entry.value.max | number: '1.0-2' }}</td>
1504 </tr>
1505 </tbody>
1506 </table>
1507 `
1508 },] }
1509];
1510JhiMetricsHttpRequestComponent.propDecorators = {
1511 requestMetrics: [{ type: Input }],
1512 updating: [{ type: Input }]
1513};
1514
1515/*
1516 Copyright 2013-2020 the original author or authors from the JHipster project.
1517
1518 This file is part of the JHipster project, see https://www.jhipster.tech/
1519 for more information.
1520
1521 Licensed under the Apache License, Version 2.0 (the "License");
1522 you may not use this file except in compliance with the License.
1523 You may obtain a copy of the License at
1524
1525 http://www.apache.org/licenses/LICENSE-2.0
1526
1527 Unless required by applicable law or agreed to in writing, software
1528 distributed under the License is distributed on an "AS IS" BASIS,
1529 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1530 See the License for the specific language governing permissions and
1531 limitations under the License.
1532 */
1533class JhiMetricsSystemComponent {
1534 convertMillisecondsToDuration(ms) {
1535 const times = {
1536 year: 31557600000,
1537 month: 2629746000,
1538 day: 86400000,
1539 hour: 3600000,
1540 minute: 60000,
1541 second: 1000
1542 };
1543 let timeString = '';
1544 for (const key in times) {
1545 if (Math.floor(ms / times[key]) > 0) {
1546 let plural = '';
1547 if (Math.floor(ms / times[key]) > 1) {
1548 plural = 's';
1549 }
1550 timeString += Math.floor(ms / times[key]).toString() + ' ' + key.toString() + plural + ' ';
1551 ms = ms - times[key] * Math.floor(ms / times[key]);
1552 }
1553 }
1554 return timeString;
1555 }
1556}
1557JhiMetricsSystemComponent.decorators = [
1558 { type: Component, args: [{
1559 selector: 'jhi-metrics-system',
1560 template: `
1561 <h4>System</h4>
1562 <div class="row" *ngIf="!updating">
1563 <div class="col-md-4">Uptime</div>
1564 <div class="col-md-8 text-right">{{ convertMillisecondsToDuration(systemMetrics['process.uptime']) }}</div>
1565 </div>
1566 <div class="row" *ngIf="!updating">
1567 <div class="col-md-4">Start time</div>
1568 <div class="col-md-8 text-right">{{ systemMetrics['process.start.time'] | date: 'full' }}</div>
1569 </div>
1570 <div class="row" *ngIf="!updating">
1571 <div class="col-md-9">Process CPU usage</div>
1572 <div class="col-md-3 text-right">{{ 100 * systemMetrics['process.cpu.usage'] | number: '1.0-2' }} %</div>
1573 </div>
1574 <ngb-progressbar
1575 [value]="100 * systemMetrics['process.cpu.usage']"
1576 [striped]="true"
1577 [animated]="false"
1578 type="success"
1579 *ngIf="!updating"
1580 >
1581 <span>{{ 100 * systemMetrics['process.cpu.usage'] | number: '1.0-2' }} %</span>
1582 </ngb-progressbar>
1583 <div class="row" *ngIf="!updating">
1584 <div class="col-md-9">System CPU usage</div>
1585 <div class="col-md-3 text-right">{{ 100 * systemMetrics['system.cpu.usage'] | number: '1.0-2' }} %</div>
1586 </div>
1587 <ngb-progressbar
1588 [value]="100 * systemMetrics['system.cpu.usage']"
1589 [striped]="true"
1590 [animated]="false"
1591 type="success"
1592 *ngIf="!updating"
1593 >
1594 <span>{{ 100 * systemMetrics['system.cpu.usage'] | number: '1.0-2' }} %</span>
1595 </ngb-progressbar>
1596 <div class="row" *ngIf="!updating">
1597 <div class="col-md-9">System CPU count</div>
1598 <div class="col-md-3 text-right">{{ systemMetrics['system.cpu.count'] }}</div>
1599 </div>
1600 <div class="row" *ngIf="!updating">
1601 <div class="col-md-9">System 1m Load average</div>
1602 <div class="col-md-3 text-right">{{ systemMetrics['system.load.average.1m'] | number: '1.0-2' }}</div>
1603 </div>
1604 <div class="row" *ngIf="!updating">
1605 <div class="col-md-9">Process files max</div>
1606 <div class="col-md-3 text-right">{{ systemMetrics['process.files.max'] | number: '1.0-0' }}</div>
1607 </div>
1608 <div class="row" *ngIf="!updating">
1609 <div class="col-md-9">Process files open</div>
1610 <div class="col-md-3 text-right">{{ systemMetrics['process.files.open'] | number: '1.0-0' }}</div>
1611 </div>
1612 `
1613 },] }
1614];
1615JhiMetricsSystemComponent.propDecorators = {
1616 systemMetrics: [{ type: Input }],
1617 updating: [{ type: Input }]
1618};
1619
1620/*
1621 Copyright 2013-2020 the original author or authors from the JHipster project.
1622
1623 This file is part of the JHipster project, see https://www.jhipster.tech/
1624 for more information.
1625
1626 Licensed under the Apache License, Version 2.0 (the "License");
1627 you may not use this file except in compliance with the License.
1628 You may obtain a copy of the License at
1629
1630 http://www.apache.org/licenses/LICENSE-2.0
1631
1632 Unless required by applicable law or agreed to in writing, software
1633 distributed under the License is distributed on an "AS IS" BASIS,
1634 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1635 See the License for the specific language governing permissions and
1636 limitations under the License.
1637 */
1638class JhiCapitalizePipe {
1639 transform(input) {
1640 if (input !== null) {
1641 input = input.toLowerCase();
1642 }
1643 return input.substring(0, 1).toUpperCase() + input.substring(1);
1644 }
1645}
1646JhiCapitalizePipe.decorators = [
1647 { type: Pipe, args: [{ name: 'capitalize' },] }
1648];
1649
1650/*
1651 Copyright 2013-2020 the original author or authors from the JHipster project.
1652
1653 This file is part of the JHipster project, see https://www.jhipster.tech/
1654 for more information.
1655
1656 Licensed under the Apache License, Version 2.0 (the "License");
1657 you may not use this file except in compliance with the License.
1658 You may obtain a copy of the License at
1659
1660 http://www.apache.org/licenses/LICENSE-2.0
1661
1662 Unless required by applicable law or agreed to in writing, software
1663 distributed under the License is distributed on an "AS IS" BASIS,
1664 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1665 See the License for the specific language governing permissions and
1666 limitations under the License.
1667 */
1668class JhiFilterPipe {
1669 transform(input, filter, field) {
1670 if (typeof filter === 'undefined' || filter === '') {
1671 return input;
1672 }
1673 // if filter is of type 'function' compute current value of filter, otherwise return filter
1674 const currentFilter = typeof filter === 'function' ? filter() : filter;
1675 if (typeof currentFilter === 'number') {
1676 return input.filter(this.filterByNumber(currentFilter, field));
1677 }
1678 if (typeof currentFilter === 'boolean') {
1679 return input.filter(this.filterByBoolean(currentFilter, field));
1680 }
1681 if (typeof currentFilter === 'string') {
1682 return input.filter(this.filterByString(currentFilter, field));
1683 }
1684 if (typeof currentFilter === 'object') {
1685 // filter by object ignores 'field' if specified
1686 return input.filter(this.filterByObject(currentFilter));
1687 }
1688 // 'symbol' && 'undefined'
1689 return input.filter(this.filterDefault(currentFilter, field));
1690 }
1691 filterByNumber(filter, field) {
1692 return value => (value && !filter) || (typeof value === 'object' && field)
1693 ? value[field] && typeof value[field] === 'number' && value[field] === filter
1694 : typeof value === 'number' && value === filter;
1695 }
1696 filterByBoolean(filter, field) {
1697 return value => typeof value === 'object' && field
1698 ? value[field] && typeof value[field] === 'boolean' && value[field] === filter
1699 : typeof value === 'boolean' && value === filter;
1700 }
1701 filterByString(filter, field) {
1702 return value => (value && !filter) || (typeof value === 'object' && field)
1703 ? value[field] && typeof value[field] === 'string' && value[field].toLowerCase().includes(filter.toLowerCase())
1704 : typeof value === 'string' && value.toLowerCase().includes(filter.toLowerCase());
1705 }
1706 filterDefault(filter, field) {
1707 return value => ((value && !filter) || (typeof value === 'object' && field) ? value[field] && filter === value : filter === value);
1708 }
1709 filterByObject(filter) {
1710 return value => {
1711 const keys = Object.keys(filter);
1712 let isMatching = false;
1713 // all fields defined in filter object must match
1714 for (const key of keys) {
1715 if (typeof filter[key] === 'number') {
1716 isMatching = this.filterByNumber(filter[key])(value[key]);
1717 }
1718 else if (typeof filter[key] === 'boolean') {
1719 isMatching = this.filterByBoolean(filter[key])(value[key]);
1720 }
1721 else if (typeof filter[key] === 'string') {
1722 isMatching = this.filterByString(filter[key])(value[key]);
1723 }
1724 else {
1725 isMatching = this.filterDefault(filter[key])(value[key]);
1726 }
1727 }
1728 return isMatching;
1729 };
1730 }
1731}
1732JhiFilterPipe.decorators = [
1733 { type: Pipe, args: [{ name: 'filter', pure: false },] }
1734];
1735
1736/*
1737 Copyright 2013-2020 the original author or authors from the JHipster project.
1738
1739 This file is part of the JHipster project, see https://www.jhipster.tech/
1740 for more information.
1741
1742 Licensed under the Apache License, Version 2.0 (the "License");
1743 you may not use this file except in compliance with the License.
1744 You may obtain a copy of the License at
1745
1746 http://www.apache.org/licenses/LICENSE-2.0
1747
1748 Unless required by applicable law or agreed to in writing, software
1749 distributed under the License is distributed on an "AS IS" BASIS,
1750 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1751 See the License for the specific language governing permissions and
1752 limitations under the License.
1753 */
1754class JhiKeysPipe {
1755 transform(value) {
1756 const keys = [];
1757 const valueKeys = Object.keys(value);
1758 for (const key of valueKeys) {
1759 keys.push({ key, value: value[key] });
1760 }
1761 return keys;
1762 }
1763}
1764JhiKeysPipe.decorators = [
1765 { type: Pipe, args: [{ name: 'keys' },] }
1766];
1767
1768/*
1769 Copyright 2013-2020 the original author or authors from the JHipster project.
1770
1771 This file is part of the JHipster project, see https://www.jhipster.tech/
1772 for more information.
1773
1774 Licensed under the Apache License, Version 2.0 (the "License");
1775 you may not use this file except in compliance with the License.
1776 You may obtain a copy of the License at
1777
1778 http://www.apache.org/licenses/LICENSE-2.0
1779
1780 Unless required by applicable law or agreed to in writing, software
1781 distributed under the License is distributed on an "AS IS" BASIS,
1782 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1783 See the License for the specific language governing permissions and
1784 limitations under the License.
1785 */
1786class JhiOrderByPipe {
1787 transform(values, predicate = '', reverse = false) {
1788 if (predicate === '') {
1789 return reverse ? values.sort().reverse() : values.sort();
1790 }
1791 return values.sort((a, b) => {
1792 if (a[predicate] < b[predicate]) {
1793 return reverse ? 1 : -1;
1794 }
1795 else if (b[predicate] < a[predicate]) {
1796 return reverse ? -1 : 1;
1797 }
1798 return 0;
1799 });
1800 }
1801}
1802JhiOrderByPipe.decorators = [
1803 { type: Pipe, args: [{ name: 'orderBy' },] }
1804];
1805
1806/*
1807 Copyright 2013-2020 the original author or authors from the JHipster project.
1808
1809 This file is part of the JHipster project, see https://www.jhipster.tech/
1810 for more information.
1811
1812 Licensed under the Apache License, Version 2.0 (the "License");
1813 you may not use this file except in compliance with the License.
1814 You may obtain a copy of the License at
1815
1816 http://www.apache.org/licenses/LICENSE-2.0
1817
1818 Unless required by applicable law or agreed to in writing, software
1819 distributed under the License is distributed on an "AS IS" BASIS,
1820 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1821 See the License for the specific language governing permissions and
1822 limitations under the License.
1823 */
1824class JhiPureFilterPipe extends JhiFilterPipe {
1825 transform(input, filter, field) {
1826 return super.transform(input, filter, field);
1827 }
1828}
1829JhiPureFilterPipe.decorators = [
1830 { type: Pipe, args: [{ name: 'pureFilter' },] }
1831];
1832
1833/*
1834 Copyright 2013-2020 the original author or authors from the JHipster project.
1835
1836 This file is part of the JHipster project, see https://www.jhipster.tech/
1837 for more information.
1838
1839 Licensed under the Apache License, Version 2.0 (the "License");
1840 you may not use this file except in compliance with the License.
1841 You may obtain a copy of the License at
1842
1843 http://www.apache.org/licenses/LICENSE-2.0
1844
1845 Unless required by applicable law or agreed to in writing, software
1846 distributed under the License is distributed on an "AS IS" BASIS,
1847 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1848 See the License for the specific language governing permissions and
1849 limitations under the License.
1850 */
1851class JhiTruncateCharactersPipe {
1852 transform(input, chars, breakOnWord) {
1853 if (isNaN(chars)) {
1854 return input;
1855 }
1856 if (chars <= 0) {
1857 return '';
1858 }
1859 if (input && input.length > chars) {
1860 input = input.substring(0, chars);
1861 if (!breakOnWord) {
1862 const lastspace = input.lastIndexOf(' ');
1863 // Get last space
1864 if (lastspace !== -1) {
1865 input = input.substr(0, lastspace);
1866 }
1867 }
1868 else {
1869 while (input.endsWith(' ')) {
1870 input = input.substr(0, input.length - 1);
1871 }
1872 }
1873 return input + '...';
1874 }
1875 return input;
1876 }
1877}
1878JhiTruncateCharactersPipe.decorators = [
1879 { type: Pipe, args: [{ name: 'truncateCharacters' },] }
1880];
1881
1882/*
1883 Copyright 2013-2020 the original author or authors from the JHipster project.
1884
1885 This file is part of the JHipster project, see https://www.jhipster.tech/
1886 for more information.
1887
1888 Licensed under the Apache License, Version 2.0 (the "License");
1889 you may not use this file except in compliance with the License.
1890 You may obtain a copy of the License at
1891
1892 http://www.apache.org/licenses/LICENSE-2.0
1893
1894 Unless required by applicable law or agreed to in writing, software
1895 distributed under the License is distributed on an "AS IS" BASIS,
1896 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1897 See the License for the specific language governing permissions and
1898 limitations under the License.
1899 */
1900class JhiTruncateWordsPipe {
1901 transform(input, words) {
1902 if (isNaN(words)) {
1903 return input;
1904 }
1905 if (words <= 0) {
1906 return '';
1907 }
1908 if (input) {
1909 const inputWords = input.split(/\s+/);
1910 if (inputWords.length > words) {
1911 input = inputWords.slice(0, words).join(' ') + '...';
1912 }
1913 }
1914 return input;
1915 }
1916}
1917JhiTruncateWordsPipe.decorators = [
1918 { type: Pipe, args: [{ name: 'truncateWords' },] }
1919];
1920
1921/*
1922 Copyright 2013-2020 the original author or authors from the JHipster project.
1923
1924 This file is part of the JHipster project, see https://www.jhipster.tech/
1925 for more information.
1926
1927 Licensed under the Apache License, Version 2.0 (the "License");
1928 you may not use this file except in compliance with the License.
1929 You may obtain a copy of the License at
1930
1931 http://www.apache.org/licenses/LICENSE-2.0
1932
1933 Unless required by applicable law or agreed to in writing, software
1934 distributed under the License is distributed on an "AS IS" BASIS,
1935 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1936 See the License for the specific language governing permissions and
1937 limitations under the License.
1938 */
1939const JHI_PIPES = [
1940 JhiCapitalizePipe,
1941 JhiFilterPipe,
1942 JhiKeysPipe,
1943 JhiOrderByPipe,
1944 JhiPureFilterPipe,
1945 JhiTruncateCharactersPipe,
1946 JhiTruncateWordsPipe
1947];
1948const JHI_DIRECTIVES = [
1949 JhiMaxValidatorDirective,
1950 JhiMinValidatorDirective,
1951 JhiMaxbytesValidatorDirective,
1952 JhiMinbytesValidatorDirective,
1953 JhiSortDirective,
1954 JhiSortByDirective
1955];
1956const JHI_COMPONENTS = [
1957 JhiItemCountComponent,
1958 JhiBooleanComponent,
1959 JhiJvmMemoryComponent,
1960 JhiJvmThreadsComponent,
1961 JhiMetricsHttpRequestComponent,
1962 JhiMetricsEndpointsRequestsComponent,
1963 JhiMetricsCacheComponent,
1964 JhiMetricsDatasourceComponent,
1965 JhiMetricsSystemComponent,
1966 JhiMetricsGarbageCollectorComponent,
1967 JhiThreadModalComponent
1968];
1969
1970/*
1971 Copyright 2013-2020 the original author or authors from the JHipster project.
1972
1973 This file is part of the JHipster project, see https://www.jhipster.tech/
1974 for more information.
1975
1976 Licensed under the Apache License, Version 2.0 (the "License");
1977 you may not use this file except in compliance with the License.
1978 You may obtain a copy of the License at
1979
1980 http://www.apache.org/licenses/LICENSE-2.0
1981
1982 Unless required by applicable law or agreed to in writing, software
1983 distributed under the License is distributed on an "AS IS" BASIS,
1984 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1985 See the License for the specific language governing permissions and
1986 limitations under the License.
1987 */
1988function translatePartialLoader(http) {
1989 return new TranslateHttpLoader(http, 'i18n/', `.json?buildTimestamp=${process.env.BUILD_TIMESTAMP}`);
1990}
1991function missingTranslationHandler(configService) {
1992 return new JhiMissingTranslationHandler(configService);
1993}
1994class NgJhipsterModule {
1995 static forRoot(moduleConfig) {
1996 return {
1997 ngModule: NgJhipsterModule,
1998 providers: [{ provide: JhiModuleConfig, useValue: moduleConfig }],
1999 };
2000 }
2001}
2002NgJhipsterModule.decorators = [
2003 { type: NgModule, args: [{
2004 imports: [CommonModule, NgbModule, FormsModule],
2005 declarations: [...JHI_PIPES, ...JHI_DIRECTIVES, ...JHI_COMPONENTS, JhiTranslateDirective],
2006 entryComponents: [JhiThreadModalComponent],
2007 exports: [...JHI_PIPES, ...JHI_DIRECTIVES, ...JHI_COMPONENTS, JhiTranslateDirective, CommonModule],
2008 },] }
2009];
2010
2011/*
2012 Copyright 2013-2020 the original author or authors from the JHipster project.
2013
2014 This file is part of the JHipster project, see https://www.jhipster.tech/
2015 for more information.
2016
2017 Licensed under the Apache License, Version 2.0 (the "License");
2018 you may not use this file except in compliance with the License.
2019 You may obtain a copy of the License at
2020
2021 http://www.apache.org/licenses/LICENSE-2.0
2022
2023 Unless required by applicable law or agreed to in writing, software
2024 distributed under the License is distributed on an "AS IS" BASIS,
2025 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2026 See the License for the specific language governing permissions and
2027 limitations under the License.
2028 */
2029
2030/*
2031 Copyright 2013-2020 the original author or authors from the JHipster project.
2032
2033 This file is part of the JHipster project, see https://www.jhipster.tech/
2034 for more information.
2035
2036 Licensed under the Apache License, Version 2.0 (the "License");
2037 you may not use this file except in compliance with the License.
2038 You may obtain a copy of the License at
2039
2040 http://www.apache.org/licenses/LICENSE-2.0
2041
2042 Unless required by applicable law or agreed to in writing, software
2043 distributed under the License is distributed on an "AS IS" BASIS,
2044 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2045 See the License for the specific language governing permissions and
2046 limitations under the License.
2047 */
2048/**
2049 * An utility service for pagination
2050 */
2051class JhiPaginationUtil {
2052 constructor() { }
2053 /**
2054 * Method to find whether the sort is defined
2055 */
2056 parseAscending(sort) {
2057 let sortArray = sort.split(',');
2058 sortArray = sortArray.length > 1 ? sortArray : sort.split('%2C');
2059 if (sortArray.length > 1) {
2060 return sortArray.slice(-1)[0] === 'asc';
2061 }
2062 // default to true if no sort is defined
2063 return true;
2064 }
2065 /**
2066 * Method to query params are strings, and need to be parsed
2067 */
2068 parsePage(page) {
2069 return parseInt(page, 10);
2070 }
2071 /**
2072 * Method to sort can be in the format `id,asc` or `id`
2073 */
2074 parsePredicate(sort) {
2075 return sort.split(',')[0].split('%2C')[0];
2076 }
2077}
2078JhiPaginationUtil.ɵprov = ɵɵdefineInjectable({ factory: function JhiPaginationUtil_Factory() { return new JhiPaginationUtil(); }, token: JhiPaginationUtil, providedIn: "root" });
2079JhiPaginationUtil.decorators = [
2080 { type: Injectable, args: [{
2081 providedIn: 'root'
2082 },] }
2083];
2084JhiPaginationUtil.ctorParameters = () => [];
2085
2086/*
2087 Copyright 2013-2020 the original author or authors from the JHipster project.
2088
2089 This file is part of the JHipster project, see https://www.jhipster.tech/
2090 for more information.
2091
2092 Licensed under the Apache License, Version 2.0 (the "License");
2093 you may not use this file except in compliance with the License.
2094 You may obtain a copy of the License at
2095
2096 http://www.apache.org/licenses/LICENSE-2.0
2097
2098 Unless required by applicable law or agreed to in writing, software
2099 distributed under the License is distributed on an "AS IS" BASIS,
2100 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2101 See the License for the specific language governing permissions and
2102 limitations under the License.
2103 */
2104/**
2105 * An utility service for link parsing.
2106 */
2107class JhiParseLinks {
2108 constructor() { }
2109 /**
2110 * Method to parse the links
2111 */
2112 parse(header) {
2113 if (header.length === 0) {
2114 throw new Error('input must not be of zero length');
2115 }
2116 // Split parts by comma
2117 const parts = header.split(',');
2118 const links = {};
2119 // Parse each part into a named link
2120 parts.forEach(p => {
2121 const section = p.split(';');
2122 if (section.length !== 2) {
2123 throw new Error('section could not be split on ";"');
2124 }
2125 const url = section[0].replace(/<(.*)>/, '$1').trim();
2126 const queryString = {};
2127 url.replace(new RegExp('([^?=&]+)(=([^&]*))?', 'g'), ($0, $1, $2, $3) => (queryString[$1] = $3));
2128 let page = queryString.page;
2129 if (typeof page === 'string') {
2130 page = parseInt(page, 10);
2131 }
2132 const name = section[1].replace(/rel="(.*)"/, '$1').trim();
2133 links[name] = page;
2134 });
2135 return links;
2136 }
2137}
2138JhiParseLinks.ɵprov = ɵɵdefineInjectable({ factory: function JhiParseLinks_Factory() { return new JhiParseLinks(); }, token: JhiParseLinks, providedIn: "root" });
2139JhiParseLinks.decorators = [
2140 { type: Injectable, args: [{
2141 providedIn: 'root'
2142 },] }
2143];
2144JhiParseLinks.ctorParameters = () => [];
2145
2146/*
2147 Copyright 2013-2020 the original author or authors from the JHipster project.
2148
2149 This file is part of the JHipster project, see https://www.jhipster.tech/
2150 for more information.
2151
2152 Licensed under the Apache License, Version 2.0 (the "License");
2153 you may not use this file except in compliance with the License.
2154 You may obtain a copy of the License at
2155
2156 http://www.apache.org/licenses/LICENSE-2.0
2157
2158 Unless required by applicable law or agreed to in writing, software
2159 distributed under the License is distributed on an "AS IS" BASIS,
2160 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2161 See the License for the specific language governing permissions and
2162 limitations under the License.
2163 */
2164/**
2165 * An utility service for data.
2166 */
2167class JhiDataUtils {
2168 constructor() { }
2169 /**
2170 * Method to abbreviate the text given
2171 */
2172 abbreviate(text, append = '...') {
2173 if (text.length < 30) {
2174 return text;
2175 }
2176 return text ? text.substring(0, 15) + append + text.slice(-10) : '';
2177 }
2178 /**
2179 * Method to find the byte size of the string provides
2180 */
2181 byteSize(base64String) {
2182 return this.formatAsBytes(this.size(base64String));
2183 }
2184 /**
2185 * Method to open file
2186 */
2187 openFile(contentType, data) {
2188 if (window.navigator && window.navigator.msSaveOrOpenBlob) {
2189 // To support IE and Edge
2190 const byteCharacters = atob(data);
2191 const byteNumbers = new Array(byteCharacters.length);
2192 for (let i = 0; i < byteCharacters.length; i++) {
2193 byteNumbers[i] = byteCharacters.charCodeAt(i);
2194 }
2195 const byteArray = new Uint8Array(byteNumbers);
2196 const blob = new Blob([byteArray], {
2197 type: contentType
2198 });
2199 window.navigator.msSaveOrOpenBlob(blob);
2200 }
2201 else {
2202 // Other browsers
2203 const fileURL = `data:${contentType};base64,${data}`;
2204 const win = window.open();
2205 win.document.write('<iframe src="' +
2206 fileURL +
2207 '" frameborder="0" style="border:0; top:0; left:0; bottom:0; right:0; width:100%; height:100%;" allowfullscreen></iframe>');
2208 }
2209 }
2210 /**
2211 * Method to convert the file to base64
2212 */
2213 toBase64(file, cb) {
2214 const fileReader = new FileReader();
2215 fileReader.onload = function (e) {
2216 const base64Data = e.target.result.substr(e.target.result.indexOf('base64,') + 'base64,'.length);
2217 cb(base64Data);
2218 };
2219 fileReader.readAsDataURL(file);
2220 }
2221 /**
2222 * Method to clear the input
2223 */
2224 clearInputImage(entity, elementRef, field, fieldContentType, idInput) {
2225 if (entity && field && fieldContentType) {
2226 if (Object.prototype.hasOwnProperty.call(entity, field)) {
2227 entity[field] = null;
2228 }
2229 if (Object.prototype.hasOwnProperty.call(entity, fieldContentType)) {
2230 entity[fieldContentType] = null;
2231 }
2232 if (elementRef && idInput && elementRef.nativeElement.querySelector('#' + idInput)) {
2233 elementRef.nativeElement.querySelector('#' + idInput).value = null;
2234 }
2235 }
2236 }
2237 /**
2238 * Sets the base 64 data & file type of the 1st file on the event (event.target.files[0]) in the passed entity object
2239 * and returns a promise.
2240 *
2241 * @param event the object containing the file (at event.target.files[0])
2242 * @param entity the object to set the file's 'base 64 data' and 'file type' on
2243 * @param field the field name to set the file's 'base 64 data' on
2244 * @param isImage boolean representing if the file represented by the event is an image
2245 * @returns a promise that resolves to the modified entity if operation is successful, otherwise rejects with an error message
2246 */
2247 setFileData(event, entity, field, isImage) {
2248 return new Promise((resolve, reject) => {
2249 if (event && event.target && event.target.files && event.target.files[0]) {
2250 const file = event.target.files[0];
2251 if (isImage && !file.type.startsWith('image/')) {
2252 reject(`File was expected to be an image but was found to be ${file.type}`);
2253 }
2254 else {
2255 this.toBase64(file, base64Data => {
2256 entity[field] = base64Data;
2257 entity[`${field}ContentType`] = file.type;
2258 resolve(entity);
2259 });
2260 }
2261 }
2262 else {
2263 reject(`Base64 data was not set as file could not be extracted from passed parameter: ${event}`);
2264 }
2265 });
2266 }
2267 /**
2268 * Sets the base 64 data & file type of the 1st file on the event (event.target.files[0]) in the passed entity object
2269 * and returns an observable.
2270 *
2271 * @param event the object containing the file (at event.target.files[0])
2272 * @param editForm the form group where the input field is located
2273 * @param field the field name to set the file's 'base 64 data' on
2274 * @param isImage boolean representing if the file represented by the event is an image
2275 * @returns an observable that loads file to form field and completes if sussessful
2276 * or returns error as JhiFileLoadError on failure
2277 */
2278 loadFileToForm(event, editForm, field, isImage) {
2279 return new Observable((observer) => {
2280 const eventTarget = event.target;
2281 if (eventTarget.files && eventTarget.files[0]) {
2282 const file = eventTarget.files[0];
2283 if (isImage && !file.type.startsWith('image/')) {
2284 const error = {
2285 message: `File was expected to be an image but was found to be '${file.type}'`,
2286 key: 'not.image',
2287 params: { fileType: file.type }
2288 };
2289 observer.error(error);
2290 }
2291 else {
2292 const fieldContentType = field + 'ContentType';
2293 this.toBase64(file, (base64Data) => {
2294 editForm.patchValue({
2295 [field]: base64Data,
2296 [fieldContentType]: file.type
2297 });
2298 observer.next();
2299 observer.complete();
2300 });
2301 }
2302 }
2303 else {
2304 const error = {
2305 message: 'Could not extract file',
2306 key: 'could.not.extract',
2307 params: { event }
2308 };
2309 observer.error(error);
2310 }
2311 });
2312 }
2313 /**
2314 * Method to download file
2315 */
2316 downloadFile(contentType, data, fileName) {
2317 const byteCharacters = atob(data);
2318 const byteNumbers = new Array(byteCharacters.length);
2319 for (let i = 0; i < byteCharacters.length; i++) {
2320 byteNumbers[i] = byteCharacters.charCodeAt(i);
2321 }
2322 const byteArray = new Uint8Array(byteNumbers);
2323 const blob = new Blob([byteArray], {
2324 type: contentType
2325 });
2326 const tempLink = document.createElement('a');
2327 tempLink.href = window.URL.createObjectURL(blob);
2328 tempLink.download = fileName;
2329 tempLink.target = '_blank';
2330 tempLink.click();
2331 }
2332 endsWith(suffix, str) {
2333 return str.includes(suffix, str.length - suffix.length);
2334 }
2335 paddingSize(value) {
2336 if (this.endsWith('==', value)) {
2337 return 2;
2338 }
2339 if (this.endsWith('=', value)) {
2340 return 1;
2341 }
2342 return 0;
2343 }
2344 size(value) {
2345 return (value.length / 4) * 3 - this.paddingSize(value);
2346 }
2347 formatAsBytes(size) {
2348 return size.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ') + ' bytes';
2349 }
2350}
2351JhiDataUtils.ɵprov = ɵɵdefineInjectable({ factory: function JhiDataUtils_Factory() { return new JhiDataUtils(); }, token: JhiDataUtils, providedIn: "root" });
2352JhiDataUtils.decorators = [
2353 { type: Injectable, args: [{
2354 providedIn: 'root'
2355 },] }
2356];
2357JhiDataUtils.ctorParameters = () => [];
2358
2359/*
2360 Copyright 2013-2020 the original author or authors from the JHipster project.
2361
2362 This file is part of the JHipster project, see https://www.jhipster.tech/
2363 for more information.
2364
2365 Licensed under the Apache License, Version 2.0 (the "License");
2366 you may not use this file except in compliance with the License.
2367 You may obtain a copy of the License at
2368
2369 http://www.apache.org/licenses/LICENSE-2.0
2370
2371 Unless required by applicable law or agreed to in writing, software
2372 distributed under the License is distributed on an "AS IS" BASIS,
2373 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2374 See the License for the specific language governing permissions and
2375 limitations under the License.
2376 */
2377/**
2378 * An utility service for date.
2379 */
2380class JhiDateUtils {
2381 constructor() {
2382 this.pattern = 'yyyy-MM-dd';
2383 this.datePipe = new DatePipe('en');
2384 }
2385 /**
2386 * Method to convert the date time from server into JS date object
2387 */
2388 convertDateTimeFromServer(date) {
2389 if (date) {
2390 return new Date(date);
2391 }
2392 else {
2393 return null;
2394 }
2395 }
2396 /**
2397 * Method to convert the date from server into JS date object
2398 */
2399 convertLocalDateFromServer(date) {
2400 if (date) {
2401 const dateString = date.split('-');
2402 return new Date(dateString[0], dateString[1] - 1, dateString[2]);
2403 }
2404 return null;
2405 }
2406 /**
2407 * Method to convert the JS date object into specified date pattern
2408 */
2409 convertLocalDateToServer(date, pattern = this.pattern) {
2410 if (date) {
2411 const newDate = new Date(date.year, date.month - 1, date.day);
2412 return this.datePipe.transform(newDate, pattern);
2413 }
2414 else {
2415 return null;
2416 }
2417 }
2418 /**
2419 * Method to get the default date pattern
2420 */
2421 dateformat() {
2422 return this.pattern;
2423 }
2424 // TODO Change this method when moving from datetime-local input to NgbDatePicker
2425 toDate(date) {
2426 if (date === undefined || date === null) {
2427 return null;
2428 }
2429 const dateParts = date.split(/\D+/);
2430 if (dateParts.length === 7) {
2431 return new Date(dateParts[0], dateParts[1] - 1, dateParts[2], dateParts[3], dateParts[4], dateParts[5], dateParts[6]);
2432 }
2433 if (dateParts.length === 6) {
2434 return new Date(dateParts[0], dateParts[1] - 1, dateParts[2], dateParts[3], dateParts[4], dateParts[5]);
2435 }
2436 return new Date(dateParts[0], dateParts[1] - 1, dateParts[2], dateParts[3], dateParts[4]);
2437 }
2438}
2439JhiDateUtils.ɵprov = ɵɵdefineInjectable({ factory: function JhiDateUtils_Factory() { return new JhiDateUtils(); }, token: JhiDateUtils, providedIn: "root" });
2440JhiDateUtils.decorators = [
2441 { type: Injectable, args: [{
2442 providedIn: 'root'
2443 },] }
2444];
2445JhiDateUtils.ctorParameters = () => [];
2446
2447/*
2448 Copyright 2013-2020 the original author or authors from the JHipster project.
2449
2450 This file is part of the JHipster project, see https://www.jhipster.tech/
2451 for more information.
2452
2453 Licensed under the Apache License, Version 2.0 (the "License");
2454 you may not use this file except in compliance with the License.
2455 You may obtain a copy of the License at
2456
2457 http://www.apache.org/licenses/LICENSE-2.0
2458
2459 Unless required by applicable law or agreed to in writing, software
2460 distributed under the License is distributed on an "AS IS" BASIS,
2461 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2462 See the License for the specific language governing permissions and
2463 limitations under the License.
2464 */
2465/**
2466 * An utility class to manage RX events
2467 */
2468class JhiEventManager {
2469 constructor() {
2470 this.observable = Observable.create((observer) => {
2471 this.observer = observer;
2472 }).pipe(share());
2473 }
2474 /**
2475 * Method to broadcast the event to observer
2476 */
2477 broadcast(event) {
2478 if (this.observer) {
2479 this.observer.next(event);
2480 }
2481 }
2482 /**
2483 * Method to subscribe to an event with callback
2484 */
2485 subscribe(eventName, callback) {
2486 const subscriber = this.observable
2487 .pipe(filter((event) => {
2488 if (typeof event === 'string') {
2489 return event === eventName;
2490 }
2491 return event.name === eventName;
2492 }), map((event) => {
2493 if (typeof event !== 'string') {
2494 // when releasing generator-jhipster v7 then current return will be changed to
2495 // (to avoid redundant code response.content in JhiEventManager.subscribe callbacks):
2496 // return event.content;
2497 return event;
2498 }
2499 }))
2500 .subscribe(callback);
2501 return subscriber;
2502 }
2503 /**
2504 * Method to unsubscribe the subscription
2505 */
2506 destroy(subscriber) {
2507 subscriber.unsubscribe();
2508 }
2509}
2510JhiEventManager.ɵprov = ɵɵdefineInjectable({ factory: function JhiEventManager_Factory() { return new JhiEventManager(); }, token: JhiEventManager, providedIn: "root" });
2511JhiEventManager.decorators = [
2512 { type: Injectable, args: [{
2513 providedIn: 'root'
2514 },] }
2515];
2516JhiEventManager.ctorParameters = () => [];
2517
2518/*
2519 Copyright 2013-2020 the original author or authors from the JHipster project.
2520
2521 This file is part of the JHipster project, see https://www.jhipster.tech/
2522 for more information.
2523
2524 Licensed under the Apache License, Version 2.0 (the "License");
2525 you may not use this file except in compliance with the License.
2526 You may obtain a copy of the License at
2527
2528 http://www.apache.org/licenses/LICENSE-2.0
2529
2530 Unless required by applicable law or agreed to in writing, software
2531 distributed under the License is distributed on an "AS IS" BASIS,
2532 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2533 See the License for the specific language governing permissions and
2534 limitations under the License.
2535 */
2536class JhiEventWithContent {
2537 constructor(name, content) {
2538 this.name = name;
2539 this.content = content;
2540 }
2541}
2542
2543/*
2544 Copyright 2013-2020 the original author or authors from the JHipster project.
2545
2546 This file is part of the JHipster project, see https://www.jhipster.tech/
2547 for more information.
2548
2549 Licensed under the Apache License, Version 2.0 (the "License");
2550 you may not use this file except in compliance with the License.
2551 You may obtain a copy of the License at
2552
2553 http://www.apache.org/licenses/LICENSE-2.0
2554
2555 Unless required by applicable law or agreed to in writing, software
2556 distributed under the License is distributed on an "AS IS" BASIS,
2557 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2558 See the License for the specific language governing permissions and
2559 limitations under the License.
2560 */
2561class JhiAlertService {
2562 constructor(sanitizer, configService, ngZone, translateService) {
2563 this.sanitizer = sanitizer;
2564 this.configService = configService;
2565 this.ngZone = ngZone;
2566 this.translateService = translateService;
2567 const config = this.configService.getConfig();
2568 this.toast = config.alertAsToast;
2569 this.i18nEnabled = config.i18nEnabled;
2570 this.alertId = 0; // unique id for each alert. Starts from 0.
2571 this.alerts = [];
2572 this.timeout = config.alertTimeout;
2573 }
2574 clear() {
2575 this.alerts.splice(0, this.alerts.length);
2576 }
2577 get() {
2578 return this.alerts;
2579 }
2580 success(msg, params, position) {
2581 return this.addAlert({
2582 type: 'success',
2583 msg,
2584 params,
2585 timeout: this.timeout,
2586 toast: this.isToast(),
2587 position
2588 }, []);
2589 }
2590 error(msg, params, position) {
2591 return this.addAlert({
2592 type: 'danger',
2593 msg,
2594 params,
2595 timeout: this.timeout,
2596 toast: this.isToast(),
2597 position
2598 }, []);
2599 }
2600 warning(msg, params, position) {
2601 return this.addAlert({
2602 type: 'warning',
2603 msg,
2604 params,
2605 timeout: this.timeout,
2606 toast: this.isToast(),
2607 position
2608 }, []);
2609 }
2610 info(msg, params, position) {
2611 return this.addAlert({
2612 type: 'info',
2613 msg,
2614 params,
2615 timeout: this.timeout,
2616 toast: this.isToast(),
2617 position
2618 }, []);
2619 }
2620 addAlert(alertOptions, extAlerts) {
2621 alertOptions.id = this.alertId++;
2622 if (this.i18nEnabled && alertOptions.msg) {
2623 alertOptions.msg = this.translateService.instant(alertOptions.msg, alertOptions.params);
2624 }
2625 const alert = this.factory(alertOptions);
2626 if (alertOptions.timeout && alertOptions.timeout > 0) {
2627 // Workaround protractor waiting for setTimeout.
2628 // Reference https://www.protractortest.org/#/timeouts
2629 this.ngZone.runOutsideAngular(() => {
2630 setTimeout(() => {
2631 this.ngZone.run(() => {
2632 this.closeAlert(alertOptions.id, extAlerts);
2633 });
2634 }, alertOptions.timeout);
2635 });
2636 }
2637 return alert;
2638 }
2639 closeAlert(id, extAlerts) {
2640 const thisAlerts = extAlerts && extAlerts.length > 0 ? extAlerts : this.alerts;
2641 return this.closeAlertByIndex(thisAlerts.map(e => e.id).indexOf(id), thisAlerts);
2642 }
2643 closeAlertByIndex(index, thisAlerts) {
2644 return thisAlerts.splice(index, 1);
2645 }
2646 isToast() {
2647 return this.toast;
2648 }
2649 factory(alertOptions) {
2650 const alert = {
2651 type: alertOptions.type,
2652 msg: this.sanitizer.sanitize(SecurityContext.HTML, alertOptions.msg),
2653 id: alertOptions.id,
2654 timeout: alertOptions.timeout,
2655 toast: alertOptions.toast,
2656 position: alertOptions.position ? alertOptions.position : 'top right',
2657 scoped: alertOptions.scoped,
2658 close: (alerts) => {
2659 return this.closeAlert(alertOptions.id, alerts);
2660 }
2661 };
2662 if (!alert.scoped) {
2663 this.alerts.push(alert);
2664 }
2665 return alert;
2666 }
2667}
2668JhiAlertService.ɵprov = ɵɵdefineInjectable({ factory: function JhiAlertService_Factory() { return new JhiAlertService(ɵɵinject(DomSanitizer), ɵɵinject(JhiConfigService), ɵɵinject(NgZone), ɵɵinject(TranslateService, 8)); }, token: JhiAlertService, providedIn: "root" });
2669JhiAlertService.decorators = [
2670 { type: Injectable, args: [{
2671 providedIn: 'root'
2672 },] }
2673];
2674JhiAlertService.ctorParameters = () => [
2675 { type: DomSanitizer },
2676 { type: JhiConfigService },
2677 { type: NgZone },
2678 { type: TranslateService, decorators: [{ type: Optional }] }
2679];
2680
2681/*
2682 Copyright 2013-2020 the original author or authors from the JHipster project.
2683
2684 This file is part of the JHipster project, see https://www.jhipster.tech/
2685 for more information.
2686
2687 Licensed under the Apache License, Version 2.0 (the "License");
2688 you may not use this file except in compliance with the License.
2689 You may obtain a copy of the License at
2690
2691 http://www.apache.org/licenses/LICENSE-2.0
2692
2693 Unless required by applicable law or agreed to in writing, software
2694 distributed under the License is distributed on an "AS IS" BASIS,
2695 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2696 See the License for the specific language governing permissions and
2697 limitations under the License.
2698 */
2699class JhiBase64Service {
2700 constructor() {
2701 this.keyStr = 'ABCDEFGHIJKLMNOP' + 'QRSTUVWXYZabcdef' + 'ghijklmnopqrstuv' + 'wxyz0123456789+/' + '=';
2702 }
2703 encode(input) {
2704 let output = '';
2705 let enc1 = '';
2706 let enc2 = '';
2707 let enc3 = '';
2708 let enc4 = '';
2709 let chr1 = '';
2710 let chr2 = '';
2711 let chr3 = '';
2712 let i = 0;
2713 while (i < input.length) {
2714 chr1 = input.charCodeAt(i++);
2715 chr2 = input.charCodeAt(i++);
2716 chr3 = input.charCodeAt(i++);
2717 enc1 = chr1 >> 2;
2718 enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
2719 enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
2720 enc4 = chr3 & 63;
2721 if (isNaN(chr2)) {
2722 enc3 = enc4 = 64;
2723 }
2724 else if (isNaN(chr3)) {
2725 enc4 = 64;
2726 }
2727 output = output + this.keyStr.charAt(enc1) + this.keyStr.charAt(enc2) + this.keyStr.charAt(enc3) + this.keyStr.charAt(enc4);
2728 chr1 = chr2 = chr3 = '';
2729 enc1 = enc2 = enc3 = enc4 = '';
2730 }
2731 return output;
2732 }
2733 decode(input) {
2734 let output = '';
2735 let enc1 = '';
2736 let enc2 = '';
2737 let enc3 = '';
2738 let enc4 = '';
2739 let chr1 = '';
2740 let chr2 = '';
2741 let chr3 = '';
2742 let i = 0;
2743 // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
2744 input = input.replace(/[^A-Za-z0-9+/=]/g, '');
2745 while (i < input.length) {
2746 enc1 = this.keyStr.indexOf(input.charAt(i++));
2747 enc2 = this.keyStr.indexOf(input.charAt(i++));
2748 enc3 = this.keyStr.indexOf(input.charAt(i++));
2749 enc4 = this.keyStr.indexOf(input.charAt(i++));
2750 chr1 = (enc1 << 2) | (enc2 >> 4);
2751 chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
2752 chr3 = ((enc3 & 3) << 6) | enc4;
2753 output = output + String.fromCharCode(chr1);
2754 if (enc3 !== 64) {
2755 output = output + String.fromCharCode(chr2);
2756 }
2757 if (enc4 !== 64) {
2758 output = output + String.fromCharCode(chr3);
2759 }
2760 chr1 = chr2 = chr3 = '';
2761 enc1 = enc2 = enc3 = enc4 = '';
2762 }
2763 return output;
2764 }
2765}
2766JhiBase64Service.ɵprov = ɵɵdefineInjectable({ factory: function JhiBase64Service_Factory() { return new JhiBase64Service(); }, token: JhiBase64Service, providedIn: "root" });
2767JhiBase64Service.decorators = [
2768 { type: Injectable, args: [{
2769 providedIn: 'root'
2770 },] }
2771];
2772
2773/*
2774 Copyright 2013-2020 the original author or authors from the JHipster project.
2775
2776 This file is part of the JHipster project, see https://www.jhipster.tech/
2777 for more information.
2778
2779 Licensed under the Apache License, Version 2.0 (the "License");
2780 you may not use this file except in compliance with the License.
2781 You may obtain a copy of the License at
2782
2783 http://www.apache.org/licenses/LICENSE-2.0
2784
2785 Unless required by applicable law or agreed to in writing, software
2786 distributed under the License is distributed on an "AS IS" BASIS,
2787 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2788 See the License for the specific language governing permissions and
2789 limitations under the License.
2790 */
2791class JhiResolvePagingParams {
2792 constructor(paginationUtil) {
2793 this.paginationUtil = paginationUtil;
2794 }
2795 resolve(route, state) {
2796 const page = route.queryParams['page'] ? route.queryParams['page'] : '1';
2797 const defaultSort = route.data['defaultSort'] ? route.data['defaultSort'] : 'id,asc';
2798 const sort = route.queryParams['sort'] ? route.queryParams['sort'] : defaultSort;
2799 return {
2800 page: this.paginationUtil.parsePage(page),
2801 predicate: this.paginationUtil.parsePredicate(sort),
2802 ascending: this.paginationUtil.parseAscending(sort)
2803 };
2804 }
2805}
2806JhiResolvePagingParams.ɵprov = ɵɵdefineInjectable({ factory: function JhiResolvePagingParams_Factory() { return new JhiResolvePagingParams(ɵɵinject(JhiPaginationUtil)); }, token: JhiResolvePagingParams, providedIn: "root" });
2807JhiResolvePagingParams.decorators = [
2808 { type: Injectable, args: [{
2809 providedIn: 'root'
2810 },] }
2811];
2812JhiResolvePagingParams.ctorParameters = () => [
2813 { type: JhiPaginationUtil }
2814];
2815
2816/*
2817 Copyright 2013-2020 the original author or authors from the JHipster project.
2818
2819 This file is part of the JHipster project, see https://www.jhipster.tech/
2820 for more information.
2821
2822 Licensed under the Apache License, Version 2.0 (the "License");
2823 you may not use this file except in compliance with the License.
2824 You may obtain a copy of the License at
2825
2826 http://www.apache.org/licenses/LICENSE-2.0
2827
2828 Unless required by applicable law or agreed to in writing, software
2829 distributed under the License is distributed on an "AS IS" BASIS,
2830 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2831 See the License for the specific language governing permissions and
2832 limitations under the License.
2833 */
2834
2835/*
2836 Copyright 2013-2020 the original author or authors from the JHipster project.
2837
2838 This file is part of the JHipster project, see https://www.jhipster.tech/
2839 for more information.
2840
2841 Licensed under the Apache License, Version 2.0 (the "License");
2842 you may not use this file except in compliance with the License.
2843 You may obtain a copy of the License at
2844
2845 http://www.apache.org/licenses/LICENSE-2.0
2846
2847 Unless required by applicable law or agreed to in writing, software
2848 distributed under the License is distributed on an "AS IS" BASIS,
2849 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2850 See the License for the specific language governing permissions and
2851 limitations under the License.
2852 */
2853
2854/**
2855 * Generated bundle index. Do not edit.
2856 */
2857
2858export { JhiAlertService, JhiBase64Service, JhiBooleanComponent, JhiCapitalizePipe, JhiConfigService, JhiDataUtils, JhiDateUtils, JhiEventManager, JhiEventWithContent, JhiFilterPipe, JhiItemCountComponent, JhiKeysPipe, JhiLanguageService, JhiMaxValidatorDirective, JhiMaxbytesValidatorDirective, JhiMinValidatorDirective, JhiMinbytesValidatorDirective, JhiMissingTranslationHandler, JhiModuleConfig, JhiOrderByPipe, JhiPaginationUtil, JhiParseLinks, JhiPureFilterPipe, JhiResolvePagingParams, JhiSortByDirective, JhiSortDirective, JhiTranslateDirective, JhiTruncateCharactersPipe, JhiTruncateWordsPipe, NgJhipsterModule, missingTranslationHandler, translatePartialLoader, JHI_PIPES as ɵa, JHI_DIRECTIVES as ɵb, JHI_COMPONENTS as ɵc, JhiJvmMemoryComponent as ɵd, JhiJvmThreadsComponent as ɵe, JhiMetricsHttpRequestComponent as ɵf, JhiMetricsEndpointsRequestsComponent as ɵg, JhiMetricsCacheComponent as ɵh, JhiMetricsDatasourceComponent as ɵi, JhiMetricsSystemComponent as ɵj, JhiMetricsGarbageCollectorComponent as ɵk, JhiThreadModalComponent as ɵl };
2859//# sourceMappingURL=ng-jhipster.js.map