Skip to content

fix: fix refresh power button issue.#3430

Closed
punam20 wants to merge 3 commits into
device-management-toolkit:mainfrom
punam20:refresh_button_changes
Closed

fix: fix refresh power button issue.#3430
punam20 wants to merge 3 commits into
device-management-toolkit:mainfrom
punam20:refresh_button_changes

Conversation

@punam20

@punam20 punam20 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

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.

  1. User opens device detail page
    ngOnInit() calls getPowerState()
    HTTP call fires -> { powerstate: 2 } returned
    Cache stores: { powerstate: 2 }
    Toolbar shows: GREEN button

  2. User clicks Power Off button
    Device turns off
    BUT cache still has: { powerstate: 2 } -> NOT updated

  3. 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.

  1. 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

{"powerstate":2,"OSPowerSavingState":2}

  1. Request URL
    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

  • Unit Tests have been added for new changes
  • API tests have been updated if applicable
  • All commented code has been removed
  • If you've added a dependency, you've ensured license is compatible with Apache 2.0 and clearly outlined the added dependency.

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 )

@punam20
punam20 marked this pull request as draft July 13, 2026 03:42
punam20 and others added 3 commits July 13, 2026 09:30
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
DevipriyaS17 marked this pull request as ready for review July 14, 2026 08:25
@DevipriyaS17
DevipriyaS17 requested a review from Copilot July 14, 2026 08:25
@DevipriyaS17 DevipriyaS17 changed the title Fix refresh power button issue. fix: fix refresh power button issue. Jul 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 call DevicesService.getPowerState() (fresh HTTP) instead of getPowerStateCached().
  • 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())
@DevipriyaS17

Copy link
Copy Markdown
Contributor

closing the PR, as new PR opened #3441
to fix the commit message and CI error.
Note: branch created by punam was not available in github for me to fix the above errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants