implemented download of account data as CSV
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { api, eventStream, get } from '../../urls.svelte';
|
||||
import { api, download, eventStream, get } from '../../urls.svelte';
|
||||
import { error, yikes } from '../../warn.svelte';
|
||||
import { t } from '../../translations.svelte';
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
let users = {};
|
||||
let sums = $derived.by(calcSums);
|
||||
|
||||
function addToFilter(tag){
|
||||
filter.push(tag.toLowerCase());
|
||||
}
|
||||
|
||||
function calcSums(){
|
||||
let sums = {};
|
||||
sums[ 0] = 0;
|
||||
@@ -32,10 +36,6 @@
|
||||
return sums;
|
||||
}
|
||||
|
||||
function addToFilter(tag){
|
||||
filter.push(tag.toLowerCase());
|
||||
}
|
||||
|
||||
function checker(taglist, filter){
|
||||
for (var f of filter){
|
||||
var included = false;
|
||||
@@ -47,6 +47,10 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
function csvexport(ev){
|
||||
download(api(`accounting/${id}/csv`),account.name+".csv");
|
||||
}
|
||||
|
||||
function dropTag(tag){
|
||||
filter = filter.filter(x => x != tag.toLowerCase());
|
||||
}
|
||||
@@ -167,7 +171,9 @@
|
||||
{t('external expenses')}<br/>
|
||||
{t('sum external')}
|
||||
</td>
|
||||
<td colspan="2"></td>
|
||||
<td colspan="2">
|
||||
<button onclick={csvexport}>{t('export as {format}',{format:'CSV'})}</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -8,6 +8,13 @@ export function get(url){
|
||||
return fetch(url,{ credentials:'include' });
|
||||
}
|
||||
|
||||
export function download(url,name = null){
|
||||
var link=document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = name ? name : url.substr(url.lastIndexOf('/') + 1);
|
||||
link.click();
|
||||
}
|
||||
|
||||
export function drop(url, payload){
|
||||
let data = {
|
||||
credentials:'include',
|
||||
|
||||
Reference in New Issue
Block a user