diff --git a/imports/api/projects/server/publications.js b/imports/api/projects/server/publications.js index 16cef0b..fd90d2f 100644 --- a/imports/api/projects/server/publications.js +++ b/imports/api/projects/server/publications.js @@ -12,7 +12,11 @@ import { checkAuthentication, getGlobalSettingAsync } from '../../../utils/serve * @returns {Array} - The list of projects for the current user. */ Meteor.publish('myprojects', async function myProjects({ projectLimit }) { - await checkAuthentication(this) + if(this.userId) { + await checkAuthentication(this) + } else { + return this.ready() + } check(projectLimit, Match.Maybe(Number)) return projectLimit ? Projects.find({ $or: [{ userId: this.userId }, { public: true }, { team: this.userId }], diff --git a/imports/startup/client/startup.js b/imports/startup/client/startup.js index 68225d7..79a9056 100644 --- a/imports/startup/client/startup.js +++ b/imports/startup/client/startup.js @@ -116,7 +116,9 @@ Meteor.startup(() => { Tracker.autorun(() => { if (getGlobalSetting('enableOpenIDConnect')) { import('../../utils/oidc/oidc_client.js').then((Oidc) => { - Oidc.registerOidc() + if(Accounts.oauth.serviceNames().indexOf('oidc') === -1) { + Oidc.registerOidc() + } }) } }) diff --git a/imports/ui/pages/overview/components/allprojectschart.js b/imports/ui/pages/overview/components/allprojectschart.js index a34b8b7..b6ca2a9 100644 --- a/imports/ui/pages/overview/components/allprojectschart.js +++ b/imports/ui/pages/overview/components/allprojectschart.js @@ -144,7 +144,7 @@ Template.allprojectschart.onRendered(() => { } const colors = [] for (const project of templateInstance.projectDistribution.get()) { - colors.push(Projects.findOne({ _id: project._id }).color ? Projects.findOne({ _id: project._id }).color : '#009688') + colors.push(Projects.findOne({ _id: project._id })?.color ? Projects.findOne({ _id: project._id })?.color : '#009688') } templateInstance.piechart = new Chart(templateInstance.$('.js-pie-chart-container')[0], { type: 'pie', @@ -152,7 +152,7 @@ Template.allprojectschart.onRendered(() => { height: 230, data: { labels: templateInstance.projectDistribution.get() - .map((project) => $('').text(Projects.findOne({ _id: project._id }).name).html()), + .map((project) => $('').text(Projects.findOne({ _id: project._id })?.name).html()), datasets: [{ values: templateInstance.projectDistribution.get().map((project) => project.count), }], diff --git a/imports/ui/pages/overview/projectlist.js b/imports/ui/pages/overview/projectlist.js index 16d4ee0..5e04da4 100644 --- a/imports/ui/pages/overview/projectlist.js +++ b/imports/ui/pages/overview/projectlist.js @@ -17,57 +17,33 @@ Template.projectlist.onCreated(function createProjectList() { this.showArchived = new ReactiveVar(false) this.projectId = new ReactiveVar(null) this.period = new ReactiveVar('all') + this.startDate = new ReactiveVar(null) + this.endDate = new ReactiveVar(null) this.autorun(() => { this.showArchived.set(FlowRouter.getQueryParam('showArchived') === 'true') this.period.set(FlowRouter.getQueryParam('period') || 'all') }) + this.autorun(async () => { + if(this.period.get() !== 'all') { + const {startDate, endDate} = await periodToDates(templateInstance.period.get()) + this.startDate.set(startDate) + this.endDate.set(endDate) + } + }) }) Template.projectlist.onRendered(() => { - Meteor.setTimeout(() => { - import('sortablejs').then((sortableImport) => { - const Sortable = sortableImport.default - const el = document.querySelector('.js-project-list') - if (el) { - Sortable.create(el, { - handle: '.handle', - onChoose: (evt) => { - document.querySelectorAll('.js-project-list .card-body').forEach((element) => { - element.classList.add('d-none') - }) - document.querySelectorAll('.progress-bar').forEach((element) => { - element.classList.add('d-none') - }) - }, - onEnd: (evt) => { - document.querySelectorAll('.js-project-list .card-body').forEach((element) => { - element.classList.remove('d-none') - }) - document.querySelectorAll('.progress-bar').forEach((element) => { - element.classList.remove('d-none') - }) - const projectId = $(evt.item).children('.card-body').children('.row.mt-2')[0].id - const priority = evt.newIndex - Meteor.call('updatePriority', { projectId, priority }, (error, result) => { - if (error) { - console.error(error) - } - }) - }, - }) - } - }) - }, 1000) + // Template.instance().subscribe('myprojects', {}) }) Template.projectlist.helpers({ - async projects() { + projects() { + const templateInstance = Template.instance() const limit = FlowRouter.getQueryParam('limit') ? Number(FlowRouter.getQueryParam('limit')) : 25 const selector = {} - if(Template.instance().period?.get() && Template.instance().period.get() !== 'all'){ - const {startDate, endDate} = await periodToDates(Template.instance().period.get()) - selector.$and = [{ $or: [ { startDate: { $exists: false } }, { startDate: { $gte: startDate } }] }, - { $or: [{ endDate: {$exists: false } }, { endDate: { $lte: endDate } }] }] + if(templateInstance.period?.get() && templateInstance.period.get() !== 'all'){ + selector.$and = [{ $or: [ { startDate: { $exists: false } }, { startDate: { $gte: templateInstance.startDate.get() } }] }, + { $or: [{ endDate: {$exists: false } }, { endDate: { $lte: templateInstance.endDate.get() } }] }] } - if(!Template.instance().showArchived?.get()) { + if(!templateInstance.showArchived?.get()) { if(selector.$and) { selector.$and.push({ $or: [{ archived: { $exists: false } }, { archived: false }] }) } else { @@ -76,14 +52,14 @@ Template.projectlist.helpers({ } return Projects.find(selector, { sort: { priority: 1, name: 1 }, limit }) }, - async moreThanOneProject() { + moreThanOneProject() { const selector = {} - if(Template.instance().period?.get() && Template.instance().period.get() !== 'all'){ - const {startDate, endDate} = await periodToDates(Template.instance().period.get()) - selector.$and = [{ $or: [ { startDate: { $exists: false } }, { startDate: { $gte: startDate } }] }, - { $or: [{ endDate: {$exists: false } }, { endDate: { $lte: endDate } }] }] + const templateInstance = Template.instance() + if(templateInstance.period?.get() && templateInstance.period.get() !== 'all'){ + selector.$and = [{ $or: [ { startDate: { $exists: false } }, { startDate: { $gte: templateInstance.startDate.get() } }] }, + { $or: [{ endDate: {$exists: false } }, { endDate: { $lte: templateInstance.endDate.get() } }] }] } - if(!Template.instance().showArchived?.get()) { + if(!templateInstance.showArchived?.get()) { if(selector.$and) { selector.$and.push({ $or: [{ archived: { $exists: false } }, { archived: false }] }) } else { @@ -105,14 +81,14 @@ Template.projectlist.helpers({ archived(_id) { return Projects.findOne({ _id }).archived }, - async projectCount() { + projectCount() { const selector = {} - if(Template.instance().period?.get() && Template.instance().period.get() !== 'all'){ - const {startDate, endDate} = await periodToDates(Template.instance().period.get()) - selector.$and = [{ $or: [ { startDate: { $exists: false } }, { startDate: { $gte: startDate } }] }, - { $or: [{ endDate: {$exists: false } }, { endDate: { $lte: endDate } }] }] + const templateInstance = Template.instance() + if(templateInstance.period?.get() && templateInstance.period.get() !== 'all'){ + selector.$and = [{ $or: [ { startDate: { $exists: false } }, { startDate: { $gte: templateInstance.startDate.get() } }] }, + { $or: [{ endDate: {$exists: false } }, { endDate: { $lte: templateInstance.endDate.get() } }] }] } - if(!Template.instance().showArchived?.get()) { + if(!templateInstance.showArchived?.get()) { if(selector.$and) { selector.$and.push({ $or: [{ archived: { $exists: false } }, { archived: false }] }) } else { diff --git a/imports/utils/server_method_helpers.js b/imports/utils/server_method_helpers.js index 8615e65..49c8025 100644 --- a/imports/utils/server_method_helpers.js +++ b/imports/utils/server_method_helpers.js @@ -99,6 +99,7 @@ async function checkAuthentication(context) { if (!context.userId || meteorUser?.inactive) { throw new Meteor.Error('notifications.auth_error_method') } + return true } /** * Checks if the current user is authenticated and an admin. diff --git a/package.json b/package.json index 4c4bd07..3568251 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "titra", - "version": "0.99.1", + "version": "0.99.2", "private": true, "scripts": { "start": "meteor run"