Skip to content

Commit

Permalink
Feat/implement pipingapp (#701)
Browse files Browse the repository at this point in the history
* feat: initial commit

* update gitignore

* wip

* wip

* wip: garden, sidesheet

* feat: ✨ add workorder tab in sidesheet

* feat: ✨ add Insulation tab

* Insulation table header

* forgot to change to h4

* feat: ✨ add Checklist tab

* need to commit before merge

* feat: ✨ update fusion workspace to 2.1.4

* feat: ✨ update api-calls

* feat: ✨ add the rest of the app

* merge with main

* feat: ✨ connect backend and frontend

* fix pr feedback

* change appname in package.json
  • Loading branch information
MagnusGjosund committed Nov 20, 2023
1 parent ef82313 commit 3ba1383
Show file tree
Hide file tree
Showing 55 changed files with 3,134 additions and 3,375 deletions.
3 changes: 3 additions & 0 deletions apps/piping/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Version 0.0.1

Init app
3 changes: 3 additions & 0 deletions apps/piping/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# piping

Add readme
15 changes: 15 additions & 0 deletions apps/piping/app.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { readFileSync } from 'fs';

const { name } = JSON.parse(readFileSync('./package.json').toString('utf-8'));

export default () => ({
manifest: {
key: name,
name: name,
},
environment: {
uri: 'https://backend-fusion-data-gateway-test.radix.equinor.com',
defaultScopes: ['api://ed6de162-dd30-4757-95eb-0ffc8d34fbe0/access_as_user'],
},
endpoints: {},
});
15 changes: 15 additions & 0 deletions apps/piping/app.config.local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { readFileSync } from 'fs';

const { name } = JSON.parse(readFileSync('./package.json').toString('utf-8'));

export default () => ({
manifest: {
key: name,
name: name,
},
environment: {
uri: 'https://localhost:7074',
defaultScopes: ['api://ed6de162-dd30-4757-95eb-0ffc8d34fbe0/access_as_user'],
},
endpoints: {},
});
23 changes: 23 additions & 0 deletions apps/piping/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "pipetest",
"displayName": "Pipetest",
"version": "0.0.1",
"main": "/src/main.tsx",
"private": true,
"type": "module",
"scripts": {
"dev": "fusion-framework-cli app dev",
"dev:local": "fusion-framework-cli app dev -c app.config.local.js",
"build": "tsc -b -f",
"pr:deploy": "npx ts-node --esm ../../github-action/src/releasePr.ts release",
"fprd:deploy": "npx ts-node --esm ../../github-action/src/releaseMain.ts release"
},
"dependencies": {
"@cc-components/pipingapp": "workspace:^",
"@cc-components/shared": "workspace:^"
},
"files": [
"dist/app-bundle.js",
"app-manifest.json"
]
}
Empty file added apps/piping/prod.skip
Empty file.
15 changes: 15 additions & 0 deletions apps/piping/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { configure, WorkspaceWrapper } from '@cc-components/pipingapp';
import { useHttpClient } from '@equinor/fusion-framework-react-app/http';
import { createRender, RootAppWrapper } from '@cc-components/shared';

const PipingApp = () => {
const client = useHttpClient('cc-api');
return (
<RootAppWrapper client={client}>
<WorkspaceWrapper />
</RootAppWrapper>
);
};

export const render = createRender(PipingApp, configure, 'Piping');
export default render;
22 changes: 22 additions & 0 deletions apps/piping/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"types": ["node"],
"rootDir": "."
},
"exclude": [
"jest.config.ts",
"**/*.spec.ts",
"**/*.test.ts",
"**/*.spec.tsx",
"**/*.test.tsx",
"**/*.spec.js",
"**/*.test.js",
"**/*.spec.jsx",
"**/*.test.jsx",
"dist",
"vite.config.ts"
],
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
}
22 changes: 22 additions & 0 deletions apps/piping/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
}
]
}
19 changes: 19 additions & 0 deletions apps/piping/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from 'vite';
import EnvironmentPlugin from 'vite-plugin-environment';

export default defineConfig({
plugins: [
EnvironmentPlugin({
NODE_ENV: 'production',
}),
],
appType: 'custom',
build: {
emptyOutDir: true,
lib: {
entry: './src/main.tsx',
fileName: 'app-bundle',
formats: ['es'],
},
},
});
2 changes: 0 additions & 2 deletions libs/loopsidesheet/src/lib/ui-sidesheet/LoopSidesheet.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Loop } from '@cc-components/loopshared';
import { createWidget } from '@cc-components/shared';

