+
+ ng-click="$ctrl.filterByRecord(modelLog)">
diff --git a/front/salix/components/log/index.js b/front/salix/components/log/index.js
index ecbeaefe7..822a31801 100644
--- a/front/salix/components/log/index.js
+++ b/front/salix/components/log/index.js
@@ -67,8 +67,7 @@ export default class Controller extends Section {
$onInit() {
const match = this.url?.match(/(.*)Logs$/);
- this.model = match && match[1];
- this.modelI18n = this.translateModel(this.model);
+ this.modelI18n = this.translateModel(match && match[1]);
}
$postLink() {
@@ -279,7 +278,7 @@ export default class Controller extends Section {
if (value == null || value == '') return null;
switch (prop) {
case 'search':
- if (/^\s*[0-9]+\s*$/.test(value) || this.byEntity)
+ if (/^\s*[0-9]+\s*$/.test(value) || this.byRecord)
return {changedModelId: value.trim()};
else
return {changedModelValue: {like: `%${value}%`}};
@@ -332,8 +331,8 @@ export default class Controller extends Section {
const and = [];
if (!filter.search || !filter.changedModel)
- this.byEntity = false;
- if (!this.byEntity)
+ this.byRecord = false;
+ if (!this.byRecord)
and.push({originFk: this.originId});
for (const prop in filter) {
@@ -348,8 +347,8 @@ export default class Controller extends Section {
return this.$.model.applyFilter(lbFilter);
}
- filterByEntity(modelLog) {
- this.byEntity = true;
+ filterByRecord(modelLog) {
+ this.byRecord = true;
this.$.filter = {
who: 'all',
search: modelLog.id,
diff --git a/front/salix/components/log/style.scss b/front/salix/components/log/style.scss
index 8c39559fc..f11fc2f25 100644
--- a/front/salix/components/log/style.scss
+++ b/front/salix/components/log/style.scss
@@ -74,7 +74,8 @@ vn-log {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
- margin-top: 6px;
+ margin-top: 5px;
+ min-height: 22px;
& > .model-name {
display: inline-block;
@@ -131,7 +132,7 @@ vn-log {
& > vn-icon.pit {
@extend %clickable-light;
vertical-align: middle;
- font-size: 18px;
+ font-size: 20px;
color: $color-font-secondary;
display: none;
diff --git a/loopback/common/methods/log/pitInstance.js b/loopback/common/methods/log/pitInstance.js
index 3cbe013b3..1c054c53e 100644
--- a/loopback/common/methods/log/pitInstance.js
+++ b/loopback/common/methods/log/pitInstance.js
@@ -1,3 +1,5 @@
+const NotFoundError = require('vn-loopback/util/not-found-error');
+
module.exports = Self => {
Self.remoteMethod('pitInstance', {
description: 'Gets the status of instance at specific point in time',
@@ -21,24 +23,40 @@ module.exports = Self => {
Self.pitInstance = async function(id) {
const log = await Self.findById(id, {
- fields: ['changedModel', 'changedModelId']
+ fields: [
+ 'changedModel',
+ 'changedModelId',
+ 'creationDate'
+ ]
});
+ if (!log)
+ throw new NotFoundError();
const where = {
changedModel: log.changedModel,
changedModelId: log.changedModelId
};
- const createdWhere = {action: 'insert'};
+ const createdWhere = {
+ action: 'insert',
+ creationDate: {lte: log.creationDate}
+ };
const createdLog = await Self.findOne({
- fields: ['id'],
- where: Object.assign(createdWhere, where)
+ fields: ['id', 'creationDate'],
+ where: Object.assign(createdWhere, where),
+ order: 'creationDate DESC'
});
+ if (!createdLog)
+ throw new NotFoundError('Cannot find creation log');
const logsWhere = {
id: {between: [
Math.min(id, createdLog.id),
Math.max(id, createdLog.id)
+ ]},
+ creationDate: {between: [
+ createdLog.creationDate,
+ log.creationDate
]}
};
const logs = await Self.find({
@@ -46,6 +64,8 @@ module.exports = Self => {
where: Object.assign(logsWhere, where),
order: 'creationDate'
});
+ if (!logs.length)
+ throw new NotFoundError('No logs found for record');
const instance = {};
for (const log of logs)