Skip to content

Commit

Permalink
Merge pull request #107 from bitfinexcom/beta
Browse files Browse the repository at this point in the history
Release version 3.5.3
  • Loading branch information
ezewer authored Aug 24, 2021
2 parents 1179a00 + 56466d9 commit 1d197b7
Show file tree
Hide file tree
Showing 9 changed files with 702 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bfx-reports-framework
471 changes: 471 additions & 0 deletions docs/user-manual.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bfx-report-electron",
"version": "3.5.2",
"version": "3.5.3",
"repository": "https://github.com/bitfinexcom/bfx-report-electron",
"description": "Reporting tool",
"author": "bitfinex.com",
Expand Down Expand Up @@ -32,7 +32,7 @@
},
"devDependencies": {
"app-builder-bin": "^3.5.13",
"electron": "13.1.7",
"electron": "13.1.9",
"electron-builder": "22.11.7",
"node-gyp": "7.1.2",
"node-pre-gyp": "^0.11.0",
Expand Down
8 changes: 7 additions & 1 deletion src/create-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const {
quitAndInstall
} = require('./auto-updater')
const { manageNewGithubIssue } = require('./error-manager')
const showDocs = require('./show-docs')

module.exports = ({
pathToUserData,
Expand Down Expand Up @@ -126,8 +127,13 @@ module.exports = ({
},
{ type: 'separator' },
{
label: 'About',
label: 'User manual',
accelerator: 'CmdOrCtrl+H',
click: showDocs
},
{ type: 'separator' },
{
label: 'About',
click: showAboutModalDialog()
}
]
Expand Down
6 changes: 6 additions & 0 deletions src/error-manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ const initLogger = () => {
if (message.level === 'error') {
const error = message.data.join(os.EOL)

// Don't open a new issue when can't download differentially
// it would fallback to full download
if (/Cannot download differentially/gi.test(error)) {
return message
}

_manageErrorLogLevel(error)
}

Expand Down
9 changes: 8 additions & 1 deletion src/errors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ class SyncFrequencyChangingError extends BaseError {
}
}

class UserManualShowingError extends BaseError {
constructor (message = 'ERR_USER_MANUAL_HAS_NOT_SHOWN') {
super(message)
}
}

module.exports = {
BaseError,
InvalidFilePathError,
Expand All @@ -110,5 +116,6 @@ module.exports = {
WrongPathToUserCsvError,
WrongSecretKeyError,
ReportsFolderChangingError,
SyncFrequencyChangingError
SyncFrequencyChangingError,
UserManualShowingError
}
19 changes: 17 additions & 2 deletions src/modal-dialog-src/modal-dialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ body::-webkit-scrollbar-thumb,
}

.markdown-body {
background-color: #102331; /* #102331 / #172d3e */
background-color: #102331;
padding: 16px 16px 0;
}

Expand Down Expand Up @@ -90,14 +90,29 @@ body::-webkit-scrollbar-thumb,

.markdown-body details,
.markdown-body pre,
.markdown-body p {
.markdown-body p,
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
text-align: left;
}

.markdown-body hr {
background-color: rgba(255,255,255,0.1);
}

.markdown-body h1,
.markdown-body h2 {
border-bottom: 1px solid #19354a;
}

.markdown-body blockquote {
border-left: .25em solid #19354a;
}

.rangeInput {
display: flex;
align-items: center;
Expand Down
189 changes: 189 additions & 0 deletions src/show-docs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
'use strict'

const { app, screen, remote } = require('electron')
const fs = require('fs')
const path = require('path')
const { Converter } = require('showdown')
const Alert = require('electron-alert')
const { rootPath } = require('electron-root-path')

const wins = require('../windows')
const { UserManualShowingError } = require('../errors')

const mdUserManual = fs.readFileSync(
path.join(rootPath, 'docs/user-manual.md'),
'utf8'
)

const mdStyle = fs.readFileSync(path.join(
rootPath, 'node_modules', 'github-markdown-css/github-markdown.css'
))
const fontsStyle = fs.readFileSync(path.join(
rootPath, 'bfx-report-ui/build/fonts/roboto.css'
))
const alertStyle = fs.readFileSync(path.join(
__dirname, '../modal-dialog-src/modal-dialog.css'
))
const alertScript = fs.readFileSync(path.join(
__dirname, '../modal-dialog-src/modal-dialog.js'
))

const fonts = `<style>${fontsStyle}</style>`
const mdS = `<style>${mdStyle}</style>`
const style = `<style>${alertStyle}</style>`
const script = `<script type="text/javascript">${alertScript}</script>`
const sound = { freq: 'F2', type: 'triange', duration: 1.5 }

const converter = new Converter({
tables: true,
strikethrough: true,
tasklists: true,
disableForced4SpacesIndentedSublists: true,
requireSpaceBeforeHeadingText: true
})

const _isMainWinAvailable = () => {
return (
wins.mainWindow &&
typeof wins.mainWindow === 'object' &&
!wins.mainWindow.isDestroyed()
)
}

const _closeAlert = (alert) => {
if (
!alert ||
!alert.browserWindow
) return

alert.browserWindow.hide()
alert.browserWindow.close()
}

const _fireAlert = (params) => {
const {
title = 'User manual',
html
} = params
const win = wins.mainWindow

if (!_isMainWinAvailable()) {
return { value: false }
}

const _screen = screen || remote.screen
const {
getCursorScreenPoint,
getDisplayNearestPoint
} = _screen
const {
workArea
} = getDisplayNearestPoint(getCursorScreenPoint())
const { height: screenHeight } = workArea
const maxHeight = Math.floor(screenHeight * 0.90)

const alert = new Alert([mdS, fonts, style, script])
const _close = () => _closeAlert(alert)

win.once('closed', _close)

const bwOptions = {
frame: false,
transparent: false,
thickFrame: false,
closable: false,
hasShadow: false,
backgroundColor: '#172d3e',
darkTheme: false,
parent: win,
modal: true,
width: 1000,
webPreferences: {
contextIsolation: false
}
}
const swalOptions = {
position: 'center',
allowOutsideClick: false,
backdrop: 'rgba(0,0,0,0.0)',
customClass: {
content: 'markdown-body'
},

type: 'info',
title,
html,
showConfirmButton: false,
focusCancel: true,
showCancelButton: true,
cancelButtonText: 'Cancel',
timerProgressBar: false,

onBeforeOpen: () => {
if (
!alert ||
!alert.browserWindow
) return

alert.browserWindow.hide()
},
onOpen: () => {
if (
!alert ||
!alert.browserWindow
) return

alert.browserWindow.show()
const { height } = alert.browserWindow
.getContentBounds()
alert.browserWindow.setBounds({
height: height > maxHeight
? maxHeight
: height
})
},
onClose: () => {
if (
!alert ||
!alert.browserWindow
) return

alert.browserWindow.hide()
},
onAfterClose: () => {
win.removeListener('closed', _close)
}
}

const res = alert.fire(
swalOptions,
bwOptions,
null,
true,
false,
sound
)

return res
}

module.exports = async (params = {}) => {
try {
const {
mdDoc = mdUserManual
} = params

if (
!app.isReady() ||
!_isMainWinAvailable()
) {
throw new UserManualShowingError()
}

const html = converter.makeHtml(mdDoc)

await _fireAlert({ html })
} catch (err) {
console.error(err)
}
}

0 comments on commit 1d197b7

Please sign in to comment.