Git Product home page Git Product logo

light-admin's Introduction

LightAdmin - [PoC] Pluggable CRUD UI library for Java web applications

The primary goal of this PoC project is to speed up application development by bringing pluggable fully operational data management back-end for JPA based applications and to relieve your codebase for more important stuff.

Features

  • DSL configurations: Allows developers to easily configure their administration user interface
  • Displaying persistent entities: Customizable Listing & Quick Views with paging & sorting capabilities
  • CRUD operations: Complete entities manipulation support (including their associations)
  • Automatic Validation: JSR-303 annotation-based validation rules support
  • Search: Allows users to search entities by text fields, dates, numeric values & associations
  • Filtering Scopes: Use scopes to filter data by predefined criteria
  • Pluggable Security: Authentication based on Spring Security
  • REST API: Enriching your application with REST API based on Spring Data REST
  • Easy integration: Servlet 2.5/3.0 web applications supported

Integration examples

Documentation & Support

Bug Reports

License

  • LightAdmin is released under version 2.0 of the Apache License.

Contribute

You're interested in contributing to LightAdmin? AWESOME. Here are the basic steps:

  • Fork LightAdmin from here: http://github.com/la-team/light-admin
  • Clone your fork
  • Hack away
  • If necessary, rebase your commits into logical chunks, without errors
  • Verify your code by running the test suite, and adding additional tests if able
  • Push the branch up to GitHub
  • Send a pull request to the la-team/light-admin project

We'll do our best to get your changes in!

Getting started

Declare maven dependency for using with Spring 4.0.X directly from Maven Central

<dependency>
  <groupId>org.lightadmin</groupId>
  <artifactId>lightadmin</artifactId>
  <version>1.2.0.RC1</version>
</dependency> 

or

<dependency>
  <groupId>org.lightadmin</groupId>
  <artifactId>lightadmin</artifactId>
  <version>1.2.0.BUILD-SNAPSHOT</version>
</dependency> 

For snapshots and LightAdmin compatible with Spring 3.2.X, please declare LA Nexus repositories:

<repositories>
  <repository>
    <id>lightadmin-nexus-releases</id>
    <url>http://lightadmin.org/nexus/content/repositories/releases</url>
    <releases>
      <enabled>true</enabled>
      <updatePolicy>always</updatePolicy>
    </releases>
  </repository>
  <repository>
    <id>lightadmin-nexus-snapshots</id>
    <url>http://lightadmin.org/nexus/content/repositories/snapshots</url>
    <snapshots>
      <enabled>true</enabled>
      <updatePolicy>always</updatePolicy>
    </snapshots>
  </repository>  
</repositories>

And dependency

<dependency>
  <groupId>org.lightadmin</groupId>
  <artifactId>lightadmin</artifactId>
  <version>1.0.0.M2</version>
</dependency> 

Enable LightAdmin web-module in your web.xml if you have one:

<context-param>
  <param-name>light:administration:base-url</param-name>
  <param-value>/admin</param-value>
</context-param>

<context-param>
  <param-name>light:administration:security</param-name>
  <param-value>true</param-value>
</context-param>

<context-param>
  <param-name>light:administration:base-package</param-name>
  <param-value>[package with @Administration configurations, ex.: org.lightadmin.demo.config]</param-value>
</context-param>

Or enable LightAdmin web-module in your WebApplicationInitializer:

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
  servletContext.setInitParameter(LIGHT_ADMINISTRATION_BASE_URL, "/admin");
  servletContext.setInitParameter(LIGHT_ADMINISTRATION_BACK_TO_SITE_URL, "http://lightadmin.org");
  servletContext.setInitParameter(LIGHT_ADMINISTRATION_BASE_PACKAGE, "org.lightadmin.administration");

  super.onStartup(servletContext);
}

Include your JPA persistence provider of choice (Hibernate, EclipseLink, OpenJpa) and setup basic Spring JPA configuration.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jdbc="http://www.springframework.org/schema/jdbc"
       xmlns:jpa="http://www.springframework.org/schema/data/jpa"
       xsi:schemaLocation="http://www.springframework.org/schema/jdbc 
                           http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
                           http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/data/jpa
                           http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
  
  <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="jpaVendorAdapter">
      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
    </property>
  </bean>

  <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
  </bean>

</beans>

Create an entity:

@Entity
public class User {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Integer id;
  private String firstname;
  private String lastname;
       
  // Getters and setters
}

Create an @Administration configuration in the package defined in web.xml previously:

public class UserAdministration extends AdministrationConfiguration<User> {

  public EntityMetadataConfigurationUnit configuration( EntityMetadataConfigurationUnitBuilder configurationBuilder ) {
    return configurationBuilder.nameField( "firstname" ).build();
  }

  public ScreenContextConfigurationUnit screenContext( ScreenContextConfigurationUnitBuilder screenContextBuilder ) {
    return screenContextBuilder
      .screenName( "Users Administration" )
      .menuName( "Users" )
      .build();
  }

