Added statistics tools
This commit is contained in:
parent
d435d5db04
commit
cee0139e06
2 changed files with 106 additions and 1 deletions
71
src/components/juggl/JugglProjectStatisticsList.vue
Normal file
71
src/components/juggl/JugglProjectStatisticsList.vue
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
<template>
|
||||||
|
<b-table
|
||||||
|
:items="statistics"
|
||||||
|
primary-key="project_id"
|
||||||
|
hover
|
||||||
|
:busy="isLoading"
|
||||||
|
:fields="statistic_fields"
|
||||||
|
sort-by="name"
|
||||||
|
>
|
||||||
|
<template #table-busy>
|
||||||
|
<div class="text-center">
|
||||||
|
<b-spinner></b-spinner>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- Custom data -->
|
||||||
|
<template #cell(project)="data">
|
||||||
|
<JugglProjectName :project="data.item" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #cell(duration)="data">
|
||||||
|
{{ getDurationTimestamp(data.item.duration) }}
|
||||||
|
</template>
|
||||||
|
</b-table>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import JugglProjectName from "@/components/juggl/JugglProjectName";
|
||||||
|
import { helperService } from "@/services/helper.service.js";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "JugglProjectStatisticsList",
|
||||||
|
components: {
|
||||||
|
JugglProjectName
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
statistics: {
|
||||||
|
required: true,
|
||||||
|
type: Array
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data: () => {
|
||||||
|
return {
|
||||||
|
statistic_fields: [
|
||||||
|
{
|
||||||
|
key: "project",
|
||||||
|
label: "Project"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "duration",
|
||||||
|
label: "Duration"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "record_count",
|
||||||
|
label: "Records"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
isLoading: function() {
|
||||||
|
return this.statistics === undefined;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getDurationTimestamp: helperService.getDurationTimestamp
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="sass"></style>
|
|
@ -6,6 +6,7 @@ export const juggl = {
|
||||||
projects: [],
|
projects: [],
|
||||||
records: [],
|
records: [],
|
||||||
tags: [],
|
tags: [],
|
||||||
|
statistics: [],
|
||||||
user: undefined,
|
user: undefined,
|
||||||
auth: undefined,
|
auth: undefined,
|
||||||
recordsLimit: 0
|
recordsLimit: 0
|
||||||
|
@ -20,6 +21,9 @@ export const juggl = {
|
||||||
setTags(state, tags) {
|
setTags(state, tags) {
|
||||||
state.tags = tags;
|
state.tags = tags;
|
||||||
},
|
},
|
||||||
|
setStatistics(state, statistics) {
|
||||||
|
state.statistics = statistics;
|
||||||
|
},
|
||||||
setRecordsLimit(state, limit) {
|
setRecordsLimit(state, limit) {
|
||||||
state.recordsLimit = limit;
|
state.recordsLimit = limit;
|
||||||
},
|
},
|
||||||
|
@ -66,7 +70,23 @@ export const juggl = {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var recProjectVisible = visibleIds.includes(rec.project_id);
|
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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -76,6 +96,7 @@ export const juggl = {
|
||||||
apiUrl: state => state.apiUrl,
|
apiUrl: state => state.apiUrl,
|
||||||
user: state => state.user,
|
user: state => state.user,
|
||||||
isLoggedIn: state => !!state.auth,
|
isLoggedIn: state => !!state.auth,
|
||||||
|
statistics: state => state.statistics,
|
||||||
records: state => state.records,
|
records: state => state.records,
|
||||||
projects: state => state.projects,
|
projects: state => state.projects,
|
||||||
tags: state => state.tags,
|
tags: state => state.tags,
|
||||||
|
@ -223,6 +244,19 @@ export const juggl = {
|
||||||
commit("setRecords", allRecords);
|
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 }) {
|
loadRunningRecords({ commit, getters }) {
|
||||||
return jugglService.getRunningRecords().then(r => {
|
return jugglService.getRunningRecords().then(r => {
|
||||||
var allRecords = {
|
var allRecords = {
|
||||||
|
|
Loading…
Reference in a new issue