Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
masterarbeit-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Robin Leber
masterarbeit-frontend
Commits
38136c8b
Commit
38136c8b
authored
1 year ago
by
Robin Leber
Browse files
Options
Downloads
Patches
Plain Diff
FIX: pipe name uniqueness and editable
parent
4507bd30
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/functions/duplication.js
+26
-19
26 additions, 19 deletions
src/functions/duplication.js
src/functions/id.js
+8
-0
8 additions, 0 deletions
src/functions/id.js
src/index.html
+2
-0
2 additions, 0 deletions
src/index.html
src/main.js
+2
-1
2 additions, 1 deletion
src/main.js
with
38 additions
and
20 deletions
src/functions/duplication.js
+
26
−
19
View file @
38136c8b
...
...
@@ -2,12 +2,13 @@ import { v4 as uuidv4 } from "uuid";
import
{
createEndpoints
}
from
"
./endpoints
"
;
import
{
appState
}
from
"
./state
"
;
import
{
showWarning
}
from
"
./visualValidation
"
;
import
{
shortenId
}
from
"
./id
"
;
export
const
duplicatePipe
=
(
instance
)
=>
{
const
selectedPipe
=
document
.
getElementById
(
window
.
selectedPipe
);
const
newPipe
=
selectedPipe
.
cloneNode
(
true
);
newPipe
.
id
=
uuidv4
();
newPipe
.
id
=
shortenId
(
uuidv4
()
)
;
const
top
=
selectedPipe
.
offsetTop
+
36
;
const
topStr
=
top
.
toString
()
+
"
px
"
;
...
...
@@ -30,7 +31,7 @@ export const duplicateFilter = (instance) => {
const
selectedFilter
=
document
.
getElementById
(
window
.
selectedFilter
);
const
newFilter
=
selectedFilter
.
cloneNode
(
true
);
newFilter
.
id
=
uuidv4
();
newFilter
.
id
=
shortenId
(
uuidv4
()
)
;
const
top
=
selectedFilter
.
offsetTop
+
48
;
const
topStr
=
top
.
toString
()
+
"
px
"
;
...
...
@@ -50,25 +51,31 @@ export const duplicateFilter = (instance) => {
};
export
const
extendPipe
=
()
=>
{
let
newPipeName
=
prompt
(
"
Bitte geben Sie einen Pipe Namen ein:
"
);
const
pipeToName
=
document
.
getElementById
(
window
.
selectedPipe
);
if
(
pipeToName
)
{
var
textIndex
=
pipeToName
.
innerHTML
.
indexOf
(
"
Queue
"
);
textIndex
===
-
1
?
(
textIndex
=
pipeToName
.
innerHTML
.
indexOf
(
"
Topic
"
))
:
null
;
if
(
textIndex
!==
-
1
)
{
var
beforeQueue
=
pipeToName
.
innerHTML
.
slice
(
0
,
textIndex
+
"
Queue
"
.
length
);
var
afterQueue
=
pipeToName
.
innerHTML
.
slice
(
textIndex
+
"
Queue
"
.
length
);
let
newPipeName
;
while
(
true
)
{
newPipeName
=
prompt
(
"
Bitte geben Sie einen Pipe Namen ein:
"
);
var
newContent
=
beforeQueue
+
`<br> "
${
newPipeName
}
"`
+
afterQueue
;
let
nameExists
=
Array
.
from
(
appState
.
getState
().
pipes
.
values
()).
includes
(
newPipeName
);
pipeToName
.
innerHTML
=
newContent
;
if
(
nameExists
)
{
alert
(
"
Dieser Name ist bereits vergeben. Bitte geben Sie einen anderen Namen ein.
"
);
}
else
{
break
;
}
appState
.
addPipe
(
pipeToName
.
id
,
newPipeName
);
}
if
(
window
.
selectedPipe
&&
newPipeName
)
{
appState
.
addPipe
(
window
.
selectedPipe
,
newPipeName
);
const
spanToChange
=
document
.
querySelector
(
`#
${
window
.
selectedPipe
}
#PipeName`
);
spanToChange
.
innerHTML
=
`"
${
newPipeName
}
"`
;
console
.
log
(
appState
.
getState
().
pipes
);
}
};
This diff is collapsed.
Click to expand it.
src/functions/id.js
0 → 100644
+
8
−
0
View file @
38136c8b
export
const
shortenId
=
(
uuid
)
=>
{
const
startsWithNumber
=
/^
\d
/
.
test
(
uuid
);
if
(
startsWithNumber
)
{
uuid
=
uuid
.
replace
(
/^
\d
+/
,
""
);
}
return
uuid
;
};
This diff is collapsed.
Click to expand it.
src/index.html
+
2
−
0
View file @
38136c8b
...
...
@@ -27,6 +27,8 @@
<h5>
PIPES
</h5>
<div
class=
"Pipe"
data-type=
"Default"
>
Queue
<br
/>
<span
id=
"PipeName"
></span>
<i
id=
"Warning"
class=
"fa-sharp fa-solid fa-xl fa-circle-exclamation"
...
...
This diff is collapsed.
Click to expand it.
src/main.js
+
2
−
1
View file @
38136c8b
...
...
@@ -14,6 +14,7 @@ import {
}
from
"
./functions/api
"
;
import
{
getScaleValues
}
from
"
./functions/scaling
"
;
import
{
showAllWarning
}
from
"
./functions/visualValidation
"
;
import
{
shortenId
}
from
"
./functions/id
"
;
function
App
()
{
const
instance
=
jsPlumb
.
getInstance
({});
...
...
@@ -61,7 +62,7 @@ function App() {
// Diagramm DIV droppable machen
$
(
"
#Diagram
"
).
droppable
({
drop
:
function
(
event
,
ui
)
{
var
id
=
uuidv4
();
var
id
=
shortenId
(
uuidv4
()
)
;
var
clone
=
$
(
ui
.
helper
).
clone
(
true
);
clone
.
attr
(
"
id
"
,
id
);
clone
.
appendTo
(
this
);
...
...
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