Kaffy - a quick and flexible admin interface for phoenix applications

I wasn’t aware of this. Thanks for the feedback @jkbbwr and welcome to the community :pray:t2:

Hey @aesmail, Hope you are doing well.
I ran into another problem and I want your suggestion for its solution. While clicking on editing a record which has many-to-many relationships it shows

lists in Phoenix.HTML and templates may only contain integers representing bytes, binaries or other lists, got invalid entry:

%Stakester.Accounts.Roles{
  __meta__: #Ecto.Schema.Metadata<:loaded, "roles">,
  description: "This role will contain staff of Stakester",
  id: 2,
  name: "Staff",
  permissions: [
    %Stakester.Accounts.Permissions{
      __meta__: #Ecto.Schema.Metadata<:loaded, "permissions">,
      description: "",
      id: 2,
      name: "staff_user",
      roles: #Ecto.Association.NotLoaded<association :roles is not loaded>,
    },
    %Stakester.Accounts.Permissions{
      __meta__: #Ecto.Schema.Metadata<:loaded, "permissions">,
      description: "",
      id: 8,
      name: "registered_user",
      roles: #Ecto.Association.NotLoaded<association :roles is not loaded>,
    }
  ],
}

As far as I guess it is occurring due to
permissions: [%Stakester.Accounts.Permissions{}],
and we need to override some kind of show, edit or view function just like index(_conn) but I cannot get any idea about it.

Also, it would be much better if somehow we can render our custom form for editing because we will have to check/uncheck the permissions for several roles.

I think phoenix is complaining that it doesn’t know how to render %Roles{}. You need to be explicit in how to render stuff in templates ( <%= roles.name %> instead of <%= roles %> for example).

You can customize the form page (show/edit) by overriding form_fields/1. This allows you to customize what fields to display in forms and how to display them. There’s a very simple authorization mechanism if it’s enough for you.

Having said all that, Kaffy is undergoing a major rewrite that is taking longer than I expected. Adding features and applying bug fixes is slow currently due to this.

2 Likes

@aesmail, thank you for the feedback. I managed to get it work.

P.S I am excited for the new release, More power to you and all the developers working on it.

1 Like

Hey @aesmail, congrats on the project! It’s definitely a big undertaking so we all appreciate your efforts.

My honest feedback from what I’ve read so far about the project is that you should prioritize more convention over configuration. If you try to make the panel too extensible to accomodate all needs you fall into the trap of forcing developers to having to learn way too much in order to properly use it, which creates greater cognitive overload and thus steers people away: “It’ll be easier to just write this from scratch by myself than figuring all of this out to fit my needs”, you know?

I’d suggest to make some design choices on how you think most people will use an admin panel and create a powerful and simple workflow based on that, and if people need customization, give them the liberty to just write common controllers/views/templates as they would a normal Phoenix app.

