Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Knowledge Space WP Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alg
Knowledge Space WP Plugin
Commits
4084b15b
Commit
4084b15b
authored
2 years ago
by
Maximilian Giller
Browse files
Options
Downloads
Patches
Plain Diff
Deleted unused file
parent
7e7b652a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Implemented editor in the react framework
Pipeline
#56689
failed
2 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/editor/js/graph.js
+0
-141
0 additions, 141 deletions
src/editor/js/graph.js
with
0 additions
and
141 deletions
src/editor/js/graph.js
deleted
100644 → 0
+
0
−
141
View file @
7e7b652a
/**
import ManagedData from "./structures/manageddata";
import { PLUGIN_PATH, COLOR_PALETTE } from "../../config";
const LINK_NAME_CONNECTOR = " → ";
export const GRAPH_NODES = "nodes";
export const GRAPH_LINKS = "links";
export const IMAGE_SIZE = 12;
export const IMAGE_SRC = PLUGIN_PATH + "datasets/images/";
export const JSON_CONFIG = PLUGIN_PATH + "datasets/aud1v2.json";
export const STOP_PHYSICS_DELAY = 5000; // ms
export class PREVIOUSGraph extends ManagedData {
constructor(data) {
super(Graph.addIdentifiers(data));
this.calculateNodeTypes();
this.physicsDelay = STOP_PHYSICS_DELAY;
this.physicsStopTimeoutId = undefined;
}
restartSimulation() {
if (this.physicsStopTimeoutId !== undefined) {
clearTimeout(this.physicsStopTimeoutId);
}
this.data = Graph.addIdentifiers(this.getCleanData(this.data, false));
this.triggerOnChange();
// Deactivate physics after a short delay
this.physicsStopTimeoutId = setTimeout(() => {
this.stopPhysics();
this.storeCurrentData("Physics stopped", false);
this.physicsStopTimeoutId = undefined;
}, this.physicsDelay);
}
stopPhysics() {
this.data[GRAPH_NODES].forEach((n) => {
n.fx = n.x;
n.fy = n.y;
});
}
existsLink(sourceId, targetId) {
const links = this.data[GRAPH_LINKS];
for (var i = 0; i < links.length; i++) {
var link = links[i];
if (
linkdeleteLink[LINK_SOURCE][NODE_ID] === sourceId &&
link[LINK_TARGET][NODE_ID] === targetId
) {
return true;
}
}
return false;
}
getCleanLink(link, simulationParameters) {
var cleanLink = {};
// Assuming that all nodes are valid, there are two possible formats
// 1. source and target are node objects
if (link[LINK_SOURCE][NODE_ID] !== undefined) {
// Source and target nodes
// Node ids will be converted to complete node objects on running graphs, gotta convert back
cleanLink[LINK_SOURCE] = link[LINK_SOURCE][NODE_ID];
cleanLink[LINK_TARGET] = link[LINK_TARGET][NODE_ID];
} else {
// 2. source and target are just node ids
cleanLink[LINK_SOURCE] = link[LINK_SOURCE];
cleanLink[LINK_TARGET] = link[LINK_TARGET];
}
return cleanLink;
}
existsNodeId(nodeId) {
var nodes = this.data[GRAPH_NODES];
for (var i = 0; i < nodes.length; i++) {
if (nodes[i][NODE_ID] === nodeId) {
return true;
}
}
return false;
}
getUnusedNodeId() {
var id;
do {
id = this.getRandomString();
} while (this.existsNodeId(id));
return id;
}
getRandomString(length = 8) {
// Move to global helpers
// Based on: https://stackoverflow.com/a/1349426/7376120
var characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var charactersLength = characters.length;
var result = "";
for (var i = 0; i < length; i++) {
result += characters.charAt(
Math.floor(Math.random() * charactersLength)
);
}
return result;
}
static toStr(item) {
if (item === undefined) {
return "UNDEFINED";
}
if (item.node) {
return item[NODE_LABEL];
} else if (item.link) {
return (
Graph.toStr(item[LINK_SOURCE]) +
LINK_NAME_CONNECTOR +
Graph.toStr(item[LINK_TARGET])
);
} else {
return "UNDEFINED";
}
}
}
*/
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment