Skip to content
2 changes: 2 additions & 0 deletions jsapp/js/UniversalTable/UniversalTableCore.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ $z-index-spinner: 8;
overflow-x: auto;
position: relative;
border-radius: $universal-table-border-radius-inner;
// Hard-coded minimum height that will not cut off dropdowns in header if there are little to no entries in the table
min-height: 200px;
}

// If the footer is displayed, don't round bottom corners
Expand Down
4 changes: 3 additions & 1 deletion jsapp/js/UniversalTable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useMemo } from 'react'

import type { UseQueryResult } from '@tanstack/react-query'
import type { ErrorObject } from 'schema-utils/declarations/validate'
import type { ErrorDetail } from '#/api/models/errorDetail'
import UniversalTableCore from './UniversalTableCore'
import type { UniversalTableColumn } from './UniversalTableCore'

Expand Down Expand Up @@ -44,7 +46,7 @@ export namespace PaginatedListResponse {
}
}

interface UniversalTableProps<Datum, TError = Error> {
interface UniversalTableProps<Datum, TError = Error | ErrorDetail | ErrorObject> {
// Below are props from `UniversalTable` that should come from the parent
// component (these are kind of "configuration" props). The other
// `UniversalTable` props are being handled here internally.
Expand Down
26 changes: 12 additions & 14 deletions jsapp/js/account/usage/assetUsage.api.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { fetchGet } from '#/api'
import type { PaginatedResponse } from '#/dataInterface'
import { PROJECT_FIELDS } from '#/projects/projectViews/constants'
import type { ProjectFieldName } from '#/projects/projectViews/constants'
import type { ProjectsTableOrder } from '#/projects/projectsTable/projectsTable'

export interface AssetUsage {
count: string
next: string | null
previous: string | null
results: AssetWithUsage[]
}

export interface AssetWithUsage {
asset: string
uid: string
asset__name: string
nlp_usage_current_period: {
total_nlp_asr_seconds: number
Expand All @@ -31,14 +24,16 @@ export interface AssetWithUsage {
const ORG_ASSET_USAGE_URL = '/api/v2/organizations/:organization_id/asset_usage/'

export async function getOrgAssetUsage(
pageNumber: number | string,
limit: number,
offset: number,
organizationId: string,
order?: ProjectsTableOrder,
) {
const apiUrl = ORG_ASSET_USAGE_URL.replace(':organization_id', organizationId)

const params = new URLSearchParams({
page: pageNumber.toString(),
limit: limit.toString(),
offset: offset.toString(),
})

if (order?.fieldName && order.direction && (order.direction === 'ascending' || order.direction === 'descending')) {
Expand All @@ -47,8 +42,11 @@ export async function getOrgAssetUsage(
params.set('ordering', orderingPrefix + fieldDefinition.apiOrderingName)
}

return fetchGet<AssetUsage>(`${apiUrl}?${params}`, {
includeHeaders: true,
errorMessageDisplay: t('There was an error fetching asset usage data.'),
})
return {
status: 200 as const,
data: await fetchGet<PaginatedResponse<AssetWithUsage>>(`${apiUrl}?${params}`, {
includeHeaders: true,
errorMessageDisplay: t('There was an error fetching asset usage data.'),
}),
}
}
81 changes: 0 additions & 81 deletions jsapp/js/account/usage/usageProjectBreakdown.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,88 +30,7 @@
padding: 2%;
}

.root table {
width: 100%;
border-collapse: collapse;
margin-block-end: 60px;
}

.root table th {
padding: 0 8px;
}

.projects {
padding-right: 15%;
padding-left: 8px;
}

.root th {
font-weight: 700;
font-size: 13px;
color: colors.$kobo-gray-700;
text-align: initial;
padding-block: 1.5%;
}

.root tr {
font-weight: 400;
font-size: 16px;
color: colors.$kobo-gray-800;
border-bottom: 1px solid colors.$kobo-gray-300;
}

.root td {
padding: 18px 8px;
}

.link {
color: colors.$kobo-dark-blue;
font-weight: 600;
}

.currentMonth {
font-weight: 600;
}

.pagination {
font-weight: 400;
font-size: 14px;
color: colors.$kobo-gray-800;
position: fixed;
bottom: 20px;
background-color: white;
border: 1px solid colors.$kobo-gray-400;
width: 150px;
border-radius: 4px;
padding: 5px 0;
display: flex;
align-items: center;
height: 36px;
}

.root button {
background: transparent;
border: none;
padding: 0 8px;
color: colors.$kobo-gray-400;
cursor: pointer;

&.active {
color: colors.$kobo-gray-800;
}
}

.range {
padding: 6px;
border-right: 1px solid colors.$kobo-gray-400;
border-left: 1px solid colors.$kobo-gray-400;
flex: 1;
text-align: center;
}

.emptyMessage {
padding: 40px;
font-size: 1.2rem;
justify-content: center;
text-align: center;
}
Loading