2018-10-03 09:27:05 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
|
|
|
|
class Controller {
|
|
|
|
constructor($scope, $stateParams) {
|
|
|
|
this.$scope = $scope;
|
|
|
|
this.$stateParams = $stateParams;
|
|
|
|
this.filter = {
|
|
|
|
include: [{
|
2018-10-29 10:56:55 +00:00
|
|
|
relation: 'user',
|
2018-10-03 09:27:05 +00:00
|
|
|
scope: {
|
2018-10-29 10:56:55 +00:00
|
|
|
fields: ['name'],
|
|
|
|
},
|
|
|
|
}],
|
2018-10-03 09:27:05 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-10-23 09:34:07 +00:00
|
|
|
get logs() {
|
|
|
|
return this._logs;
|
|
|
|
}
|
2018-10-03 09:27:05 +00:00
|
|
|
|
2018-10-23 09:34:07 +00:00
|
|
|
set logs(value) {
|
|
|
|
this._logs = value;
|
|
|
|
|
2018-11-26 10:41:11 +00:00
|
|
|
if (this.logs) {
|
2018-11-05 08:29:05 +00:00
|
|
|
this.logs.forEach(log => {
|
2018-10-23 09:34:07 +00:00
|
|
|
log.oldProperties = this.getInstance(log.oldInstance);
|
|
|
|
log.newProperties = this.getInstance(log.newInstance);
|
|
|
|
});
|
2018-11-26 10:41:11 +00:00
|
|
|
}
|
2018-10-03 09:27:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getInstance(instance) {
|
2019-01-16 11:09:43 +00:00
|
|
|
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)?$/;
|
2018-10-29 10:56:55 +00:00
|
|
|
const properties = [];
|
2018-11-26 10:41:11 +00:00
|
|
|
if (typeof instance == 'object' && instance != null) {
|
|
|
|
Object.keys(instance).forEach(property => {
|
2019-01-16 11:09:43 +00:00
|
|
|
if (validDate.test(instance[property]))
|
|
|
|
instance[property] = new Date(instance[property]).toLocaleString('es-ES');
|
|
|
|
|
2018-11-26 10:41:11 +00:00
|
|
|
properties.push({key: property, value: instance[property]});
|
|
|
|
});
|
|
|
|
return properties;
|
|
|
|
}
|
|
|
|
return null;
|
2018-10-03 09:27:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Controller.$inject = ['$scope', '$stateParams'];
|
|
|
|
|
2018-10-29 10:56:55 +00:00
|
|
|
ngModule.component('vnClientLog', {
|
2018-10-03 09:27:05 +00:00
|
|
|
template: require('./index.html'),
|
2018-10-29 10:56:55 +00:00
|
|
|
controller: Controller,
|
2018-10-03 09:27:05 +00:00
|
|
|
});
|