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!
Bladeren bron

Correct implementation of fetchSharedWithMe().

pull/1/head
Stanislaw Adaszewski 4 jaren geleden
bovenliggende
commit
e93ef4da96
2 gewijzigde bestanden met toevoegingen van 13 en 65 verwijderingen
  1. +9
    -64
      frontend/src/js/dialog/wb-browse-dialog-project-list.js
  2. +4
    -1
      frontend/src/js/dialog/wb-browse-dialog.js

+ 9
- 64
frontend/src/js/dialog/wb-browse-dialog-project-list.js Bestand weergeven

@@ -34,73 +34,18 @@ class WBBrowseDialogProjectList extends Component {
fetchSharedWithMe() {
const { arvHost, arvToken, currentUser } = this.props.app.state;
/*const filters = [
[ '' ]
];*/
const { textSearch, itemsPerPage, page } = this.props;
const filters = [
[ 'tail_uuid', '=', currentUser.uuid ],
[ 'link_class', '=', 'permission' ],
[ 'head_uuid', 'is_a', 'arvados#group']
['group_class', '=', 'project']
];
let prom = makeArvadosRequest(arvHost, arvToken,
'/arvados/v1/links?filters=' +
encodeURIComponent(JSON.stringify(filters)));
const uuids = {};
prom = prom.then(xhr => {
let prom_1 = new Promise(accept => accept());
const { items_available, limit } = xhr.response;
for (let i = 0; i < items_available; i += limit) {
prom_1 = prom_1.then(() => makeArvadosRequest(arvHost, arvToken,
'/arvados/v1/links?filters=' +
encodeURIComponent(JSON.stringify(filters)) +
'&limit=' + limit +
'&offset=' + i));
prom_1 = prom_1.then(xhr =>
xhr.response.items.map(it => (uuids[it.head_uuid] = true)));
}
return prom_1;
});
prom = prom.then(() => {
const filters_1 = [
['uuid', 'in', Object.keys(uuids)],
['group_class', '=', 'project']
];
return makeArvadosRequest(arvHost, arvToken,
'/arvados/v1/groups?filters=' +
encodeURIComponent(JSON.stringify(filters_1)));
});
let res = [];
prom = prom.then(xhr => {
const filters_1 = [
['uuid', 'in', Object.keys(uuids)],
['group_class', '=', 'project']
];
let prom_1 = new Promise(accept => accept());
const { items_available, limit } = xhr.response;
for (let i = 0; i < items_available; i += limit) {
prom_1 = prom_1.then(() => makeArvadosRequest(arvHost, arvToken,
'/arvados/v1/groups?filters=' +
encodeURIComponent(JSON.stringify(filters_1)) +
'&limit=' + limit +
'&offset=' + i));
prom_1 = prom_1.then(xhr => (res = res.concat(xhr.response.items)));
}
return prom_1;
});
const { page, itemsPerPage } = this.props;
prom = prom.then(() => {
res.sort((a, b) => a.name.localeCompare(b.name));
return {
'response': {
'items': res.slice(page * itemsPerPage,
page * itemsPerPage + itemsPerPage),
'items_available': res.length
}
};
});
if (textSearch)
filters.push([ 'name', 'ilike', '%' + textSearch + '%']);
const prom = makeArvadosRequest(arvHost, arvToken,
'/arvados/v1/groups/shared?filters=' +
encodeURIComponent(JSON.stringify(filters)) +
'&limit=' + itemsPerPage +
'&offset=' + (itemsPerPage * page));
return prom;
// prom = prom.then(xhr => xhr.items.filter(it => (it.group_class === 'project')));
// prom = prom.then(items => )
}
fetchOwned() {


+ 4
- 1
frontend/src/js/dialog/wb-browse-dialog.js Bestand weergeven

@@ -141,7 +141,10 @@ class WBBrowseDialog extends Component {
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="Search"
aria-label="Search" value={ textSearch }
onChange={ linkState(this, 'textSearch') } />
onChange={ e => this.setState({
'textSearch': e.target.value,
'topPage': 0,
'bottomPage': 0}) } />
<div class="input-group-append">
<button class="btn btn-outline-primary" type="button">Search</button>


Laden…
Annuleren
Opslaan