Mar 6, 2015

Another Method for Admin screens with Grails

I came from a background of making sites with Django and after I starting going head-first into Grails, one of the things I missed was a really good and easy to make an admin section. You know — something that “just works” to do some basic CRUD. I know that there is the scaffolding plugin but the problem with that is that it’s not always robust and it’s not easily configurable. I want my admin pages to be look nice as well as being robust.

A little while ago I bumped into the admin-interface plugin, which pretty much does everything that I had hoped for. There is a bit of configuration but it’s not much more than what you had to do in Django. I have a very simple github project for you to play with.

If you look at the bottom of the Config.groovy you will see some simple configurations:

The AuthorAdmin and BookAdmin are little descriptor files that say what fields should appear to be and what order. I found that admin-interface really isn’t that smart — that the fields aren’t listed in any sensible order so I think that file is quite necessary. It’s not even smart enough to remove dateCreated and lastUpdate which Scaffolding does just fine! My sample Author file looked like this:

Admin page with random order

You just have to add the field to the list. This isn’t quite the magic I was hoping for, but it’s only small change, as oppose to generating GSPs or editing them to put in a field.

It’s not like these files are complicated. See below for the Author’s admin file:

And then admin page looks immediately better:

Much better!

I didn’t do it in my example but it can use Spring Security to define what role has access to the Admin section. You can also define the URL and put different domains in logical groups. These are things that this plugin does better than Scaffolding.

I think the admin-interface plugin can easily replace the scaffolding plugin and have happier users too.

About the Author

Mike Hostetler profile.

Mike Hostetler

Principal Technologist

Mike has almost 20 years of experience in technology. He started in networking and Unix administration, and grew into technical support and QA testing. But he has always done some development on the side and decided a few years ago to pursue it full-time. His history of working with users gives Mike a unique perspective on writing software.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Blog Posts
Setup Spring DataSource from values stored in AWS Secret Manager
I was tasked migrating an application to AWS recently. The company wanted the application to store the database credentials in AWS’s Secret Manager. The issue that I had is that if I setup a configuration […]
Up to Spec: JavaScript Numeric Separators
Let's take a look at the proposal to add Numeric Separators to the JavaScript specification.
Using Conftest to Validate Configuration Files
Conftest is a utility within the Open Policy Agent ecosystem that helps simplify writing validation tests against configuration files. In a previous blog post, I wrote about using the Open Policy Agent utility directly to […]
SwiftGen with Image & Color Asset Catalogs
You might remember back in 2015 when iOS 9 was introduced, and we were finally given a way to manage all of our assets in one place with Asset Catalogs. A few years later, support […]