1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 $(document).on('ready', function() {
6 var db = new SessionDB()
11 window.SessionsTable = {
12 oninit: function(vnode) {
13 vnode.state.db = new SessionDB()
14 vnode.state.hostToAdd = m.stream('')
15 vnode.state.error = m.stream()
16 vnode.state.checking = m.stream()
18 view: function(vnode) {
19 var db = vnode.state.db
20 var sessions = db.loadAll()
21 return m('.container', [
23 'You can log in to multiple Arvados sites here, then use the ',
24 m('a[href="/search"]', 'multi-site search'),
25 ' page to search collections and projects on all sites at once.',
27 m('table.table.table-condensed.table-hover', [
30 m('th', 'cluster ID'),
37 Object.keys(sessions).map(function(uuidPrefix) {
38 var session = sessions[uuidPrefix]
40 session.token && session.user ? [
41 m('td', m('span.label.label-success', 'logged in')),
42 m('td', {title: session.baseURL}, uuidPrefix),
43 m('td', session.user.username),
44 m('td', session.user.email),
45 m('td', session.isFromRails ? null : m('button.btn.btn-xs.btn-default', {
46 uuidPrefix: uuidPrefix,
47 onclick: m.withAttr('uuidPrefix', db.logout),
48 }, 'Log out ', m('span.glyphicon.glyphicon-log-out'))),
50 m('td', m('span.label.label-default', 'logged out')),
51 m('td', {title: session.baseURL}, uuidPrefix),
54 m('td', m('a.btn.btn-xs.btn-primary', {
55 uuidPrefix: uuidPrefix,
56 onclick: db.login.bind(db, session.baseURL),
57 }, 'Log in ', m('span.glyphicon.glyphicon-log-in'))),
59 m('td', session.isFromRails ? null : m('button.btn.btn-xs.btn-default', {
60 uuidPrefix: uuidPrefix,
61 onclick: m.withAttr('uuidPrefix', db.trash),
62 }, 'Remove ', m('span.glyphicon.glyphicon-trash'))),
67 m('.row', m('.col-md-6', [
69 onsubmit: function() {
70 vnode.state.error(null)
71 vnode.state.checking(true)
72 db.findAPI(vnode.state.hostToAdd())
75 vnode.state.error(true)
77 .then(vnode.state.checking.bind(null, null))
82 'To add a remote Arvados site, paste the remote site\'s host here (see "ARVADOS_API_HOST" on the "current token" page).',
84 m('.input-group', { className: vnode.state.error() && 'has-error' }, [
85 m('input.form-control[type=text][name=apiHost][placeholder="zzzzz.arvadosapi.com"]', {
86 oninput: m.withAttr('value', vnode.state.hostToAdd),
88 m('.input-group-btn', [
89 m('input.btn.btn-primary[type=submit][value="Log in"]', {
90 disabled: !vnode.state.hostToAdd(),
96 vnode.state.error() && m('p.alert.alert-danger', 'Request failed. Make sure this is a working API server address.'),
97 vnode.state.checking() && m('p.alert.alert-info', 'Checking...'),