diff --git a/frontend/src/js/misc/make-arvados-request.js b/frontend/src/js/misc/make-arvados-request.js
index dc12cc0..b9b1e74 100644
--- a/frontend/src/js/misc/make-arvados-request.js
+++ b/frontend/src/js/misc/make-arvados-request.js
@@ -2,6 +2,9 @@
function makeArvadosRequest(arvHost, arvToken, endpoint, method='GET', data=null,
contentType='application/json;charset=utf-8', responseType='json') {
+ if (!arvHost || !arvToken)
+ return new Promise((accept, reject) => reject());
+
let xhr = new XMLHttpRequest();
xhr.open(method, 'https://' + arvHost + endpoint);
xhr.setRequestHeader('Authorization', 'OAuth2 ' + arvToken);
diff --git a/frontend/src/js/page/wb-app.js b/frontend/src/js/page/wb-app.js
index 6afce09..c0674b8 100644
--- a/frontend/src/js/page/wb-app.js
+++ b/frontend/src/js/page/wb-app.js
@@ -1,24 +1,36 @@
import { h, Component } from 'preact';
import { Router, route } from 'preact-router';
-import WBTabs from 'wb-tabs';
-import WBTable from 'wb-table';
-import WBPagination from 'wb-pagination';
-import WBProjectListing from 'wb-project-listing';
-import WBNavbar from 'wb-navbar';
import WBBrowse from 'wb-browse';
import WBSignIn from 'wb-sign-in';
+import WBLandingPage from 'wb-landing-page';
class WBApp extends Component {
- render({}, { activePage }) {
+ constructor(...args) {
+ super(...args);
+ this.state.arvHost = window.localStorage['arvHost'];
+ this.state.arvToken = window.localStorage['arvToken'];
+ this.appCallbacks = {
+ 'navbarItemClicked': this.navbarItemClicked
+ };
+ }
+
+ navbarItemClicked(item) {
+ if (item['id'] === 'sign-out') {
+ delete window.localStorage['arvHost'];
+ delete window.localStorage['arvToken'];
+ delete window.localStorage['currentUser'];
+ route('/sign-in');
+ }
+ }
+
+ render({}, { activePage, arvHost, arvToken }) {
return (
-
- Hello, world!
-
+
-
+
);
}
diff --git a/frontend/src/js/page/wb-browse.js b/frontend/src/js/page/wb-browse.js
index be0cdb3..3ad52c7 100644
--- a/frontend/src/js/page/wb-browse.js
+++ b/frontend/src/js/page/wb-browse.js
@@ -4,15 +4,16 @@ import WBProjectListing from 'wb-project-listing';
import WBInlineSearch from 'wb-inline-search';
class WBBrowse extends Component {
- render({ ownerUuid }) {
+ render({ ownerUuid, appCallbacks }) {
return (
- ) } />
+ ) } onItemClicked={ appCallbacks.navbarItemClicked } />
+
route('/browse/' + xhr.response['uuid']));
+ prom = prom.catch(() => route('/sign-in'));
+ }
+
+ render() {
+ return (
+ Please wait...
+ );
+ }
+}
+
+export default WBLandingPage;
diff --git a/frontend/src/js/page/wb-sign-in.js b/frontend/src/js/page/wb-sign-in.js
index dc1706d..a9ea513 100644
--- a/frontend/src/js/page/wb-sign-in.js
+++ b/frontend/src/js/page/wb-sign-in.js
@@ -1,24 +1,49 @@
import { h, Component } from 'preact';
+import { route } from 'preact-router';
import WBNavbar from 'wb-navbar';
+import linkState from 'linkstate';
+import makeArvadosRequest from 'make-arvados-request';
-class WBLogin extends Component {
- render() {
+class WBSignIn extends Component {
+ onSubmit() {
+ let { arvHost, arvToken } = this.state;
+ window.localStorage['arvHost'] = arvHost;
+ window.localStorage['arvToken'] = arvToken;
+ let prom = makeArvadosRequest(arvHost, arvToken, '/arvados/v1/users/current');
+ prom = prom.then(xhr => {
+ window.localStorage['currentUser'] = JSON.stringify(xhr.response);
+ route('/browse/' + xhr.response['uuid']);
+ });
+ prom = prom.catch(() => {
+ alert('Sign in unsuccessful. Verify your input and try again.')
+ });
+ }
+
+ render({}, { arvHost, arvToken }) {
return (
-
+
+
@@ -28,4 +53,4 @@ class WBLogin extends Component {
}
}
-export default WBLogin;
+export default WBSignIn;
diff --git a/frontend/src/js/widget/wb-navbar.js b/frontend/src/js/widget/wb-navbar.js
index 2ab453c..c5bbef5 100644
--- a/frontend/src/js/widget/wb-navbar.js
+++ b/frontend/src/js/widget/wb-navbar.js
@@ -1,10 +1,10 @@
import { h, Component } from 'preact';
class WBNavbar extends Component {
- render({ title, items, rhs, onItemClicked }) {
+ render({ title, items, rhs, onItemClicked, onTitleClicked }) {
return (
@@ -81,7 +86,8 @@ WBNavbar.defaultProps = {
'title': 'Workbench Advanced',
'items': [],
'form': null,
- 'onItemClicked': () => {}
+ 'onItemClicked': () => {},
+ 'onTitleClicked': () => {}
}
export default WBNavbar;