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
46e7ead9
Commit
46e7ead9
authored
3 years ago
by
Maximilian Giller
Browse files
Options
Downloads
Patches
Plain Diff
Basic importer
parent
fa604722
No related branches found
No related tags found
No related merge requests found
Pipeline
#54761
passed
3 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
editor/editor.php
+20
-0
20 additions, 0 deletions
editor/editor.php
editor/js/interactions.js
+48
-4
48 additions, 4 deletions
editor/js/interactions.js
with
68 additions
and
4 deletions
editor/editor.php
+
20
−
0
View file @
46e7ead9
...
...
@@ -93,6 +93,26 @@
</br>
<input
type=
"number"
onkeypress=
"return (event.charCode !=8 && event.charCode ==0 || (event.charCode >= 48 && event.charCode <= 57))"
value=
"5"
id=
"stop-physics-delay"
name=
"stop-physics-delay"
class=
"small-width"
>
</input>
</br>
</br>
<h3>
Import Space
</h3>
<label
for=
"import-space-area"
>
Space JSON
</label>
</br>
<textarea
id=
"import-space-area"
name=
"import-space-area"
class=
"bottom-space"
>
</textarea>
</br>
<label
for=
"import-space-name-text"
>
Space Name
</label>
</br>
<input
type=
"text"
id=
"import-space-name-text"
name=
"import-space-name-text"
class=
"bottom-space"
>
</input>
</br>
<button
id=
"import-space-btn"
name=
"import-space-btn"
class=
"bottom-space"
>
Import
</button>
</br>
</br>
</div>
</section>
</div>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
editor/js/interactions.js
+
48
−
4
View file @
46e7ead9
import
jQuery
from
"
jquery
"
;
import
{
state
}
from
"
./editor
"
;
import
{
listAllSpaces
}
from
"
../../datasets/datasets
"
;
import
{
listAllSpaces
,
saveGraphJson
}
from
"
../../datasets/datasets
"
;
import
{
SPACE
}
from
"
../../config
"
;
/**
...
...
@@ -11,18 +11,62 @@ export function initInteractions() {
state
.
clearSelectedItems
();
});
// Fill space dropdown
jQuery
(
"
button#import-space-btn
"
).
on
(
"
click
"
,
()
=>
importSpaceFromInterface
()
);
loadSpacesList
();
}
function
loadSpacesList
()
{
var
selectContainer
=
jQuery
(
"
#space-id-select
"
);
selectContainer
.
empty
();
listAllSpaces
().
then
((
spaces
)
=>
{
spaces
.
forEach
(
space
=>
{
spaces
.
forEach
(
(
space
)
=>
{
var
selectedTxt
=
""
;
if
(
space
===
SPACE
)
{
selectedTxt
=
"
selected
"
;
}
var
child
=
"
<option
"
+
selectedTxt
+
"
value=
\"
"
+
space
+
"
\"
>
"
+
space
+
"
</option>
"
var
child
=
"
<option
"
+
selectedTxt
+
'
value="
'
+
space
+
'
">
'
+
space
+
"
</option>
"
;
selectContainer
.
append
(
child
);
});
});
selectContainer
.
val
(
SPACE
);
}
function
importSpaceFromInterface
()
{
var
json
=
undefined
;
try
{
console
.
log
(
jQuery
(
"
#import-space-area
"
).
val
());
json
=
JSON
.
parse
(
jQuery
(
"
#import-space-area
"
).
val
());
}
catch
(
e
)
{
console
.
log
(
e
);
alert
(
'
"Space JSON" not valid. Check console for details.
'
);
return
;
}
var
spaceName
=
jQuery
(
"
#import-space-name-text
"
).
val
();
if
(
spaceName
.
length
==
0
)
{
alert
(
'
"Space Name" cannot be empty.
'
);
return
;
}
saveGraphJson
(
spaceName
,
json
)
.
then
(()
=>
{
loadSpacesList
();
alert
(
"
Space imported!
"
);
})
.
catch
((
ex
)
=>
{
console
.
log
(
ex
);
alert
(
"
Something went wrong, could not import space. Check console for further details.
"
);
});
}
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