33 * SPDX-License-Identifier: Apache-2.0
44 **********************************************************************/
55
6- import { Component , OnDestroy , OnInit , inject , signal } from '@angular/core'
6+ import { Component , OnDestroy , OnInit , computed , inject , signal } from '@angular/core'
77import { ReactiveFormsModule } from '@angular/forms'
88import { MatList , MatListItem , MatListItemTitle , MatListItemLine , MatListModule } from '@angular/material/list'
99import { provideNativeDateAdapter } from '@angular/material/core'
@@ -12,7 +12,7 @@ import { MatTooltip } from '@angular/material/tooltip'
1212import { MatSidenavContainer , MatSidenav , MatSidenavContent } from '@angular/material/sidenav'
1313import { DeviceToolbarComponent } from '../device-toolbar/device-toolbar.component'
1414import { ActivatedRoute , RouterLink , RouterLinkActive } from '@angular/router'
15- import { Subject , takeUntil } from 'rxjs'
15+ import { catchError , of , Subject , switchMap , takeUntil } from 'rxjs'
1616import { ExplorerComponent } from '../explorer/explorer.component'
1717import { AlarmsComponent } from '../alarms/alarms.component'
1818import { CertificatesComponent } from '../certificates/certificates.component'
@@ -21,11 +21,23 @@ import { AuditLogComponent } from '../audit-log/audit-log.component'
2121import { HardwareInformationComponent } from '../hardware-information/hardware-information.component'
2222import { SolComponent } from '../sol/sol.component'
2323import { KvmComponent } from '../kvm/kvm.component'
24+ import { IderComponent } from '../ider/ider.component'
2425import { GeneralComponent } from '../general/general.component'
2526import { NetworkSettingsComponent } from '../network-settings/network-settings.component'
2627import { environment } from '../../../environments/environment'
2728import { TLSComponent } from '../tls/tls.component'
28- import { TranslatePipe } from '@ngx-translate/core'
29+ import { TranslatePipe , TranslateService } from '@ngx-translate/core'
30+ import { DevicesService } from '../devices.service'
31+ import SnackbarDefaults from '../../shared/config/snackBarDefault'
32+ import { MatSnackBar } from '@angular/material/snack-bar'
33+
34+ interface DeviceDetailCategory {
35+ name : string
36+ description : string
37+ description2 ?: string
38+ component : string
39+ icon : string
40+ }
2941
3042@Component ( {
3143 selector : 'app-device-detail' ,
@@ -40,6 +52,7 @@ import { TranslatePipe } from '@ngx-translate/core'
4052 HardwareInformationComponent ,
4153 SolComponent ,
4254 KvmComponent ,
55+ IderComponent ,
4356 GeneralComponent ,
4457 ExplorerComponent ,
4558 DeviceToolbarComponent ,
@@ -62,67 +75,78 @@ import { TranslatePipe } from '@ngx-translate/core'
6275 ]
6376} )
6477export class DeviceDetailComponent implements OnInit , OnDestroy {
65- // Dependency Injection
6678 private readonly activatedRoute = inject ( ActivatedRoute )
79+ private readonly devicesService = inject ( DevicesService )
80+ private readonly translate = inject ( TranslateService )
81+ private readonly snackBar = inject ( MatSnackBar )
6782 private readonly destroy$ = new Subject < void > ( )
83+ private readonly ismSku = '16400'
6884 public deviceId = ''
6985 public readonly isCloudMode : boolean = environment . cloud
70-
71- categories = [
72- {
73- name : 'deviceDetail.general.value' ,
74- description : 'deviceDetail.generalDescription.value' ,
75- description2 : '' ,
76- component : 'general' ,
77- icon : 'info'
78- } ,
79- {
80- name : 'deviceDetail.kvm.value' ,
81- description : 'deviceDetail.kvmDescription.value' ,
82- component : 'kvm' ,
83- icon : 'tv'
84- } ,
85- {
86- name : 'deviceDetail.sol.value' ,
87- description : 'deviceDetail.solDescription.value' ,
88- component : 'sol' ,
89- icon : 'keyboard'
90- } ,
91- {
92- name : 'deviceDetail.hardwareInfo.value' ,
93- description : 'deviceDetail.hardwareInfoDescription.value' ,
94- component : 'hardware-info' ,
95- icon : 'memory'
96- } ,
97- {
98- name : 'deviceDetail.auditLog.value' ,
99- description : 'deviceDetail.auditLogDescription.value' ,
100- component : 'audit-log' ,
101- icon : 'history'
102- } ,
103- {
104- name : 'deviceDetail.eventLog.value' ,
105- description : 'deviceDetail.eventLogDescription.value' ,
106- component : 'event-log' ,
107- icon : 'event_list'
108- } ,
109- {
110- name : 'deviceDetail.alarms.value' ,
111- description : 'deviceDetail.alarmsDescription.value' ,
112- component : 'alarms' ,
113- icon : 'alarm'
114- } ,
115- {
116- name : 'deviceDetail.certificates.value' ,
117- description : 'deviceDetail.certificatesDescription.value' ,
118- component : 'certificates' ,
119- icon : 'verified'
120- }
121- ]
122-
123- constructor ( ) {
86+ public isISMSystem = signal ( false )
87+ public categories = computed ( ( ) => {
88+ const base : DeviceDetailCategory [ ] = [
89+ {
90+ name : 'deviceDetail.general.value' ,
91+ description : 'deviceDetail.generalDescription.value' ,
92+ description2 : '' ,
93+ component : 'general' ,
94+ icon : 'info'
95+ } ,
96+ {
97+ name : 'deviceDetail.kvm.value' ,
98+ description : 'deviceDetail.kvmDescription.value' ,
99+ component : 'kvm' ,
100+ icon : 'tv'
101+ } ,
102+ {
103+ name : 'deviceDetail.sol.value' ,
104+ description : 'deviceDetail.solDescription.value' ,
105+ component : 'sol' ,
106+ icon : 'keyboard'
107+ } ,
108+ {
109+ name : 'deviceDetail.hardwareInfo.value' ,
110+ description : 'deviceDetail.hardwareInfoDescription.value' ,
111+ component : 'hardware-info' ,
112+ icon : 'memory'
113+ } ,
114+ {
115+ name : 'deviceDetail.auditLog.value' ,
116+ description : 'deviceDetail.auditLogDescription.value' ,
117+ component : 'audit-log' ,
118+ icon : 'history'
119+ } ,
120+ {
121+ name : 'deviceDetail.eventLog.value' ,
122+ description : 'deviceDetail.eventLogDescription.value' ,
123+ component : 'event-log' ,
124+ icon : 'event_list'
125+ } ,
126+ {
127+ name : 'deviceDetail.alarms.value' ,
128+ description : 'deviceDetail.alarmsDescription.value' ,
129+ component : 'alarms' ,
130+ icon : 'alarm'
131+ } ,
132+ {
133+ name : 'deviceDetail.certificates.value' ,
134+ description : 'deviceDetail.certificatesDescription.value' ,
135+ component : 'certificates' ,
136+ icon : 'verified'
137+ } ,
138+ {
139+ name : 'deviceDetail.ider.value' ,
140+ description : 'deviceDetail.iderDescription.value' ,
141+ component : 'ider' ,
142+ icon : 'storage'
143+ }
144+ ]
145+ const filtered = base
146+ . filter ( ( c ) => ! ( this . isISMSystem ( ) && c . component === 'kvm' ) )
147+ . filter ( ( c ) => ! ( ! this . isISMSystem ( ) && c . component === 'ider' ) )
124148 if ( ! this . isCloudMode ) {
125- this . categories . push (
149+ filtered . push (
126150 {
127151 name : 'deviceDetail.explorer.value' ,
128152 description : 'deviceDetail.explorerDescription.value' ,
@@ -143,18 +167,43 @@ export class DeviceDetailComponent implements OnInit, OnDestroy {
143167 }
144168 )
145169 }
146- }
170+ return filtered
171+ } )
147172
148173 public currentView = 'general'
149174 public isLoading = signal ( false )
150175 isCollapsed = false
151176
152177 ngOnInit ( ) : void {
153- this . activatedRoute . params . pipe ( takeUntil ( this . destroy$ ) ) . subscribe ( ( params ) => {
154- this . isLoading . set ( true )
155- this . deviceId = params . id
156- this . currentView = params . component || 'general'
157- } )
178+ this . activatedRoute . params
179+ . pipe (
180+ takeUntil ( this . destroy$ ) ,
181+ switchMap ( ( params ) => {
182+ this . isLoading . set ( true )
183+ this . deviceId = params . id
184+ this . currentView = params . component || 'general'
185+ return this . devicesService . getAMTVersion ( this . deviceId ) . pipe (
186+ catchError ( ( ) => {
187+ const msg : string = this . translate . instant ( 'general.errorAMTVersion.value' )
188+ this . snackBar . open ( msg , undefined , SnackbarDefaults . defaultError )
189+ return of ( null )
190+ } )
191+ )
192+ } )
193+ )
194+ . subscribe ( {
195+ next : ( amtVersion ) => {
196+ const sku : string = amtVersion ?. CIM_SoftwareIdentity ?. responses [ 4 ] ?. VersionString ?? ''
197+ const isIsm = sku === this . ismSku
198+ this . isISMSystem . set ( isIsm )
199+ if ( isIsm && this . currentView === 'kvm' ) this . currentView = 'ider'
200+ if ( ! isIsm && this . currentView === 'ider' ) this . currentView = 'kvm'
201+ this . isLoading . set ( false )
202+ } ,
203+ error : ( ) => {
204+ this . isLoading . set ( false )
205+ }
206+ } )
158207 }
159208
160209 ngOnDestroy ( ) : void {
0 commit comments