aesmail / kaffy Goto Github PK
View Code? Open in Web Editor NEWPowerfully simple admin package for phoenix applications
Home Page: https://kaffy.fly.dev/admin/
License: MIT License
Powerfully simple admin package for phoenix applications
Home Page: https://kaffy.fly.dev/admin/
License: MIT License
Since phoenix 1.3 and 1.4 are still widely used, we should probably make sure kaffy runs fine with those versions.
The main issue currently is how templates are using @inner_content
instead of the old way.
It would be great to have an order_by option on the index page.
It would be great to have the ability to create a custom link in the menu.
For instance if you want a link that point to Phoenix LiveDashboard, or an API Swagger UI.
Imagine the scenario when you want to allow a field to be created but not edited.
If you use something like:
def form_fields(_) do
[
username: %{permission: :read},
...
Then the field cannot be introduced when you create the resource.
Is there a way to tackle this problem or should we consider introducing different permission mechanism:
:permission - can be :editable, :read-only or :create-only
It would be great to have the ability to create your own custom page, eg to build a custom report, or something very specific for someone business needs.
That customer page should be displayed inside the kaffy-admin, not on a different page.
Would love to see that.
I've added kaffy to my exisiting project, see branch: https://github.com/axelclark/ex338/tree/kaffy.
For some resources, the ID field on the form page displays ERROR when I click on the ID in the index list. For example Ex338.Trade, Ex338.User, and Ex338.FantasyTeam.
I don't receive the error for Ex338.SportsLeague, Ex338.FantasyPlayer, and Ex338.DraftPick.
Any ideas what the issue could be?
Thanks for sharing this project!
I believe it would get more support and adoption if you add a license like MIT for example.
...
* Getting kaffy (Hex package)
...
➜ kaffy_test (master) ✗ mix compile
==> kaffy
Compiling 12 files (.ex)
== Compilation error in file lib/kaffy/resource.ex ==
** (CompileError) lib/kaffy/resource.ex:35: undefined function is_struct/1
(elixir) src/elixir_locals.erl:108: :elixir_locals."-ensure_no_undefined_local/3-lc$^0/1-0-"/2
(elixir) src/elixir_locals.erl:108: anonymous fn/3 in :elixir_locals.ensure_no_undefined_local/3
(stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
(elixir) lib/kernel/parallel_compiler.ex:229: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7
Feel we could get rid of the JS datatables & API by using Liveview.
It might give us more flexibility in building our own filter system or a different type of listing which might not be a table.
Know this is a complex one, but let's keep track of this here, where we can share our thoughts on this.
Ref: https://github.com/dmitriid/phreak
Thanks!
I'm new to Phoenix so I can easily say something very stupid.
Here a demo project to show an issue I'm seeing.
https://github.com/areski/ex-chitchat/blob/master/lib/chit_chat/blog/post.ex#L20
The Unique UUID
is empty in Kaffy admin page:
But it will work fine with Phoenix Generated template:
Any advice to fix that?
When we have Blogs.Post
and Rooms.Room
schemas and define them like this in kaffy:
resources: [
room: [
name: "Room",
schemas: [
example: [schema: ChitChat.Chat.Room, admin: ChitChatWeb.RoomAdmin]
]
],
blog: [
name: "Blog",
schemas: [
test: [schema: ChitChat.Blog.Post]
]
]
]
Kaffy will not be able to create/update schemas correctly.
Currently, kaffy uses the schemas
keys to construct URLs which it shouldn't.
We need a fix for now, but we also need to evaluate having atom keys in the schemas
list since they are becoming irrelevant. The previous example could be written as follows:
resources: [
rooms: [
name: "Room",
schemas: [
[schema: ChitChat.Chat.Room, admin: ChitChatWeb.RoomAdmin]
]
],
blogs: [
name: "Blog",
schemas: [
[schema: ChitChat.Blog.Post]
]
]
]
Django has the notion of "raw" IDs.
I might follow a similar way.
Ecto.Schema.field/3 has an option to label virtual: true
for when the field is not persisted to the database. See https://hexdocs.pm/ecto/Ecto.Schema.html#field/3.
Suggest removing these virtual
fields from the default form.
The dashboard looks nice, but probably tailwindcss will provide a higher level of customization.
Additionally I found that SB-Admin is not very nice on mobile, I know there is a small audience using backend on mobile, nevertheless if we could tackle this early rather than later it would be awesome
[https://www.creative-tim.com/learning-lab/tailwind-starter-kit/dashboard]
Above Create-Tim is providing a skel for Dashboard which is MIT licensed. It might be a good fit, although it would be worth doing more research.
Kaffy: Master branch
Phoenix: 1.5
It seems there is an issue with the current master branch, it cannot find the asset.
iex [10:14 :: 4] > [info] GET /kaffy/assets/vendors/css/vendor.bundle.base.css
[debug] ** (Phoenix.Router.NoRouteError) no route found for GET /kaffy/assets/vendors/css/vendor.bundle.base.css (ChitChatWeb.Router)
(chit_chat 0.1.0) lib/phoenix/router.ex:402: ChitChatWeb.Router.call/2
(chit_chat 0.1.0) lib/chit_chat_web/endpoint.ex:1: ChitChatWeb.Endpoint.plug_builder_call/2
(chit_chat 0.1.0) lib/plug/debugger.ex:132: ChitChatWeb.Endpoint."call (overridable 3)"/2
(chit_chat 0.1.0) lib/chit_chat_web/endpoint.ex:1: ChitChatWeb.Endpoint.call/2
(phoenix 1.5.3) lib/phoenix/endpoint/cowboy2_handler.ex:65: Phoenix.Endpoint.Cowboy2Handler.init/4
(cowboy 2.7.0) /home/areski/projects/phoenix/ex-chitchat/deps/cowboy/src/cowboy_handler.erl:41: :cowboy_handler.execute/2
(cowboy 2.7.0) /home/areski/projects/phoenix/ex-chitchat/deps/cowboy/src/cowboy_stream_h.erl:320: :cowboy_stream_h.execute/3
(cowboy 2.7.0) /home/areski/projects/phoenix/ex-chitchat/deps/cowboy/src/cowboy_stream_h.erl:302: :cowboy_stream_h.request_process/3
(stdlib 3.11) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Screenshots
If applicable, add screenshots to help explain your problem.
Need a way to figure out the primary key.
Might also need to check if the primary key is a set of fields and not just a single field.
This is considered a bug because of its importance.
The HexDocs should be complete and clear before shipping v1.0
By default, I would not expect id
, inserted_at
, and updated_at
to be included in the form for creating a new record or updating an existing record. I would consider removing these fields from the default form.
We need a way to support adding child records from the parent record itself on the same page and give an option to display children records from the parent page.
The schemas in the side bar are displayed in reverse alphabetical order. Suggest updating to display in alphabetical order (vertically top to bottom).
I feel that filter should produce an exchangeable URL, either for bookmark purpose or to send to someone, maybe we could use ex_sieve to achieve it:
https://github.com/valyukov/ex_sieve
widgets need to be fixed on mobile.
Just like we have with single resource actions, we need to implement a way to perform actions on a group of resources together.
When accessed with small screens, the side menu subitems are all "open". A quick fix is to touch any section name and they all go away, but this needs to be fixed.
In the update form ChampionshipResult
displays as Championshipresult
. It displays correctly in the new form as ChampionshipResult
.
See:
Seems related to #29
The issue doesn't seem to affect successful submission of the update form.
Since telemetry is becoming the de facto package for metrics and instrumentations in elixir, I feel it's going to provide a huge benefit for developers/admins using Kaffy if we have built-in support for it.
Also note the the official phoenix_live_dashboard uses this to provide useful metrics.
it would be useful to have some documentation on the type of inputs.
Specially the embed
& map
https://github.com/aesmail/kaffy/blob/master/lib/kaffy/resource_form.ex#L78
@aesmail coming from react-admin I found custom filters very useful
It will be great to have more flexibility with filters, for instance having the ability to create filter for fields not on the list.
Django display the filter on the right side:
I quite dislike this approach, I think we could design something better that is neat.
Here an example with Tailwind https://tailwindcomponents.com/component/table-responsive-with-filters
A good example of that might be the new built-in dashboard:
https://github.com/phoenixframework/phoenix_live_dashboard
Watch it autorefresh, really something I would want to see
Maybe all :textarea
fields should handle rich text content.
When I submit a form for a resource with two words in the name, I receive an error that all required forms are blank.
It appears in might be an error with the two words not separated with an underscore in the parameters:
Parameters: %{"_csrf_token" => "XiADUzgRR1JoGh4TRC8YCgEPETRoK1l5hMV7Yy341lQ87Zs26W_N_jdD", "championship_result" => %{"championship_id" => "52", "fantasy_player_id" => "531", "id" => "", "inserted_at" => %{"day" => "1", "hour" => "0", "minute" => "0", "month" => "1", "year" => "2015"}, "points" => "8", "rank" => "1", "updated_at" => %{"day" => "1", "hour" => "0", "minute" => "0", "month" => "1", "year" => "2015"}}, "context" => "ex338", "resource" => "championshipresult", "submit" => "Save"}
See "championship_result" => %{"data" => "data"}
& "resource" => "championshipresult"
.
I was able to save my "owners" resource, but also couldn't save my "fantasy_leagues" resource.
Successful owners
resource:
Parameters: %{"_csrf_token" => "bz0tFhQPPDlrLwx-JR8iWg4rJz1_Lw5lYPxrugH_2YCUVjIb9siGHn3X", "context" => "ex338", "owner" => %{"fantasy_team_id" => "53", "id" => "", "inserted_at" => %{"day" => "1", "hour" => "0", "minute" => "0", "month" => "1", "year" => "2015"}, "updated_at" => %{"day" => "1", "hour" => "0", "minute" => "0", "month" => "1", "year" => "2015"}, "user_id" => "2"}, "resource" => "owner", "submit" => "Save"}
One way to fix this is to provide horizontal scrolling for tables.
I'm interested in exporting data as csv.
Maybe something like:
def export_fields(schema, params) do
entries = Kaffy.ResourceAdmin.list_resource(schema, params)
fields = [:id, :title, :status, :inserted_at]
for entry <- entries do
# ...
end
end
The ability to add custom actions to be performed on single resources.
For example, I need to send an email for a commenter to inform them that their comment was approved (etc).
Trying to figure out in the code base if many-to-many relation is supported.
If not it would be nice to support it in future version.
When we tackle this it might be nice to consider 3 cases:
Tag Field: https://ant.design/components/select/#header
Multi Select Tree: https://ant.design/components/tree-select/
Hi @aesmail - hope you're well.
Imagine this scenario
User belongs to Profile
User has got email and a couple of other fields
Profile has got first name, last name etc.
on Kaffy I'm not gonna have two resource tabs called Users
and Profiles
. I will only have Users
, right?
Users resource will show also user's profile first/last name, etc.
I would like to be able to search by user's profile first/last name, email, etc
if that make sense? 👍
Filtration should be extensible and configurable.
I'm thinking something like:
def search_fields(_schema) do
[
title: nil,
inserted_at: nil,
# etc
]
end
Not sure though what would be passed as values.
If nothing should be passed, we should use normal lists instead of keyword lists.
Non-visible contexts/schemas are unreachable because the side menu does not scroll.
In relation to #57 I wanted to shared other points to keep track for future improvements.
I have tested Kaffy with 10 millions records.
In my use case, I will often have some big tables, in those case count
can become a huge pain in the neck, unfortunately unavoidable.
One good hack I use with django-admin.
https://stackoverflow.com/questions/39851915/faster-django-admin-paginator-cannot-get-this-django-snippet-to-work#39852663
This allows you to have an estimated count which is very cheap, although not exact, this will not work with filters of course, but most of the time, the admin will open an index page and start from there, so if we can improve that first view that's a big win.
It would be great if we could overload with our own paginator or having an option to select a different one for some view. It doesn't make sense for all tables, so definitely something you would want to use only when table are huge.
More info about count performance, here a good read:
https://www.citusdata.com/blog/2016/10/12/count-performance/
We're using /:context/:resource/...
Using these names might potentially introduce some naming conflicts especially with some url/form parameters.
Should change it to something else like /:kaffy_context/:kaffy_resource/...
@areski do you have any idea what's going on here?
I went crazy yesterday because of this. I'm not sure if this is css or js related since adding/removing classes to the items doesn't seem to change anything.
Versions Used
Kaffy: v0.8.0 (master)
What's actually happening?
When clicking on the dashboard page link, all the items below it are marked as active and they are expanded.
What should happen instead?
Clicking on the dashboard link should only make the dashboard item active (white) while closing all the other menu items.
We might want to consider keeping in mind when drafting kaffy for extendability.
For instance in Django-admin I have built this addons years ago to upload audio files https://github.com/areski/django-audiofield
Similar django-admin addons exists to upload images, videos etc...
This type of addons, give some flexibility in building a custom display for the file you are uploading, add some custom javascript.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.