Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
verona-modules-aspect
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
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
IQB
verona-modules-aspect
Commits
2ca15907
Commit
2ca15907
authored
3 years ago
by
rhenck
Browse files
Options
Downloads
Patches
Plain Diff
[editor] Refactor Verona API Service
Introduce interfaces and clean the structure.
parent
33e72a0b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
projects/editor/src/app/app.component.ts
+3
-4
3 additions, 4 deletions
projects/editor/src/app/app.component.ts
projects/editor/src/app/services/verona-api.service.ts
+21
-11
21 additions, 11 deletions
projects/editor/src/app/services/verona-api.service.ts
with
24 additions
and
15 deletions
projects/editor/src/app/app.component.ts
+
3
−
4
View file @
2ca15907
...
...
@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import
{
TranslateService
}
from
'
@ngx-translate/core
'
;
import
{
registerLocaleData
}
from
'
@angular/common
'
;
import
localeDe
from
'
@angular/common/locales/de
'
;
import
{
VeronaAPIService
}
from
'
./services/verona-api.service
'
;
import
{
VeronaAPIService
,
VoeStartCommand
}
from
'
./services/verona-api.service
'
;
import
{
UnitService
}
from
'
./services/unit.service
'
;
@
Component
({
...
...
@@ -18,7 +18,6 @@ import { UnitService } from './services/unit.service';
]
})
export
class
AppComponent
implements
OnInit
{
editorConfig
!
:
Record
<
string
,
any
>
;
isStandalone
=
():
boolean
=>
window
===
window
.
parent
;
constructor
(
private
unitService
:
UnitService
,
...
...
@@ -30,12 +29,12 @@ export class AppComponent implements OnInit {
ngOnInit
():
void
{
this
.
veronaApiService
.
voeStartCommand
.
subscribe
((
message
:
Record
<
string
,
any
>
):
void
=>
{
.
subscribe
((
message
:
VoeStartCommand
):
void
=>
{
this
.
unitService
.
loadUnitDefinition
(
message
.
unitDefinition
);
});
this
.
veronaApiService
.
voeGetDefinitionRequest
.
subscribe
(()
=>
{
this
.
veronaApiService
.
sendVoeDefinitionChangedNotification
(
this
.
unitService
.
getUnitAsJSON
(
));
this
.
veronaApiService
.
sendVoeDefinitionChangedNotification
(
JSON
.
stringify
(
this
.
unitService
.
unit
));
});
this
.
veronaApiService
.
sendVoeReadyNotification
();
...
...
This diff is collapsed.
Click to expand it.
projects/editor/src/app/services/verona-api.service.ts
+
21
−
11
View file @
2ca15907
...
...
@@ -6,32 +6,29 @@ import { fromEvent, Observable, Subject } from 'rxjs';
})
export
class
VeronaAPIService
{
sessionID
:
string
=
''
;
private
_voeStartCommand
=
new
Subject
<
Record
<
string
,
string
>
>
();
// TODO proper interfaces
private
_voeGetDefinitionRequest
=
new
Subject
<
Record
<
string
,
string
>
>
();
private
_voeStartCommand
=
new
Subject
<
VoeStartCommand
>
();
// TODO proper interfaces
private
_voeGetDefinitionRequest
=
new
Subject
<
VoeGetDefinitionRequest
>
();
private
isStandalone
=
():
boolean
=>
window
===
window
.
parent
;
constructor
()
{
fromEvent
(
window
,
'
message
'
)
.
subscribe
((
event
:
Event
):
void
=>
{
const
message
=
(
event
as
MessageEvent
).
data
;
this
.
handleMessage
(
message
);
this
.
handleMessage
((
event
as
MessageEvent
).
data
);
});
}
private
handleMessage
(
messageData
:
Record
<
string
,
string
>
):
void
{
private
handleMessage
(
messageData
:
VoeGetDefinitionRequest
|
VoeStartCommand
):
void
{
switch
(
messageData
.
type
)
{
case
'
voeStartCommand
'
:
// console.log('editor: voeStartCommand ', messageData);
this
.
sessionID
=
messageData
.
sessionId
;
this
.
_voeStartCommand
.
next
(
messageData
);
this
.
_voeStartCommand
.
next
(
messageData
as
VoeStartCommand
);
break
;
case
'
voeGetDefinitionRequest
'
:
// console.log('editor: voeGetDefinitionRequest ', messageData);
this
.
_voeGetDefinitionRequest
.
next
(
messageData
);
break
;
default
:
//
console.warn(`editor: got message of unknown type ${messageData
.type
}`);
console
.
warn
(
`editor: got message of unknown type
${
messageData
}
`
);
}
}
...
...
@@ -63,11 +60,24 @@ export class VeronaAPIService {
});
}
get
voeStartCommand
():
Observable
<
an
y
>
{
get
voeStartCommand
():
Observable
<
VoeStartComm
an
d
>
{
return
this
.
_voeStartCommand
.
asObservable
();
}
get
voeGetDefinitionRequest
():
Observable
<
any
>
{
get
voeGetDefinitionRequest
():
Observable
<
VoeGetDefinitionRequest
>
{
return
this
.
_voeGetDefinitionRequest
.
asObservable
();
}
}
export
interface
VoeStartCommand
extends
MessageEvent
{
sessionId
:
string
,
unitDefinition
:
string
,
unitDefinitionType
:
string
,
editorConfig
:
{
definitionReportPolicy
:
string
}
}
export
interface
VoeGetDefinitionRequest
extends
MessageEvent
{
sessionId
:
string
}
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