Skip to content

Commit f41a127

Browse files
authored
Merge pull request #128 from bitfinexcom/beta
Release version 1.6.2
2 parents 332b468 + 2f22ef9 commit f41a127

27 files changed

Lines changed: 988 additions & 220 deletions

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
package-lock=false
2+
save-exact=true

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
12+
- Added ability to `backup/restore` DB
13+
- Added ability to track server worker errors
14+
- Added `changelog` file and flow to show one in the modal dialog after the app was updated
15+
16+
### Fixed
17+
18+
- Fixed snapshots tickers. The issue is the following: when taking a snapshot of wallets it's not showing the correspondent tickers as to represent crypto in fiat equivalent
19+
- Fixed error manager
20+
21+
### Changed
22+
23+
- Updated electron version up to `13.6.3`
24+
25+
## [3.6.1] - 2021-11-03
26+
27+
### Fixed
28+
29+
- Fixed `account summary` response for sub-account
30+
- Fixed issue with app crashing on `Start Snapshot` and related `React` errors
31+
32+
### Added
33+
34+
- Added `win/loss` vs `account balance` report
35+
- Added `Show Unrealized Profits` selectors to `Average Win/Loss` and `Account Balance` sections

Dockerfile.win-builder

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ ENV NODE_VERSION 14.16.0
44

55
COPY ./scripts/install-nodejs.sh ./scripts/install-nodejs.sh
66

7-
RUN ./scripts/install-nodejs.sh $NODE_VERSION \
8-
&& wget -nv https://download.opensuse.org/repositories/Emulators:/Wine:/Debian/xUbuntu_18.04/Release.key -O Release.key \
9-
&& apt-key add - < Release.key \
7+
RUN ./scripts/install-nodejs.sh $NODE_VERSION \
8+
# Remove the `Wine` source entry to resolve
9+
# the release key expiration issue for `apt-get update`
10+
&& sed -i '/Wine/d' /etc/apt/sources.list \
1011
&& apt-get update -y \
1112
&& apt-get install -y --no-install-recommends \
1213
p7zip-full \

docs/user-manual.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ First time opening the App or Syncing an account users would need to wait the pr
399399
> - Tools:
400400
> - Export DB
401401
> - Import DB
402+
> - Restore DB
403+
> - Backup DB
402404
> - Remove DB
403405
> - Clear all data
404406
> - Change reports folder
@@ -407,6 +409,7 @@ First time opening the App or Syncing an account users would need to wait the pr
407409
> - Open new GitHub issue
408410
> - Check for update
409411
> - User manual
412+
> - Changelog
410413
> - About
411414
412415
</details>
@@ -418,9 +421,17 @@ First time opening the App or Syncing an account users would need to wait the pr
418421
> - If a user wishes to upgrade between report versions, change the computer or replicate a report on another computer, without syncing their data again, there is an option added to import/export the reports DB.
419422
By pressing the `ALT` key, a menu will pop up on the top with the respective tools relating to do the export/import task.
420423
> - If it becomes necessary to clear all confidential data, it is possible to completely delete the database files using the menu bar item `Tools`->`Remove DB`.
421-
> Also has ability to drop all data except users login information to be able to login using the menu bar item `Tools`->`Clear all data`.
424+
> - Also has ability to drop all data except users login information to be able to login using the menu bar item `Tools`->`Clear all data`.
422425
> After it the app would be launched except exporting case
423426
427+
> In addition to the above, there is an option to restore the DB from previously saved backups:
428+
> - when a new version of the app is published DB structure might be changed
429+
> - in this case, the corresponding DB backup would be saved to keep users data safe
430+
> - if DB migration to a new version has some trouble would restore the previous DB version from the made backups
431+
> - also, available an option into the menu bar to be able to restore DB from the selected backup `Tools`->`Restore DB` and make a new backup file `Tools`->`Backup DB`
432+
> - backups store in the same place where the main DB is placed, in a separated folder `backups/`
433+
> - stores only two last versions of backup files (e.g. `backup_v26_TIMESTAMP.db` and `backup_v25_TIMESTAMP.db`). And not more than two backup files of the last DB version (e.g. `backup_v26_2021-11-05T00-00-00.000Z.db` and `backup_v26_2021-09-05T00-00-00.000Z.db`) for cases when user wants to store more than one backup file for current supported DB schema. Taking into account the previously described, max number of backup files might be three
434+
424435
</details>
425436

426437
<details>

