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

Create a setting for user to indicate humanized or hours on dashboard/device detail #634

Merged
merged 7 commits into from
Jul 25, 2024
Merged

Create a setting for user to indicate humanized or hours on dashboard/device detail #634

merged 7 commits into from
Jul 25, 2024

Conversation

bauzer714
Copy link

Default is "humanize" creates a non-breaking change.

Setting:
image

image

Dashboard:
image

image

Detail:
image

Detail tooltip:
image

image

Implements original request of #628.

Comment on lines 335 to 340
{
SettingKeyName: "powered_on_hours_unit",
SettingKeyDescription: "Presentation format for device powered on time ('humanize' | 'device_hours')",
SettingDataType: "string",
SettingValueString: "humanize",
},
Copy link
Owner

Choose a reason for hiding this comment

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

This has to be added as a new migration, otherwise it will be skipped for users with an existing database..

@AnalogJ
Copy link
Owner

AnalogJ commented Jul 19, 2024

sure, I can get behind this.
thanks for the PR! 🥳

Added comment about the db settings change - it needs to be in it's own migration

@bauzer714
Copy link
Author

Thanks @AnalogJ - I've never developed in Go, any specific naming conventions or versioning? Does it need to be removed from the current script?

@AnalogJ
Copy link
Owner

AnalogJ commented Jul 19, 2024

Basically just copy paste a migration entry like this: https://github.com/bauzer714/scrutiny/blob/addDeviceHoursSetting/webapp/backend/pkg/database/scrutiny_repository_migrations.go#L379C3-L393C5

The ID should start with "m" and be followed by a timestamp in YYYYMMDDHHMMSS format

date '+%Y%m%d%H%M%S' should do it

Thanks @bauzer714 !

@bauzer714
Copy link
Author

@AnalogJ - thanks for the guidance. Pushed the latest changes. Let me know if this needs further changes.

Comment on lines 1 to 9
import { DeviceHoursPipe } from './device-hours.pipe';


describe('DeviceHoursPipe', () => {
it('create an instance', () => {
const pipe = new DeviceHoursPipe();
expect(pipe).toBeTruthy();
});
});
Copy link
Owner

@AnalogJ AnalogJ Jul 22, 2024

Choose a reason for hiding this comment

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

one last nit. Can you add some tests to show how this pipe behaves when called with:

  • 'humanize'
  • 'device_hours'
  • null
  • a invalid string

thanks! @bauzer714 this is great work

@bauzer714
Copy link
Author

bauzer714 commented Jul 22, 2024

@AnalogJ - updated. I added tests for "configuration" of each of the 4 requested.

Additionally I added null input values (since null is a number in TS) for the configuration "device_hours" and "humanize".

image

What's your thoughts on "null hours" vs "0 hours" as the expected output of the "null" input tests? A few options I thought of:

  • Leave both as is
  • Update the device_hours pipe to return '0 hours'
  • Update all configurations of the pipe to return ''
  • ???

image

@AnalogJ
Copy link
Owner

AnalogJ commented Jul 25, 2024

if no data is present, maybe "No Data" or "Unknown"

@bauzer714
Copy link
Author

bauzer714 commented Jul 25, 2024

@AnalogJ - Updated. Let me know any additional changes.

image

@AnalogJ
Copy link
Owner

AnalogJ commented Jul 25, 2024

LGTM. Thanks for the PR @bauzer714 ! 🥇

@AnalogJ AnalogJ merged commit 49108bd into AnalogJ:master Jul 25, 2024
12 of 13 checks passed
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.

2 participants