File indexing completed on 2026-12-02 10:29:21
0001 {% extends 'base.html' %}
0002 {% load swf_fmt %}
0003
0004 {% block title %}{{ user.username }}{% endblock %}
0005
0006 {% block content %}
0007 <style>
0008 .user-tabs { margin: 14px 0 .4rem 0; }
0009 .user-tabs a {
0010 border-bottom: 2px solid transparent;
0011 color: #3d85c6;
0012 font-weight: 600;
0013 margin-right: 1.1rem;
0014 padding-bottom: 2px;
0015 text-decoration: none;
0016 }
0017 .user-tabs a.active { border-bottom-color: #3d85c6; color: #111; }
0018 .user-tab-panel {
0019 padding: 14px 0;
0020 }
0021 .my-workflows-table {
0022 border-collapse: collapse;
0023 }
0024 .my-workflows-table th, .my-workflows-table td {
0025 padding: 6px 14px;
0026 border-bottom: 1px solid #ddd;
0027 text-align: left;
0028 white-space: nowrap;
0029 }
0030 .my-workflows-table th {
0031 border-bottom: 2px solid #999;
0032 }
0033 </style>
0034
0035 <div>
0036 <div class="user-tabs">
0037 <a href="?tab=workflows" class="{% if active_tab == 'workflows' %}active{% endif %}">My Workflows</a>
0038 <a href="?tab=account" class="{% if active_tab == 'account' %}active{% endif %}">Account</a>
0039 </div>
0040
0041 {% if active_tab == 'workflows' %}
0042 <div class="user-tab-panel">
0043
0044 <div class="card mb-4">
0045 <div class="card-header"><strong>Time history</strong>
0046 {% if snapper_embed.report_query %}
0047 <a class="ms-3" href="{% url 'snapper_ai:snapper_report' scope=snapper_embed.scope %}?{{ snapper_embed.report_query }}">Open in Snapper</a>
0048 {% endif %}
0049 </div>
0050 <div class="card-body">
0051 {% include 'snapper_ai/_snapper_embed.html' with embed=snapper_embed %}
0052 </div>
0053 </div>
0054 {% if not user.is_authenticated %}
0055 <p>Sign in to see your workflows.</p>
0056 {% else %}
0057 <p>PanDA tasks for username <strong>{{ panda_username }}</strong>, last 30 days.</p>
0058 {% if my_tasks_error %}
0059 <p class="error_fill" style="padding: 6px 10px;">PanDA task lookup failed: {{ my_tasks_error }}</p>
0060 {% elif my_tasks %}
0061 <table class="table table-striped table-bordered table-sm align-middle w-auto swf-sortable">
0062 <thead>
0063 <tr><th>Task</th><th>JEDI ID</th><th>Status</th><th>Label</th><th>Created</th><th>Modified</th></tr>
0064 </thead>
0065 <tbody>
0066 {% for t in my_tasks %}
0067 <tr>
0068 <td><a href="{% url 'monitor_app:panda_task_detail' t.jeditaskid %}">{{ t.taskname }}</a></td>
0069 <td>{{ t.jeditaskid }}</td>
0070 <td class="{{ t.status|state_class }}">{{ t.status }}</td>
0071 <td>{{ t.prodsourcelabel }}</td>
0072 <td>{{ t.creationdate|date:"Y-m-d H:i" }}</td>
0073 <td>{{ t.modificationtime|date:"Y-m-d H:i" }}</td>
0074 </tr>
0075 {% endfor %}
0076 </tbody>
0077 </table>
0078 {% else %}
0079 <p>No PanDA tasks for <strong>{{ panda_username }}</strong> in the last 30 days.</p>
0080 {% endif %}
0081 <p style="margin-top: 14px;">
0082 <a href="{% url 'monitor_app:panda_tasks_list' %}?username={{ panda_username }}">All tasks for {{ panda_username }} in the PanDA tasks view</a>
0083 </p>
0084 {% endif %}
0085 </div>
0086 {% endif %}
0087
0088 {% if active_tab == 'account' %}
0089 <div class="user-tab-panel">
0090 <h3>Account Details</h3>
0091 <p><strong>Username:</strong> {{ user.username }}</p>
0092 <p><strong>Email:</strong> {{ user.email|default:'Not set' }}</p>
0093
0094 <h3 style="margin-top: 24px;">Production access</h3>
0095 <table class="table table-sm w-auto" style="font-size: 1rem;">
0096 <tr><th scope="row" style="padding-right: 1.2rem;">GitHub account</th>
0097 <td>{% if authority.record.github %}<strong>{{ authority.record.github }}</strong>{% else %}none linked{% endif %}</td></tr>
0098 <tr><th scope="row" style="padding-right: 1.2rem;">eic member</th>
0099 <td>{% if authority.record.eic is True %}<strong>yes</strong>{% elif authority.record.eic is False %}<strong>no</strong>{% else %}not recorded{% endif %}{% if authority.record.eic_at %}, checked <span data-relative-time="{{ authority.record.eic_at }}"></span> (on {{ authority.record.eic_at|slice:":10" }}){% endif %}</td></tr>
0100 {% if authority.record.check_failed %}
0101 <tr><th scope="row" style="padding-right: 1.2rem; color: #a4001d;">Last check</th>
0102 <td style="color: #a4001d;"><strong>membership could not be checked</strong>
0103 (<span data-relative-time="{{ authority.record.check_failed_at }}"></span>):
0104 {{ authority.record.check_failed }}. Reading is unaffected; signing out
0105 and in again retries, and operations has been alerted.</td></tr>
0106 {% endif %}
0107 </table>
0108 {% if authority.may_act %}
0109 <p><strong>You may act on the production system.</strong></p>
0110 <p>
0111 {% if authority.record.eic is True %}
0112 Your GitHub account {{ authority.record.github|default:"" }} is a
0113 member of the eic organization.
0114 {% else %}
0115 Your account holds
0116 {{ authority.record.rights|default:"granted" }} rights on this
0117 system.
0118 {% endif %}
0119 </p>
0120 {% else %}
0121 <p><strong>You may read monitoring information. Actions against the
0122 production system are withheld.</strong></p>
0123 {% if authority.record.rights == 'read' %}
0124 <p>Your account is set to read on this system. An administrator can
0125 change that on the User admin page.</p>
0126 {% elif authority.record.eic is False %}
0127 <p>
0128 Your GitHub account {{ authority.record.github|default:"" }} is not a
0129 member of the eic organization. ePIC production monitoring requires
0130 membership for actions against the production system; reading
0131 monitoring information does not. The joining procedure is on the
0132 ePIC Software & Computing
0133 <a href="https://eic.github.io/documentation/getstarted.html"
0134 target="_blank" rel="noopener">Get Started</a> page — see
0135 "Join GitHub". Once you have been added, sign in again and your
0136 account will work.
0137 </p>
0138 {% else %}
0139 <p>
0140 No eic organization membership has been recorded for this account
0141 yet. Membership is checked when you sign in through
0142 epic-devcloud.org. The joining procedure is on the ePIC Software
0143 & Computing
0144 <a href="https://eic.github.io/documentation/getstarted.html"
0145 target="_blank" rel="noopener">Get Started</a> page — see
0146 "Join GitHub".
0147 </p>
0148 {% endif %}
0149 {% endif %}
0150
0151 <h3 style="margin-top: 24px;">Roles</h3>
0152 <p>
0153 <span class="me-3"><input type="checkbox" class="form-check-input" disabled{% if authority.is_ops %} checked{% endif %}> Ops</span>
0154 <span class="me-3"><input type="checkbox" class="form-check-input" disabled{% if authority.is_pac %} checked{% endif %}> PAC</span>
0155 <span class="me-3"><input type="checkbox" class="form-check-input" disabled{% if user.is_staff or user.is_superuser %} checked{% endif %}> Admin</span>
0156 </p>
0157 <p class="text-muted">Ops: act on the production system, administer accounts, set request priorities. PAC: set request priorities, as a physics analysis coordinator. Admin: staff on this system. Roles are granted on the <a href="{% url 'monitor_app:user_admin' %}">User admin</a> page.</p>
0158
0159 <h3 style="margin-top: 24px;">API token</h3>
0160 <p>A token lets a script or a command line use the API as you, for
0161 example to compose PCS draft tasks. Send it as the header
0162 <code>Authorization: Token <key></code> to
0163 <code>https://epic-devcloud.org/prod/pcs/api/</code>, or inside BNL to
0164 <code>https://pandaserver02.sdcc.bnl.gov/swf-monitor/pcs/api/</code>.
0165 Keep it private: anyone holding it acts as you.</p>
0166 <div id="api-token" data-url="{% url 'pcs:my_api_token' %}"
0167 data-may-issue="{% if authority.may_act %}1{% endif %}">
0168 {% csrf_token %}
0169 <p id="api-token-state">
0170 {% if api_token_created %}You have a token, made
0171 <span data-relative-time="{{ api_token_created }}"></span>
0172 (on {{ api_token_created|slice:":10" }}).
0173 {% else %}You have no token.{% endif %}
0174 </p>
0175 <p>
0176 <button type="button" class="btn btn-secondary btn-sm" data-token-action="show"{% if not api_token_created %} hidden{% endif %}>Show token</button>
0177 {% if authority.may_act %}
0178 <button type="button" class="btn btn-primary btn-sm" data-token-action="create"{% if api_token_created %} hidden{% endif %}>Create token</button>
0179 <button type="button" class="btn btn-success btn-sm" data-token-action="regenerate"{% if not api_token_created %} hidden{% endif %}>Regenerate</button>
0180 {% endif %}
0181 <button type="button" class="btn btn-danger btn-sm" data-token-action="revoke"{% if not api_token_created %} hidden{% endif %}>Revoke</button>
0182 </p>
0183 {% if not authority.may_act %}
0184 <p>A token is issued only to an account that may act on the
0185 production system: a token passes writes without the authority
0186 check, so issuing it is the check.</p>
0187 {% endif %}
0188 <p id="api-token-key" hidden><code style="font-size: 1.05rem; user-select: all;"></code></p>
0189 <p id="api-token-error" style="color: #a4001d;" hidden></p>
0190 </div>
0191 <script>
0192 (function () {
0193 const box = document.getElementById('api-token');
0194 const url = box.dataset.url;
0195 const csrf = box.querySelector('[name=csrfmiddlewaretoken]').value;
0196 const keyRow = document.getElementById('api-token-key');
0197 const errRow = document.getElementById('api-token-error');
0198 const stateRow = document.getElementById('api-token-state');
0199 const confirmText = {
0200 regenerate: 'Regenerate your token? The current one stops working at once, in every script that uses it.',
0201 revoke: 'Revoke your token? It stops working at once, in every script that uses it.',
0202 };
0203 function show(state) {
0204 const has = state.has_token;
0205 stateRow.textContent = has
0206 ? 'You have a token, made ' + state.created.slice(0, 10) + '.'
0207 : 'You have no token.';
0208 box.querySelectorAll('[data-token-action]').forEach(function (b) {
0209 const a = b.dataset.tokenAction;
0210 b.hidden = (a === 'create') ? has : !has;
0211 });
0212 if (state.token) {
0213 keyRow.querySelector('code').textContent = state.token;
0214 keyRow.hidden = false;
0215 } else {
0216 keyRow.hidden = true;
0217 }
0218 }
0219 box.addEventListener('click', async function (e) {
0220 const b = e.target.closest('[data-token-action]');
0221 if (!b) return;
0222 const action = b.dataset.tokenAction;
0223 if (confirmText[action] && !confirm(confirmText[action])) return;
0224 errRow.hidden = true;
0225 b.disabled = true;
0226 try {
0227 const r = action === 'show'
0228 ? await fetch(url + '?show=1', { credentials: 'same-origin' })
0229 : await fetch(url, {
0230 method: 'POST', credentials: 'same-origin',
0231 headers: { 'Content-Type': 'application/json', 'X-CSRFToken': csrf },
0232 body: JSON.stringify({ action: action }),
0233 });
0234 const j = await r.json().catch(function () { return {}; });
0235 if (!r.ok) throw new Error(j.error || j.detail || ('request failed, HTTP ' + r.status));
0236 show(j);
0237 } catch (err) {
0238 errRow.textContent = err.message;
0239 errRow.hidden = false;
0240 } finally {
0241 b.disabled = false;
0242 }
0243 });
0244 })();
0245 </script>
0246
0247 <h3 style="margin-top: 24px;">Change Password</h3>
0248 {% if is_tunnel %}
0249 <p><a class="btn btn-primary btn-sm" href="/prod/accounts/password_change/">Change password</a></p>
0250 <p>Password changes here apply to your epic-devcloud.org account only and do not propagate upstream.</p>
0251 {% else %}
0252 {% if messages %}
0253 <ul class="messages">
0254 {% for message in messages %}
0255 <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
0256 {% endfor %}
0257 </ul>
0258 {% endif %}
0259 <form method="post" action="{% url 'monitor_app:account' %}?tab=account">
0260 {% csrf_token %}
0261 {{ form.as_p }}
0262 <button type="submit">Change Password</button>
0263 </form>
0264 {% endif %}
0265 </div>
0266 {% endif %}
0267 </div>
0268 {% endblock %}