Commit 2572fe0b931c25cc2eceb014c272f1a57a9157a9
fixed some styles
austinfrey committed on 11/6/2018, 2:22:51 AMParent: 8f610eca2bb7c82ab4520dcd17f0816be4901f3b
Files changed
package-lock.json | changed |
package.json | changed |
stores/ledger.js | changed |
views/accounts.js | changed |
views/entries.js | changed |
views/transactions.js | changed |
sw.js | deleted |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 384244 bytes New file size: 384592 bytes |
package.json | ||
---|---|---|
@@ -4,8 +4,11 @@ | ||
4 | 4 … | "private": true, |
5 | 5 … | "scripts": { |
6 | 6 … | "build": "bankai build index.js", |
7 | 7 … | "create": "choo-scaffold", |
8 … | + "electro": "electro .", | |
9 … | + "electro:clean": "rm .test.db accounts.json entries.json && electro .", | |
10 … | + "carlo": "node carlo", | |
8 | 11 … | "inspect": "bankai inspect index.js", |
9 | 12 … | "start": "bankai start index.js", |
10 | 13 … | "test": "standard && npm run test-deps", |
11 | 14 … | "test-deps": "dependency-check . && dependency-check . --extra --no-dev -i tachyons" |
@@ -26,8 +29,9 @@ | ||
26 | 29 … | "bankai": "^9.15.0", |
27 | 30 … | "choo-devtools": "^2.5.1", |
28 | 31 … | "choo-scaffold": "^1.2.0", |
29 | 32 … | "dependency-check": "^3.2.1", |
33 … | + "electro": "^2.1.1", | |
30 | 34 … | "electron": "^3.0.6", |
31 | 35 … | "flumelog-memory": "^0.1.3", |
32 | 36 … | "standard": "^12.0.1" |
33 | 37 … | } |
stores/ledger.js | ||
---|---|---|
@@ -3,18 +3,20 @@ | ||
3 | 3 … | const FlumeLog = require('flumelog-offset') |
4 | 4 … | const { pull, drain } = require('pull-stream') |
5 | 5 … | const codec = require('flumecodec') |
6 | 6 … | |
7 | -function ledger (state, emitter) { | |
7 … | +const db = Flume(FlumeLog('.test.db', { codec: codec.json })) | |
8 … | + .use('entries', Reduce(1, entriesReducer, null, null, [])) | |
9 … | + .use('accounts', Reduce(1, accountReducer, null, null, {})) | |
10 … | + | |
11 … | +const onDone = () => console.log('DONE') | |
12 … | + | |
13 … | +module.exports = ledgerStore | |
14 … | + | |
15 … | +function ledgerStore (state, emitter) { | |
8 | 16 … | state.accounts = {} |
9 | 17 … | state.entries = [] |
10 | 18 … | |
11 | - const db = Flume(FlumeLog('.test.db', { codec: codec.json })) | |
12 | - .use('entries', Reduce(1, entriesReducer, null, null, [])) | |
13 | - .use('accounts', Reduce(1, accountReducer, null, null, {})) | |
14 | - | |
15 | - const onDone = () => console.log('DONE') | |
16 | - | |
17 | 19 … | pull(db.accounts.stream(), drain(acctState => { |
18 | 20 … | state.accounts = acctState |
19 | 21 … | emitter.emit.RENDER |
20 | 22 … | }, onDone)) |
@@ -37,35 +39,33 @@ | ||
37 | 39 … | } |
38 | 40 … | |
39 | 41 … | emitter.on('DOMContentLoaded', onLoad) |
40 | 42 … | |
41 | - function entriesReducer (acc, item) { | |
42 | - if (item.type !== 'entries') return acc | |
43 | - acc.push(item) | |
43 … | +} | |
44 | 44 … | |
45 | - return acc | |
46 | - } | |
45 … | +function entriesReducer (acc, item) { | |
46 … | + if (item.type !== 'entries') return acc | |
47 … | + acc.push(item) | |
47 | 48 … | |
48 | - function accountReducer (acc, item) { // TODO account for account creation of existing account | |
49 | - if (item.type === 'entries') { | |
50 | - const { msg } = item | |
51 | - acc[msg.debit].debit += msg.amount | |
52 | - acc[msg.credit].credit += msg.amount | |
49 … | + return acc | |
50 … | +} | |
53 | 51 … | |
54 | - return acc | |
55 | - } | |
56 | - if (item.type !== 'accounts') return acc | |
52 … | +function accountReducer (acc, item) { // TODO account for account creation of existing account | |
53 … | + if (item.type === 'entries') { | |
57 | 54 … | const { msg } = item |
55 … | + acc[msg.debit].debit += msg.amount | |
56 … | + acc[msg.credit].credit += msg.amount | |
58 | 57 … | |
59 | - if (!acc[msg.name]) { | |
60 | - acc[msg.name] = msg | |
58 … | + return acc | |
59 … | + } | |
60 … | + if (item.type !== 'accounts') return acc | |
61 … | + const { msg } = item | |
61 | 62 … | |
62 | - return acc | |
63 | - } | |
63 … | + if (!acc[msg.name]) { | |
64 … | + acc[msg.name] = msg | |
64 | 65 … | |
65 | - Object.assign(acc[msg.name], msg) | |
66 | - Object.assign(state.accounts[msg.name], msg) | |
67 | 66 … | return acc |
68 | 67 … | } |
68 … | + | |
69 … | + Object.assign(acc[msg.name], msg) | |
70 … | + return acc | |
69 | 71 … | } |
70 | - | |
71 | -module.exports = ledger |
views/accounts.js | ||
---|---|---|
@@ -4,21 +4,25 @@ | ||
4 | 4 … | |
5 | 5 … | function accountsView (state, emit) { |
6 | 6 … | return h('body.code.ph3.lh-copy', [ |
7 | 7 … | state.cache(Nav, 'nav').render(), |
8 | - h('div.pv2', 'account balances'), | |
9 | - Object.keys(state.accounts).map(key => { | |
10 | - if (state.accounts[key].archived) { | |
11 | - return h('div', [ | |
12 | - h('div.dib.strike', { onclick: handleAccountArchive }, state.accounts[key].name), | |
13 | - h('div.dib.pr2.strike', state.accounts[key].debit - state.accounts[key].credit) | |
14 | - ]) | |
15 | - } | |
16 | - return h('div', [ | |
17 | - h('div.dib.pr2', { onclick: handleAccountArchive }, state.accounts[key].name), | |
18 | - h('div.dib', state.accounts[key].debit - state.accounts[key].credit) | |
19 | - ]) | |
20 | - }), | |
8 … | + h('table', [ | |
9 … | + h('thead', h('tr', [ | |
10 … | + h('td.pr2.red', 'account'), | |
11 … | + h('td.pr2', 'balance') | |
12 … | + ])), | |
13 … | + h('tbody', Object.keys(state.accounts).map(key => { | |
14 … | + return state.accounts[key].archived | |
15 … | + ? h('tr', [ | |
16 … | + h('td.strike', state.accounts[key].name), | |
17 … | + h('td.tr.strike', state.accounts[key].debit - state.accounts[key].credit) | |
18 … | + ]) | |
19 … | + : h('tr', [ | |
20 … | + h('td', {onclick: handleAccountArchive}, state.accounts[key].name), | |
21 … | + h('td.tr', state.accounts[key].debit - state.accounts[key].credit) | |
22 … | + ]) | |
23 … | + })) | |
24 … | + ]), | |
21 | 25 … | h('div', [ |
22 | 26 … | h('div.pt4', 'create a new account'), |
23 | 27 … | h('form.pb3', h('input#account')), |
24 | 28 … | h('button', { onclick: handleAccountCreate }, 'create') |
views/entries.js | ||
---|---|---|
@@ -4,18 +4,18 @@ | ||
4 | 4 … | |
5 | 5 … | function view (state, emit) { |
6 | 6 … | if (state.title !== TITLE) emit(state.events.DOMTITLECHANGE, TITLE) |
7 | 7 … | |
8 | - const form = h('form.pv3', [ | |
8 … | + const form = h('form', [ | |
9 | 9 … | h('div.pb2', [ |
10 | - h('label', 'debit account'), | |
10 … | + h('label.mb2', 'debit account'), | |
11 | 11 … | h('div', h('select#debit', [ |
12 | 12 … | h('option', { value: 'true' }, 'select'), |
13 | 13 … | generateAccountList() |
14 | 14 … | ])) |
15 | 15 … | ]), |
16 | 16 … | h('div.pb2', [ |
17 | - h('label', 'credit account'), | |
17 … | + h('label.mb2', 'credit account'), | |
18 | 18 … | h('div', h('select#credit', [ |
19 | 19 … | h('option', { value: 'true' }, 'select'), |
20 | 20 … | generateAccountList() |
21 | 21 … | ])) |
views/transactions.js | ||
---|---|---|
@@ -12,18 +12,18 @@ | ||
12 | 12 … | h('td.pr2', 'description') |
13 | 13 … | ])), |
14 | 14 … | h('tbody', state.entries.map(entry => ['debit', 'credit'].map(i => { |
15 | 15 … | return i === 'debit' |
16 | - ? h('tr', [ | |
16 … | + ? h('tr.bg-light-gray', [ | |
17 | 17 … | h('td', entry.msg.debit), |
18 | 18 … | h('td', entry.msg.amount), |
19 | - h('td', '-'), | |
19 … | + h('td', ''), | |
20 | 20 … | h('td', entry.msg.description) |
21 | 21 … | ]) |
22 | 22 … | : h('tr', [ |
23 | 23 … | h('td', entry.msg.credit), |
24 | - h('td', '-'), | |
25 | - h('td', entry.msg.amount), | |
24 … | + h('td', ''), | |
25 … | + h('td.bg-washed-red', entry.msg.amount), | |
26 | 26 … | h('td', entry.msg.description) |
27 | 27 … | ]) |
28 | 28 … | }))) |
29 | 29 … | ]) |
sw.js | ||
---|---|---|
@@ -1,28 +1,0 @@ | ||
1 | -/* eslint-env serviceworker */ | |
2 | - | |
3 | -var VERSION = require('./package.json').version | |
4 | -var URLS = process.env.FILE_LIST | |
5 | - | |
6 | -// Respond with cached resources | |
7 | -self.addEventListener('fetch', function (e) { | |
8 | - e.respondWith(self.caches.match(e.request).then(function (request) { | |
9 | - if (request) return request | |
10 | - else return self.fetch(e.request) | |
11 | - })) | |
12 | -}) | |
13 | - | |
14 | -// Register worker | |
15 | -self.addEventListener('install', function (e) { | |
16 | - e.waitUntil(self.caches.open(VERSION).then(function (cache) { | |
17 | - return cache.addAll(URLS) | |
18 | - })) | |
19 | -}) | |
20 | - | |
21 | -// Remove outdated resources | |
22 | -self.addEventListener('activate', function (e) { | |
23 | - e.waitUntil(self.caches.keys().then(function (keyList) { | |
24 | - return Promise.all(keyList.map(function (key, i) { | |
25 | - if (keyList[i] !== VERSION) return self.caches.delete(keyList[i]) | |
26 | - })) | |
27 | - })) | |
28 | -}) |
Built with git-ssb-web