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()
9 db.migrateNonFederatedSessions()
10 db.autoLoadRemoteHosts()
13 window.SessionsTable = {
14 oninit: function(vnode) {
15 vnode.state.db = new SessionDB()
16 vnode.state.hostToAdd = m.stream('')
17 vnode.state.error = m.stream()
18 vnode.state.checking = m.stream()
20 view: function(vnode) {
21 var db = vnode.state.db
22 var sessions = db.loadAll()
23 return m('.container', [
25 'You can log in to multiple Arvados sites here, then use the ',
26 m('a[href="/search"]', 'multi-site search'),
27 ' page to search collections and projects on all sites at once.',
29 m('table.table.table-condensed.table-hover', [
32 m('th', 'cluster ID'),
39 Object.keys(sessions).map(function(uuidPrefix) {
40 var session = sessions[uuidPrefix]
42 session.token && session.user ? [
43 m('td', session.user.is_active ?
44 m('span.label.label-success', 'logged in') :
45 m('span.label.label-warning', 'inactive')),
46 m('td', {title: session.baseURL}, [
48 href: db.workbenchBaseURL(session) + '?api_token=' + session.token
51 m('td', session.user.username),
52 m('td', session.user.email),
53 m('td', session.isFromRails ? null : m('button.btn.btn-xs.btn-default', {
54 uuidPrefix: uuidPrefix,
55 onclick: m.withAttr('uuidPrefix', db.logout),
56 }, 'Log out ', m('span.glyphicon.glyphicon-log-out'))),
58 m('td', m('span.label.label-default', 'logged out')),
59 m('td', {title: session.baseURL}, uuidPrefix),
62 m('td', m('a.btn.btn-xs.btn-primary', {
63 uuidPrefix: uuidPrefix,
64 onclick: db.login.bind(db, session.baseURL),
65 }, 'Log in ', m('span.glyphicon.glyphicon-log-in'))),
67 m('td', session.isFromRails ? null : m('button.btn.btn-xs.btn-default', {
68 uuidPrefix: uuidPrefix,
69 onclick: m.withAttr('uuidPrefix', db.trash),
70 }, 'Remove ', m('span.glyphicon.glyphicon-trash'))),
75 m('.row', m('.col-md-6', [
77 onsubmit: function() {
78 vnode.state.error(null)
79 vnode.state.checking(true)
80 db.findAPI(vnode.state.hostToAdd())
83 vnode.state.error(true)
85 .then(vnode.state.checking.bind(null, null))
90 'To add a remote Arvados site, paste the remote site\'s host here (see "ARVADOS_API_HOST" on the "current token" page).',
92 m('.input-group', { className: vnode.state.error() && 'has-error' }, [
93 m('input.form-control[type=text][name=apiHost][placeholder="zzzzz.arvadosapi.com"]', {
94 oninput: m.withAttr('value', vnode.state.hostToAdd),
96 m('.input-group-btn', [
97 m('input.btn.btn-primary[type=submit][value="Log in"]', {
98 disabled: !vnode.state.hostToAdd(),
104 vnode.state.error() && m('p.alert.alert-danger', 'Request failed. Make sure this is a working API server address.'),
105 vnode.state.checking() && m('p.alert.alert-info', 'Checking...'),