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

Add date picker to silence form views #2262

Merged
merged 9 commits into from
Jul 24, 2020

Conversation

m-masataka
Copy link
Contributor

Added date picker to silence form views to select date easier.
see #2226
datepicker-demo

Signed-off-by: m-masataka <[email protected]>
Signed-off-by: m-masataka <[email protected]>
@simonpasquier
Copy link
Member

Thanks for tackling this one! It seems that the CI isn't happy with your changes yet :)

@simonpasquier simonpasquier requested a review from w0rm May 25, 2020 15:01
@simonpasquier
Copy link
Member

This looks really good. I guess it would be good to support time too but probably it isn't that easy (at least the component supports only dates)?

@roidelapluie
Copy link
Member

should we pick up a component that support both? can we reuse Prometheus' component?

@w0rm
Copy link
Member

w0rm commented May 25, 2020

After a brief research I found this component: https://package.elm-lang.org/packages/mercurymedia/elm-datetime-picker/latest/

It supports both date and time, it also supports selecting the duration, which is what we need.

I didn't look in depth and what the integration would look like. @m-masataka I wonder if you have checked this one?

70648518-7f2cf880-1c4b-11ea-8c6e-e97e4615c34c

@mizukoshi-m
Copy link

Thank you for your comments.
@w0rm I didn't check that great component. I'll try to use it. thanks a lot!

@m-masataka
Copy link
Contributor Author

@w0rm Please give me some advice.
I tried Panaguitus/elm-datepicker because mercurymedia/elm-datetime-picker's time selector always reset 00:00 when open datetime picker( I think it is not useful for anyone ) .
However Panaguitus/elm-datepicker uses a component that has duplicated name with ui/app/src/DateTime.elm.
How can I avoid this component name duplication? ( or I have to use other component?)

here is the demo↓
datetimepicker

@w0rm
Copy link
Member

w0rm commented Jun 5, 2020

@m-masataka feel free to just move this module into Utils!

I also think we should get rid of the type alias and just use Posix instead of our DateTime type.

@m-masataka
Copy link
Contributor Author

I checked some datetime picker components, but I didn't find the perfect one.
Therefore I implement original datetime picker that based on mercurymedia/elm-datetime-picker.
Please check it out @w0rm.
demo-datetimepicker

@w0rm
Copy link
Member

w0rm commented Jun 14, 2020

@m-masataka why did you have to inline the third party lib, can you please summarise what was not working in the original?

I also wonder whether there might be a copyright issue by inlining the code like this.

@m-masataka
Copy link
Contributor Author

@w0rm the original one mostly work fine, it’s just a matter of preference.
I want to use date picker(not datetime picker) when there is no need to edit time. But the original time picker always reset 0:00 when date is picked.
In addtion, I don't like select field as time-picker much.

I also wonder whether there might be a copyright issue by inlining the code like this.

That is true for sure. I'll implement full scratch code as needed.
But in this PR, is it better if I only add mercurymedia/elm-datetime-picker?

@w0rm
Copy link
Member

w0rm commented Jun 14, 2020

@m-masataka Oh, I see. Sorry, you actually wrote about this before!

Panaguitus/elm-datepicker didn't work either? I think renaming or getting rid of our internal types is totally fine if that is needed.

@m-masataka
Copy link
Contributor Author

m-masataka commented Jun 14, 2020

Panaguitus/elm-datepicker is perfect for me expect unnecessary view component such as today button and date limit.
Panaguitus/elm-datepicker strongly depends on other datetime component such as elm-datetime. I'm concerned about that datetime component will conflict with other packages in the future.

@m-masataka
Copy link
Contributor Author

m-masataka commented Jun 14, 2020

I think renaming or getting rid of our internal types is totally fine if that is needed.

Ah sorry, we can avoid any conflict.
Which do you think is better we should use, single picker or duration picker? @w0rm

@w0rm
Copy link
Member

w0rm commented Jun 14, 2020

@m-masataka I think picking a duration is better, this way a user won't have to open the dialog twice for each date time.

Screenshot 2020-06-14 at 20 38 47

This looks pretty good, just the colours need to be tweaked to match what we have so far.


@m-masataka I also don't mind if we implement our own datepicker inside alertmanager codebase from scratch. I am just a bit worried that we shouldn't copy paste somebody else's code and sign it off as our own.

@m-masataka
Copy link
Contributor Author

Thank you @w0rm.
Unfortunately, I have one bad news about Panaguitus/elm-datepicker.
This duration picker can't pick same date as start and end. (here is the code.)
I think this feature is not user-friendly. What's your opinion on this?

We have some choice

  1. Use Panaguitus/elm-datepicker's duration picker
  2. Use Panaguitus/elm-datepicker's datetime picker ( not use duration picker)
  3. Use mercurymedia/elm-datetime-picker's duration picker
  4. Implement datepicker inside alertmanager with full scratch code

I think 3 (or 4) is better than others.

@w0rm
Copy link
Member

w0rm commented Jun 15, 2020

@m-masataka I fully agree with you that 3 or 4 is better. Will you be willing to contribute a custom date picker (option 4)? Long term I would prefer this option, because it is easier to migrate our own code if a new version of Elm comes up.

@m-masataka
Copy link
Contributor Author

Hi @w0rm
I Implemented DateTimePicker inside alertmanager (and this is not third party libs).
Please review this.

datetime-picker-demo

@roidelapluie
Copy link
Member

cc @juliusv

@juliusv
Copy link
Member

juliusv commented Jul 15, 2020

Looks pretty IMO! I can't review Elm stuff though, I have never touched it :( @w0rm or @simonpasquier?



type alias PickerConfig msg =
{ zone : Zone
Copy link
Member

Choose a reason for hiding this comment

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

I think it is safe to assume that this is always going to be in utc. You can simplify a lot of code and just use utc everywhere.

[ text "x" ]
]
, div [ class "modal-body" ]
[ viewDateTimePicker dateTimePickerConfig form.dateTimePicker ]
Copy link
Member

@w0rm w0rm Jul 15, 2020

Choose a reason for hiding this comment

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

If we change to use utc everywhere, then viewDateTimePicker could take UpdateDateTimePicker and the dateTimePickerConfig would not be needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank's. I removed ...Config.

@@ -124,25 +136,50 @@ toSilence { id, comment, matchers, createdBy, startsAt, endsAt } =

fromSilence : GettableSilence -> SilenceForm
fromSilence { id, createdBy, comment, startsAt, endsAt, matchers } =
let
startsPosix =
case Utils.Date.timeFromString (DateTime.toString startsAt) of
Copy link
Member

Choose a reason for hiding this comment

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

You can use Result.toMaybe

Nothing

endsPosix =
case Utils.Date.timeFromString (DateTime.toString endsAt) of
Copy link
Member

Choose a reason for hiding this comment

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

form.pickedStart

endsAtTime =
case timeFromString form.endsAt.value of
Copy link
Member

Choose a reason for hiding this comment

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

Pipe to Result.toMaybe

@w0rm
Copy link
Member

w0rm commented Jul 15, 2020

@m-masataka looks great, thank you for implementing this non trivial feature!

I left a few comments that may simplify things a bit. But I am fine if this goes as is.

@simonpasquier
Copy link
Member

Thanks a lot @m-masataka for the hard work! I'm not really qualified to review the Elm code but I'll trust @w0rm :)

@simonpasquier simonpasquier merged commit 73db787 into prometheus:master Jul 24, 2020
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.

6 participants