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
72aaa1c8
Commit
72aaa1c8
authored
3 years ago
by
Maximilian Giller
Browse files
Options
Downloads
Patches
Plain Diff
Parsing graph in front end now
parent
06757cac
No related branches found
No related tags found
No related merge requests found
Pipeline
#54333
passed
3 years ago
Stage: test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
datasets/datasets.js
+50
-1
50 additions, 1 deletion
datasets/datasets.js
editor/editor.php
+1
-1
1 addition, 1 deletion
editor/editor.php
editor/js/editor.js
+3
-0
3 additions, 0 deletions
editor/js/editor.js
knowledge-space.php
+2
-26
2 additions, 26 deletions
knowledge-space.php
with
56 additions
and
28 deletions
datasets/datasets.js
+
50
−
1
View file @
72aaa1c8
...
@@ -7,9 +7,58 @@ import jQuery from "jquery";
...
@@ -7,9 +7,58 @@ import jQuery from "jquery";
*
*
* @param {String} spaceId Identification of graph to load.
* @param {String} spaceId Identification of graph to load.
*
*
* @returns Promise returning graph object.
* @returns Promise returning
simple
graph object.
*/
*/
export
function
loadGraphJson
(
spaceId
)
{
export
function
loadGraphJson
(
spaceId
)
{
return
loadSpaceJson
(
spaceId
).
then
((
json
)
=>
{
var
space
=
Object
.
values
(
json
.
spaces
)[
0
];
// Simplify nodes
var
nodes
=
[];
Object
.
values
(
space
.
nodes
).
forEach
((
n
)
=>
{
var
references
=
Object
.
values
(
n
.
references
).
map
((
r
)
=>
r
.
url
);
nodes
.
push
({
id
:
n
.
node_id
,
name
:
n
.
title
,
description
:
n
.
description
,
type
:
n
.
type
.
name
,
color
:
n
.
type
.
color
,
video
:
n
.
video_url
,
icon
:
n
.
icon_url
,
header
:
n
.
header_url
,
references
:
references
});
});
// Simplify links
var
links
=
[];
Object
.
values
(
space
.
links
).
forEach
((
l
)
=>
{
links
.
push
({
source
:
l
.
source_node_id
,
target
:
l
.
target_node_id
,
});
});
// Convert to simple object
return
{
id
:
space
.
space_id
,
name
:
space
.
name
,
description
:
space
.
description
,
nodes
:
nodes
,
links
:
links
,
};
});
}
/**
* Returns the json object from the stored graph as promise.
*
* @param {String} spaceId Identification of graph to load.
*
* @returns Promise returning detailed space object.
*/
export
function
loadSpaceJson
(
spaceId
)
{
let
payload
=
{
let
payload
=
{
action
:
"
get_space
"
,
action
:
"
get_space
"
,
space_id
:
spaceId
,
space_id
:
spaceId
,
...
...
This diff is collapsed.
Click to expand it.
editor/editor.php
+
1
−
1
View file @
72aaa1c8
<div
id=
"ks-editor"
>
<div
id=
"ks-editor"
>
<!--The id "ks-editor" indicates, that the javascript associated with this should automatically be executed-->
<!--The id "ks-editor" indicates, that the javascript associated with this should automatically be executed-->
<h1>
Interface
</h1>
<h1>
Interface
<
span
id=
"header-space-title"
></span><
/h1>
<div
id=
"box-select-layer"
>
<div
id=
"box-select-layer"
>
<div
id=
"2d-graph"
></div>
<div
id=
"2d-graph"
></div>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
editor/js/editor.js
+
3
−
0
View file @
72aaa1c8
...
@@ -4,6 +4,7 @@ import { loadGraphJson } from "../../datasets/datasets";
...
@@ -4,6 +4,7 @@ import { loadGraphJson } from "../../datasets/datasets";
import
ForceGraph
from
"
force-graph
"
;
import
ForceGraph
from
"
force-graph
"
;
import
*
as
Interactions
from
"
./interactions
"
;
import
*
as
Interactions
from
"
./interactions
"
;
import
{
setSpace
,
SPACE
}
from
"
../../config
"
;
import
{
setSpace
,
SPACE
}
from
"
../../config
"
;
import
jquery
from
"
jquery
"
;
export
var
state
=
undefined
;
export
var
state
=
undefined
;
export
var
graph
=
undefined
;
export
var
graph
=
undefined
;
...
@@ -30,6 +31,8 @@ export function loadSpace(spaceId) {
...
@@ -30,6 +31,8 @@ export function loadSpace(spaceId) {
setSpace
(
spaceId
);
setSpace
(
spaceId
);
return
loadGraphJson
(
SPACE
).
then
((
graphConfig
)
=>
{
return
loadGraphJson
(
SPACE
).
then
((
graphConfig
)
=>
{
jquery
(
"
#ks-editor #header-space-title
"
).
text
(
"
-
"
+
graphConfig
.
name
+
"
[
"
+
graphConfig
.
id
+
"
]
"
);
state
=
new
State
();
state
=
new
State
();
graph
=
new
Graph
.
Graph
(
graphConfig
);
graph
=
new
Graph
.
Graph
(
graphConfig
);
load
();
load
();
...
...
This diff is collapsed.
Click to expand it.
knowledge-space.php
+
2
−
26
View file @
72aaa1c8
...
@@ -24,7 +24,7 @@ function ks_add_graph($atts = []): string
...
@@ -24,7 +24,7 @@ function ks_add_graph($atts = []): string
function
parse_atts
(
$atts
)
function
parse_atts
(
$atts
)
{
{
return
shortcode_atts
(
array
(
return
shortcode_atts
(
array
(
'space'
=>
'
space
'
,
'space'
=>
'
1
'
,
'mode'
=>
'default'
'mode'
=>
'default'
),
$atts
);
),
$atts
);
}
}
...
@@ -44,14 +44,13 @@ function ks_localize($handle, $atts)
...
@@ -44,14 +44,13 @@ function ks_localize($handle, $atts)
echo
'</pre>'
;
echo
'</pre>'
;
}
}
$space_id
=
kg_get_space_id_from_atts
(
$atts
);
// TODO: Replace with $params
$plugin_dir
=
plugin_dir_url
(
__FILE__
);
$plugin_dir
=
plugin_dir_url
(
__FILE__
);
wp_localize_script
(
wp_localize_script
(
$handle
,
$handle
,
'ks_global'
,
'ks_global'
,
array
(
array
(
'ajax_url'
=>
admin_url
(
'admin-ajax.php'
),
'ajax_url'
=>
admin_url
(
'admin-ajax.php'
),
'space_id'
=>
$space
_id
,
'space_id'
=>
$
params
[
'
space
'
]
,
'plugin_path'
=>
$plugin_dir
,
'plugin_path'
=>
$plugin_dir
,
'mode'
=>
$params
[
'mode'
]
'mode'
=>
$params
[
'mode'
]
)
)
...
@@ -79,29 +78,6 @@ function ks_load_styles() {
...
@@ -79,29 +78,6 @@ function ks_load_styles() {
wp_enqueue_style
(
'ks-style'
,
plugins_url
(
$styles_path
,
__FILE__
));
wp_enqueue_style
(
'ks-style'
,
plugins_url
(
$styles_path
,
__FILE__
));
}
}
function
kg_escape_space_id
(
$id
)
{
return
str_replace
(
"
\\
"
,
"-"
,
str_replace
(
"/"
,
"-"
,
str_replace
(
" "
,
"-"
,
$id
)
)
);
}
function
kg_get_space_id_from_atts
(
$atts
)
{
if
(
$atts
!=
""
&&
array_key_exists
(
"space"
,
$atts
))
{
return
kg_escape_space_id
(
$atts
[
"space"
]);
}
else
{
return
"space"
;
}
}
add_action
(
'admin_menu'
,
'kg_editor_admin_add_page'
);
add_action
(
'admin_menu'
,
'kg_editor_admin_add_page'
);
function
kg_editor_admin_add_page
()
function
kg_editor_admin_add_page
()
{
{
...
...
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