Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Permit users to choose Celsius or Fahrenheit. #1182

Merged
merged 1 commit into from
May 19, 2023

Conversation

altearius
Copy link
Contributor

@altearius altearius commented May 12, 2023

altearius Medium altearius /FEATURE/cpu-temp-units → Lissy93/dashy Commits: 1 | Files Changed: 3 | Additions: 47 Label Unchecked Tasks Powered by Pull Request Badge

Thank you for contributing to Dashy! So that your PR can be handled effectively, please populate the following fields (delete sections that are not applicable)

Category:

One of: Bugfix / Feature / Code style update / Refactoring Only / Build related changes / Documentation / Other (please specify)

Feature

Overview

Briefly outline your new changes...

If merged, this PR will introduce a new option for the GlCpuTemp widget, permitting users to express a preference for either Celsius or Fahrenheit values.

The underlying Glances sensor API can already be configured to report temperatures using either scale, using the --fahrenheit command line argument.

This PR utilizes the unit reported by the Glances API to determine whether any conversion is necessary.

Prior to this PR, the default behavior is to always display values in Celsius, whether Glances has been configured to report in Fahrenheit or not. This default behavior has been retained, as the new option is understood to have a default value of C.

Issue Number (if applicable) #00

None.

New Vars (if applicable)

If you've added any new build scripts, environmental variables, config file options, dependency or devDependency, please outline here

A new widget option named units has been introduced to the GlCpuTemp widget. Documentation for this option has been added to widgets.md.

Screenshot (if applicable)

If you've introduced any significant UI changes, please include a screenshot

image

Code Quality Checklist (Please complete)

  • All changes are backwards compatible
  • All lint checks and tests are passing
  • There are no (new) build warnings or errors
  • (If a new config option is added) Attribute is outlined in the schema and documented
  • (If a new dependency is added) Package is essential, and has been checked out for security or performance
  • Bumps version, if new feature added

Note: There is currently a lint failure in the src/components/Widgets/RssFeed.vue file. This appears to be unrelated to my changes and I presently understand this to be out of scope. Please let me know if I should correct this anyway.

I am unclear on whether this is a big enough "feature" to warrant a version bump. Please advise.

@altearius altearius requested a review from Lissy93 as a code owner May 12, 2023 19:22
@netlify
Copy link

netlify bot commented May 12, 2023

Deploy Preview for dashy-dev ready!

Name Link
🔨 Latest commit e336034
🔍 Latest deploy log https://app.netlify.com/sites/dashy-dev/deploys/645e9206ebf6b5000865dc37
😎 Deploy Preview https://deploy-preview-1182--dashy-dev.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@viezly
Copy link

viezly bot commented May 12, 2023

Changes preview:

Legend:

👀 Review pull request on Viezly

@@ -165,6 +165,11 @@ export const getValueFromCss = (colorVar) => {
return cssProps.getPropertyValue(`--${colorVar}`).trim();
};

/* Given a temperature in Celsius, returns value in Fahrenheit */
export const celsiusToFahrenheit = (celsius) => {
return Math.round((celsius * 1.8) + 32);
Copy link

Choose a reason for hiding this comment

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

Why not :

Suggested change
return Math.round((celsius * 1.8) + 32);
return Math.round((celsius * 9 / 5) + 32);

To keep style consistent with the below fahrenheitToCelsius ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no reason to prefer one form or the other.

Would you like me to make the suggested change, or are you asking merely out of curiosity?

If the latter, it is because I asked Google for the formula for the conversion, even though the reverse formula was staring me in the face and I might have worked it out myself.

If the former, I have no objections. Let me know if I should take action based on your suggestion.

Copy link

Choose a reason for hiding this comment

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

I was suggesting it for the style consistency. It's your PR, and your code is fine... My suggestion may be viewed as nitpicking ;-)

// Justification: This is a recoverable error that developers
// should nevertheless be warned about.
// eslint-disable-next-line
console.warn('Unrecognized unit', sensor.unit);
Copy link
Owner

Choose a reason for hiding this comment

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

There is also a this.error('msg') (defined in the WidgetMixin.js) - which will display this to the user, as well as log to console - here's an example.

But I'm happy either way :)

@Lissy93 Lissy93 merged commit 9c73bb9 into Lissy93:master May 19, 2023
@altearius altearius deleted the FEATURE/cpu-temp-units branch May 21, 2023 02:13
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