IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Browse Source

Started implementing request ordering.

pull/1/head
parent
commit
e6df9e0eb3
2 changed files with 28 additions and 5 deletions
  1. +15
    -3
      frontend/src/js/component/wb-collection-listing.js
  2. +13
    -2
      frontend/src/js/misc/make-arvados-request.js

+ 15
- 3
frontend/src/js/component/wb-collection-listing.js View File

@@ -13,6 +13,7 @@ class WBCollectionListing extends Component {
super(...args); super(...args);
this.state.rows = []; this.state.rows = [];
this.state.numPages = 0; this.state.numPages = 0;
this.state.orderStream = uuid.v4();
} }
componentDidMount() { componentDidMount() {
@@ -65,7 +66,8 @@ class WBCollectionListing extends Component {
let prom = makeArvadosRequest(arvHost, arvToken, let prom = makeArvadosRequest(arvHost, arvToken,
'/arvados/v1/collections?filters=' + encodeURIComponent(JSON.stringify(filters)) + '/arvados/v1/collections?filters=' + encodeURIComponent(JSON.stringify(filters)) +
'&limit=' + encodeURIComponent(itemsPerPage) + '&limit=' + encodeURIComponent(itemsPerPage) +
'&offset=' + encodeURIComponent(itemsPerPage * activePage));
'&offset=' + encodeURIComponent(itemsPerPage * activePage),
{ 'orderStream': this.state.orderStream });
let collections; let collections;
let numPages let numPages
@@ -106,8 +108,14 @@ class WBCollectionListing extends Component {
prom = prom.then(ownerLookup => prom = prom.then(ownerLookup =>
this.setState({ this.setState({
'numPages': numPages, 'numPages': numPages,
'rows': this.prepareRows(collections, ownerLookup)
'rows': this.prepareRows(collections, ownerLookup),
'error': null
})); }));
prom = prom.catch(() => this.setState({
'error': 'An error occured querying the Arvados API',
'rows': []
}));
} }
componentWillReceiveProps(nextProps, nextState) { componentWillReceiveProps(nextProps, nextState) {
@@ -115,9 +123,13 @@ class WBCollectionListing extends Component {
this.fetchItems(); this.fetchItems();
} }
render({ app, ownerUuid, activePage, getPageUrl }, { rows, numPages }) {
render({ app, ownerUuid, activePage, getPageUrl }, { rows, numPages, error }) {
return ( return (
<div> <div>
{ error ? (<div class="alert alert-danger" role="alert">
{ error }
</div>) : null }
<WBTable columns={ [ 'Name', 'Description', 'Owner', 'File Count', 'Total Size', 'Actions' ] } <WBTable columns={ [ 'Name', 'Description', 'Owner', 'File Count', 'Total Size', 'Actions' ] }
rows={ rows } /> rows={ rows } />


+ 13
- 2
frontend/src/js/misc/make-arvados-request.js View File

@@ -1,3 +1,4 @@
const requestOrdering = {};
function makeArvadosRequest(arvHost, arvToken, endpoint, params={}) { function makeArvadosRequest(arvHost, arvToken, endpoint, params={}) {
const defaultParams = { const defaultParams = {
@@ -6,12 +7,22 @@ function makeArvadosRequest(arvHost, arvToken, endpoint, params={}) {
'contentType': 'application/json;charset=utf-8', 'contentType': 'application/json;charset=utf-8',
'responseType': 'json', 'responseType': 'json',
'useSsl': true, 'useSsl': true,
'requireToken': true
'requireToken': true,
'orderStream': null
}; };
Object.keys(defaultParams).map(k => (params[k] = Object.keys(defaultParams).map(k => (params[k] =
(k in params ? params[k] : defaultParams[k]))); (k in params ? params[k] : defaultParams[k])));
let { method, data, contentType, responseType, useSsl, requireToken } = params;
let { method, data, contentType, responseType, useSsl, requireToken, orderStream } = params;
let orderId;
if (orderStream) {
if (!(orderStream in requestOrdering))
requestOrdering[orderStream] = { 'counter': 0, 'started': [], 'completed': [] };
requestOrdering[orderStream].counter += 1;
orderId = requestOrdering[orderStream].counter;
requestOrdering[orderStream].started.push(orderId);
}
if (!(arvHost && (arvToken || !requireToken))) if (!(arvHost && (arvToken || !requireToken)))
return new Promise((accept, reject) => reject()); return new Promise((accept, reject) => reject());


Loading…
Cancel
Save