Adds route and component to view quiz details in the admin module

parent 81afa3a2
Pipeline #23643 failed with stages
in 8 minutes and 26 seconds
......@@ -3,6 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { SharedModule } from '../shared/shared.module';
import { AdminOverviewComponent } from './admin-overview/admin-overview.component';
import { QuizAdminComponent } from './quiz-admin/quiz-admin.component';
import { QuizDetailsAdminComponent } from './quiz-details-admin/quiz-details-admin.component';
import { UserAdminComponent } from './user-admin/user-admin.component';
const routes: Routes = [
......@@ -13,13 +14,16 @@ const routes: Routes = [
path: 'quiz',
component: QuizAdminComponent,
}, {
path: 'quiz/:id',
component: QuizDetailsAdminComponent,
}, {
path: '',
component: AdminOverviewComponent,
},
];
@NgModule({
declarations: [UserAdminComponent, QuizAdminComponent, AdminOverviewComponent],
declarations: [UserAdminComponent, QuizAdminComponent, AdminOverviewComponent, QuizDetailsAdminComponent],
imports: [
SharedModule, RouterModule.forChild(routes),
],
......
<div *ngFor="let quiz of data; let i = index"
class="card mx-sm-auto mx-5 my-3 w-100">
<a *ngFor="let quiz of data; let i = index"
[routerLink]="['/admin', 'quiz', quiz.id]"
class="card mx-sm-auto mx-5 my-3 cursor-pointer text-dark nav-link p-0">
<div class="card-body">
<div class="d-flex justify-content-end">
<fa-icon *ngIf="isDeletingElem(i)"
[icon]="'spinner'"
[spin]="true"></fa-icon>
<fa-icon *ngIf="!isDeletingElem(i)"
[icon]="'times'"
class="cursor-pointer"
(click)="deleteElem(i)"></fa-icon>
<div class="d-flex">
<p class="card-text">
<span>Name: </span>
<span>{{quiz.name}}</span>
</p>
<div class="ml-auto">
<fa-icon *ngIf="isDeletingElem(i)"
[icon]="'spinner'"
[spin]="true"></fa-icon>
<fa-icon *ngIf="!isDeletingElem(i)"
[icon]="'times'"
class="cursor-pointer"
(click)="deleteElem($event, i)"></fa-icon>
</div>
</div>
<p class="card-text">
<span>Name: </span>
<span>{{quiz.name}}</span>
</p>
<p class="card-text"
*ngIf="quiz.expiry">
<span>Expiry: </span>
<span>{{quiz.expiry}}</span>
<span>{{quiz.expiry | date}}</span>
</p>
<p class="card-text"
*ngIf="quiz.visibility">
......@@ -25,72 +28,5 @@
<span>{{quiz.visibility}}</span>
</p>
<p class="card-text">Is Active: {{isActiveQuiz(quiz)}}</p>
<ng-container>
<p class="card-text">Member Groups:</p>
<ul>
<li *ngFor="let group of quiz.memberGroups">
<span>Name: {{group.name}}</span>
<ul>
<li *ngFor="let member of group.members">
<span>Member Name: {{member}}</span>
</li>
</ul>
</li>
</ul>
<p class="card-text">Questions:</p>
<ul>
<li *ngFor="let question of quiz.questionList">
<span>Type: {{question.TYPE}}</span>
<p class="card-text">Answers:</p>
<ul>
<li *ngFor="let answers of question.answerOptionList">
<span>Answer Text: {{answers.answerText}}</span><br/>
<span>Is Correct: {{answers.isCorrect}}</span><br/>
<span>Type: {{answers.TYPE}}</span><br/>
</li>
</ul>
<span>Display Answer Text: {{question.displayAnswerText}}</span><br/>
<span>Multiple Selection Enabled: {{question.multipleSelectionEnabled}}</span><br/>
<span>Show One Answer Per Row: {{question.showOneAnswerPerRow}}</span><br/>
<span>Timer: {{question.timer}}</span><br/>
<span>Question Text: {{question.questionText}}</span>
</li>
</ul>
<p class="card-text">Music Config</p>
<p class="card-text">Lobby</p>
<ul>
<li>Enabled: {{quiz.sessionConfig.music.enabled.lobby}}</li>
<li>Title: {{quiz.sessionConfig.music.titleConfig.lobby}}</li>
<li>Volume: {{quiz.sessionConfig.music.volumeConfig.lobby}}</li>
</ul>
<p class="card-text">Countdown Running</p>
<ul>
<li>Enabled: {{quiz.sessionConfig.music.enabled.countdownRunning}}</li>
<li>Title: {{quiz.sessionConfig.music.titleConfig.countdownRunning}}</li>
<li>Volume: {{quiz.sessionConfig.music.volumeConfig.countdownRunning}}</li>
</ul>
<p class="card-text">Countdown End</p>
<ul>
<li>Enabled: {{quiz.sessionConfig.music.enabled.countdownEnd}}</li>
<li>Title: {{quiz.sessionConfig.music.titleConfig.countdownEnd}}</li>
<li>Volume: {{quiz.sessionConfig.music.volumeConfig.countdownEnd}}</li>
</ul>
<p class="card-text">Nick Config</p>
<ul>
<li>Member Groups: {{quiz.sessionConfig.nicks.memberGroups}}</li>
<li>Max Members Per Group: {{quiz.sessionConfig.nicks.maxMembersPerGroup}}</li>
<li>Automatically join to Group: {{quiz.sessionConfig.nicks.autoJoinToGroup}}</li>
<li>Selected Nicks: {{quiz.sessionConfig.nicks.selectedNicks}}</li>
<li>Block Illegal Nicks: {{quiz.sessionConfig.nicks.blockIllegalNicks}}</li>
<li>Restrict to CAS Login: {{quiz.sessionConfig.nicks.restrictToCasLogin}}</li>
</ul>
<p class="card-text">Session Config</p>
<ul>
<li>Reading-Confirmation enabled: {{quiz.sessionConfig.readingConfirmationEnabled}}</li>
<li>Confidence-Slider enabled: {{quiz.sessionConfig.confidenceSliderEnabled}}</li>
<li>Show response progress: {{quiz.sessionConfig.showResponseProgress}}</li>
<li>Theme: {{quiz.sessionConfig.theme}}</li>
</ul>
</ng-container>
</div>
</div>
\ No newline at end of file
</a>
\ No newline at end of file
......@@ -35,7 +35,10 @@ export class QuizAdminComponent implements OnInit {
return this._deletingElements.indexOf(index) > -1;
}
public deleteElem(index: number): void {
public deleteElem($event: Event, index: number): void {
$event.stopPropagation();
$event.stopImmediatePropagation();
$event.preventDefault();
this._deletingElements.push(index);
this.adminService.deleteQuiz((this._data[index] as any).name || (this._data[index] as any).originalObject.name).subscribe(() => {
this._deletingElements.splice(this._deletingElements.indexOf(index), 1);
......
<div class="text-light">
<p class="card-text">Questions:</p>
<ul>
<li *ngFor="let question of data.questionList">
<span>Type: {{question.TYPE}}</span>
<p class="card-text">Answers:</p>
<ul>
<li *ngFor="let answers of question.answerOptionList">
<span>Answer Text: {{answers.answerText}}</span><br/>
<span>Is Correct: {{answers.isCorrect}}</span><br/>
<span>Type: {{answers.TYPE}}</span><br/>
</li>
</ul>
<span>Display Answer Text: {{question.displayAnswerText}}</span><br/>
<span>Multiple Selection Enabled: {{question.multipleSelectionEnabled}}</span><br/>
<span>Show One Answer Per Row: {{question.showOneAnswerPerRow}}</span><br/>
<span>Timer: {{question.timer}}</span><br/>
<span>Question Text: {{question.questionText}}</span>
</li>
</ul>
<p class="card-text">Music Config</p>
<p class="card-text">Lobby</p>
<ul>
<li>Enabled: {{data.sessionConfig?.music.enabled.lobby}}</li>
<li>Title: {{data.sessionConfig?.music.titleConfig.lobby}}</li>
<li>Volume: {{data.sessionConfig?.music.volumeConfig.lobby}}</li>
</ul>
<p class="card-text">Countdown Running</p>
<ul>
<li>Enabled: {{data.sessionConfig?.music.enabled.countdownRunning}}</li>
<li>Title: {{data.sessionConfig?.music.titleConfig.countdownRunning}}</li>
<li>Volume: {{data.sessionConfig?.music.volumeConfig.countdownRunning}}</li>
</ul>
<p class="card-text">Countdown End</p>
<ul>
<li>Enabled: {{data.sessionConfig?.music.enabled.countdownEnd}}</li>
<li>Title: {{data.sessionConfig?.music.titleConfig.countdownEnd}}</li>
<li>Volume: {{data.sessionConfig?.music.volumeConfig.countdownEnd}}</li>
</ul>
<p class="card-text">Nick Config</p>
<p>Member Groups:</p>
<ul>
<li *ngFor="let group of data.sessionConfig?.nicks.memberGroups">
<span>Name: {{group.name}}</span>
</li>
</ul>
<ul>
<li>Max Members Per Group: {{data.sessionConfig?.nicks.maxMembersPerGroup}}</li>
<li>Automatically join to Group: {{data.sessionConfig?.nicks.autoJoinToGroup}}</li>
<li>Selected Nicks: {{data.sessionConfig?.nicks.selectedNicks}}</li>
<li>Block Illegal Nicks: {{data.sessionConfig?.nicks.blockIllegalNicks}}</li>
<li>Restrict to CAS Login: {{data.sessionConfig?.nicks.restrictToCasLogin}}</li>
</ul>
<p class="card-text">Session Config</p>
<ul>
<li>Reading-Confirmation enabled: {{data.sessionConfig?.readingConfirmationEnabled}}</li>
<li>Confidence-Slider enabled: {{data.sessionConfig?.confidenceSliderEnabled}}</li>
<li>Show response progress: {{data.sessionConfig?.showResponseProgress}}</li>
<li>Theme: {{data.sessionConfig?.theme}}</li>
</ul>
</div>
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { QuizDetailsAdminComponent } from './quiz-details-admin.component';
describe('QuizDetailsAdminComponent', () => {
let component: QuizDetailsAdminComponent;
let fixture: ComponentFixture<QuizDetailsAdminComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [QuizDetailsAdminComponent],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(QuizDetailsAdminComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { AdminService } from '../../service/api/admin/admin.service';
import { FooterBarService } from '../../service/footer-bar/footer-bar.service';
@Component({
selector: 'app-quiz-details-admin',
templateUrl: './quiz-details-admin.component.html',
styleUrls: ['./quiz-details-admin.component.scss'],
})
export class QuizDetailsAdminComponent implements OnInit {
private _data: object = {};
get data(): object {
return this._data;
}
constructor(private footerBarService: FooterBarService, private adminService: AdminService, private activatedRoute: ActivatedRoute) {
this.updateFooterElements();
}
public ngOnInit(): void {
this.activatedRoute.params.subscribe(params => {
this.adminService.getQuiz(params.id).subscribe(data => {
this._data = data;
});
});
}
private updateFooterElements(): void {
const footerElements = [
this.footerBarService.footerElemBack,
];
this.footerBarService.replaceFooterElements(footerElements);
}
}
......@@ -110,8 +110,8 @@
<svg version="1.1" id="arsnova-logo-image" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 1024 1024" xml:space="preserve">
<g id="text">
<text transform="translate(512 200)" class="arsnova-logo-origin">{{origin}}</text>
<text transform="matrix(1 0 0 1 69 500)" class="arsnova-logo-ars">ars</text>
<text transform="matrix(1 0 0 1 420 500)" class="arsnova-logo-nova">nova</text>
<text [attr.transform]="'matrix(1 0 0 1 69 ' + (origin.length > 0 ? '500' : '400') + ')'" class="arsnova-logo-ars">ars</text>
<text [attr.transform]="'matrix(1 0 0 1 420 ' + (origin.length > 0 ? '500' : '400') + ')'" class="arsnova-logo-nova">nova</text>
<text transform="matrix(1 0 0 1 512 820)" class="arsnova-logo-click">.click</text>
</g>
</svg>
......
......@@ -25,8 +25,6 @@ export class HeaderComponent implements OnInit {
return 'Beta';
case 'staging.arsnova.click':
return 'Staging';
case 'localhost':
return 'DEV';
default:
return '';
}
......
......@@ -342,7 +342,7 @@ export class HomeComponent implements OnInit, OnDestroy {
if (this.userService.isAuthorizedFor(UserRole.EditI18n)) {
footerElements.push(this.footerBarService.footerElemEditI18n);
}
if (this.userService.isAuthorizedFor([UserRole.QuizAdmin, UserRole.SuperAdmin])) {
if (this.userService.isAuthorizedFor([UserRole.SuperAdmin])) {
footerElements.push(this.footerBarService.footerElemAdmin);
}
footerElements.push(this.footerBarService.footerElemLogout);
......
......@@ -13,6 +13,7 @@ export class AdminService {
private _deleteQuizUrl: string;
private _deleteUserUrl: string;
private _putUserUrl: string;
private _getQuizUrl: string;
constructor(private http: HttpClient, private userService: UserService) {
this.initUrls();
......@@ -38,11 +39,16 @@ export class AdminService {
return this.http.put<void>(this._putUserUrl, value, { headers: { authorization: this.userService.staticLoginToken } });
}
public getQuiz(quizname: string): Observable<object> {
return this.http.get(`${this._getQuizUrl}/${quizname}`, { headers: { authorization: this.userService.staticLoginToken } });
}
private initUrls(): void {
this._getAvailableUsersUrl = `${DefaultSettings.httpApiEndpoint}/admin/users`;
this._deleteUserUrl = `${DefaultSettings.httpApiEndpoint}/admin/user`;
this._putUserUrl = `${DefaultSettings.httpApiEndpoint}/admin/user`;
this._getAvailableQuizzesUrl = `${DefaultSettings.httpApiEndpoint}/admin/quizzes`;
this._getQuizUrl = `${DefaultSettings.httpApiEndpoint}/admin/quiz`;
this._deleteQuizUrl = `${DefaultSettings.httpApiEndpoint}/admin/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