git ssb

0+

punkmonk / double



Commit 2572fe0b931c25cc2eceb014c272f1a57a9157a9

fixed some styles

austinfrey committed on 11/6/2018, 2:22:51 AM
Parent: 8f610eca2bb7c82ab4520dcd17f0816be4901f3b

Files changed

package-lock.jsonchanged
package.jsonchanged
stores/ledger.jschanged
views/accounts.jschanged
views/entries.jschanged
views/transactions.jschanged
sw.jsdeleted
package-lock.jsonView
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.jsonView
@@ -4,8 +4,11 @@
44 "private": true,
55 "scripts": {
66 "build": "bankai build index.js",
77 "create": "choo-scaffold",
8 + "electro": "electro .",
9 + "electro:clean": "rm .test.db accounts.json entries.json && electro .",
10 + "carlo": "node carlo",
811 "inspect": "bankai inspect index.js",
912 "start": "bankai start index.js",
1013 "test": "standard && npm run test-deps",
1114 "test-deps": "dependency-check . && dependency-check . --extra --no-dev -i tachyons"
@@ -26,8 +29,9 @@
2629 "bankai": "^9.15.0",
2730 "choo-devtools": "^2.5.1",
2831 "choo-scaffold": "^1.2.0",
2932 "dependency-check": "^3.2.1",
33 + "electro": "^2.1.1",
3034 "electron": "^3.0.6",
3135 "flumelog-memory": "^0.1.3",
3236 "standard": "^12.0.1"
3337 }
stores/ledger.jsView
@@ -3,18 +3,20 @@
33 const FlumeLog = require('flumelog-offset')
44 const { pull, drain } = require('pull-stream')
55 const codec = require('flumecodec')
66
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) {
816 state.accounts = {}
917 state.entries = []
1018
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-
1719 pull(db.accounts.stream(), drain(acctState => {
1820 state.accounts = acctState
1921 emitter.emit.RENDER
2022 }, onDone))
@@ -37,35 +39,33 @@
3739 }
3840
3941 emitter.on('DOMContentLoaded', onLoad)
4042
41- function entriesReducer (acc, item) {
42- if (item.type !== 'entries') return acc
43- acc.push(item)
43 +}
4444
45- return acc
46- }
45 +function entriesReducer (acc, item) {
46 + if (item.type !== 'entries') return acc
47 + acc.push(item)
4748
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 +}
5351
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') {
5754 const { msg } = item
55 + acc[msg.debit].debit += msg.amount
56 + acc[msg.credit].credit += msg.amount
5857
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
6162
62- return acc
63- }
63 + if (!acc[msg.name]) {
64 + acc[msg.name] = msg
6465
65- Object.assign(acc[msg.name], msg)
66- Object.assign(state.accounts[msg.name], msg)
6766 return acc
6867 }
68 +
69 + Object.assign(acc[msg.name], msg)
70 + return acc
6971 }
70-
71-module.exports = ledger
views/accounts.jsView
@@ -4,21 +4,25 @@
44
55 function accountsView (state, emit) {
66 return h('body.code.ph3.lh-copy', [
77 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 + ]),
2125 h('div', [
2226 h('div.pt4', 'create a new account'),
2327 h('form.pb3', h('input#account')),
2428 h('button', { onclick: handleAccountCreate }, 'create')
views/entries.jsView
@@ -4,18 +4,18 @@
44
55 function view (state, emit) {
66 if (state.title !== TITLE) emit(state.events.DOMTITLECHANGE, TITLE)
77
8- const form = h('form.pv3', [
8 + const form = h('form', [
99 h('div.pb2', [
10- h('label', 'debit account'),
10 + h('label.mb2', 'debit account'),
1111 h('div', h('select#debit', [
1212 h('option', { value: 'true' }, 'select'),
1313 generateAccountList()
1414 ]))
1515 ]),
1616 h('div.pb2', [
17- h('label', 'credit account'),
17 + h('label.mb2', 'credit account'),
1818 h('div', h('select#credit', [
1919 h('option', { value: 'true' }, 'select'),
2020 generateAccountList()
2121 ]))
views/transactions.jsView
@@ -12,18 +12,18 @@
1212 h('td.pr2', 'description')
1313 ])),
1414 h('tbody', state.entries.map(entry => ['debit', 'credit'].map(i => {
1515 return i === 'debit'
16- ? h('tr', [
16 + ? h('tr.bg-light-gray', [
1717 h('td', entry.msg.debit),
1818 h('td', entry.msg.amount),
19- h('td', '-'),
19 + h('td', ''),
2020 h('td', entry.msg.description)
2121 ])
2222 : h('tr', [
2323 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),
2626 h('td', entry.msg.description)
2727 ])
2828 })))
2929 ])
sw.jsView
@@ -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