fix: fix refresh power button issue.#3430
Closed
punam20 wants to merge 3 commits into
Closed
Conversation
punam20
marked this pull request as draft
July 13, 2026 03:42
https://github.com/device-management-toolkit/console/issues/1119 Clicking the Refresh Power Status icon does not retrieve the latest power state Signed-off-by: punam biswal <punam.biswal@intel.com>
DevipriyaS17
marked this pull request as ready for review
July 14, 2026 08:25
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #3440 by ensuring the Device Details toolbar refresh action fetches the latest device power state from the backend rather than returning a stale cached value.
Changes:
- Updated
DeviceToolbarComponent.getPowerState()to callDevicesService.getPowerState()(fresh HTTP) instead ofgetPowerStateCached(). - Updated the inline comment to reflect the new cache-bypass behavior.
Comment on lines
224
to
228
| this.devicesService | ||
| .getPowerStateCached(this.deviceId()) | ||
| .getPowerState(this.deviceId()) | ||
| .pipe(takeUntilDestroyed(this.destroyRef)) | ||
| .subscribe((powerState) => { | ||
| this.powerState.set( |
Comment on lines
+222
to
+223
| // Bypass the cache so a manual refresh always fetches the latest state from | ||
| // the device rather than returning a previously cached value. |
| // the device rather than returning a previously cached value. | ||
| this.devicesService | ||
| .getPowerStateCached(this.deviceId()) | ||
| .getPowerState(this.deviceId()) |
Contributor
|
closing the PR, as new PR opened #3441 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue - #3440 Clicking the Refresh Power Status icon does not retrieve the latest power state
Root Cause:
The getPowerState()]method in the toolbar component was calling devicesService.getPowerStateCached() a method that returns a cached value when one exists, without making a new HTTP request.
User opens device detail page
ngOnInit() calls getPowerState()
HTTP call fires -> { powerstate: 2 } returned
Cache stores: { powerstate: 2 }
Toolbar shows: GREEN button
User clicks Power Off button
Device turns off
BUT cache still has: { powerstate: 2 } -> NOT updated
User clicks mode_standby icon (refresh)
getPowerStateCached() is called
It checks: "is there a cached value?"
Cache has { powerstate: 2 } -> YES, not null
Returns cached value IMMEDIATELY -> no HTTP call!
Toolbar still shows: GREEN -> WRONG, should be RED
Fix
Changed the toolbar's getPowerState() to call devicesService.getPowerState() directly, which always makes a fresh HTTP request and also updates the cache. Every click on the refresh icon fires a real HTTP request to the device.
https://10.99.115.56/mps/api/v1/amt/power/state/4939adac-fc23-8c93-c2d0-88aedd6e4316
Request Method
GET
Status Code
200 OK
{"powerstate":2,"OSPowerSavingState":2}
https://10.99.115.56/mps/api/v1/amt/power/action/4939adac-fc23-8c93-c2d0-88aedd6e4316
Request Method
POST
Status Code
200 OK
{
"Header": {
"To": "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
"RelatesTo": 0,
"Action": "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService/RequestPowerStateChangeResponse",
"MessageID": "uuid:00000000-8086-8086-8086-00000000014C",
"ResourceURI": "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService"
},
"Body": {
"ReturnValue": 0,
"ReturnValueStr": "SUCCESS"
}
}
3.Request URL
https://10.99.115.56/mps/api/v1/amt/power/state/4939adac-fc23-8c93-c2d0-88aedd6e4316
Request Method
GET
Status Code
200 OK
Remote Address
{"powerstate":8,"OSPowerSavingState":0}
PR Checklist
What are you changing?
Anything the reviewer should know when reviewing this PR?
If the there are associated PRs in other repositories, please link them here (i.e. device-management-toolkit/repo#365 )