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

Commit

Permalink
### Version 0.14.0
Browse files Browse the repository at this point in the history
#### Features
- increase height of progress bar
- added upload queue status
- update download/upload queue status whenever file transfers
- show demimals for upload/download progress
#### Fixes
- dbl_dot_local_app video and audio templates
- rename Atoms to Resources in download queue tooltip
- fix eventSource to shutdown after killing dbl_dot_local_app process
- Show files remaining to download in initial download queue status
- try keep (revision 0) bundles sorted in a more stable order

(Merge branch 'v.0.14.0')
  • Loading branch information
ericpyle committed Nov 7, 2018
2 parents 0de01b8 + 1f14f75 commit 0e062ab
Show file tree
Hide file tree
Showing 19 changed files with 269 additions and 190 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
### Version 0.14.0
#### Features
- increase height of progress bar
- added upload queue status
- update download/upload queue status whenever file transfers
- show demimals for upload/download progress
#### Fixes
- dbl_dot_local_app video and audio templates
- rename Atoms to Resources in download queue tooltip
- fix eventSource to shutdown after killing dbl_dot_local_app process
- Show files remaining to download in initial download queue status
- try keep (revision 0) bundles sorted in a more stable order

### Version 0.13.2
- Update dbl_dot_local_app to latest (11-02-2018)
- Skip calculating checksums for files over 250MB
Expand Down
42 changes: 38 additions & 4 deletions app/actions/bundle.actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import throttledQueue from 'throttled-queue';
import { bundleConstants } from '../constants/bundle.constants';
import { bundleService } from '../services/bundle.service';
import { updateSearchResultsForBundleId } from '../actions/bundleFilter.actions';
import { dblDotLocalConfig } from '../constants/dblDotLocal.constants';
import { history } from '../store/configureStore';
import { navigationConstants } from '../constants/navigation.constants';
import { dblDotLocalService } from '../services/dbl_dot_local.service';
Expand Down Expand Up @@ -189,6 +188,11 @@ export function createNewBundle(_medium) {

export function setupBundlesEventSource() {
return (dispatch, getState) => {
const { authentication: { eventSource } } = getState();
if (!eventSource) {
console.error('EventSource undefined');
return;
}
const listeners = {
'storer/execute_task': listenStorerExecuteTaskDownloadResources,
'storer/change_mode': (e) => dispatch(listenStorerChangeMode(e)),
Expand All @@ -197,13 +201,14 @@ export function setupBundlesEventSource() {
'downloader/receiver': listenDownloaderReceiver,
'downloader/spec_status': (e) => dispatch(listenDownloaderSpecStatus(e)),
'downloader/global_status': (e) => dispatch(listenDownloaderGlobalStatus(e)),
'uploader/global_status': (e) => dispatch(listenUploaderGlobalStatus(e)),
'storer/delete_resource': (e) => listenStorerDeleteResource(e, dispatch, getState),
'storer/delete_bundle': (e) => listenStorerDeleteBundle(e, dispatch, getState),
'storer/write_resource': (e) => dispatch(listenStorerWriteResource(e))
};
Object.keys(listeners).forEach((evType) => {
const handler = listeners[evType];
dblDotLocalService.eventSourceStore().addEventListener(evType, handler);
eventSource.addEventListener(evType, handler);
});
};

Expand All @@ -216,6 +221,13 @@ export function setupBundlesEventSource() {
return updateDownloadQueue(nSpecs, nAtoms);
}

/*
* data:{"args": [11], "component": "uploader", "type": "global_status"}
*/
function listenUploaderGlobalStatus() {
return fetchUploadQueueCounts();
}

function listenStorerExecuteTaskDownloadResources() {
// console.log(e);
}
Expand Down Expand Up @@ -272,7 +284,9 @@ export function setupBundlesEventSource() {
const [entryId, jobId, payload] = nextArgs;
const bundleId = uploadJobs[jobId];
const [resourceCountToUpload, resourceCountUploaded] = [payload[0], payload[5]];
return dispatch(updateUploadProgress(bundleId, entryId, jobId, resourceCountUploaded, resourceCountToUpload));
dispatch(updateUploadProgress(bundleId, entryId, jobId, resourceCountUploaded, resourceCountToUpload));
dispatch(fetchUploadQueueCounts());
return;
}
if (type === 'state' || type === 'status') {
const [jobId, payload] = nextArgs;
Expand Down Expand Up @@ -329,6 +343,7 @@ export function setupBundlesEventSource() {
}
dispatch(updateDownloadStatus(bundleId, resourcesDownloaded, resourcesToDownload));
dispatch(updateSearchResultsForBundleId(bundleId));
dispatch(fetchDownloadQueueCounts());
};
}

Expand Down Expand Up @@ -458,19 +473,38 @@ function updateDownloadQueue(nSpecs, nAtoms) {
};
}

function updateUploadQueue(nSpecs, nAtoms) {
return (dispatch) => {
dispatch({ type: bundleConstants.UPDATE_UPLOAD_QUEUE, nSpecs, nAtoms });
};
}

export function fetchDownloadQueueCounts() {
return async dispatch => {
try {
const downloadQueueList = await bundleService.getSubsystemDownloadQueue();
const nSpecs = Object.keys(downloadQueueList).length;
const nAtoms = downloadQueueList.reduce((acc, spec) => acc + spec.n_atoms, 0);
const nAtoms = downloadQueueList.reduce((acc, spec) => acc + (spec.n_atoms - spec.n_downloaded), 0);
return dispatch(updateDownloadQueue(nSpecs, nAtoms));
} catch (error) {
log.error(error);
}
};
}

export function fetchUploadQueueCounts() {
return async dispatch => {
try {
const uploadQueueList = await bundleService.getSubsystemUploadQueue();
const nSpecs = Object.keys(uploadQueueList).length;
const nAtoms = uploadQueueList.reduce((acc, spec) => acc + (spec.n_atoms - spec.n_uploaded), 0);
return dispatch(updateUploadQueue(nSpecs, nAtoms));
} catch (error) {
log.error(error);
}
};
}

function getAddedBundle(getState, bundleId) {
const { bundles } = getState();
const { addedByBundleIds = {} } = bundles;
Expand Down
6 changes: 3 additions & 3 deletions app/actions/user.actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ function login(username, password, _workspaceName) {
return { type: userConstants.LOGIN_FAILURE, error };
}
function connectSSE(authToken) {
return () => {
console.log(`SSE connect to Bundles: ${authToken}`);
dblDotLocalService.eventSourceStore().startEventSource(authToken);
return dispatch => {
const eventSource = dblDotLocalService.startEventSource(authToken);
dispatch({ type: userConstants.SERVER_SENT_EVENTS_SOURCE_CREATED, eventSource });
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/DBLEntryRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ class DBLEntryRow extends PureComponent<Props> {
className="row"
style={{ marginLeft: '20px', marginRight: '20px', paddingBottom: '10px' }}
>
<LinearProgress mode="determinate" value={progress} />
<LinearProgress style={{ height: '8px' }} mode="determinate" value={progress} />
</div>
)}
{isSelected && (
Expand Down
31 changes: 24 additions & 7 deletions app/components/DblDotLocalAppBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,31 @@ import Tooltip from '@material-ui/core/Tooltip';
import Typography from '@material-ui/core/Typography';
import ListIcon from '@material-ui/icons/List';
import ArrowDownwardIcon from '@material-ui/icons/ArrowDownward';
import ArrowUpwardIcon from '@material-ui/icons/ArrowUpward';

import { fetchDownloadQueueCounts } from '../actions/bundle.actions';
import { fetchDownloadQueueCounts, fetchUploadQueueCounts } from '../actions/bundle.actions';

function mapStateToProps(state) {
const { bundlesFilter, bundles } = state;
const { downloadQueue = { nSpecs: 0, nAtoms: 0 } } = bundles;
const {
downloadQueue = { nSpecs: 0, nAtoms: 0 },
uploadQueue = { nSpecs: 0, nAtoms: 0 }
} = bundles;
const { isSearchActive, searchResults } = bundlesFilter;
const entriesMatching = (isSearchActive && searchResults) ? Object.keys(searchResults.bundlesMatching) : [];
const entries = bundles.items;
return {
entries,
entriesMatching,
isSearchActive,
downloadQueue
downloadQueue,
uploadQueue
};
}

const mapDispatchToProps = {
fetchDownloadQueueCounts
fetchDownloadQueueCounts,
fetchUploadQueueCounts
};

type Props = {
Expand All @@ -35,7 +41,9 @@ type Props = {
entriesMatching: [],
isSearchActive: boolean,
downloadQueue: {},
fetchDownloadQueueCounts: () => {}
uploadQueue: {},
fetchDownloadQueueCounts: () => {},
fetchUploadQueueCounts: () => {}
};

const styles = theme => ({
Expand Down Expand Up @@ -65,11 +73,12 @@ class DblDotLocalAppBar extends React.PureComponent {

componentDidMount() {
this.props.fetchDownloadQueueCounts();
this.props.fetchUploadQueueCounts();
}

render() {
const {
classes, entries, entriesMatching, isSearchActive, downloadQueue
classes, entries, entriesMatching, isSearchActive, downloadQueue, uploadQueue
} = this.props;
return (
<AppBar position="sticky" className={classes.appBar}>
Expand All @@ -88,7 +97,15 @@ class DblDotLocalAppBar extends React.PureComponent {
</div>
</Tooltip>
<div className={classes.flex} />
<Tooltip title="Downloads (Entries/Atoms)">
<Tooltip title="Uploads (Entries/Atoms)">
<div className={classes.dblDotLocalBarItem}>
<ArrowUpwardIcon />
<Typography variant="title" color="inherit" className={classes.textSmall}>
{uploadQueue.nSpecs}/{uploadQueue.nAtoms}
</Typography>
</div>
</Tooltip>
<Tooltip title="Downloads (Entries/Resources)">
<div className={classes.dblDotLocalBarItem}>
<ArrowDownwardIcon />
<Typography variant="title" color="inherit" className={classes.textSmall}>
Expand Down
2 changes: 1 addition & 1 deletion app/components/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class LoginForm extends React.Component {
}


async startWaitUntil() {
startWaitUntil = async () => {
await wait.every(3000).and(this.ensureLoadHtmlBaseUrl).until(this.isDblBaseUrlReady);
}

Expand Down
3 changes: 1 addition & 2 deletions app/constants/bundle.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export const bundleConstants = {

UPDATE_UPLOAD_JOBS: 'BUNDLES_UPLOAD_UPDATE_JOBS',

SESSION_EVENTS_CONNECTED: 'BUNDLES_SESSION_EVENTS_CONNECTED',

DOWNLOAD_RESOURCES_REQUEST: 'BUNDLES_DOWNLOAD_RESOURCES_REQUEST',
DOWNLOAD_RESOURCES_UPDATED: 'BUNDLES_DOWNLOAD_RESOURCES_UPDATED',
DOWNLOAD_RESOURCES_FAILURE: 'BUNDLES_DOWNLOAD_RESOURCES_FAILURE',
Expand All @@ -37,6 +35,7 @@ export const bundleConstants = {
REMOVE_RESOURCES_FAILURE: 'BUNDLES_REMOVE_RESOURCES_FAILURE',

UPDATE_DOWNLOAD_QUEUE: 'BUNDLES_UPDATE_DOWNLOAD_QUEUE',
UPDATE_UPLOAD_QUEUE: 'BUNDLES_UPDATE_UPLOAD_QUEUE',

SAVETO_REQUEST: 'BUNDLES_SAVETO_REQUEST',
SAVETO_UPDATED: 'BUNDLES_SAVETO_UPDATED',
Expand Down
2 changes: 2 additions & 0 deletions app/constants/user.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const userConstants = {
DELETE_REQUEST: 'USERS_DELETE_REQUEST',
DELETE_SUCCESS: 'USERS_DELETE_SUCCESS',
DELETE_FAILURE: 'USERS_DELETE_FAILURE',

SERVER_SENT_EVENTS_SOURCE_CREATED: 'USERS_SERVER_SENT_EVENTS_SOURCE_CREATED',
};

export default userConstants;
2 changes: 1 addition & 1 deletion app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nathanael",
"productName": "nathanael",
"version": "0.13.2",
"version": "0.14.0",
"description": "Electron frontend to DBL dot Local",
"main": "./main.prod.js",
"author": {
Expand Down
9 changes: 8 additions & 1 deletion app/reducers/authentication.reducer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { userConstants } from '../constants';

const user = JSON.parse(localStorage.getItem('user'));
const initialState = user ? { loggedIn: true, user } : { loggedIn: false };
const initialState = user ?
{ loggedIn: true, user } : { loggedIn: false };

export function authentication(state = initialState, action) {
switch (action.type) {
Expand Down Expand Up @@ -36,6 +37,12 @@ export function authentication(state = initialState, action) {
loggedOut: true,
error: action.error
};
case userConstants.SERVER_SENT_EVENTS_SOURCE_CREATED: {
return {
...state,
eventSource: action.eventSource
};
}
default:
return state;
}
Expand Down
3 changes: 2 additions & 1 deletion app/reducers/bundleResourceManager.reducer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { bundleResourceManagerConstants } from '../constants/bundleResourceManager.constants';
import { utilities } from '../utils/utilities';

const initialState = {
bundleId: null,
Expand Down Expand Up @@ -51,7 +52,7 @@ export function bundleManageResources(state = initialState, action) {
const filesCompleted = [...filesCompletedPrev, filePath];
const filesDone = filesCompleted.length;
const filesTotal = Object.keys(fileToContainerPaths).length;
const progress = Math.floor((filesDone / filesTotal) * 100);
const progress = utilities.calculatePercentage(filesDone, filesTotal);
const loading = state.loading && filesDone < filesTotal;
return {
...state,
Expand Down
Loading

0 comments on commit 0e062ab

Please sign in to comment.