salix/modules/client/front/log/index.js

50 lines
1.2 KiB
JavaScript
Raw Normal View History

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: [{
relation: 'user',
2018-10-03 09:27:05 +00:00
scope: {
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) {
const properties = [];
2018-11-26 10:41:11 +00:00
if (typeof instance == 'object' && instance != null) {
Object.keys(instance).forEach(property => {
properties.push({key: property, value: instance[property]});
});
return properties;
}
return null;
2018-10-03 09:27:05 +00:00
}
}
Controller.$inject = ['$scope', '$stateParams'];
ngModule.component('vnClientLog', {
2018-10-03 09:27:05 +00:00
template: require('./index.html'),
controller: Controller,
2018-10-03 09:27:05 +00:00
});