mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-10 09:19:24 +01:00
fix report crash when some values are null
This commit is contained in:
parent
2326894a2b
commit
f2b1e5f93e
2 changed files with 6 additions and 3 deletions
|
@ -133,7 +133,7 @@
|
||||||
<template v-else-if="srv.result.fields[columnIndex].type === 'tx_id'">
|
<template v-else-if="srv.result.fields[columnIndex].type === 'tx_id'">
|
||||||
<vc:truncate-center text="value" is-vue="true" padding="15" classes="truncate-center-id" link="getExplorerUrl(value, row[columnIndex-1])" />
|
<vc:truncate-center text="value" is-vue="true" padding="15" classes="truncate-center-id" link="getExplorerUrl(value, row[columnIndex-1])" />
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="['Address', 'PaymentId'].includes(srv.result.fields[columnIndex].name)">
|
<template v-else-if="value && ['Address', 'PaymentId'].includes(srv.result.fields[columnIndex].name)" >
|
||||||
<vc:truncate-center text="value" is-vue="true" padding="15" classes="truncate-center-id" />
|
<vc:truncate-center text="value" is-vue="true" padding="15" classes="truncate-center-id" />
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="srv.result.fields[columnIndex].type === 'datetime'">{{ displayDate(value) }}</template>
|
<template v-else-if="srv.result.fields[columnIndex].type === 'datetime'">{{ displayDate(value) }}</template>
|
||||||
|
|
|
@ -149,6 +149,9 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
const dtFormatter = new Intl.DateTimeFormat('default', { dateStyle: 'short', timeStyle: 'short' });
|
const dtFormatter = new Intl.DateTimeFormat('default', { dateStyle: 'short', timeStyle: 'short' });
|
||||||
|
|
||||||
function displayDate(val) {
|
function displayDate(val) {
|
||||||
|
if(!val){
|
||||||
|
return val;
|
||||||
|
}
|
||||||
const date = new Date(val);
|
const date = new Date(val);
|
||||||
return dtFormatter.format(date);
|
return dtFormatter.format(date);
|
||||||
}
|
}
|
||||||
|
@ -182,7 +185,7 @@ function downloadCSV() {
|
||||||
|
|
||||||
// Convert ISO8601 dates to YYYY-MM-DD HH:mm:ss so the CSV easily integrate with Excel
|
// Convert ISO8601 dates to YYYY-MM-DD HH:mm:ss so the CSV easily integrate with Excel
|
||||||
modifyFields(srv.result.fields, data, 'amount', displayValue)
|
modifyFields(srv.result.fields, data, 'amount', displayValue)
|
||||||
modifyFields(srv.result.fields, data, 'datetime', v => moment(v).format('YYYY-MM-DD hh:mm:ss'));
|
modifyFields(srv.result.fields, data, 'datetime', v => v? moment(v).format('YYYY-MM-DD hh:mm:ss'): v);
|
||||||
const csv = Papa.unparse({ fields: srv.result.fields.map(f => f.name), data });
|
const csv = Papa.unparse({ fields: srv.result.fields.map(f => f.name), data });
|
||||||
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
|
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
|
||||||
saveAs(blob, "export.csv");
|
saveAs(blob, "export.csv");
|
||||||
|
@ -202,7 +205,7 @@ async function fetchStoreReports() {
|
||||||
srv.dataUpdated();
|
srv.dataUpdated();
|
||||||
|
|
||||||
// Dates from API are UTC, convert them to local time
|
// Dates from API are UTC, convert them to local time
|
||||||
modifyFields(srv.result.fields, srv.result.data, 'datetime', a => moment(a).format());
|
modifyFields(srv.result.fields, srv.result.data, 'datetime', a => a? moment(a).format(): a);
|
||||||
var urlParams = new URLSearchParams(new URL(window.location).search);
|
var urlParams = new URLSearchParams(new URL(window.location).search);
|
||||||
urlParams.set("viewName", srv.request.viewName);
|
urlParams.set("viewName", srv.request.viewName);
|
||||||
urlParams.set("from", srv.request.timePeriod.from);
|
urlParams.set("from", srv.request.timePeriod.from);
|
||||||
|
|
Loading…
Add table
Reference in a new issue