-
Notifications
You must be signed in to change notification settings - Fork 27
Improve web dashboard navigation #141
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,21 +8,36 @@ defmodule ErrorTracker.Web.Router.Routes do | |
@doc """ | ||
Returns the dashboard path | ||
""" | ||
def dashboard_path(socket = %Socket{}) do | ||
socket.private[:dashboard_path] | ||
def dashboard_path(socket = %Socket{}, params \\ %{}) do | ||
socket | ||
|> dashboard_uri(params) | ||
|> URI.to_string() | ||
end | ||
|
||
@doc """ | ||
Returns the path to see the details of an error | ||
""" | ||
def error_path(socket = %Socket{}, %Error{id: id}) do | ||
dashboard_path(socket) <> "/#{id}" | ||
def error_path(socket = %Socket{}, %Error{id: id}, params \\ %{}) do | ||
socket | ||
|> dashboard_uri(params) | ||
|> URI.append_path("/#{id}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Much nicer solution ❤️ |
||
|> URI.to_string() | ||
end | ||
|
||
@doc """ | ||
Returns the path to see the details of an occurrence | ||
""" | ||
def occurrence_path(socket = %Socket{}, %Occurrence{id: id, error_id: error_id}) do | ||
dashboard_path(socket) <> "/#{error_id}/#{id}" | ||
def occurrence_path(socket = %Socket{}, %Occurrence{id: id, error_id: error_id}, params \\ %{}) do | ||
socket | ||
|> dashboard_uri(params) | ||
|> URI.append_path("/#{error_id}/#{id}") | ||
|> URI.to_string() | ||
end | ||
|
||
defp dashboard_uri(socket = %Socket{}, params) do | ||
%URI{ | ||
path: socket.private[:dashboard_path], | ||
query: if(Enum.any?(params), do: URI.encode_query(params)) | ||
} | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
defmodule ErrorTracker.Web.Search do | ||
@moduledoc false | ||
|
||
@types %{ | ||
reason: :string, | ||
source_line: :string, | ||
source_function: :string, | ||
status: :string | ||
} | ||
|
||
defp changeset(params) do | ||
Ecto.Changeset.cast({%{}, @types}, params, Map.keys(@types)) | ||
end | ||
|
||
@spec from_params(map()) :: %{atom() => String.t()} | ||
def from_params(params) do | ||
params |> changeset() |> Ecto.Changeset.apply_changes() | ||
end | ||
|
||
@spec to_form(map()) :: Phoenix.HTML.Form.t() | ||
def to_form(params) do | ||
params |> changeset() |> Phoenix.Component.to_form(as: :search) | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously we were triggering a full page reload when going back to the dashboard page. With this change we just do a LiveView navigation over the existing websocket connection.
This is faster and does not require negotiating a TLS handshake or reloading all static assets again.