diff --git a/README.md b/README.md index 0dd7cea..12dc5f3 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,22 @@ ## Usage -This is a [JHipster](http://jhipster.github.io/) module, that is meant to be use in a JHipster application. +This is a [JHipster](http://jhipster.github.io/) module, that is meant to be used in a JHipster application. -The module will extend the existing entities with `AbstractAuditingEntity` class to enable audits hence make sure that your entities doesn't have any superclass. +You can choose to enable audit for all entities or choose the entities to be audited from a list during generation. + +The module will extend the selected entities and its DTOs with `AbstractAuditingEntity` and `AbstractAuditingDTO` class respectively to enable audits, hence make sure that your entities/DTOs doesn't have any super class. This will also add new columns to the liquibase changeset for the entities, so it is ideal to recreate the tables if you are enabling this for existing entities. +The Audit log page is optional and can be added by choosing the option while running the generator + ### Installation As this is a [JHipster](http://jhipster.github.io/) module, we expect you have [JHipster and its related tools already installed](http://jhipster.github.io/installation.html). +This module requires Jhipster version greater than 2.26.2 in order to work + ```bash npm install -g generator-jhipster-entity-audit ``` @@ -28,6 +34,7 @@ If you want don't want to answer each question you can use ```bash yo jhipster-entity-audit default ``` +This will enable auditing for all available entities (only ones created by the jhipster:entity generator) and add the audit log page under admin ## License diff --git a/generators/app/index.js b/generators/app/index.js index 77cc3c1..31079f4 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -132,6 +132,11 @@ module.exports = yeoman.generators.Base.extend({ resourceDir + 'config/liquibase/changelog/' + this.changelogDate + '_added_entity_EntityAuditEvent.xml', TPL, this, { 'interpolate': interpolateRegex }); jhipsterFunc.addChangelogToLiquibase(this.changelogDate + '_added_entity_EntityAuditEvent'); + + jhipsterFunc.copyTemplate(webappDir + '/scripts/components/interceptor/_entity.audit.interceptor.js', webappDir + '/scripts/components/interceptor/entity.audit.interceptor.js', TPL, this); + jhipsterFunc.addJavaScriptToIndex('components/interceptor/entity.audit.interceptor.js'); + jhipsterFunc.addAngularJsInterceptor('entityAuditInterceptor'); + // add the new Listener to the 'AbstractAuditingEntity' class and add import jhipsterFunc.replaceContent(javaDir + 'domain/AbstractAuditingEntity.java', 'AuditingEntityListener.class', '{AuditingEntityListener.class, EntityAuditEventListener.class}'); jhipsterFunc.rewriteFile(javaDir + 'domain/AbstractAuditingEntity.java', @@ -179,17 +184,15 @@ module.exports = yeoman.generators.Base.extend({ jhipsterFunc.copyTemplate(webappDir + '/scripts/app/admin/entityAudit/_entityAudit.controller.js', webappDir + 'scripts/app/admin/entityAudit/entityAudit.controller.js', TPL, this); jhipsterFunc.copyTemplate(webappDir + '/scripts/app/admin/entityAudit/_entityAudit.detail.controller.js', webappDir + 'scripts/app/admin/entityAudit/entityAudit.detail.controller.js', TPL, this); jhipsterFunc.copyTemplate(webappDir + '/scripts/components/admin/_entityAudit.service.js', webappDir + 'scripts/components/admin/entityAudit.service.js', TPL, this); - jhipsterFunc.copyTemplate(webappDir + '/scripts/components/interceptor/_entity.audit.interceptor.js', webappDir + '/scripts/components/interceptor/entity.audit.interceptor.js', TPL, this); + // add the scripts to index.html jhipsterFunc.addJavaScriptToIndex('components/admin/entityAudit.service.js'); - jhipsterFunc.addJavaScriptToIndex('components/interceptor/entity.audit.interceptor.js'); jhipsterFunc.addJavaScriptToIndex('app/admin/entityAudit/entityAudit.js'); jhipsterFunc.addJavaScriptToIndex('app/admin/entityAudit/entityAudit.controller.js'); jhipsterFunc.addJavaScriptToIndex('app/admin/entityAudit/entityAudit.detail.controller.js'); // add bower dependency required jhipsterFunc.addBowerDependency('angular-object-diff', '0.6.1'); jhipsterFunc.addAngularJsModule('ds.objectDiff'); - jhipsterFunc.addAngularJsInterceptor('entityAuditInterceptor'); // add new menu entry jhipsterFunc.addElementToAdminMenu('entityAudit', 'list-alt', jhipsterVar.enableTranslation); jhipsterFunc.addTranslationKeyToAllLanguages('entityAudit', 'Entity Audit', 'addAdminElementTranslationKey', jhipsterVar.enableTranslation);