From 279d644a2e20e3abdae510c6a96498995fcaf842 Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Tue, 18 Dec 2018 08:59:01 -0600 Subject: [PATCH] WIP: Use firebase as a backend for the app --- package-lock.json | 785 +++++++++++++++++++++-- package.json | 1 + src/app/api.service.ts | 18 +- src/app/app.component.html | 6 +- src/app/app.component.ts | 18 +- src/app/app.module.ts | 5 +- src/app/auth.service.ts | 54 +- src/app/dashboard/dashboard.component.ts | 2 +- src/app/login/login.component.html | 4 +- src/app/login/login.component.ts | 5 +- src/app/transaction.service.ts | 24 +- 11 files changed, 810 insertions(+), 112 deletions(-) diff --git a/package-lock.json b/package-lock.json index fa6ec43..893beaa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -430,6 +430,212 @@ "tslib": "1.9.3" } }, + "@firebase/app": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/@firebase/app/-/app-0.3.4.tgz", + "integrity": "sha512-Q6sNpWZ3x+FeuBkLCCRrsOraGJOKVLUCc9Amj8zu2vAC1v2uWifRR6kZ60TrpaIxtY4N6pcPTaG0YIUT5lgeSA==", + "requires": { + "@firebase/app-types": "0.3.2", + "@firebase/util": "0.2.2", + "dom-storage": "2.1.0", + "tslib": "1.9.0", + "xmlhttprequest": "1.8.0" + }, + "dependencies": { + "tslib": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz", + "integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==" + } + } + }, + "@firebase/app-types": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@firebase/app-types/-/app-types-0.3.2.tgz", + "integrity": "sha512-ZD8lTgW07NGgo75bTyBJA8Lt9+NweNzot7lrsBtIvfciwUzaFJLsv2EShqjBeuhF7RpG6YFucJ6m67w5buCtzw==" + }, + "@firebase/auth": { + "version": "0.7.9", + "resolved": "https://registry.npmjs.org/@firebase/auth/-/auth-0.7.9.tgz", + "integrity": "sha512-m8e2KZ/WvToTMovoBI5K3N0Ku8Aqt6083oqzQODUYHjf94KsAfGdoQEaJono7T7vK4o7E5xpqFgFldOM5LdgiQ==", + "requires": { + "@firebase/auth-types": "0.3.4" + } + }, + "@firebase/auth-types": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/@firebase/auth-types/-/auth-types-0.3.4.tgz", + "integrity": "sha512-0r3gSQk9jw5orFHCTUIgao0zan6dHt2J0BO3t/uEzbod+uwqvUn/gh+yg+kK6HX92Fg8E7y030KX4Bw/aXt0Ew==" + }, + "@firebase/database": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@firebase/database/-/database-0.3.6.tgz", + "integrity": "sha512-r02JOqTLcd2/qn7QkkJvIAxMiMxmeyd5B76kl9hHAs+3cil5mUzHnI3svtb4h0VIJYDHFKJMlVl/bE3GfcTR3A==", + "requires": { + "@firebase/database-types": "0.3.2", + "@firebase/logger": "0.1.1", + "@firebase/util": "0.2.2", + "faye-websocket": "0.11.1", + "tslib": "1.9.0" + }, + "dependencies": { + "faye-websocket": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.1.tgz", + "integrity": "sha1-8O/hjE9W5PQK/H4Gxxn9XuYYjzg=", + "requires": { + "websocket-driver": "0.7.0" + } + }, + "tslib": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz", + "integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==" + } + } + }, + "@firebase/database-types": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@firebase/database-types/-/database-types-0.3.2.tgz", + "integrity": "sha512-9ZYdvYQ6r3aaHJarhUM5Hf6lQWu3ZJme+RR0o8qfBb9L04TL3uNjt+AJFku1ysVPntTn+9GqJjiIB2/OC3JtwA==" + }, + "@firebase/firestore": { + "version": "0.8.7", + "resolved": "https://registry.npmjs.org/@firebase/firestore/-/firestore-0.8.7.tgz", + "integrity": "sha512-FdC8YKryht2Rp2CHguendS8VelP83MDY5p7EKBTlxPPZV7yb5Vt+cmLR6AG7TR+FsBzvdOUpbOEnAErUVgZAFQ==", + "requires": { + "@firebase/firestore-types": "0.7.0", + "@firebase/logger": "0.1.1", + "@firebase/webchannel-wrapper": "0.2.11", + "grpc": "1.16.0", + "tslib": "1.9.0" + }, + "dependencies": { + "tslib": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz", + "integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==" + } + } + }, + "@firebase/firestore-types": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@firebase/firestore-types/-/firestore-types-0.7.0.tgz", + "integrity": "sha512-jyKRcKnSh3CSEPL4xGOZNoOXEiv7YmFK/JEcdd/4cAH17/Xo+Pk67gk1E648LRKh6QPghgNvzNTY5R10mKbQNw==" + }, + "@firebase/functions": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@firebase/functions/-/functions-0.3.2.tgz", + "integrity": "sha512-jZdNzNrJplswIJXcdpXZr6vEbDrDKU4P0+nHv/D85LHeHnPkkdNO+Yh3tikbVEJpYCG8EVOhIEfAIEuFo37i4A==", + "requires": { + "@firebase/functions-types": "0.2.1", + "@firebase/messaging-types": "0.2.3", + "isomorphic-fetch": "2.2.1", + "tslib": "1.9.0" + }, + "dependencies": { + "tslib": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz", + "integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==" + } + } + }, + "@firebase/functions-types": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@firebase/functions-types/-/functions-types-0.2.1.tgz", + "integrity": "sha512-hH78lgDoa5E1peBSXnfQyshENmh/5a8aia+S4Ocjc53OUWRJ4VqYwWUV5gE4b2mqVKTpN4akJccLq2pCnNGZcA==" + }, + "@firebase/logger": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.1.1.tgz", + "integrity": "sha512-5jn3HHbEfdOwychyIEIkP1cik+MW/vvoOavTOzwDkH+fv6Bx+HBUOzh09M7sCYzXFtKzjbUax9+g39mJNBLklQ==" + }, + "@firebase/messaging": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@firebase/messaging/-/messaging-0.3.6.tgz", + "integrity": "sha512-Sz/fWOXMa3HxDZxE64Fm335kwP9um1rmun5PIka7od7I4hZ8US+SjYVyUe6jWTh1V/YjcqDi6Xkhoj2nF8yu9g==", + "requires": { + "@firebase/messaging-types": "0.2.3", + "@firebase/util": "0.2.2", + "tslib": "1.9.0" + }, + "dependencies": { + "tslib": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz", + "integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==" + } + } + }, + "@firebase/messaging-types": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@firebase/messaging-types/-/messaging-types-0.2.3.tgz", + "integrity": "sha512-avwCgZzcx2uxIW/wT3p3G/EyHftIrvMyiTS7AA7dxDlzfx+8dpAeTsb1+jsHJT4F6foSh5HG17Nw8sDzYuxH1Q==" + }, + "@firebase/polyfill": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@firebase/polyfill/-/polyfill-0.3.3.tgz", + "integrity": "sha512-xs8IZf1WEbufYXyfV8YjmiFZOaujRRq0T03NteihYfuGVTTym7z5SmvLvEHLEUjf2fgeobPEzZ2JgrCQHS+QHw==", + "requires": { + "core-js": "2.5.5", + "promise-polyfill": "7.1.2", + "whatwg-fetch": "2.0.4" + }, + "dependencies": { + "core-js": { + "version": "2.5.5", + "resolved": "http://registry.npmjs.org/core-js/-/core-js-2.5.5.tgz", + "integrity": "sha1-sU3ek2xkDAV5prUMq8wTLdYSfjs=" + }, + "whatwg-fetch": { + "version": "2.0.4", + "resolved": "http://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz", + "integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==" + } + } + }, + "@firebase/storage": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/@firebase/storage/-/storage-0.2.4.tgz", + "integrity": "sha512-uqA6CoZYkugk69ImqB16VBPP7JRPRfZwcUP9CsE0GPVGQkZQQfBGwzIyEoFA8lUfVLrvxQiL0sQvHUXZ945LMg==", + "requires": { + "@firebase/storage-types": "0.2.3", + "tslib": "1.9.0" + }, + "dependencies": { + "tslib": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz", + "integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==" + } + } + }, + "@firebase/storage-types": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@firebase/storage-types/-/storage-types-0.2.3.tgz", + "integrity": "sha512-RaZeam2LgsB7xwAtOQr4G0Geoyf7D5TnLF3a12By6Rh0Z9PqBSlWn0SVYGW3SkmxIdqvWZMZvCyamUlqQvQzWw==" + }, + "@firebase/util": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.2.tgz", + "integrity": "sha512-vfRjmCWuxtJx3txHocaNlDwCDwwv6KLL5YtlSNi73wBdvF3UfnpLGrth7G3X6gn5rDhOKamRg2+9L8cfsjSS1A==", + "requires": { + "tslib": "1.9.0" + }, + "dependencies": { + "tslib": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz", + "integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==" + } + } + }, + "@firebase/webchannel-wrapper": { + "version": "0.2.11", + "resolved": "https://registry.npmjs.org/@firebase/webchannel-wrapper/-/webchannel-wrapper-0.2.11.tgz", + "integrity": "sha512-WyMXDxk/WZ+f2lOCeEvDWUce2f5Kk2sNfvArK8f+PlUnzFdy/MBzLXrmbMgyZXP7GP4ooUxYV8Sdmoh1hGk1Uw==" + }, "@ngtools/webpack": { "version": "6.1.5", "resolved": "https://registry.npmjs.org/@ngtools/webpack/-/webpack-6.1.5.tgz", @@ -791,7 +997,6 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", - "dev": true, "requires": { "kind-of": "3.2.2", "longest": "1.0.1", @@ -802,7 +1007,6 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, "requires": { "is-buffer": "1.1.6" } @@ -963,6 +1167,15 @@ "dev": true, "optional": true }, + "ascli": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ascli/-/ascli-1.0.1.tgz", + "integrity": "sha1-vPpZdKYvGOgcq660lzKrSoj5Brw=", + "requires": { + "colour": "0.7.1", + "optjs": "3.2.2" + } + }, "asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", @@ -1603,6 +1816,14 @@ "integrity": "sha1-y5T662HIaWRR2zZTThQi+U8K7og=", "dev": true }, + "bytebuffer": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/bytebuffer/-/bytebuffer-5.0.1.tgz", + "integrity": "sha1-WC7qSxqHO20CCkjVjfhfC7ps/d0=", + "requires": { + "long": "3.2.0" + } + }, "bytes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", @@ -1665,9 +1886,7 @@ "camelcase": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", - "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", - "dev": true, - "optional": true + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=" }, "camelcase-keys": { "version": "2.1.0", @@ -1703,8 +1922,6 @@ "version": "0.1.3", "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", - "dev": true, - "optional": true, "requires": { "align-text": "0.1.4", "lazy-cache": "1.0.4" @@ -1810,8 +2027,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", - "dev": true, - "optional": true, "requires": { "center-align": "0.1.3", "right-align": "0.1.3", @@ -1821,9 +2036,7 @@ "wordwrap": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", - "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", - "dev": true, - "optional": true + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=" } } }, @@ -1901,6 +2114,11 @@ "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", "dev": true }, + "colour": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/colour/-/colour-0.7.1.tgz", + "integrity": "sha1-nLFpkX7F0SwHNtPoaFdG3xyt93g=" + }, "combine-lists": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/combine-lists/-/combine-lists-1.0.1.tgz", @@ -2326,8 +2544,7 @@ "decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" }, "decode-uri-component": { "version": "0.2.0", @@ -2605,6 +2822,11 @@ } } }, + "dom-storage": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/dom-storage/-/dom-storage-2.1.0.tgz", + "integrity": "sha512-g6RpyWXzl0RR6OTElHKBl7nwnK87GUyZMYC7JWsB/IA73vpqK2K6LT39x4VepLxlSsWBFrPVLnsSR5Jyty0+2Q==" + }, "domain-browser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", @@ -2704,6 +2926,14 @@ "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", "dev": true }, + "encoding": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", + "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", + "requires": { + "iconv-lite": "0.4.19" + } + }, "end-of-stream": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", @@ -3440,6 +3670,21 @@ "locate-path": "2.0.0" } }, + "firebase": { + "version": "5.5.8", + "resolved": "https://registry.npmjs.org/firebase/-/firebase-5.5.8.tgz", + "integrity": "sha512-aT75TO8JLX2bTsPLq/2FrX87sgsvSF7mFDJBKl+hC5yJeaT3fuqrn806lQ56TRGWXFi5oYENYn00hmy/4PR0AQ==", + "requires": { + "@firebase/app": "0.3.4", + "@firebase/auth": "0.7.9", + "@firebase/database": "0.3.6", + "@firebase/firestore": "0.8.7", + "@firebase/functions": "0.3.2", + "@firebase/messaging": "0.3.6", + "@firebase/polyfill": "0.3.3", + "@firebase/storage": "0.2.4" + } + }, "flush-write-stream": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.0.3.tgz", @@ -3555,8 +3800,7 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "fstream": { "version": "1.0.11", @@ -3638,7 +3882,6 @@ "version": "7.1.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", - "dev": true, "requires": { "fs.realpath": "1.0.0", "inflight": "1.0.6", @@ -3740,6 +3983,422 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" }, + "grpc": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/grpc/-/grpc-1.16.0.tgz", + "integrity": "sha512-+p8YRIng7Gihkn2jycAXwXdA9aQ10SikRrcHY+/r3W1Z1Pr9NFIbLcmBZPoaTbzzLDv/ysqwqFEZriAdd8tveQ==", + "requires": { + "lodash": "4.17.10", + "nan": "2.11.0", + "node-pre-gyp": "0.10.3", + "protobufjs": "5.0.3" + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "bundled": true + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true + }, + "aproba": { + "version": "1.2.0", + "bundled": true + }, + "are-we-there-yet": { + "version": "1.1.5", + "bundled": true, + "requires": { + "delegates": "1.0.0", + "readable-stream": "2.3.6" + } + }, + "balanced-match": { + "version": "1.0.0", + "bundled": true + }, + "brace-expansion": { + "version": "1.1.11", + "bundled": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "chownr": { + "version": "1.0.1", + "bundled": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true + }, + "concat-map": { + "version": "0.0.1", + "bundled": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true + }, + "debug": { + "version": "2.6.9", + "bundled": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.6.0", + "bundled": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true + }, + "detect-libc": { + "version": "1.0.3", + "bundled": true + }, + "fs-minipass": { + "version": "1.2.5", + "bundled": true, + "requires": { + "minipass": "2.3.3" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "requires": { + "aproba": "1.2.0", + "console-control-strings": "1.1.0", + "has-unicode": "2.0.1", + "object-assign": "4.1.1", + "signal-exit": "3.0.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wide-align": "1.1.3" + } + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true + }, + "iconv-lite": { + "version": "0.4.23", + "bundled": true, + "requires": { + "safer-buffer": "2.1.2" + } + }, + "ignore-walk": { + "version": "3.0.1", + "bundled": true, + "requires": { + "minimatch": "3.0.4" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true + }, + "ini": { + "version": "1.3.5", + "bundled": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "isarray": { + "version": "1.0.0", + "bundled": true + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "requires": { + "brace-expansion": "1.1.11" + } + }, + "minimist": { + "version": "1.2.0", + "bundled": true + }, + "minipass": { + "version": "2.3.3", + "bundled": true, + "requires": { + "safe-buffer": "5.1.2", + "yallist": "3.0.2" + } + }, + "minizlib": { + "version": "1.1.0", + "bundled": true, + "requires": { + "minipass": "2.3.3" + } + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "requires": { + "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "bundled": true + } + } + }, + "ms": { + "version": "2.0.0", + "bundled": true + }, + "needle": { + "version": "2.2.2", + "bundled": true, + "requires": { + "debug": "2.6.9", + "iconv-lite": "0.4.23", + "sax": "1.2.4" + } + }, + "node-pre-gyp": { + "version": "0.10.3", + "bundled": true, + "requires": { + "detect-libc": "1.0.3", + "mkdirp": "0.5.1", + "needle": "2.2.2", + "nopt": "4.0.1", + "npm-packlist": "1.1.11", + "npmlog": "4.1.2", + "rc": "1.2.8", + "rimraf": "2.6.2", + "semver": "5.5.0", + "tar": "4.4.6" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "requires": { + "abbrev": "1.1.1", + "osenv": "0.1.5" + } + }, + "npm-bundled": { + "version": "1.0.3", + "bundled": true + }, + "npm-packlist": { + "version": "1.1.11", + "bundled": true, + "requires": { + "ignore-walk": "3.0.1", + "npm-bundled": "1.0.3" + } + }, + "npmlog": { + "version": "4.1.2", + "bundled": true, + "requires": { + "are-we-there-yet": "1.1.5", + "console-control-strings": "1.1.0", + "gauge": "2.7.4", + "set-blocking": "2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true + }, + "osenv": { + "version": "0.1.5", + "bundled": true, + "requires": { + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true + }, + "process-nextick-args": { + "version": "2.0.0", + "bundled": true + }, + "rc": { + "version": "1.2.8", + "bundled": true, + "requires": { + "deep-extend": "0.6.0", + "ini": "1.3.5", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + } + }, + "readable-stream": { + "version": "2.3.6", + "bundled": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "2.0.0", + "safe-buffer": "5.1.2", + "string_decoder": "1.1.1", + "util-deprecate": "1.0.2" + } + }, + "rimraf": { + "version": "2.6.2", + "bundled": true, + "requires": { + "glob": "7.1.2" + } + }, + "safe-buffer": { + "version": "5.1.2", + "bundled": true + }, + "safer-buffer": { + "version": "2.1.2", + "bundled": true + }, + "sax": { + "version": "1.2.4", + "bundled": true + }, + "semver": { + "version": "5.5.0", + "bundled": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "bundled": true, + "requires": { + "safe-buffer": "5.1.2" + } + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true + }, + "tar": { + "version": "4.4.6", + "bundled": true, + "requires": { + "chownr": "1.0.1", + "fs-minipass": "1.2.5", + "minipass": "2.3.3", + "minizlib": "1.1.0", + "mkdirp": "0.5.1", + "safe-buffer": "5.1.2", + "yallist": "3.0.2" + } + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true + }, + "wide-align": { + "version": "1.1.3", + "bundled": true, + "requires": { + "string-width": "1.0.2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true + }, + "yallist": { + "version": "3.0.2", + "bundled": true + } + } + }, "hammerjs": { "version": "2.0.8", "resolved": "https://registry.npmjs.org/hammerjs/-/hammerjs-2.0.8.tgz", @@ -4080,8 +4739,7 @@ "http-parser-js": { "version": "0.4.13", "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.4.13.tgz", - "integrity": "sha1-O9bW/ebjFyyTNMOzO2wZPYD+ETc=", - "dev": true + "integrity": "sha1-O9bW/ebjFyyTNMOzO2wZPYD+ETc=" }, "http-proxy": { "version": "1.17.0", @@ -4147,8 +4805,7 @@ "iconv-lite": { "version": "0.4.19", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", - "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", - "dev": true + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" }, "ieee754": { "version": "1.1.12", @@ -4241,7 +4898,6 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, "requires": { "once": "1.4.0", "wrappy": "1.0.2" @@ -4518,8 +5174,7 @@ "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" }, "is-symbol": { "version": "1.0.1", @@ -4575,6 +5230,15 @@ "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" }, + "isomorphic-fetch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", + "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", + "requires": { + "node-fetch": "1.7.3", + "whatwg-fetch": "3.0.0" + } + }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -5209,9 +5873,7 @@ "lazy-cache": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", - "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", - "dev": true, - "optional": true + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=" }, "lcid": { "version": "1.0.0", @@ -5344,8 +6006,7 @@ "lodash": { "version": "4.17.10", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", - "dev": true + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" }, "lodash.assign": { "version": "4.2.0", @@ -5429,14 +6090,12 @@ "long": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz", - "integrity": "sha1-2CG3E4yhy1gcFymQ7xTbIAtcR0s=", - "dev": true + "integrity": "sha1-2CG3E4yhy1gcFymQ7xTbIAtcR0s=" }, "longest": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", - "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", - "dev": true + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=" }, "loose-envify": { "version": "1.4.0", @@ -5795,9 +6454,7 @@ "nan": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.0.tgz", - "integrity": "sha512-F4miItu2rGnV2ySkXOQoA8FKz/SR2Q2sWP0sbTxNxz/tuokeC8WxOhPMcwi0qIyGtVn/rrSeLbvVkznqCdwYnw==", - "dev": true, - "optional": true + "integrity": "sha512-F4miItu2rGnV2ySkXOQoA8FKz/SR2Q2sWP0sbTxNxz/tuokeC8WxOhPMcwi0qIyGtVn/rrSeLbvVkznqCdwYnw==" }, "nanomatch": { "version": "1.2.13", @@ -5843,6 +6500,15 @@ "lower-case": "1.1.4" } }, + "node-fetch": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", + "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", + "requires": { + "encoding": "0.1.12", + "is-stream": "1.1.0" + } + }, "node-forge": { "version": "0.7.5", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.5.tgz", @@ -6292,7 +6958,6 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, "requires": { "wrappy": "1.0.2" } @@ -6344,6 +7009,11 @@ "integrity": "sha1-7CLTEoBrtT5zF3Pnza788cZDEo8=", "dev": true }, + "optjs": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/optjs/-/optjs-3.2.2.tgz", + "integrity": "sha1-aabOicRCpEQDFBrS+bNwvVu29O4=" + }, "original": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/original/-/original-1.0.2.tgz", @@ -6789,6 +7459,22 @@ "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=", "dev": true }, + "promise-polyfill": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-7.1.2.tgz", + "integrity": "sha512-FuEc12/eKqqoRYIGBrUptCBRhobL19PS2U31vMNTfyck1FxPyMfgsXyW4Mav85y/ZN1hop3hOwRlUDok23oYfQ==" + }, + "protobufjs": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-5.0.3.tgz", + "integrity": "sha512-55Kcx1MhPZX0zTbVosMQEO5R6/rikNXd9b6RQK4KSPcrSIIwoXTtebIczUrXlwaSrbz4x8XUVThGPob1n8I4QA==", + "requires": { + "ascli": "1.0.1", + "bytebuffer": "5.0.1", + "glob": "7.1.3", + "yargs": "3.10.0" + } + }, "protractor": { "version": "5.4.0", "resolved": "https://registry.npmjs.org/protractor/-/protractor-5.4.0.tgz", @@ -7433,8 +8119,6 @@ "version": "0.1.3", "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", - "dev": true, - "optional": true, "requires": { "align-text": "0.1.4" } @@ -9552,7 +10236,6 @@ "version": "0.7.0", "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.0.tgz", "integrity": "sha1-DK+dLXVdk67gSdS90NP+LMoqJOs=", - "dev": true, "requires": { "http-parser-js": "0.4.13", "websocket-extensions": "0.1.3" @@ -9561,8 +10244,12 @@ "websocket-extensions": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.3.tgz", - "integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==", - "dev": true + "integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==" + }, + "whatwg-fetch": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", + "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" }, "when": { "version": "3.6.4", @@ -9598,9 +10285,7 @@ "window-size": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", - "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", - "dev": true, - "optional": true + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=" }, "wordwrap": { "version": "1.0.0", @@ -9630,8 +10315,7 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "ws": { "version": "1.1.2", @@ -9673,6 +10357,11 @@ "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=", "dev": true }, + "xmlhttprequest": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", + "integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw=" + }, "xmlhttprequest-ssl": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz", @@ -9716,8 +10405,6 @@ "version": "3.10.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", - "dev": true, - "optional": true, "requires": { "camelcase": "1.2.1", "cliui": "2.1.0", diff --git a/package.json b/package.json index c094bbd..c77c5fc 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "@angular/service-worker": "^6.1.0", "core-js": "^2.5.4", "dexie": "^2.0.4", + "firebase": "^5.5.8", "hammerjs": "^2.0.8", "ng2-currency-mask": "^5.3.1", "rxjs": "^6.0.0", diff --git a/src/app/api.service.ts b/src/app/api.service.ts index 7750b56..3c886b1 100644 --- a/src/app/api.service.ts +++ b/src/app/api.service.ts @@ -1,7 +1,9 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; -import { Observable, of } from 'rxjs'; +import { Observable, of, from } from 'rxjs'; import { Transaction } from './transaction'; +import * as firebase from 'firebase/app'; +import 'firebase/database'; const httpOptions = { headers: new HttpHeaders({ @@ -52,10 +54,16 @@ export class ApiService { } getTransactions(): Observable { - return this.http.get( - host + '/transactions', - httpOptions - ); + return Observable.create(subscriber => { + const transactionsRef = firebase.database().ref('transactions'); + transactionsRef.on('child_changed', data => { + if (!data.val()) { + return; + } + + subscriber.next(data.val()); + }); + }); } saveTransaction(transaction: Transaction): Observable { diff --git a/src/app/app.component.html b/src/app/app.component.html index 34dd007..04381e4 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -3,9 +3,9 @@ Manage Accounts Export Data - Login - Register - Logout + Login + Register + Logout diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 31a448f..81234bb 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -3,6 +3,8 @@ import { Location } from '@angular/common'; import { Actionable } from './actionable'; import { AuthService } from './auth.service'; import { BudgetDatabase } from './budget-database'; +import * as firebase from 'firebase/app'; +import 'firebase/auth'; @Component({ selector: 'app-root', @@ -18,7 +20,17 @@ export class AppComponent { public authService: AuthService, private location: Location, private db: BudgetDatabase, - ) { } + ) { + const config = { + apiKey: 'AIzaSyALYI-ILmLV8NBNXE3DLF9yf1Z5Pp-Y1Mk', + authDomain: 'budget-c7da5.firebaseapp.com', + databaseURL: 'https://budget-c7da5.firebaseio.com', + projectId: 'budget-c7da5', + storageBucket: 'budget-c7da5.appspot.com', + messagingSenderId: '527070722499' + }; + firebase.initializeApp(config); + } goBack(): void { this.location.back(); @@ -43,4 +55,8 @@ export class AppComponent { window.URL.revokeObjectURL(url); }); } + + isLoggedIn() { + return firebase.auth().currentUser != null; + } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index c6112fe..8573844 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -36,8 +36,9 @@ import { AddEditAccountComponent } from './add-edit-account/add-edit-account.com import { EditProfileComponent } from './edit-profile/edit-profile.component'; import { UserComponent } from './user/user.component'; import { HttpClientModule } from '@angular/common/http'; -import { CurrencyMaskModule } from "ng2-currency-mask"; -import { CurrencyMaskConfig, CURRENCY_MASK_CONFIG } from "ng2-currency-mask/src/currency-mask.config"; +import { CurrencyMaskModule } from 'ng2-currency-mask'; +import { CurrencyMaskConfig, CURRENCY_MASK_CONFIG } from 'ng2-currency-mask/src/currency-mask.config'; +import * as firebase from 'firebase/app'; export const CustomCurrencyMaskConfig: CurrencyMaskConfig = { align: 'left', diff --git a/src/app/auth.service.ts b/src/app/auth.service.ts index 2e8432c..f1dfe4e 100644 --- a/src/app/auth.service.ts +++ b/src/app/auth.service.ts @@ -2,52 +2,42 @@ import { Injectable } from '@angular/core'; import { ApiService } from './api.service'; import { User } from './user'; import { Router } from '@angular/router'; +import * as firebase from 'firebase/app'; @Injectable({ providedIn: 'root' }) export class AuthService { - public currentUser: User; constructor( private apiService: ApiService, private router: Router, ) { } - login(user: User) { - this.apiService.login(user.name, user.password).subscribe( - value => { - this.currentUser = value; - this.router.navigate(['/']); - }, - error => { - console.log('Login failed'); - console.log(error); - } - ); + login(email: string, password: string) { + firebase.auth().signInWithEmailAndPassword(email, password).then(value => { + this.router.navigate(['/']); + }).catch(err => { + console.log('Login failed'); + console.log(err); + }); } - register(user: User) { - this.apiService.register(user.name, user.email, user.password).subscribe( - value => { - this.login(value); - }, - error => { - console.log('Registration failed'); - console.log(error); - } - ); - } + // register(user: User) { + // this.apiService.register(user.name, user.email, user.password).subscribe( + // value => { + // this.login(value); + // }, + // error => { + // console.log('Registration failed'); + // console.log(error); + // } + // ); + // } logout() { - this.apiService.logout().subscribe( - value => { - window.location.reload(); - }, - error => { - console.log('Logout failed'); - console.log(error); - } - ); + firebase.auth().signOut().then(value => { + window.location.reload(); + }); } } diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index de8512d..bf599e1 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -39,7 +39,7 @@ export class DashboardComponent implements OnInit { } getTransactions(): void { - this.transactionService.getTransactions(5).subscribe(transactions => this.transactions = transactions) + this.transactionService.getTransactions(5).subscribe(transactions => this.transactions = transactions); } getCategories(): void { diff --git a/src/app/login/login.component.html b/src/app/login/login.component.html index 82671df..9042c8d 100644 --- a/src/app/login/login.component.html +++ b/src/app/login/login.component.html @@ -1,8 +1,8 @@ \ No newline at end of file diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index 722e592..910da31 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -11,7 +11,8 @@ import { AppComponent } from '../app.component'; }) export class LoginComponent implements OnInit, OnDestroy, Actionable { - public user: User = new User(); + public email: string; + public password: string; constructor( private app: AppComponent, @@ -29,7 +30,7 @@ export class LoginComponent implements OnInit, OnDestroy, Actionable { } doAction(): void { - this.authService.login(this.user); + this.authService.login(this.email, this.password); } getActionLabel() { diff --git a/src/app/transaction.service.ts b/src/app/transaction.service.ts index 4d4fa22..f8f0a0e 100644 --- a/src/app/transaction.service.ts +++ b/src/app/transaction.service.ts @@ -5,6 +5,7 @@ import { TransactionType } from './transaction.type'; import { BudgetDatabase, ITransaction } from './budget-database'; import { AuthService } from './auth.service'; import { ApiService } from './api.service'; +import * as firebase from 'firebase/app'; @Injectable({ providedIn: 'root' @@ -19,21 +20,14 @@ export class TransactionService { getTransactions(count?: number): Observable { // Check if we have a currently logged in user - if (this.authService.currentUser) { - this.apiService.getTransactions().subscribe( - value => { - console.log(value); - }, - error => { - console.error(error); - } - ); - } - if (count) { - return from(this.db.transactions.orderBy('date').reverse().limit(count).toArray()); - } else { - return from(this.db.transactions.orderBy('date').reverse().toArray()); + if (!firebase.auth().currentUser) { + if (count) { + return from(this.db.transactions.orderBy('date').reverse().limit(count).toArray()); + } else { + return from(this.db.transactions.orderBy('date').reverse().toArray()); + } } + return this.apiService.getTransactions(); } getTransaction(id: number): Observable { @@ -53,7 +47,7 @@ export class TransactionService { saveTransaction(transaction: Transaction): Observable { this.db.transactions.put(transaction); - if (this.authService.currentUser) { + if (auth().currentUser) { return this.apiService.saveTransaction(transaction); } else { return of(transaction);