-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Development: Migrate admin metrics Angular code to new best practices
- Loading branch information
Showing
27 changed files
with
1,334 additions
and
416 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/main/webapp/app/admin/metrics/blocks/jvm-memory/jvm-memory.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 11 additions & 3 deletions
14
src/main/webapp/app/admin/metrics/blocks/jvm-memory/jvm-memory.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { ChangeDetectionStrategy, Component, input } from '@angular/core'; | ||
|
||
import { JvmMetrics } from 'app/admin/metrics/metrics.model'; | ||
import { TranslateDirective } from 'app/shared/language/translate.directive'; | ||
import { NgbProgressbar } from '@ng-bootstrap/ng-bootstrap'; | ||
import { DecimalPipe, KeyValuePipe } from '@angular/common'; | ||
|
||
@Component({ | ||
selector: 'jhi-jvm-memory', | ||
templateUrl: './jvm-memory.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [TranslateDirective, NgbProgressbar, DecimalPipe, KeyValuePipe], | ||
}) | ||
export class JvmMemoryComponent { | ||
/** | ||
* object containing all jvm memory metrics | ||
*/ | ||
@Input() jvmMemoryMetrics?: { [key: string]: JvmMetrics }; | ||
jvmMemoryMetrics = input.required<{ | ||
[key: string]: JvmMetrics; | ||
}>(); | ||
|
||
/** | ||
* boolean field saying if the metrics are in the process of being updated | ||
*/ | ||
@Input() updating?: boolean; | ||
updating = input<boolean>(false); | ||
} |
26 changes: 13 additions & 13 deletions
26
src/main/webapp/app/admin/metrics/blocks/jvm-threads/jvm-threads.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 41 additions & 33 deletions
74
src/main/webapp/app/admin/metrics/blocks/jvm-threads/jvm-threads.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,60 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; | ||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, effect, inject, input, signal } from '@angular/core'; | ||
import { NgbModal, NgbProgressbar } from '@ng-bootstrap/ng-bootstrap'; | ||
|
||
import { Thread, ThreadState } from 'app/admin/metrics/metrics.model'; | ||
import { MetricsModalThreadsComponent } from '../metrics-modal-threads/metrics-modal-threads.component'; | ||
import { TranslateDirective } from 'app/shared/language/translate.directive'; | ||
import { DecimalPipe } from '@angular/common'; | ||
|
||
@Component({ | ||
selector: 'jhi-jvm-threads', | ||
templateUrl: './jvm-threads.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [TranslateDirective, NgbProgressbar, DecimalPipe], | ||
}) | ||
export class JvmThreadsComponent { | ||
threadStats = { | ||
threadDumpAll: 0, | ||
threadDumpRunnable: 0, | ||
threadDumpTimedWaiting: 0, | ||
threadDumpWaiting: 0, | ||
threadDumpBlocked: 0, | ||
}; | ||
|
||
@Input() | ||
set threads(threads: Thread[] | undefined) { | ||
this._threads = threads; | ||
|
||
threads?.forEach((thread) => { | ||
if (thread.threadState === ThreadState.Runnable) { | ||
this.threadStats.threadDumpRunnable += 1; | ||
} else if (thread.threadState === ThreadState.Waiting) { | ||
this.threadStats.threadDumpWaiting += 1; | ||
} else if (thread.threadState === ThreadState.TimedWaiting) { | ||
this.threadStats.threadDumpTimedWaiting += 1; | ||
} else if (thread.threadState === ThreadState.Blocked) { | ||
this.threadStats.threadDumpBlocked += 1; | ||
} | ||
}); | ||
threadStats = signal({ | ||
all: 0, | ||
runnable: 0, | ||
timedWaiting: 0, | ||
waiting: 0, | ||
blocked: 0, | ||
}); | ||
|
||
this.threadStats.threadDumpAll = | ||
this.threadStats.threadDumpRunnable + this.threadStats.threadDumpWaiting + this.threadStats.threadDumpTimedWaiting + this.threadStats.threadDumpBlocked; | ||
} | ||
private changeDetector = inject(ChangeDetectorRef); | ||
private modalService = inject(NgbModal); | ||
|
||
threads = input<Thread[]>([]); | ||
|
||
get threads(): Thread[] | undefined { | ||
return this._threads; | ||
constructor() { | ||
effect(() => this.computeThreadStats()); | ||
} | ||
|
||
private _threads: Thread[] | undefined; | ||
private computeThreadStats() { | ||
this.threads().forEach((thread) => { | ||
switch (thread.threadState) { | ||
case ThreadState.Runnable: | ||
this.threadStats().runnable += 1; | ||
break; | ||
case ThreadState.Waiting: | ||
this.threadStats().waiting += 1; | ||
break; | ||
case ThreadState.TimedWaiting: | ||
this.threadStats().timedWaiting += 1; | ||
break; | ||
case ThreadState.Blocked: | ||
this.threadStats().blocked += 1; | ||
break; | ||
} | ||
}); | ||
|
||
constructor(private modalService: NgbModal) {} | ||
this.threadStats().all = this.threadStats().runnable + this.threadStats().waiting + this.threadStats().timedWaiting + this.threadStats().blocked; | ||
this.changeDetector.markForCheck(); | ||
} | ||
|
||
open(): void { | ||
const modalRef = this.modalService.open(MetricsModalThreadsComponent, { size: 'xl' }); | ||
modalRef.componentInstance.threads = this.threads; | ||
modalRef.componentInstance.threads = this.threads(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
src/main/webapp/app/admin/metrics/blocks/metrics-cache/metrics-cache.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,28 @@ | ||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; | ||
import { ChangeDetectionStrategy, Component, input } from '@angular/core'; | ||
import { CacheMetrics } from 'app/admin/metrics/metrics.model'; | ||
import { filterNaN } from 'app/core/util/operators'; | ||
import { TranslateDirective } from 'app/shared/language/translate.directive'; | ||
import { DecimalPipe, KeyValuePipe } from '@angular/common'; | ||
|
||
@Component({ | ||
selector: 'jhi-metrics-cache', | ||
templateUrl: './metrics-cache.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [TranslateDirective, DecimalPipe, KeyValuePipe], | ||
}) | ||
export class MetricsCacheComponent { | ||
/** | ||
* object containing all cache related metrics | ||
*/ | ||
@Input() cacheMetrics?: { [key: string]: CacheMetrics }; | ||
cacheMetrics = input.required<{ | ||
[key: string]: CacheMetrics; | ||
}>(); | ||
|
||
/** | ||
* boolean field saying if the metrics are in the process of being updated | ||
*/ | ||
@Input() updating?: boolean; | ||
updating = input<boolean>(false); | ||
|
||
filterNaN = (input: number): number => filterNaN(input); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 7 additions & 3 deletions
10
src/main/webapp/app/admin/metrics/blocks/metrics-datasource/metrics-datasource.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; | ||
import { ChangeDetectionStrategy, Component, input } from '@angular/core'; | ||
import { Databases } from 'app/admin/metrics/metrics.model'; | ||
import { filterNaN } from 'app/core/util/operators'; | ||
import { TranslateDirective } from 'app/shared/language/translate.directive'; | ||
import { DecimalPipe } from '@angular/common'; | ||
|
||
@Component({ | ||
selector: 'jhi-metrics-datasource', | ||
templateUrl: './metrics-datasource.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [TranslateDirective, DecimalPipe], | ||
}) | ||
export class MetricsDatasourceComponent { | ||
/** | ||
* object containing all datasource related metrics | ||
*/ | ||
@Input() datasourceMetrics?: Databases; | ||
datasourceMetrics = input.required<Databases>(); | ||
|
||
/** | ||
* boolean field saying if the metrics are in the process of being updated | ||
*/ | ||
@Input() updating?: boolean; | ||
updating = input<boolean>(false); | ||
|
||
filterNaN = (input: number): number => filterNaN(input); | ||
} |
Oops, something went wrong.