This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from Siderus/bugfix/157-progress-bar-while-ad…
…ding Shows the activity window when adding a new file
- Loading branch information
Showing
9 changed files
with
356 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React from 'react' | ||
import ProgressBar from '../../../components/ProgressBar' | ||
import styled from 'styled-components' | ||
|
||
const NameAndPath = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
h4 { | ||
margin: 0px; | ||
color: rgb(95,95,95); | ||
} | ||
span { | ||
color: rgb(127,127,127); | ||
} | ||
` | ||
const Progress = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-end; | ||
width: 100%; | ||
div { | ||
margin-top: 20px; | ||
} | ||
span { | ||
color: rgb(95,95,95); | ||
} | ||
` | ||
const ActivityWrapper = styled.div` | ||
margin-top: 5px; | ||
display: flex; | ||
width: 100%; | ||
padding: 5px; | ||
border-radius: 5px; | ||
background-color: rgb(239,239,239); | ||
align-items: center; | ||
.icon { | ||
transform: scale(2.5); | ||
padding: 0 25px; | ||
color: rgb(95,95,95); | ||
} | ||
` | ||
|
||
const Activity = ({ activity }) => { | ||
const finished = activity.progress.bytes === activity.size.bytes | ||
|
||
return ( | ||
<ActivityWrapper> | ||
<span className="icon icon-upload"></span> | ||
<NameAndPath> | ||
<h4>{activity.filename}</h4> | ||
<span>{activity.path}</span> | ||
</NameAndPath> | ||
<Progress> | ||
{ | ||
!finished && <ProgressBar percentage={activity.progress.bytes / activity.size.bytes * 100} /> | ||
} | ||
{ | ||
finished ? <span>{activity.size.value} {activity.size.unit}</span> | ||
: <span>{activity.progress.value} {activity.progress.unit} of {activity.size.value} {activity.size.unit}</span> | ||
} | ||
</Progress> | ||
</ActivityWrapper> | ||
) | ||
} | ||
|
||
export default Activity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<style> | ||
.window-content { | ||
padding: 24px !important; | ||
display: initial !important; | ||
background-color: rgb(236, 236, 236) !important; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="host"></div> | ||
</body> | ||
|
||
<!-- Electron Javascript --> | ||
<script src="loader.js" charset="utf-8"></script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Spinner from 'spin.js' | ||
|
||
var target = document.getElementById('host') | ||
new Spinner().spin(target) | ||
|
||
// After the spinner is rendered, we require the actual component | ||
setTimeout(() => require('./renderer.jsx'), 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react' | ||
import ReactDom from 'react-dom' | ||
import { Window } from 'react-photonkit' | ||
import { ipcRenderer } from 'electron' | ||
import styled from 'styled-components' | ||
import Activity from './Components/Activity' | ||
|
||
const ActivityList = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
overflow-y: auto; | ||
` | ||
|
||
// This will store the loop's timeout ID | ||
window.loopTimeoutID = null | ||
|
||
class ActivitiesWindow extends React.Component { | ||
data = { | ||
activitiesById: [], | ||
activities: {} | ||
} | ||
|
||
componentDidMount () { | ||
ipcRenderer.on('update', (event, data) => { | ||
this.data = data | ||
}) | ||
|
||
ipcRenderer.send('update-activities') | ||
this.startUpdateLoop() | ||
} | ||
|
||
startUpdateLoop = () => { | ||
this.forceUpdate() | ||
// update with 50fps | ||
window.loopTimeoutID = setTimeout(this.startUpdateLoop, 20) | ||
} | ||
|
||
componentWillUnmount () { | ||
ipcRenderer.removeAllListeners('update') | ||
clearTimeout(window.loopTimeoutID) | ||
} | ||
|
||
render () { | ||
const { activities, activitiesById } = this.data | ||
|
||
return ( | ||
<Window> | ||
<ActivityList> | ||
{ | ||
activitiesById.map(id => <Activity key={id} activity={activities[id]} />) | ||
} | ||
</ActivityList> | ||
</Window> | ||
) | ||
} | ||
} | ||
|
||
ReactDom.render(<ActivitiesWindow />, document.querySelector('#host')) |
Oops, something went wrong.