  public FieldSetConfigurationUnit listView( final FieldSetConfigurationUnitBuilder fragmentBuilder ) {
    return fragmentBuilder
      .field( "firstname" ).caption( "First Name" )
      .field( "lastname" ).caption( "Last Name" )
      .build();
  }

Voila! You have a brand new LightAdmin back-end configured.

Check Out and Build from Source

  1. Clone the repository from GitHub:

     $ git clone git://github.com/la-team/light-admin.git
    
  2. Navigate into the cloned repository directory:

     $ cd light-admin
    
  3. The project uses Maven to build:

     $ mvn clean install
    

Running from the Command Line

By default, the app will run in 'embedded' mode which does not require any external setup. The Tomcat 7 Maven plugin is configured for you in the POM file.

  1. Navigate into demo application directory:

     $ cd lightadmin-sandbox
    
  2. Launch Tomcat from the command line:

     $ mvn tomcat7:run
    
  3. Access the deployed webapp at

     http://localhost:8080/lightadmin-sandbox
    

LightAdmin integration example

We prepared an example how easily you can integrate LightAdmin back-end to existing web application.

It's based on Spring Travel reference application.

  1. Clone the repository from GitHub:

     $ git clone git://github.com/la-team/lightadmin-spring-travel.git
    
  2. Navigate into the cloned repository directory:

     $ cd lightadmin-spring-travel
    
  3. The project uses Maven to build:

     $ mvn clean install
    
  4. Launch Tomcat from the command line:

     $ mvn tomcat7:run
    
  5. Access the deployed webapp at

     http://localhost:8080/booking-mvc
    

Screenshots

Login to LightAdmin:

Login view

Dashboard:

Dashboard view

List of persistent entities configured:

List view

Search entities by criteria:

List view & Filtering

Quick view for particular entity:

Quick view

Editing entity:

Form view

Show entity with all fields:

Show view

light-admin's People

Contributors

aliubunia avatar disciolli avatar elwin013 avatar ikostenko avatar indyaah avatar jimmyfm avatar linsy avatar max-dev avatar servy avatar volkan avatar yilo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

light-admin's Issues

UI tests performance improvement

To increase the performance of UI tests, the following optimizations should be done:

  1. Log in and navigation should be performed once per test class
  2. Decrease component load wait timeout

EditView: handling of orphan removal & ignoring errors for hidden fields

When editing a record of an entity where @OneToMany field has orphanRemoval = true, an alert is displayed containing the following message
"A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: org.lightadmin.demo.model.Customer.addresses; nested exception is org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: org.lightadmin.demo.model.Customer.addresses"

To reproduce, try to save any entry of "Customer" entity.

Question 1. What should be the expected result?
Question 2. adresses field is not specified in Form View of CustomerAdministration. Shouldn't errors for fields hidden from Form View be ignored?

Table View: Sorting resets paging

In a table with more than one page go to page # 2 > sort the table by a column

Expected result: page # 2 is still displayed, items are sorted by the appropriate column

Actual result: items are sorted by the appropriate column, but page # 1 is displayed

Edit View: two records cannot have the same value in OneToMany field

  1. Enter 'Customer' domain: observe that Customer # 2 has value of 'Ukraine, Kiev, Kiev' in the 'Addresses' field
  2. Edit Customer # 4:

Expected result: 'Ukraine, Kiev, Kiev' is not present in the 'Addresses' field

Actual result: it is possible to select value of 'Ukraine, Kiev, Kiev' (which is already selected for Customer # 2), and save Customer # 4
In this case Customer # 2 will have an empty 'Addresses' field

Edit Form View

We need to support rendering, binding & validation of commonly used part of JPA attribute types.

Filter: no validation for fixed format fields

When entering f.ex., a string into an integer field, no validation is displayed, and the following exception is thrown in console:
ERROR o.s.d.r.w.RepositoryRestController - Parameter value [%s%] did not match expected type [java.math.BigDecimal] java.lang.IllegalArgumentException: Parameter value [%s%] did not match expected type [java.math.BigDecimal] at org.hibernate.ejb.AbstractQueryImpl.validateParameterBinding(AbstractQueryImpl.java:375) ~[hibernate-entitymanager-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.ejb.AbstractQueryImpl.registerParameterBinding(AbstractQueryImpl.java:348) ~[hibernate-entitymanager-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:375) ~[hibernate-entitymanager-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.ejb.criteria.CriteriaQueryCompiler$1$1.bind(CriteriaQueryCompiler.java:195) ~[hibernate-entitymanager-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.ejb.criteria.CriteriaQueryCompiler.compile(CriteriaQueryCompiler.java:241) ~[hibernate-entitymanager-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:587) ~[hibernate-entitymanager-4.1.6.Final.jar:4.1.6.Final] at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source) ~[na:na] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_34] at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_34] at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365) ~[spring-orm-3.1.2.RELEASE.jar:3.1.2.RELEASE] at $Proxy31.createQuery(Unknown Source)

Fields not added to the Entity class are displayed on the List view

A field on ListView should be displayed only when all of the following conditions are met:

