2019-04-02 09:04:53 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-18 11:55:22 +00:00
|
|
|
import Section from 'salix/components/section';
|
2019-04-02 09:04:53 +00:00
|
|
|
import './style.scss';
|
|
|
|
|
2020-03-18 11:55:22 +00:00
|
|
|
export default class Controller extends Section {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
2019-04-02 09:04:53 +00:00
|
|
|
this.actionsText = {
|
|
|
|
'insert': 'Creates',
|
|
|
|
'update': 'Updates',
|
|
|
|
'delete': 'Deletes',
|
|
|
|
'select': 'Views'
|
|
|
|
};
|
2019-07-03 09:08:44 +00:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|
2019-04-02 09:04:53 +00:00
|
|
|
}
|
|
|
|
|
2019-07-03 09:08:44 +00:00
|
|
|
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;
|
|
|
|
}
|
2020-06-08 09:05:17 +00:00
|
|
|
|
|
|
|
showWorkerDescriptor(event, workerId) {
|
|
|
|
if (!workerId) return;
|
|
|
|
this.$.workerDescriptor.show(event.target, workerId);
|
|
|
|
}
|
2019-04-02 09:04:53 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnLog', {
|
2019-04-02 09:04:53 +00:00
|
|
|
controller: Controller,
|
|
|
|
template: require('./index.html'),
|
|
|
|
bindings: {
|
2019-07-03 09:08:44 +00:00
|
|
|
model: '<',
|
|
|
|
originId: '<',
|
|
|
|
url: '@'
|
2019-04-02 09:04:53 +00:00
|
|
|
}
|
|
|
|
});
|