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
5be69c37
Commit
5be69c37
authored
3 years ago
by
Matthias Konitzny
Browse files
Options
Downloads
Patches
Plain Diff
Extracted some functions from graph.js
parent
8f2022b2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
display/display.js
+41
-0
41 additions, 0 deletions
display/display.js
display/graph.js
+7
-44
7 additions, 44 deletions
display/graph.js
index.js
+1
-1
1 addition, 1 deletion
index.js
with
49 additions
and
45 deletions
display/display.js
0 → 100644
+
41
−
0
View file @
5be69c37
import
*
as
Helpers
from
"
./helpers
"
;
import
*
as
Config
from
"
../config
"
;
import
{
FilterOverlay
}
from
"
./overlays/filteroverlay
"
;
import
{
NodeInfoOverlay
}
from
"
./overlays/nodeinfo
"
;
import
Graph
from
"
./graph
"
;
function
loadComponents
()
{
filterOverlay
.
create
();
infoOverlay
.
create
();
filterOverlay
.
filterChangedCallback
=
(
cls
)
=>
infoOverlay
.
bottomMenu
.
toggleTabVisibility
(
cls
);
createFullScreenButton
();
}
function
createFullScreenButton
()
{
const
sceneNode
=
Helpers
.
getCanvasDivNode
();
const
overlayNode
=
document
.
createElement
(
"
div
"
);
overlayNode
.
className
=
"
fullscreen-button
"
;
overlayNode
.
innerHTML
=
"
<p>⤢</p>
"
;
overlayNode
.
addEventListener
(
"
click
"
,
function
()
{
if
(
!
document
.
fullscreenElement
)
{
Helpers
.
getCanvasDivNode
().
requestFullscreen
();
}
else
{
document
.
exitFullscreen
();
}
G
.
resize
();
});
sceneNode
.
appendChild
(
overlayNode
);
}
let
G
=
null
;
let
filterOverlay
=
null
;
let
infoOverlay
=
null
;
// Only execute, if corresponding dom is present
if
(
document
.
getElementById
(
"
3d-graph
"
)
!==
null
)
{
G
=
new
Graph
(
Config
.
SPACE
,
loadComponents
);
filterOverlay
=
new
FilterOverlay
(
G
,
"
node
"
);
infoOverlay
=
new
NodeInfoOverlay
(
G
);
G
.
infoOverlay
=
infoOverlay
;
}
This diff is collapsed.
Click to expand it.
display/graph.js
+
7
−
44
View file @
5be69c37
import
*
as
Config
from
"
../config
"
;
import
*
as
Config
from
"
../config
"
;
import
*
as
Helpers
from
"
./helpers
"
;
import
*
as
Helpers
from
"
./helpers
"
;
import
{
loadGraphJson
}
from
"
../datasets/datasets
"
;
import
{
loadGraphJson
}
from
"
../datasets/datasets
"
;
import
{
NodeInfoOverlay
}
from
"
./overlays/nodeinfo
"
;
import
{
FilterOverlay
}
from
"
./overlays/filteroverlay
"
;
import
*
as
THREE
from
"
three
"
;
import
*
as
THREE
from
"
three
"
;
import
ForceGraph3D
from
"
3d-force-graph
"
;
import
ForceGraph3D
from
"
3d-force-graph
"
;
...
@@ -16,12 +14,13 @@ import {
...
@@ -16,12 +14,13 @@ import {
/**
/**
* The main ForceGraph. Displays the graph and handles all connected events.
* The main ForceGraph. Displays the graph and handles all connected events.
*/
*/
class
Graph
{
export
default
class
Graph
{
/**
/**
* Constructs a new Graph object.
* Constructs a new Graph object.
* @param {string} dataUrl URL to a JSON object defining the graph structure.
* @param {string} spaceId Name of the knowledge space that should be loaded
* @param {function} loadingFinishedCallback Callback that is called when the graph is fully loaded.
*/
*/
constructor
(
spaceId
)
{
constructor
(
spaceId
,
loadingFinishedCallback
=
Function
()
)
{
this
.
graph
=
null
;
this
.
graph
=
null
;
this
.
gData
=
null
;
this
.
gData
=
null
;
...
@@ -38,6 +37,8 @@ class Graph {
...
@@ -38,6 +37,8 @@ class Graph {
this
.
edgeTypeVisibility
=
{};
this
.
edgeTypeVisibility
=
{};
this
.
nodeTypeVisibility
=
{};
this
.
nodeTypeVisibility
=
{};
this
.
loadingFinishedCallback
=
loadingFinishedCallback
;
this
.
loadGraph
(
spaceId
);
this
.
loadGraph
(
spaceId
);
}
}
...
@@ -95,9 +96,6 @@ class Graph {
...
@@ -95,9 +96,6 @@ class Graph {
// Can only be called after link colors have been mapped.
// Can only be called after link colors have been mapped.
this
.
graph
.
linkThreeObject
((
link
)
=>
this
.
drawLink
(
link
));
this
.
graph
.
linkThreeObject
((
link
)
=>
this
.
drawLink
(
link
));
// Add overlay components
loadComponents
();
// Catch resize events
// Catch resize events
document
.
addEventListener
(
"
fullscreenchange
"
,
()
=>
this
.
resize
());
document
.
addEventListener
(
"
fullscreenchange
"
,
()
=>
this
.
resize
());
window
.
addEventListener
(
"
resize
"
,
()
=>
this
.
resize
());
window
.
addEventListener
(
"
resize
"
,
()
=>
this
.
resize
());
...
@@ -110,6 +108,7 @@ class Graph {
...
@@ -110,6 +108,7 @@ class Graph {
(
item
)
=>
(
this
.
nodeTypeVisibility
[
item
]
=
true
)
(
item
)
=>
(
this
.
nodeTypeVisibility
[
item
]
=
true
)
);
);
this
.
firstTick
=
false
;
this
.
firstTick
=
false
;
this
.
loadingFinishedCallback
();
}
}
}
}
...
@@ -494,39 +493,3 @@ class Graph {
...
@@ -494,39 +493,3 @@ class Graph {
return
group
;
return
group
;
}
}
}
}
function
loadComponents
()
{
filterOverlay
.
create
();
infoOverlay
.
create
();
filterOverlay
.
filterChangedCallback
=
(
cls
)
=>
infoOverlay
.
bottomMenu
.
toggleTabVisibility
(
cls
);
createFullScreenButton
();
}
function
createFullScreenButton
()
{
const
sceneNode
=
Helpers
.
getCanvasDivNode
();
const
overlayNode
=
document
.
createElement
(
"
div
"
);
overlayNode
.
className
=
"
fullscreen-button
"
;
overlayNode
.
innerHTML
=
"
<p>⤢</p>
"
;
overlayNode
.
addEventListener
(
"
click
"
,
function
()
{
if
(
!
document
.
fullscreenElement
)
{
Helpers
.
getCanvasDivNode
().
requestFullscreen
();
}
else
{
document
.
exitFullscreen
();
}
G
.
resize
();
});
sceneNode
.
appendChild
(
overlayNode
);
}
let
G
=
null
;
let
filterOverlay
=
null
;
let
infoOverlay
=
null
;
// Only execute, if corresponding dom is present
if
(
document
.
getElementById
(
"
3d-graph
"
)
!==
null
)
{
G
=
new
Graph
(
Config
.
SPACE
);
// space_id defined globaly through knowledge-space.php
filterOverlay
=
new
FilterOverlay
(
G
,
"
node
"
);
infoOverlay
=
new
NodeInfoOverlay
(
G
);
G
.
infoOverlay
=
infoOverlay
;
}
This diff is collapsed.
Click to expand it.
index.js
+
1
−
1
View file @
5be69c37
import
"
./display/display.css
"
;
import
"
./display/display.css
"
;
import
"
./editor/css/editor.css
"
;
import
"
./editor/css/editor.css
"
;
import
"
./display/
graph
"
;
import
"
./display/
display
"
;
import
"
./editor/js/editor
"
;
import
"
./editor/js/editor
"
;
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