-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4262 from cloud-gov/4258-user-org-reporting
Make org/user data available via reports interface
- Loading branch information
Showing
18 changed files
with
457 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
export const downloadCSV = async (fetchCSV, filename) => { | ||
const csv = await fetchCSV(); | ||
const blob = new Blob([csv], { type: 'application/octet-stream' }); | ||
const aElement = document.createElement('a'); | ||
aElement.setAttribute('download', filename); | ||
const href = URL.createObjectURL(blob); | ||
aElement.href = href; | ||
aElement.setAttribute('target', '_blank'); | ||
aElement.click(); | ||
URL.revokeObjectURL(href); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<script> | ||
import { downloadCSV } from '../../helpers/downloadCSV'; | ||
import { fetchOrganizationsReport, fetchOrganizationsReportCSV } from '../../lib/api'; | ||
import { PaginatedQueryPage, DataTable } from '../../components'; | ||
</script> | ||
|
||
<PaginatedQueryPage path="reports/organizations" title="Organizations" query={fetchOrganizationsReport} noSearch let:data> | ||
<div> | ||
<button type="button" class="usa-button margin-left-1" on:click={() => downloadCSV(fetchOrganizationsReportCSV, 'organizations.csv')}>Download CSV of All Organizations</button> | ||
</div> | ||
<DataTable data={data}> | ||
<tr slot="header"> | ||
<th scope="col">Organization</th> | ||
<th scope="col">Agency</th> | ||
</tr> | ||
<tr slot="item" let:item={org}> | ||
<td> | ||
<a href="/organizations/{org.id}">{org.name}</a> | ||
</td> | ||
<td> | ||
{org.agency} | ||
</td> | ||
</tr> | ||
</DataTable> | ||
</PaginatedQueryPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<script> | ||
import { formatDistanceStrict } from 'date-fns'; | ||
import { downloadCSV } from '../../helpers/downloadCSV'; | ||
import { fetchUsersReport, fetchUsersReportCSV } from '../../lib/api'; | ||
import { PaginatedQueryPage, DataTable } from '../../components'; | ||
</script> | ||
|
||
<PaginatedQueryPage path="reports/organizations" title="Users" query={fetchUsersReport} noSearch let:data> | ||
<div> | ||
<button type="button" class="usa-button margin-left-1" on:click={() => downloadCSV(fetchUsersReportCSV, 'users.csv')}>Download CSV of All Users</button> | ||
</div> | ||
<DataTable data={data}> | ||
<tr slot="header"> | ||
<th scope="col">ID</th> | ||
<th scope="col">Github Email</th> | ||
<th scope="col">UAA Email</th> | ||
<th scope="col">Organizations</th> | ||
<th scope="col">Details</th> | ||
<th scope="col">Created</th> | ||
<th scope="col">Signed In</th> | ||
</tr> | ||
<tr slot="item" let:item={user}> | ||
<td> | ||
<a href="/organizations/{user.id}">{user.id}</a> | ||
</td> | ||
<td> | ||
{#if user.email } | ||
{user.email} | ||
{/if} | ||
</td> | ||
<td> | ||
{#if user.UAAIdentity } | ||
{user.UAAIdentity.email} | ||
{/if} | ||
</td> | ||
<td> | ||
{#if user.OrganizationRoles.length > 0} | ||
{ | ||
user.OrganizationRoles.map((orgRole) => `${orgRole.Organization.name}`).join(', ') | ||
} | ||
{/if} | ||
</td> | ||
<td> | ||
{#if user.OrganizationRoles.length > 0} | ||
{ | ||
user.OrganizationRoles.map((orgRole) => `${orgRole.Organization.name}: ${orgRole.Role.name}`).join(', ') | ||
} | ||
{/if} | ||
</td> | ||
<td> | ||
{ formatDistanceStrict(new Date(user.createdAt), new Date(), { addSuffix: true, roundingMethod: 'floor' }) } | ||
</td> | ||
<td> | ||
{#if user.signedInAt } | ||
{ formatDistanceStrict(new Date(user.signedInAt), new Date(), { addSuffix: true, roundingMethod: 'floor' }) } | ||
{:else } | ||
never | ||
{/if } | ||
</td> | ||
</tr> | ||
</DataTable> | ||
</PaginatedQueryPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { default as Show } from './Show.svelte'; | ||
export { default as Index } from './Index.svelte'; | ||
export { default as Invite } from './Invite.svelte'; | ||
export { default as UsersReport } from './UsersReport.svelte'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.