Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
X-tee
X-Road-catalogue
Commits
feb028cb
Commit
feb028cb
authored
Mar 18, 2019
by
Vitali Stupin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing lint warnings
parent
753f9357
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
206 additions
and
206 deletions
+206
-206
src/app/app-routing.module.ts
src/app/app-routing.module.ts
+1
-1
src/app/app.component.html
src/app/app.component.html
+1
-1
src/app/app.component.spec.ts
src/app/app.component.spec.ts
+1
-1
src/app/app.module.ts
src/app/app.module.ts
+1
-1
src/app/config.ts
src/app/config.ts
+8
-8
src/app/header/header.component.html
src/app/header/header.component.html
+1
-1
src/app/header/header.component.ts
src/app/header/header.component.ts
+5
-5
src/app/languages.service.ts
src/app/languages.service.ts
+18
-18
src/app/subsystem-list/search/search.component.spec.ts
src/app/subsystem-list/search/search.component.spec.ts
+1
-1
src/app/subsystem-list/search/search.component.ts
src/app/subsystem-list/search/search.component.ts
+9
-9
src/app/subsystem-list/subsystem-item/subsystem-item.component.css
...ubsystem-list/subsystem-item/subsystem-item.component.css
+1
-1
src/app/subsystem-list/subsystem-item/subsystem-item.component.html
...bsystem-list/subsystem-item/subsystem-item.component.html
+1
-1
src/app/subsystem-list/subsystem-item/subsystem-item.component.spec.ts
...stem-list/subsystem-item/subsystem-item.component.spec.ts
+9
-9
src/app/subsystem-list/subsystem-item/subsystem-item.component.ts
...subsystem-list/subsystem-item/subsystem-item.component.ts
+7
-7
src/app/subsystem-list/subsystem-list.component.spec.ts
src/app/subsystem-list/subsystem-list.component.spec.ts
+6
-6
src/app/subsystem-list/subsystem-list.component.ts
src/app/subsystem-list/subsystem-list.component.ts
+31
-31
src/app/subsystem/subsystem.component.spec.ts
src/app/subsystem/subsystem.component.spec.ts
+9
-9
src/app/subsystem/subsystem.component.ts
src/app/subsystem/subsystem.component.ts
+37
-37
src/app/subsystems.service.spec.ts
src/app/subsystems.service.spec.ts
+1
-1
src/app/subsystems.service.ts
src/app/subsystems.service.ts
+56
-56
src/assets/i18n/eng.json
src/assets/i18n/eng.json
+1
-1
src/assets/i18n/est.json
src/assets/i18n/est.json
+1
-1
No files found.
src/app/app-routing.module.ts
View file @
feb028cb
...
...
@@ -15,4 +15,4 @@ const routes: Routes = [
imports
:
[
RouterModule
.
forRoot
(
routes
,
{
scrollPositionRestoration
:
'
enabled
'
})
],
exports
:
[
RouterModule
]
})
export
class
AppRoutingModule
{}
\ No newline at end of file
export
class
AppRoutingModule
{}
src/app/app.component.html
View file @
feb028cb
...
...
@@ -2,4 +2,4 @@
<router-outlet></router-outlet>
</div>
\ No newline at end of file
</div>
src/app/app.component.spec.ts
View file @
feb028cb
import
{
TestBed
,
async
}
from
'
@angular/core/testing
'
;
import
{
RouterTestingModule
}
from
'
@angular/router/testing
'
import
{
RouterTestingModule
}
from
'
@angular/router/testing
'
;
import
{
AppComponent
}
from
'
./app.component
'
;
describe
(
'
AppComponent
'
,
()
=>
{
...
...
src/app/app.module.ts
View file @
feb028cb
...
...
@@ -42,4 +42,4 @@ export class AppModule { }
export
function
HttpLoaderFactory
(
http
:
HttpClient
)
{
// Providing path as a workaround for ngx-translate bug with --base-href option
return
new
TranslateHttpLoader
(
http
,
'
./assets/i18n/
'
);
}
\ No newline at end of file
}
src/app/config.ts
View file @
feb028cb
export
const
MAX_LIMIT
:
number
=
1000000
;
export
const
DEFAULT_LIMIT
:
number
=
10
;
export
const
MAX_LIMIT
=
1000000
;
export
const
DEFAULT_LIMIT
=
10
;
export
const
INSTANCES
=
{
'
EE
'
:
'
https://www.x-tee.ee/catalogue/EE/wsdls/
'
,
EE
:
'
https://www.x-tee.ee/catalogue/EE/wsdls/
'
,
'
ee-test
'
:
'
https://www.x-tee.ee/catalogue/ee-test/wsdls/
'
,
'
ee-dev
'
:
'
https://www.x-tee.ee/catalogue/ee-dev/wsdls/
'
}
}
;
export
const
API_SERVICE
=
'
index.json
'
;
export
const
LANGUAGES
=
{
'
EST
'
:
'
est
'
,
'
ENG
'
:
'
eng
'
}
export
const
PREVIEW_SIZE
:
number
=
5
EST
:
'
est
'
,
ENG
:
'
eng
'
}
;
export
const
PREVIEW_SIZE
=
5
;
src/app/header/header.component.html
View file @
feb028cb
...
...
@@ -7,4 +7,4 @@
</li>
</ul>
</div>
</div>
\ No newline at end of file
</div>
src/app/header/header.component.ts
View file @
feb028cb
...
...
@@ -10,16 +10,16 @@ export class HeaderComponent implements OnInit {
constructor
(
private
languagesService
:
LanguagesService
)
{
}
getLangs
():
string
[]
{
return
this
.
languagesService
.
getLangs
()
getLangs
():
string
[]
{
return
this
.
languagesService
.
getLangs
()
;
}
getLang
():
string
{
return
this
.
languagesService
.
getLang
()
getLang
():
string
{
return
this
.
languagesService
.
getLang
()
;
}
setLang
(
lang
:
string
)
{
return
this
.
languagesService
.
setLang
(
lang
)
return
this
.
languagesService
.
setLang
(
lang
)
;
}
ngOnInit
()
{}
...
...
src/app/languages.service.ts
View file @
feb028cb
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
TranslateService
}
from
"
@ngx-translate/core
"
;
import
{
TranslateService
}
from
'
@ngx-translate/core
'
;
import
{
Title
}
from
'
@angular/platform-browser
'
;
import
{
Subscription
}
from
'
rxjs
'
;
import
{
take
}
from
'
rxjs/operators
'
;
import
{
LANGUAGES
}
from
'
./config
'
import
{
LANGUAGES
}
from
'
./config
'
;
@
Injectable
({
providedIn
:
'
root
'
})
export
class
LanguagesService
{
private
selectedLang
=
''
private
translateSubscription
:
Subscription
private
selectedLang
=
''
;
private
translateSubscription
:
Subscription
;
constructor
(
private
translate
:
TranslateService
,
private
title
:
Title
)
{
this
.
selectedLang
=
this
.
getDefaultLang
()
translate
.
setDefaultLang
(
LANGUAGES
[
this
.
selectedLang
])
this
.
updateTitle
()
this
.
selectedLang
=
this
.
getDefaultLang
()
;
translate
.
setDefaultLang
(
LANGUAGES
[
this
.
selectedLang
])
;
this
.
updateTitle
()
;
}
updateTitle
():
void
{
// Not subscribing if subscription already in progress
if
(
!
this
.
translateSubscription
||
this
.
translateSubscription
.
closed
)
{
this
.
translateSubscription
=
this
.
translate
.
get
(
'
index.title
'
).
pipe
(
take
(
1
)).
subscribe
((
res
:
string
)
=>
{
this
.
title
.
setTitle
(
res
)
this
.
title
.
setTitle
(
res
)
;
});
}
}
getDefaultLang
():
string
{
if
(
window
&&
window
.
localStorage
&&
window
.
localStorage
.
getItem
(
'
lang
'
))
{
return
window
.
localStorage
.
getItem
(
'
lang
'
)
if
(
window
&&
window
.
localStorage
&&
window
.
localStorage
.
getItem
(
'
lang
'
))
{
return
window
.
localStorage
.
getItem
(
'
lang
'
)
;
}
return
Object
.
keys
(
LANGUAGES
)[
0
]
return
Object
.
keys
(
LANGUAGES
)[
0
]
;
}
getLangs
():
string
[]
{
return
Object
.
keys
(
LANGUAGES
)
return
Object
.
keys
(
LANGUAGES
)
;
}
getLang
():
string
{
return
this
.
selectedLang
return
this
.
selectedLang
;
}
setLang
(
lang
:
string
):
void
{
this
.
selectedLang
=
lang
if
(
window
&&
window
.
localStorage
)
{
window
.
localStorage
.
setItem
(
'
lang
'
,
this
.
selectedLang
)
this
.
selectedLang
=
lang
;
if
(
window
&&
window
.
localStorage
)
{
window
.
localStorage
.
setItem
(
'
lang
'
,
this
.
selectedLang
)
;
}
this
.
translate
.
use
(
LANGUAGES
[
this
.
selectedLang
]);
this
.
updateTitle
()
this
.
updateTitle
()
;
}
}
src/app/subsystem-list/search/search.component.spec.ts
View file @
feb028cb
...
...
@@ -29,4 +29,4 @@ describe('SearchComponent', () => {
it
(
'
should create
'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
\ No newline at end of file
});
src/app/subsystem-list/search/search.component.ts
View file @
feb028cb
...
...
@@ -8,27 +8,27 @@ import { SubsystemsService } from '../../subsystems.service';
})
export
class
SearchComponent
implements
OnInit
{
limit
:
string
nonEmpty
:
boolean
filter
:
string
limit
:
string
;
nonEmpty
:
boolean
;
filter
:
string
;
constructor
(
private
subsystemsService
:
SubsystemsService
)
{
}
setNonEmpty
(
nonEmpty
:
boolean
)
{
this
.
subsystemsService
.
setNonEmpty
(
nonEmpty
)
this
.
subsystemsService
.
setNonEmpty
(
nonEmpty
)
;
}
setLimit
(
limit
:
string
)
{
this
.
subsystemsService
.
setLimit
(
limit
)
this
.
subsystemsService
.
setLimit
(
limit
)
;
}
setFilter
(
filter
:
string
)
{
this
.
subsystemsService
.
setFilter
(
filter
)
this
.
subsystemsService
.
setFilter
(
filter
)
;
}
ngOnInit
()
{
this
.
limit
=
this
.
subsystemsService
.
getLimit
()
this
.
nonEmpty
=
this
.
subsystemsService
.
getNonEmpty
()
this
.
filter
=
this
.
subsystemsService
.
getfilter
()
this
.
limit
=
this
.
subsystemsService
.
getLimit
()
;
this
.
nonEmpty
=
this
.
subsystemsService
.
getNonEmpty
()
;
this
.
filter
=
this
.
subsystemsService
.
getfilter
()
;
}
}
src/app/subsystem-list/subsystem-item/subsystem-item.component.css
View file @
feb028cb
.pointerCursor
{
cursor
:
pointer
;
}
\ No newline at end of file
}
src/app/subsystem-list/subsystem-item/subsystem-item.component.html
View file @
feb028cb
...
...
@@ -23,4 +23,4 @@
{{'subsystem.moreMethods' | translate:{"count": getNotInPreview()} }}
</p>
</div>
</div>
\ No newline at end of file
</div>
src/app/subsystem-list/subsystem-item/subsystem-item.component.spec.ts
View file @
feb028cb
...
...
@@ -11,7 +11,7 @@ describe('SubsystemItemComponent', () => {
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
SubsystemItemComponent
SubsystemItemComponent
],
imports
:
[
TranslateModule
.
forRoot
(),
...
...
@@ -27,14 +27,14 @@ describe('SubsystemItemComponent', () => {
component
=
fixture
.
componentInstance
;
component
.
subsystem
=
{
xRoadInstance
:
"
XRD
"
,
memberClass
:
"
CLASS
"
,
memberCode
:
"
CODE
"
,
subsystemCode
:
"
SUB
"
,
subsystemStatus
:
"
OK
"
,
fullSubsystemName
:
"
XRD/CLASS/CODE/SUB
"
,
xRoadInstance
:
'
XRD
'
,
memberClass
:
'
CLASS
'
,
memberCode
:
'
CODE
'
,
subsystemCode
:
'
SUB
'
,
subsystemStatus
:
'
OK
'
,
fullSubsystemName
:
'
XRD/CLASS/CODE/SUB
'
,
methods
:
[]
}
}
;
fixture
.
detectChanges
();
});
...
...
@@ -42,4 +42,4 @@ describe('SubsystemItemComponent', () => {
it
(
'
should create
'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
\ No newline at end of file
});
src/app/subsystem-list/subsystem-item/subsystem-item.component.ts
View file @
feb028cb
...
...
@@ -3,7 +3,7 @@ import { Subsystem } from '../../subsystem';
import
{
Method
}
from
'
../../method
'
;
import
{
SubsystemsService
}
from
'
../../subsystems.service
'
;
import
{
Router
}
from
'
@angular/router
'
;
import
{
PREVIEW_SIZE
}
from
'
../../config
'
import
{
PREVIEW_SIZE
}
from
'
../../config
'
;
@
Component
({
selector
:
'
app-subsystem-item
'
,
...
...
@@ -11,7 +11,7 @@ import { PREVIEW_SIZE } from '../../config'
styleUrls
:
[
'
./subsystem-item.component.css
'
]
})
export
class
SubsystemItemComponent
implements
OnInit
{
@
Input
()
subsystem
:
Subsystem
@
Input
()
subsystem
:
Subsystem
;
constructor
(
private
subsystemsService
:
SubsystemsService
,
...
...
@@ -19,18 +19,18 @@ export class SubsystemItemComponent implements OnInit {
)
{
}
getApiUrlBase
():
string
{
return
this
.
subsystemsService
.
getApiUrlBase
()
return
this
.
subsystemsService
.
getApiUrlBase
()
;
}
getMethodsPreview
():
Method
[]
{
return
this
.
subsystem
.
methods
.
length
?
this
.
subsystem
.
methods
.
slice
(
0
,
PREVIEW_SIZE
)
:
[]
return
this
.
subsystem
.
methods
.
length
?
this
.
subsystem
.
methods
.
slice
(
0
,
PREVIEW_SIZE
)
:
[]
;
}
getNotInPreview
():
number
{
if
(
this
.
subsystem
.
methods
.
length
-
PREVIEW_SIZE
<
0
)
{
return
0
return
0
;
}
return
this
.
subsystem
.
methods
.
length
-
PREVIEW_SIZE
return
this
.
subsystem
.
methods
.
length
-
PREVIEW_SIZE
;
}
showDetail
()
{
...
...
@@ -39,7 +39,7 @@ export class SubsystemItemComponent implements OnInit {
+
'
/
'
+
this
.
subsystem
.
memberClass
+
'
/
'
+
this
.
subsystem
.
memberCode
+
'
/
'
+
this
.
subsystem
.
subsystemCode
)
)
;
}
ngOnInit
()
{}
...
...
src/app/subsystem-list/subsystem-list.component.spec.ts
View file @
feb028cb
import
{
async
,
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
TranslateModule
}
from
'
@ngx-translate/core
'
;
import
{
HttpClientModule
}
from
'
@angular/common/http
'
;
import
{
RouterTestingModule
}
from
'
@angular/router/testing
'
import
{
RouterTestingModule
}
from
'
@angular/router/testing
'
;
import
{
SubsystemListComponent
}
from
'
./subsystem-list.component
'
;
import
{
Component
,
Input
}
from
'
@angular/core
'
;
import
{
Subsystem
}
from
'
../subsystem
'
;
import
{
ActivatedRoute
}
from
'
@angular/router
'
;
import
{
of
}
from
'
rxjs
'
;
@
Component
({
selector
:
'
app-header
'
,
template
:
''
})
class
HeaderStubComponent
{}
@
Component
({
selector
:
'
app-search
'
,
template
:
''
})
class
SearchStubComponent
{}
@
Component
({
selector
:
'
app-subsystem-item
'
,
template
:
''
})
class
SubsystemItemStubComponent
{
@
Input
()
subsystem
:
Subsystem
@
Input
()
subsystem
:
Subsystem
;
}
describe
(
'
SubsystemListComponent
'
,
()
=>
{
...
...
@@ -41,8 +41,8 @@ describe('SubsystemListComponent', () => {
beforeEach
(()
=>
{
// Mocks and spies
TestBed
.
get
(
ActivatedRoute
).
params
=
of
({
"
instance
"
:
"
EE
"
})
instance
:
'
EE
'
})
;
fixture
=
TestBed
.
createComponent
(
SubsystemListComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
...
...
@@ -51,4 +51,4 @@ describe('SubsystemListComponent', () => {
it
(
'
should create
'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
\ No newline at end of file
});
src/app/subsystem-list/subsystem-list.component.ts
View file @
feb028cb
import
{
Component
,
OnInit
,
OnDestroy
}
from
'
@angular/core
'
;
import
{
Component
,
OnInit
,
AfterViewInit
,
OnDestroy
}
from
'
@angular/core
'
;
import
{
Subsystem
}
from
'
../subsystem
'
;
import
{
SubsystemsService
}
from
'
../subsystems.service
'
;
import
{
ActivatedRoute
,
Router
,
Scroll
}
from
'
@angular/router
'
;
...
...
@@ -11,15 +11,15 @@ import { filter } from 'rxjs/operators';
templateUrl
:
'
./subsystem-list.component.html
'
,
styleUrls
:
[
'
./subsystem-list.component.css
'
]
})
export
class
SubsystemListComponent
implements
OnInit
,
OnDestroy
{
subsystems
:
Subsystem
[]
message
:
string
=
''
export
class
SubsystemListComponent
implements
OnInit
,
AfterViewInit
,
OnDestroy
{
subsystems
:
Subsystem
[]
;
message
=
''
;
scrollSubject
:
BehaviorSubject
<
any
>
=
new
BehaviorSubject
(
null
);
routerScrollSubscription
:
Subscription
routeSubscription
:
Subscription
warningsSubscription
:
Subscription
scrollSubjectSubscription
:
Subscription
filteredSubsystems
:
BehaviorSubject
<
Subsystem
[]
>
routerScrollSubscription
:
Subscription
;
routeSubscription
:
Subscription
;
warningsSubscription
:
Subscription
;
scrollSubjectSubscription
:
Subscription
;
filteredSubsystems
:
BehaviorSubject
<
Subsystem
[]
>
;
constructor
(
private
subsystemsService
:
SubsystemsService
,
...
...
@@ -30,51 +30,51 @@ export class SubsystemListComponent implements OnInit, OnDestroy {
// Geting previous scroll position
this
.
routerScrollSubscription
=
this
.
router
.
events
.
pipe
(
filter
(
e
=>
e
instanceof
Scroll
)
).
subscribe
(
async
(
e
)
=>
{
).
subscribe
(
async
(
e
)
=>
{
if
((
e
as
Scroll
).
position
)
{
this
.
scrollSubject
.
next
((
e
as
Scroll
).
position
)
this
.
scrollSubject
.
next
((
e
as
Scroll
).
position
)
;
}
});
}
getInstance
():
string
{
return
this
.
subsystemsService
.
getInstance
()
return
this
.
subsystemsService
.
getInstance
()
;
}
getInstances
():
string
[]
{
return
this
.
subsystemsService
.
getInstances
()
return
this
.
subsystemsService
.
getInstances
()
;
}
switchInstance
(
instance
:
string
):
void
{
this
.
router
.
navigateByUrl
(
'
/
'
+
instance
)
this
.
router
.
navigateByUrl
(
'
/
'
+
instance
)
;
}
getApiUrl
():
string
{
return
this
.
subsystemsService
.
getApiUrl
()
return
this
.
subsystemsService
.
getApiUrl
()
;
}
ngOnInit
()
{
// Reset message on page load
this
.
message
=
''
this
.
filteredSubsystems
=
this
.
subsystemsService
.
filteredSubsystemsSubject
this
.
message
=
''
;
this
.
filteredSubsystems
=
this
.
subsystemsService
.
filteredSubsystemsSubject
;
// Service will tell when data loading failed!
this
.
warningsSubscription
=
this
.
subsystemsService
.
warnings
.
subscribe
(
signal
=>
{
this
.
message
=
signal
this
.
message
=
signal
;
});
this
.
routeSubscription
=
this
.
route
.
params
.
subscribe
(
params
=>
{
// Reset message on navigation
this
.
message
=
''
this
.
message
=
''
;
// Redirect to default instance if instance is empty or invalid
if
(
!
this
.
subsystemsService
.
getInstances
().
includes
(
params
[
'
instance
'
]
))
{
this
.
router
.
navigateByUrl
(
'
/
'
+
this
.
subsystemsService
.
getDefaultInstance
())
return
if
(
!
this
.
subsystemsService
.
getInstances
().
includes
(
params
.
instance
))
{
this
.
router
.
navigateByUrl
(
'
/
'
+
this
.
subsystemsService
.
getDefaultInstance
())
;
return
;
}
// Only reload on switching of instance or when no instance is selected yet on service side
if
(
this
.
getInstance
()
==
''
||
this
.
getInstance
()
!=
params
[
'
instance
'
]
)
{
this
.
subsystemsService
.
setInstance
(
params
[
'
instance
'
]
?
params
[
'
instance
'
]
:
this
.
subsystemsService
.
getDefaultInstance
())
if
(
this
.
getInstance
()
==
=
''
||
this
.
getInstance
()
!=
=
params
.
instance
)
{
this
.
subsystemsService
.
setInstance
(
params
.
instance
?
params
.
instance
:
this
.
subsystemsService
.
getDefaultInstance
())
;
}
});
}
...
...
@@ -82,16 +82,16 @@ export class SubsystemListComponent implements OnInit, OnDestroy {
ngAfterViewInit
()
{
// Restoring scroll position
this
.
scrollSubjectSubscription
=
this
.
scrollSubject
.
subscribe
(
position
=>
{
if
(
position
)
{
if
(
position
)
{
this
.
viewportScroller
.
scrollToPosition
(
position
);
}
})
})
;
}
ngOnDestroy
()
{
this
.
routerScrollSubscription
.
unsubscribe
()
this
.
routeSubscription
.
unsubscribe
()
this
.
warningsSubscription
.
unsubscribe
()
this
.
scrollSubjectSubscription
.
unsubscribe
()
this
.
routerScrollSubscription
.
unsubscribe
()
;
this
.
routeSubscription
.
unsubscribe
()
;
this
.
warningsSubscription
.
unsubscribe
()
;
this
.
scrollSubjectSubscription
.
unsubscribe
()
;
}
}
src/app/subsystem/subsystem.component.spec.ts
View file @
feb028cb
...
...
@@ -4,8 +4,8 @@ import { Component } from '@angular/core';
import
{
SubsystemComponent
}
from
'
./subsystem.component
'
;
import
{
RouterTestingModule
}
from
'
@angular/router/testing
'
;
import
{
HttpClientModule
}
from
'
@angular/common/http
'
;
//import { ViewportScroller } from '@angular/common';
//import { SubsystemsService } from '../methods.service';
//
import { ViewportScroller } from '@angular/common';
//
import { SubsystemsService } from '../methods.service';
import
{
ActivatedRoute
}
from
'
@angular/router
'
;
import
{
of
}
from
'
rxjs
'
;
...
...
@@ -23,7 +23,7 @@ describe('SubsystemComponent', () => {
HeaderStubComponent
],
imports
:
[
TranslateModule
.
forRoot
(),
TranslateModule
.
forRoot
(),
HttpClientModule
,
RouterTestingModule
]
/*,
...
...
@@ -37,12 +37,12 @@ describe('SubsystemComponent', () => {
beforeEach
(()
=>
{
// Mocks and spies
TestBed
.
get
(
ActivatedRoute
).
params
=
of
({
"
instance
"
:
"
EE
"
,
"
class
"
:
"
CLASS
"
,
"
member
"
:
"
MEMBER
"
,
"
subsystem
"
:
"
SYSTEM
"
})
//spyOn(TestBed.get(ViewportScroller), "scrollToPosition").and.callFake(() => {});
instance
:
'
EE
'
,
class
:
'
CLASS
'
,
member
:
'
MEMBER
'
,
subsystem
:
'
SYSTEM
'
})
;
//
spyOn(TestBed.get(ViewportScroller), "scrollToPosition").and.callFake(() => {});
fixture
=
TestBed
.
createComponent
(
SubsystemComponent
);
component
=
fixture
.
componentInstance
;
...
...
src/app/subsystem/subsystem.component.ts
View file @
feb028cb
import
{
Component
,
OnInit
,
OnDestroy
}
from
'
@angular/core
'
;
import
{
Component
,
OnInit
,
AfterViewInit
,
OnDestroy
}
from
'
@angular/core
'
;
import
{
SubsystemsService
}
from
'
../subsystems.service
'
;
import
{
Subsystem
}
from
'
../subsystem
'
;
import
{
ActivatedRoute
,
Router
,
Scroll
}
from
'
@angular/router
'
;
...
...
@@ -11,16 +11,16 @@ import { filter } from 'rxjs/operators';
templateUrl
:
'
./subsystem.component.html
'
,
styleUrls
:
[
'
./subsystem.component.css
'
]
})
export
class
SubsystemComponent
implements
OnInit
,
OnDestroy
{
subsystemId
:
string
=
''
message
:
string
=
''
private
scrollSubject
:
BehaviorSubject
<
any
>
=
new
BehaviorSubject
(
null
)
private
routerScrollSubscription
:
Subscription
private
routeSubscription
:
Subscription
private
warningsSubscription
:
Subscription
private
scrollSubjectSubscription
:
Subscription
private
subsystemsSubscription
:
Subscription
subsystemSubject
:
BehaviorSubject
<
Subsystem
>
=
new
BehaviorSubject
(
null
)
export
class
SubsystemComponent
implements
OnInit
,
AfterViewInit
,
OnDestroy
{
subsystemId
=
''
;
message
=
''
;
private
scrollSubject
:
BehaviorSubject
<
any
>
=
new
BehaviorSubject
(
null
)
;
private
routerScrollSubscription
:
Subscription
;
private
routeSubscription
:
Subscription
;
private
warningsSubscription
:
Subscription
;
private
scrollSubjectSubscription
:
Subscription
;
private
subsystemsSubscription
:
Subscription
;
subsystemSubject
:
BehaviorSubject
<
Subsystem
>
=
new
BehaviorSubject
(
null
)
;
constructor
(
private
subsystemsService
:
SubsystemsService
,
...
...
@@ -31,76 +31,76 @@ export class SubsystemComponent implements OnInit, OnDestroy {
// Geting previous scroll position
this
.
routerScrollSubscription
=
this
.
router
.
events
.
pipe
(
filter
(
e
=>
e
instanceof
Scroll
)
).
subscribe
(
async
(
e
)
=>
{
).
subscribe
(
async
(
e
)
=>
{
if
((
e
as
Scroll
).
position
)
{
this
.
scrollSubject
.
next
((
e
as
Scroll
).
position
)
this
.
scrollSubject
.
next
((
e
as
Scroll
).
position
)
;
}
});
}
private
getSubsystem
(
subsystems
:
Subsystem
[],
name
:
string
):
Subsystem
{
return
subsystems
.
find
(
function
(
element
)
{
return
subsystems
.
find
((
element
)
=>
{
return
element
.
fullSubsystemName
===
name
;
})
})
;
}
getInstance
():
string
{
return
this
.
subsystemsService
.
getInstance
()
return
this
.
subsystemsService
.
getInstance
()
;
}
getApiUrlBase
():
string
{
return
this
.
subsystemsService
.
getApiUrlBase
()
return
this
.
subsystemsService
.
getApiUrlBase
()
;
}
goToList
():
void
{
this
.
router
.
navigateByUrl
(
'
/
'
+
this
.
subsystemsService
.
getInstance
())
this
.
router
.
navigateByUrl
(
'
/
'
+
this
.
subsystemsService
.
getInstance
())
;
}
ngOnInit
()
{
// Reset message on page load
this
.
message
=
''
this
.
message
=
''
;
// Service will tell when data loading failed!
this
.
warningsSubscription
=
this
.
subsystemsService
.
warnings
.
subscribe
(
signal
=>
{
this
.
message
=
signal
this
.
message
=
signal
;
});
this
.
routeSubscription
=
this
.
route
.
params
.
subscribe
(
params
=>
{
// Checking if instance is correct
if
(
!
this
.
subsystemsService
.
getInstances
().
includes
(
params
[
'
instance
'
]
))
{
this
.
message
=
'
Incorrect instance!
'
return
if
(
!
this
.
subsystemsService
.
getInstances
().
includes
(
params
.
instance
))
{
this
.
message
=
'
Incorrect instance!
'
;
return
;
}
this
.
subsystemId
=
params
[
'
instance
'
]
+
'
/
'
+
params
[
'
class
'
]
+
'
/
'
+
params
[
'
member
'
]
+
'
/
'
+
params
[
'
subsystem
'
]