diff --git a/src/components/juggl/JugglProjectStatisticsList.vue b/src/components/juggl/JugglProjectStatisticsList.vue new file mode 100644 index 0000000..c4e4014 --- /dev/null +++ b/src/components/juggl/JugglProjectStatisticsList.vue @@ -0,0 +1,71 @@ + + + + + diff --git a/src/store/modules/juggl.js b/src/store/modules/juggl.js index 278b111..f8f9656 100644 --- a/src/store/modules/juggl.js +++ b/src/store/modules/juggl.js @@ -6,6 +6,7 @@ export const juggl = { projects: [], records: [], tags: [], + statistics: [], user: undefined, auth: undefined, recordsLimit: 0 @@ -20,6 +21,9 @@ export const juggl = { setTags(state, tags) { state.tags = tags; }, + setStatistics(state, statistics) { + state.statistics = statistics; + }, setRecordsLimit(state, limit) { state.recordsLimit = limit; }, @@ -66,7 +70,23 @@ export const juggl = { return false; } var recProjectVisible = visibleIds.includes(rec.project_id); - if (projectVisible !== undefined && projectVisible !== recProjectVisible) { + if ( + projectVisible !== undefined && + projectVisible !== recProjectVisible + ) { + return false; + } + return true; + }); + }, + getFilteredStatistics: (state, getters) => ({ + projectVisible = undefined + }) => { + return Object.values(getters.statistics).filter(statistic => { + if ( + projectVisible !== undefined && + statistic.visible !== projectVisible + ) { return false; } return true; @@ -76,6 +96,7 @@ export const juggl = { apiUrl: state => state.apiUrl, user: state => state.user, isLoggedIn: state => !!state.auth, + statistics: state => state.statistics, records: state => state.records, projects: state => state.projects, tags: state => state.tags, @@ -223,6 +244,19 @@ export const juggl = { commit("setRecords", allRecords); }); }, + loadTodaysStatistics({ dispatch }) { + dispatch("loadStatistics", { from: new Date(), until: new Date() }); + }, + loadStatistics({ commit }, { from, until }) { + var options = { + from: from, + until: until + }; + + return jugglService.getStatistics(options).then(r => { + commit("setStatistics", r.data.statistics); + }); + }, loadRunningRecords({ commit, getters }) { return jugglService.getRunningRecords().then(r => { var allRecords = {