-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from mshima/adjusts
reimplement angular-audit and adjust javers
- Loading branch information
Showing
12 changed files
with
255 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"ngx-diff": "6.0.1" | ||
"ngx-diff": "8.0.4" | ||
} | ||
} |
49 changes: 16 additions & 33 deletions
49
...it/templates/src/main/webapp/app/admin/entity-audit/entity-audit-modal.component.html.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,27 @@ | ||
<div class="modal-header"> | ||
<h4 class="modal-title" <%= jhiPrefix %>Translate="entityAudit.detail.title"> | ||
Audit Details | ||
</h4> | ||
<button | ||
<%_ if (enableTranslation) { _%> | ||
attr.aria-label="{{ 'entityAudit.detail.close' | translate }}" | ||
<%_ } else { _%> | ||
aria-label="Close" | ||
<%_ } _%> | ||
data-dismiss="modal" class="close" type="button" | ||
(click)="activeModal.dismiss('closed')"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
<h4 class="modal-title">__jhiTranslateTag__('entityAudit.detail.title')</h4> | ||
|
||
<span class="btn btn-close" data-dismiss="modal" aria-hidden="true" (click)="activeModal.dismiss('closed')"></span> | ||
</div> | ||
<div class="modal-body pad"> | ||
<div> | ||
<strong<% if (enableTranslation) { %> | ||
<%= jhiPrefix %>Translate="entityAudit.detail.action" | ||
[translateValues]="{ action: action }"<% } %>> | ||
{{action}} action was performed on below data | ||
</strong> | ||
<br><br> | ||
<strong>__jhiTranslateTag__('entityAudit.detail.action', { "action": "action" })</strong> | ||
<br /><br /> | ||
|
||
<del class="diff diff-key" <%= jhiPrefix %>Translate="entityAudit.detail.old"> | ||
Old/Removed value | ||
</del> | ||
| ||
<ins class="diff diff-key" <%= jhiPrefix %>Translate="entityAudit.detail.new"> | ||
New/Added value | ||
</ins> | ||
<del class="ngx-diff-light-theme">__jhiTranslateTag__('entityAudit.detail.old')</del> | ||
| ||
<ins class="ngx-diff-light-theme">__jhiTranslateTag__('entityAudit.detail.new')</ins> | ||
</div> | ||
<br> | ||
<br /> | ||
|
||
<label <%= jhiPrefix %>Translate="entityAudit.detail.changedFields">Changed Fields</label> | ||
<inline-diff *ngIf="left && right" class="code" [oldText]="left" [newText]="right" /> | ||
<label>__jhiTranslateTag__('entityAudit.detail.changedFields')</label> | ||
<ngx-unified-diff *ngIf="left && right" class="ngx-diff-light-theme" [before]="left" [after]="right" /> | ||
</div> | ||
<div class="modal-footer"> | ||
<button | ||
data-dismiss="modal" class="btn btn-secondary float-left" | ||
type="button" (click)="activeModal.dismiss('closed')"> | ||
Done | ||
</button> | ||
data-dismiss="modal" | ||
class="btn btn-secondary float-left" | ||
type="button" | ||
(click)="activeModal.dismiss('closed')" | ||
>__jhiTranslateTag__('entityAudit.detail.close')</button> | ||
</div> |
94 changes: 40 additions & 54 deletions
94
...udit/templates/src/main/webapp/app/admin/entity-audit/entity-audit-modal.component.ts.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,52 @@ | ||
import { Component } from '@angular/core'; | ||
import { HttpResponse } from '@angular/common/http'; | ||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; | ||
import { InlineDiffComponent } from 'ngx-diff'; | ||
import { UnifiedDiffComponent } from 'ngx-diff'; | ||
|
||
import SharedModule from 'app/shared/shared.module'; | ||
import { EntityAuditService } from './entity-audit.service'; | ||
import { EntityAuditEvent } from './entity-audit-event.model'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '<%= jhiPrefixDashed %>-entity-audit-modal', | ||
templateUrl: './entity-audit-modal.component.html', | ||
imports: [SharedModule, InlineDiffComponent], | ||
styles: [` | ||
/* NOTE: for now the ::ng-deep shadow-piercing descendant combinator is | ||
* required because Angular defaults to emulated view encapsulation and | ||
* preprocesses all component styles to approximate shadow scoping | ||
* rules. This means these styles wouldn't apply to the HTML generated | ||
* by ng-diff-match-patch. | ||
* | ||
* This shouldn't be required when browsers support native | ||
* encapsulation, at which point ::ng-deep will also be deprecated/removed | ||
* see https://angular.io/guide/component-styles | ||
*/ | ||
|
||
:host ::ng-deep ins { | ||
color: black; | ||
background: #bbffbb; | ||
} | ||
|
||
:host ::ng-deep del { | ||
color: black; | ||
background: #ffbbbb; | ||
} | ||
|
||
.code { | ||
background: #dcdada; | ||
padding: 10px; | ||
} | ||
`] | ||
standalone: true, | ||
selector: '<%= jhiPrefixDashed %>-entity-audit-modal', | ||
templateUrl: './entity-audit-modal.component.html', | ||
imports: [SharedModule, UnifiedDiffComponent], | ||
styles: [ | ||
` | ||
@import 'ngx-diff/styles/default-theme'; | ||
|
||
ins { | ||
color: black; | ||
background-color: var(--ngx-diff-inserted-background-color); | ||
} | ||
|
||
del { | ||
color: black; | ||
background-color: var(--ngx-diff-deleted-background-color); | ||
} | ||
`, | ||
], | ||
}) | ||
export default class EntityAuditModalComponent { | ||
action?: string; | ||
left?: string; | ||
right?: string; | ||
|
||
constructor( | ||
private service: EntityAuditService, | ||
public activeModal: NgbActiveModal | ||
) {} | ||
|
||
openChange(audit: EntityAuditEvent): void { | ||
this.service.getPrevVersion( | ||
audit.entityType, audit.entityId, audit.commitVersion! | ||
).subscribe((res: HttpResponse<EntityAuditEvent>) => { | ||
const data: EntityAuditEvent = res.body!; | ||
const previousVersion = JSON.stringify(JSON.parse(data.entityValue ?? '{}'), null, 2); | ||
const currentVersion = JSON.stringify(audit.entityValue, null, 2); | ||
|
||
this.action = audit.action; | ||
this.left = previousVersion; | ||
this.right = currentVersion; | ||
}); | ||
} | ||
action?: string; | ||
left?: string; | ||
right?: string; | ||
|
||
constructor( | ||
private service: EntityAuditService, | ||
public activeModal: NgbActiveModal, | ||
) {} | ||
|
||
openChange(audit: EntityAuditEvent): void { | ||
this.service.getPrevVersion(audit.entityType, audit.entityId, audit.commitVersion!).subscribe((res: HttpResponse<EntityAuditEvent>) => { | ||
const data: EntityAuditEvent = res.body!; | ||
const previousVersion = JSON.stringify(JSON.parse(data.entityValue ?? '{}'), null, 2); | ||
const currentVersion = JSON.stringify(audit.entityValue, null, 2); | ||
|
||
this.action = audit.action; | ||
this.left = previousVersion; | ||
this.right = currentVersion; | ||
}); | ||
} | ||
} |
Oops, something went wrong.