_russellb

_russellb

How would you present customer data using a dashboard?

I need to build a crm-like dashboard to present customer data to the logged in user.
Would you implement the dashboard as property of the customer using something like

schema "customers" do
  has_one(:dashboard, Dashboard )
end

Or would you just have a Dashboard controller (not a table) and only make it available on certain routes?
For example let’s say the logged in user is viewing the customer show page. I could then get customer from the params and look
them up in the database then present the customer data on the dashboard.

Both ways would work but which is less error prone? Or is there another way to do this that I’m not seeing?

Most Liked

sobojack

sobojack

Hi, @_russellb, I think it would be considered best practices to go the controller route. Phoenix promotes MVC( Model, View, Controller ) principles designed just for this. If I were you I would create a controller for your dashboard, along with that I would create a dashboard template in yourAppWeb/templates/dashboard/index.html.eex and a dashboard view in yourAppWeb/views/ dashboard_view.ex. You can call functions to load your data in your controller and pass that data to your template, in your template you can render the data in your CRM like fashion. You can use your view file to call functions for any logic needed in your template.

Inside your router you can create a route for this page, you can also restrict the route to only allowing certain usesr to view it.

_russellb

_russellb

Thanks, that’s the way I’ve been writing this feature. I just wanted some extra opinions on how to do it.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: The documentation above suggests that while ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement