Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
arsnova-click-v2-frontend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
12
Merge Requests
12
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
ARSnova
arsnova-click-v2-frontend
Commits
4db291f8
Commit
4db291f8
authored
Nov 20, 2019
by
Christopher Mark Fullarton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes subscription logic in router param calls
parent
f8f48e47
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
21 deletions
+28
-21
src/app/quiz/quiz-duplicate/quiz-duplicate.component.ts
src/app/quiz/quiz-duplicate/quiz-duplicate.component.ts
+2
-2
src/app/quiz/quiz-flow/leaderboard/leaderboard.component.ts
src/app/quiz/quiz-flow/leaderboard/leaderboard.component.ts
+10
-8
src/app/quiz/quiz-join/quiz-join.component.ts
src/app/quiz/quiz-join/quiz-join.component.ts
+9
-6
src/app/root/info/info.component.ts
src/app/root/info/info.component.ts
+6
-4
src/app/shared/sentry-error-handler.ts
src/app/shared/sentry-error-handler.ts
+1
-1
No files found.
src/app/quiz/quiz-duplicate/quiz-duplicate.component.ts
View file @
4db291f8
...
...
@@ -29,8 +29,8 @@ export class QuizDuplicateComponent implements OnInit, OnDestroy {
public
ngOnInit
():
void
{
this
.
route
.
paramMap
.
pipe
(
map
(
params
=>
params
.
get
(
'
name
'
)),
filter
(()
=>
this
.
userService
.
isAuthorizedFor
(
UserRole
.
CreateQuiz
)),
distinctUntilChanged
(),
takeUntil
(
this
.
_destroy
),
switchMap
(
name
=>
this
.
quizApiService
.
initQuizInstance
(
name
)))
.
subscribe
(
data
=>
{
this
.
storageService
.
db
.
Quiz
.
put
(
data
.
payload
.
quiz
);
.
subscribe
(
async
data
=>
{
await
this
.
storageService
.
db
.
Quiz
.
put
(
data
.
payload
.
quiz
);
this
.
quizService
.
quiz
=
new
QuizEntity
(
data
.
payload
.
quiz
);
this
.
quizService
.
isOwner
=
true
;
this
.
router
.
navigate
([
'
/quiz
'
,
'
flow
'
]);
...
...
src/app/quiz/quiz-flow/leaderboard/leaderboard.component.ts
View file @
4db291f8
...
...
@@ -4,7 +4,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import
{
NgbModal
,
NgbModalRef
}
from
'
@ng-bootstrap/ng-bootstrap
'
;
import
{
SimpleMQ
}
from
'
ng2-simple-mq
'
;
import
{
Subject
}
from
'
rxjs
'
;
import
{
takeUntil
}
from
'
rxjs/operators
'
;
import
{
distinctUntilChanged
,
map
,
takeUntil
}
from
'
rxjs/operators
'
;
import
{
environment
}
from
'
../../../../environments/environment
'
;
import
{
StorageKey
}
from
'
../../../lib/enums/enums
'
;
import
{
MessageProtocol
}
from
'
../../../lib/enums/Message
'
;
...
...
@@ -32,7 +32,6 @@ export class LeaderboardComponent implements OnInit, OnDestroy, IHasTriggeredNav
public
hasTriggeredNavigation
:
boolean
;
private
_questionIndex
:
number
;
private
readonly
_destroy
=
new
Subject
();
get
questionIndex
():
number
{
return
this
.
_questionIndex
;
...
...
@@ -62,6 +61,7 @@ export class LeaderboardComponent implements OnInit, OnDestroy, IHasTriggeredNav
return
this
.
_ownResponse
;
}
private
readonly
_destroy
=
new
Subject
();
private
_serverUnavailableModal
:
NgbModalRef
;
private
_name
:
string
;
private
readonly
_messageSubscriptions
:
Array
<
string
>
=
[];
...
...
@@ -78,7 +78,9 @@ export class LeaderboardComponent implements OnInit, OnDestroy, IHasTriggeredNav
private
connectionService
:
ConnectionService
,
private
i18nService
:
I18nService
,
private
leaderboardApiService
:
LeaderboardApiService
,
private
ngbModal
:
NgbModal
,
private
messageQueue
:
SimpleMQ
,
private
customMarkdownService
:
CustomMarkdownService
,
private
ngbModal
:
NgbModal
,
private
messageQueue
:
SimpleMQ
,
private
customMarkdownService
:
CustomMarkdownService
,
)
{
this
.
footerBarService
.
TYPE_REFERENCE
=
LeaderboardComponent
.
TYPE
;
}
...
...
@@ -171,14 +173,15 @@ export class LeaderboardComponent implements OnInit, OnDestroy, IHasTriggeredNav
}
private
initData
():
void
{
this
.
route
.
params
.
pipe
(
takeUntil
(
this
.
_destroy
)).
subscribe
(
params
=>
{
this
.
_questionIndex
=
+
params
[
'
questionIndex
'
];
this
.
route
.
paramMap
.
pipe
(
map
(
params
=>
parseInt
(
params
.
get
(
'
questionIndex
'
),
10
)),
distinctUntilChanged
(),
takeUntil
(
this
.
_destroy
))
.
subscribe
(
questionIndex
=>
{
this
.
_questionIndex
=
questionIndex
;
this
.
_isGlobalRanking
=
isNaN
(
this
.
_questionIndex
);
if
(
this
.
_isGlobalRanking
)
{
this
.
headerLabelService
.
headerLabel
=
'
component.leaderboard.global_header
'
;
this
.
_questionIndex
=
null
;
if
(
params
[
'
questionIndex
'
]
)
{
if
(
!!
questionIndex
)
{
this
.
hasTriggeredNavigation
=
true
;
this
.
router
.
navigate
([
'
/quiz
'
,
'
flow
'
,
'
leaderboard
'
]);
return
;
...
...
@@ -206,8 +209,7 @@ export class LeaderboardComponent implements OnInit, OnDestroy, IHasTriggeredNav
this
.
messageQueue
.
subscribe
(
MessageProtocol
.
NextQuestion
,
payload
=>
{
this
.
quizService
.
quiz
.
currentQuestionIndex
=
payload
.
nextQuestionIndex
;
sessionStorage
.
removeItem
(
StorageKey
.
CurrentQuestionIndex
);
}),
this
.
messageQueue
.
subscribe
(
MessageProtocol
.
Start
,
payload
=>
{
}),
this
.
messageQueue
.
subscribe
(
MessageProtocol
.
Start
,
payload
=>
{
this
.
hasTriggeredNavigation
=
true
;
this
.
router
.
navigate
([
'
/quiz
'
,
'
flow
'
,
'
voting
'
]);
}),
this
.
messageQueue
.
subscribe
(
MessageProtocol
.
UpdatedResponse
,
payload
=>
{
...
...
src/app/quiz/quiz-join/quiz-join.component.ts
View file @
4db291f8
import
{
Component
,
Inject
,
OnDestroy
,
OnInit
,
PLATFORM_ID
}
from
'
@angular/core
'
;
import
{
ActivatedRoute
,
Router
}
from
'
@angular/router
'
;
import
{
Subject
}
from
'
rxjs
'
;
import
{
takeUntil
}
from
'
rxjs/operators
'
;
import
{
distinctUntilChanged
,
map
,
takeUntil
}
from
'
rxjs/operators
'
;
import
{
MessageProtocol
,
StatusProtocol
}
from
'
../../lib/enums/Message
'
;
import
{
IMessage
}
from
'
../../lib/interfaces/communication/IMessage
'
;
import
{
QuizApiService
}
from
'
../../service/api/quiz/quiz-api.service
'
;
import
{
CasLoginService
}
from
'
../../service/login/cas-login.service
'
;
import
{
QuizService
}
from
'
../../service/quiz/quiz.service
'
;
...
...
@@ -31,17 +32,19 @@ export class QuizJoinComponent implements OnInit, OnDestroy {
}
public
ngOnInit
():
void
{
this
.
route
.
queryParams
.
pipe
(
takeUntil
(
this
.
_destroy
)).
subscribe
(
queryParams
=>
{
this
.
route
.
queryParams
.
pipe
(
distinctUntilChanged
(),
takeUntil
(
this
.
_destroy
)).
subscribe
(
queryParams
=>
{
this
.
casService
.
ticket
=
queryParams
.
ticket
;
});
this
.
route
.
params
.
pipe
(
takeUntil
(
this
.
_destroy
)).
subscribe
(
async
params
=>
{
if
(
!
params
||
!
params
.
quizName
)
{
this
.
route
.
paramMap
.
pipe
(
map
(
val
=>
val
.
get
(
'
quizName
'
)),
distinctUntilChanged
(),
takeUntil
(
this
.
_destroy
)).
subscribe
(
quizname
=>
{
console
.
log
(
quizname
);
if
(
!
quizname
)
{
this
.
router
.
navigate
([
'
/
'
]);
return
;
}
this
.
sharedService
.
isLoadingEmitter
.
next
(
true
);
this
.
quizApiService
.
getFullQuizStatusData
(
params
.
quizN
ame
).
subscribe
(
quizStatusData
=>
this
.
resolveQuizStatusData
(
quizStatusData
));
this
.
quizApiService
.
getFullQuizStatusData
(
quizn
ame
).
subscribe
(
quizStatusData
=>
this
.
resolveQuizStatusData
(
quizStatusData
));
});
}
...
...
@@ -50,7 +53,7 @@ export class QuizJoinComponent implements OnInit, OnDestroy {
this
.
_destroy
.
complete
();
}
private
resolveQuizStatusData
(
quizStatusData
):
void
{
private
resolveQuizStatusData
(
quizStatusData
:
IMessage
):
void
{
if
(
quizStatusData
.
status
!==
StatusProtocol
.
Success
||
quizStatusData
.
step
!==
MessageProtocol
.
Available
)
{
this
.
router
.
navigate
([
'
/
'
]);
return
;
...
...
src/app/root/info/info.component.ts
View file @
4db291f8
import
{
AfterViewInit
,
Component
,
ElementRef
,
OnDestroy
,
OnInit
,
ViewChild
}
from
'
@angular/core
'
;
import
{
ActivatedRoute
}
from
'
@angular/router
'
;
import
{
TranslateService
}
from
'
@ngx-translate/core
'
;
import
{
Subscription
}
from
'
rxjs
'
;
import
{
Subject
}
from
'
rxjs
'
;
import
{
distinctUntilChanged
,
takeUntil
}
from
'
rxjs/operators
'
;
import
{
environment
}
from
'
../../../environments/environment
'
;
import
{
DefaultSettings
}
from
'
../../lib/default.settings
'
;
import
{
FooterBarService
}
from
'
../../service/footer-bar/footer-bar.service
'
;
...
...
@@ -17,7 +18,7 @@ export class InfoComponent implements OnInit, OnDestroy, AfterViewInit {
public
static
TYPE
=
'
InfoComponent
'
;
public
currentData
:
string
;
public
readonly
infoButtons
:
Array
<
{
id
:
string
,
i18nRef
:
string
}
>
=
[];
private
_routerSubscription
:
Subscription
;
private
readonly
_destroy
=
new
Subject
()
;
@
ViewChild
(
'
buttonHeader
'
,
{
static
:
true
})
private
buttonHeader
:
ElementRef
;
...
...
@@ -58,7 +59,7 @@ export class InfoComponent implements OnInit, OnDestroy, AfterViewInit {
}
public
ngOnInit
():
void
{
this
.
_routerSubscription
=
this
.
route
.
data
.
subscribe
(
data
=>
{
this
.
route
.
data
.
pipe
(
distinctUntilChanged
(),
takeUntil
(
this
.
_destroy
))
.
subscribe
(
data
=>
{
this
.
currentData
=
data
.
content
;
});
}
...
...
@@ -74,7 +75,8 @@ export class InfoComponent implements OnInit, OnDestroy, AfterViewInit {
}
public
ngOnDestroy
():
void
{
this
.
_routerSubscription
.
unsubscribe
();
this
.
_destroy
.
next
();
this
.
_destroy
.
complete
();
}
public
toInfoContent
(
target
:
string
):
void
{
...
...
src/app/shared/sentry-error-handler.ts
View file @
4db291f8
...
...
@@ -17,7 +17,7 @@ export class SentryErrorHandler implements ErrorHandler {
release
:
environment
.
version
,
});
setExtra
(
'
nonErrorException
'
,
tru
e
);
setExtra
(
'
nonErrorException
'
,
fals
e
);
}
public
handleError
(
error
):
void
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment