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 Library page preview #1081

Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
d2a6df7
Start create page
VanessaScherma Oct 25, 2024
d9a9a4b
Complete start page
VanessaScherma Oct 25, 2024
92cb369
Little fix
VanessaScherma Oct 25, 2024
2bacabe
Move field for DT name
VanessaScherma Oct 26, 2024
d50cae0
Fix reconfigure
VanessaScherma Oct 26, 2024
5395574
Refactor gitlabDigitalTwin
VanessaScherma Oct 27, 2024
53c3e30
Fix codeclimate issue (gitlabDigitalTwin)
VanessaScherma Oct 27, 2024
41a36cb
Refactor CreatePage
VanessaScherma Oct 27, 2024
5051ce2
Refactor CreatePage
VanessaScherma Oct 28, 2024
39fc69a
Refactor Create dialogs
VanessaScherma Oct 28, 2024
a18bca8
Fix codeclimate issues
VanessaScherma Oct 28, 2024
fc573bb
Refactor Sidebar
VanessaScherma Oct 28, 2024
fbaf9b7
Fix codeclimate issues
VanessaScherma Oct 28, 2024
47a66e4
Fix codeclimate issues
VanessaScherma Oct 28, 2024
1949343
Apply changes and refactor
VanessaScherma Oct 31, 2024
ed8fa36
Remove duplication from files reducers
VanessaScherma Oct 31, 2024
16093b1
Apply requested changes
VanessaScherma Nov 1, 2024
511d5c3
Fix and add unit tests
Nov 5, 2024
f79f9f9
Fix integration tests
Nov 6, 2024
e60abe5
Apply requested changes
Nov 7, 2024
89cd7d6
Add integration tests
Nov 7, 2024
3148f9b
rebase
Nov 7, 2024
cb476a6
Little fix
Nov 7, 2024
6c71a0d
Little fix
Nov 7, 2024
0c00214
Refactor DigitalTwin class and add DTAssets class
Nov 8, 2024
1c4f56b
Update unit tests
Nov 9, 2024
cea5cd1
Upgrade integration tests
Nov 9, 2024
74d6255
Add Library page
Nov 12, 2024
934d6a8
Fetch library assets from GitLab
Nov 13, 2024
b9d1088
Add description and fullDescription in Library page
Nov 13, 2024
e9b87ae
Update ShoppingCart
Nov 13, 2024
2c0823a
Add LibraryManager
VanessaScherma Nov 15, 2024
2a26f28
Integration with Create page
VanessaScherma Nov 17, 2024
3647621
Integration with Reconfigure feature
VanessaScherma Nov 18, 2024
9fc8fbd
Add LIBRARY_PREVIEW to env and workbench
VanessaScherma Nov 18, 2024
53ecac9
Fix eslint errors
VanessaScherma Nov 18, 2024
57cb63a
Fix documentation (#1057)
prasadtalasila Nov 10, 2024
30642ee
Add Create tab into Digital Twins page preview (#1005)
VanessaScherma Nov 14, 2024
f69013f
Increments version of client package (#1060)
prasadtalasila Nov 14, 2024
cd84528
Fixes the stalling container (#1063)
atomicgamedeveloper Nov 16, 2024
8172f40
Start create page
VanessaScherma Oct 25, 2024
0f18489
Complete start page
VanessaScherma Oct 25, 2024
0e919f4
Little fix
VanessaScherma Oct 25, 2024
7cd4c66
Refactor CreatePage
VanessaScherma Oct 27, 2024
2658fec
Refactor Create dialogs
VanessaScherma Oct 28, 2024
064c4c9
Fix codeclimate issues
VanessaScherma Oct 28, 2024
8edf9ba
Refactor Sidebar
VanessaScherma Oct 28, 2024
d87d6b2
Fix codeclimate issues
VanessaScherma Oct 28, 2024
373aa54
Fix codeclimate issues
VanessaScherma Oct 28, 2024
9259340
Apply changes and refactor
VanessaScherma Oct 31, 2024
e4a3b82
Remove duplication from files reducers
VanessaScherma Oct 31, 2024
94f7928
Apply requested changes
VanessaScherma Nov 1, 2024
597dc8b
Fix and add unit tests
Nov 5, 2024
90c3901
Fix integration tests
Nov 6, 2024
4d3f1b0
Apply requested changes
Nov 7, 2024
4b18766
Add integration tests
Nov 7, 2024
f751543
rebase
Nov 7, 2024
fd38a16
Little fix
Nov 7, 2024
ddff637
Refactor DigitalTwin class and add DTAssets class
Nov 8, 2024
6e6f8c1
Upgrade integration tests
Nov 9, 2024
8bfce83
Integration with Create page
VanessaScherma Nov 17, 2024
bb07b52
Fix after rebase
VanessaScherma Nov 18, 2024
f6c3438
Graphical fix
VanessaScherma Nov 24, 2024
9d9757e
Improve Create page layout
VanessaScherma Nov 24, 2024
c1dc662
Add APIs to manage common DTs
VanessaScherma Nov 24, 2024
2348976
Library graphical fix
VanessaScherma Nov 24, 2024
3f27ee8
Sidebar refactor
VanessaScherma Nov 25, 2024
9d9f5d9
Merge branch 'feature/distributed-demo' into library
VanessaScherma Nov 28, 2024
55e9b14
updates
VanessaScherma Nov 29, 2024
62bc020
Fix eslint issues
VanessaScherma Dec 1, 2024
3344fb3
Rephrasing terms
VanessaScherma Dec 1, 2024
517aaf8
use 'common' project in Library page
VanessaScherma Dec 2, 2024
c584c31
use 'common' project in Create page
VanessaScherma Dec 3, 2024
c2a108c
use 'common' in Reconfigure page
VanessaScherma Dec 3, 2024
95c78d8
fix eslint issues
VanessaScherma Dec 3, 2024
67b09ed
Fix previous unit tests
Dec 4, 2024
882b72e
Fix previous integration tests
Dec 4, 2024
fb0aa62
Add unit tests
Dec 6, 2024
b880164
Add integration tests
Dec 6, 2024
11f9bf0
Remove useAuth and useGetAndSetUsername from LibraryContent
VanessaScherma Dec 6, 2024
2ad41bc
Remove reselect
VanessaScherma Dec 6, 2024
07d9032
Add reselect
VanessaScherma Dec 6, 2024
80b350c
Remove common/private selector from Create page
Dec 6, 2024
14476fa
Merge branch 'library' of https://github.com/VanessaScherma/DTaaS int…
Dec 6, 2024
a6e052f
Fix warning and console.error in tests
Dec 6, 2024
ad67e7e
Delete unnecessary tests
Dec 6, 2024
134ad89
Change package version
Dec 6, 2024
6769f16
Fix bugs
Dec 7, 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
2 changes: 2 additions & 0 deletions client/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ if (typeof window !== 'undefined') {
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: '',
REACT_APP_WORKBENCHLINK_LIBRARY_PREVIEW: '/preview/library',
REACT_APP_WORKBENCHLINK_DT_PREVIEW: '/preview/digitaltwins',

REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c',
Expand Down Expand Up @@ -148,6 +149,7 @@ if (typeof window !== 'undefined') {
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: '',
REACT_APP_WORKBENCHLINK_LIBRARY_PREVIEW: '/preview/library',
REACT_APP_WORKBENCHLINK_DT_PREVIEW: '/preview/digitaltwins',

REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c',
Expand Down
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_LIBRARY_PREVIEW: '/preview/library',
REACT_APP_WORKBENCHLINK_DT_PREVIEW: '/preview/digitaltwins',

REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c',
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_LIBRARY_PREVIEW: '/preview/library',
REACT_APP_WORKBENCHLINK_DT_PREVIEW: '/preview/digitaltwins',

REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c',
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_LIBRARY_PREVIEW: '/preview/library',
REACT_APP_WORKBENCHLINK_DT_PREVIEW: '/preview/digitaltwins',

REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c',
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,10 +9,11 @@ if (typeof window !== 'undefined') {
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: '',
REACT_APP_WORKBENCHLINK_LIBRARY_PREVIEW: '/preview/library',
REACT_APP_WORKBENCHLINK_DT_PREVIEW: '/preview/digitaltwins',

REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c',
REACT_APP_AUTH_AUTHORITY: 'https://gitlab.com/',
REACT_APP_CLIENT_ID: '38bf4764fad5ebb2ebbf49b4f57c7720145b61266f13bf4891ff7851dd5c6563',
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_LIBRARY_PREVIEW: string;
REACT_APP_WORKBENCHLINK_DT_PREVIEW: string;

REACT_APP_CLIENT_ID: string;
Expand Down
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"redux": "^5.0.1",
"remarkable": "^2.0.1",
"remarkable-katex": "^1.2.1",
"reselect": "^5.1.1",
prasadtalasila marked this conversation as resolved.
Show resolved Hide resolved
"resize-observer-polyfill": "^1.5.1",
"serve": "^14.2.1",
"styled-components": "^6.1.1",
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 @@ -7,6 +7,7 @@ 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';
import LibraryBooksOutlined from '@mui/icons-material/LibraryBooksOutlined';

type LinkIconsType = {
[key: string]: { icon: React.ReactElement; name: string | undefined };
Expand All @@ -29,6 +30,10 @@ const LinkIcons: LinkIconsType = {
icon: <NoteAltOutlinedIcon />,
name: 'Jupyter Notebook',
},
LIBRARY_PREVIEW: {
icon: <LibraryBooksOutlined />,
name: 'Library page preview',
},
DT_PREVIEW: {
icon: <TabIcon />,
name: 'Digital Twins page preview',
Expand Down
46 changes: 46 additions & 0 deletions client/src/preview/components/asset/AddToCartButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import * as React from 'react';
import { Button } from '@mui/material';
import LibraryAsset from 'preview/util/libraryAsset';
import useCart from 'preview/store/CartAccess';
import { useSelector } from 'react-redux';
import { selectAssetByPath } from 'preview/store/assets.slice';

interface AddToCartButtonProps {
assetPath: string;
}

function AddToCartButton({ assetPath }: AddToCartButtonProps) {
const { state: cartState, actions } = useCart();
const asset = useSelector(selectAssetByPath(assetPath)) as LibraryAsset;

const isInCart = cartState.assets.some(
(item: LibraryAsset) => item.path === asset.path,
);

const handleAddToCart = async () => {
actions.add(asset);
};

const handleRemoveFromCart = async () => {
actions.remove(asset);
};

return (
<Button
variant="contained"
size="small"
color="primary"
onClick={() => {
if (isInCart) {
handleRemoveFromCart();
} else {
handleAddToCart();
}
}}
>
{isInCart ? 'Remove' : 'Add'}
</Button>
);
}

export default AddToCartButton;
6 changes: 6 additions & 0 deletions client/src/preview/components/asset/Asset.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import GitlabInstance from 'preview/util/gitlab';

export interface Asset {
name: string;
path: string;
type: string;
isPrivate: boolean;
gitlabInstance?: GitlabInstance;
fullDescription?: string;
}
75 changes: 59 additions & 16 deletions client/src/preview/components/asset/AssetBoard.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import * as React from 'react';
import { Grid } from '@mui/material';
import { Grid, CircularProgress } from '@mui/material';
import { useSelector, useDispatch } from 'react-redux';
import {
deleteAsset,
selectAssetsByTypeAndPrivacy,
} from 'preview/store/assets.slice';
import { fetchDigitalTwins } from 'preview/util/init';
import { setShouldFetchDigitalTwins } from 'preview/store/digitalTwin.slice';
import { RootState } from 'store/store';
import { deleteAsset } from 'preview/store/assets.slice';
import { fetchAssets } from 'preview/util/init';
import Filter from './Filter';
import { Asset } from './Asset';
import { AssetCardExecute, AssetCardManage } from './AssetCard';

Expand Down Expand Up @@ -45,36 +50,74 @@ const AssetGridItem: React.FC<{
);

const AssetBoard: React.FC<AssetBoardProps> = ({ tab }) => {
const assets = useSelector((state: RootState) => state.assets.items);
const allAssets = useSelector(
selectAssetsByTypeAndPrivacy('Digital Twins', true),
);
const [filter, setFilter] = React.useState<string>('');
const [error, setError] = React.useState<string | null>(null);
const shouldFetchDigitalTwins = useSelector(
(state: RootState) => state.digitalTwin.shouldFetchDigitalTwins,
);
const [loading, setLoading] = React.useState<boolean>(true);
const dispatch = useDispatch();

React.useEffect(() => {
const fetchData = async () => {
await fetchAssets(dispatch, setError);
setLoading(true);
try {
await fetchDigitalTwins(dispatch, setError);
} finally {
setLoading(false);
dispatch(setShouldFetchDigitalTwins(false));
}
};
fetchData();

if (shouldFetchDigitalTwins === true) {
fetchData();
} else {
setLoading(false);
}
}, [dispatch]);

const handleDelete = (deletedAssetPath: string) => {
dispatch(deleteAsset(deletedAssetPath));
};

const filteredAssets = allAssets.filter((asset) =>
asset.name.toLowerCase().includes(filter.toLowerCase()),
);

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

return (
<Grid {...outerGridContainerProps}>
{assets.map((asset) => (
<AssetGridItem
key={asset.path}
asset={asset}
tab={tab}
onDelete={handleDelete}
/>
))}
</Grid>
<>
{loading ? (
<Grid
container
justifyContent="center"
alignItems="center"
sx={{ minHeight: '10rem' }}
>
<CircularProgress />
</Grid>
) : (
<>
<Filter value={filter} onChange={setFilter} />
<Grid {...outerGridContainerProps}>
{filteredAssets.map((asset) => (
<AssetGridItem
key={asset.path}
asset={asset}
tab={tab}
onDelete={handleDelete}
/>
))}
</Grid>
</>
)}
</>
);
};

Expand Down
71 changes: 65 additions & 6 deletions client/src/preview/components/asset/AssetCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ import LogDialog from 'preview/route/digitaltwins/execute/LogDialog';
import DetailsDialog from 'preview/route/digitaltwins/manage/DetailsDialog';
import ReconfigureDialog from 'preview/route/digitaltwins/manage/ReconfigureDialog';
import DeleteDialog from 'preview/route/digitaltwins/manage/DeleteDialog';
import { selectAssetByPath } from 'preview/store/assets.slice';
import StartStopButton from './StartStopButton';
import LogButton from './LogButton';
import { Asset } from './Asset';
import DetailsButton from './DetailsButton';
import ReconfigureButton from './ReconfigureButton';
import DeleteButton from './DeleteButton';
import AddToCartButton from './AddToCartButton';

interface AssetCardProps {
asset: Asset;
buttons?: React.ReactNode;
library?: boolean;
}

interface AssetCardManageProps {
Expand All @@ -44,6 +47,12 @@ interface CardButtonsContainerExecuteProps {
setShowLog: Dispatch<SetStateAction<boolean>>;
}

interface CardButtonsContainerLibraryProps {
assetName: string;
assetPath: string;
setShowDetails: Dispatch<SetStateAction<boolean>>;
}

const Header = styled(Typography)`
display: -webkit-box;
-webkit-line-clamp: 1;
Expand All @@ -59,11 +68,15 @@ const Description = styled(Typography)`
text-overflow: ellipsis;
`;

function CardActionAreaContainer(asset: Asset) {
function CardActionAreaContainer(asset: Asset, library?: boolean) {
const digitalTwin = useSelector(
(state: RootState) => state.digitalTwin[asset.name],
(state: RootState) => state.digitalTwin.digitalTwin[asset.name],
);

const libraryAsset = useSelector(selectAssetByPath(asset.path));

const selectedAsset = library ? libraryAsset : digitalTwin;

return (
<Grid container>
<Grid item xs={12}>
Expand All @@ -78,7 +91,7 @@ function CardActionAreaContainer(asset: Asset) {
}}
>
<Description variant="body2" color="text.secondary">
{digitalTwin.description}
{selectedAsset!.description}
</Description>
</CardContent>
</Grid>
Expand Down Expand Up @@ -120,7 +133,25 @@ function CardButtonsContainerExecute({
);
}

function AssetCard({ asset, buttons }: AssetCardProps) {
function CardButtonsContainerLibrary({
assetName,
assetPath,
setShowDetails,
}: CardButtonsContainerLibraryProps) {
return (
<CardActions style={{ justifyContent: 'flex-end' }}>
<DetailsButton
assetName={assetName}
setShowDetails={setShowDetails}
library={true}
assetPath={assetPath}
/>
<AddToCartButton assetPath={assetPath} />
</CardActions>
);
}

function AssetCard({ asset, buttons, library }: AssetCardProps) {
return (
<Card
sx={{
Expand All @@ -133,7 +164,7 @@ function AssetCard({ asset, buttons }: AssetCardProps) {
}}
>
<Header variant="h6">{formatName(asset.name)}</Header>
<CardActionAreaContainer {...asset} />
<CardActionAreaContainer {...{ ...asset, library }} />
{buttons}
</Card>
);
Expand Down Expand Up @@ -209,4 +240,32 @@ function AssetCardExecute({ asset }: AssetCardProps) {
);
}

export { AssetCardManage, AssetCardExecute };
function AssetCardLibrary({ asset }: AssetCardProps) {
useState<AlertColor>('success');
const [showDetails, setShowDetails] = useState(false);

return (
<>
<AssetCard
asset={asset}
buttons={
<CardButtonsContainerLibrary
assetName={asset.name}
assetPath={asset.path}
setShowDetails={setShowDetails}
/>
}
library={true}
/>
<DetailsDialog
showDialog={showDetails}
setShowDialog={setShowDetails}
name={asset.name}
library={true}
path={asset.path}
/>
</>
);
}

export { AssetCardManage, AssetCardExecute, AssetCardLibrary };
Loading
Loading