Removes unnecessary providers in the root module. Fixes isActive state of the startQuiz button

parent 1b60a385
......@@ -3,7 +3,6 @@ import { Router } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { environment } from '../../../../environments/environment';
import { availableQuestionTypes, IAvailableQuestionType } from '../../../lib/available-question-types';
import { DefaultAnswerEntity } from '../../../lib/entities/answer/DefaultAnswerEntity';
......@@ -71,6 +70,7 @@ export class QuizManagerComponent implements OnInit, OnDestroy {
}
self.isLoading = true;
this.quizApiService.setQuiz(this.quizService.quiz).subscribe(updatedQuiz => {
this.quizService.quiz = updatedQuiz;
this.router.navigate(['/quiz', 'flow', 'lobby']);
self.isLoading = false;
});
......@@ -78,16 +78,6 @@ export class QuizManagerComponent implements OnInit, OnDestroy {
}
public ngOnInit(): void {
this.quizService.quizUpdateEmitter.pipe(takeUntil(this._destroy)).subscribe(() => {
this.footerBarService.footerElemStartQuiz.isActive = this.quizService.isValid() && this.connectionService.serverAvailable;
});
this.connectionService.serverStatusEmitter.pipe(takeUntil(this._destroy)).subscribe(() => {
this.footerBarService.footerElemStartQuiz.isActive = this.quizService.isValid() && this.connectionService.serverAvailable;
this.footerBarService.footerElemNicknames.isActive = this.connectionService.serverAvailable;
});
this.footerBarService.footerElemNicknames.isActive = this.connectionService.serverAvailable;
this.quizService.loadDataToEdit(sessionStorage.getItem(StorageKey.CurrentQuizName));
}
......
......@@ -27,30 +27,8 @@ import { LoginComponent } from './root/login/login.component';
import { RootComponent } from './root/root/root.component';
import { ThemeSwitcherComponent } from './root/theme-switcher/theme-switcher.component';
import rxStompConfig from './rx-stomp.config';
import { AttendeeService } from './service/attendee/attendee.service';
import { ConnectionService } from './service/connection/connection.service';
import { CustomMarkdownService } from './service/custom-markdown/custom-markdown.service';
import { FileUploadService } from './service/file-upload/file-upload.service';
import { FooterBarService } from './service/footer-bar/footer-bar.service';
import { HeaderLabelService } from './service/header-label/header-label.service';
import { I18nService } from './service/i18n/i18n.service';
import { LanguageLoaderService } from './service/language-loader/language-loader.service';
import { CasLoginService } from './service/login/cas-login.service';
import { StaticLoginService } from './service/login/static-login.service';
import { ModalOrganizerService } from './service/modal-organizer/modal-organizer.service';
import { ProjectLoaderService } from './service/project-loader/project-loader.service';
import { QuestionTextService } from './service/question-text/question-text.service';
import { QuizService } from './service/quiz/quiz.service';
import { SettingsService } from './service/settings/settings.service';
import { SharedService } from './service/shared/shared.service';
import { StorageService } from './service/storage/storage.service';
import { ThemesService } from './service/themes/themes.service';
import { TrackingService } from './service/tracking/tracking.service';
import { UpdateCheckService } from './service/update-check/update-check.service';
import { UserRoleGuardService } from './service/user-role-guard/user-role-guard.service';
import { UserService } from './service/user/user.service';
import { SharedModule } from './shared/shared.module';
import { ArsnovaClickAngulartics2Piwik } from './shared/tracking/ArsnovaClickAngulartics2Piwik';
const appRoutes: Routes = [
{
......@@ -163,11 +141,6 @@ export function markedOptionsFactory(): MarkedOptions {
}),
],
providers: [
/* {
provide: ErrorHandler,
useClass: GlobalErrorHandler,
}, */
CustomMarkdownService,
{
provide: InjectableRxStompConfig,
useValue: rxStompConfig,
......@@ -178,44 +151,21 @@ export function markedOptionsFactory(): MarkedOptions {
deps: [InjectableRxStompConfig],
},
SimpleMQ,
UserService,
RoutePreloader,
StorageService,
I18nService,
FooterBarService,
ConnectionService,
QuizService,
CasLoginService,
FileUploadService,
SettingsService,
NgbActiveModal,
SharedService,
AttendeeService,
HeaderLabelService,
QuestionTextService,
ThemesService,
ArsnovaClickAngulartics2Piwik,
TrackingService,
UpdateCheckService,
UserRoleGuardService,
LanguageLoaderService,
ProjectLoaderService,
ModalOrganizerService,
],
bootstrap: [RootComponent],
})
export class RootModule {
constructor() {
if (environment.production) {
const console: any = {};
console.log = function (): void {};
// tslint:disable-next-line:no-console
console.info = function (): void {};
// tslint:disable-next-line:no-console
console.trace = function (): void {};
console.warn = function (): void {};
console.error = window.console.error;
(window as any).console = console;
(window as any).console = {
log: function (): void {},
info: function (): void {},
trace: function (): void {},
warn: function (): void {},
error: window.console.error,
};
}
}
}
......@@ -123,9 +123,9 @@ export class AttendeeService {
return;
}
if (quiz.state === QuizState.Inactive) {
this.footerBarService.footerElemStartQuiz.isActive = this._attendees.length > 0;
return;
}
this.footerBarService.footerElemStartQuiz.isActive = this._attendees.length > 0;
console.log('AttendeeService#loadData', 'quiz set', quiz);
this.restoreMembers();
......
......@@ -410,6 +410,8 @@ export class FooterBarService {
return this._footerElements;
}
private _connectionState: RxStompState;
constructor(
@Inject(PLATFORM_ID) private platformId: Object,
private userService: UserService,
......@@ -420,7 +422,9 @@ export class FooterBarService {
) {
this.rxStompService.connectionState$.subscribe(value => {
this._connectionState = value;
this.toggleFooterElemState(value === RxStompState.OPEN);
console.log('setting active state', value === RxStompState.OPEN);
});
this.quizService.quizUpdateEmitter.pipe(filter(quiz => !!quiz)).subscribe(() => {
......@@ -483,27 +487,34 @@ export class FooterBarService {
this.footerElemImport.isActive = isActive;
this.footerElemLogin.isActive = isActive;
this.footerElemAdmin.isActive = isActive;
this.footerElemStartQuiz.isActive = this.quizService.isValid() && isActive;
this.footerElemNicknames.isActive = isActive;
}
private updateFooterElementsState(): void {
this.footerElemReadingConfirmation.isActive = !!this.quizService.quiz.sessionConfig.readingConfirmationEnabled;
this.footerElemConfidenceSlider.isActive = !!this.quizService.quiz.sessionConfig.confidenceSliderEnabled;
this.footerElemStartQuiz.isActive = this.quizService.isValid() && this._connectionState === RxStompState.OPEN;
console.log('updating footer elements state', this.quizService.isValid(), this._connectionState === RxStompState.OPEN);
this.footerElemExport.restoreClickCallback();
this.footerElemExport.onClickCallback = async () => {
const link = `${DefaultSettings.httpApiEndpoint}/quiz/export/${this.quizService.quiz.name}/${sessionStorage.getItem(
StorageKey.PrivateKey)}/${this.quizService.quiz.sessionConfig.theme}/${this.translateService.currentLang}`;
window.open(link);
};
this.footerElemEnableCasLogin.restoreClickCallback();
this.footerElemEnableCasLogin.isActive = this.quizService.quiz.sessionConfig.nicks.restrictToCasLogin;
this.footerElemBlockRudeNicknames.isActive = this.quizService.quiz.sessionConfig.nicks.blockIllegalNicks;
this.footerElemEnableCasLogin.onClickCallback = () => {
const newState = !this.footerElemEnableCasLogin.isActive;
this.footerElemEnableCasLogin.isActive = newState;
this.quizService.quiz.sessionConfig.nicks.restrictToCasLogin = newState;
this.quizService.persist();
};
this.footerElemBlockRudeNicknames.restoreClickCallback();
this.footerElemBlockRudeNicknames.isActive = this.quizService.quiz.sessionConfig.nicks.blockIllegalNicks;
this.footerElemBlockRudeNicknames.onClickCallback = () => {
const newState = !this.footerElemBlockRudeNicknames.isActive;
this.footerElemBlockRudeNicknames.isActive = newState;
......
......@@ -83,6 +83,7 @@ export class QuizService {
if (this._isInEditMode) {
this.quizApiService.putSavedQuiz(this.quiz).subscribe();
this.quizUpdateEmitter.next(this.quiz);
}
}
......
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