Fork of the excellent esp8266-react - https://github.com/rjwats/esp8266-react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
856 B

  1. import * as Highlight from '../constants/Highlight';
  2. export const NTP_TIME_NOT_SET = 0;
  3. export const NTP_TIME_NEEDS_SYNC = 1;
  4. export const NTP_TIME_SET = 2;
  5. export const isSynchronized = ntpStatus => ntpStatus && (ntpStatus.status === NTP_TIME_NEEDS_SYNC || ntpStatus.status === NTP_TIME_SET);
  6. export const ntpStatusHighlight = ntpStatus => {
  7. switch (ntpStatus.status){
  8. case NTP_TIME_SET:
  9. return Highlight.SUCCESS;
  10. case NTP_TIME_NEEDS_SYNC:
  11. return Highlight.WARN;
  12. case NTP_TIME_NOT_SET:
  13. default:
  14. return Highlight.ERROR;
  15. }
  16. }
  17. export const ntpStatus = ntpStatus => {
  18. switch (ntpStatus.status){
  19. case NTP_TIME_SET:
  20. return "Synchronized";
  21. case NTP_TIME_NEEDS_SYNC:
  22. return "Synchronization required";
  23. case NTP_TIME_NOT_SET:
  24. return "Time not set"
  25. default:
  26. return "Unknown";
  27. }
  28. }