All Projects → mojotech → Torch

mojotech / Torch

Licence: mit
A rapid admin generator for Elixir & Phoenix

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Torch

Kaffy
Powerfully simple admin package for phoenix applications
Stars: ✭ 617 (-3.59%)
Mutual labels:  phoenix, admin
Fes.js
Fes.js 是一套优秀的中后台前端解决方案。提供初始项目、开发调试、Mock接口、编译打包的命令行工具。内置布局、权限、数据字典、状态管理、存储、Api等多个模块。以约定、配置化、组件化的设计思想,让用户仅仅关心用组件搭建页面内容。基于Vue.js,上手简单。经过多个项目中打磨,趋于稳定。
Stars: ✭ 579 (-9.53%)
Mutual labels:  admin
Xadmin
Drop-in replacement of Django admin comes with lots of goodies, fully extensible with plugin support, pretty UI based on Twitter Bootstrap.
Stars: ✭ 4,627 (+622.97%)
Mutual labels:  admin
Phoenix swagger
Swagger integration to Phoenix framework
Stars: ✭ 533 (-16.72%)
Mutual labels:  phoenix
Qor
QOR is a set of libraries written in Go that abstracts common features needed for business applications, CMSs, and E-commerce systems.
Stars: ✭ 4,905 (+666.41%)
Mutual labels:  admin
Vue Seed
a boilerplate for large vue project with ElementUI 2.x
Stars: ✭ 555 (-13.28%)
Mutual labels:  admin
Vuetify Admin Dashboard
A Crud Admin panel made from Vue js and Vuetify
Stars: ✭ 481 (-24.84%)
Mutual labels:  admin
Yii2admin
通用的yii2后台,基于Yii2的advanced应用程序模板,整合RBAC、Menu、Config、Migration多语言、RESTfull等等...
Stars: ✭ 619 (-3.28%)
Mutual labels:  admin
Django Jazzmin
Jazzy theme for Django
Stars: ✭ 574 (-10.31%)
Mutual labels:  admin
Snake
🚀thinkphp5.1 + layui 实现的带rbac的基础管理后台,方便快速开发法使用
Stars: ✭ 526 (-17.81%)
Mutual labels:  admin
Cleopatra
Admin Dashboard Template Built On Tailwind CSS
Stars: ✭ 521 (-18.59%)
Mutual labels:  admin
Vue Quasar Admin
Vue 2.0 admin-dashboard based on Quasar-Framework
Stars: ✭ 516 (-19.37%)
Mutual labels:  admin
Ex venture
Text based MMORPG engine written in Elixir
Stars: ✭ 559 (-12.66%)
Mutual labels:  phoenix
Aurora
Cross-platform beanstalkd queue server admin console.
Stars: ✭ 508 (-20.62%)
Mutual labels:  admin
Ruoyi Vue
(RuoYi)官方仓库 基于SpringBoot,Spring Security,JWT,Vue & Element 的前后端分离权限管理系统
Stars: ✭ 596 (-6.87%)
Mutual labels:  admin
Sail
Sail is a lightweight Rails engine that brings an admin panel for managing configuration settings on a live Rails app
Stars: ✭ 484 (-24.37%)
Mutual labels:  admin
Ngx Admin
Customizable admin dashboard template based on Angular 10+
Stars: ✭ 23,286 (+3538.44%)
Mutual labels:  admin
Flask Profiler
a flask profiler which watches endpoint calls and tries to make some analysis.
Stars: ✭ 622 (-2.81%)
Mutual labels:  admin
Go Admin
A golang framework helps gopher to build a data visualization and admin panel in ten minutes
Stars: ✭ 5,580 (+771.88%)
Mutual labels:  admin
Rest Admin
Restful Admin Dashboard Based on Vue and Boostrap 4
Stars: ✭ 565 (-11.72%)
Mutual labels:  admin

License Hex.pm Build Status Coverage Status

Torch

Torch is a rapid admin generator for Phoenix applications. It creates custom templates and relies on the Phoenix HTML generator under the hood.

image

Installation

To install Torch, perform the following steps:

  1. Add torch to your list of dependencies in mix.exs. Then, run mix deps.get:
def deps do
  [
    {:torch, "~> 3.4"}
  ]
end
  1. Add a Plug.Static plug to your endpoint.ex:
plug(
  Plug.Static,
  at: "/torch",
  from: {:torch, "priv/static"},
  gzip: true,
  cache_control_for_etags: "public, max-age=86400"
)
  1. Configure Torch by adding the following to your config.exs.
config :torch,
  otp_app: :my_app_name,
  template_format: "eex" || "slime"
  1. Run mix torch.install

