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

Incorporated projects page into URL routing.

pull/1/head
parent
commit
5e10d1cfbd
3 changed files with 22 additions and 10 deletions
  1. +16
    -7
      frontend/src/js/component/wb-project-listing.js
  2. +1
    -1
      frontend/src/js/page/wb-app.js
  3. +5
    -2
      frontend/src/js/page/wb-browse.js

+ 16
- 7
frontend/src/js/component/wb-project-listing.js View File

@@ -1,4 +1,5 @@
import { h, Component } from 'preact'; import { h, Component } from 'preact';
import { route } from 'preact-router';
import makeArvadosRequest from 'make-arvados-request'; import makeArvadosRequest from 'make-arvados-request';
import WBTable from 'wb-table'; import WBTable from 'wb-table';
import WBPagination from 'wb-pagination'; import WBPagination from 'wb-pagination';
@@ -9,17 +10,19 @@ class WBProjectListing extends Component {
super(...args); super(...args);
this.state.rows = []; this.state.rows = [];
this.state.numPages = 0; this.state.numPages = 0;
this.state.activePage = 0;
} }
componentDidMount() { componentDidMount() {
this.setActivePage(0);
this.fetchItems();
} }
prepareRows(items) { prepareRows(items) {
return items.map(item => [ return items.map(item => [
(<div> (<div>
<div>{ item['name'] }</div>
<div>
<a href="#"
onclick={ e => { e.preventDefault(); route('/browse/' + item['uuid']) }}>{ item['name'] }</a>
</div>
<div>{ item['uuid'] }</div> <div>{ item['uuid'] }</div>
</div>), </div>),
item['description'], item['description'],
@@ -27,8 +30,8 @@ class WBProjectListing extends Component {
]); ]);
} }
setActivePage(i) {
this.state.activePage = i;
fetchItems() {
let i = this.props.activePage;
let filters = [ let filters = [
[ 'group_class', '=', 'project' ] [ 'group_class', '=', 'project' ]
]; ];
@@ -45,14 +48,20 @@ class WBProjectListing extends Component {
})); }));
} }
render({ arvHost, arvToken, ownerUuid }, { rows, numPages, activePage }) {
componentWillReceiveProps(nextProps, nextState) {
// this.setState({ 'rows': [] }); // .rows = [];
this.props = nextProps;
this.fetchItems();
}
render({ arvHost, arvToken, ownerUuid, activePage, onPageChanged }, { rows, numPages }) {
return ( return (
<div> <div>
<WBTable columns={ [ 'Name', 'Description', 'Owner' ] } <WBTable columns={ [ 'Name', 'Description', 'Owner' ] }
rows={ rows } /> rows={ rows } />
<WBPagination numPages={ numPages } <WBPagination numPages={ numPages }
activePage={ activePage } activePage={ activePage }
onPageChanged={ i => this.setActivePage(i) } />
onPageChanged={ i => onPageChanged(i) } />
</div> </div>
); );
} }


+ 1
- 1
frontend/src/js/page/wb-app.js View File

@@ -30,7 +30,7 @@ class WBApp extends Component {
<WBSignIn path="/sign-in" /> <WBSignIn path="/sign-in" />
<WBBrowse path="/browse/:ownerUuid?" appCallbacks={ this.appCallbacks } />
<WBBrowse path="/browse/:ownerUuid?/:activePage?" appCallbacks={ this.appCallbacks } />
</Router> </Router>
); );
} }


+ 5
- 2
frontend/src/js/page/wb-browse.js View File

@@ -1,10 +1,11 @@
import { h, Component } from 'preact'; import { h, Component } from 'preact';
import { route } from 'preact-router';
import WBNavbar from 'wb-navbar'; import WBNavbar from 'wb-navbar';
import WBProjectListing from 'wb-project-listing'; import WBProjectListing from 'wb-project-listing';
import WBInlineSearch from 'wb-inline-search'; import WBInlineSearch from 'wb-inline-search';
class WBBrowse extends Component { class WBBrowse extends Component {
render({ ownerUuid, appCallbacks }) {
render({ ownerUuid, activePage, appCallbacks }) {
return ( return (
<div> <div>
<WBNavbar items={ [ <WBNavbar items={ [
@@ -17,7 +18,9 @@ class WBBrowse extends Component {
<WBProjectListing arvHost="api.arkau.roche.com" <WBProjectListing arvHost="api.arkau.roche.com"
arvToken="v2/arkau-gj3su-uf4hnu2o2qkvm8j/15kla38mafzq6b31d5t74ynhk6iuy32v1ticslodr0obvvhde9" arvToken="v2/arkau-gj3su-uf4hnu2o2qkvm8j/15kla38mafzq6b31d5t74ynhk6iuy32v1ticslodr0obvvhde9"
ownerUuid={ ownerUuid } ownerUuid={ ownerUuid }
itemsPerPage="5" />
itemsPerPage="5"
activePage={ Number(activePage || 0) }
onPageChanged={ i => route('/browse/' + (ownerUuid || '') + '/' + i)} />
</div> </div>
); );
} }


Loading…
Cancel
Save