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

Add 'Execute' tab to Digital Twins page preview #903

Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
699a0dc
manual rebase in progress
prasadtalasila Sep 9, 2024
25158f3
manual rebase in progress
prasadtalasila Sep 9, 2024
3dcbd9b
completes manual rebase
prasadtalasila Sep 9, 2024
eccae19
Delete old components
Sep 10, 2024
4b54723
Add properties to gitlabDigitalTwin
Sep 10, 2024
e3bce4c
Add unit tests
Sep 10, 2024
3ab550f
Complete documentation
Sep 10, 2024
447ff03
Fix codeclimate issues
Sep 10, 2024
2f5d458
Refactor ExecutionFunctions
Sep 10, 2024
656ca9a
Remove strip-ansi and add instructions to gitlab-runner
VanessaScherma Sep 12, 2024
5ba4ebf
Apply comments
Sep 13, 2024
b56730b
Start unit testing and use preview folders
Sep 14, 2024
a43f972
Add Manage tab files
Sep 10, 2024
577b320
Change components and use redux
Sep 11, 2024
39d8deb
Update unit tests
Sep 11, 2024
afe4d4f
Format
Sep 11, 2024
34a9709
Fix codeclimate issues
Sep 11, 2024
38c0329
Use remarkable library
Sep 15, 2024
f3bb71d
Add Reconfigure Dialog
Sep 16, 2024
3b66b29
Complete Reconfigure dialog
Sep 18, 2024
684b4f2
Unit testing
Sep 21, 2024
cbe3946
Add unit tests and refactor
VanessaScherma Sep 24, 2024
be7d442
Deletes unused DT manage code
prasadtalasila Sep 24, 2024
94bded4
Update unit testing
Sep 27, 2024
4d9f2d3
Add integration tests
Sep 29, 2024
7c43821
Fix codeclimate issues
VanessaScherma Sep 30, 2024
556b807
Add integration tests
VanessaScherma Oct 1, 2024
749f344
Add integration tests
Oct 3, 2024
c24958e
Fix codeclimate issue
Oct 3, 2024
bbf071b
Checkout files from feature/distributed-demo
Oct 3, 2024
30088d6
Resolve conflicts
Oct 3, 2024
10fef9e
Resolve conflicts
Oct 3, 2024
6465b26
Resolve conflicts
Oct 3, 2024
3552dfe
Resolve yarn.lock conflict
Oct 3, 2024
c892111
Resolve yarn.lock conflict
Oct 3, 2024
eae696e
Checkout yarn.lock
Oct 3, 2024
388d36f
Resolve review comments
Oct 4, 2024
4ce2ff4
Checkout files from feature/distributed-demo branch
Oct 5, 2024
458eb2f
Use pipeline names instead of pipeline id in stop function
Oct 5, 2024
2935ecd
Update unit test
Oct 5, 2024
9e6a62c
Move gitlabDriver.ts into preview folder
Oct 5, 2024
76709d5
Configuration fix
Oct 5, 2024
acb33e0
Configuration fix
Oct 5, 2024
60d6723
Checkout yarn.lock
Oct 5, 2024
44b3038
Merge branch 'feature/distributed-demo' into execute-DTs-on-gitlab
VanessaScherma Oct 5, 2024
a3d1925
Little fix in gitlabDriver.ts
Oct 5, 2024
a445cf5
Update .eslintignore
Oct 6, 2024
9938e33
Update package.json and jest.config.json
Oct 6, 2024
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
16 changes: 16 additions & 0 deletions client/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ if (typeof window !== 'undefined') {
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: '',
REACT_APP_WORKBENCHLINK_DT_PREVIEW: '/preview/digitaltwins',

REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c',
REACT_APP_AUTH_AUTHORITY: 'https://gitlab.com/',
Expand Down Expand Up @@ -140,6 +141,7 @@ if (typeof window !== 'undefined') {
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: '',
REACT_APP_WORKBENCHLINK_DT_PREVIEW: '/preview/digitaltwins',

REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c',
REACT_APP_AUTH_AUTHORITY: 'https://gitlab.com/',
Expand Down Expand Up @@ -197,6 +199,12 @@ api, read_api, read_user, create_runner, k8s_proxy, read_repository, write_repos

The token information needs to be updated in `config/gitlab.json`.

In addition to the personal access token, you also need to create a
[pipeline trigger token](https://archives.docs.gitlab.com/16.4/ee/ci/triggers/index.html).
This token is required to trigger pipelines by using the API.
You can create this token in your GitLab project's CI/CD settings under
the *Pipeline trigger tokens* section.

Once the token configuration is in place, the gitlab code can be developed
and tested using the following yarn commands.

Expand Down Expand Up @@ -230,3 +238,11 @@ Execution Logs: [
}
]
```

## Digital Twins page preview

In the Workbench section, there is a link to preview the **Digital Twins**
page. The GitLab account used as OAuth provider must have a *DTaaS* group,
a project under your username, and a *digital_twins* folder which contains
the Digital Twins. From this interface, you can start or stop execution of
Digital Twins, and once the execution is complete, view the complete logs.
35 changes: 35 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,38 @@ This error is expected.
If you would like to try the complete DTaaS application, please see
localhost installation in
[docs](https://into-cps-association.github.io/DTaaS/development/admin/localhost.html).

## Gitlab Runner configuration

To properly use the Digital Twins page preview, you need to configure at least
one project runner in your GitLab profile. Follow the steps below:

1. Login to the GitLab profile that will be used as the OAuth provider.

1. Navigate to the *DTaaS* group and select the project named after your
GitLab username.

1. In the project menu, go to Settings and select CI/CD.

1. Expand the **Runners** section and click on *New project runner*. Follow the
configuration instructions carefully:
- Add **linux** as a tag during configuration.
- Click on *Create runner*.
- Ensure GitLab Runner is installed before proceeding. Depending on your
environment, you will be shown the correct command to install GitLab Runner.
- Once GitLab Runner is installed, follow these steps to register the runner:
- Copy and paste the command shown in the GitLab interface into your command
line to register the runner. It includes a URL and a token for your specific
GitLab instance.
- Choose *docker* as executor when prompted by the command line.
- Choose the default docker image. You must use an image based on Linux,
like the default one (*ruby:2.7*).

You can manually verify that the runner is available to pick up jobs by running
the following command:

```bash
sudo gitlab-runner run
```

It can also be used to reactivate offline runners during subsequent sessions.
1 change: 1 addition & 0 deletions client/config/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if (typeof window !== 'undefined') {
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: '',
REACT_APP_WORKBENCHLINK_DT_PREVIEW: '/preview/digitaltwins',

REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c',
REACT_APP_AUTH_AUTHORITY: 'https://gitlab.foo.com/',
Expand Down
1 change: 1 addition & 0 deletions client/config/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if (typeof window !== 'undefined') {
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: '',
REACT_APP_WORKBENCHLINK_DT_PREVIEW: '/preview/digitaltwins',

REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c',
REACT_APP_AUTH_AUTHORITY: 'https://gitlab.com/',
Expand Down
1 change: 1 addition & 0 deletions client/config/prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if (typeof window !== 'undefined') {
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: '',
REACT_APP_WORKBENCHLINK_DT_PREVIEW: '/preview/digitaltwins',

REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c',
REACT_APP_AUTH_AUTHORITY: 'https://gitlab.com/',
Expand Down
5 changes: 3 additions & 2 deletions client/config/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ if (typeof window !== 'undefined') {
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: '',
REACT_APP_WORKBENCHLINK_DT_PREVIEW: '/preview/digitaltwins',

REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c',
REACT_APP_AUTH_AUTHORITY: 'https://gitlab.com/',
REACT_APP_CLIENT_ID: '38bf4764fad5ebb2ebbf49b4f57c7720145b61266f13bf4891ff7851dd5c6563',
VanessaScherma marked this conversation as resolved.
Show resolved Hide resolved
REACT_APP_AUTH_AUTHORITY: 'https://maestro.cps.digit.au.dk/gitlab',
REACT_APP_REDIRECT_URI: 'http://localhost:4000/Library',
REACT_APP_LOGOUT_REDIRECT_URI: 'http://localhost:4000/',
REACT_APP_GITLAB_SCOPES: 'openid profile read_user read_repository api',
Expand Down
1 change: 1 addition & 0 deletions client/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ declare global {
REACT_APP_WORKBENCHLINK_VSCODE: string;
REACT_APP_WORKBENCHLINK_JUPYTERLAB: string;
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: string;
REACT_APP_WORKBENCHLINK_DT_PREVIEW: string;

REACT_APP_CLIENT_ID: string;
REACT_APP_AUTH_AUTHORITY: string;
Expand Down
14 changes: 10 additions & 4 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@into-cps-association/dtaas-web",
"version": "0.4.0",
"version": "0.4.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 0.5.0

"description": "Web client for Digital Twin as a Service (DTaaS)",
"main": "index.tsx",
"author": "prasadtalasila <[email protected]> (http://prasad.talasila.in/)",
Expand All @@ -16,7 +16,7 @@
"type": "module",
"scripts": {
"build": "npx shx cp config/gitlab.json src/util/gitlab.json && npx react-scripts build && npx rimraf src/util/gitlab.json",
"clean": "npx rimraf build/ dist/ node_modules/ coverage/ playwright-report/ *.svg src/util/gitlab.json",
"clean": "npx rimraf build/ dist/ node_modules/ coverage/ playwright-report/ test-results/ *.svg src/util/gitlab.json",
"config:dev": "npx shx cp config/dev.js public/env.js && npx shx cp config/dev.js build/env.js",
"config:local": "npx shx cp config/local.js public/env.js && npx shx cp config/local.js build/env.js",
"config:prod": "npx shx cp config/prod.js public/env.js && npx shx cp config/prod.js build/env.js",
Expand All @@ -30,9 +30,12 @@
"stop": "npx kill-port 4000",
"syntax": "npx eslint . --fix",
"test:all": "yarn test:unit && yarn test:int && yarn test:e2e",
"test:e2e": "yarn build && yarn config:test && npx kill-port 4000 && yarn start >/dev/null & playwright test && npx kill-port 4000",
"test:e2e:ext": "cross-env ext=true yarn test:e2e",
"test:e2e": "playwright test -c ./playwright.config.ts",
"test:int": "jest -c ./jest.config.json ../test/integration --setupFilesAfterEnv ./test/integration/jest.setup.ts",
"test:unit": "jest -c ./jest.config.json ../test/unit --setupFilesAfterEnv ./test/unit/jest.setup.ts"
"test:unit": "jest -c ./jest.config.json ../test/unit --setupFilesAfterEnv ./test/unit/jest.setup.ts",
"test:preview:int": "jest -c ./jest.config.json ../test/preview/integration --setupFilesAfterEnv ./test/preview/integration/jest.setup.ts",
"test:preview:unit": "jest -c ./jest.config.json ../test/preview/unit --setupFilesAfterEnv ./test/preview/unit/jest.setup.ts"
},
"eslintConfig": {
"extends": [
Expand All @@ -53,6 +56,7 @@
"@types/styled-components": "^5.1.32",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"cross-env": "^7.0.3",
"dotenv": "^16.1.4",
"eslint": "8.54.0",
"eslint-config-airbnb-base": "^15.0.0",
Expand All @@ -71,6 +75,7 @@
"react-redux": "^8.1.3",
"react-router-dom": "^6.20.0",
"react-scripts": "^5.0.1",
"react-syntax-highlighter": "^15.5.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not required in this PR

"react-tabs": "^6.0.2",
"redux": "^4.2.1",
"resize-observer-polyfill": "^1.5.1",
Expand All @@ -92,6 +97,7 @@
"@types/react-dom": "^18.2.17",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"monocart-coverage-reports": "^2.10.2",
"playwright": "^1.32.1",
"prettier": "^3.2.4",
"shx": "^0.3.4",
Expand Down
5 changes: 5 additions & 0 deletions client/src/components/LinkIconsLib.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import NoteAltOutlinedIcon from '@mui/icons-material/NoteAltOutlined';
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
import GitHubIcon from '@mui/icons-material/GitHub';
import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
import TabIcon from '@mui/icons-material/Tab';

type LinkIconsType = {
[key: string]: { icon: React.ReactElement; name: string | undefined };
Expand All @@ -28,6 +29,10 @@ const LinkIcons: LinkIconsType = {
icon: <NoteAltOutlinedIcon />,
name: 'Jupyter Notebook',
},
DT_PREVIEW: {
icon: <TabIcon />,
name: 'Digital Twins page preview',
},
GITHUB: {
icon: <GitHubIcon />,
name: 'ToolbarIcon',
Expand Down
5 changes: 5 additions & 0 deletions client/src/preview/components/asset/Asset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface Asset {
name: string;
description?: string;
path: string;
}
71 changes: 71 additions & 0 deletions client/src/preview/components/asset/AssetBoard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import * as React from 'react';
import { Grid } from '@mui/material';
import { useDispatch, useSelector } from 'react-redux';
import { RootState } from 'store/store';
import { deleteAsset } from 'store/assets.slice';
import { AssetCardExecute } from './AssetCard';
import { Asset } from './Asset';

const outerGridContainerProps = {
container: true,
spacing: 2,
sx: {
justifyContent: 'flex-start',
overflow: 'auto',
maxHeight: 'inherent',
marginTop: 2,
},
};

interface AssetBoardProps {
tab: string;
error: string | null;
}

const AssetGridItem: React.FC<{
asset: Asset;
tab: string;
onDelete: (path: string, dispatch: ReturnType<typeof useDispatch>) => void;
}> = ({ asset }) => (
<Grid
key={asset.path}
item
xs={12}
sm={6}
md={4}
lg={3}
sx={{ minWidth: 250 }}
>
<AssetCardExecute asset={asset} />
</Grid>
);

export const handleDelete =
VanessaScherma marked this conversation as resolved.
Show resolved Hide resolved
(deletedAssetPath: string, dispatch: ReturnType<typeof useDispatch>) =>
() => {
dispatch(deleteAsset(deletedAssetPath));
};

const AssetBoard: React.FC<AssetBoardProps> = ({ tab, error }) => {
const assets = useSelector((state: RootState) => state.assets.items);
const dispatch = useDispatch();

if (error) {
return <em style={{ textAlign: 'center' }}>{error}</em>;
}

return (
<Grid {...outerGridContainerProps}>
{assets.map((asset: Asset) => (
<AssetGridItem
key={asset.path}
asset={asset}
tab={tab}
onDelete={handleDelete(asset.path, dispatch)}
VanessaScherma marked this conversation as resolved.
Show resolved Hide resolved
/>
))}
</Grid>
);
};

export default AssetBoard;
Loading
Loading