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

MG-164 - Add input validation to chart modals #193

Merged
merged 9 commits into from
Mar 8, 2024

Conversation

felixgateru
Copy link
Contributor

What type of PR is this?

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update
  • Dependency Update

What does this do?

Adds input validation to the forms present in the create chart modals.

Which issue(s) does this PR fix/relate to?

Have you included tests for your changes?

  • Yes
  • No, and this is why:

Did you document any new/modified functionality?

  • Yes
  • No, and this is why:

Notes

@felixgateru felixgateru changed the title MG-164 - Add input validation to chart modals, MG-164 - Add input validation to chart modals Feb 26, 2024
@felixgateru felixgateru force-pushed the MG-164-input_validation branch 2 times, most recently from b680d66 to 60e94c0 Compare February 26, 2024 14:33
@felixgateru felixgateru marked this pull request as ready for review February 27, 2024 07:37
@felixgateru felixgateru force-pushed the MG-164-input_validation branch 2 times, most recently from d73d954 to af3e516 Compare March 4, 2024 13:34
Copy link
Contributor

@dborovcanin dborovcanin left a comment

Choose a reason for hiding this comment

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

Can we extract the pattern to a shared variable so we can easily change it? We will probably have more of the same check (for not-chart-related) things.

@ianmuchyri
Copy link
Contributor

It shouldn't be showing the green tick if the time is wrong
image

Also, make sure both the start time and end time are not greater than the now() time. You can find a way of disabling any time that is greater than now() from being selected, or validate it afterward.

ui/web/templates/charts/alarmcountmodal.html Show resolved Hide resolved
@@ -60,7 +64,7 @@ <h5 class="modal-title" id="alarmsTableModalLabel">Alarms Table</h5>
<div class="mb-3">
<label for="update-interval" class="form-label">Update interval</label>
<input
type="text"
type="number"
Copy link
Member

Choose a reason for hiding this comment

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

The interval shouldn't be a string something like 1h or 10s?

Copy link
Contributor

@ianmuchyri ianmuchyri Mar 6, 2024

Choose a reason for hiding this comment

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

Currently, we are only using intervals in seconds for the first iteration. This will be improved in the next iteration to incorporate other intervals, minutes, hours, days etc. This will also have to change based on the to and from

Copy link
Contributor

Choose a reason for hiding this comment

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

But it should still be string/text @1998-felix

Copy link
Contributor

Choose a reason for hiding this comment

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

Have select options sth like: 1s, 2s, 5s 10s, 20s, 30s,60s

Copy link
Contributor

Choose a reason for hiding this comment

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

@1998-felix ^

Signed-off-by: felix.gateru <[email protected]>
Signed-off-by: felix.gateru <[email protected]>
Signed-off-by: felix.gateru <[email protected]>
Signed-off-by: felix.gateru <[email protected]>
const invalidTimeFeedback = form.querySelector(".invalid-time");
invalidTimeFeedback.innerHTML = "";
const invalidTimeInput = form.querySelector("#stop-time");
invalidTimeInput.classList.remove("is-invalid");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
invalidTimeInput.classList.remove("is-invalid");
form.querySelector(".invalid-time").innerHTML="";
form.querySelector("#stop-time").classList.remove("is-invalid");

Copy link
Contributor

Choose a reason for hiding this comment

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

This simplifies the code. Do this for the other files that do this.

Signed-off-by: felix.gateru <[email protected]>
<option value="" disabled>Select an update interval</option>
<option value="MAX">Maximum</option>
<option value="MIN">Minimum</option>
<option value="SUM">Sum</option>
Copy link
Contributor

Choose a reason for hiding this comment

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

missing count aggregation. Check others too if they are missing any.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is done for bar charts and pie charts which I dont think will have the count aggregation as an option

Copy link
Contributor

Choose a reason for hiding this comment

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

It will. say, I want a pie chart that shows the count of the various messages published by different devices in the same channel.

Signed-off-by: felix.gateru <[email protected]>
@@ -101,31 +105,46 @@ <h5 class="modal-title" id="lineChartModalLabel">Time Series Line Chart</h5>
<label for="start-time" class="form-label">Start time</label>
<input
type="datetime-local"
class="form-control mb-3"
class="form-control mb-3 no-validate"
Copy link
Contributor

Choose a reason for hiding this comment

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

what's with the no-validate class and why is it just being used in the line chart and not the other time series charts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be removed.

Signed-off-by: felix.gateru <[email protected]>
@dborovcanin dborovcanin merged commit 21463e5 into absmach:main Mar 8, 2024
2 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.

4 participants