GitLab wurde aktualisiert. Dank regelmäßiger Updates bleibt das THM GitLab sicher und Sie profitieren von den neuesten Funktionen. Vielen Dank für Ihre Geduld.

Commit 3dc9e748 authored by Nils Mittler's avatar Nils Mittler 🕵🏼
Browse files

Merge branch 'adapt-to-new-backend' into 'master'

Adapt to the new backend

See merge request !441
parents 03f4e9a2 519156e1
Pipeline #51653 passed with stages
in 7 minutes and 14 seconds
......@@ -59,7 +59,7 @@ deploy:
- ngbuild
script:
- eval $(ssh-agent -s)
- mkdir ~/.ssh #&& echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- ssh-keyscan "$SERVER_URL" >> ~/.ssh/known_hosts
- mkdir ~/.ssh
- ssh-keyscan "$NEW_SERVER_URL" >> ~/.ssh/known_hosts
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- scp -r "$BUILD_DIR"* "$SSH_URL"
- scp -r "$BUILD_DIR"* "$NEW_SSH_URL"
......@@ -27,21 +27,20 @@ To set up port forwarding for this VM, proceed as follows:
* Port Forwarding
Forwarding must be entered here for the following ports. The TCP is used as the protocol, host IP and guest IP should remain empty:
* 5984
* 5432
* 5672
* 15672
* 61613
* 8888
* 8080
* 8090
* 80
## Get the code base
Clone the frag-jetzt repository and the Docker Orchestration repository:
* [frag.jetzt](https://git.thm.de/arsnova/frag.jetzt)
* [Docker Orchestration](https://git.thm.de/swtp-2020/docker-orchestration)
* [Docker Orchestration](https://git.thm.de/arsnova/frag.jetzt-docker-orchestration)
## Start the Backend
......@@ -55,10 +54,6 @@ Follow the steps described in the Docker Orchestration repository:
* You may stop it and remove the containers with `docker-compose down`
* You may update your images with `docker-compose pull`
## Add a Database
The first time you start your Backend, you have to add a database. You can add a database to couchdb via http:
* `curl -X PUT http://arsnova:arsnova@127.0.0.1:5984/_users`
## Start the Frontend (Webstorm)
......
{
"/api/comment": {
"target": "http://localhost:8088",
"secure": false,
"pathRewrite": {
"^/api": ""
},
"logLevel": "debug"
},
"/api/vote": {
"target": "http://localhost:8088",
"secure": false,
"pathRewrite": {
"^/api": ""
},
"logLevel": "debug"
},
"/api/bonustoken": {
"target": "http://localhost:8088",
"secure": false,
"pathRewrite": {
"^/api": ""
},
"logLevel": "debug"
},
"/api/settings": {
"target": "http://localhost:8088",
"secure": false,
"pathRewrite": {
"^/api": ""
},
"logLevel": "debug"
},
"/api/ws/websocket": {
"target": "ws://localhost:8099",
"target": "ws://localhost:8080",
"secure": false,
"pathRewrite": {
"^/api": ""
......@@ -41,7 +9,7 @@
"logLevel": "debug"
},
"/api": {
"target": "http://localhost:8080",
"target": "http://localhost:8888",
"secure": false,
"pathRewrite": {
"^/api": ""
......
......@@ -38,7 +38,6 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { DemoVideoComponent } from './components/home/_dialogs/demo-video/demo-video.component';
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 { CustomIconService } from './services/util/custom-icon.service';
import { ModeratorModule } from './components/moderator/moderator.module';
......@@ -156,7 +155,6 @@ export function initializeApp(appConfig: AppConfig) {
UserService,
VoteService,
ModeratorService,
CommentSettingsService,
BonusTokenService,
CustomIconService,
WsConnectorService,
......
......@@ -7,7 +7,6 @@ import { RoomService } from '../../../../services/http/room.service';
import { Router } from '@angular/router';
import { CommentService } from '../../../../services/http/comment.service';
import { BonusTokenService } from '../../../../services/http/bonus-token.service';
import { CommentSettingsService } from '../../../../services/http/comment-settings.service';
import { DeleteCommentsComponent } from '../delete-comments/delete-comments.component';
import { Room } from '../../../../models/room';
import { CommentBonusTokenMixin } from '../../../../models/comment-bonus-token-mixin';
......@@ -40,36 +39,19 @@ export class CommentSettingsComponent implements OnInit {
protected roomService: RoomService,
public router: Router,
public commentService: CommentService,
public commentSettingsService: CommentSettingsService,
private bonusTokenService: BonusTokenService,
@Inject(MAT_DIALOG_DATA) public data: any
) {
}
ngOnInit() {
if (this.editRoom.extensions && this.editRoom.extensions['comments']) {
const commentExtension = this.editRoom.extensions['comments'];
if (commentExtension.enableThreshold !== null) {
if (commentExtension.commentThreshold) {
this.commentThreshold = commentExtension.commentThreshold;
} else {
this.commentThreshold = -100;
}
this.settingThreshold = commentExtension.enableThreshold;
}
if (commentExtension.enableTags !== null) {
this.tagsEnabled = commentExtension.enableTags;
this.tags = commentExtension.tags;
}
if (this.editRoom.extensions['comments'].enableModeration !== null) {
this.enableCommentModeration = this.editRoom.extensions['comments'].enableModeration;
}
if (this.editRoom.threshold !== null) {
this.commentThreshold = this.editRoom.threshold;
this.settingThreshold = true;
}
this.commentSettingsService.get(this.roomId).subscribe(settings => {
this.directSend = settings.directSend;
});
this.tags = [];
this.enableCommentModeration = this.editRoom.moderated;
this.directSend = this.editRoom.directSend;
}
onSliderChange(event: any) {
......@@ -117,9 +99,14 @@ export class CommentSettingsComponent implements OnInit {
commentSettings.roomId = this.roomId;
commentSettings.directSend = this.directSend;
const settingsReturn = new CommentSettingsDialog();
this.editRoom.directSend = this.directSend;
this.editRoom.threshold = this.commentThreshold;
this.editRoom.moderated = this.enableCommentModeration;
// If moderation isn't enabled, the direct send is of no interest and shouldn't be updated to avoid confusion about missing comments
if ((this.enableCommentModeration && !this.directSend) || this.directSend) {
this.commentSettingsService.update(commentSettings).subscribe( x => {
this.roomService.updateRoom(this.editRoom).subscribe(x => {
});
settingsReturn.directSend = this.directSend;
}
......
......@@ -41,12 +41,12 @@ export class ModeratorsComponent implements OnInit {
getModerators() {
this.moderatorService.get(this.roomId).subscribe(list => {
this.moderators = list;
this.moderators.forEach((user, i) => {
this.userIds[i] = user.userId;
this.moderators.forEach((user: any, i) => {
this.userIds[i] = user.accountId;
});
this.moderatorService.getUserData(this.userIds).subscribe(users => {
users.forEach((user, i) => {
this.moderators[i].loginId = user.loginId;
users.forEach((user: any, i) => {
this.moderators[i].loginId = user.email;
});
});
});
......@@ -61,8 +61,8 @@ export class ModeratorsComponent implements OnInit {
return;
}
this.moderatorService.add(this.roomId, list[0].id).subscribe();
this.moderatorService.addToHistory(this.roomId, list[0].id);
this.moderators.push(new Moderator(list[0].id, loginId));
// this.moderatorService.addToHistory(this.roomId, list[0].id);
this.moderators.push(new Moderator(list[0].id, this.roomId, loginId));
this.translationService.get('room-page.moderator-added').subscribe(msg => {
this.notificationService.show(msg);
});
......@@ -77,7 +77,7 @@ export class ModeratorsComponent implements OnInit {
dialogRef.afterClosed()
.subscribe(result => {
if (result === 'delete') {
this.removeModerator(moderator.userId, this.moderators.indexOf(moderator));
this.removeModerator(moderator.accountId, this.moderators.indexOf(moderator));
}
});
}
......
......@@ -13,7 +13,7 @@
aria-labelledby="tag-new"
[formControl]="tagFormControl"
name="taginput"
maxlength="30"/>
maxlength="75"/>
<mat-placeholder class="placeholder">{{ 'room-page.tag-new' | translate }}</mat-placeholder>
<mat-hint align="end"><span aria-hidden="true">{{tag.value.length}} / 30</span></mat-hint>
<mat-error *ngIf="!tagFormControl.valid">
......@@ -29,7 +29,7 @@
</button>
<span class="fill-remaining-space"></span>
</div>
<div *ngIf="tagsEnabled === true && tags !== undefined && tags.length > 0">
<div *ngIf="tags.length > 0">
<div
fxLayout="row"
*ngFor="let tag of tags"
......
......@@ -12,12 +12,9 @@ import { FormControl, Validators } from '@angular/forms';
templateUrl: './tags.component.html',
styleUrls: ['./tags.component.scss']
})
export class TagsComponent implements OnInit {
extension: {};
export class TagsComponent {
tags: string[];
tagsEnabled: boolean;
tagFormControl = new FormControl('', [Validators.minLength(3), Validators.maxLength(50)]);
@ViewChild('tag') redel: ElementRef;
......@@ -32,37 +29,19 @@ export class TagsComponent implements OnInit {
langService.langEmitter.subscribe(lang => translationService.use(lang));
}
ngOnInit() {
if (!this.extension) {
this.extension = {};
this.extension['enableTags'] = true;
this.tags = [];
this.tagsEnabled = true;
} else {
if (this.extension['tags']) {
this.tags = this.extension['tags'];
} else {
this.tags = [];
}
this.tagsEnabled = this.extension['enableTags'];
}
}
addTag(tag: string) {
if (this.tagFormControl.valid) {
if (this.tagFormControl.valid && tag.length > 0) {
this.tags.push(tag);
this.extension['tags'] = this.tags;
this.redel.nativeElement.value = '';
}
}
deleteTag(tag: string) {
this.tags = this.tags.filter(o => o !== tag);
this.extension['tags'] = this.tags;
}
closeDialog(): void {
this.dialogRef.close(this.extension);
this.dialogRef.close(this.tags);
}
......
......@@ -112,7 +112,7 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni
}
}
afterRoomLoadHook() {
postRoomLoadHook() {
if (this.moderationEnabled) {
this.viewModuleCount = this.viewModuleCount + 1;
this.commentService.countByRoomId(this.room.id, false).subscribe(commentCounter => {
......@@ -123,13 +123,7 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni
}
updateCommentSettings(settings: CommentSettingsDialog) {
const commentExtension: TSMap<string, any> = new TSMap();
commentExtension.set('enableThreshold', settings.enableThreshold);
commentExtension.set('commentThreshold', settings.threshold);
commentExtension.set('enableModeration', settings.enableModeration);
commentExtension.set('enableTags', settings.enableTags);
commentExtension.set('tags', settings.tags);
this.room.extensions['comments'] = commentExtension;
this.room.tags = settings.tags;
if (this.moderationEnabled && !settings.enableModeration) {
this.viewModuleCount = this.viewModuleCount - 1;
......@@ -139,14 +133,13 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni
this.moderationEnabled = settings.enableModeration;
localStorage.setItem('moderationEnabled', String(this.moderationEnabled));
this.updRoom.extensions['comments'] = commentExtension;
}
resetThreshold(): void {
if (this.room.extensions && this.room.extensions['comments']) {
delete this.room.extensions['comments'];
}
this.room.moderated = undefined;
this.room.threshold = undefined;
this.room.directSend = undefined;
this.room.tags = undefined;
}
saveChanges() {
......@@ -226,17 +219,17 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni
const dialogRef = this.dialog.open(TagsComponent, {
width: '400px'
});
let tagExtension;
if (this.room.extensions !== undefined && this.room.extensions['tags'] !== undefined) {
tagExtension = JSON.parse(JSON.stringify(this.room.extensions['tags']));
let tags = [];
if (this.room.tags !== undefined) {
tags = this.room.tags;
}
dialogRef.componentInstance.extension = tagExtension;
dialogRef.componentInstance.tags = tags;
dialogRef.afterClosed()
.subscribe(result => {
if (!result || result === 'abort') {
return;
} else {
this.updRoom.extensions['tags'] = result;
this.updRoom.tags = result;
this.saveChanges();
}
});
......
......@@ -121,8 +121,8 @@ export class ModeratorCommentListComponent implements OnInit {
getComments(): void {
this.isLoading = false;
let commentThreshold = -10;
if (this.room && this.room.extensions && this.room.extensions['comments']) {
commentThreshold = this.room.extensions['comments'].commentThreshold;
if (this.room.threshold !== null) {
commentThreshold = this.room.threshold;
if (this.hideCommentsList) {
this.filteredComments = this.filteredComments.filter(x => x.score >= commentThreshold);
} else {
......
......@@ -47,11 +47,9 @@ export class RoomModeratorPageComponent extends RoomPageComponent implements OnI
this.roomService.getRoomByShortId(id).subscribe(room => {
this.room = room;
this.isLoading = false;
if (this.room.extensions && this.room.extensions['comments']) {
if (this.room.extensions['comments'].enableModeration !== null) {
this.moderationEnabled = this.room.extensions['comments'].enableModeration;
this.viewModuleCount = this.viewModuleCount + 1;
}
this.moderationEnabled = this.room.moderated;
if (this.moderationEnabled) {
this.viewModuleCount = this.viewModuleCount + 1;
}
this.commentService.countByRoomId(this.room.id, true).subscribe(commentCounter => {
this.commentCounter = commentCounter;
......
......@@ -15,6 +15,8 @@ import { LiveAnnouncer } from '@angular/cdk/a11y';
import { EventService } from '../../../services/util/event.service';
import { KeyboardUtils } from '../../../utils/keyboard';
import { KeyboardKey } from '../../../utils/keyboard/keys';
import { map } from 'rxjs/operators';
import { Observable, of } from 'rxjs';
@Component({
selector: 'app-room-participant-page',
......@@ -90,14 +92,20 @@ export class RoomParticipantPageComponent extends RoomPageComponent implements O
}
afterRoomLoadHook() {
preRoomLoadHook(): Observable<any> {
this.authenticationService.watchUser.subscribe( user => this.user = user);
if (!this.user) {
this.authenticationService.guestLogin(UserRole.PARTICIPANT).subscribe(() => {
this.roomService.addToHistory(this.room.id);
});
return this.authenticationService.guestLogin(UserRole.PARTICIPANT).pipe(map((user) => {
return user;
}));
} else {
return of(this.user);
}
}
postRoomLoadHook() {
this.authenticationService.setAccess(this.room.shortId, UserRole.PARTICIPANT);
this.authenticationService.checkAccess(this.room.shortId);
this.roomService.addToHistory(this.room.id);
}
}
......@@ -65,9 +65,7 @@ export class CreateCommentComponent implements OnInit {
comment.body = body;
comment.creatorId = this.user.id;
comment.createdFromLecturer = this.user.role === 1;
if (this.selectedTag !== null) {
comment.tag = this.selectedTag;
}
comment.tag = this.selectedTag;
this.dialogRef.close(comment);
}
}
......
......@@ -61,10 +61,6 @@ export class RoomCreateComponent implements OnInit {
return;
}
const newRoom = new Room();
const commentExtension: TSMap<string, any> = new TSMap();
newRoom.extensions = new TSMap();
commentExtension.set('enableModeration', true);
newRoom.extensions.set('comments', commentExtension);
newRoom.name = longRoomName;
newRoom.abbreviation = '00000000';
newRoom.description = '';
......
......@@ -51,7 +51,7 @@ export class CommentAnswerComponent implements OnInit {
saveAnswer() {
this.edit = false;
this.wsCommentService.answer(this.comment, this.answer);
this.commentService.answer(this.comment, this.answer).subscribe();
this.translateService.get('comment-page.comment-answered').subscribe(msg => {
this.notificationService.show(msg);
});
......@@ -71,7 +71,7 @@ export class CommentAnswerComponent implements OnInit {
deleteAnswer() {
this.answer = null;
this.wsCommentService.answer(this.comment, this.answer);
this.commentService.answer(this.comment, this.answer).subscribe();
this.translateService.get('comment-page.answer-deleted').subscribe(msg => {
this.notificationService.show(msg);
});
......
......@@ -91,59 +91,53 @@ export class CommentListComponent implements OnInit, OnDestroy {
}
ngOnInit() {
this.initRoom(() => {
this.authenticationService.watchUser.subscribe(newUser => {
if (newUser) {
this.user = newUser;
this.userRole = this.user.role;
if (this.userRole === 0) {
this.voteService.getByRoomIdAndUserID(this.roomId, this.user.id).subscribe(votes => {
for (const v of votes) {
this.commentVoteMap.set(v.commentId, v);
}
});
}
}
});
this.route.params.subscribe(params => {
this.authenticationService.guestLogin(UserRole.PARTICIPANT).subscribe(r => {
this.roomService.getRoomByShortId(this.shortId).subscribe(room => {
this.room = room;
if (this.room && this.room.extensions && this.room.extensions['comments']) {
if (this.room.extensions['comments'].enableModeration !== null) {
this.moderationEnabled = this.room.extensions['comments'].enableModeration;
localStorage.setItem('moderationEnabled', JSON.stringify(this.moderationEnabled));
}
if (this.room.extensions['comments'].directSend !== null) {
this.directSend = this.room.extensions['comments'].directSend;
}
this.authenticationService.watchUser.subscribe(newUser => {
if (newUser) {
this.user = newUser;
this.userRole = this.user.role;
if (this.userRole === 0) {
this.voteService.getByRoomIdAndUserID(this.roomId, this.user.id).subscribe(votes => {
for (const v of votes) {
this.commentVoteMap.set(v.commentId, v);
}
if (!this.authenticationService.hasAccess(this.shortId, UserRole.PARTICIPANT)) {
this.roomService.addToHistory(this.room.id);
this.authenticationService.setAccess(this.shortId, UserRole.PARTICIPANT);
}
this.subscribeCommentStream();
this.commentService.getAckComments(this.roomId)
.subscribe(comments => {
this.comments = comments;
this.getComments();
});
/**
if (this.userRole === UserRole.PARTICIPANT) {
this.openCreateDialog();
}
*/
});
}
}
});
this.route.params.subscribe(params => {
this.shortId = params['shortId'];
this.authenticationService.guestLogin(UserRole.PARTICIPANT).subscribe(r => {
this.roomService.getRoomByShortId(this.shortId).subscribe(room => {
this.room = room;
this.roomId = room.id;
this.moderationEnabled = this.room.moderated;
this.directSend = this.room.directSend;
localStorage.setItem('moderationEnabled', JSON.stringify(this.moderationEnabled));
if (!this.authenticationService.hasAccess(this.shortId, UserRole.PARTICIPANT)) {
this.roomService.addToHistory(this.room.id);
this.authenticationService.setAccess(this.shortId, UserRole.PARTICIPANT);
}
this.subscribeCommentStream();
this.commentService.getAckComments(this.room.id)
.subscribe(comments => {
this.comments = comments;
this.getComments();
});
/**
if (this.userRole === UserRole.PARTICIPANT) {
this.openCreateDialog();
}
*/
});
});
this.currentSort = this.votedesc;
this.hideCommentsList = false;
this.translateService.use(localStorage.getItem('currentLang'));
this.deviceType = localStorage.getItem('deviceType');
this.isSafari = localStorage.getItem('isSafari');
this.translateService.get('comment-list.search').subscribe(msg => {
this.searchPlaceholder = msg;
});
});
this.currentSort = this.votedesc;
this.hideCommentsList = false;
this.translateService.use(localStorage.getItem('currentLang'));
this