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
468f2012
Commit
468f2012
authored
11 months ago
by
Robin Leber
Browse files
Options
Downloads
Patches
Plain Diff
FEAT: replace pipe name in code if wished
parent
6e389179
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/functions/codeEditor.js
+1
-1
1 addition, 1 deletion
src/functions/codeEditor.js
src/functions/naming.js
+43
-0
43 additions, 0 deletions
src/functions/naming.js
src/functions/pipeBinding.js
+35
-4
35 additions, 4 deletions
src/functions/pipeBinding.js
with
79 additions
and
5 deletions
src/functions/codeEditor.js
+
1
−
1
View file @
468f2012
...
...
@@ -6,7 +6,7 @@ import { showCheck } from "./visualValidation";
import
{
handlePipeBinding
,
getPipesForFilter
}
from
"
./pipeBinding
"
;
let
editorValues
=
{
doc
:
"
const amqp = require('amqplib/callback_api');
\n\n
const rabbitmqUrl = 'amqp://mquser:mqpass@rabbit:5672';
\n\n
amqp.connect(rabbitmqUrl, (error0, connection) => {
\n
if (error0) {
\n
throw error0;
\n
}
\n
connection.createChannel((error1, channel) => {
\n
if (error1) {
\n
throw error1;
\n
}
\n\n
// START
pipe-binding
\n
//
incoming Pipes
\n
// outgoing Pipes
\n
// END
pipe-binding
\n\n
// TODO: Code logic here
\n\n\n\t
});
\n
});
\n
"
,
doc
:
"
// Please don't remove comments!
\n
const amqp = require('amqplib/callback_api');
\n\n
const rabbitmqUrl = 'amqp://mquser:mqpass@rabbit:5672';
\n\n
amqp.connect(rabbitmqUrl, (error0, connection) => {
\n
if (error0) {
\n
throw error0;
\n
}
\n
connection.createChannel((error1, channel) => {
\n
if (error1) {
\n
throw error1;
\n
}
\n\n
// START
PIPE-BINDING
\n
//
INCOMING PIPES
\n
// OUTGOING PIPES
\n
// END
PIPE-BINDING
\n\n
// TODO: Code logic here
\n\n\n\t
});
\n
});
\n
"
,
extensions
:
[
basicSetup
,
javascript
()],
};
...
...
This diff is collapsed.
Click to expand it.
src/functions/naming.js
+
43
−
0
View file @
468f2012
import
{
showCheck
}
from
"
./visualValidation
"
;
import
{
appState
}
from
"
./state
"
;
import
{
renamePipeNamesInCode
}
from
"
./pipeBinding
"
;
export
const
namePipe
=
(
instance
)
=>
{
let
newPipeName
;
const
selectedPipe
=
window
.
selectedPipe
;
const
pipeWasNamedBefore
=
appState
.
getPipe
(
selectedPipe
);
const
allConnections
=
instance
.
getAllConnections
();
const
pipeHasConnection
=
allConnections
.
some
(
(
con
)
=>
con
.
sourceId
===
selectedPipe
||
con
.
targetId
===
selectedPipe
);
while
(
true
)
{
newPipeName
=
prompt
(
"
Bitte geben Sie einen Pipe Namen ein:
"
);
...
...
@@ -15,6 +23,41 @@ export const namePipe = (instance) => {
alert
(
"
Dieser Name ist bereits vergeben. Bitte geben Sie einen anderen Namen ein.
"
);
}
else
if
(
pipeHasConnection
&&
pipeWasNamedBefore
&&
newPipeName
)
{
if
(
confirm
(
"
Durch ändern des Pipe Namens wird dein Code im Filter angepasst! Alle alten Pipe Namen werden durch den Neuen ersetzt.
"
)
)
{
const
oldPipeName
=
appState
.
getPipe
(
selectedPipe
);
const
tagetIds
=
allConnections
.
filter
((
con
)
=>
con
.
sourceId
===
selectedPipe
)
.
map
((
con
)
=>
con
.
targetId
);
const
sourceIds
=
allConnections
.
filter
((
con
)
=>
con
.
targetId
===
selectedPipe
)
.
map
((
con
)
=>
con
.
sourceId
);
const
filterIDs
=
[...
tagetIds
,
...
sourceIds
];
const
filterEditors
=
[];
filterIDs
.
forEach
((
id
)
=>
{
const
codeEditorEl
=
document
.
getElementById
(
`codeEditor
${
id
}
`
);
if
(
codeEditorEl
)
{
const
editor
=
codeEditorEl
.
editor
;
filterEditors
.
push
(
editor
);
}
});
if
(
filterEditors
.
length
!==
0
)
{
filterEditors
.
forEach
((
editor
)
=>
renamePipeNamesInCode
(
editor
,
oldPipeName
,
newPipeName
)
);
}
break
;
}
else
{
newPipeName
=
null
;
break
;
}
}
else
{
break
;
}
...
...
This diff is collapsed.
Click to expand it.
src/functions/pipeBinding.js
+
35
−
4
View file @
468f2012
...
...
@@ -29,7 +29,7 @@ export const getPipesForFilter = (instance) => {
const
pipeName
=
appState
.
getPipe
(
connection
.
pipeId
);
if
(
!
pipeName
)
{
const
pipeName
=
`Default
${
defaultCount
}
`
;
appState
.
addPipe
(
connection
,
pipeName
);
appState
.
addPipe
(
connection
.
pipeId
,
pipeName
);
const
pipe
=
{
pipeName
,
...
connection
};
pipeMapping
.
push
(
pipe
);
const
spanToChange
=
document
.
querySelector
(
...
...
@@ -51,9 +51,9 @@ export const getPipesForFilter = (instance) => {
export
const
handlePipeBinding
=
(
pipeMapping
,
editor
)
=>
{
// clear pipe-binindg code
let
codeArray
=
editor
.
state
.
doc
.
toString
();
const
start
=
"
//
incoming Pipes
"
;
const
middle
=
"
//
outgoing Pipes
"
;
const
end
=
"
// END
pipe-binding
"
;
const
start
=
"
//
INCOMING PIPES
"
;
const
middle
=
"
//
OUTGOING PIPES
"
;
const
end
=
"
// END
PIPE-BINDING
"
;
const
startIndex
=
codeArray
.
indexOf
(
start
);
const
midIndexIn
=
codeArray
.
indexOf
(
middle
);
...
...
@@ -139,6 +139,16 @@ const makeValidConstName = (str) => {
"
import
"
,
"
export
"
,
"
default
"
,
"
throw
"
,
"
callback
"
,
"
amqp
"
,
"
rabbitmqUrl
"
,
"
error0
"
,
"
error1
"
,
"
connection
"
,
"
channel
"
,
"
createConnection
"
,
"
createChannel
"
,
]);
if
(
reservedWords
.
has
(
validStr
))
{
validStr
=
"
_
"
+
validStr
;
...
...
@@ -204,3 +214,24 @@ const fillEditorwithCode = (editor, pipeMapping, lineNumber) => {
lineNumber
=
lineNumber
+
4
;
});
};
export
const
renamePipeNamesInCode
=
(
editor
,
oldName
,
newName
)
=>
{
const
oldNameInCode
=
makeValidConstName
(
oldName
);
const
newNameInCode
=
makeValidConstName
(
newName
);
const
codeString
=
editor
.
state
.
doc
.
toString
();
const
from
=
"
// TODO: Code logic here
"
;
const
fromIndex
=
codeString
.
indexOf
(
from
);
const
codeToChange
=
codeString
.
slice
(
fromIndex
);
const
newCodeString
=
codeToChange
.
replaceAll
(
oldNameInCode
,
newNameInCode
);
const
transaction
=
editor
.
state
.
update
({
changes
:
[
{
from
:
fromIndex
,
to
:
editor
.
state
.
doc
.
length
,
insert
:
newCodeString
,
},
],
});
editor
.
dispatch
(
transaction
);
};
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