I liked how Torch (https://github.com/mojotech/torch) approached this: it simply generates a bunch of files for you and lets you adjust them however you like. But that’s obviously just one way of looking at things, you gotta nail the right balance between funcionality and freedom, I just think Kaffy as it stands is pulling a bit harder on the functionality side (whilst Torch is too much on the freedom side).

I’ll be keeping a watch on how things develop, good luck!

3 Likes

@pedromtavares I love and appreciate the honest and great feedback. From my side, I’m actually adding features or customizations that I actually use for my personal or professional projects. The thing that started Kaffy was that I should be able to just hit the ground running with sensible defaults where I shouldn’t have to customize the functionality. I have been following Torch. I understand the use cases for it. I played with it a little. I think it’s cool, but honestly I personally never needed a package like Torch before. My personal opinion is, an admin package should handle all basic things out of the box, providing options to customize the default behavior.

After working with django for years now, I still find new options/customizations that I didn’t know about. Django’s admin app isn’t the best admin panel out there (it definitely has its real drawbacks that I tried to fix somehow with Kaffy), but it shows how much of a “weight” is lifted from your shoulder just not having to think about creating an admin panel.

I agree with you that things could get too complicated and confusing the more options a package has, but I also feel it depends on how those options are “presented” to the developers. I like that if I need to do something, there’s a supported way for it.

Kaffy is really young and has a long way to go (hopefully). Feedback like yours is highly appreciated and could realistically improve the project’s future.

I do have really big expectations for Kaffy’s future and one of my personal goals is to make Kaffy the default choice for new phoenix projects.

Having said all that, Kaffy will have some kind of support for “building your own thing”. I’m not sure how to add it yet. I don’t think it’ll be through generators though. I’m experimenting with different ways now. I’ve said this before, but the project is going through a major rewrite for an upcoming feature and it’s the perfect opportunity to add and/or break stuff when necessary for the sake of the project’s future.

5 Likes

I really am super grateful for and impressed by this project, but I have the same feedback as @pedromtavares. I started using Kaffy from the beginning because it filled such a crucial gap and, initially, was so easy to just plug in and use. But now I find myself on 0.9, with a view that doesn’t work because one of the columns has an unsupported type, and the configuration to hide or fix the issue is just too overwhelming to attempt. Maybe it’s just an issue of documentation and I’m missing the way to simply change this sort of thing, but I had to do something similar a few versions back and although it already felt a bit clunky I managed it fine.

In other words, while I completely agree with these two statements:

The thing that started Kaffy was that I should be able to just hit the ground running with sensible defaults where I shouldn’t have to customize the functionality.

I agree with you that things could get too complicated and confusing the more options a package has, but I also feel it depends on how those options are “presented” to the developers.

…I’m not sure I see Kaffy moving steadily in that direction, of “works out of the box”, and “easy to customize if you need.” My broken view is probably a minor issue that will be fixed in a future release so it’s more the second issue that’s more of a problem, at least for me. For the effort required to use now I’m on the edge of just forking it and stripping it down to just what I need. That’s the great thing about open source of course, but it’s also a last ditch solution.

Finally, I don’t want this to just be a (non-paying) ‘customer complaint’, so I’m happy to off more concrete suggestions in a DM (and possibly help implementing them) if you’d find that helpful.

Cheers!

1 Like

I’m glad you’re sharing your feedback @tfwright.

I’d say that Kaffy is still not “production-ready” in terms of features. We are using it in production in a few projects, but the lack of some basic features (e.g. many-to-many associations) makes it not beginner-friendly.

As mentioned earlier, Kaffy is potentially a huge project and relatively extremely young. It won’t be everybody’s cup of tea. I spent countless hours during April/May trying to get a version on hex. It was full of bugs I didn’t know about and missing features requested by the community I wasn’t planning to include. Then the community started contributing heavily to the project. Without the community’s contributions (in any way and form, including feedback like yours), Kaffy wouldn’t have reached where it is right now in such a short time.

I totally agree that it has a long way to go. However, it’s getting there slowly.

I also plan on releasing v1.0 when the time comes which will be the “stable and production-ready” version.

One important and critical thing that I currently consider a bug is Kaffy’s documentation. I wouldn’t say that Kaffy has good documentation. That also needs to be fixed before v1.0.


I don’t see it that way. The fact that you are taking the time to express your ideas and concerns shows that you care. And I’m grateful for that.

That would be great. Feel free to DM me any time. Any efforts to help Kaffy reach its goals and cover the needs of more developers are welcome.

6 Likes

What would be an alternative to Kaffy which is production-ready? I’ve seen Ex_admin but it hasn’t been updated since 2018. I’ve also found Torch (https://github.com/mojotech/torch) but I don’t know if it’s production ready.

Kaffy looks really cool and sleek though. Congrat’ I can’t wait for the stable release 1.0

I think Torch is your best bet right now if Kaffy doesn’t provide what you need. There’s also adminable.

Thank you! I’ll go for Torch then but will definitively keep an eyes on Kaffy.

Hi @aesmail,

this looks like a very good project. I couldn’t get it setup though.

  • the URL to the demo returns not found
  • the kaffy-demo repository’s instructions are incomplete. After setup, the admin page returns function nil.title/0 is undefined

Hello @ion
You’re right the demo is down for some time now. I should pay more attention to it to be honest but currently I’m focusing on getting v0.10.0 out. However, Kaffy should work out of the box if you just configure it correctly as shown in the README file on GitHub. You only need to have the following minimum configs in order for Kaffy v0.9.0 to work:

# in your router.ex
use Kaffy.Routes, scope: "/admin", pipe_through: [:some_plug, :authenticate]

# in your endpoint.ex
plug Plug.Static,
  at: "/kaffy",
  from: :kaffy,
  gzip: false,
  only: ~w(assets)

# in your config/config.exs
config :kaffy,
  otp_app: :my_app,
  ecto_repo: MyApp.Repo,
  router: MyAppWeb.Router

Please let me know if you face any issues after setting it up.

Great library. Thank You. Taking the case of fewer than 20 in the association, how would I control which column is displayed in the select. In the case of Post above, there is only one string column (title), so perhaps you pick it automatically. But my associated record has more than one string column and it is not selecting the column I want displayed in the select box. I can’t find any documentation on how to specify the column I want. Thanks

@aesmail this is amazing. Just wanted to say great work :slight_smile:

3 Likes

hi,

Can I modify the form pages separately. Like any one individual page and suppose it has some text area which I don’t like and want to change it but it should not affect the rest of the pages. Can we do that?

I have trouble with Kaffy not loading the assets.

This is one of the errors I get

[debug] ** (Phoenix.Router.NoRouteError) no route found for GET /kaffy/assets/js/misc.js (BlogWeb.Router)
    (blog 0.1.0) lib/phoenix/router.ex:402: BlogWeb.Router.call/2
    (blog 0.1.0) lib/blog_web/endpoint.ex:1: BlogWeb.Endpoint.plug_builder_call/2
    (blog 0.1.0) lib/plug/debugger.ex:132: BlogWeb.Endpoint."call (overridable 3)"/2
    (blog 0.1.0) lib/blog_web/endpoint.ex:1: BlogWeb.Endpoint.call/2
    (phoenix 1.5.7) lib/phoenix/endpoint/cowboy2_handler.ex:65: Phoenix.Endpoint.Cowboy2Handler.init/4
    (cowboy 2.8.0) /Users/josefrichter/code/phoenix/blog/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
    (cowboy 2.8.0) /Users/josefrichter/code/phoenix/blog/deps/cowboy/src/cowboy_stream_h.erl:300: :cowboy_stream_h.execute/3
    (cowboy 2.8.0) /Users/josefrichter/code/phoenix/blog/deps/cowboy/src/cowboy_stream_h.erl:291: :cowboy_stream_h.request_process/3
    (stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

This is the endpoint config, which I am suspicious may not be correct…

plug Plug.Static,
    at: "/kaffy",
    from: :kaffy,
    gzip: false,
    only: ~w(assets)

Anyone ran into same issue, please? Any suggestions? Everything seems to work, just assets not loading. Thank you very much.

ok I was able to partially fix this by moving kaffy static plug to the top of the endpoint file.

but one asset still not loading:

[debug] ** (Phoenix.Router.NoRouteError) no route found for GET /kaffy/assets/vendors/fontawesome/css/all.css (BlogWeb.Router)
    (blog 0.1.0) lib/phoenix/router.ex:402: BlogWeb.Router.call/2
    (blog 0.1.0) lib/blog_web/endpoint.ex:1: BlogWeb.Endpoint.plug_builder_call/2
    (blog 0.1.0) lib/plug/debugger.ex:132: BlogWeb.Endpoint."call (overridable 3)"/2
    (blog 0.1.0) lib/blog_web/endpoint.ex:1: BlogWeb.Endpoint.call/2
    (phoenix 1.5.7) lib/phoenix/endpoint/cowboy2_handler.ex:65: Phoenix.Endpoint.Cowboy2Handler.init/4
    (cowboy 2.8.0) /Users/josefrichter/code/phoenix/blog/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
    (cowboy 2.8.0) /Users/josefrichter/code/phoenix/blog/deps/cowboy/src/cowboy_stream_h.erl:300: :cowboy_stream_h.execute/3
    (cowboy 2.8.0) /Users/josefrichter/code/phoenix/blog/deps/cowboy/src/cowboy_stream_h.erl:291: :cowboy_stream_h.request_process/3
    (stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

Just wanted to add I recently added Kaffy after trying to install Torch for about an hour. Kaffy was SO easy to do (15 minutes!) and super nice as it autogenerated everything. Please keep maintaining it!

4 Likes

I really like this library but I am missing few minor features.
I would be able to implement them myself (hopefully). I just wanted to know if the official repo is still active, or if there’s some more active fork. Or what’s the state of this project.
I don’t want to create pressure on @aesmail, I understand it’s a lot of work and I have no right to demand anything. It would be just useful information, not only for me I guess. Thanks a lot. :slight_smile: