Main logic + prettier graphing, no graph solver yet
This commit is contained in:
28
output.json
28
output.json
@@ -26,6 +26,32 @@
|
||||
"value" : "\"10s\""
|
||||
} ]
|
||||
} ]
|
||||
}, {
|
||||
"name" : "DatabaseAccessImpl",
|
||||
"functions" : [ {
|
||||
"name" : "GetUserList",
|
||||
"access_modifier" : "public",
|
||||
"implemented_interface" : "none",
|
||||
"importance" : "critical",
|
||||
"inputTypes" : [ {
|
||||
"type" : "FLOAT",
|
||||
"identifier" : "x"
|
||||
}, {
|
||||
"type" : "STRING",
|
||||
"identifier" : "ag"
|
||||
} ],
|
||||
"returnTypes" : [ {
|
||||
"type" : "\"CustomDataType\"",
|
||||
"identifier" : "x"
|
||||
} ],
|
||||
"specificationEntries" : [ {
|
||||
"key" : "ExecTime",
|
||||
"value" : "\"10s\""
|
||||
}, {
|
||||
"key" : "MaxReturnVals",
|
||||
"value" : "\"10s\""
|
||||
} ]
|
||||
} ]
|
||||
} ],
|
||||
"specifications" : [ {
|
||||
"name" : "DatabaseAccess",
|
||||
@@ -100,7 +126,7 @@
|
||||
"name" : "GetUserdfList",
|
||||
"access_modifier" : "public",
|
||||
"implemented_interface" : "Database",
|
||||
"importance" : "critical",
|
||||
"importance" : "optional",
|
||||
"inputTypes" : [ {
|
||||
"type" : "FLOAT",
|
||||
"identifier" : "x"
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.lumijiez.parser.WinxParser;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
@@ -41,7 +40,7 @@ public class Main {
|
||||
|
||||
// Retrieve the collected data and save it to JSON
|
||||
List<Package> packages = collector.getPackages();
|
||||
String json = saveAsJson(packages, "output.json");
|
||||
String json = saveAsJson(packages);
|
||||
|
||||
System.out.println("Data successfully saved to 'output.json'.");
|
||||
|
||||
@@ -63,11 +62,11 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
private static String saveAsJson(List<Package> packages, String filePath) throws IOException {
|
||||
private static String saveAsJson(List<Package> packages) throws IOException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
String jsonString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(packages);
|
||||
Files.writeString(Paths.get(filePath), jsonString);
|
||||
Files.writeString(Paths.get("output.json"), jsonString);
|
||||
return jsonString;
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new IOException("Failed to serialize data to JSON", e);
|
||||
|
||||
@@ -33,7 +33,7 @@ package Database {
|
||||
return INT x;
|
||||
}
|
||||
|
||||
critical public GetUserdList(FLOAT[] x, STRING ag) implements Database {
|
||||
critical private GetUserdList(FLOAT[] x, STRING ag) implements Database {
|
||||
@ExecTime : "10s";
|
||||
@MaxReturnVals : "10s";
|
||||
return INT x;
|
||||
@@ -45,7 +45,7 @@ package Database {
|
||||
return INT x;
|
||||
}
|
||||
|
||||
critical public GetUsesfrList(FLOAT[] x, STRING ag) implements Database {
|
||||
optional public GetUsesfrList(FLOAT[] x, STRING ag) implements Database {
|
||||
@ExecTime : "10s";
|
||||
@MaxReturnVals : "10s";
|
||||
return INT x;
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Graph Visualization</title>
|
||||
<script type="text/javascript" src="https://unpkg.com/vis-network/standalone/umd/vis-network.min.js"></script>
|
||||
<style>
|
||||
#mynetwork {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
border: 1px solid lightgray;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mynetwork"></div>
|
||||
|
||||
<script>
|
||||
const jsonData = null;
|
||||
|
||||
function generateVisData(data) {
|
||||
const nodes = [];
|
||||
const edges = [];
|
||||
|
||||
data.forEach(pkg => {
|
||||
const pkgId = `pkg-${pkg.name}`;
|
||||
nodes.push({
|
||||
id: pkgId,
|
||||
label: `Package: ${pkg.name}`,
|
||||
shape: 'box'
|
||||
});
|
||||
|
||||
const interfaceIds = {};
|
||||
|
||||
pkg.interfaces.forEach(iface => {
|
||||
const ifaceId = `iface-${iface.name}`;
|
||||
interfaceIds[iface.name] = ifaceId;
|
||||
nodes.push({
|
||||
id: ifaceId,
|
||||
label: formatInterface(iface),
|
||||
shape: 'box'
|
||||
});
|
||||
edges.push({ from: pkgId, to: ifaceId });
|
||||
|
||||
iface.functions.forEach(func => {
|
||||
const funcId = `func-${iface.name}-${func.name}`;
|
||||
nodes.push({
|
||||
id: funcId,
|
||||
label: formatFunction(func),
|
||||
shape: 'box'
|
||||
});
|
||||
edges.push({ from: ifaceId, to: funcId });
|
||||
|
||||
if (func.implemented_interface && func.implemented_interface !== "none" && interfaceIds[func.implemented_interface]) {
|
||||
edges.push({ from: funcId, to: interfaceIds[func.implemented_interface] });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
pkg.specifications.forEach(spec => {
|
||||
const specId = `spec-${spec.name}`;
|
||||
nodes.push({
|
||||
id: specId,
|
||||
label: formatSpecification(spec),
|
||||
shape: 'box'
|
||||
});
|
||||
edges.push({ from: pkgId, to: specId });
|
||||
|
||||
spec.functions.forEach(func => {
|
||||
const funcId = `func-${spec.name}-${func.name}`;
|
||||
nodes.push({
|
||||
id: funcId,
|
||||
label: formatFunction(func),
|
||||
shape: 'box'
|
||||
});
|
||||
edges.push({ from: specId, to: funcId });
|
||||
|
||||
if (func.implemented_interface && func.implemented_interface !== "none" && interfaceIds[func.implemented_interface]) {
|
||||
edges.push({ from: funcId, to: interfaceIds[func.implemented_interface] });
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return { nodes: new vis.DataSet(nodes), edges: new vis.DataSet(edges) };
|
||||
}
|
||||
|
||||
function formatInterface(iface) {
|
||||
return `Interface: ${iface.name}`;
|
||||
}
|
||||
|
||||
function formatFunction(func) {
|
||||
let label = `Function: ${func.name}\nAccess: ${func.access_modifier}`;
|
||||
label += `\nImplements: ${func.implemented_interface}`;
|
||||
label += `\nImportance: ${func.importance}`;
|
||||
func.inputTypes.forEach(input => {
|
||||
label += `\nInput: ${input.type} ${input.identifier}`;
|
||||
});
|
||||
func.returnTypes.forEach(ret => {
|
||||
label += `\nReturn: ${ret.type} ${ret.identifier}`;
|
||||
});
|
||||
func.specificationEntries.forEach(entry => {
|
||||
label += `\n${entry.key}: ${entry.value}`;
|
||||
});
|
||||
return label;
|
||||
}
|
||||
|
||||
function formatSpecification(spec) {
|
||||
let label = `Specification: ${spec.name}\nImplements: ${spec.implementedInterface}`;
|
||||
spec.requirements.forEach(req => {
|
||||
label += `\nRequirement: ${req.name}`;
|
||||
req.annotations.forEach(anno => {
|
||||
label += `\n - ${anno.name} (${anno.importance})`;
|
||||
});
|
||||
});
|
||||
spec.results.forEach(result => {
|
||||
label += `\nResult: ${result.name} (${result.importance})`;
|
||||
});
|
||||
return label;
|
||||
}
|
||||
|
||||
const { nodes, edges } = generateVisData(jsonData);
|
||||
|
||||
const container = document.getElementById('mynetwork');
|
||||
const data = {
|
||||
nodes: nodes,
|
||||
edges: edges
|
||||
};
|
||||
const options = {
|
||||
nodes: {
|
||||
font: {
|
||||
multi: 'html',
|
||||
size: 14
|
||||
}
|
||||
},
|
||||
layout: {
|
||||
randomSeed: undefined,
|
||||
improvedLayout: true,
|
||||
clusterThreshold: 150,
|
||||
hierarchical: {
|
||||
enabled: true,
|
||||
levelSeparation: 150,
|
||||
nodeSpacing: 300,
|
||||
treeSpacing: 200,
|
||||
blockShifting: true,
|
||||
edgeMinimization: true,
|
||||
parentCentralization: true,
|
||||
direction: 'UD',
|
||||
sortMethod: 'directed'
|
||||
}
|
||||
},
|
||||
edges: {
|
||||
smooth: {
|
||||
type: 'dynamic',
|
||||
roundness: 0.5
|
||||
},
|
||||
length: 400
|
||||
}
|
||||
};
|
||||
const network = new vis.Network(container, data, options);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
23
winx-serve/.gitignore
vendored
Normal file
23
winx-serve/.gitignore
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
5
winx-serve/.idea/.gitignore
generated
vendored
Normal file
5
winx-serve/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
6
winx-serve/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
6
winx-serve/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
||||
8
winx-serve/.idea/modules.xml
generated
Normal file
8
winx-serve/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/winx-serve.iml" filepath="$PROJECT_DIR$/.idea/winx-serve.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
7
winx-serve/.idea/vcs.xml
generated
Normal file
7
winx-serve/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../../../.." vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
70
winx-serve/README.md
Normal file
70
winx-serve/README.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# Getting Started with Create React App
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
|
||||
## Available Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
|
||||
### `npm start`
|
||||
|
||||
Runs the app in the development mode.\
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
|
||||
|
||||
The page will reload when you make changes.\
|
||||
You may also see any lint errors in the console.
|
||||
|
||||
### `npm test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.\
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
|
||||
### `npm run build`
|
||||
|
||||
Builds the app for production to the `build` folder.\
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.\
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `npm run eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
|
||||
|
||||
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
|
||||
|
||||
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||
|
||||
### Code Splitting
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
||||
|
||||
### Analyzing the Bundle Size
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
||||
|
||||
### Making a Progressive Web App
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
||||
|
||||
### Advanced Configuration
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
||||
|
||||
### Deployment
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
||||
|
||||
### `npm run build` fails to minify
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|
||||
18936
winx-serve/package-lock.json
generated
Normal file
18936
winx-serve/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
43
winx-serve/package.json
Normal file
43
winx-serve/package.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "winx-serve",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@testing-library/jest-dom": "^5.17.0",
|
||||
"@testing-library/react": "^13.4.0",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-flow-renderer": "^10.3.17",
|
||||
"react-scripts": "5.0.1",
|
||||
"reactflow": "^11.11.2",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"tailwindcss": "^3.4.3"
|
||||
}
|
||||
}
|
||||
BIN
winx-serve/public/cog.png
Normal file
BIN
winx-serve/public/cog.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 130 KiB |
BIN
winx-serve/public/favicon.ico
Normal file
BIN
winx-serve/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
43
winx-serve/public/index.html
Normal file
43
winx-serve/public/index.html
Normal file
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
BIN
winx-serve/public/input.png
Normal file
BIN
winx-serve/public/input.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
BIN
winx-serve/public/logo192.png
Normal file
BIN
winx-serve/public/logo192.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
BIN
winx-serve/public/logo512.png
Normal file
BIN
winx-serve/public/logo512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
25
winx-serve/public/manifest.json
Normal file
25
winx-serve/public/manifest.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
||||
BIN
winx-serve/public/output.png
Normal file
BIN
winx-serve/public/output.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
3
winx-serve/public/robots.txt
Normal file
3
winx-serve/public/robots.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
||||
38
winx-serve/src/App.css
Normal file
38
winx-serve/src/App.css
Normal file
@@ -0,0 +1,38 @@
|
||||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
height: 40vmin;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.App-logo {
|
||||
animation: App-logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.App-header {
|
||||
background-color: #282c34;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.App-link {
|
||||
color: #61dafb;
|
||||
}
|
||||
|
||||
@keyframes App-logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
12
winx-serve/src/App.js
Normal file
12
winx-serve/src/App.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import CustomGraph from './CustomGraph';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div className="App" style={{height: 100 + 'vh'}}>
|
||||
<CustomGraph />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
149
winx-serve/src/CustomGraph.js
Normal file
149
winx-serve/src/CustomGraph.js
Normal file
@@ -0,0 +1,149 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import ReactFlow, { Controls, Background, useNodesState, useEdgesState } from 'react-flow-renderer';
|
||||
import CustomNodeComponent from './CustomNodeComponent';
|
||||
import {ReactFlowProvider} from "reactflow";
|
||||
import {jsonData} from './Data.js';
|
||||
|
||||
const nodeTypes = {
|
||||
customNode: CustomNodeComponent,
|
||||
};
|
||||
|
||||
function CustomGraph() {
|
||||
const [nodes, setNodes, onNodesChange] = useNodesState([]);
|
||||
const [edges, setEdges, onEdgesChange] = useEdgesState([]);
|
||||
|
||||
useEffect(() => {
|
||||
const loadedNodes = [];
|
||||
const loadedEdges = [];
|
||||
let yOffset = 100;
|
||||
|
||||
jsonData.forEach((pkg, index) => {
|
||||
const pkgId = `pkg-${pkg.name}`;
|
||||
loadedNodes.push({
|
||||
id: pkgId,
|
||||
type: 'customNode',
|
||||
position: { x: 100, y: yOffset * index },
|
||||
data: { label: `Package: ${pkg.name}`, ...pkg }
|
||||
});
|
||||
|
||||
pkg.interfaces.forEach((iface, iIndex) => {
|
||||
const ifaceId = `iface-${iface.name}`;
|
||||
loadedNodes.push({
|
||||
id: ifaceId,
|
||||
type: 'customNode',
|
||||
position: { x: 300, y: yOffset * (index + 1 + iIndex) },
|
||||
data: { label: `Interface: ${iface.name}`, ...iface }
|
||||
});
|
||||
loadedEdges.push({
|
||||
id: `e-${pkgId}-${ifaceId}`,
|
||||
source: pkgId,
|
||||
target: ifaceId,
|
||||
type: 'simplebezier',
|
||||
animated: true,
|
||||
});
|
||||
|
||||
iface.functions.forEach((func, fIndex) => {
|
||||
const funcId = `func-${iface.name}-${func.name}`;
|
||||
loadedNodes.push({
|
||||
id: funcId,
|
||||
type: 'customNode',
|
||||
position: { x: 500, y: yOffset * (index + 2 + iIndex + fIndex) },
|
||||
data: { label: `${func.name}()`, ...func }
|
||||
});
|
||||
loadedEdges.push({
|
||||
id: `e-${ifaceId}-${funcId}`,
|
||||
source: ifaceId,
|
||||
target: funcId,
|
||||
type: 'simplebezier',
|
||||
animated: true
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
pkg.specifications.forEach((spec, sIndex) => {
|
||||
const specId = `spec-${spec.name}`;
|
||||
loadedNodes.push({
|
||||
id: specId,
|
||||
type: 'customNode',
|
||||
position: { x: 300, y: yOffset * (index + 1 + sIndex) },
|
||||
data: { label: `Specification: ${spec.name}`, ...spec }
|
||||
});
|
||||
|
||||
if (spec.implemented_interface) {
|
||||
const interfaceId = `iface-${spec.implemented_interface}`;
|
||||
loadedEdges.push({
|
||||
id: `e-${interfaceId}-${specId}`,
|
||||
source: interfaceId,
|
||||
target: specId,
|
||||
type: 'simplebezier',
|
||||
animated: true
|
||||
});
|
||||
}
|
||||
|
||||
loadedEdges.push({
|
||||
id: `e-${pkgId}-${specId}`,
|
||||
source: pkgId,
|
||||
target: specId,
|
||||
type: 'simplebezier',
|
||||
animated: true,
|
||||
style: { stroke: '#000', strokeWidth: 4 }
|
||||
});
|
||||
|
||||
spec.functions.forEach((func, fIndex) => {
|
||||
const funcId = `func-${spec.name}-${func.name}`;
|
||||
loadedNodes.push({
|
||||
id: funcId,
|
||||
type: 'customNode',
|
||||
position: { x: 500, y: yOffset * (index + 2 + sIndex + fIndex) },
|
||||
data: { label: `${func.name}()`, ...func },
|
||||
});
|
||||
|
||||
if (func.implemented_interface) {
|
||||
const interfaceId = `iface-${func.implemented_interface}`;
|
||||
loadedEdges.push({
|
||||
id: `e-${interfaceId}-${funcId}`,
|
||||
source: interfaceId,
|
||||
target: funcId,
|
||||
type: 'simplebezier',
|
||||
animated: true
|
||||
});
|
||||
}
|
||||
|
||||
loadedEdges.push({
|
||||
id: `e-${specId}-${funcId}`,
|
||||
source: specId,
|
||||
target: funcId,
|
||||
type: 'simplebezier',
|
||||
animated: true,
|
||||
style: { stroke: '#000', strokeWidth: 4 }
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
console.log(loadedEdges)
|
||||
|
||||
setNodes(loadedNodes);
|
||||
setEdges(loadedEdges);
|
||||
}, [setNodes, setEdges]);
|
||||
|
||||
return (
|
||||
<div style={{ height: 100+'vh', width: 100 + '%' }}>
|
||||
<ReactFlowProvider>
|
||||
<ReactFlow
|
||||
nodes={nodes}
|
||||
edges={edges}
|
||||
onNodesChange={onNodesChange}
|
||||
onEdgesChange={onEdgesChange}
|
||||
nodeTypes={nodeTypes}
|
||||
fitView>
|
||||
|
||||
<Controls />
|
||||
<Background />
|
||||
</ReactFlow>
|
||||
</ReactFlowProvider>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default CustomGraph;
|
||||
128
winx-serve/src/CustomNodeComponent.js
Normal file
128
winx-serve/src/CustomNodeComponent.js
Normal file
@@ -0,0 +1,128 @@
|
||||
import React from 'react';
|
||||
import {Handle} from "reactflow";
|
||||
|
||||
const CustomNodeComponent = ({data}) => {
|
||||
return (
|
||||
<div className="flex">
|
||||
|
||||
|
||||
{data.inputTypes && (<div className="content-start bg-amber-400 flex-1 h-1/2 p-1 rounded-l">
|
||||
<div>
|
||||
<div className="flex">
|
||||
<img className="content-center mr-2" alt="inputCog" src="/input.png"
|
||||
style={{width: 20 + 'px', height: 20 + 'px'}}/>
|
||||
<strong className="content-center">Input: </strong>
|
||||
</div>
|
||||
|
||||
{data.inputTypes.map((input, idx) => (
|
||||
<div className="text-gray-700" key={idx}>{input.type} {input.identifier}</div>))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
<div className="flex flex-col innerBody rounded-bl-lg rounded-tr-lg divide-y sans-font"
|
||||
style={{
|
||||
backgroundColor: data.importance === 'critical' ? '#F59975' : '#01C6C9',
|
||||
}}>
|
||||
|
||||
|
||||
<div>
|
||||
<div className="access rounded-tr-lg m-0 text-center" style={{
|
||||
backgroundColor: data.access_modifier === "public" ? "#00aa88" : data.access_modifier === "private" ? "red" : "#FF8C00"
|
||||
}}>
|
||||
{data.access_modifier && (<div
|
||||
className="p-1 text-xl font-bold text-white">{data.access_modifier.toUpperCase()}</div>)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="p-3 m-0">
|
||||
<Handle type="target" position="top" style={{borderRadius: 0}}/>
|
||||
|
||||
|
||||
<div className="header">
|
||||
<div className="flex justify-between" style={{fontWeight: 'bold', marginBottom: '5px'}}>
|
||||
<div className="content-center text-2xl">
|
||||
{data.label}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="general">
|
||||
<div className="flex">
|
||||
<div className="content-center mr-2">
|
||||
<img src="/cog.png" alt="cog" style={{width: 20 + 'px', height: 20 + 'px'}}/>
|
||||
</div>
|
||||
<span className="content-center">
|
||||
{data.implemented_interface || 'None'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{data.requirements && (<div>
|
||||
<strong>Requirements:</strong>
|
||||
{data.requirements.map((requirement, idx) => (<div className="text-gray-700" key={idx}>
|
||||
<span className="text-xl font-bold">
|
||||
{requirement.name}
|
||||
</span>
|
||||
|
||||
{requirement.annotations && requirement.annotations.map((annotation, index) => (
|
||||
<div key={index}>
|
||||
<span className="fade-in-out font-mono text-red-700">
|
||||
{annotation.importance === "critical" ? "!" : ""}
|
||||
</span>
|
||||
|
||||
<span style={{
|
||||
color: annotation.importance === "critical" ? "red" : "green"
|
||||
}}>
|
||||
{annotation.importance.toUpperCase()} {annotation.name}
|
||||
</span>
|
||||
</div>))}
|
||||
</div>))}
|
||||
</div>)}
|
||||
|
||||
|
||||
<div className="specs">
|
||||
{data.specificationEntries && (<div>
|
||||
<strong>Specifications:</strong>
|
||||
{data.specificationEntries.map((entry, idx) => (
|
||||
<div key={idx}>{entry.key}: {entry.value}</div>))}
|
||||
</div>)}
|
||||
</div>
|
||||
|
||||
|
||||
<Handle type="source" position="bottom" style={{borderRadius: 0}}/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{data.returnTypes && (<div className="flex flex-col m-0 justify-between">
|
||||
<div>
|
||||
<div className="outerBody">
|
||||
<span className="fade-in-out font-mono text-7xl text-red-700">
|
||||
{data.importance === "critical" ? "!" : ""}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-amber-400 p-1 rounded-r">
|
||||
<div className="flex">
|
||||
<img className="content-center mr-1" alt="outputCog" src="/output.png"
|
||||
style={{width: 20 + 'px', height: 20 + 'px'}}/>
|
||||
<strong className="content-center">Output: </strong>
|
||||
</div>
|
||||
|
||||
{data.returnTypes.map((ret, idx) => (
|
||||
<div className="text-gray-700 m-1" key={idx}>{ret.type} {ret.identifier}</div>))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
</div>);
|
||||
};
|
||||
|
||||
export default CustomNodeComponent;
|
||||
174
winx-serve/src/Data.js
Normal file
174
winx-serve/src/Data.js
Normal file
@@ -0,0 +1,174 @@
|
||||
export const jsonData = [ {
|
||||
"name" : "Database",
|
||||
"interfaces" : [ {
|
||||
"name" : "Database",
|
||||
"functions" : [ {
|
||||
"name" : "GetUserList",
|
||||
"access_modifier" : "public",
|
||||
"implemented_interface" : "none",
|
||||
"importance" : "optional",
|
||||
"inputTypes" : [ {
|
||||
"type" : "FLOAT",
|
||||
"identifier" : "x"
|
||||
}, {
|
||||
"type" : "STRING",
|
||||
"identifier" : "ag"
|
||||
} ],
|
||||
"returnTypes" : [ {
|
||||
"type" : "\"CustomDataType\"",
|
||||
"identifier" : "x"
|
||||
} ],
|
||||
"specificationEntries" : [ {
|
||||
"key" : "ExecTime",
|
||||
"value" : "\"10s\""
|
||||
}, {
|
||||
"key" : "MaxReturnVals",
|
||||
"value" : "\"10s\""
|
||||
} ]
|
||||
} ]
|
||||
}, {
|
||||
"name" : "DatabaseAccessImpl",
|
||||
"functions" : [ {
|
||||
"name" : "GetUserList",
|
||||
"access_modifier" : "protected",
|
||||
"implemented_interface" : "none",
|
||||
"importance" : "critical",
|
||||
"inputTypes" : [ {
|
||||
"type" : "FLOAT",
|
||||
"identifier" : "x"
|
||||
}, {
|
||||
"type" : "STRING",
|
||||
"identifier" : "ag"
|
||||
} ],
|
||||
"returnTypes" : [ {
|
||||
"type" : "\"CustomDataType\"",
|
||||
"identifier" : "x"
|
||||
} ],
|
||||
"specificationEntries" : [ {
|
||||
"key" : "ExecTime",
|
||||
"value" : "\"10s\""
|
||||
}, {
|
||||
"key" : "MaxReturnVals",
|
||||
"value" : "\"10s\""
|
||||
} ]
|
||||
} ]
|
||||
} ],
|
||||
"specifications" : [ {
|
||||
"name" : "DatabaseAccess",
|
||||
"implemented_interface" : "Database",
|
||||
"requirements" : [ {
|
||||
"name" : "DatabaseAccessMember",
|
||||
"annotations" : [ {
|
||||
"importance" : "optional",
|
||||
"name" : "UserHasAdminAccess"
|
||||
}, {
|
||||
"importance" : "critical",
|
||||
"name" : "UserIsNotBanned"
|
||||
} ]
|
||||
} ],
|
||||
"results" : [ {
|
||||
"name" : "DatabaseAdminPanel",
|
||||
"importance" : "optional"
|
||||
}, {
|
||||
"name" : "DatabaseVisualizerPanel",
|
||||
"importance" : "critical"
|
||||
}, {
|
||||
"name" : "Clock",
|
||||
"importance" : "none"
|
||||
} ],
|
||||
"functions" : [ {
|
||||
"name" : "GetUserList",
|
||||
"access_modifier" : "public",
|
||||
"implemented_interface" : "DatabaseAccessImpl",
|
||||
"importance" : "critical",
|
||||
"inputTypes" : [ {
|
||||
"type" : "FLOAT",
|
||||
"identifier" : "x"
|
||||
}, {
|
||||
"type" : "STRING",
|
||||
"identifier" : "ag"
|
||||
} ],
|
||||
"returnTypes" : [ {
|
||||
"type" : "INT",
|
||||
"identifier" : "x"
|
||||
} ],
|
||||
"specificationEntries" : [ {
|
||||
"key" : "ExecTime",
|
||||
"value" : "\"10s\""
|
||||
}, {
|
||||
"key" : "MaxReturnVals",
|
||||
"value" : "\"10s\""
|
||||
} ]
|
||||
}, {
|
||||
"name" : "GetUserdList",
|
||||
"access_modifier" : "private",
|
||||
"implemented_interface" : "Database",
|
||||
"importance" : "optional",
|
||||
"inputTypes" : [ {
|
||||
"type" : "FLOAT",
|
||||
"identifier" : "x"
|
||||
}, {
|
||||
"type" : "STRING",
|
||||
"identifier" : "ag"
|
||||
} ],
|
||||
"returnTypes" : [ {
|
||||
"type" : "INT",
|
||||
"identifier" : "x"
|
||||
} ],
|
||||
"specificationEntries" : [ {
|
||||
"key" : "ExecTime",
|
||||
"value" : "\"10s\""
|
||||
}, {
|
||||
"key" : "MaxReturnVals",
|
||||
"value" : "\"10s\""
|
||||
} ]
|
||||
}, {
|
||||
"name" : "GetUserdfList",
|
||||
"access_modifier" : "public",
|
||||
"implemented_interface" : "Database",
|
||||
"importance" : "optional",
|
||||
"inputTypes" : [ {
|
||||
"type" : "FLOAT",
|
||||
"identifier" : "x"
|
||||
}, {
|
||||
"type" : "STRING",
|
||||
"identifier" : "ag"
|
||||
} ],
|
||||
"returnTypes" : [ {
|
||||
"type" : "INT",
|
||||
"identifier" : "x"
|
||||
} ],
|
||||
"specificationEntries" : [ {
|
||||
"key" : "ExecTime",
|
||||
"value" : "\"10s\""
|
||||
}, {
|
||||
"key" : "MaxReturnVals",
|
||||
"value" : "\"10s\""
|
||||
} ]
|
||||
}, {
|
||||
"name" : "GetUsesfrList",
|
||||
"access_modifier" : "private",
|
||||
"implemented_interface" : "Database",
|
||||
"importance" : "optional",
|
||||
"inputTypes" : [ {
|
||||
"type" : "FLOAT",
|
||||
"identifier" : "x"
|
||||
}, {
|
||||
"type" : "STRING",
|
||||
"identifier" : "ag"
|
||||
} ],
|
||||
"returnTypes" : [ {
|
||||
"type" : "INT",
|
||||
"identifier" : "x"
|
||||
} ],
|
||||
"specificationEntries" : [ {
|
||||
"key" : "ExecTime",
|
||||
"value" : "\"10s\""
|
||||
}, {
|
||||
"key" : "MaxReturnVals",
|
||||
"value" : "\"10s\""
|
||||
} ]
|
||||
} ],
|
||||
"implementedInterface" : "Database"
|
||||
} ]
|
||||
} ];
|
||||
23
winx-serve/src/index.css
Normal file
23
winx-serve/src/index.css
Normal file
@@ -0,0 +1,23 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap');
|
||||
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
@keyframes fadeAnimation {
|
||||
0%, 100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.fade-in-out {
|
||||
animation: fadeAnimation 3s infinite;
|
||||
}
|
||||
|
||||
.sans-font {
|
||||
font-family: "Open Sans", sans-serif;
|
||||
font-optical-sizing: auto;
|
||||
}
|
||||
12
winx-serve/src/index.js
Normal file
12
winx-serve/src/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root'));
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
);
|
||||
|
||||
10
winx-serve/tailwind.config.js
Normal file
10
winx-serve/tailwind.config.js
Normal file
@@ -0,0 +1,10 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
content: [
|
||||
"./src/**/*.{js,jsx,ts,tsx}",
|
||||
],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
}
|
||||
Reference in New Issue
Block a user