Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions app/components/ReportCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import {
InlineLayout,
ListView,
} from '@ifrc-go/ui';
import { isDefined } from '@togglecorp/fujs';

import type { ReportsQuery } from '#generated/types/graphql';
import {
ReportContentType,
type ReportsQuery,
} from '#generated/types/graphql';

import styles from './styles.module.css';

Expand All @@ -21,12 +25,13 @@ function ReportCard({ report }: ReportCardProps) {
coverImage,
title,
description,
contentType,
} = report;

return (
<InlineLayout
before={
coverImage?.url ? (
isDefined(coverImage?.url) ? (
<Image
src={coverImage.url}
alt="Report"
Expand All @@ -52,6 +57,19 @@ function ReportCard({ report }: ReportCardProps) {
layout="block"
spacing="3xs"
>
{contentType === ReportContentType.Iframe && (
<Description
withLightText
>
<InlineLayout
spacing="3xs"
before={<DashboardLineIcon />}
>
External Dashboard
</InlineLayout>
</Description>
)}

<Heading
level={4}
>
Expand Down
2 changes: 1 addition & 1 deletion app/views/CapacityAndResources/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function CapacityAndResourcesList() {
const [{ data, fetching }] = useCapacityAndResourcesQuery({
variables: {
filters: {
regions: [regionId ?? ''],
regions: regionId ? [regionId] : null,
isActive: true,
search: filter.searchText,
},
Expand Down
51 changes: 18 additions & 33 deletions app/views/DataAndReport/AIsummary/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { StarLineIcon } from '@ifrc-go/icons';
import {
BlockLoading,
Description,
Heading,
InlineView,
Expand All @@ -8,8 +9,13 @@ import {

import styles from './styles.module.css';

function AIsummary() {
// TODO: fetch ai summary data from backend and display here
interface AISummaryProps {
loading? : boolean,
summary: string
}

function AIsummary(props: AISummaryProps) {
const { loading, summary } = props;
return (
<ListView
layout="block"
Expand All @@ -24,37 +30,16 @@ function AIsummary() {
>
<Heading level={2}>AI Summary</Heading>
</InlineView>
<Description textSize="lg">
A cholera outbreak was declared in Arsi Zone,
Ethiopia on 17 May 2025 and is spreading to nearby areas.
By mid-June, 201 cases (92% severe) and 2 deaths were reported.
The outbreak is rapidly increasing, with over 62,000 people in need of assistance.
</Description>
<Description textSize="lg">
A cholera outbreak was declared in Arsi Zone,
Ethiopia on 17 May 2025 and is spreading to nearby areas.
By mid-June, 201 cases (92% severe) and 2 deaths were reported.
The outbreak is rapidly increasing, with over 62,000 people in need of assistance.
</Description>
<Description textSize="lg">
A cholera outbreak was declared in Arsi Zone,
Ethiopia on 17 May 2025 and is spreading to nearby areas.
By mid-June, 201 cases (92% severe) and 2 deaths were reported.
The outbreak is rapidly increasing, with over 62,000 people in need of assistance.
</Description>
<Description textSize="lg">
A cholera outbreak was declared in Arsi Zone,
Ethiopia on 17 May 2025 and is spreading to nearby areas.
By mid-June, 201 cases (92% severe) and 2 deaths were reported.
The outbreak is rapidly increasing, with over 62,000 people in need of assistance.
</Description>
<Description textSize="lg">
A cholera outbreak was declared in Arsi Zone,
Ethiopia on 17 May 2025 and is spreading to nearby areas.
By mid-June, 201 cases (92% severe) and 2 deaths were reported.
The outbreak is rapidly increasing, with over 62,000 people in need of assistance.
</Description>

{loading ? (
<BlockLoading
withoutBorder
message="Generating...."
/>
) : (
<Description textSize="lg">
{summary}
</Description>
) }
</ListView>
);
}
Expand Down
2 changes: 2 additions & 0 deletions app/views/DataAndReport/AIsummary/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
background: var(--go-ui-color-primary-red) ;
padding-top: var(--go-ui-spacing-4xl) !important;
height: 100%;
white-space: pre-line;
color: var(--go-ui-color-white);

}
70 changes: 60 additions & 10 deletions app/views/DataAndReport/ReportDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@ import {
ListView,
PageContainer,
} from '@ifrc-go/ui';
import { encodeDate } from '@togglecorp/fujs';
import {
encodeDate,
isDefined,
} from '@togglecorp/fujs';
import { gql } from 'urql';

import PdfViewer from '#components/PdfViewer';
import PowerBIEmbed from '#components/PowerBiEmbed';
import { useReportQuery } from '#generated/types/graphql';
import {
DocumentExtractionStatus,
ExtractionType,
ReportContentType,
useReportQuery,
useReportSummaryQuery,
} from '#generated/types/graphql';
import AIsummary from '#views/DataAndReport/AIsummary';

import styles from './styles.module.css';
Expand All @@ -39,18 +48,56 @@ const REPORT_QUERY = gql`
}
`;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const REPORT_SUMMARY_QUERY = gql`
query ReportSummary(
$pagination: OffsetPaginationInput,
$filters: ReportSummaryFilter
) {
reportSummaries(
filters: $filters
pagination: $pagination
) {
totalCount
results {
id
chunkType
text
pageNumber
status
}
totalCount
pageInfo {
offset
limit
}
}
}
`;

function ReportDetail() {
const { id } = useParams<{ id: string }>();

const [{ fetching, data }] = useReportQuery({
variables: { id: id! },
pause: !id,
});

const reportData = data?.report;

// TODO: add condition or ai summary
const aiSummaryAvailable = !reportData?.iframeUrl;
const [{ fetching: summaryLoading, data: summaryData }] = useReportSummaryQuery({
variables: {
filters: {
report: id,
status: DocumentExtractionStatus.Success,
chunkType: ExtractionType.DocumentSummary,
},
},
pause: !id || !reportData || reportData.contentType === ReportContentType.Iframe,
});

const aiSummary = summaryData?.reportSummaries.results
.map((summary) => summary.text)
.join('\n \n');
const publishedDate = new Date(reportData?.publishedAt);
const encodedPublishedDate = encodeDate(publishedDate);

Expand All @@ -63,13 +110,13 @@ function ReportDetail() {
>
<ListView
// eslint-disable-next-line react/jsx-props-no-spreading
{...(aiSummaryAvailable
{...(isDefined(aiSummary)
? { layout: 'grid', withSidebar: true }
: { layout: 'block' })}
>
<ListView
layout="block"
spacing={aiSummaryAvailable ? 'md' : 'xs'}
spacing={aiSummary ? 'md' : 'xs'}
className={styles.content}
>
<ListView
Expand Down Expand Up @@ -117,18 +164,21 @@ function ReportDetail() {
</Description>
</ListView>
</ListView>
{reportData?.file?.url
{isDefined(reportData?.file?.url)
? <PdfViewer file={reportData?.file?.url ?? ''} />
: (
<PowerBIEmbed
embedUrl={reportData?.iframeUrl ?? ''}
/>
) }
</ListView>
{aiSummaryAvailable && (
{isDefined(aiSummary) && (
<div className={styles.details}>
<div className={styles.stickyDetails}>
<AIsummary />
<AIsummary
summary={aiSummary}
loading={summaryLoading}
/>
</div>
</div>
)}
Expand Down
7 changes: 4 additions & 3 deletions app/views/DataAndReport/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const Reports_QUERY = gql`
contentType
visibility
publishedAt
contentType
createdAt
owner
iframeUrl
Expand Down Expand Up @@ -91,6 +92,7 @@ function DataAndReport() {
rawFilter,
setFilterField,
setPage,
filter,
offset,
} = useFilterState<{
thematicAreaId?: string,
Expand All @@ -105,9 +107,8 @@ function DataAndReport() {
filters: {
thematicAreaId: rawFilter.thematicAreaId,
reportType: ReportTypeEnum.Report,
// TODO: add search filter in backend and uncomment below line
// search: rawFilter.search,
regions: [regionId ?? ''],
search: filter.searchText ?? '',
regions: regionId ? [regionId] : null,
},
pagination: {
limit,
Expand Down
2 changes: 1 addition & 1 deletion app/views/OurWork/EmergencyResponse/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function EmergencyResponse() {
filters: {
page: DashboardPage.EmergencyResponse,
isActive: true,
regions: [regionId ?? ''],
regions: regionId ? [regionId] : null,
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion app/views/Preparedness/DisasterResponse/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function DisasterResponse() {
filters: {
page: DashboardPage.DisasterResponse,
isActive: true,
regions: [regionId ?? ''],
regions: regionId ? [regionId] : null,
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion app/views/Preparedness/EmergencyAlert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function EmergencyAlert() {
filters: {
page: DashboardPage.EmergencyAlerts,
isActive: true,
regions: [regionId ?? ''],
regions: regionId ? [regionId] : null,
},
},
});
Expand Down
4 changes: 2 additions & 2 deletions app/views/TeamList/Members/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ const TEAM_MEMBERS_QUERY = gql`
) {
totalCount
results {
woredaId
woreda
updatedAt
training
teamId
sex
regionId
region
position
phoneNumber
order
Expand Down
2 changes: 1 addition & 1 deletion backend
Submodule backend updated 44 files
+4 −15 apps/dashboards/admin.py
+4 −0 apps/dashboards/graphql/filters.py
+2 −2 apps/dashboards/graphql/inputs.py
+35 −0 apps/dashboards/graphql/mutations.py
+9 −1 apps/dashboards/graphql/types.py
+23 −0 apps/dashboards/migrations/0002_replace_m2m_dashboards_with_fk.py
+35 −33 apps/dashboards/models.py
+55 −17 apps/dashboards/serializers.py
+228 −116 apps/dashboards/tests/mutations_test.py
+23 −7 apps/dashboards/tests/queries_test.py
+2 −2 apps/reports/admin.py
+0 −0 apps/reports/ai_features/__init__.py
+145 −0 apps/reports/ai_features/extraction.py
+63 −0 apps/reports/ai_features/llms.py
+55 −0 apps/reports/ai_features/prompts.py
+106 −0 apps/reports/ai_features/search_docs.py
+10 −17 apps/reports/extraction.py
+11 −1 apps/reports/factories.py
+38 −3 apps/reports/graphql/filters.py
+1 −1 apps/reports/graphql/inputs.py
+21 −1 apps/reports/graphql/mutations.py
+10 −4 apps/reports/graphql/queries.py
+19 −1 apps/reports/graphql/types.py
+13 −0 apps/reports/migrations/0007_create_vector_extension.py
+53 −0 apps/reports/migrations/0008_remove_documentextraction_extracted_contents_and_more.py
+23 −0 apps/reports/migrations/0009_create_hnsw_index.py
+19 −0 apps/reports/migrations/0010_alter_report_thematic_area.py
+19 −0 apps/reports/migrations/0011_alter_documentextraction_chunk_type.py
+31 −5 apps/reports/models.py
+0 −0 apps/reports/tasks/__init__.py
+35 −0 apps/reports/tasks/task.py
+13 −10 apps/reports/tests/mutations_test.py
+125 −3 apps/reports/tests/queries_test.py
+1 −0 apps/teams/graphql/filters.py
+4 −0 apps/teams/graphql/queries.py
+11 −2 apps/teams/graphql/types.py
+5 −1 docker-compose.yaml
+1 −1 gh-docker-compose.yml
+9 −1 main/celery.py
+3 −3 main/graphql/enums.py
+10 −0 main/settings.py
+9 −0 pyproject.toml
+231 −28 schema.graphql
+1,088 −0 uv.lock
Loading