mirror of
https://github.com/gwenhael-le-moine/credger.git
synced 2024-12-26 09:58:36 +01:00
active accounts list
This commit is contained in:
parent
0efc88e71d
commit
d52d58eb15
1 changed files with 44 additions and 36 deletions
|
@ -66,6 +66,7 @@
|
||||||
|
|
||||||
const Controls = {
|
const Controls = {
|
||||||
period: {
|
period: {
|
||||||
|
init: () => Controls.period.set( new Date() ),
|
||||||
set: ( period ) => {
|
set: ( period ) => {
|
||||||
current_period = period;
|
current_period = period;
|
||||||
const months = { 0: 'Janvier',
|
const months = { 0: 'Janvier',
|
||||||
|
@ -96,12 +97,18 @@
|
||||||
},
|
},
|
||||||
accounts: {
|
accounts: {
|
||||||
init: async () => {
|
init: async () => {
|
||||||
|
let account_to_option = account => `<option value="${account.join(':')}">${account.join(':')}</option>`;
|
||||||
let accounts = await API.accounts();
|
let accounts = await API.accounts();
|
||||||
|
let select = document.querySelector("select#accounts");
|
||||||
|
select.innerHTML = '';
|
||||||
|
|
||||||
let account_to_option = ( account ) => `<option value="${account.join(':')}">${account.join(':')}</option>`;
|
for ( let i = 1 ; i < accounts.reduce( (memo, a) => a.length > memo ? a.length : memo, 0 ) ; i++ ) {
|
||||||
document.querySelector("#accounts").innerHTML = `<select multiple name="accounts" id="lstaccounts">
|
select.innerHTML += `<optgroup label="Depth: ${i}">${accounts.filter( a => a.length == i ).map( account => account_to_option( account )).join('')}</optgroup>`;
|
||||||
${accounts.map( account => account_to_option( account )).join('')}
|
}
|
||||||
</select>`;
|
},
|
||||||
|
onchange: ( accounts_selected ) => {
|
||||||
|
/* TODO */
|
||||||
|
console.log( accounts_selected );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* granularity: {
|
/* granularity: {
|
||||||
|
@ -144,8 +151,9 @@
|
||||||
<input oninput="Controls.granularity.set( this.value );">
|
<input oninput="Controls.granularity.set( this.value );">
|
||||||
</div> -->
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
<div id="accounts">
|
|
||||||
</div>
|
<select id="accounts" name="accounts" multiple size="20" onchange="Controls.accounts.onchange( Array.from( this.options ).filter( o => o.selected ).map( o => o.value ) )"></select>
|
||||||
|
|
||||||
<div id="month">
|
<div id="month">
|
||||||
<div id="donut" style="height: 256; width: 256;"></div>
|
<div id="donut" style="height: 256; width: 256;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -153,9 +161,9 @@
|
||||||
<script>
|
<script>
|
||||||
(async () => {
|
(async () => {
|
||||||
await Controls.accounts.init();
|
await Controls.accounts.init();
|
||||||
console.log( await API.graph_values( "", ["Expenses", "Income"].join(" "), "monthly" ) )
|
await Controls.period.init();
|
||||||
|
|
||||||
await Controls.period.set( new Date() );
|
console.log( await API.graph_values( "", ["Expenses", "Income"].join(" "), "monthly" ) )
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in a new issue