-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NXP-32252: admin-console-nuxeo-server-information
- Loading branch information
1 parent
fef5bc4
commit 6b1f3a4
Showing
10 changed files
with
171 additions
and
6 deletions.
There are no files selected for viewing
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
15 changes: 12 additions & 3 deletions
15
...dmin-home/components/admin-registration-version/admin-registration-version.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
<mat-card role="region" aria-label="registration-version"> | ||
<mat-card-content>Registration and Version Info</mat-card-content> | ||
<button mat-flat-button color="primary">Details</button> | ||
</mat-card> | ||
<mat-card-content>Registration and Version Info</mat-card-content> | ||
<ng-container *ngIf="probesInfo$ | async as probesInfo"> | ||
<p class="version"> | ||
<span class="label">Server Version:</span> {{ probesInfo.version }} | ||
</p> | ||
<p class="cluster"> | ||
<span class="label">Cluster Enabled:</span> | ||
{{ probesInfo.clusterEnabled }} | ||
</p> | ||
</ng-container> | ||
<button mat-flat-button color="primary">Details</button> | ||
</mat-card> |
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
31 changes: 29 additions & 2 deletions
31
.../admin-home/components/admin-registration-version/admin-registration-version.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,8 +1,35 @@ | ||
import { Component } from "@angular/core"; | ||
import { Component, OnInit } from "@angular/core"; | ||
import { Store, select } from "@ngrx/store"; | ||
import { Observable } from "rxjs"; | ||
import { AdminHomeService } from "../../services/admin-home-service"; | ||
import * as AdminHomeActions from "../../store/actions"; | ||
import { AdminState } from "../../store/reducers"; | ||
|
||
@Component({ | ||
selector: "admin-registration-version", | ||
templateUrl: "./admin-registration-version.component.html", | ||
styleUrls: ["./admin-registration-version.component.scss"], | ||
}) | ||
export class AdminRegistrationVersionComponent {} | ||
export class AdminRegistrationVersionComponent implements OnInit { | ||
probesInfo$: Observable<{ | ||
version: string | null; | ||
clusterEnabled: boolean | null; | ||
}>; | ||
loading$: Observable<boolean>; | ||
error$: Observable<any>; | ||
|
||
constructor( | ||
private store: Store<{ admin: AdminState }>, | ||
private adminHomeService: AdminHomeService | ||
) { | ||
this.probesInfo$ = this.store.pipe( | ||
select((state) => state.admin.probesInfo) | ||
); | ||
this.loading$ = this.store.pipe(select((state) => state.admin.loading)); | ||
this.error$ = this.store.pipe(select((state) => state.admin.error)); | ||
} | ||
|
||
ngOnInit(): void { | ||
this.store.dispatch(AdminHomeActions.fetchVersionInfo()); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/app/features/admin-home/services/admin-home-service.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Injectable } from "@angular/core"; | ||
import { HttpClient } from "@angular/common/http"; | ||
import { Observable } from "rxjs"; | ||
import { environment } from "../../../../environments/environment"; | ||
import { VersionInfo } from "../../../shared/types/versionInfo.interface"; | ||
|
||
@Injectable({ | ||
providedIn: "root", | ||
}) | ||
export class AdminHomeService { | ||
private readonly jsonFilePath = environment.apiUrl + "/version-info.json"; | ||
|
||
constructor(private http: HttpClient) {} | ||
|
||
getVersionInfo(): Observable<VersionInfo> { | ||
return this.http.get<VersionInfo>(this.jsonFilePath); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createAction, props } from "@ngrx/store"; | ||
|
||
export const fetchVersionInfo = createAction("[Admin] Fetch Version Info"); | ||
export const fetchVersionInfoSuccess = createAction( | ||
"[Admin] Fetch Version Info Success", | ||
props<{ probesInfo: { version: string; clusterEnabled: boolean } }>() | ||
); | ||
export const fetchVersionInfoFailure = createAction( | ||
"[Admin] Fetch Version Info Failure", | ||
props<{ error: any }>() | ||
); |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { HttpErrorResponse } from "@angular/common/http"; | ||
import { inject } from "@angular/core"; | ||
import { Actions, createEffect, ofType } from "@ngrx/effects"; | ||
import { catchError, map, of, switchMap } from "rxjs"; | ||
import { AdminHomeService } from "../services/admin-home-service"; | ||
import * as AdminHomeActions from "../store/actions"; | ||
|
||
export const loadVersionInfoEffect = createEffect( | ||
(actions$ = inject(Actions), adminHomeService = inject(AdminHomeService)) => { | ||
return actions$.pipe( | ||
ofType(AdminHomeActions.fetchVersionInfo), | ||
switchMap(() => { | ||
return adminHomeService.getVersionInfo().pipe( | ||
map((data) => { | ||
return AdminHomeActions.fetchVersionInfoSuccess({ | ||
probesInfo: { | ||
version: data.version, | ||
clusterEnabled: data.clusterEnabled, | ||
}, | ||
}); | ||
}), | ||
catchError((error: HttpErrorResponse) => { | ||
return of(AdminHomeActions.fetchVersionInfoFailure({ error })); | ||
}) | ||
); | ||
}) | ||
); | ||
}, | ||
{ functional: true } | ||
); |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { createReducer, on } from "@ngrx/store"; | ||
import * as AdminHomeActions from "./actions"; //AdminHomeActions // ProbesInfo | ||
|
||
export interface AdminState { | ||
probesInfo: { | ||
version: string | null; | ||
clusterEnabled: boolean | null; | ||
}; | ||
loading: boolean; | ||
error: any; | ||
} | ||
|
||
export const initialState: AdminState = { | ||
probesInfo: { | ||
version: null, | ||
clusterEnabled: null, | ||
}, | ||
loading: false, | ||
error: null, | ||
}; | ||
|
||
export const adminHomeReducer = createReducer( | ||
initialState, | ||
on(AdminHomeActions.fetchVersionInfo, (state) => ({ | ||
...state, | ||
loading: true, | ||
error: null, | ||
})), | ||
on(AdminHomeActions.fetchVersionInfoSuccess, (state, { probesInfo }) => ({ | ||
...state, | ||
probesInfo: { | ||
version: probesInfo.version, | ||
clusterEnabled: probesInfo.clusterEnabled, | ||
}, | ||
loading: false, | ||
})), | ||
on(AdminHomeActions.fetchVersionInfoFailure, (state, { error }) => ({ | ||
...state, | ||
error, | ||
loading: false, | ||
})) | ||
); |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface VersionInfo { | ||
version: string; | ||
clusterEnabled: boolean; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"version": "Nuxeo Platform 2021.45.8", | ||
"clusterEnabled": true | ||
} |