Skip to content

Commit

Permalink
fix: logs csv export [WTEL-3984]
Browse files Browse the repository at this point in the history
  • Loading branch information
dlohvinov committed Dec 19, 2023
1 parent ab12947 commit bc2de45
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ export default {
// const { dummy } = useDummy({ namespace: `${namespace}/${subNamespace}`, hiddenText: true });
// return { dummy };
// },
computed: {
getFilters() {
return this.$store.getters[`${namespace}/${subNamespace}/filters/GET_FILTERS`];
},
},
watch: {
'$route.query': {
async handler() {
Expand All @@ -108,10 +114,30 @@ export default {
},
},
created() {
this.initCSVExport(LogsAPI.getList, {
this.initCSVExport(this.getDataForCSVExport, {
filename: `${this.itemInstance.name}-logs-at-${new Date().toLocaleString()}`,
});
},
methods: {
async getDataForCSVExport(params) {
const filters = this.getFilters;
const { items, next } = await LogsAPI.getList({
...filters,
...params,
parentId: this.parentId,
});
const transformedItems = items.map((item) => ({
...item,
date: new Date(+item.date).toLocaleString(),
}));
return {
items: transformedItems,
next,
};
},
},
};
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default {
});
},
methods: {
async getDataForCSVExport(...params) {
async getDataForCSVExport(params) {
const filters = this.getFilters;
const { items, next } = await LogsAPI.getList({
...filters,
Expand Down

0 comments on commit bc2de45

Please sign in to comment.