Displays and hides the connection-unavailable-modal depending on the current...

Displays and hides the connection-unavailable-modal depending on the current connection to the server
parent 2d0daae2
import { Component, Inject, PLATFORM_ID } from '@angular/core';
import { Router } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { Subscription } from 'rxjs';
import { AutoUnsubscribe } from '../../../../lib/AutoUnsubscribe';
import { StorageKey } from '../../../../lib/enums/enums';
......@@ -29,6 +29,7 @@ export class ConfidenceRateComponent {
return this._confidenceValue;
}
private _serverUnavailableModal: NgbModalRef;
// noinspection JSMismatchedCollectionQueryUpdate
private _subscriptions: Array<Subscription> = [];
......@@ -55,12 +56,20 @@ export class ConfidenceRateComponent {
this.initData();
}));
this._subscriptions.push(this.connectionService.serverStatusEmitter.subscribe(isConnected => {
if (isConnected) {
if (this._serverUnavailableModal) {
this._serverUnavailableModal.dismiss();
}
return;
} else if (!isConnected && this._serverUnavailableModal) {
return;
}
this.ngbModal.open(ServerUnavailableModalComponent);
this.ngbModal.dismissAll();
this._serverUnavailableModal = this.ngbModal.open(ServerUnavailableModalComponent);
this._serverUnavailableModal.result.finally(() => this._isServerUnavailableModalOpen = false);
}));
}
......
......@@ -2,7 +2,7 @@ import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnDestroy, PLATFORM_ID, SecurityContext } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { ActivatedRoute, Router } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { ILeaderBoardItem } from 'arsnova-click-v2-types/dist/common';
import { Subscription } from 'rxjs';
import { AutoUnsubscribe } from '../../../../lib/AutoUnsubscribe';
......@@ -59,23 +59,25 @@ export class LeaderboardComponent implements OnDestroy {
return this._hasMultipleAnswersAvailable;
}
private _serverUnavailableModal: NgbModalRef;
private _name: string;
// noinspection JSMismatchedCollectionQueryUpdate
private readonly _subscriptions: Array<Subscription> = [];
constructor(@Inject(PLATFORM_ID) private platformId: Object,
public attendeeService: AttendeeService,
public quizService: QuizService,
private sanitizer: DomSanitizer,
private footerBarService: FooterBarService,
private route: ActivatedRoute,
private headerLabelService: HeaderLabelService,
private router: Router,
private connectionService: ConnectionService,
private i18nService: I18nService,
private leaderboardApiService: LeaderboardApiService,
private ngbModal: NgbModal,
constructor(
@Inject(PLATFORM_ID) private platformId: Object,
public attendeeService: AttendeeService,
public quizService: QuizService,
private sanitizer: DomSanitizer,
private footerBarService: FooterBarService,
private route: ActivatedRoute,
private headerLabelService: HeaderLabelService,
private router: Router,
private connectionService: ConnectionService,
private i18nService: I18nService,
private leaderboardApiService: LeaderboardApiService,
private ngbModal: NgbModal,
) {
this.footerBarService.TYPE_REFERENCE = LeaderboardComponent.TYPE;
......@@ -91,12 +93,20 @@ export class LeaderboardComponent implements OnDestroy {
this.attendeeService.restoreMembers();
this.addFooterElements();
}));
this._subscriptions.push(this.connectionService.serverStatusEmitter.subscribe(isConnected => {
if (isConnected) {
if (this._serverUnavailableModal) {
this._serverUnavailableModal.dismiss();
}
return;
} else if (!isConnected && this._serverUnavailableModal) {
return;
}
this.ngbModal.open(ServerUnavailableModalComponent);
this.ngbModal.dismissAll();
this._serverUnavailableModal = this.ngbModal.open(ServerUnavailableModalComponent);
this._serverUnavailableModal.result.finally(() => this._isServerUnavailableModalOpen = false);
}));
}
......
......@@ -2,7 +2,7 @@ import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnDestroy, PLATFORM_ID, SecurityContext } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { Router } from '@angular/router';
import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { Subscription } from 'rxjs';
import { AutoUnsubscribe } from '../../../../lib/AutoUnsubscribe';
import { QuizEntity } from '../../../../lib/entities/QuizEntity';
......@@ -57,6 +57,7 @@ export class QuizLobbyComponent implements OnDestroy {
return this._nickToRemove;
}
private _serverUnavailableModal: NgbModalRef;
private _reconnectTimeout: any;
private _kickMemberModalRef: NgbActiveModal;
// noinspection JSMismatchedCollectionQueryUpdate
......@@ -97,12 +98,20 @@ export class QuizLobbyComponent implements OnDestroy {
this.attendeeService.restoreMembers();
}
}));
this._subscriptions.push(this.connectionService.serverStatusEmitter.subscribe(isConnected => {
if (isConnected) {
if (this._serverUnavailableModal) {
this._serverUnavailableModal.dismiss();
}
return;
} else if (!isConnected && this._serverUnavailableModal) {
return;
}
this.ngbModal.open(ServerUnavailableModalComponent);
this.ngbModal.dismissAll();
this._serverUnavailableModal = this.ngbModal.open(ServerUnavailableModalComponent);
this._serverUnavailableModal.result.finally(() => this._isServerUnavailableModalOpen = false);
}));
this.footerBarService.TYPE_REFERENCE = QuizLobbyComponent.TYPE;
......
import { Component, OnDestroy, OnInit } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { ActivatedRoute, Router } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { Subscription } from 'rxjs';
import { AutoUnsubscribe } from '../../../../../lib/AutoUnsubscribe';
import { AbstractQuestionEntity } from '../../../../../lib/entities/question/AbstractQuestionEntity';
......@@ -52,6 +52,7 @@ export class QuestionDetailsComponent implements OnInit, OnDestroy {
return this._answers;
}
private _serverUnavailableModal: NgbModalRef;
private _subscriptions: Array<Subscription> = [];
constructor(
......@@ -70,12 +71,20 @@ export class QuestionDetailsComponent implements OnInit, OnDestroy {
footerBarService.replaceFooterElements([
this.footerBarService.footerElemBack, this.footerBarService.footerElemFullscreen,
]);
this._subscriptions.push(this.connectionService.serverStatusEmitter.subscribe(isConnected => {
if (isConnected) {
if (this._serverUnavailableModal) {
this._serverUnavailableModal.dismiss();
}
return;
} else if (!isConnected && this._serverUnavailableModal) {
return;
}
this.ngbModal.open(ServerUnavailableModalComponent);
this.ngbModal.dismissAll();
this._serverUnavailableModal = this.ngbModal.open(ServerUnavailableModalComponent);
this._serverUnavailableModal.result.finally(() => this._isServerUnavailableModalOpen = false);
}));
}
......
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { Subscription } from 'rxjs';
import { AutoUnsubscribe } from '../../../../lib/AutoUnsubscribe';
import { Countdown } from '../../../../lib/countdown/countdown';
......@@ -38,6 +38,7 @@ export class QuizResultsComponent implements OnInit, OnDestroy {
return this._selectedQuestionIndex;
}
private _serverUnavailableModal: NgbModalRef;
// noinspection JSMismatchedCollectionQueryUpdate
private readonly _subscriptions: Array<Subscription> = [];
......@@ -70,12 +71,20 @@ export class QuizResultsComponent implements OnInit, OnDestroy {
});
this.addFooterElements();
}));
this._subscriptions.push(this.connectionService.serverStatusEmitter.subscribe(isConnected => {
if (isConnected) {
if (this._serverUnavailableModal) {
this._serverUnavailableModal.dismiss();
}
return;
} else if (!isConnected && this._serverUnavailableModal) {
return;
}
this.ngbModal.open(ServerUnavailableModalComponent);
this.ngbModal.dismissAll();
this._serverUnavailableModal = this.ngbModal.open(ServerUnavailableModalComponent);
this._serverUnavailableModal.result.finally(() => this._isServerUnavailableModalOpen = false);
}));
}
......
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
import { Component, Inject, OnDestroy, PLATFORM_ID } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { Subscription } from 'rxjs';
import { AutoUnsubscribe } from '../../../../lib/AutoUnsubscribe';
import { ServerUnavailableModalComponent } from '../../../modals/server-unavailable-modal/server-unavailable-modal.component';
import { ConnectionService } from '../../../service/connection/connection.service';
import { FooterBarService } from '../../../service/footer-bar/footer-bar.service';
......@@ -11,11 +13,15 @@ import { ThemesService } from '../../../service/themes/themes.service';
selector: 'app-quiz-theme',
templateUrl: './quiz-theme.component.html',
styleUrls: ['./quiz-theme.component.scss'],
})
}) //
@AutoUnsubscribe('_subscriptions')
export class QuizThemeComponent implements OnDestroy {
public static TYPE = 'QuizThemeComponent';
private previewThemeBackup: string;
// noinspection JSMismatchedCollectionQueryUpdate
private _subscriptions: Array<Subscription> = [];
private _serverUnavailableModal: NgbModalRef;
constructor(
@Inject(PLATFORM_ID) private platformId: Object,
......@@ -35,16 +41,24 @@ export class QuizThemeComponent implements OnDestroy {
this._subscriptions.push(this.connectionService.serverStatusEmitter.subscribe(isConnected => {
if (isConnected) {
if (this._serverUnavailableModal) {
this._serverUnavailableModal.dismiss();
}
return;
} else if (!isConnected && this._serverUnavailableModal) {
return;
}
this.ngbModal.open(ServerUnavailableModalComponent);
this.ngbModal.dismissAll();
this._serverUnavailableModal = this.ngbModal.open(ServerUnavailableModalComponent);
this._serverUnavailableModal.result.finally(() => this._isServerUnavailableModalOpen = false);
}));
}
}
public ngOnDestroy(): void {
this.themesService.updateCurrentlyUsedTheme();
this._subscriptions.forEach(sub => sub.unsubscribe());
}
public updateTheme(id: string): void {
......
import { Component, Inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { Router } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { Subscription } from 'rxjs';
import { MessageProtocol } from '../../../../lib/enums/Message';
import { IMessage } from '../../../../lib/interfaces/communication/IMessage';
......@@ -26,6 +26,7 @@ export class ReadingConfirmationComponent implements OnInit, OnDestroy {
public questionIndex: number;
public questionText: string;
private _subscriptions: Array<Subscription> = [];
private _serverUnavailableModal: NgbModalRef;
constructor(
@Inject(PLATFORM_ID) private platformId: Object,
......@@ -48,10 +49,17 @@ export class ReadingConfirmationComponent implements OnInit, OnDestroy {
this._subscriptions.push(this.connectionService.serverStatusEmitter.subscribe(isConnected => {
if (isConnected) {
if (this._serverUnavailableModal) {
this._serverUnavailableModal.dismiss();
}
return;
} else if (!isConnected && this._serverUnavailableModal) {
return;
}
this.ngbModal.open(ServerUnavailableModalComponent);
this.ngbModal.dismissAll();
this._serverUnavailableModal = this.ngbModal.open(ServerUnavailableModalComponent);
this._serverUnavailableModal.result.finally(() => this._isServerUnavailableModalOpen = false);
}));
}
......
......@@ -2,7 +2,7 @@ import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnDestroy, PLATFORM_ID } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { Router } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { Subscription } from 'rxjs';
import { AutoUnsubscribe } from '../../../../lib/AutoUnsubscribe';
import { Countdown } from '../../../../lib/countdown/countdown';
......@@ -58,6 +58,7 @@ export class VotingComponent implements OnDestroy {
return this._selectedAnswers;
}
private _serverUnavailableModal: NgbModalRef;
// noinspection JSMismatchedCollectionQueryUpdate
private readonly _subscriptions: Array<Subscription> = [];
......@@ -91,12 +92,20 @@ export class VotingComponent implements OnDestroy {
this.initData();
this.attendeeService.restoreMembers();
}));
this._subscriptions.push(this.connectionService.serverStatusEmitter.subscribe(isConnected => {
if (isConnected) {
if (this._serverUnavailableModal) {
this._serverUnavailableModal.dismiss();
}
return;
} else if (!isConnected && this._serverUnavailableModal) {
return;
}
this.ngbModal.open(ServerUnavailableModalComponent);
this.ngbModal.dismissAll();
this._serverUnavailableModal = this.ngbModal.open(ServerUnavailableModalComponent);
this._serverUnavailableModal.result.finally(() => this._isServerUnavailableModalOpen = false);
}));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment