dpc-web/app/views/portal/_assigned_content.html.erb
<p class="ds-text--lead ds-u-measure--wide ds-u-margin-top--2">
Welcome to the Data at the Point of Care Sandbox. You have been assigned to the organizations below to start using the APIs in a synthetic, or test, sandbox. <strong>Remember</strong>, do NOT add any real patient information to the sandbox environment.
</p>
<div class="ds-l-row--12">
<% @user.organizations.each do |organization| %>
<div class="portal-section-header">
<div>
<div>
<h2 class="portal-section-heading ds-u-font-size--h1"><%= organization.name %></h2>
</div>
<div>
<% if organization.reg_org.present? && organization.reg_org.enabled == true %>
<strong>ID:</strong> <%= organization.registered_organization.api_id %>
<% end %>
</div>
</div>
<% if organization.prod_sbx? %>
<div>
<div>
<span class="ds-u-color--muted"><strong>NPI:</strong> (auto-generated) <%= organization.npi %></span>
</div>
</div>
<% else %>
<div>
<div>
<strong>NPI:</strong> <%= npi_text(organization) %> | <strong>Vendor(s):</strong> <%= vendor_text(organization) %>
</div>
</div>
<%= link_to "Edit", edit_organization_url(organization), class: "ds-c-button ds-c-button--outline ds-c-button--small", data: { test: "edit-link" } %>
<%end %>
</div>
<% if organization.reg_org.present? && organization.reg_org.enabled == true %>
<section class="box">
<div class="box__content">
<div class="box__header">
<h3 class="box__heading">Client tokens</h3>
<div class="box__header__actions">
<%= link_to new_organization_client_token_path(organization_id: organization.id), class: "ds-c-button ds-c-button--primary", data: { test: "new-client-token" } do %>
<svg class="icon ds-u-margin-right--1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<use xlink:href="/assets/solid.svg#plus"></use>
</svg>
New token
<% end %>
</div>
</div>
<% if organization.reg_org.client_tokens.count != 0 %>
<table class="usa-table" data-toggle="table" id="client-token-table">
<caption aria-hidden="true" hidden>Client Token Table</caption>
<div class="ds-l-col--12">
<thead>
<tr>
<th data-sortable="true" scope="col" role="columnheader">
Token Name
</th>
<th data-sortable="true" scope="col" role="columnheader" aria-sort="descending">
Creation Date
</th>
<th data-sortable="true" scope="col" role="columnheader">
Expiration Date
</th>
<th>Actions</th>
</tr>
</thead>
</div>
<tbody style="width: 100%">
<% @client_tokens.each_with_index do |token, index| %>
<tr class="credentials">
<%= tag.td data: { sortable_value: token['label']} do %>
<h3 class="credential__name">
<%= token['label'] %>
</h3>
<% end %>
<%= tag.td data: {sortable_value: token['createdAt']} do %>
Created: <%= formatted_datestr(token['createdAt']) %>
<% end %>
<%= tag.td data: {sortable_value: token['expiresAt']} do %>
Expires: <%= formatted_datestr(token['expiresAt']) %>
<% end %>
<td data-sortable="false">
<div class="usa-accordion">
<button id="button<%= index +1 %>" class="usa-accordion__button credential__delete_button" aria-expanded="false" aria-controls="collapse<%= index +1 %>">
X
</button>
<div id="collapse<%= index +1 %>" class="credential__btn_container usa-accordion__content" hidden>
<div class="credential__text">
Delete Client Token?
</div>
<div class="credential__actions">
<button class="credential__cancel_btn" onclick="collapseButtons('button<%= index +1 %>', 'collapse<%= index +1 %>')">
Cancel
</button>
<%= button_to "Delete Token", organization_client_token_path(id: token['id'], organization_id: organization.id), method: :delete, class: "ds-c-button ds-c-button--danger ds-u-float--right" %>
</div>
</div>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
<div
class="usa-sr-only usa-table__announcement-region"
aria-live="polite">
</div>
<%= paginate @client_tokens, window: 1, outer_window: 1, param_name: :token_page %>
<% else %>
<p class="ds-u-color--muted">
Before you can start testing in the sandbox, you must create a unique client token for each application or vendor that will have access to the sandbox on your behalf. <%= link_to "Create a client token", new_organization_client_token_path(organization_id: organization.id) %>.
</p>
<% end %>
</div>
</section>
<section class="box">
<div class="box__content">
<div class="box__header">
<h3 class="box__heading">Public Keys</h3>
<div class="box__header__actions">
<%= link_to new_organization_public_key_path(organization_id: organization.id), class: "ds-c-button ds-c-button--primary", data: { test: "new-public-key" } do %>
<svg class="icon ds-u-margin-right--1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<use xlink:href="/assets/solid.svg#plus"></use>
</svg>
Add key
<% end %>
</div>
</div>
<% if organization.reg_org.public_keys.count == 0 %>
<p class="ds-u-color--muted">
Before you can start testing in the sandbox, add your public keys to get a UUID that you will use when you authenticate access. <%= link_to "Add a public key", new_organization_public_key_path(organization_id: organization.id) %>
</p>
<% else %>
<table class="usa-table" data-toggle="table" id="public-key-table">
<caption aria-hidden="true" hidden>Public Key Table</caption>
<div class="ds-l-col--12">
<thead>
<tr>
<th data-sortable="true" scope="col" role="columnheader">
Key Name
</th>
<th data-sortable="true" scope="col" role="columnheader">
Key ID
</th>
<th data-sortable="true" scope="col" role="columnheader" aria-sort="descending">
Creation Date
</th>
<th>Actions</th>
</tr>
</thead>
</div>
<tbody style="width: 100%">
<% @public_keys.each_with_index do |key, index| %>
<tr class="credentials">
<%= tag.td data: {sortable_value: key['label']} do %>
<div class="credential">
<svg class="icon icon--lg ds-u-margin-right--3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<use xlink:href="/assets/solid.svg#key"></use>
</svg>
<h3 class="credential__name"><%= key['label'] %></h3>
</div>
<% end %>
<%= tag.td data: {sortable_value: key['id']} do %>
<p class="ds-u-color--base"><%= key['id'] %></p>
<% end %>
<%= tag.td data: {sortable_value: key['createdAt']} do %>
<p>Created: <%= formatted_datestr(key['createdAt']) %></p>
<% end %>
<td data-sortable="false">
<div class="credential__delete usa-accordion">
<button id="button<%= index +1 %>" class="usa-accordion__button credential__delete_button" aria-expanded="false" aria-controls="collapse_key<%= index +1 %>">
X
</button>
<div id="collapse_key<%= index +1 %>" class="credential__btn_container usa-accordion__content" hidden>
<div class="credential__text">
Delete Public Key?
</div>
<div class="credential__actions">
<button class="credential__cancel_btn" onclick="collapseButtons('button<%= index +1 %>', 'collapse_key<%= index +1 %>')">
Cancel
</button>
<%= button_to "Delete", organization_public_key_path(id: key['id'], organization_id: organization.id), method: :delete, class: "ds-c-button ds-c-button--danger ds-u-float--right"%>
</div>
</div>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
<div
class="usa-sr-only usa-table__announcement-region"
aria-live="polite">
</div>
<%= paginate @public_keys, window: 1, outer_window: 1, param_name: :key_page %>
<% end %>
</div>
</div>
<p><svg class="icon ds-u-margin-right--1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<use xlink:href="/assets/solid.svg#exclamation-triangle"></use>
</svg> You will need <strong>both</strong> client tokens and public keys to use the API for this organization.</p>
</section>
<% else %>
<section class="box box--dashed ds-u-margin-bottom--7">
<div class="box__content">
<div class="box__header">
<h3 class="box__heading"><%= organization.name %> is almost ready!</h3>
</div>
<p class="ds-text--lead ds-u-measure--wide">
<% if organization.prod_sbx? %>
Before this organization can add credentials for sandbox testing, a CMS admin must enable sandbox access.
<% elsif organization.npi.present? %>
Before this organization can add credentials, a CMS admin must enable access.
<% else %>
Before this organization can add credentials for API access, you need to designate an organizational NPI and vendor by <%= link_to "editing the organization", edit_organization_url(organization) %>.
<% end %>
</p>
</div>
</section>
<% end %>
<% end %>
</div>