Skip to content

Commit c089b73

Browse files
Upgrade dashboard weekly (#549)
* Removing the old dashboard code * one last line to clean * commit for review and collab * people enabled * removing practice count from test Co-authored-by: Spencer Stolworthy <[email protected]>
1 parent 04d15d9 commit c089b73

File tree

4 files changed

+122
-18
lines changed

4 files changed

+122
-18
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { Artifact, Engagement } from '../../../schemas/engagement';
2+
import {
3+
Card,
4+
CardBody,
5+
CardFooter,
6+
CardHeader,
7+
Text,
8+
TextContent,
9+
TextVariants,
10+
} from '@patternfly/react-core';
11+
import { Table, TableBody, TableHeader } from '@patternfly/react-table';
12+
13+
import CustomRowWrapper from '../../../components/custom_row_wrapper/custom_row_wrapper';
14+
import {ReactComponent as HeartbeatIcon} from '../../../assets/images/heart-rate.svg';
15+
import { Link } from 'react-router-dom';
16+
import { LinkOrSpan } from '../../link_or_span/link_or_span';
17+
import React from 'react';
18+
19+
export interface DwLastWeeklyReportProps {
20+
artifacts: Artifact[];
21+
engagements: Partial<Engagement>[];
22+
}
23+
const columns = ['Weekly Report', 'Engagement'];
24+
export function DwLastWeeklyReport2({
25+
artifacts = [],
26+
engagements = [],
27+
}: DwLastWeeklyReportProps) {
28+
const engagementsById = artifacts.reduce(
29+
(acc, curr) => ({
30+
...acc,
31+
[curr.engagement_uuid]: engagements.find(
32+
e => e.uuid === curr.engagement_uuid
33+
),
34+
}),
35+
{}
36+
);
37+
const rows = artifacts.map(artifact => {
38+
return [
39+
{
40+
title: (
41+
<LinkOrSpan href={artifact?.linkAddress}>
42+
{artifact?.description}
43+
</LinkOrSpan>
44+
),
45+
},
46+
{
47+
title: (
48+
<Link to={`/app/engagements/${artifact.engagement_uuid}`}>
49+
{engagementsById[artifact.engagement_uuid]?.customer_name}
50+
&nbsp;—&nbsp;
51+
{engagementsById[artifact.engagement_uuid]?.project_name}
52+
</Link>
53+
),
54+
},
55+
];
56+
});
57+
return (
58+
<Card>
59+
<CardHeader>
60+
<HeartbeatIcon
61+
width="25"
62+
fill="#EE0000"
63+
stroke="#EE0000"
64+
style={{marginRight:"5px"}}
65+
></HeartbeatIcon>
66+
<TextContent>
67+
<Text component={TextVariants.h2}>Weekly Reports <span style={{fontSize:"12px", color:"#999999", verticalAlign:"middle"}}>(last 5)</span></Text>
68+
</TextContent>
69+
</CardHeader>
70+
<CardBody>
71+
<Table
72+
aria-label="Last 5 Weekly Reports"
73+
rows={rows}
74+
cells={columns}
75+
gridBreakPoint={'grid-lg'}
76+
rowWrapper={({trRef, rowProps, ...props}) => <CustomRowWrapper trref={trRef} rowprops={rowProps} {...props}/>}
77+
>
78+
<TableHeader />
79+
<TableBody />
80+
</Table>
81+
</CardBody>
82+
<CardFooter></CardFooter>
83+
</Card>
84+
);
85+
}

src/hooks/use_practice_count.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { useEffect, useState } from 'react';
22

33
import { PracticeCount } from '../schemas/engagement';
44

5-
export const usePracticeCount = (fetcher: () => Promise<PracticeCount>) => {
6-
const [practiceCount, setPracticeCount] = useState<PracticeCount | undefined>(
5+
export const usePracticeCount = (fetcher: () => Promise<PracticeCount[]>) => {
6+
const [practiceCount, setPracticeCount] = useState<PracticeCount[] | undefined>(
77
undefined
88
);
99
const [isLoading, setIsLoading] = useState(false);

src/packages/api_v1_sdk/apiv1_practice_count_service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class Apiv1PracticeCountService implements PracticeCountService {
3737
}
3838
async getPracticeCount(filter?: PracticeCountFilter): Promise<PracticeCount[]> {
3939
const { data } = await this.axios.get(
40-
`https://word-analyzer-engagements-dev.apps.hivec.sandbox1405.opentlc.com/aggregate-for-engagement?uuid=999`
40+
`https://word-analyzer-engagements-dev.apps.openshift-4813-7bsw4.do500.redhatlabs.dev/aggregate-for-engagement?uuid=999`
4141
);
4242

4343
let sorted = data.data.slice().sort((a, b) => b.value - a.value).splice(1, 5).reverse();

src/routes/dashboard/index.tsx

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ import { DwLastDemo } from '../../components/dashboard/widgets/dw_last_demo';
2323
import { DwLastUpdated } from '../../components/dashboard/widgets/dw_last_updated_engagements';
2424
import { DwLastUseCases } from '../../components/dashboard/widgets/dw_last_use_cases';
2525
import { DwLastWeeklyReport } from '../../components/dashboard/widgets/dw_last_weekly_report';
26-
import { DwTopPractices } from '../../components/dashboard/widgets/dw_top_practices';
26+
//import { DwLastWeeklyReport2 } from '../../components/dashboard/widgets/dw_last_weekly_report2';
27+
//import { DwTopPractices } from '../../components/dashboard/widgets/dw_top_practices';
2728
import { DwTopTags } from '../../components/dashboard/widgets/dw_top_tags';
2829
import { EnabledUsersFilter } from '../../services/enabled_users_service/enabled_users_service';
2930
import { EngagementQueryMediator } from '../../components/dashboard/widgets/engagement_query_mediator';
3031
import { Feature } from '../../components/feature/feature';
31-
import { PracticeCountFilter } from '../../services/practice_count_service/practice_count_service';
32+
//import { PracticeCountFilter } from '../../services/practice_count_service/practice_count_service';
3233
import { SortOrder } from '../../services/engagement_service/engagement_service';
3334
import { SummaryCountFilter } from '../../services/summary_count_service/summary_count_service';
3435
import { createBase64ParseableFilter } from '../engagement_list/engagement_list_route';
@@ -37,7 +38,7 @@ import { useEnabledUsers } from '../../hooks/use_enabled_users';
3738
import { useEngagementCollection } from '../../hooks/engagement_collection_hook';
3839
import { useEngagementFormConfig } from '../../context/engagement_config_context/engagement_config_hook';
3940
import { useHistory } from 'react-router';
40-
import { usePracticeCount } from '../../hooks/use_practice_count';
41+
//import { usePracticeCount } from '../../hooks/use_practice_count';
4142
import { useServiceProviders } from '../../context/service_provider_context/service_provider_context';
4243
import { useSummaryCount } from '../../hooks/use_summary_count';
4344
import { useVersion } from '../../context/version_context/version_context';
@@ -70,7 +71,7 @@ export function Dashboard() {
7071
artifactService,
7172
useCaseService,
7273
enabledUsersService,
73-
practiceCountService,
74+
// practiceCountService,
7475
summaryCountService,
7576
} = useServiceProviders();
7677
const [isRegionSelectOpen, setIsRegionSelectOpen] = useState(false);
@@ -89,16 +90,16 @@ export function Dashboard() {
8990
undefined
9091
);
9192

92-
const practiceFetcher = useCallback(() => {
93-
const filter: PracticeCountFilter = {
94-
regions: selectedRegions,
95-
};
96-
return practiceCountService.getPracticeCount(filter);
97-
}, [practiceCountService, selectedRegions]);
93+
// const practiceFetcher = useCallback(() => {
94+
// const filter: PracticeCountFilter = {
95+
// regions: selectedRegions,
96+
// };
97+
// return practiceCountService.getPracticeCount(filter);
98+
// }, [practiceCountService, selectedRegions]);
9899

99-
const { practiceCount, isLoading: isLoadingPractices } = usePracticeCount(
100-
practiceFetcher
101-
);
100+
// const { practiceCount, isLoading: isLoadingPractices } = usePracticeCount(
101+
// practiceFetcher
102+
// );
102103

103104
const categoryFetcher = useCallback(() => {
104105
const filter: CategoryFilter = {
@@ -239,18 +240,36 @@ export function Dashboard() {
239240
}}
240241
/>
241242
</GridItem>
243+
{/* <GridItem sm={12} xl={12} xl2={6}>
244+
{withArtifacts(
245+
DwLastWeeklyReport2,
246+
() =>
247+
artifactService.getArtifacts({
248+
page: 1,
249+
perPage: 5,
250+
type: 'weeklyReport',
251+
startDate: dateFilter?.startDate,
252+
endDate: dateFilter?.endDate,
253+
regions: selectedRegions,
254+
sortOrder: 'DESC',
255+
sortFields: 'updated',
256+
}),
257+
258+
engagementService.getEngagementById
259+
)}
260+
</GridItem> */}
242261
<GridItem colSpan={1} sm={12} md={6} xl={6} xl2={6}>
243262
<DashboardPeopleEnabledCard
244263
usersEnabled={enabledUsers}
245264
isLoading={isLoadingEnabledUsers}
246265
/>
247266
</GridItem>
248-
<GridItem colSpan={1} sm={12} md={6} xl={6} xl2={6}>
267+
{/* <GridItem colSpan={1} sm={12} md={6} xl={6} xl2={6}>
249268
<DwTopPractices
250269
practices={practiceCount}
251270
isLoading={isLoadingPractices}
252271
/>
253-
</GridItem>
272+
</GridItem> */}
254273
<GridItem colSpan={1} sm={12} md={6} xl={6} xl2={6}>
255274
<DwTopTags
256275
categories={categories}

0 commit comments

Comments
 (0)