Commit 276da410 authored by Tom Käsler's avatar Tom Käsler

Add tokens for bonus points

Whenever a comment gets favorited, a token will be generated.
Participants can view theirs under the 'user account menu' in the header.
Session owners can view the given tokens for the room in the settings drop down menu for a room
parent 18b168b5
Pipeline #31980 failed with stages
in 9 minutes and 36 seconds
......@@ -15,6 +15,14 @@
},
"logLevel": "debug"
},
"/api/bonustoken": {
"target": "http://localhost:8088",
"secure": false,
"pathRewrite": {
"^/api": ""
},
"logLevel": "debug"
},
"/api/settings": {
"target": "http://localhost:8088",
"secure": false,
......
......@@ -41,6 +41,7 @@ import { DemoVideoComponent } from './components/home/_dialogs/demo-video/demo-v
import { HomeCreatorPageComponent } from './components/home/home-creator-page/home-creator-page.component';
import { HomeParticipantPageComponent } from './components/home/home-participant-page/home-participant-page.component';
import { CommentSettingsService } from './services/http/comment-settings.service';
import { BonusTokenService } from './services/http/bonus-token.service';
import { ModeratorModule } from './components/moderator/moderator.module';
import { ImprintComponent } from './components/home/_dialogs/imprint/imprint.component';
import { DataProtectionComponent } from './components/home/_dialogs/data-protection/data-protection.component';
......@@ -150,6 +151,7 @@ export function initializeApp(appConfig: AppConfig) {
VoteService,
ModeratorService,
CommentSettingsService,
BonusTokenService,
WsConnectorService,
{
provide: MatDialogRef,
......
<div mat-dialog-content>
<h1>{{'room-page.bonus-token-header' | translate }}</h1>
<mat-divider></mat-divider>
<div fxLayout="row" *ngFor="let bonusToken of bonusTokens">
<h2>
{{bonusToken.token}}
</h2>
</div>
</div>
import { Component, OnInit } from '@angular/core';
import { BonusTokenService } from '../../../../services/http/bonus-token.service';
import { BonusToken } from '../../../../models/bonus-token';
@Component({
selector: 'app-bonus-token',
templateUrl: './bonus-token.component.html',
styleUrls: ['./bonus-token.component.scss']
})
export class BonusTokenComponent implements OnInit {
roomId: string;
bonusTokens: BonusToken[] = [];
constructor(
private bonusTokenService: BonusTokenService
) {
}
ngOnInit() {
this.bonusTokenService.getTokensByRoomId(this.roomId).subscribe( list => {
this.bonusTokens = list;
});
}
}
......@@ -23,6 +23,7 @@ import { ContentEditComponent } from './_dialogs/content-edit/content-edit.compo
import { ContentPresentationComponent } from './content-presentation/content-presentation.component';
import { CommentExportComponent } from './_dialogs/comment-export/comment-export.component';
import { ModeratorsComponent } from './_dialogs/moderators/moderators.component';
import { BonusTokenComponent } from './_dialogs/bonus-token/bonus-token.component';
import { CommentSettingsComponent } from './_dialogs/comment-settings/comment-settings.component';
import { ModeratorDeleteComponent } from './_dialogs/moderator-delete/moderator-delete.component';
import { DeleteCommentComponent } from './_dialogs/delete-comment/delete-comment.component';
......@@ -59,6 +60,7 @@ import { DeleteCommentsComponent } from './_dialogs/delete-comments/delete-comme
ContentPresentationComponent,
CommentExportComponent,
ModeratorsComponent,
BonusTokenComponent,
CommentSettingsComponent,
ModeratorDeleteComponent,
DeleteCommentsComponent,
......@@ -77,6 +79,7 @@ import { DeleteCommentsComponent } from './_dialogs/delete-comments/delete-comme
ContentEditComponent,
CommentExportComponent,
ModeratorsComponent,
BonusTokenComponent,
CommentSettingsComponent,
ModeratorDeleteComponent,
DeleteCommentsComponent,
......
......@@ -35,6 +35,10 @@
<mat-icon>gavel</mat-icon>
{{ 'room-page.moderators' | translate}}
</button>
<button mat-menu-item (click)="showBonusTokenDialog()" aria-labelledby= "person">
<mat-icon>grade</mat-icon>
{{ 'room-page.bonus-token' | translate}}
</button>
</mat-menu>
<button id="settings-menu"
mat-icon-button class="corner-icons" [matMenuTriggerFor]="settingsMenu" aria-labelledby="settings">
......
......@@ -14,6 +14,7 @@ import { TSMap } from 'typescript-map';
import { WsCommentServiceService } from '../../../services/websockets/ws-comment-service.service';
import { CommentService } from '../../../services/http/comment.service';
import { ModeratorsComponent } from '../_dialogs/moderators/moderators.component';
import { BonusTokenComponent } from '../_dialogs/bonus-token/bonus-token.component';
import { CommentSettingsComponent } from '../_dialogs/comment-settings/comment-settings.component';
import { LiveAnnouncer } from '@angular/cdk/a11y';
import { EventService } from '../../../services/util/event.service';
......@@ -202,6 +203,13 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni
dialogRef.componentInstance.roomId = this.room.id;
}
showBonusTokenDialog(): void {
const dialogRef = this.dialog.open(BonusTokenComponent, {
width: '400px'
});
dialogRef.componentInstance.roomId = this.room.id;
}
copyShortId(): void {
const selBox = document.createElement('textarea');
selBox.style.position = 'fixed';
......
<div mat-dialog-content>
<h1>{{'user-bonus-token-dialog.header' | translate }}</h1>
<mat-divider></mat-divider>
<div fxLayout="row" *ngFor="let bonusToken of bonusTokens">
<h2>
{{bonusToken.token}}
</h2>
</div>
</div>
import { Component, OnInit } from '@angular/core';
import { BonusTokenService } from '../../../../services/http/bonus-token.service';
import { BonusToken } from '../../../../models/bonus-token';
@Component({
selector: 'app-user-bonus-token',
templateUrl: './user-bonus-token.component.html',
styleUrls: ['./user-bonus-token.component.scss']
})
export class UserBonusTokenComponent implements OnInit {
userId: string;
bonusTokens: BonusToken[] = [];
constructor(
private bonusTokenService: BonusTokenService
) {
}
ngOnInit() {
this.bonusTokenService.getTokensByUserId(this.userId).subscribe( list => {
this.bonusTokens = list;
});
}
}
......@@ -196,8 +196,8 @@ export class CommentListComponent implements OnInit {
this.comments[i].favorite = <boolean>value;
console.log(this.comments[i]);
if (this.user.id === this.comments[i].creatorId && <boolean>value) {
this.translateService.get('comment-list.comment-got-favorited').subscribe( msg => {
this.notificationService.show(msg);
this.translateService.get('comment-list.comment-got-favorited').subscribe(ret => {
this.notificationService.show(ret);
});
}
break;
......
......@@ -34,6 +34,10 @@
<span *ngIf="!user.isGuest">{{'header.my-sessions' | translate}}</span>
<span *ngIf="user.isGuest" svgIcon="meeting_room">{{'header.visited-sessions' | translate}}</span>
</button>
<button mat-menu-item *ngIf="user" (click)="openUserBonusTokenDialog()">
<mat-icon color="warn">grade</mat-icon>
<span>{{'header.user-bonus-token' | translate}}</span>
</button>
<button mat-menu-item *ngIf="user && !user.isGuest" (click)="openDeleteUserDialog()">
<mat-icon color="warn">delete</mat-icon>
<span>{{'header.delete-account' | translate}}</span>
......
......@@ -15,6 +15,7 @@ import { AppComponent } from '../../../app.component';
import { Rescale } from '../../../models/rescale';
import { KeyboardUtils } from '../../../utils/keyboard';
import { KeyboardKey } from '../../../utils/keyboard/keys';
import { UserBonusTokenComponent } from '../_dialogs/user-bonus-token/user-bonus-token.component';
@Component({
selector: 'app-header',
......@@ -151,6 +152,13 @@ export class HeaderComponent implements OnInit {
});
}
openUserBonusTokenDialog() {
const dialogRef = this.dialog.open(UserBonusTokenComponent, {
width: '600px'
});
dialogRef.componentInstance.userId = this.user.id;
}
cookiesDisabled(): boolean {
return localStorage.getItem('cookieAccepted') === 'false';
}
......
......@@ -19,6 +19,7 @@ import { ChartsModule } from 'ng2-charts';
import { StatisticComponent } from './statistic/statistic.component';
import { RoomJoinComponent } from './room-join/room-join.component';
import { RoomCreateComponent } from './_dialogs/room-create/room-create.component';
import { UserBonusTokenComponent } from './_dialogs/user-bonus-token/user-bonus-token.component';
import { LoginComponent } from './login/login.component';
import { StatisticHelpComponent } from './_dialogs/statistic-help/statistic-help.component';
import { CommentComponent } from './comment/comment.component';
......@@ -54,6 +55,7 @@ import { MatRippleModule } from '@angular/material';
ListStatisticComponent,
StatisticComponent,
RoomCreateComponent,
UserBonusTokenComponent,
LoginComponent,
StatisticHelpComponent,
CommentComponent,
......@@ -88,7 +90,8 @@ import { MatRippleModule } from '@angular/material';
StatisticHelpComponent,
CreateCommentComponent,
PresentCommentComponent,
DeleteAccountComponent
DeleteAccountComponent,
UserBonusTokenComponent
]
})
export class SharedModule {
......
export class BonusToken {
roomId: string;
userId: string;
token: string;
constructor(
roomId: string,
userId: string,
token: string
) {
this.roomId = roomId;
this.userId = userId;
this.token = token;
}
}
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { BonusToken } from '../../models/bonus-token';
import { catchError, tap } from 'rxjs/operators';
import { BaseHttpService } from './base-http.service';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' })
};
@Injectable()
export class BonusTokenService extends BaseHttpService {
private apiUrl = {
base: '/api',
bonustoken: '/bonustoken',
find: '/find'
};
constructor(private http: HttpClient) {
super();
}
getTokensByRoomId(roomId: string): Observable<BonusToken[]> {
const connectionUrl = `${this.apiUrl.base + this.apiUrl.bonustoken + this.apiUrl.find}`;
return this.http.post<BonusToken[]>(connectionUrl, {
properties: {
roomId: roomId
}
}).pipe(
tap(() => ''),
catchError(this.handleError<BonusToken[]>(`get bonus token by roomid = ${roomId}`))
);
}
getTokensByUserId(userId: string): Observable<BonusToken[]> {
const connectionUrl = `${this.apiUrl.base + this.apiUrl.bonustoken + this.apiUrl.find}`;
return this.http.post<BonusToken[]>(connectionUrl, {
properties: {
userId: userId
}
}).pipe(
tap(() => ''),
catchError(this.handleError<BonusToken[]>(`get bonus token by userId = ${userId}`))
);
}
}
......@@ -161,6 +161,8 @@
"a11y-threshold": "Schieberegler zum Einstellen des Schwellenwerts für sichtbare Fragen",
"abort": "Abbrechen",
"answer-statistics": "Statistiken",
"bonus-token": "Tokens für Bonuspunkte",
"bonus-token-header": "Tokens für Bonuspunkte",
"cancel": "Abbrechen",
"cancel-description": "Abbrechen",
"changes-successful": "Änderungen gespeichert.",
......
......@@ -162,6 +162,8 @@
"a11y-threshold": "Slider for setting the threshold for visible questions",
"abort": "Abort",
"answer-statistics": "Statistics",
"bonus-token": "Tokens for bonus points",
"bonus-token-header": "Tokens for bonus points",
"cancel": "Cancel",
"cancel-description": "Cancel",
"changes-successful": "Successfully updated.",
......
......@@ -59,6 +59,7 @@
"my-sessions": "Meine Sitzungen",
"really-delete-account": "Willst du dein Konto mit allen Sitzungen unwiderruflich löschen?",
"sure": "Bist du sicher?",
"user-bonus-token": "Zu deinen Bonus Tokens",
"visited-sessions": "Besuchte Sitzungen"
},
"help": {
......@@ -220,5 +221,8 @@
"activation-key-input-description": "Gib hier den Aktivierungs-Schlüssel ein, den du per E-Mail zugesendet bekommen hast.",
"cancel": "Abbrechen",
"cancel-description": "Abbrechen"
},
"user-bonus-token": {
"header": "Tokens für Bonuspunkte"
}
}
......@@ -60,6 +60,7 @@
"my-sessions": "My sessions",
"really-delete-account": "Do you really want to irrevocably delete your account with the associated sessions?",
"sure": "Are you sure?",
"user-bonus-token": "See your bonus tokens",
"visited-sessions": "Visited sessions"
},
"help": {
......@@ -222,5 +223,8 @@
"activation-key-input-description": "Enter the activation key that you received by e-mail.",
"cancel": "Cancel",
"cancel-description": "Cancel"
},
"user-bonus-token-dialog": {
"header": "Tokens for bonus points"
}
}
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