edisonywh / backoffice

Admin tool built with the PETAL stack
MIT License
217 stars 15 forks source link

Add Home/Dashboard page support? #54

Open NduatiK opened 3 years ago

NduatiK commented 3 years ago

At the moment there is Backoffice has no clear home/dashboard page. I think this could be a nice value addition. Just a simple page that has the app logo, some widgets with useful stats and some shortcuts to existing resources. @edisonywh, what do you think? Is this a stretch for the library, something outside scope?

What I have in mind is something that looks like: PotentialHomePage

At a high-level, we would add a new page type. Maybe Backoffice.Page.Dashboard? That page would have two functions: widgets and shortcuts.

widgets would return a list of widgets, just like those at in the Index page.

def widgets(socket) do
    %Backoffice.PlainWidget{
      title: "Blog Posts",
      data: ...
    },
    %Backoffice.PlainWidget{
      title: "Podcast Episodes",
      data:  ...
    },
    %Backoffice.PlainWidget{
      title: "Unique Visitors",
      data:  ...
    }
end

shortcuts would return a list of shortcuts to other pages.

def shortcuts do
[
    %Backoffice.ShortcutWidget{
      title: "Blog",
      subtitle: "Get writing",
      color: "#23A342",
      icon: #svg_data
    }
]
NduatiK commented 3 years ago

The question would be, is this useful for the library to provide? Or would it be bloat? If useful, I would be happy to take it on.

edisonywh commented 3 years ago

Definitely! I think the idea has merits, but there's a couple of things I think we need to figure out.

The main reason I didn't start with a dashboard is because of the aforementioned reasons, and also that I think dashboard by nature varies by business, so I don't see a way to provide a good default. And I'm not sure if ultimately it adds a lot of value to them (for example if it's not extensible enough to adapt to their use case, they just won't use it altogether)

So my idea instead moved to using Widget as the building block - focus on building a core set of widgets, and this way users can plug & play these into their own dashboard page. One idea for example is to build a ChartWidget that takes in a Contex chart, so users can just pass in the data struct, and the widget can just render them.

I am open to changing my mind though, maybe we can start off by answering some of the questions above!

NduatiK commented 3 years ago

Charts? Even better!!!

My initial thought was that:

The widget approach you suggest feels a lot more valuable and extensible. We would probably need