Skip to content

Commit

Permalink
Added support for facilities in PBI and apps
Browse files Browse the repository at this point in the history
  • Loading branch information
kjellhaaland committed Oct 8, 2024
1 parent 53e429f commit d54b555
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 42 deletions.
19 changes: 10 additions & 9 deletions libs/handoverapp/src/lib/config/workspaceConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,27 @@ import { useModuleCurrentContext } from '@equinor/fusion-framework-react-module-

const pbi_context_mapping = {
Facility: {
column: "Facility",
table: "Dim_Facility"
column: 'Facility',
table: 'Dim_Facility',
},
ProjectMaster: {
column: "ProjectMaster GUID",
table: "Dim_ProjectMaster"
column: 'ProjectMaster GUID',
table: 'Dim_ProjectMaster',
},
} as const

} as const;

export const WorkspaceWrapper = () => {
const contextId = useContextId();
useCloseSidesheetOnContextChange();
const client = useHttpClient('cc-app');
const { isLoading } = useCCApiAccessCheck(contextId, client, 'handover');

const { currentContext } = useModuleCurrentContext();

const { currentContext } = useModuleCurrentContext()

const pbi = usePBIOptions('handoveranalytics', pbi_context_mapping[(currentContext?.type.id) as "ProjectMaster" | "Facility"]);
const pbi = usePBIOptions(
'handoveranalytics',
pbi_context_mapping[currentContext?.type.id as 'ProjectMaster' | 'Facility']
);
const { bookmarkKey, currentBookmark, onBookmarkChange } = useWorkspaceBookmarks();

const filterConfig = useFilterConfig((req) =>
Expand Down
2 changes: 1 addition & 1 deletion libs/heattraceapp/src/lib/config/frameworkConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ModelViewerEnvConfig, enableModelViewer } from '@cc-components/modelvie

export const configure = async (config: IAppConfigurator, c: ComponentRenderArgs) => {
enableContext(config, async (builder) => {
builder.setContextType(['ProjectMaster']);
builder.setContextType(['ProjectMaster', 'Facility']);
builder.setContextParameterFn(({ search, type }) => {
return buildQuery({
search,
Expand Down
22 changes: 18 additions & 4 deletions libs/heattraceapp/src/lib/config/workspaceConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ import {
import { CCApiAccessLoading } from '@cc-components/sharedcomponents';
import { useGardenConfig } from './gardenConfig';
import { sidesheetConfig } from './heattraceSidesheet';
import { useModuleCurrentContext } from '@equinor/fusion-framework-react-module-context';

const pbi_context_mapping = {
Facility: {
column: 'Facility',
table: 'Dim_Facility',
},
ProjectMaster: {
column: 'ProjectMaster GUID',
table: 'Dim_ProjectMaster',
},
} as const;

export const WorkspaceWrapper = () => {
const contextId = useContextId();
Expand All @@ -33,10 +45,12 @@ export const WorkspaceWrapper = () => {
const statusBarConfig = useStatusBarConfig(contextId);
const gardenConfig = useGardenConfig(contextId);

const pbi = usePBIOptions('cc-heattrace-analytics', {
column: 'ProjectMaster GUID',
table: 'Dim_ProjectMaster',
});
const { currentContext } = useModuleCurrentContext();

const pbi = usePBIOptions(
'cc-heattrace-analytics',
pbi_context_mapping[currentContext?.type.id as 'ProjectMaster' | 'Facility']
);

if (isLoading) {
return <CCApiAccessLoading />;
Expand Down
2 changes: 1 addition & 1 deletion libs/loopapp/src/lib/config/frameworkConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import buildQuery from 'odata-query';

export const configure = async (config: IAppConfigurator, c: ComponentRenderArgs) => {
enableContext(config, async (builder) => {
builder.setContextType(['ProjectMaster']);
builder.setContextType(['ProjectMaster', 'Facility']);
builder.setContextParameterFn(({ search, type }) => {
return buildQuery({
search,
Expand Down
24 changes: 20 additions & 4 deletions libs/loopapp/src/lib/config/workspaceConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,30 @@ import { gardenModule } from '@equinor/workspace-fusion/garden-module';
import { gridModule } from '@equinor/workspace-fusion/grid-module';
import { powerBiModule } from '@equinor/workspace-fusion/power-bi-module';
import { CCApiAccessLoading } from '@cc-components/sharedcomponents';
import { useModuleCurrentContext } from '@equinor/fusion-framework-react-module-context';

const pbi_context_mapping = {
Facility: {
column: 'Facility',
table: 'Dim_Facility',
},
ProjectMaster: {
column: 'ProjectMaster GUID',
table: 'Dim_ProjectMaster',
},
} as const;

export const WorkspaceWrapper = () => {
const contextId = useContextId();
useCloseSidesheetOnContextChange();
const pbi = usePBIOptions('loop-analytics', {
column: 'ProjectMaster GUID',
table: 'Dim_ProjectMaster',
});

const { currentContext } = useModuleCurrentContext();

const pbi = usePBIOptions(
'loop-analytics',
pbi_context_mapping[currentContext?.type.id as 'ProjectMaster' | 'Facility']
);

const client = useHttpClient();
const { bookmarkKey, currentBookmark, onBookmarkChange } = useWorkspaceBookmarks();
const { isLoading } = useCCApiAccessCheck(contextId, client, 'loop');
Expand Down
2 changes: 1 addition & 1 deletion libs/pipingapp/src/lib/config/frameworkConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ModelViewerEnvConfig, enableModelViewer } from '@cc-components/modelvie

export const configure = async (config: IAppConfigurator, c: ComponentRenderArgs) => {
enableContext(config, async (builder) => {
builder.setContextType(['ProjectMaster']);
builder.setContextType(['ProjectMaster', 'Facility']);
builder.setContextParameterFn(({ search, type }) => {
return buildQuery({
search,
Expand Down
22 changes: 18 additions & 4 deletions libs/pipingapp/src/lib/config/workspaceConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ import {
import { useGardenConfig } from './gardenConfig';
import { sidesheetConfig } from './pipingSidesheet';
import { CCApiAccessLoading } from '@cc-components/sharedcomponents';
import { useModuleCurrentContext } from '@equinor/fusion-framework-react-module-context';

const pbi_context_mapping = {
Facility: {
column: 'Facility',
table: 'Dim_Facility',
},
ProjectMaster: {
column: 'ProjectMaster GUID',
table: 'Dim_ProjectMaster',
},
} as const;

export const WorkspaceWrapper = () => {
const contextId = useContextId();
Expand All @@ -32,10 +44,12 @@ export const WorkspaceWrapper = () => {
const statusBarConfig = useStatusBarConfig(contextId);
const gardenConfig = useGardenConfig(contextId);

const pbi = usePBIOptions('cc-pipetest-analytics', {
column: 'ProjectMaster GUID',
table: 'Dim_ProjectMaster',
});
const { currentContext } = useModuleCurrentContext();

const pbi = usePBIOptions(
'cc-pipetest-analytics',
pbi_context_mapping[currentContext?.type.id as 'ProjectMaster' | 'Facility']
);

if (isLoading) {
return <CCApiAccessLoading />;
Expand Down
2 changes: 1 addition & 1 deletion libs/punchapp/src/lib/config/frameworkConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import buildQuery from 'odata-query';

export const configure = async (config: IAppConfigurator, c: ComponentRenderArgs) => {
enableContext(config, async (builder) => {
builder.setContextType(['ProjectMaster']);
builder.setContextType(['ProjectMaster', 'Facility']);
builder.setContextParameterFn(({ search, type }) => {
return buildQuery({
search,
Expand Down
22 changes: 18 additions & 4 deletions libs/punchapp/src/lib/config/workspaceConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,31 @@ import { gridModule } from '@equinor/workspace-fusion/grid-module';
import { useTableConfig } from './tableConfig';
import { useStatusBarConfig } from './statusBarConfig';
import { useGardenConfig } from './gardenConfig';
import { useModuleCurrentContext } from '@equinor/fusion-framework-react-module-context';

const pbi_context_mapping = {
Facility: {
column: 'Facility',
table: 'Dim_Facility',
},
ProjectMaster: {
column: 'ProjectMaster GUID',
table: 'Dim_ProjectMaster',
},
} as const;

export const WorkspaceWrapper = () => {
const contextId = useContextId();
useCloseSidesheetOnContextChange();
const ccApi = useHttpClient();
const { bookmarkKey, currentBookmark, onBookmarkChange } = useWorkspaceBookmarks();

const pbi = usePBIOptions('cc-punch-analytics', {
column: 'ProjectMaster GUID',
table: 'Dim_ProjectMaster',
});
const { currentContext } = useModuleCurrentContext();

const pbi = usePBIOptions(
'cc-punch-analytics',
pbi_context_mapping[currentContext?.type.id as 'ProjectMaster' | 'Facility']
);

const filterConfig = useFilterConfig((req) =>
ccApi.fetch(`/api/contexts/${contextId}/punch/filter-model`, req)
Expand Down
2 changes: 1 addition & 1 deletion libs/swcrapp/src/lib/config/frameworkConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import buildQuery from 'odata-query';

export const configure = async (config: IAppConfigurator, c: ComponentRenderArgs) => {
enableContext(config, async (builder) => {
builder.setContextType(['ProjectMaster']);
builder.setContextType(['ProjectMaster', 'Facility']);
builder.setContextParameterFn(({ search, type }) => {
return buildQuery({
search,
Expand Down
22 changes: 18 additions & 4 deletions libs/swcrapp/src/lib/config/workspaceConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,30 @@ import { powerBiModule } from '@equinor/workspace-fusion/power-bi-module';
import { useGardenConfig } from './gardenConfig';
import { useStatusBarConfig } from './statusBarConfig';
import { useTableConfig } from './tableConfig';
import { useModuleCurrentContext } from '@equinor/fusion-framework-react-module-context';

const pbi_context_mapping = {
Facility: {
column: 'Facility',
table: 'Dim_Facility',
},
ProjectMaster: {
column: 'ProjectMaster GUID',
table: 'Dim_ProjectMaster',
},
} as const;

export const WorkspaceWrapper = () => {
const contextId = useContextId();
useCloseSidesheetOnContextChange();
const ccApi = useHttpClient();

const pbi = usePBIOptions('swcr-analytics', {
column: 'ProjectMaster GUID',
table: 'Dim_ProjectMaster',
});
const { currentContext } = useModuleCurrentContext();

const pbi = usePBIOptions(
'swcr-analytics',
pbi_context_mapping[currentContext?.type.id as 'ProjectMaster' | 'Facility']
);

const { bookmarkKey, currentBookmark, onBookmarkChange } = useWorkspaceBookmarks();

Expand Down
2 changes: 1 addition & 1 deletion libs/workorderapp/src/lib/config/frameworkConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import buildQuery from 'odata-query';

export const configure = async (config: IAppConfigurator, c: ComponentRenderArgs) => {
enableContext(config, async (builder) => {
builder.setContextType(['ProjectMaster']);
builder.setContextType(['ProjectMaster', 'Facility']);
builder.setContextParameterFn(({ search, type }) => {
return buildQuery({
search,
Expand Down
27 changes: 20 additions & 7 deletions libs/workorderapp/src/lib/config/workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
useHttpClient,
usePBIOptions,
useWorkspaceBookmarks,
useCloseSidesheetOnContextChange
useCloseSidesheetOnContextChange,
} from '@cc-components/shared';
import { useFilterConfig } from '@cc-components/shared/workspace-config';
import Workspace from '@equinor/workspace-fusion';
Expand All @@ -18,17 +18,32 @@ import { gridModule } from '@equinor/workspace-fusion/grid-module';
import { useStatusBarConfig } from './statusBarConfig';
import { useGardenConfig } from './gardenConfig';
import { CCApiAccessLoading } from '@cc-components/sharedcomponents';
import { useModuleCurrentContext } from '@equinor/fusion-framework-react-module-context';

const pbi_context_mapping = {
Facility: {
column: 'Facility',
table: 'Dim_Facility',
},
ProjectMaster: {
column: 'ProjectMaster GUID',
table: 'Dim_ProjectMaster',
},
} as const;

export const WorkspaceWrapper = () => {
const contextId = useContextId();
useCloseSidesheetOnContextChange();
const client = useHttpClient();
const { bookmarkKey, currentBookmark, onBookmarkChange } = useWorkspaceBookmarks();
const { isLoading } = useCCApiAccessCheck(contextId, client, 'work-orders');
const pbi = usePBIOptions('workorder-analytics', {
column: 'ProjectMaster GUID',
table: 'Dim_ProjectMaster',
});

const { currentContext } = useModuleCurrentContext();

const pbi = usePBIOptions(
'workorder-analytics',
pbi_context_mapping[currentContext?.type.id as 'ProjectMaster' | 'Facility']
);

const filterConfig = useFilterConfig((req) =>
client.fetch(`/api/contexts/${contextId}/work-orders/filter-model`, req)
Expand All @@ -37,12 +52,10 @@ export const WorkspaceWrapper = () => {
const statusBarConfig = useStatusBarConfig(contextId);
const gardenConfig = useGardenConfig(contextId);


if (isLoading) {
return <CCApiAccessLoading />;
}


return (
<>
<Workspace
Expand Down

0 comments on commit d54b555

Please sign in to comment.