NOTE: You can also choose to use slime templates, but you will need to first install Phoenix Slime and then update your configuration to specify template_format: "slime".

Now you're ready to start generating your admin! 🎉

Usage

Torch uses Phoenix generators under the hood. Torch injects it's own custom templates into your priv/static directory, then runs the mix phx.gen.html task with the options you passed in. Finally, it uninstalls the custom templates so they don't interfere with running the plain Phoenix generators.

In light of that fact, the torch.gen.html task takes all the same arguments as the phx.gen.html, but does some extra configuration on either end. Checkout mix help phx.gen.html for more details about the supported options and format.

For example, if we wanted to generate a blog with a Post model we could run the following command:

$ mix torch.gen.html Blog Post posts title:string body:text published_at:datetime published:boolean views:integer

The output would look like:

Add the resource to your browser scope in lib/my_app_web/router.ex:

    resources "/posts", PostController

Ensure the following is added to your endpoint.ex:

    plug(
      Plug.Static,
      at: "/torch",
      from: {:torch, "priv/static"},
      gzip: true,
      cache_control_for_etags: "public, max-age=86400",
      headers: [{"access-control-allow-origin", "*"}]
    )

  🔥 Torch generated html for Posts! 🔥

Torch also installed an admin layout into your my_app_web/templates/layout/torch.html.eex. You will want to update it to include your new navigation link:

<nav class="torch-nav">
  <a href="/posts">Posts</a>
</nav>

There may be times when you are adding Torch into an already existing system where your application already contains the modules and controllers and you just want to use the Torch admin interface. Since the torch.gen mix tasks are just wrappers around the existing phx.gen tasks, you can use most of the same flags. To add an admin interface for Posts in the previous example, where the model and controller modules already exist, use the following command:

$ mix torch.gen.html Blog Post posts --no-schema --no-context --web Admin title:string body:text published_at:datetime published:boolean views:integer

Association filters

Torch does not support association filters at this time. Filtrex does not yet support them.

You can checkout these two issues to see the latest updates:

https://github.com/rcdilorenzo/filtrex/issues/55

https://github.com/rcdilorenzo/filtrex/issues/38

However, that does not mean you can't roll your own.

Example

We have a Accounts.User model that has_many :credentials, Accounts.Credential and we want to support filtering users by credentials.email.

  1. Update the Accounts domain.
# accounts.ex
...
defp do_paginate_users(filter, params) do
  credential_params = Map.get(params, "credentials")
  params = Map.drop(params, ["credentials"])

  User
  |> Filtrex.query(filter)
  |> credential_filters(credential_params)
  |> order_by(^sort(params))
  |> paginate(Repo, params, @pagination)
end

defp credential_filters(query, nil), do: query

defp credential_filters(query, params) do
  search_string = "%#{params["email"]}%"

  from(u in query,
    join: c in assoc(u, :credentials),
    where: like(c.email, ^search_string),
    group_by: u.id
  )
end
...
  1. Update form filters.
# users/index.html.eex
<div class="field">
  <label>Credential email</label>
  <%= text_input(:credentials, :email, value: maybe(@conn.params, ["credentials", "email"])) %>
</div>

Note: You'll need to install & import Maybe into your views {:maybe, "~> 1.0.0"} for the above eex to work.

Styling

Torch generates two CSS themes you can use: base.css & theme.css. The base styles are basically bare bones, and the theme styles look like the screenshot above. Just change the stylesheet link in the torch.html.eex layout.

If you want to use the theme, but override the colors, you'll need to include your own stylesheet with the specific overrides.

Internationalization

Torch comes with .po files for several locales. If you are using Torch and can provide us with translation files for other languages, please submit a Pull Request with the translation file. We'd love to add as many translations as possible.

If you wish to add your own customized translations, you can configure Torch to use your own custom MessagesBackend and adding it in your Torch configuration settings in config.exs. You can find the all messages that can be customized in the default i18n/backend.ex file.

If you are customizing a backend for a "standard" spoken language, please submit back a proper .po translation file for us to include in the official Torch releases so other users can take advantage.

Example

defmodule MyApp.CustomMessagesBackend do
  def message("Contains"), do: "** CUSTOM Contains **"
  def message("Equals"), do: "** CUSTOM Equals ****"
  def message("< Prev"), do: "<--"
  def message("Next >"), do: "-->"

  # You can add a fallback so it won't break with newly added messages or
  # messages you did not customize
  def message(text), do: Torch.I18n.Backend.message(text)
end
# config.exs
config :torch,
  otp_app: :my_app_name,
  i18n_backend: MyApp.CustomMessagesBackend
  template_format: "eex" || "slime"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].