Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎁 Heated-tags tab in HeatTrace app #1081

Merged
merged 3 commits into from
Aug 22, 2024
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
14 changes: 14 additions & 0 deletions libs/heattraceshared/src/lib/types/heatTraceHeatedTag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export type HeatTraceHeatedTag = {
heatTracingCableTagNo: string;
heatTracingCableTagId: string;
heatedTagNo: string;
heatedTagId: string;
register: string;
description: string;
mechanicalCompletionHandoverStatus?: string;
commissioningPackageNo?: string;
mechanicalCompletionPackageNo?: string;
commissioningPackageUrl?: string;
mechanicalCompletionUrl?: string;
tagUrl?: string;
};
1 change: 1 addition & 0 deletions libs/heattraceshared/src/lib/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './heattrace';
export * from './heatTraceChecklist';
export * from './dcrEnum';
export * from './heatTraceHeatedTag';
22 changes: 22 additions & 0 deletions libs/heattracesidesheet/src/lib/ui-sidesheet/HeatedTagsTab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { TabTable } from '@cc-components/shared';
import { heatedTagsColumns } from './heatedTagsColumns';
import { HeatTraceHeatedTag } from '@cc-components/heattraceshared';

type HeatedTagsTabProps = {
data: HeatTraceHeatedTag[] | undefined;
isFetching: boolean;
error: Error | null;
};

export const HeatedTagsTab = (props: HeatedTagsTabProps): JSX.Element => {
const { data, error, isFetching } = props;
return (
<TabTable
columns={heatedTagsColumns}
error={error}
isFetching={isFetching}
packages={data}
resourceName="Heated tags"
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import { Icon, Tabs } from '@equinor/eds-core-react';
import { useGetEleNetwork } from '../utils-sidesheet/useGetEleNetwork';
import styled from 'styled-components';
import { tokens } from '@equinor/eds-tokens';
import { useGetHeatedTags } from '../utils-sidesheet/useGetHeatedTags';
import { HeatedTagsTab } from './HeatedTagsTab';

const viewerOptions = {
statusResolver: (status: string) => {
Expand Down Expand Up @@ -79,6 +81,8 @@ const HeattraceSidesheetComponent = ({

const { dataWorkorders, errorWorkorders, isLoadingWorkorders } = useGetWorkorders(id);

const { dataHeatedTags, errorHeatedTags, isLoadingHeatedTags } = useGetHeatedTags(id);

const { dataChecklists, errorChecklists, isLoadingChecklists } =
useGetHeatTraceChecklists(id);

Expand Down Expand Up @@ -139,6 +143,10 @@ const HeattraceSidesheetComponent = ({
<StyledTabListWrapper>
<StyledTabsList ref={ref}>
<Tabs.Tab>Circuit diagram</Tabs.Tab>
<Tabs.Tab>
Heated tags
<TabTitle data={dataHeatedTags} isLoading={isLoadingHeatedTags} />
</Tabs.Tab>
<Tabs.Tab>
Work orders
<TabTitle data={dataWorkorders} isLoading={isLoadingWorkorders} />
Expand Down Expand Up @@ -167,6 +175,13 @@ const HeattraceSidesheetComponent = ({
}}
/>
</StyledPanel>
<StyledPanel>
<HeatedTagsTab
error={errorHeatedTags}
isFetching={isLoadingHeatedTags}
data={dataHeatedTags}
/>
</StyledPanel>
<StyledPanel>
<WorkorderTab
error={errorWorkorders}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { ColDef, ICellRendererProps } from '@equinor/workspace-ag-grid';
import { HeatTraceHeatedTag } from '@cc-components/heattraceshared';

import { LinkCell } from '@cc-components/shared';

export const heatedTagsColumns: ColDef<HeatTraceHeatedTag>[] = [
{
headerName: 'Tag No',
valueGetter: (pkg) => pkg.data?.heatedTagNo,
cellRenderer: (props: ICellRendererProps<HeatTraceHeatedTag>) => {
return <LinkCell url={props.data?.tagUrl ?? ''} urlText={props.value ?? ''} />;
},
},
{
headerName: 'Tag description',
valueGetter: (pkg) => pkg.data?.description,
},
{
headerName: 'Tag register',
valueGetter: (pkg) => pkg.data?.register,
},
{
headerName: 'Handover status',
valueGetter: (pkg) => pkg.data?.mechanicalCompletionHandoverStatus,
},
{
headerName: 'CommPkg',
valueGetter: (pkg) => pkg.data?.commissioningPackageNo,
cellRenderer: (props: ICellRendererProps<HeatTraceHeatedTag>) => {
return (
<LinkCell
url={props.data?.commissioningPackageUrl ?? ''}
urlText={props.value ?? ''}
/>
);
},
},
{
headerName: 'McPkg',
valueGetter: (pkg) => pkg.data?.mechanicalCompletionPackageNo,
cellRenderer: (props: ICellRendererProps<HeatTraceHeatedTag>) => {
return (
<LinkCell
url={props.data?.mechanicalCompletionUrl ?? ''}
urlText={props.value ?? ''}
/>
);
},
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useContextId, useHttpClient } from '@cc-components/shared';
import { useQuery } from '@tanstack/react-query';
import { HeatTraceHeatedTag } from '@cc-components/heattraceshared';

export const useGetHeatedTags = (heatTraceCableId: string) => {
const client = useHttpClient();
const contextId = useContextId();

const { data, isLoading, error } = useQuery<HeatTraceHeatedTag[], Error>({
queryKey: ['heat-trace', heatTraceCableId, 'heated-tags'],
queryFn: async ({ signal }) => {
const response = await client.fetch(
`/api/contexts/${contextId}/heat-trace/${heatTraceCableId}/heated-tags`,
{ signal }
);
if (!response.ok) {
throw new Error();
}
return response.json();
},
});

return {
dataHeatedTags: data,
isLoadingHeatedTags: isLoading,
errorHeatedTags: error,
};
};
Loading