|
|
|
@ -1,6 +1,8 @@ |
|
|
|
|
import { AttachmentStorage } from '/models/attachments'; |
|
|
|
|
import { CardSearchPagedComponent } from '/client/lib/cardSearch'; |
|
|
|
|
import SessionData from '/models/usersessiondata'; |
|
|
|
|
import { QueryParams } from '/config/query-classes'; |
|
|
|
|
import { OPERATOR_LIMIT } from '/config/search-const'; |
|
|
|
|
|
|
|
|
|
BlazeComponent.extendComponent({ |
|
|
|
|
subscription: null, |
|
|
|
@ -8,10 +10,14 @@ BlazeComponent.extendComponent({ |
|
|
|
|
showBrokenCardsReport: new ReactiveVar(false), |
|
|
|
|
showOrphanedFilesReport: new ReactiveVar(false), |
|
|
|
|
showRulesReport: new ReactiveVar(false), |
|
|
|
|
showCardsReport: new ReactiveVar(false), |
|
|
|
|
showBoardsReport: new ReactiveVar(false), |
|
|
|
|
sessionId: null, |
|
|
|
|
|
|
|
|
|
onCreated() { |
|
|
|
|
this.error = new ReactiveVar(''); |
|
|
|
|
this.loading = new ReactiveVar(false); |
|
|
|
|
this.sessionId = SessionData.getSessionId(); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
events() { |
|
|
|
@ -21,6 +27,8 @@ BlazeComponent.extendComponent({ |
|
|
|
|
'click a.js-report-files': this.switchMenu, |
|
|
|
|
'click a.js-report-orphaned-files': this.switchMenu, |
|
|
|
|
'click a.js-report-rules': this.switchMenu, |
|
|
|
|
'click a.js-report-cards': this.switchMenu, |
|
|
|
|
'click a.js-report-boards': this.switchMenu, |
|
|
|
|
}, |
|
|
|
|
]; |
|
|
|
|
}, |
|
|
|
@ -32,6 +40,9 @@ BlazeComponent.extendComponent({ |
|
|
|
|
this.showFilesReport.set(false); |
|
|
|
|
this.showBrokenCardsReport.set(false); |
|
|
|
|
this.showOrphanedFilesReport.set(false); |
|
|
|
|
this.showRulesReport.set(false) |
|
|
|
|
this.showBoardsReport.set(false); |
|
|
|
|
this.showCardsReport.set(false); |
|
|
|
|
if (this.subscription) { |
|
|
|
|
this.subscription.stop(); |
|
|
|
|
} |
|
|
|
@ -64,68 +75,79 @@ BlazeComponent.extendComponent({ |
|
|
|
|
this.showRulesReport.set(true); |
|
|
|
|
this.loading.set(false); |
|
|
|
|
}); |
|
|
|
|
} else if ('report-boards' === targetID) { |
|
|
|
|
this.subscription = Meteor.subscribe('boardsReport', () => { |
|
|
|
|
this.showBoardsReport.set(true); |
|
|
|
|
this.loading.set(false); |
|
|
|
|
}); |
|
|
|
|
} else if ('report-cards' === targetID) { |
|
|
|
|
const qp = new QueryParams(); |
|
|
|
|
qp.addPredicate(OPERATOR_LIMIT, 300); |
|
|
|
|
this.subscription = Meteor.subscribe( |
|
|
|
|
'globalSearch', |
|
|
|
|
this.sessionId, |
|
|
|
|
qp.getParams(), |
|
|
|
|
qp.text, |
|
|
|
|
() => { |
|
|
|
|
this.showCardsReport.set(true); |
|
|
|
|
this.loading.set(false); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}).register('adminReports'); |
|
|
|
|
|
|
|
|
|
Template.filesReport.helpers({ |
|
|
|
|
attachmentFiles() { |
|
|
|
|
class AdminReport extends BlazeComponent { |
|
|
|
|
collection; |
|
|
|
|
|
|
|
|
|
results() { |
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
|
// console.log('attachments:', AttachmentStorage.find());
|
|
|
|
|
// console.log('attachments.count:', AttachmentStorage.find().count());
|
|
|
|
|
return AttachmentStorage.find(); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
rulesReport() { |
|
|
|
|
const rules = []; |
|
|
|
|
|
|
|
|
|
Rules.find().forEach(rule => { |
|
|
|
|
rules.push({ |
|
|
|
|
_id: rule._id, |
|
|
|
|
title: rule.title, |
|
|
|
|
boardId: rule.boardId, |
|
|
|
|
boardTitle: rule.board().title, |
|
|
|
|
action: rule.action().fetch(), |
|
|
|
|
trigger: rule.trigger().fetch(), |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
return this.collection.find(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return rules; |
|
|
|
|
}, |
|
|
|
|
yesOrNo(value) { |
|
|
|
|
if (value) { |
|
|
|
|
return TAPi18n.__('yes'); |
|
|
|
|
} else { |
|
|
|
|
return TAPi18n.__('no'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
resultsCount() { |
|
|
|
|
return AttachmentStorage.find().count(); |
|
|
|
|
}, |
|
|
|
|
return this.collection.find().count(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileSize(size) { |
|
|
|
|
return Math.round(size / 1024); |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
usageCount(key) { |
|
|
|
|
return Attachments.find({ 'copies.attachments.key': key }).count(); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Template.orphanedFilesReport.helpers({ |
|
|
|
|
attachmentFiles() { |
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
|
// console.log('attachments:', AttachmentStorage.find());
|
|
|
|
|
// console.log('attachments.count:', AttachmentStorage.find().count());
|
|
|
|
|
return AttachmentStorage.find(); |
|
|
|
|
}, |
|
|
|
|
abbreviate(text) { |
|
|
|
|
if (text.length > 30) { |
|
|
|
|
return `${text.substr(0, 29)}...`; |
|
|
|
|
} |
|
|
|
|
return text; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
resultsCount() { |
|
|
|
|
return AttachmentStorage.find().count(); |
|
|
|
|
}, |
|
|
|
|
(class extends AdminReport { |
|
|
|
|
collection = AttachmentStorage; |
|
|
|
|
}.register('filesReport')); |
|
|
|
|
|
|
|
|
|
fileSize(size) { |
|
|
|
|
return Math.round(size / 1024); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
(class extends AdminReport { |
|
|
|
|
collection = AttachmentStorage; |
|
|
|
|
}.register('orphanedFilesReport')); |
|
|
|
|
|
|
|
|
|
(class extends AdminReport { |
|
|
|
|
collection = Rules; |
|
|
|
|
|
|
|
|
|
Template.rulesReport.helpers({ |
|
|
|
|
rows() { |
|
|
|
|
results() { |
|
|
|
|
const rules = []; |
|
|
|
|
|
|
|
|
|
Rules.find().forEach(rule => { |
|
|
|
@ -139,14 +161,43 @@ Template.rulesReport.helpers({ |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
|
console.log('rows:', rules); |
|
|
|
|
return rules; |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
}.register('rulesReport')); |
|
|
|
|
|
|
|
|
|
(class extends AdminReport { |
|
|
|
|
collection = Boards; |
|
|
|
|
|
|
|
|
|
userNames(members) { |
|
|
|
|
let text = ''; |
|
|
|
|
members.forEach(member => { |
|
|
|
|
const user = Users.findOne(member.userId); |
|
|
|
|
text += text ? ', ' : ''; |
|
|
|
|
if (user) { |
|
|
|
|
text += user.username; |
|
|
|
|
} else { |
|
|
|
|
text += member.userId |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return text; |
|
|
|
|
} |
|
|
|
|
}.register('boardsReport')); |
|
|
|
|
|
|
|
|
|
resultsCount() { |
|
|
|
|
return Rules.find().count(); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
(class extends AdminReport { |
|
|
|
|
collection = Cards; |
|
|
|
|
|
|
|
|
|
userNames(userIds) { |
|
|
|
|
let text = ''; |
|
|
|
|
userIds.forEach(userId => { |
|
|
|
|
const user = Users.findOne(userId); |
|
|
|
|
text += text ? ', ' : ''; |
|
|
|
|
text += user.username; |
|
|
|
|
}); |
|
|
|
|
return text; |
|
|
|
|
} |
|
|
|
|
}.register('cardsReport')); |
|
|
|
|
|
|
|
|
|
class BrokenCardsComponent extends CardSearchPagedComponent { |
|
|
|
|
onCreated() { |
|
|
|
|