diff --git a/src/app/core/admin/admin.service.ts b/src/app/core/admin/admin.service.ts index cf76d41bc..49199376e 100644 --- a/src/app/core/admin/admin.service.ts +++ b/src/app/core/admin/admin.service.ts @@ -68,10 +68,21 @@ export class AdminService extends BaseHttpService { return this.http.get< ScheduledJob >(job).pipe(retry(2), catchError(err => throwError(err))); } + public getEnvironmentHealth(serviceContext:string): Observable< any > { + //const url = `${(this.configService.configData && this.configService.configData.apiBaseUrl) || '/' }api/v1/`; + let url = `${(this.configService.configData && this.configService.configData.apiBaseUrl) || '/' }api/v1/health/info`; + url = url.replace('/api/v1/health/info', `/service/`+ serviceContext + `/api/v1/health/info`); - public getEnvironmentHealth(): Observable< any > { - const url = `${(this.configService.configData && this.configService.configData.apiBaseUrl) || '/' }api/v1/`; - return this.http.get< any >(`${url}health/info`); + const result = this.http.get< any >(url, { observe: 'response' }).pipe( + catchError((error: HttpErrorResponse) => { + return of(error); + })); + + +//http://localhost:8081/ginas/app/service/clinical-trials/api/v1/health/info + + // const url = `${(this.configService.configData && this.configService.configData.apiBaseUrl) || '/' }api/v1/`; + return result; } diff --git a/src/app/core/admin/cache-summary/cache-summary.component.html b/src/app/core/admin/cache-summary/cache-summary.component.html index 60eb96155..8d6dcaa70 100644 --- a/src/app/core/admin/cache-summary/cache-summary.component.html +++ b/src/app/core/admin/cache-summary/cache-summary.component.html @@ -1,127 +1,147 @@ -
-
- - Runtime Environment -
-
Epoch
-
{{health.epoch | date: 'medium'}}
-
- -
-
Uptime
-
{{runtime}}
-
+ +
+ + + Service + + + {{option}} + + + +
-
-
Server
-
{{health.hostname}}
-
-
-
Available Processors
-
{{health.runtime.availableProcessors}}
-
-
-
Free Memory
-
{{health.runtime.freeMemory/(1024*1024) | number : '1.1-1'}} Mb
-
+
+

Error Loading Health Information

+
-
-
Total Memory
-
{{health.runtime.totalMemory/(1024*1024) | number : '1.1-1'}} Mb
-
+
+
+ + Runtime Environment test +
+
Epoch
+
{{health.epoch | date: 'medium'}}
+
-
-
Max Memory
-
{{health.runtime.maxMemory/(1024*1024) | number : '1.1-1'}} Mb
-
+
+
Uptime
+
{{runtime}}
+
-
-
JRE Version
-
{{health.javaVersion}}
-
+
+
Server
+
{{health.hostname}}
+
+
+
Available Processors
+
{{health.runtime.availableProcessors}}
+
+
+
Free Memory
+
{{health.runtime.freeMemory/(1024*1024) | number : '1.1-1'}} Mb
+
-
-
Number of Threads
-
{{health.threads}}
-
+
+
Total Memory
+
{{health.runtime.totalMemory/(1024*1024) | number : '1.1-1'}} Mb
+
-
-
Number of Running Threads
-
{{health.runningThreads}}
-
+
+
Max Memory
+
{{health.runtime.maxMemory/(1024*1024) | number : '1.1-1'}} Mb
+
-
-
-
-
-
-
+
+
JRE Version
+
{{health.javaVersion}}
+
+ +
+
Number of Threads
+
{{health.threads}}
+
+ +
+
Number of Running Threads
+
{{health.runningThreads}}
+
+ +
+
+
+
+ +
-
- +
+ Cache Configuration -
-
Max Cache Elements
-
{{health.cacheInfo.maxCacheElements}}
-
-
+
+
Max Cache Elements
+
{{health.cacheInfo.maxCacheElements}}
+
+
Max Evictable Cache Elements
{{health.cacheInfo.maxNotEvictableCacheElements}}
-
-
+
+
Time to Live (seconds)
{{health.cacheInfo.timeToLive}}
-
-
+
+
Time to Idle (seconds)
{{health.cacheInfo.timeToIdle}}
-
- -
-
- - Database Information -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Database {{db.database}} Driver {{db.driver}} Product {{db.product}} Latency {{db.latency}} ms Connected {{db.connected}} Max Connections {{db.maxConnectionPool ? db.maxConnectionPool : 'N/A'}} Active Connections {{db.activeConnection ? db.activeConnection : 'N/A'}} Connection Usage - {{ db.activeConnection && db.maxConnectionPool ? - (100-((db.maxConnectionPool - db.activeConnection) / db.maxConnectionPool * 100) | number : '1.1-2') + '%' : 'N/A' - }}
+
+
+
+
+ + Database Information +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Database {{db.database}} Driver {{db.driver}} Product {{db.product}} Latency {{db.latency}} ms Connected {{db.connected}} Max Connections {{db.maxConnectionPool ? db.maxConnectionPool : 'N/A'}} Active Connections {{db.activeConnection ? db.activeConnection : 'N/A'}} Connection Usage + {{ db.activeConnection && db.maxConnectionPool ? + (100-((db.maxConnectionPool - db.activeConnection) / db.maxConnectionPool * 100) | number : + '1.1-2') + '%' : 'N/A' + }}
+
+
+ +
-
-
\ No newline at end of file diff --git a/src/app/core/admin/cache-summary/cache-summary.component.ts b/src/app/core/admin/cache-summary/cache-summary.component.ts index 846ec4b8f..43e2dd1ff 100644 --- a/src/app/core/admin/cache-summary/cache-summary.component.ts +++ b/src/app/core/admin/cache-summary/cache-summary.component.ts @@ -2,64 +2,99 @@ import { Component, OnInit, OnDestroy } from '@angular/core'; import { HealthInfo } from '@gsrs-core/admin/admin-objects.model'; import { AuthService } from '@gsrs-core/auth'; import { AdminService } from '@gsrs-core/admin/admin.service'; -import { Subscription } from 'rxjs'; +import { Subscription, take } from 'rxjs'; import * as moment from 'moment'; +import { MatSelectChange } from '@angular/material/select'; +import { ConfigService } from '@gsrs-core/config'; +import * as _ from 'lodash'; +import { H } from '@angular/cdk/keycodes'; @Component({ - selector: 'app-cache-summary', - templateUrl: './cache-summary.component.html', - styleUrls: ['./cache-summary.component.scss'], - standalone: false + selector: 'app-cache-summary', + templateUrl: './cache-summary.component.html', + styleUrls: ['./cache-summary.component.scss'], + standalone: false }) export class CacheSummaryComponent implements OnInit, OnDestroy { displayedColumns: string[] = ['database', 'driver', 'product', 'latency', 'connected', 'max', 'active', 'usage']; health: HealthInfo; sub: Subscription; runtime = ''; + currentService: string = 'substances'; + services: Array = []; + loading: boolean; + isError: boolean; + constructor( - private adminService: AdminService + private adminService: AdminService, + private configService: ConfigService ) { } ngOnInit() { - this.sub = this.adminService.getEnvironmentHealth().subscribe(response => { - this.health = response; + + let activeServices = _.filter(this.configService.configData?.services || [], { 'active': true, 'hasEntities': true }); // for now the gsrs starter is not a dependency of non-entity services, so we will only show those that have entities. This will be changed in the future. + + this.services = _.map(activeServices, "name",).sort(); + //this.loading = true; + // setTimeout(() => { + // this.adminService.fetchJobs(this.currentService).pipe(take(1)).subscribe( resp => { + // this.loading = false; + // //this.jobs = resp.content; + // }); + // }, 1000); + + this.reloadHealth(); + } + + reloadHealth() { + this.isError = false; - this.setStart(); - }); + this.sub = this.adminService.getEnvironmentHealth(this.currentService).subscribe(response => { + //this.loading = true; + if (response.status != 200) { + this.isError = true; + } + this.health = response.body; + this.setStart(); + //this.loading = false; + }); } setStart() { if (this.health.epoch) { const date = new Date(); - const duration = moment.duration((( date.getTime() - 0) - this.health.epoch)); + const duration = moment.duration(((date.getTime() - 0) - this.health.epoch)); let timestring = ''; - if ( duration.years() !== 0) { + if (duration.years() !== 0) { timestring += duration.years() + (duration.years() > 1 ? ' years, ' : ' year, '); } - if ( duration.months() !== 0) { + if (duration.months() !== 0) { timestring += duration.months() + (duration.months() > 1 ? ' months, ' : ' month, '); } - if ( duration.days() !== 0) { + if (duration.days() !== 0) { timestring += duration.days() + (duration.days() > 1 ? ' days, ' : ' day, '); } - if ( duration.hours() !== 0) { + if (duration.hours() !== 0) { timestring += duration.hours() + (duration.hours() > 1 ? ' hrs, ' : ' hr, '); } - if ( duration.minutes() !== 0) { + if (duration.minutes() !== 0) { timestring += duration.minutes() + (duration.minutes() > 1 ? ' min, ' : ' min, '); } - if ( duration.seconds() !== 0) { + if (duration.seconds() !== 0) { timestring += duration.seconds() + (duration.seconds() > 1 ? ' sec' : ' sec'); } else if (timestring === '') { - timestring = (( date.getTime() - 0) - this.health.epoch) + ' ms'; + timestring = ((date.getTime() - 0) - this.health.epoch) + ' ms'; } this.runtime = timestring; + } } -} + onServiceSelectionChange(event: MatSelectChange) { + this.currentService = event.value; + this.reloadHealth(); + } ngOnDestroy() { - this.sub.unsubscribe(); + this.sub.unsubscribe(); } - } diff --git a/src/app/core/admin/scheduled-jobs/scheduled-jobs.component.html b/src/app/core/admin/scheduled-jobs/scheduled-jobs.component.html index 576ce3884..a9ca8bd4a 100644 --- a/src/app/core/admin/scheduled-jobs/scheduled-jobs.component.html +++ b/src/app/core/admin/scheduled-jobs/scheduled-jobs.component.html @@ -1,6 +1,7 @@
+ Service