#707 Loggable
This commit is contained in:
parent
f2d5e6afee
commit
86f6253ed7
|
@ -1,10 +1,9 @@
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="/client/api/ClientLogs"
|
url="/client/api/ClientLogs"
|
||||||
filter="$ctrl.filter"
|
|
||||||
link="{originFk: $ctrl.$stateParams.id}"
|
link="{originFk: $ctrl.$stateParams.id}"
|
||||||
limit="20"
|
limit="20"
|
||||||
data="logs" on-data-change="$ctrl.onDataChange()">
|
data="$ctrl.logs">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
|
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
|
@ -15,39 +14,63 @@
|
||||||
<vn-thead>
|
<vn-thead>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
<vn-th field="creationDate" default-order="DESC">Date</vn-th>
|
<vn-th field="creationDate" default-order="DESC">Date</vn-th>
|
||||||
<vn-th field="model">Model</vn-th>
|
<vn-th field="userFk" class="expendable">Changed by</vn-th>
|
||||||
<vn-th field="action">Action</vn-th>
|
<vn-th field="changedModel" class="expendable">Model</vn-th>
|
||||||
<vn-th field="userFk">Changed by</vn-th>
|
<vn-th field="action" class="expendable">Action</vn-th>
|
||||||
<vn-th field="before">Before</vn-th>
|
<vn-th field="changedModelValue" class="expendable">Instance</vn-th>
|
||||||
<vn-th field="after">After</vn-th>
|
<vn-th>Before</vn-th>
|
||||||
|
<vn-th>After</vn-th>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="clientLog in logs">
|
<vn-tr ng-repeat="clientLog in $ctrl.logs">
|
||||||
<vn-td>
|
<vn-td>
|
||||||
{{::clientLog.creationDate | date:'dd/MM/yyyy HH:mm'}}
|
{{::clientLog.creationDate | date:'dd/MM/yyyy HH:mm'}}
|
||||||
|
<div class="changes">
|
||||||
|
<div>
|
||||||
|
<span translate class="label">Changed by</span><span class="label">: </span>
|
||||||
|
<span translate class="value">{{::clientLog.user.name}}</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span translate class="label">Model</span><span class="label">: </span>
|
||||||
|
<span translate class="value">{{::clientLog.changedModel}}</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span translate class="label">Action</span><span class="label">: </span>
|
||||||
|
<span translate class="value">{{::clientLog.action}}</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span translate class="label">Instance</span><span class="label">: </span>
|
||||||
|
<span translate class="value">{{::clientLog.changedModelValue}}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td>
|
<vn-td class="expendable">
|
||||||
{{::clientLog.model}}
|
|
||||||
</vn-td>
|
|
||||||
<vn-td translate>
|
|
||||||
{{::clientLog.action}}
|
|
||||||
</vn-td>
|
|
||||||
<vn-td>
|
|
||||||
{{::clientLog.user.name}}
|
{{::clientLog.user.name}}
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td>
|
<vn-td class="expendable">
|
||||||
|
{{::clientLog.changedModel}}
|
||||||
|
</vn-td>
|
||||||
|
<vn-td translate class="expendable">
|
||||||
|
{{::clientLog.action}}
|
||||||
|
</vn-td>
|
||||||
|
<vn-td class="expendable">
|
||||||
|
{{::clientLog.changedModelValue}}
|
||||||
|
</vn-td>
|
||||||
|
<vn-td class="before">
|
||||||
<vn-one ng-repeat="old in clientLog.oldProperties">
|
<vn-one ng-repeat="old in clientLog.oldProperties">
|
||||||
<vn-label-value label="{{old.key}}"
|
<div>
|
||||||
value="{{old.value}}">
|
<span translate class="label">{{::old.key}}</span><span class="label">: </span>
|
||||||
</vn-label-value>
|
<span translate class="value">{{::old.value}}</span>
|
||||||
|
</div>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td>
|
<vn-td class="after">
|
||||||
<vn-one ng-repeat="new in clientLog.newProperties">
|
<vn-one ng-repeat="new in clientLog.newProperties">
|
||||||
<vn-label-value label="{{new.key}}"
|
<div>
|
||||||
value="{{new.value}}">
|
<span translate class="label">{{::new.key}}</span><span class="label">: </span>
|
||||||
</vn-label-value>
|
<span translate class="value">{{::new.value}}</span>
|
||||||
|
</div>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
|
import './style.scss';
|
||||||
|
|
||||||
class Controller {
|
class Controller {
|
||||||
constructor($scope, $stateParams) {
|
constructor($scope, $stateParams) {
|
||||||
|
@ -14,13 +15,18 @@ class Controller {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
onDataChange() {
|
get logs() {
|
||||||
let logs = this.$scope.model.data;
|
return this._logs;
|
||||||
|
}
|
||||||
|
|
||||||
logs.forEach(log => {
|
set logs(value) {
|
||||||
log.oldProperties = this.getInstance(log.oldInstance);
|
this._logs = value;
|
||||||
log.newProperties = this.getInstance(log.newInstance);
|
|
||||||
});
|
if (this.logs)
|
||||||
|
this.logs.forEach(log => {
|
||||||
|
log.oldProperties = this.getInstance(log.oldInstance);
|
||||||
|
log.newProperties = this.getInstance(log.newInstance);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getInstance(instance) {
|
getInstance(instance) {
|
||||||
|
|
|
@ -7,20 +7,20 @@ describe('Client', () => {
|
||||||
let controller;
|
let controller;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
angular.mock.module('client');
|
ngModule('client');
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(angular.mock.inject((_$componentController_, $rootScope) => {
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope) => {
|
||||||
$componentController = _$componentController_;
|
$componentController = _$componentController_;
|
||||||
$scope = $rootScope.$new();
|
$scope = $rootScope.$new();
|
||||||
controller = $componentController('vnClientHistory', {$scope: $scope});
|
controller = $componentController('vnClientHistory', {$scope: $scope});
|
||||||
controller.$scope.model = {data: [{newInstance: {id: 1}, oldInstance: {id: 2}}]}
|
controller.$scope.model = {data: [{newInstance: {id: 1}, oldInstance: {id: 2}}]};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('onDataChange()', () => {
|
describe('logs setter', () => {
|
||||||
it('should call the function getInstance() twice', () => {
|
it('should call the function getInstance() twice', () => {
|
||||||
spyOn(controller, 'getInstance').and.callFake(() => {});
|
spyOn(controller, 'getInstance');
|
||||||
controller.onDataChange();
|
controller.logs = [{newInstance: {id: 1}, oldInstance: {id: 2}}];
|
||||||
|
|
||||||
expect(controller.getInstance.calls.count()).toBe(2);
|
expect(controller.getInstance.calls.count()).toBe(2);
|
||||||
expect(controller.getInstance).toHaveBeenCalledWith({id: 1});
|
expect(controller.getInstance).toHaveBeenCalledWith({id: 1});
|
||||||
|
|
|
@ -3,7 +3,7 @@ Action: Acción
|
||||||
Changed by: Cambiado por
|
Changed by: Cambiado por
|
||||||
Before: Antes
|
Before: Antes
|
||||||
After: Despues
|
After: Despues
|
||||||
update: Actualizar
|
|
||||||
Create: Crear
|
|
||||||
History: Historial
|
History: Historial
|
||||||
insert: Crear
|
insert: Crear
|
||||||
|
delete: Eliminar
|
||||||
|
update: Actualizar
|
|
@ -0,0 +1,30 @@
|
||||||
|
@import 'colors';
|
||||||
|
|
||||||
|
vn-client-history {
|
||||||
|
vn-td {
|
||||||
|
vertical-align: initial !important;
|
||||||
|
}
|
||||||
|
.changes {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.label {
|
||||||
|
color: $secondary-font-color;
|
||||||
|
}
|
||||||
|
.value {
|
||||||
|
color: $main-font-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.after, .before {
|
||||||
|
max-width: 250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 1570px) {
|
||||||
|
.expendable {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.changes {
|
||||||
|
padding-top: 10px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue