Skip to content

Conversation

@yubiuser
Copy link
Member

@yubiuser yubiuser commented Dec 24, 2022

What does this PR aim to accomplish?:

We use the "status message field" to show various, independent messages (e.g. System ist hot, Updates available, Everything is fine,...). Currently, the message is set for every event in the respective GetXXXXInformation function and the order of the various GetXXXXInformation determines the final output. This made the code hard to follow, as it was not clear when which message will be shown. It also led to a bug described here, because we forget to set the message back to Everything is fine once something was not fine.

This PR disentangles the code by setting flags if certain conditions are met (e.g. updates available, system is hot) and setting the final status message in a separate function, depending on their "severity" (it's more important that the device is hot than that updates are available).

Additionally, the PR
a) Creates a new function GetPADDInformation where we check for PADD updates only. This allows to run GetPADDInformation updates more often (30 seconds) so that "Update available" does not stay for 24hours if users have been upgrading their Pi-holes inbetween
b) Only tries to get FTLs DNS port if FTL is known to be running
c) Fixes a small visual glitch in mini
d) Removed the version_status from the startup sequence (shown only for 3 seconds), if updates are available it is shown on the dashboard anyway.


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code and I have tested my changes.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)
  6. I have checked that another pull request for this purpose does not exist.
  7. I have considered, and confirmed that this submission will be valuable to others.
  8. I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  9. I give this submission freely, and claim no ownership to its content.

  • I have read the above and my PR is ready for review. Check this box to confirm

@yubiuser yubiuser force-pushed the fix/status branch 2 times, most recently from 38a7a6f to 45a74af Compare December 24, 2022 13:19
@yubiuser yubiuser marked this pull request as ready for review December 24, 2022 13:20
@yubiuser yubiuser requested a review from a team December 24, 2022 13:20
@yubiuser yubiuser mentioned this pull request Dec 24, 2022
@yubiuser yubiuser linked an issue Dec 24, 2022 that may be closed by this pull request
@rdwebdesign
Copy link
Member

I tested and it's working.
As soon as the status is changed back, PADD will show to the previous status message.


I'm not sure which is the most readable style for the SetStatusMessage() function:

  • using a sequence of independent if tests and a return for each block (like you did) or

  • using a sequence of elif, without return

    Click to see the suggested code
      if [ "${hot_flag}" = true ]; then
          pico_status="${pico_status_hot}"
          mini_status="${mini_status_hot} ${blinking_text}${red_text}${temperature}${reset_text}"
          tiny_status="${tiny_status_hot} ${blinking_text}${red_text}${temperature}${reset_text}"
          full_status="${full_status_hot} ${blinking_text}${red_text}${temperature}${reset_text}"
          mega_status="${mega_status_hot} ${blinking_text}${red_text}${temperature}${reset_text}"
      elif [ "${ftl_down_flag}" = true ]; then
          pico_status=${pico_status_ftl_down}
          mini_status=${mini_status_ftl_down}
          tiny_status=${tiny_status_ftl_down}
          full_status=${full_status_ftl_down}
          mega_status=${mega_status_ftl_down}
      elif [ "${dns_down_flag}" = true ]; then
          pico_status=${pico_status_dns_down}
          mini_status=${mini_status_dns_down}
          tiny_status=${tiny_status_dns_down}
          full_status=${full_status_dns_down}
          mega_status=${mega_status_dns_down}
      elif [ "${blocking_status}" = "unknown" ]; then
          pico_status=${pico_status_unknown}
          mini_status=${mini_status_unknown}
          tiny_status=${tiny_status_unknown}
          full_status=${full_status_unknown}
          mega_status=${mega_status_unknown}
      elif [ "${blocking_status}" = "disabled" ]; then
          pico_status=${pico_status_off}
          mini_status=${mini_status_off}
          tiny_status=${tiny_status_off}
          full_status=${full_status_off}
          mega_status=${mega_status_off}
      elif [ "${out_of_date_flag}" = "true" ] || [ "${padd_out_of_date_flag}" = "true" ]; then
          pico_status=${pico_status_update}
          mini_status=${mini_status_update}
          tiny_status=${tiny_status_update}
          full_status=${full_status_update}
          mega_status=${mega_status_update}
      elif [ "${blocking_status}" = "enabled" ]; then
           # if we reach this point and blocking is enabled, everything is fine
          pico_status=${pico_status_ok}
          mini_status=${mini_status_ok}
          tiny_status=${tiny_status_ok}
          full_status=${full_status_ok}
          mega_status=${mega_status_ok}
      fi

Copy link
Member

@DL6ER DL6ER left a comment

Choose a reason for hiding this comment

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

Tested as well, I suggest to add consistent empty lines and comments. I also looked at the style proposed by @rdwebdesign and am undecided what might be better. It is a lot more condensed (half the number of lines), however, this also means it is very condensed. In contrast, the current design feel a lot more "light" and I don't think this hurts here. Good that I don't have to decide this :-)

Signed-off-by: Christian König <[email protected]>
Signed-off-by: Christian König <[email protected]>
Signed-off-by: Christian König <[email protected]>
@yubiuser
Copy link
Member Author

Actually, I wasn't sure which style I should use when I first wrote the code. I thought the if...return would be more easily readable. However, the condensed form also didn't look bad.
I now pushed a combination: use elif but keep an empty line to separate each block to avoid a wall-of-text impression.

@yubiuser yubiuser merged commit 8ca9311 into development Dec 27, 2022
@yubiuser yubiuser deleted the fix/status branch December 27, 2022 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DNS is off! rather than System is healthy.

4 participants