import { useState } from 'react';
import { DetailsTab } from './DetailsTab';
import { Tabs } from '@equinor/eds-core-react';

import { useGetWorkorders } from '../utils-sidesheet';
import { Checklists } from './Checklists';
import { ContentDetails } from './ContentDetails';
Expand Down
3 changes: 3 additions & 0 deletions libs/pipingapp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# pipingapp

Add readme
17 changes: 17 additions & 0 deletions libs/pipingapp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@cc-components/pipingapp",
"version": "0.0.1",
"type": "module",
"scripts": {
"build": "tsc -b"
},
"module": "./dist/src/index.js",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"dependencies": {
"@cc-components/shared": "workspace:^",
"@cc-components/sharedcomponents": "workspace:^",
"@cc-components/pipingshared": "workspace:^",
"@cc-components/pipingsidesheet": "workspace:^"
}
}
1 change: 1 addition & 0 deletions libs/pipingapp/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib';
41 changes: 41 additions & 0 deletions libs/pipingapp/src/lib/config/frameworkConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {
IAppConfigurator,
ComponentRenderArgs,
} from '@equinor/fusion-framework-react-app';
import { enableContext } from '@equinor/fusion-framework-react-module-context';
import buildQuery from 'odata-query';
import { enableAgGrid } from '@equinor/fusion-framework-module-ag-grid';

export const configure = async (config: IAppConfigurator, c: ComponentRenderArgs) => {
enableContext(config, async (builder) => {
builder.setContextType(['ProjectMaster']);
builder.setContextParameterFn(({ search, type }) => {
return buildQuery({
search,
filter: {
type: {
in: type,
},
},
});
});
});
// Add more config if needed, e.g. enableAgGrid

const envConfig: PipingEnvConfig = c.env.config?.environment as PipingEnvConfig;

if (!envConfig) {
throw new Error('Failed to load environemnt config for workorder');
}
config.configureHttpClient('cc-api', {
baseUri: envConfig?.uri,
defaultScopes: envConfig?.defaultScopes,
});

enableAgGrid(config);
};

type PipingEnvConfig = {
uri: string;
defaultScopes: string[];
};
34 changes: 34 additions & 0 deletions libs/pipingapp/src/lib/config/gardenConfig.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Pipetest } from '@cc-components/pipingshared';
import { useHttpClient } from '@cc-components/shared';
import { FilterState } from '@equinor/workspace-fusion/filter';
import { GardenConfig } from '@equinor/workspace-fusion/garden';
import { useGardenDataSource } from '@cc-components/shared/workspace-config';
import { GardenItem } from '../ui-garden';

export const useGardenConfig = (
contextId: string
): GardenConfig<Pipetest, FilterState> => {
const client = useHttpClient();
const { getBlockAsync, getGardenMeta, getHeader, getSubgroupItems } =
useGardenDataSource({
getBlockAsync: (req) =>
client.fetch(`/api/contexts/${contextId}/pipetest/garden`, req),
getGardenMeta: (req) =>
client.fetch(`/api/contexts/${contextId}/pipetest/garden-meta`, req),
getHeader: (req) => client.fetch(`/api/contexts/${contextId}/pipetest/garden`, req),
getSubgroupItems: (req) =>
client.fetch(`/api/contexts/${contextId}/pipetest/subgroup-items`, req),
});

return {
getBlockAsync,
getGardenMeta,
getHeader,
getSubgroupItems,
getDisplayName: (item) => item.id,
initialGrouping: ['Priority1'],
customViews: {
customItemView: GardenItem,
},
};
};
2 changes: 2 additions & 0 deletions libs/pipingapp/src/lib/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { WorkspaceWrapper } from './workspaceConfig';
export { configure } from './frameworkConfig';
10 changes: 10 additions & 0 deletions libs/pipingapp/src/lib/config/pipingSidesheet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SidesheetConfig } from '@equinor/workspace-fusion/sidesheet';
import { Pipetest } from '@cc-components/pipingshared';
import { PipingSidesheet } from '@cc-components/pipingsidesheet';