  1. the field is added to database table
  2. the field is added to the Entity class
  3. the field is added to the listView in EntityAdministration class

Currently, a column is displayed on a List View when only # 1 and # 3 above are met.

Getting started

Please update according to the latest infrastructural changes.

Filter and Scope should complement each other

When search is performed by a filter criteria while some scope is selected, the List View should display items both matching the selected criteria AND the selected scope

UI tests:
FilteringScopedResultTest.resettingFilterDoesNotResetScope()
FilteringScopedResultTest.scopeIsAppliedToFilteredCustomers()

EditView: no validation for fixed format fields

Integer Field
I.e. when entering characters into a Integer field, no validation is displayed, and the following exception is thrown in console:
[INFO] [talledLocalContainer] org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Can not construct instance of java.math.BigDecimal from String value 'kkk': not a valid representation [INFO] [talledLocalContainer] at [Source: org.apache.catalina.connector.CoyoteInputStream@9e3b21; line: 1, column: 2]; nested exception is org.codehaus.jackson.map.JsonMappingException: Can not construct instance of java.math.BigDecimal from String value 'kkk': not a valid representation [INFO] [talledLocalContainer] at [Source: org.apache.catalina.connector.CoyoteInputStream@9e3b21; line: 1, column: 2] [INFO] [talledLocalContainer] at org.springframework.data.rest.webmvc.RepositoryAwareMappingHttpMessageConverter.readInternal(RepositoryAwareMappingHttpMessageConverter.java:165) ~[spring-data-rest-webmvc-1.0.0.RELEASE.jar:na] [INFO] [talledLocalContainer] at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:153) ~[spring-web-3.1.3.RELEASE.jar:3.1.3.RELEASE] ...

BigDecimal Field
When entering a value that is out of the defined range (f.ex., enter 1234,123 into a field defined as DECIMAL(3,2)), an alert is displayed, and the following exception is thrown in console:
[INFO] [talledLocalContainer] Caused by: org.hsqldb.HsqlException: data exception: numeric value out of range [INFO] [talledLocalContainer] at org.hsqldb.error.Error.error(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8] [INFO] [talledLocalContainer] at org.hsqldb.error.Error.error(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8] [INFO] [talledLocalContainer] at org.hsqldb.types.NumberType.convertToType(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8] [INFO] [talledLocalContainer] at org.hsqldb.StatementDML.getUpdatedData(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8] [INFO] [talledLocalContainer] at org.hsqldb.StatementDML.executeUpdateStatement(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8] [INFO] [talledLocalContainer] at org.hsqldb.StatementDML.getResult(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8] [INFO] [talledLocalContainer] at org.hsqldb.StatementDMQL.execute(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8] [INFO] [talledLocalContainer] at org.hsqldb.Session.executeCompiledStatement(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8] [INFO] [talledLocalContainer] at org.hsqldb.Session.execute(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8]

List View: error when a complex data type field is empty

When no LineItems are associated with an order, the following error message is displayed, and it is impossible to view 'Quick Look' for the order:
"DataTables warning (table id = 'orderTable'): Requested unknown parameter 'lineItems.0' from the data source for row 1"

Filter does not search by numeric fields

Nothing happens when trying to search by a numeric field, and the following exception is shown in the console:

java.lang.IllegalArgumentException: Parameter value [%49.00%] did not match expected type [java.math.BigDecimal] at org.hibernate.ejb.AbstractQueryImpl.validateParameterBinding(AbstractQueryImpl.java:375) ~[hibernate-entitymanager-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.ejb.AbstractQueryImpl.registerParameterBinding(AbstractQueryImpl.java:348) ~[hibernate-entitymanager-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:375) ~[hibernate-entitymanager-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.ejb.criteria.CriteriaQueryCompiler$1$1.bind(CriteriaQueryCompiler.java:195) ~[hibernate-entitymanager-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.ejb.criteria.CriteriaQueryCompiler.compile(CriteriaQueryCompiler.java:241) ~[hibernate-entitymanager-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:587) ~[hibernate-entitymanager-4.1.6.Final.jar:4.1.6.Final] at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source) ~[na:na] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_34] at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_34] at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)

Search result is not re-filtered after item deletion

Filter items so that f.ex., two items are displayed in the search result > Delete one of the items

Expected result: one item is displayed

Actual result: all existing items are displayed, although the filter criteria is not cleared

Batch actions

Batch Delete & Update fields actions (Select/Deselect All).

EditView: ManyToOne fields cannot be saved with an empty value

Edit any entry in "Orders" domain > De-select "Billing Address":

Expected result: an entry is saved, no value is shown for "Billing Address" field

Actual result: an alert is shown with the following message: "Array index out of range: 1". No exceptions in console

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.