Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

add WIP progress text #268

Merged
merged 5 commits into from
Feb 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions elements/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ const progressbar = css`

min-width: 8rem;
overflow: hidden;
padding-top: .85rem;
padding-bottom: .5rem;
padding-top: .4rem;
.bar {
height: var(--progress-height);
width: calc(100% - var(--counter-width));
Expand Down Expand Up @@ -72,25 +71,49 @@ const progressbar = css`
}
}
`

const progressSubline = css`
:host {
.arrow {
vertical-align: top;
}
}
`

module.exports = function (dat, stats, send) {
if (dat.owner && dat.importer) {
return html`<div>Watching for updates...</div>`
return html`<div>Watching for updates</div>`
}
var progressbarLine = (stats.state === 'loading')
? 'line-loading'
: (stats.state === 'paused')
? 'line-paused'
: 'line-complete'
var netStats = dat.stats.network
var progressText = (stats.progress === 100)
? `Complete. ↑ ${speed(dat.network.uploadSpeed)}`
: (dat.network.connected) ? html`<span><span class="arrow">↓</span> ${speed(netStats.downloadSpeed)}<span class="arrow ml2">↑</span> ${speed(netStats.uploadSpeed)}</span>`
: 'waiting for peers…'
function speed (n) {
return `${n || 0}kB/s`
}

return html`
<div class="${progressbar}">
<div class="counter">
${stats.progress}%
</div>
<div class="bar">
<div class="line ${progressbarLine}" style="width: ${stats.progress}%">
<div>
<div class="${progressbar}">
<div class="counter">
${stats.progress}%
</div>
<div class="bar">
<div class="line ${progressbarLine}" style="width: ${stats.progress}%">
</div>
</div>
</div>
<p class="f7 color-neutral-60 truncate">
<span class="${progressSubline}">
${progressText}
</span>
</p>
</div>
`
}
13 changes: 8 additions & 5 deletions elements/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const icon = require('./icon')
const table = css`
:host {
width: 100%;
tr:odd:hover td {
background: red;
}
th,
td {
padding-right: .75rem;
Expand All @@ -34,7 +37,7 @@ const table = css`
}
td {
height: 4rem;
vertical-align: middle;
vertical-align: top;
padding-top: 1rem;
}
tr:hover td {
Expand Down Expand Up @@ -63,7 +66,7 @@ const table = css`
width: 26vw;
}
.row-action {
height: 2rem;
height: 1.5rem;
display: inline-block;
border: 0;
background: transparent;
Expand Down Expand Up @@ -115,8 +118,8 @@ function tableElement (dats, send) {
<th class="cell-1"></th>
<th class="tl cell-2">Link</th>
<th class="tl cell-3">Status</th>
<th class="tr cell-4">Size</th>
<th class="tr cell-5">Network</th>
<th class="tl cell-4">Size</th>
<th class="tl cell-5">Peers</th>
<th class="cell-6"></th>
</tr>
</thead>
Expand Down Expand Up @@ -214,7 +217,7 @@ function row (dat, send) {
</td>
<td class="cell-2">
<div class="cell-truncate">
<h2 class="normal truncate">
<h2 class="f6 normal truncate">
${title}
</h2>
<p class="f7 color-neutral-60 truncate">
Expand Down
5 changes: 2 additions & 3 deletions lib/auto-updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = ({ log }) => {
autoUpdater.setFeedURL(`http://dat.land:6000/update/${platform}/${version}`)
autoUpdater.on('error', onerror)
autoUpdater.on('checking-for-update', () => log('checking for update'))
autoUpdater.on('update-available', () => log('update available, downloading...'))
autoUpdater.on('update-available', () => log('update available, downloading'))
autoUpdater.on('update-not-available', () => log('update not available'))
autoUpdater.on('download-progress', p => log('download progress ' + p.percent))
autoUpdater.on('update-downloaded', (ev, notes, version) => {
Expand All @@ -27,12 +27,11 @@ module.exports = ({ log }) => {
}, res => {
const update = res === 0
if (!update) return log('dismiss')
log('updating...')
log('updating')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hehe nice!

autoUpdater.quitAndInstall()
})
})

setTimeout(() => autoUpdater.checkForUpdates(), ms('10s'))
setInterval(() => autoUpdater.checkForUpdates(), ms('30m'))
}

2 changes: 1 addition & 1 deletion lib/browserify.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = opts => {
b.transform('sheetify/transform', { use: ['sheetify-nested'] })

const bundle = () => {
process.stderr.write(`${new Date()} bundling...`)
process.stderr.write(`${new Date()} bundling`)

b.bundle().pipe(concat(js => {
fs.writeFile(`${__dirname}/../bundle.js`, js, err => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dat-doctor": "^1.2.2",
"dat-encoding": "^4.0.1",
"dat-icons": "^1.3.0",
"dat-worker": "^5.9.1",
"dat-worker": "^5.10.0",
"electron-auto-updater": "^0.9.2",
"electron-default-menu": "^1.0.0",
"electron-window": "^0.8.1",
Expand Down