-
Notifications
You must be signed in to change notification settings - Fork 864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP - Redesign #516
WIP - Redesign #516
Changes from 46 commits
9212def
2aa19c0
7658afd
8597f71
fbd9f14
7c78e20
ff1e5a8
27f61f0
009518c
d3cbd8b
0ca2b88
1faee58
a096ff1
78b1b85
08faf60
92078bf
7b30691
12f9966
f1e53ae
9640025
3ff25b4
43fa89e
0c0cc73
aee2b15
2b12b62
2b1c9a6
e303695
552af06
a66c222
25e25aa
e71c31f
69a4e7a
cce74cb
dbaf577
c216d15
b26a60f
8ffd479
b7e2db6
d2eb903
ea17e3e
dd60b71
cceeaa0
1de62bc
3be8842
26d31c6
eb1710d
232ba2d
ed08abb
12382a0
d14e41e
b7248af
49c13a0
c9ecea0
bedb9bc
6905ed9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
out/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,29 +5,49 @@ import os from 'os' | |
import isDev from 'electron-is-dev' | ||
import {app} from 'electron' | ||
import {getLogo, macOsMenuBar} from './utils/logo' | ||
import FileHistory from './utils/file-history' | ||
|
||
const isProduction = !isDev | ||
const currentURL = (name) => `file://${__dirname}/views/${name}.html` | ||
const ipfsPathFile = path.join(app.getPath('appData'), 'ipfs-electron-app-node-path') | ||
const ipfsAppData = (() => { | ||
const p = path.join(app.getPath('appData'), 'ipfs-station') | ||
|
||
if (!fs.existsSync(p)) { | ||
fs.mkdirSync(p) | ||
} | ||
|
||
return p | ||
})() | ||
|
||
const ipfsPathFile = path.join(ipfsAppData, 'app-node-path') | ||
const ipfsFileHistoryFile = path.join(ipfsAppData, 'file-history.json') | ||
|
||
const ipfsPath = (() => { | ||
let pathIPFS | ||
try { | ||
|
||
if (fs.existsSync(ipfsPathFile)) { | ||
pathIPFS = fs.readFileSync(ipfsPathFile, 'utf-8') | ||
} catch (e) { | ||
} else { | ||
pathIPFS = path.join(process.env.IPFS_PATH || | ||
(process.env.HOME || process.env.USERPROFILE), '.ipfs') | ||
} | ||
|
||
return pathIPFS | ||
})() | ||
|
||
export const fileHistory = new FileHistory(ipfsFileHistoryFile) | ||
|
||
// Sets up the Logger | ||
export const logger = winston.createLogger({ | ||
format: winston.format.json(), | ||
transports: [ | ||
new winston.transports.File({ | ||
filename: path.join(__dirname, 'app.log'), | ||
filename: 'error.log', | ||
level: 'error', | ||
handleExceptions: false | ||
}), | ||
new winston.transports.File({ | ||
filename: 'combined.log', | ||
handleExceptions: false | ||
}) | ||
] | ||
|
@@ -40,22 +60,10 @@ if (isDev) { | |
})) | ||
} | ||
|
||
// Default settings for new windows | ||
const window = { | ||
icon: getLogo(), | ||
title: 'IPFS Dashboard', | ||
autoHideMenuBar: true, | ||
width: 800, | ||
height: 500, | ||
webPreferences: { | ||
webSecurity: false | ||
} | ||
} | ||
|
||
// Configuration for the MenuBar | ||
const menubar = { | ||
dir: __dirname, | ||
width: 300, | ||
width: 850, | ||
height: 400, | ||
index: `file://${__dirname}/views/menubar.html`, | ||
icon: (os.platform() === 'darwin') ? macOsMenuBar : getLogo(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you change this icon on the fly? I believe that you can. I see a dark gray icon because that is the default for MacOS, but before it was changing to the blue one when the node got started. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hacdias this is the culprit for the dark gray IPFS logo on my machine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you try again after I removed the context menu? Cause I think it might be related! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes -- #516 (comment) --, still gray though There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange... I don't know what I might have changed related to that... And I can't really try that out 😮 Could you check that, please? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hacdias you can try it indeed. You also should experience on Windows
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done on 232ba2d |
||
|
@@ -74,10 +82,10 @@ export default { | |
isProduction, | ||
logger, | ||
menubar, | ||
window, | ||
webuiPath: '/webui', | ||
ipfsPath, | ||
ipfsPathFile, | ||
ipfsFileHistoryFile, | ||
urls: { | ||
welcome: currentURL('welcome'), | ||
settings: currentURL('settings') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const PAGES = { | ||
FILES: 'files', | ||
INFO: 'info' | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {dialog} from 'electron' | ||
import uploadFiles from './upload-files' | ||
|
||
export default function openFileDialog (window, ipfs, dir = false) { | ||
return (event, callback) => { | ||
dialog.showOpenDialog(window, { | ||
properties: [dir ? 'openDirectory' : 'openFile', 'multiSelections'] | ||
}, (files) => { | ||
if (!files || files.length === 0) return | ||
uploadFiles(ipfs, event, files) | ||
}) | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {shell} from 'electron' | ||
import {apiAddrToUrl} from './utils' | ||
import {logger} from '../config' | ||
|
||
export default function openWebUI (ipfs, cb) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, always please use |
||
ipfs().config.get('Addresses.API') | ||
.then((res) => { | ||
shell.openExternal(apiAddrToUrl(res)) | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick, you can reduce this to just one line: |
||
.catch(logger.error) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {logger, fileHistory} from '../config' | ||
import {clipboard} from 'electron' | ||
|
||
export default function uploadFiles (ipfs, event, files) { | ||
ipfs() | ||
.add(files, {recursive: true, w: files.length > 1}) | ||
.then((res) => { | ||
logger.info('Uploading files', {files}) | ||
|
||
res.forEach((file) => { | ||
const url = `https://ipfs.io/ipfs/${file.hash}` | ||
clipboard.writeText(url) | ||
logger.info('Uploaded file', {path: file.path}) | ||
fileHistory.add(file.path, file.hash) | ||
}) | ||
}) | ||
.catch(logger.error) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should use fs.existsSync instead of trying to catch for errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done :)