"...shared/git@git.thm.de:mtrl12/frag-jetzt-swtp-2022.git" did not exist on "379b56e6476e344de51d6f9402e686e29339e336"
Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { FormControl, Validators } from '@angular/forms';
import { TranslateService } from '@ngx-translate/core';
import { Comment } from '../../../models/comment';
import { CommentService } from '../../../services/http/comment.service';
import { NotificationService } from '../../../services/util/notification.service';
import { AuthenticationService } from '../../../services/http/authentication.service';
import { User } from '../../../models/user';
import { CommentListComponent } from '../../shared/comment-list/comment-list.component';
import { RxStompService } from '@stomp/ng2-stompjs';
import { CreateComment } from '../../../models/messages/create-comment';
@Component({
selector: 'app-comment-create-page',
templateUrl: './comment-create-page.component.html',
styleUrls: ['./comment-create-page.component.scss']
})
export class CommentCreatePageComponent implements OnInit {
@ViewChild(CommentListComponent) child: CommentListComponent;
roomId: string;
roomShortId: string;
user: User;
private date = new Date(Date.now());
subjectForm = new FormControl('', [Validators.required]);
bodyForm = new FormControl('', [Validators.required]);
constructor(
protected authenticationService: AuthenticationService,
private route: ActivatedRoute,
private notification: NotificationService,
private translationService: TranslateService,
private rxStompService: RxStompService) { }
ngOnInit(): void {
this.user = this.authenticationService.getUser();
this.roomShortId = this.route.snapshot.paramMap.get('roomId');
this.roomId = localStorage.getItem(`roomId`);
}
send(subject: string, body: string): void {
subject = subject.trim();
body = body.trim();
if (!subject && !body) {
this.translationService.get('comment-page.error-both-fields').subscribe(translatedMessage => {
this.notification.show(translatedMessage);
});
return;
}
if (!subject) {
this.translationService.get('comment-page.error-title').subscribe(translatedMessage => {
this.notification.show(translatedMessage);
});
return;
}
if (!body) {
this.translationService.get('comment-page.error-comment').subscribe(translatedMessage => {
this.notification.show(translatedMessage);
});
return;
}
const message = new CreateComment(this.roomId, this.user.id, subject, body);
this.rxStompService.publish({
destination: `/queue/comment.command`,
body: JSON.stringify(message),
headers: {
'content-type': 'application/json'
}
});
/*this.commentService.addComment({
id: '',
roomId: this.roomId,
userId: this.user.id,
subject: subject,
body: body,
creationTimestamp: this.date.getTime(),
read: false,
revision: ''
} as Comment).subscribe(() => {
this.child.getComments();
this.notification.show(`Comment '${subject}' successfully created.`);
this.goBack();
});*/
}
}