83 lines
2.2 KiB
JavaScript
83 lines
2.2 KiB
JavaScript
import ngModule from '../module';
|
|
import './style.scss';
|
|
|
|
export default class Controller {
|
|
constructor($scope) {
|
|
this.$ = $scope;
|
|
this.actionsText = {
|
|
'insert': 'Creates',
|
|
'update': 'Updates',
|
|
'delete': 'Deletes',
|
|
'select': 'Views'
|
|
};
|
|
this.filter = {
|
|
include: [{
|
|
relation: 'user',
|
|
scope: {
|
|
fields: ['name'],
|
|
include: {
|
|
relation: 'worker',
|
|
scope: {
|
|
fields: ['id']
|
|
}
|
|
}
|
|
},
|
|
}],
|
|
};
|
|
}
|
|
|
|
get logs() {
|
|
return this._logs;
|
|
}
|
|
|
|
set logs(value) {
|
|
this._logs = value;
|
|
|
|
if (this.logs) {
|
|
this.logs.forEach(log => {
|
|
log.oldProperties = this.getInstance(log.oldInstance);
|
|
log.newProperties = this.getInstance(log.newInstance);
|
|
});
|
|
}
|
|
}
|
|
|
|
showWorkerDescriptor(event, workerFk) {
|
|
if (event.defaultPrevented) return;
|
|
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
|
|
this.selectedWorker = workerFk;
|
|
this.$.workerDescriptor.parent = event.target;
|
|
this.$.workerDescriptor.show();
|
|
}
|
|
|
|
getInstance(instance) {
|
|
const properties = [];
|
|
let validDate = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/;
|
|
|
|
if (typeof instance == 'object' && instance != null) {
|
|
Object.keys(instance).forEach(property => {
|
|
if (validDate.test(instance[property]))
|
|
instance[property] = new Date(instance[property]).toLocaleString('es-ES');
|
|
|
|
properties.push({key: property, value: instance[property]});
|
|
});
|
|
return properties;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$scope'];
|
|
|
|
ngModule.component('vnLog', {
|
|
controller: Controller,
|
|
template: require('./index.html'),
|
|
bindings: {
|
|
model: '<',
|
|
originId: '<',
|
|
url: '@'
|
|
}
|
|
});
|