@@ -33,6 +33,11 @@ function ACPUTable({ device, update, notify }) {
3333 const [ disable , setDisable ] = React . useState ( true ) ;
3434 const loadActivity = GetOptions ( 'A45_Load' ) ;
3535
36+ // Toggle handler to enable/disable ACPU fields
37+ const handleToggle = ( ) => {
38+ setDisable ( ! disable ) ;
39+ } ;
40+
3641 function fetchPort ( port , link ) {
3742 server . GET ( server . peripheralPath ( device , `${ link } /${ port . href } ` ) , ( data ) => {
3843 const ep = parseInt ( port . href . slice ( - 1 ) , 10 ) ;
@@ -46,7 +51,6 @@ function ACPUTable({ device, update, notify }) {
4651 function fetchAcpuData ( link ) {
4752 if ( link !== '' ) {
4853 server . GET ( server . peripheralPath ( device , link ) , ( data ) => {
49- // resolve cycling
5054 if ( data . name !== acpuData . name
5155 || data . frequency !== acpuData . frequency
5256 || data . load !== acpuData . load ) {
@@ -75,7 +79,7 @@ function ACPUTable({ device, update, notify }) {
7579 function fetchData ( ) {
7680 server . GET ( server . api . fetch ( server . Elem . peripherals , device ) , ( data ) => {
7781 const acpu = getPeripherals ( data , 'acpu' ) ;
78- setDisable ( acpu . length === 0 ) ;
82+ setDisable ( true ) ;
7983 if ( acpu . length > 0 ) {
8084 const link = acpu [ 0 ] . href ;
8185 setHref ( link ) ;
@@ -124,7 +128,6 @@ function ACPUTable({ device, update, notify }) {
124128 }
125129
126130 const deleteRow = ( index ) => {
127- // no delete method for acpu. this is just clear name of the endpoint which mean disable
128131 const val = endpoints [ index ] . data ;
129132 val . name = '' ;
130133 server . PATCH ( server . peripheralPath ( device , `${ href } /ep/${ endpoints [ index ] . ep } ` ) , val , ( ) => fetchAcpuData ( href ) ) ;
@@ -147,9 +150,20 @@ function ACPUTable({ device, update, notify }) {
147150
148151 const powerHeader = [ 'Power' , '%' ] ;
149152 const title = 'ACPU' ;
153+
150154 return (
151155 < div className = "component-table-head" >
152156 < ComponentLabel name = { title } />
157+
158+ { /* Toggle Switch for ACPU */ }
159+ < div className = "toggle-container" >
160+ < label htmlFor = "acpu-toggle" > ACPU Power</ label >
161+ < label className = "toggle-switch" >
162+ < input type = "checkbox" onChange = { handleToggle } checked = { ! disable } />
163+ < span className = "slider" />
164+ </ label >
165+ </ div >
166+
153167 < div className = "cpu-container" >
154168 < PowerTable
155169 title = "ACPU power"
@@ -172,28 +186,28 @@ function ACPUTable({ device, update, notify }) {
172186 < Dropdown value = { acpuData . load } onChangeHandler = { ( value ) => handleChange ( 'load' , value ) } items = { loadActivity } disabled = { disable } />
173187 </ div >
174188 </ div >
189+
175190 < TableBase header = { header } disabled = { disable } onClick = { ( ) => setModalOpen ( true ) } >
176- {
177- endpoints . map ( ( row , index ) => (
178- ( row . data !== undefined && row . data . name !== '' )
179- && (
180- < tr key = { row . ep } >
181- < StatusColumn messages = { row . data . consumption . messages } />
182- < Actions
183- onEditClick = { ( ) => { setEditIndex ( index ) ; setModalOpen ( true ) ; } }
184- onDeleteClick = { ( ) => deleteRow ( index ) }
185- />
186- < td > { row . data . name } </ td >
187- < SelectionCell val = { row . data . activity } values = { loadActivity } />
188- < PercentsCell val = { row . data . read_write_rate } />
189- < PercentsCell val = { row . data . toggle_rate } precition = { 1 } />
190- < BandwidthCell val = { row . data . consumption . calculated_bandwidth } />
191- < PowerCell val = { row . data . consumption . noc_power } />
192- </ tr >
193- )
194- ) )
195- }
191+ { endpoints . map ( ( row , index ) => (
192+ ( row . data !== undefined && row . data . name !== '' )
193+ && (
194+ < tr key = { row . ep } >
195+ < StatusColumn messages = { row . data . consumption . messages } />
196+ < Actions
197+ onEditClick = { ( ) => { setEditIndex ( index ) ; setModalOpen ( true ) ; } }
198+ onDeleteClick = { ( ) => deleteRow ( index ) }
199+ />
200+ < td > { row . data . name } </ td >
201+ < SelectionCell val = { row . data . activity } values = { loadActivity } />
202+ < PercentsCell val = { row . data . read_write_rate } />
203+ < PercentsCell val = { row . data . toggle_rate } precition = { 1 } />
204+ < BandwidthCell val = { row . data . consumption . calculated_bandwidth } />
205+ < PowerCell val = { row . data . consumption . noc_power } />
206+ </ tr >
207+ )
208+ ) ) }
196209 </ TableBase >
210+
197211 { modalOpen && (
198212 < ABCPUModal
199213 title = { title }
0 commit comments