[ARVADOS] updated: 830f90c04ab99c2749013bc83a5c679f952ab677
Git user
git at public.curoverse.com
Mon Sep 26 00:58:17 EDT 2016
Summary of changes:
apps/wb2/app.js | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++---
apps/wb2/arvados.js | 5 ++++
2 files changed, 77 insertions(+), 3 deletions(-)
discards 14d3187a2b5475baaff4123829b018629490e0bd (commit)
discards 5c7e073f800bb0933737fdd5dd19f069bcb054b7 (commit)
via 830f90c04ab99c2749013bc83a5c679f952ab677 (commit)
via b6fead1b4afdde54f8462cc46fe9d90c690ba808 (commit)
via 62fff2e19e11a74bc1c7f034a7f30c336f11113c (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (14d3187a2b5475baaff4123829b018629490e0bd)
\
N -- N -- N (830f90c04ab99c2749013bc83a5c679f952ab677)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 830f90c04ab99c2749013bc83a5c679f952ab677
Author: Tom Clegg <tom at curoverse.com>
Date: Mon Sep 26 00:58:12 2016 -0400
9668: Login
diff --git a/apps/wb2/app.js b/apps/wb2/app.js
index 5431008..ca5f0a1 100644
--- a/apps/wb2/app.js
+++ b/apps/wb2/app.js
@@ -16,11 +16,43 @@ function getSession(siteID) {
url: client.DiscoveryURL(),
}),
websocket: m.prop(),
+ token: loadToken(siteID),
};
}
return session;
}
+function ArvadosRequest(session, method, url) {
+ return session.dd.run(function() {
+ return m.request({
+ method: method,
+ url: session.dd().baseUrl + url,
+ config: function(xhr) {
+ xhr.setRequestHeader('Authorization', 'OAuth2 '+session.token);
+ return xhr;
+ },
+ });
+ });
+}
+
+function saveToken(siteID, token) {
+ var tokens = {};
+ try {
+ tokens = JSON.parse(window.localStorage.tokens);
+ } catch(e) {}
+ tokens[siteID] = token;
+ window.localStorage.tokens = JSON.stringify(tokens);
+ getSession(siteID).token = token;
+}
+
+function loadToken(siteID) {
+ try {
+ return JSON.parse(window.localStorage.tokens)[siteID];
+ } catch(e) {
+ return undefined;
+ }
+}
+
// getDiscoveryDoc returns a stream resolving to the discovery
// document for the Arvados API endpoint specified by siteID.
function getDiscoveryDoc(siteID) {
@@ -42,6 +74,11 @@ var ErrorTODO = {
var DiscoveryDoc = {
oninit: function(vnode) {
vnode.state.dd = getDiscoveryDoc(vnode.attrs.siteID);
+ var session = getSession(vnode.attrs.siteID);
+ if (session.token)
+ vnode.state.current_user = ArvadosRequest(session, 'GET', 'users/current');
+ else
+ vnode.state.current_user = m.prop();
},
view: function(vnode) {
var dd = vnode.state.dd;
@@ -52,6 +89,13 @@ var DiscoveryDoc = {
m('.row', ['version: ', dd().source_version]),
m('.row', ['websocketUrl: ', dd().websocketUrl]),
m('.row', ['defaultCollectionReplication: ', dd().defaultCollectionReplication]),
+ vnode.state.current_user ? m('.row', [
+ 'current user: ',
+ vnode.state.current_user().full_name,
+ ' (', vnode.state.current_user().username,
+ ', ', vnode.state.current_user().email,
+ ')',
+ ]) : [],
]);
},
};
@@ -65,9 +109,33 @@ var Show = {
},
};
+var TopNav = {
+ view: function(vnode) {
+ return Object.keys(_sessions).map(function(siteID) {
+ return [m('a', {
+ href: getSession(siteID).client.LoginURL(location.href.replace(/([^\/]*\/+[^\/]+[#!?\/]*)/, '$1loginCallback/'+siteID+'/XYZZY/')),
+ }, 'Login:', siteID), m.trust(' • ')];
+ });
+ },
+};
+
var Layout = {
view: function(vnode) {
- return m('.layout', vnode.children);
+ return m('.layout', m(TopNav), vnode.children);
+ },
+};
+
+var TryLogin = {
+ view: function(vnode) {
+ var token;
+ if (token = location.href.match(/(\?api_token=([^\?&]+))/)) {
+ location = location.href.replace(token[1], '').replace('XYZZY', token[2]);
+ } else if (token = vnode.attrs.token) {
+ saveToken(vnode.attrs.siteID, token);
+ m.route.set('/'+vnode.attrs.next);
+ } else {
+ m.route.set('/site/4xphq/discovery');
+ }
},
};
@@ -85,8 +153,9 @@ function RouteResolver(layout, component, withKey) {
(function SetupRouting() {
var RR = RouteResolver;
var routes = {
- '/': Show,
+ '/': TryLogin,
'/site/:siteID/discovery': RR(Layout, DiscoveryDoc, 'siteID'),
+ '/loginCallback/:siteID/:token/:next...': TryLogin,
};
['collections', 'containers'].map(function(table) {
routes['/site/:siteID/'+table+'/:uuid'] = RR(Layout, Show, 'uuid');
diff --git a/apps/wb2/arvados.js b/apps/wb2/arvados.js
index 308aabc..acfe14c 100644
--- a/apps/wb2/arvados.js
+++ b/apps/wb2/arvados.js
@@ -6,3 +6,8 @@ function Client(UUIDPrefix) {
Client.prototype.DiscoveryURL = function() {
return 'https://' + this.UUIDPrefix + '.arvadosapi.com/discovery/v1/apis/arvados/v1/rest';
}
+
+Client.prototype.LoginURL = function(callbackURL) {
+ return 'https://' + this.UUIDPrefix + '.arvadosapi.com/login?return_to=' +
+ encodeURIComponent(callbackURL);
+}
commit b6fead1b4afdde54f8462cc46fe9d90c690ba808
Author: Tom Clegg <tom at curoverse.com>
Date: Sun Sep 25 14:37:18 2016 -0400
9668: WIP
diff --git a/apps/wb2/app.js b/apps/wb2/app.js
index 72d13db..5431008 100644
--- a/apps/wb2/app.js
+++ b/apps/wb2/app.js
@@ -66,26 +66,30 @@ var Show = {
};
var Layout = {
- RouteResolver: function(component, withKey) {
- return {
- render: function(vnode) {
- return m(Layout, m(component,
- Object.assign({
- key: vnode.attrs[withKey],
- }, vnode.attrs)));
- },
- };
- },
view: function(vnode) {
return m('.layout', vnode.children);
},
};
-var routes = {
- '/': Show,
- '/site/:siteID/discovery': Layout.RouteResolver(DiscoveryDoc, 'siteID'),
-};
-['collections', 'containers'].map(function(table) {
- routes['/site/:siteID/'+table+'/:uuid'] = Layout.RouteResolver(Show, 'uuid');
-});
-m.route(document.body, '/', routes);
+function RouteResolver(layout, component, withKey) {
+ return {
+ render: function(vnode) {
+ return m(layout, m(component,
+ Object.assign({
+ key: withKey + ':' + vnode.attrs[withKey],
+ }, vnode.attrs)));
+ },
+ };
+}
+
+(function SetupRouting() {
+ var RR = RouteResolver;
+ var routes = {
+ '/': Show,
+ '/site/:siteID/discovery': RR(Layout, DiscoveryDoc, 'siteID'),
+ };
+ ['collections', 'containers'].map(function(table) {
+ routes['/site/:siteID/'+table+'/:uuid'] = RR(Layout, Show, 'uuid');
+ });
+ m.route(document.body, '/', routes);
+})();
commit 62fff2e19e11a74bc1c7f034a7f30c336f11113c
Author: Tom Clegg <tom at curoverse.com>
Date: Sat Sep 24 20:56:15 2016 -0400
9668: WIP
diff --git a/apps/wb2/app.js b/apps/wb2/app.js
index 794c86d..72d13db 100644
--- a/apps/wb2/app.js
+++ b/apps/wb2/app.js
@@ -1,34 +1,52 @@
var m = require('mithril');
-//var arvados = require('./arvados');
+var arvados = require('./arvados');
-var KnownSites = {
- '4xphq': '4xphq.arvadosapi.com',
-};
+var _sessions = {};
+
+// getSession returns a new or existing session for the API endpoint
+// specified by siteID.
+function getSession(siteID) {
+ var session = _sessions[siteID];
+ if (!session) {
+ var client = new arvados.Client(siteID);
+ session = _sessions[siteID] = {
+ client: client,
+ dd: m.request({
+ method: 'GET',
+ url: client.DiscoveryURL(),
+ }),
+ websocket: m.prop(),
+ };
+ }
+ return session;
+}
-var ddLoaded = {};
-function ddLoad(siteID) {
- var dd = ddLoaded[siteID];
- if (!dd) dd = ddLoaded[siteID] = m.prop();
- else if (dd()) return dd;
- m.request({
- method: 'GET',
- url: 'https://'+siteID+'.arvadosapi.com/discovery/v1/apis/arvados/v1/rest',
- }).run(dd);
- return dd;
+// getDiscoveryDoc returns a stream resolving to the discovery
+// document for the Arvados API endpoint specified by siteID.
+function getDiscoveryDoc(siteID) {
+ return getSession(siteID).dd;
}
var Loading = {
- oninit: function(vnode) {
- },
view: function() {
return m('.loading', 'Loading...');
},
};
+var ErrorTODO = {
+ view: function(vnode) {
+ return m('.errorTODO', 'Error loading: ', vnode.children)
+ },
+};
+
var DiscoveryDoc = {
+ oninit: function(vnode) {
+ vnode.state.dd = getDiscoveryDoc(vnode.attrs.siteID);
+ },
view: function(vnode) {
- var dd = ddLoad(vnode.attrs.siteID);
- if (!dd()) return m(Loading);
+ var dd = vnode.state.dd;
+ if (dd.error()) return m(ErrorTODO, dd.error());
+ else if (!dd()) return m(Loading);
return m('.dd', [
m('.row', ['site ID: ', vnode.attrs.siteID]),
m('.row', ['version: ', dd().source_version]),
@@ -40,17 +58,21 @@ var DiscoveryDoc = {
var Show = {
view: function(vnode) {
- var dd = ddLoad(vnode.attrs.siteID);
- if (!dd()) return m(Loading);
+ var dd = getDiscoveryDoc(vnode.attrs.siteID);
+ if (dd.error()) return m(ErrorTODO, dd.error());
+ else if (!dd()) return m(Loading);
return m('.show', 'It\'s a collection from ', vnode.attrs.siteID);
},
};
var Layout = {
- RouteResolver: function(component) {
+ RouteResolver: function(component, withKey) {
return {
render: function(vnode) {
- return m(Layout, m(component, vnode.attrs));
+ return m(Layout, m(component,
+ Object.assign({
+ key: vnode.attrs[withKey],
+ }, vnode.attrs)));
},
};
},
@@ -61,9 +83,9 @@ var Layout = {
var routes = {
'/': Show,
- '/site/:siteID/discovery': Layout.RouteResolver(DiscoveryDoc),
+ '/site/:siteID/discovery': Layout.RouteResolver(DiscoveryDoc, 'siteID'),
};
['collections', 'containers'].map(function(table) {
- routes['/site/:siteID/'+table+'/:uuid'] = Layout.RouteResolver(Show);
+ routes['/site/:siteID/'+table+'/:uuid'] = Layout.RouteResolver(Show, 'uuid');
});
m.route(document.body, '/', routes);
diff --git a/apps/wb2/arvados.js b/apps/wb2/arvados.js
new file mode 100644
index 0000000..308aabc
--- /dev/null
+++ b/apps/wb2/arvados.js
@@ -0,0 +1,8 @@
+module.exports.Client = Client;
+function Client(UUIDPrefix) {
+ this.UUIDPrefix = UUIDPrefix;
+}
+
+Client.prototype.DiscoveryURL = function() {
+ return 'https://' + this.UUIDPrefix + '.arvadosapi.com/discovery/v1/apis/arvados/v1/rest';
+}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list