openwisp-controller icon indicating copy to clipboard operation
openwisp-controller copied to clipboard

[fix] Recent Commands row uses "created" timestamp for the "Modified" field

Open iamavichal-geek opened this issue 8 months ago • 4 comments

Issue

In commands.js, the getElement function builds the HTML for a new command row inserted into "Recent Commands" after a command is submitted. The Modified field incorrectly uses response.created instead of response.modified:

openwisp_controller/connection/static/connection/js/commands.js ~line 506-510

<div class="form-row field-modified">
    <div><label>Modified:</label><div class="readonly">${getFormattedDateTimeString(
      response.created,   // bug: should be response.modified
    )}</div></div>
</div>

Screenshots :

Image Image

iamavichal-geek avatar Mar 08 '26 10:03 iamavichal-geek

Hi @pandafy , I have identified the fix, it is a pretty simple one.

The getElement function uses response.created for the Modified field instead of response.modified (line 508): https://github.com/openwisp/openwisp-controller/blob/master/openwisp_controller/connection/static/connection/js/commands.js#L508

Verified via dev tools, modified is present in the API response but unused here. The WebSocket handler at line 565–567 already uses data.modified correctly, so this one-line fix makes the AJAX insertion consistent with it.

Would you like me to open a PR?

iamavichal-geek avatar Mar 08 '26 11:03 iamavichal-geek

Hi, I'd like to work on this. The fix is straightforward: line 508 in commands.js passes response.created to getFormattedDateTimeString() for the Modified field, when it should be response.modified. The WebSocket handler at line 567 already uses data.modified correctly, so this is just an inconsistency in the AJAX insertion path. I'll submit a PR shortly.

xovishnukosuri avatar Mar 14 '26 05:03 xovishnukosuri

Hi, I’d like to work on this issue.

I noticed that in commands.js, the "Modified" field uses response.created instead of response.modified. I’ll fix this and ensure it matches the WebSocket behavior.

Please let me know if that’s okay.

k-sumayya avatar Mar 23 '26 19:03 k-sumayya

Hi, I have addressed all requested changes and all checks are now passing.

Could you please review again?

k-sumayya avatar Mar 24 '26 14:03 k-sumayya