package.json

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
11
{
22
"name": "bfx-report-electron",
3-
"version": "3.6.1",
3+
"version": "3.6.2",
44
"repository": "https://github.com/bitfinexcom/bfx-report-electron",
55
"description": "Reporting tool",
66
"author": "bitfinex.com",
77
"main": "index.js",
88
"license": "Apache-2.0",
99
"dependencies": {
10-
"archiver": "^3.1.1",
11-
"async": "^2.6.1",
10+
"archiver": "5.3.0",
1211
"bfx-svc-test-helper": "git+https://github.com/bitfinexcom/bfx-svc-test-helper.git",
13-
"bittorrent-dht": "^8.4.0",
14-
"clean-stack": "^3.0.1",
15-
"cron-validate": "^1.4.2",
16-
"ed25519-supercop": "^2.0.1",
12+
"bittorrent-dht": "10.0.2",
13+
"changelog-parser": "2.8.0",
14+
"clean-stack": "3.0.1",
15+
"compare-versions": "4.1.1",
16+
"cron-validate": "1.4.3",
17+
"ed25519-supercop": "2.0.1",
1718
"electron-alert": "0.1.13",
18-
"electron-log": "^4.3.2",
19-
"electron-root-path": "^1.0.16",
20-
"electron-serve": "^1.0.0",
19+
"electron-log": "4.4.1",
20+
"electron-root-path": "1.0.16",
21+
"electron-serve": "1.1.0",
2122
"electron-updater": "4.3.8",
22-
"extract-zip": "^2.0.1",
23-
"find-free-port": "^2.0.0",
24-
"github-markdown-css": "^4.0.0",
23+
"extract-zip": "2.0.1",
24+
"find-free-port": "2.0.0",
25+
"github-markdown-css": "4.0.0",
2526
"grenache-grape": "git+https://github.com/bitfinexcom/grenache-grape.git",
26-
"js-yaml": "^4.0.0",
27-
"lodash": "^4.17.15",
28-
"new-github-issue-url": "^0.2.1",
29-
"showdown": "^1.9.1",
30-
"truncate-utf8-bytes": "^1.0.2",
31-
"yauzl": "^2.10.0"
27+
"js-yaml": "4.1.0",
28+
"lodash": "4.17.21",
29+
"new-github-issue-url": "0.2.1",
30+
"showdown": "1.9.1",
31+
"truncate-utf8-bytes": "1.0.2",
32+
"yauzl": "2.10.0"
3233
},
3334
"devDependencies": {
34-
"app-builder-bin": "^3.5.13",
35-
"electron": "13.4.0",
35+
"@mapbox/node-pre-gyp": "1.0.6",
36+
"app-builder-bin": "4.1.0",
37+
"electron": "13.6.3",
3638
"electron-builder": "22.11.7",
3739
"node-gyp": "7.1.2",
38-
"node-pre-gyp": "^0.11.0",
39-
"standard": "^16.0.3"
40+
"standard": "16.0.4"
4041
},
4142
"standard": {
4243
"globals": [

server.js

Lines changed: 65 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22

3+
const { pick } = require('lodash')
34
const { fork } = require('child_process')
45
const path = require('path')
56
const EventEmitter = require('events')
@@ -13,6 +14,13 @@ const pathToConfFacs = path.join(pathToConfDir, 'facs')
1314
const pathToConfFacsGrc = path.join(pathToConfFacs, 'grc.config.json')
1415
const confFacsGrc = require(pathToConfFacsGrc)
1516

17+
const PROCESS_MESSAGES = require(
18+
'./bfx-reports-framework/workers/loc.api/process.message.manager/process.messages'
19+
)
20+
const PROCESS_STATES = require(
21+
'./bfx-reports-framework/workers/loc.api/process.message.manager/process.states'
22+
)
23+
1624
if (!process.env.NODE_ENV) process.env.NODE_ENV = 'production'
1725
process.send = process.send || (() => {})
1826
process.env.NODE_CONFIG_DIR = pathToExpressConfDir
@@ -33,8 +41,59 @@ const {
3341

3442
const emitter = new EventEmitter()
3543

36-
let isMigrationsReady = false
37-
let isMigrationsError = false
44+
const _getAllowedStatesSet = ({
45+
allStates,
46+
availableStates
47+
}) => {
48+
const pickedStates = pick(
49+
allStates,
50+
availableStates
51+
)
52+
53+
return new Set(Object.values(pickedStates))
54+
}
55+
56+
const allowedProcessMessagesSet = _getAllowedStatesSet({
57+
allStates: PROCESS_MESSAGES,
58+
availableStates: [
59+
'ERROR_WORKER',
60+
61+
'READY_MIGRATIONS',
62+
'ERROR_MIGRATIONS',
63+
64+
'ALL_TABLE_HAVE_BEEN_CLEARED',
65+
'ALL_TABLE_HAVE_NOT_BEEN_CLEARED',
66+
67+
'ALL_TABLE_HAVE_BEEN_REMOVED',
68+
'ALL_TABLE_HAVE_NOT_BEEN_REMOVED',
69+
70+
'BACKUP_PROGRESS',
71+
'BACKUP_FINISHED',
72+
'ERROR_BACKUP',
73+
74+
'DB_HAS_BEEN_RESTORED',
75+
'DB_HAS_NOT_BEEN_RESTORED',
76+
77+
'REQUEST_MIGRATION_HAS_FAILED_WHAT_SHOULD_BE_DONE',
78+
'REQUEST_SHOULD_ALL_TABLES_BE_REMOVED',
79+
80+
'RESPONSE_GET_BACKUP_FILES_METADATA'
81+
]
82+
})
83+
const allowedProcessStatesSet = _getAllowedStatesSet({
84+
allStates: PROCESS_STATES,
85+
availableStates: [
86+
'CLEAR_ALL_TABLES',
87+
'REMOVE_ALL_TABLES',
88+
89+
'RESTORE_DB',
90+
'BACKUP_DB',
91+
92+
'RESPONSE_MIGRATION_HAS_FAILED_WHAT_SHOULD_BE_DONE',
93+
94+
'REQUEST_GET_BACKUP_FILES_METADATA'
95+
]
96+
})
3897

3998
;(async () => {
4099
try {
@@ -135,10 +194,7 @@ let isMigrationsError = false
135194
ipc.on('message', (mess) => {
136195
const { state } = { ...mess }
137196

138-
if (
139-
state !== 'all-tables-have-been-cleared' &&
140-
state !== 'all-tables-have-not-been-cleared'
141-
) {
197+
if (!allowedProcessMessagesSet.has(state)) {
142198
return
143199
}
144200

@@ -147,7 +203,7 @@ let isMigrationsError = false
147203
process.on('message', (mess) => {
148204
const { state } = { ...mess }
149205

150-
if (state !== 'clear-all-tables') {
206+
if (!allowedProcessStatesSet.has(state)) {
151207
return
152208
}
153209

@@ -156,18 +212,10 @@ let isMigrationsError = false
156212

157213
const announcePromise = grapes.onAnnounce('rest:report:api')
158214
const ipcReadyPromise = new Promise((resolve, reject) => {
159-
ipc.once('error', reject)
160-
161215
const handlerMess = (mess) => {
162216
const { state } = { ...mess }
163217

164-
if (state === 'error:migrations') {
165-
isMigrationsError = true
166-
}
167-
if (state === 'ready:migrations') {
168-
isMigrationsReady = true
169-
}
170-
if (state !== 'ready:worker') {
218+
if (state !== PROCESS_MESSAGES.READY_WORKER) {
171219
return
172220
}
173221

@@ -217,11 +265,7 @@ emitter.once('ready:grapes-worker', () => {
217265
})
218266

219267
emitter.once('ready:server', () => {
220-
process.send({
221-
state: 'ready:server',
222-
isMigrationsError,
223-
isMigrationsReady
224-
})
268+
process.send({ state: 'ready:server' })
225269
})
226270

227271
module.exports = emitter

src/auto-updater/index.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const {
1818
showLoadingWindow,
1919
hideLoadingWindow
2020
} = require('../change-loading-win-visibility-state')
21+
const {
22+
closeAlert
23+
} = require('../modal-dialog-src/utils')
2124

2225
const fontsStyle = fs.readFileSync(path.join(
2326
__dirname, '../../bfx-report-ui/build/fonts/roboto.css'
@@ -53,16 +56,6 @@ const _sendProgress = (progress) => {
5356
)
5457
}
5558

56-
const _closeToast = (toast) => {
57-
if (
58-
!toast ||
59-
!toast.browserWindow
60-
) return
61-
62-
toast.browserWindow.hide()
63-
toast.browserWindow.destroy()
64-
}
65-
6659
const _fireToast = (
6760
opts = {},
6861
hooks = {}
@@ -72,7 +65,7 @@ const _fireToast = (
7265
onAfterClose = () => {}
7366
} = { ...hooks }
7467

75-
_closeToast(toast)
68+
closeAlert(toast)
7669

7770
const height = 44
7871
const win = wins.mainWindow
@@ -88,7 +81,7 @@ const _fireToast = (
8881
const alert = new Alert([fonts, style, script])
8982
toast = alert
9083

91-
const _closeAlert = () => _closeToast(alert)
84+
const _closeAlert = () => closeAlert(alert)
9285

9386
win.once('closed', _closeAlert)
9487

src/backup-db/index.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict'
2+
3+
const { app } = require('electron')
4+
5+
const ipcs = require('../ipcs')
6+
const isMainWinAvailable = require(
7+
'../helpers/is-main-win-available'
8+
)
9+
10+
const PROCESS_STATES = require(
11+
'../../bfx-reports-framework/workers/loc.api/process.message.manager/process.states'
12+
)
13+
14+
module.exports = () => {
15+
return () => {
16+
try {
17+
if (
18+
!app.isReady() ||
19+
!isMainWinAvailable()
20+
) {
21+
return
22+
}
23+
24+
ipcs.serverIpc.send({ state: PROCESS_STATES.BACKUP_DB })
25+
} catch (err) {
26+
console.error(err)
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)