export const sidesheetConfig: SidesheetConfig<Pipetest> = {
type: 'default',
DetailsSidesheet: (props) => (
<PipingSidesheet.Component id={props.id} item={props.item} close={props.close} />
),
};
20 changes: 20 additions & 0 deletions libs/pipingapp/src/lib/config/statusBarConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { StatusBarConfig } from '@equinor/workspace-fusion/status-bar';
import { useHttpClient } from '@equinor/fusion-framework-react-app/http';

export const useStatusBarConfig = (contextId: string): StatusBarConfig => {
const client = useHttpClient('cc-api');

return async (filters, signal) => {
const res = await client.fetch(`/api/contexts/${contextId}/pipetest/kpis`, {
method: 'POST',
body: JSON.stringify({
filter: filters,
}),
signal,
headers: {
['content-type']: 'application/json',
},
});
return (await res.json()).map((s: any) => ({ ...s, title: s.name }));
};
};
92 changes: 92 additions & 0 deletions libs/pipingapp/src/lib/config/tableConfig.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { ColDef, GridConfig, ICellRendererProps } from '@equinor/workspace-fusion/grid';
import { CheckList, Pipetest } from '@cc-components/pipingshared';
import { FilterState } from '@equinor/workspace-fusion/filter';
import {
defaultGridOptions,
useGridDataSource,
} from '@cc-components/shared/workspace-config';
import {
DateCell,
DescriptionCell,
StyledMonospace,
useHttpClient,
} from '@cc-components/shared';
import { generateCommaSeperatedStringArrayColumn } from '../utils-table/generateCommaSeperatedStringArrayColumn';
import { getHTList } from '../utils-table/tableHelpers';

export const useTableConfig = (contextId: string): GridConfig<Pipetest, FilterState> => {
const client = useHttpClient();

const { getRows, colDefs } = useGridDataSource<Pipetest>(async (req) => {
const res = await client.fetch(`/api/contexts/${contextId}/pipetest/grid`, req);
const meta = await res.json();

return {
rowCount: meta.rowCount,
items: meta.items,
columnDefinitions: meta.columnDefinitions,
};
}, columnDefinitions);
return {
gridOptions: {
...defaultGridOptions,
onFirstDataRendered: (e) => {
e.columnApi.autoSizeColumns(
e.columnApi
.getAllDisplayedColumns()
.filter((column) => column.getColId() !== 'description')
);
},
},
getRows: getRows,
columnDefinitions: colDefs as [ColDef<Pipetest>, ...ColDef<Pipetest>[]],
};
};

const columnDefinitions: [ColDef<Pipetest>, ...ColDef<Pipetest>[]] = [
{
headerName: 'Pipetest',
valueGetter: (pkg) => pkg.data?.id,
cellRenderer: (props: ICellRendererProps<Pipetest, string>) => {
return <StyledMonospace>{props.value}</StyledMonospace>;
},
},
{
headerName: 'Description',
colId: 'description',
valueGetter: (pkg) => pkg.data?.description,
cellRenderer: (props: ICellRendererProps<Pipetest, string | null>) => {
return <DescriptionCell description={props.value} />;
},
width: 300,
},
{ headerName: 'Priority', valueGetter: (pkg) => pkg.data?.commPkPriority1 },
{
headerName: 'Location',
valueGetter: (pkg) => pkg.data?.location,
cellRenderer: (props: ICellRendererProps<Pipetest, string>) => {
return <StyledMonospace>{props.value}</StyledMonospace>;
},
},
{ headerName: 'Checklist status', valueGetter: (pkg) => 't.b.d :D' },
{ headerName: 'Current step', valueGetter: (pkg) => 't.b.d :D' },
{
headerName: 'RFC',
valueGetter: (pkg) => pkg.data?.rfccPlanned,
cellRenderer: (props: ICellRendererProps<Pipetest, string | null | undefined>) => {
return props.value ? <DateCell dateString={props.value} /> : null;
},
},
{
headerName: 'HT cables',
valueGetter: (pkg) => pkg.data?.checkLists,
cellRenderer: (props: ICellRendererProps<Pipetest, CheckList[]>) => {
if (!props.value) return null;
return (
<StyledMonospace>
{generateCommaSeperatedStringArrayColumn(getHTList(props.value))}
</StyledMonospace>
);
},
},
];
Loading

0 comments on commit 3ba1383

Please sign in to comment.