From 94d421d08f24b117b58bc87799861016fbff8ec0 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 14 Mar 2021 08:31:19 +0200 Subject: Updated admin-panel-page's subscriptions to use an observer object --- .../admin-panel-page/admin-panel-page.component.ts | 116 +++++++++++---------- 1 file changed, 61 insertions(+), 55 deletions(-) diff --git a/src/app/components/admin-panel-page/admin-panel-page.component.ts b/src/app/components/admin-panel-page/admin-panel-page.component.ts index 95d69d3..d5ecc71 100644 --- a/src/app/components/admin-panel-page/admin-panel-page.component.ts +++ b/src/app/components/admin-panel-page/admin-panel-page.component.ts @@ -46,17 +46,17 @@ export class AdminPanelPageComponent implements OnInit { return; } - this._userService.getUserFromSessionStorageRequest().subscribe( - (result: object) => { + this._userService.getUserFromSessionStorageRequest().subscribe({ + next: (result: object) => { const user = result as User; if (!user.roles.map(x => x.name).includes(AppConstants.ADMIN_ROLE_NAME)) { this._router.navigate(['/login']); } }, - () => { + error: () => { this._router.navigate(['/login']); } - ); + }); this.languageForm = this._fb.group({ languageCreate: new FormControl(''), @@ -65,9 +65,11 @@ export class AdminPanelPageComponent implements OnInit { deleteLanguageName: new FormControl('') }); - this.languageForm.valueChanges.subscribe(() => { - this._successBar?.hideMsg(); - this._errorBar?.hideError(); + this.languageForm.valueChanges.subscribe({ + next: () => { + this._successBar?.hideMsg(); + this._errorBar?.hideError(); + } }); this.technologyForm = this._fb.group({ @@ -77,9 +79,11 @@ export class AdminPanelPageComponent implements OnInit { deleteTechnologyName: new FormControl('') }); - this.technologyForm.valueChanges.subscribe(() => { - this._successBar?.hideMsg(); - this._errorBar?.hideError(); + this.technologyForm.valueChanges.subscribe({ + next: () => { + this._successBar?.hideMsg(); + this._errorBar?.hideError(); + } }); this.deleteForm = this._fb.group({ @@ -88,9 +92,11 @@ export class AdminPanelPageComponent implements OnInit { deleteComment: new FormControl('') }); - this.deleteForm.valueChanges.subscribe(() => { - this._successBar?.hideMsg(); - this._errorBar?.hideError(); + this.deleteForm.valueChanges.subscribe({ + next: () => { + this._successBar?.hideMsg(); + this._errorBar?.hideError(); + } }); this.loadAvailableLanguages(); @@ -128,14 +134,14 @@ export class AdminPanelPageComponent implements OnInit { const languageCreate: string = this.languageForm.get('languageCreate')?.value; if (languageCreate !== '' && languageCreate !== null) { - this._languageService.createLanguageWithSessionStorageRequest(languageCreate.trim()).subscribe( - () => { + this._languageService.createLanguageWithSessionStorageRequest(languageCreate.trim()).subscribe({ + next: () => { this.languageModifiedSuccess('Successfully updated languages!'); }, - (err: HttpErrorResponse) => { + error: (err: HttpErrorResponse) => { this._errorBar.showError(err); } - ); + }); } } @@ -146,14 +152,14 @@ export class AdminPanelPageComponent implements OnInit { if (updateLanguageOldName !== '' && updateLanguageOldName !== null && updateLanguageNewName !== '' && updateLanguageNewName !== null) { const langId = this.availableLanguages.filter(x => x.name === updateLanguageOldName.trim())[0].id; - this._languageService.putLanguageWithSessionStorageRequest(langId, updateLanguageNewName.trim()).subscribe( - () => { + this._languageService.putLanguageWithSessionStorageRequest(langId, updateLanguageNewName.trim()).subscribe({ + next: () => { this.languageModifiedSuccess('Successfully updated languages!'); }, - (err: HttpErrorResponse) => { + error: (err: HttpErrorResponse) => { this._errorBar.showError(err); } - ); + }); } } @@ -163,14 +169,14 @@ export class AdminPanelPageComponent implements OnInit { if (deleteLanguageName !== '' && deleteLanguageName !== null) { const langId = this.availableLanguages.filter(x => x.name === deleteLanguageName.trim())[0].id; - this._languageService.deleteLanguageWithSessionStorageRequest(langId).subscribe( - () => { + this._languageService.deleteLanguageWithSessionStorageRequest(langId).subscribe({ + next: () => { this.languageModifiedSuccess('Successfully deleted language!'); }, - (err: HttpErrorResponse) => { + error: (err: HttpErrorResponse) => { this._errorBar.showError(err); } - ); + }); } } @@ -181,11 +187,11 @@ export class AdminPanelPageComponent implements OnInit { } private loadAvailableLanguages(): void { - this._languageService.getAllLanguagesWithSessionStorageRequest().subscribe( - (result: object) => { + this._languageService.getAllLanguagesWithSessionStorageRequest().subscribe({ + next: (result: object) => { this.availableLanguages = result as Language[]; } - ); + }); } // Technology modifying @@ -204,14 +210,14 @@ export class AdminPanelPageComponent implements OnInit { const technologyCreate: string = this.technologyForm.get('technologyCreate')?.value; if (technologyCreate !== '' && technologyCreate !== null) { - this._technologyService.createTechnologyWithSessionStorageRequest(technologyCreate.trim()).subscribe( - () => { + this._technologyService.createTechnologyWithSessionStorageRequest(technologyCreate.trim()).subscribe({ + next: () => { this.technologyModifiedSuccess('Successfully updated technologies!'); }, - (err: HttpErrorResponse) => { + error: (err: HttpErrorResponse) => { this._errorBar.showError(err); } - ); + }); } } @@ -222,14 +228,14 @@ export class AdminPanelPageComponent implements OnInit { if (updateTechnologyOldName !== '' && updateTechnologyOldName !== null && updateTechnologyNewName !== '' && updateTechnologyNewName !== null) { const techId = this.availableTechnologies.filter(x => x.name === updateTechnologyOldName.trim())[0].id; - this._technologyService.putTechnologyWithSessionStorageRequest(techId, updateTechnologyNewName.trim()).subscribe( - () => { + this._technologyService.putTechnologyWithSessionStorageRequest(techId, updateTechnologyNewName.trim()).subscribe({ + next: () => { this.technologyModifiedSuccess('Successfully updated technologies!'); }, - (err: HttpErrorResponse) => { + error: (err: HttpErrorResponse) => { this._errorBar.showError(err); } - ); + }); } } @@ -239,14 +245,14 @@ export class AdminPanelPageComponent implements OnInit { if (deleteTechnologyName !== '' && deleteTechnologyName !== null) { const techId = this.availableTechnologies.filter(x => x.name === deleteTechnologyName.trim())[0].id; - this._technologyService.deleteTechnologyWithSessionStorageRequest(techId).subscribe( - () => { + this._technologyService.deleteTechnologyWithSessionStorageRequest(techId).subscribe({ + next: () => { this.technologyModifiedSuccess('Successfully deleted technology!'); }, - (err: HttpErrorResponse) => { + error: (err: HttpErrorResponse) => { this._errorBar.showError(err); } - ); + }); } } @@ -257,11 +263,11 @@ export class AdminPanelPageComponent implements OnInit { } private loadAvailableTechnologies(): void { - this._technologyService.getAllTechnologiesWithSessionStorageRequest().subscribe( - (result: object) => { + this._technologyService.getAllTechnologiesWithSessionStorageRequest().subscribe({ + next: (result: object) => { this.availableTechnologies = result as Technology[]; } - ); + }); } // Deletions @@ -282,14 +288,14 @@ export class AdminPanelPageComponent implements OnInit { if (deleteUser !== '' && deleteUser !== null) { const userId: Guid = Guid.parse(deleteUser); - this._userService.deleteUserRequest(userId, this._tokenService.getTokenFromSessionStorage()).subscribe( - () => { + this._userService.deleteUserRequest(userId, this._tokenService.getTokenFromSessionStorage()).subscribe({ + next: () => { this.deletionSuccess('Successfully deleted user!'); }, - (err: HttpErrorResponse) => { + error: (err: HttpErrorResponse) => { this._errorBar.showError(err); } - ); + }); } } @@ -299,14 +305,14 @@ export class AdminPanelPageComponent implements OnInit { if (deletePost !== '' && deletePost !== null) { const postId: Guid = Guid.parse(deletePost); - this._postService.deletePostRequest(postId, this._tokenService.getTokenFromSessionStorage()).subscribe( - () => { + this._postService.deletePostRequest(postId, this._tokenService.getTokenFromSessionStorage()).subscribe({ + next: () => { this.deletionSuccess('Successfully deleted user!'); }, - (err: HttpErrorResponse) => { + error: (err: HttpErrorResponse) => { this._errorBar.showError(err); } - ); + }); } } @@ -316,14 +322,14 @@ export class AdminPanelPageComponent implements OnInit { if (deleteComment !== '' && deleteComment !== null) { const commentId: Guid = Guid.parse(deleteComment); - this._commentService.deleteCommentWithSessionStorage(commentId).subscribe( - () => { + this._commentService.deleteCommentWithSessionStorage(commentId).subscribe({ + next: () => { this.deletionSuccess('Successfully deleted comment!'); }, - (err: HttpErrorResponse) => { + error: (err: HttpErrorResponse) => { this._errorBar.showError(err); } - ); + }); } } -- cgit v1.2.3 From 807e72b990e7412bdf243095a07bd716bb93453f Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 14 Mar 2021 08:34:59 +0200 Subject: Updated comment and comment-page's subscriptions to use an observer object --- .../comment-page/comment-page.component.ts | 20 ++++++++++---------- src/app/components/comment/comment.component.ts | 12 ++++++------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/app/components/comment-page/comment-page.component.ts b/src/app/components/comment-page/comment-page.component.ts index 413436e..9bbdc59 100644 --- a/src/app/components/comment-page/comment-page.component.ts +++ b/src/app/components/comment-page/comment-page.component.ts @@ -32,8 +32,8 @@ export class CommentPageComponent implements OnInit { // Gets the post and the logged in user and compares them, // to determine if the current post is made by the user - this._commentService.getCommentRequest(this.commentId).subscribe( - (result: object) => { + this._commentService.getCommentRequest(this.commentId).subscribe({ + next: (result: object) => { this.comment = result as Comment; if (this.loggedIn) { this.editable = this.comment.issuerUsername === this._tokenService.getUsernameFromSessionStorageToken(); @@ -41,10 +41,10 @@ export class CommentPageComponent implements OnInit { } this.loaded = true; }, - () => { + error: () => { this._router.navigate(['/not-found']); } - ); + }); this.editCommentFormGroup = this._fb.group({ newCommentMessage: new FormControl('') @@ -66,22 +66,22 @@ export class CommentPageComponent implements OnInit { if (newMessage !== '' && newMessage !== this.comment.message) { console.log(this.commentId); - this._commentService.putCommentWithSessionStorageRequest(this.commentId, this.comment.postId, newMessage).subscribe( - () => { + this._commentService.putCommentWithSessionStorageRequest(this.commentId, this.comment.postId, newMessage).subscribe({ + next: () => { this.reloadPage(); } - ); + }); } } this.editingComment = !this.editingComment; } deleteComment(): void { - this._commentService.deleteCommentWithSessionStorage(this.commentId).subscribe( - () => { + this._commentService.deleteCommentWithSessionStorage(this.commentId).subscribe({ + next: () => { this.toPost(); } - ); + }); } private reloadPage(): void { diff --git a/src/app/components/comment/comment.component.ts b/src/app/components/comment/comment.component.ts index 5076769..d4dd9f4 100644 --- a/src/app/components/comment/comment.component.ts +++ b/src/app/components/comment/comment.component.ts @@ -25,23 +25,23 @@ export class CommentComponent implements OnInit { this.comment = this._commentService.getDefaultComment(); this.user = this._userService.getDefaultUser(); - this._commentService.getCommentRequest(Guid.parse(this.paramId)).subscribe( - (result: object) => { + this._commentService.getCommentRequest(Guid.parse(this.paramId)).subscribe({ + next: (result: object) => { Object.assign(this.comment, result); this.timeCreated = new Date(this.comment.timeCreated).toLocaleString('en-GB'); this.loadUser(); } - ); + }); } private loadUser(): void { - this._userService.getUserByUsernameRequest(this.comment.issuerUsername).subscribe( - (result: object) => { + this._userService.getUserByUsernameRequest(this.comment.issuerUsername).subscribe({ + next: (result: object) => { Object.assign(this.user, result); this.loaded = true; } - ); + }); } goToAuthorProfile(): void { -- cgit v1.2.3 From c073a058bb7e97e6a9319e88f3f7765d4a466bd0 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 14 Mar 2021 08:37:10 +0200 Subject: Updated feed's subscriptions to use an observer object --- src/app/components/feed/feed.component.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/app/components/feed/feed.component.ts b/src/app/components/feed/feed.component.ts index eaa0ef1..a9a042c 100644 --- a/src/app/components/feed/feed.component.ts +++ b/src/app/components/feed/feed.component.ts @@ -49,27 +49,27 @@ export class FeedComponent implements OnInit { fileUpload: new FormControl('') }); - this._userService.getUserFromSessionStorageRequest().subscribe( - (res: object) => { + this._userService.getUserFromSessionStorageRequest().subscribe({ + next: (res: object) => { Object.assign(this.user, res); this.loadFeed(); }, - () => { + error: () => { this.logout(); } - ); + }); } private loadFeed(): void { - this._feedService.getUserFeedFromSessionStorageRequest(this._currentPage++, this._timeLoaded, AppConstants.PAGE_SIZE).subscribe( - (result: object) => { + this._feedService.getUserFeedFromSessionStorageRequest(this._currentPage++, this._timeLoaded, AppConstants.PAGE_SIZE).subscribe({ + next: (result: object) => { this.posts.push(...Object.values(result)[0]); this.finishUserLoading(); }, - () => { + error: () => { this.finishUserLoading(); } - ); + }); } private finishUserLoading(): void { @@ -102,14 +102,14 @@ export class FeedComponent implements OnInit { const postMessage = this.createPostFormGroup.get('newPostMessage')?.value; this.dataArrived = false; - this._postService.createPostWithSessionStorageRequest(postMessage, this.files).subscribe( - () => { + this._postService.createPostWithSessionStorageRequest(postMessage, this.files).subscribe({ + next: () => { this.goToProfile(); }, - () => { + error: () => { this.dataArrived = true; } - ); + }); } onScroll(event: any): void { -- cgit v1.2.3 From 82594c050a9bbd1f527142ffe21e66c8c5f27ba3 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 14 Mar 2021 08:39:03 +0200 Subject: Updated login and register's subscriptions to use an observer object --- src/app/components/login/login.component.ts | 8 ++++---- src/app/components/register/register.component.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/components/login/login.component.ts b/src/app/components/login/login.component.ts index c3fb79c..f64848c 100644 --- a/src/app/components/login/login.component.ts +++ b/src/app/components/login/login.component.ts @@ -34,15 +34,15 @@ export class LoginComponent implements OnInit { onSubmit(): void { this._errorBar.hideError(); - this._userService.loginUserRequest(this.loginUserFormGroup).subscribe( - (res: object) => { + this._userService.loginUserRequest(this.loginUserFormGroup).subscribe({ + next: (res: object) => { this._tokenService.setUserTokenToSessionStorage(res); this._router.navigate(['/']); }, - (err: HttpErrorResponse) => { + error: (err: HttpErrorResponse) => { this._errorBar.showError(err); } - ); + }); } onRedirectRegister(): void { diff --git a/src/app/components/register/register.component.ts b/src/app/components/register/register.component.ts index 36eaa55..e51a365 100644 --- a/src/app/components/register/register.component.ts +++ b/src/app/components/register/register.component.ts @@ -50,15 +50,15 @@ export class RegisterComponent implements OnInit { } onSubmit(): void { - this._userService.registerUserRequest(this.registerUserFormGroup).subscribe( - res => { + this._userService.registerUserRequest(this.registerUserFormGroup).subscribe({ + next: (res: object) => { this._tokenService.setUserTokenToSessionStorage(res); this._router.navigate(['/']); }, - (err: HttpErrorResponse) => { + error: (err: HttpErrorResponse) => { this._errorBar.showError(err); } - ); + }); } onRedirectLogin(): void { this._router.navigate(['/login']); -- cgit v1.2.3 From 065bfead76fc9e94c8344d812ee7f5b214c74321 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 14 Mar 2021 08:41:52 +0200 Subject: Update post and post-page's subscriptions to use an observer object --- .../components/post-page/post-page.component.ts | 32 +++++++++++----------- src/app/components/post/post.component.ts | 12 ++++---- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/app/components/post-page/post-page.component.ts b/src/app/components/post-page/post-page.component.ts index 1ac89f4..7c32ce0 100644 --- a/src/app/components/post-page/post-page.component.ts +++ b/src/app/components/post-page/post-page.component.ts @@ -37,8 +37,8 @@ export class PostPageComponent implements OnInit { // Gets the post and the logged in user and compares them, // to determine if the current post is made by the user - this._postService.getPostRequest(this.postId).subscribe( - (result: object) => { + this._postService.getPostRequest(this.postId).subscribe({ + next: (result: object) => { this.post = result as Post; this.post.fileURLs = Object.values(result)[7]; if (this.loggedIn) { @@ -52,10 +52,10 @@ export class PostPageComponent implements OnInit { this.dataArrived = true; } }, - () => { + error: () => { this._router.navigate(['/not-found']); } - ); + }); this.editPostFormGroup = this._fb.group({ newPostMessage: new FormControl(''), @@ -69,8 +69,8 @@ export class PostPageComponent implements OnInit { private loadFiles(): void { for (const fileURL of this.post.fileURLs) { - this._cloudinaryService.getFileRequest(fileURL).subscribe( - (result: object) => { + this._cloudinaryService.getFileRequest(fileURL).subscribe({ + next: (result: object) => { const file = result as File; const tmp = { name: fileURL.match('(?<=\/)(?:.(?!\/))+$')?.pop() ?? 'Attachment' @@ -83,7 +83,7 @@ export class PostPageComponent implements OnInit { this.dataArrived = true; } } - ); + }); } } @@ -118,11 +118,11 @@ export class PostPageComponent implements OnInit { const newMessage = this.editPostFormGroup.get('newPostMessage')?.value; if (newMessage === '' && newMessage !== this.post.message) { - this._postService.putPostWithSessionStorageRequest(this.postId, newMessage, this.files).subscribe( - () => { + this._postService.putPostWithSessionStorageRequest(this.postId, newMessage, this.files).subscribe({ + next: () => { this.reloadPage(); } - ); + }); this.dataArrived = false; } } @@ -137,21 +137,21 @@ export class PostPageComponent implements OnInit { const newComment = this.addCommentFormGroup.get('newComment')?.value; if (newComment !== '' && newComment !== null) { - this._commentService.createCommentWithSessionStorageRequest(this.postId, newComment).subscribe( - () => { + this._commentService.createCommentWithSessionStorageRequest(this.postId, newComment).subscribe({ + next: () => { this.editPostFormGroup.reset(); this.reloadPage(); } - ); + }); } } deletePost(): void { - this._postService.deletePostWithSessionStorage(this.postId).subscribe( - () => { + this._postService.deletePostWithSessionStorage(this.postId).subscribe({ + next: () => { this._router.navigate(['/profile/' + this._tokenService.getUsernameFromSessionStorageToken()]); } - ); + }); } private reloadPage(): void { diff --git a/src/app/components/post/post.component.ts b/src/app/components/post/post.component.ts index 387f56f..a46811d 100644 --- a/src/app/components/post/post.component.ts +++ b/src/app/components/post/post.component.ts @@ -26,8 +26,8 @@ export class PostComponent implements OnInit { this.post = this._postService.getDefaultPost(); this.user = this._userService.getDefaultUser(); - this._postService.getPostRequest(Guid.parse(this.paramId)).subscribe( - (result: object) => { + this._postService.getPostRequest(Guid.parse(this.paramId)).subscribe({ + next: (result: object) => { Object.assign(this.post, result); this.post.fileURLs = Object.values(result)[7]; this.votesNumber = 23; @@ -35,16 +35,16 @@ export class PostComponent implements OnInit { this.timeCreated = new Date(this.post.timeCreated).toLocaleString('en-GB'); this.loadUser(); } - ); + }); } private loadUser(): void { - this._userService.getUserByUsernameRequest(this.post.creatorUsername).subscribe( - (result: object) => { + this._userService.getUserByUsernameRequest(this.post.creatorUsername).subscribe({ + next: (result: object) => { Object.assign(this.user, result); this.loaded = true; } - ); + }); } goToAuthorProfile(): void { -- cgit v1.2.3 From a643d5ca122b2546a02ec06e355c0d42661fdf24 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 14 Mar 2021 08:45:45 +0200 Subject: Updated profile and profile-setting's subscriptions to use an observer object --- .../profile-settings/profile-settings.component.ts | 58 +++++++++++----------- src/app/components/profile/profile.component.ts | 38 +++++++------- 2 files changed, 49 insertions(+), 47 deletions(-) diff --git a/src/app/components/profile-settings/profile-settings.component.ts b/src/app/components/profile-settings/profile-settings.component.ts index f3cd4c1..ba1fbb6 100644 --- a/src/app/components/profile-settings/profile-settings.component.ts +++ b/src/app/components/profile-settings/profile-settings.component.ts @@ -50,35 +50,35 @@ export class ProfileSettingsComponent implements OnInit { this.availableTechnologies = []; this.newProfilePicture = new File([], ''); - this._userService.getUserByUsernameRequest(this._urlUsername).subscribe( - (res: object) => { + this._userService.getUserByUsernameRequest(this._urlUsername).subscribe({ + next: (res: object) => { Object.assign(this.user, res); this.isAdminUser = this.user.roles.map(x => x.name).includes(AppConstants.ADMIN_ROLE_NAME); this.finishUserLoading(); }, - () => { + error: () => { this._router.navigate(['/not-found']); } - ); + }); - this._languageService.getAllLanguagesWithSessionStorageRequest().subscribe( - (result: object) => { + this._languageService.getAllLanguagesWithSessionStorageRequest().subscribe({ + next: (result: object) => { this.availableLanguages = result as Language[]; } - ); - this._technologyService.getAllTechnologiesWithSessionStorageRequest().subscribe( - (result: object) => { + }); + this._technologyService.getAllTechnologiesWithSessionStorageRequest().subscribe({ + next: (result: object) => { this.availableTechnologies = result as Technology[]; } - ); + }); } private finishUserLoading(): void { if (sessionStorage.getItem('UserCred')) { const userFromToken: User = this._userService.getDefaultUser(); - this._userService.getUserFromSessionStorageRequest().subscribe( - (tokenRes: object) => { + this._userService.getUserFromSessionStorageRequest().subscribe({ + next: (tokenRes: object) => { Object.assign(userFromToken, tokenRes); if (userFromToken.userName === this._urlUsername) { @@ -89,10 +89,10 @@ export class ProfileSettingsComponent implements OnInit { this.goToProfile(); } }, - () => { + error: () => { this.logout(); } - ); + }); } else { this.goToProfile(); @@ -147,9 +147,11 @@ export class ProfileSettingsComponent implements OnInit { fileUpload: new FormControl('') }); - this.updateUserFormGroup.valueChanges.subscribe(() => { - this._successBar?.hideMsg(); - this._errorBar?.hideError(); + this.updateUserFormGroup.valueChanges.subscribe({ + next: () => { + this._successBar?.hideMsg(); + this._errorBar?.hideError(); + } }); } @@ -180,11 +182,11 @@ export class ProfileSettingsComponent implements OnInit { return; } - this._userService.putProfilePictureFromSessionStorageRequest(this.newProfilePicture).subscribe( - () => { + this._userService.putProfilePictureFromSessionStorageRequest(this.newProfilePicture).subscribe({ + next: () => { this.reloadPage(); } - ); + }); this.dataArrived = false; } @@ -195,14 +197,14 @@ export class ProfileSettingsComponent implements OnInit { this.patchLanguagesControl(); this.patchTechnologiesControl(); - this._userService.putUserFromSessionStorageRequest(this.updateUserFormGroup, this.user.roles, this.user.friends).subscribe( - () => { + this._userService.putUserFromSessionStorageRequest(this.updateUserFormGroup, this.user.roles, this.user.friends).subscribe({ + next: () => { this._successBar.showMsg('Profile updated successfully!'); }, - (err: HttpErrorResponse) => { + error: (err: HttpErrorResponse) => { this._errorBar.showError(err); } - ); + }); } private patchLanguagesControl(): void { @@ -284,14 +286,14 @@ export class ProfileSettingsComponent implements OnInit { deleteAccount(): void { if (this.deleteAccountConfirm) { - this._userService.deleteUserFromSessionStorageRequest().subscribe( - () => { + this._userService.deleteUserFromSessionStorageRequest().subscribe({ + next: () => { this.logout(); }, - (err: HttpErrorResponse) => { + error: (err: HttpErrorResponse) => { this._errorBar.showError(err); } - ); + }); this.dataArrived = false; } else { diff --git a/src/app/components/profile/profile.component.ts b/src/app/components/profile/profile.component.ts index eaa1bec..429b9b8 100644 --- a/src/app/components/profile/profile.component.ts +++ b/src/app/components/profile/profile.component.ts @@ -52,16 +52,16 @@ export class ProfileComponent implements OnInit { password: new FormControl('') }); - this._userService.getUserByUsernameRequest(this._urlUsername).subscribe( - (res: object) => { + this._userService.getUserByUsernameRequest(this._urlUsername).subscribe({ + next: (res: object) => { Object.assign(this.user, res); this.isAdminUser = this.user.roles.map(x => x.name).includes(AppConstants.ADMIN_ROLE_NAME); this.loadLanguages(); }, - () => { + error: () => { this._router.navigate(['/not-found']); } - ); + }); } private loadLanguages(): void { @@ -91,17 +91,17 @@ export class ProfileComponent implements OnInit { } private loadPosts(): void { - this._feedService.getUserPostsRequest(this.user.userName, this._currentPage++, this._timeLoaded, AppConstants.PAGE_SIZE).subscribe( - (result: object) => { + this._feedService.getUserPostsRequest(this.user.userName, this._currentPage++, this._timeLoaded, AppConstants.PAGE_SIZE).subscribe({ + next: (result: object) => { const resultArr: Post[] = Object.values(result)[0]; this.userPosts.push(...resultArr); this.finishUserLoading(); }, - () => { + error: () => { this._currentPage = -1; this.finishUserLoading(); } - ); + }); } private finishUserLoading(): void { @@ -109,8 +109,8 @@ export class ProfileComponent implements OnInit { this.isUserLoggedIn = true; const userFromToken: User = this._userService.getDefaultUser(); - this._userService.getUserFromSessionStorageRequest().subscribe( - (tokenRes: object) => { + this._userService.getUserFromSessionStorageRequest().subscribe({ + next: (tokenRes: object) => { Object.assign(userFromToken, tokenRes); if (userFromToken.friends.map(x => x.userName).includes(this._urlUsername)) { @@ -121,10 +121,10 @@ export class ProfileComponent implements OnInit { } this.dataArrived = true; }, - () => { + error: () => { this.logout(); } - ); + }); } else { this.dataArrived = true; @@ -156,8 +156,8 @@ export class ProfileComponent implements OnInit { if (this.updatingFriendship) { this.dataArrived = false; - this._userService.getUserFromSessionStorageRequest().subscribe( - (result: object) => { + this._userService.getUserFromSessionStorageRequest().subscribe({ + next: (result: object) => { const loggedInUser: User = result as User; if (this.friendOfUser) { @@ -169,16 +169,16 @@ export class ProfileComponent implements OnInit { loggedInUser.friends.push(newFriend); } - this._userService.putBareUserFromSessionStorageRequest(loggedInUser, this.updateFrienship.get('password')?.value).subscribe( - () => { + this._userService.putBareUserFromSessionStorageRequest(loggedInUser, this.updateFrienship.get('password')?.value).subscribe({ + next: () => { this.reloadPage(); }, - () => { + error: () => { this._router.navigate(['/']); } - ); + }); } - ); + }); } this.updatingFriendship = !this.updatingFriendship; } -- cgit v1.2.3 From 0d58551a6b54457fc24d926f46a6efd73e332901 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 14 Mar 2021 08:51:57 +0200 Subject: Removed unnecessary getters for form group controls from login and register components --- src/app/components/login/login.component.ts | 10 +--------- src/app/components/register/register.component.ts | 20 -------------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/app/components/login/login.component.ts b/src/app/components/login/login.component.ts index f64848c..edbc461 100644 --- a/src/app/components/login/login.component.ts +++ b/src/app/components/login/login.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, ViewChild } from '@angular/core'; -import { FormGroup, FormBuilder, Validators, FormControl, AbstractControl } from '@angular/forms'; +import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms'; import { Router } from '@angular/router'; import { Title } from '@angular/platform-browser'; import { UserService } from 'src/app/services/user.service'; @@ -48,12 +48,4 @@ export class LoginComponent implements OnInit { onRedirectRegister(): void { this._router.navigate(['/register']); } - - get username(): AbstractControl | null { - return this.loginUserFormGroup.get('username'); - } - - get password(): AbstractControl | null { - return this.loginUserFormGroup.get('password'); - } } diff --git a/src/app/components/register/register.component.ts b/src/app/components/register/register.component.ts index e51a365..b5800ad 100644 --- a/src/app/components/register/register.component.ts +++ b/src/app/components/register/register.component.ts @@ -63,24 +63,4 @@ export class RegisterComponent implements OnInit { onRedirectLogin(): void { this._router.navigate(['/login']); } - - get firstName(): AbstractControl | null { - return this.registerUserFormGroup.get('firstName'); - } - - get lastName(): AbstractControl | null { - return this.registerUserFormGroup.get('lastName'); - } - - get username(): AbstractControl | null { - return this.registerUserFormGroup.get('username'); - } - - get email(): AbstractControl | null { - return this.registerUserFormGroup.get('email'); - } - - get password(): AbstractControl | null { - return this.registerUserFormGroup.get('password'); - } } -- cgit v1.2.3 From 95bcb91f281049fef320c788b71b0731b4910108 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 14 Mar 2021 08:58:25 +0200 Subject: Moved a nested http request in profile component to it's own method --- src/app/components/profile/profile.component.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/app/components/profile/profile.component.ts b/src/app/components/profile/profile.component.ts index 429b9b8..73e1e96 100644 --- a/src/app/components/profile/profile.component.ts +++ b/src/app/components/profile/profile.component.ts @@ -169,20 +169,24 @@ export class ProfileComponent implements OnInit { loggedInUser.friends.push(newFriend); } - this._userService.putBareUserFromSessionStorageRequest(loggedInUser, this.updateFrienship.get('password')?.value).subscribe({ - next: () => { - this.reloadPage(); - }, - error: () => { - this._router.navigate(['/']); - } - }); + this.updateUserWithNewFriends(loggedInUser); } }); } this.updatingFriendship = !this.updatingFriendship; } + private updateUserWithNewFriends(loggedInUser: User): void { + this._userService.putBareUserFromSessionStorageRequest(loggedInUser, this.updateFrienship.get('password')?.value).subscribe({ + next: () => { + this.reloadPage(); + }, + error: () => { + this._router.navigate(['/']); + } + }); + } + onScroll(event: any): void { // Detects when the element has reached the bottom, thx https://stackoverflow.com/a/50038429/12036073 if (event.target.offsetHeight + event.target.scrollTop >= event.target.scrollHeight && this._currentPage > 0) { -- cgit v1.2.3 From e8fef550d576aa3eba9d51ea70a3beeac6157ba5 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 14 Mar 2021 09:03:03 +0200 Subject: Renamed all models to have proper naming (from model-name.ts to model-name.model.ts), updated includes of services --- src/app/services/comment.service.ts | 2 +- src/app/services/language.service.ts | 2 +- src/app/services/post.service.ts | 2 +- src/app/services/technology.service.ts | 2 +- src/app/services/user.service.ts | 6 +- src/models/comment.model.ts | 70 +++++++++++++++++++++++ src/models/comment.ts | 70 ----------------------- src/models/identity/friend.model.ts | 3 + src/models/identity/friend.ts | 3 - src/models/identity/role.model.ts | 3 + src/models/identity/role.ts | 3 - src/models/identity/user.model.ts | 100 +++++++++++++++++++++++++++++++++ src/models/identity/user.ts | 100 --------------------------------- src/models/language.model.ts | 6 ++ src/models/language.ts | 6 -- src/models/post-comment.model.ts | 5 ++ src/models/post-comment.ts | 5 -- src/models/post.model.ts | 81 ++++++++++++++++++++++++++ src/models/post.ts | 81 -------------------------- src/models/technology.model.ts | 6 ++ src/models/technology.ts | 6 -- 21 files changed, 281 insertions(+), 281 deletions(-) create mode 100644 src/models/comment.model.ts delete mode 100644 src/models/comment.ts create mode 100644 src/models/identity/friend.model.ts delete mode 100644 src/models/identity/friend.ts create mode 100644 src/models/identity/role.model.ts delete mode 100644 src/models/identity/role.ts create mode 100644 src/models/identity/user.model.ts delete mode 100644 src/models/identity/user.ts create mode 100644 src/models/language.model.ts delete mode 100644 src/models/language.ts create mode 100644 src/models/post-comment.model.ts delete mode 100644 src/models/post-comment.ts create mode 100644 src/models/post.model.ts delete mode 100644 src/models/post.ts create mode 100644 src/models/technology.model.ts delete mode 100644 src/models/technology.ts diff --git a/src/app/services/comment.service.ts b/src/app/services/comment.service.ts index c9dbf35..29707ab 100644 --- a/src/app/services/comment.service.ts +++ b/src/app/services/comment.service.ts @@ -2,7 +2,7 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Guid } from 'guid-typescript'; import { Observable } from 'rxjs'; -import { Comment } from 'src/models/comment'; +import { Comment } from 'src/models/comment.model'; import { AppConstants } from '../app-constants.module'; import { TokenService } from './token.service'; diff --git a/src/app/services/language.service.ts b/src/app/services/language.service.ts index 15e241f..5846dd6 100644 --- a/src/app/services/language.service.ts +++ b/src/app/services/language.service.ts @@ -2,7 +2,7 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Guid } from 'guid-typescript'; import { Observable } from 'rxjs'; -import { Language } from 'src/models/language'; +import { Language } from 'src/models/language.model'; import { AppConstants } from '../app-constants.module'; import { TokenService } from './token.service'; diff --git a/src/app/services/post.service.ts b/src/app/services/post.service.ts index 7b2a539..eb613a6 100644 --- a/src/app/services/post.service.ts +++ b/src/app/services/post.service.ts @@ -3,7 +3,7 @@ import { Injectable } from '@angular/core'; import * as FormData from 'form-data'; import { Guid } from 'guid-typescript'; import { Observable } from 'rxjs'; -import { Post } from 'src/models/post'; +import { Post } from 'src/models/post.model'; import { AppConstants } from '../app-constants.module'; import { TokenService } from './token.service'; diff --git a/src/app/services/technology.service.ts b/src/app/services/technology.service.ts index dbdc039..fcc3d4c 100644 --- a/src/app/services/technology.service.ts +++ b/src/app/services/technology.service.ts @@ -2,7 +2,7 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Guid } from 'guid-typescript'; import { Observable } from 'rxjs'; -import { Technology } from 'src/models/technology'; +import { Technology } from 'src/models/technology.model'; import { AppConstants } from '../app-constants.module'; import { TokenService } from './token.service'; diff --git a/src/app/services/user.service.ts b/src/app/services/user.service.ts index 31862c4..f22952e 100644 --- a/src/app/services/user.service.ts +++ b/src/app/services/user.service.ts @@ -1,12 +1,12 @@ import { Injectable } from '@angular/core'; import { Guid } from 'guid-typescript'; -import { User } from '../../models/identity/user'; +import { User } from '../../models/identity/user.model'; import { FormGroup } from '@angular/forms'; import { AppConstants } from 'src/app/app-constants.module'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { Observable } from 'rxjs'; -import { Role } from 'src/models/identity/role'; -import { Friend } from 'src/models/identity/friend'; +import { Role } from 'src/models/identity/role.model'; +import { Friend } from 'src/models/identity/friend.model'; import { TokenService } from './token.service'; @Injectable({ diff --git a/src/models/comment.model.ts b/src/models/comment.model.ts new file mode 100644 index 0000000..0d1755f --- /dev/null +++ b/src/models/comment.model.ts @@ -0,0 +1,70 @@ +import { Guid } from 'guid-typescript'; + +export class Comment { + private _commentId: Guid; + private _postId: Guid; + private _issuerFirstName: string; + private _issuerLastName: string; + private _issuerUsername: string; + private _message: string; + private _timeCreated: Date; + + constructor(commentId: Guid, postId: Guid, issuerFirstName: string, issuerLastName: string, issuerUsername: string, message: string, timeCreated: Date) { + this.commentId = commentId; + this.postId = postId; + this.issuerFirstName = issuerFirstName; + this.issuerLastName = issuerLastName; + this.issuerUsername = issuerUsername; + this.message = message; + this.timeCreated = timeCreated; + } + + public get commentId(): Guid { + return this._commentId; + } + public set commentId(v: Guid) { + this._commentId = v; + } + + public get postId(): Guid { + return this._postId; + } + public set postId(v: Guid) { + this._postId = v; + } + + public get issuerFirstName(): string { + return this._issuerFirstName; + } + public set issuerFirstName(v: string) { + this._issuerFirstName = v; + } + + public get issuerLastName(): string { + return this._issuerLastName; + } + public set issuerLastName(v: string) { + this._issuerLastName = v; + } + + public get issuerUsername(): string { + return this._issuerUsername; + } + public set issuerUsername(v: string) { + this._issuerUsername = v; + } + + public get message(): string { + return this._message; + } + public set message(v: string) { + this._message = v; + } + + public get timeCreated(): Date { + return this._timeCreated; + } + public set timeCreated(v: Date) { + this._timeCreated = v; + } +} diff --git a/src/models/comment.ts b/src/models/comment.ts deleted file mode 100644 index 0d1755f..0000000 --- a/src/models/comment.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { Guid } from 'guid-typescript'; - -export class Comment { - private _commentId: Guid; - private _postId: Guid; - private _issuerFirstName: string; - private _issuerLastName: string; - private _issuerUsername: string; - private _message: string; - private _timeCreated: Date; - - constructor(commentId: Guid, postId: Guid, issuerFirstName: string, issuerLastName: string, issuerUsername: string, message: string, timeCreated: Date) { - this.commentId = commentId; - this.postId = postId; - this.issuerFirstName = issuerFirstName; - this.issuerLastName = issuerLastName; - this.issuerUsername = issuerUsername; - this.message = message; - this.timeCreated = timeCreated; - } - - public get commentId(): Guid { - return this._commentId; - } - public set commentId(v: Guid) { - this._commentId = v; - } - - public get postId(): Guid { - return this._postId; - } - public set postId(v: Guid) { - this._postId = v; - } - - public get issuerFirstName(): string { - return this._issuerFirstName; - } - public set issuerFirstName(v: string) { - this._issuerFirstName = v; - } - - public get issuerLastName(): string { - return this._issuerLastName; - } - public set issuerLastName(v: string) { - this._issuerLastName = v; - } - - public get issuerUsername(): string { - return this._issuerUsername; - } - public set issuerUsername(v: string) { - this._issuerUsername = v; - } - - public get message(): string { - return this._message; - } - public set message(v: string) { - this._message = v; - } - - public get timeCreated(): Date { - return this._timeCreated; - } - public set timeCreated(v: Date) { - this._timeCreated = v; - } -} diff --git a/src/models/identity/friend.model.ts b/src/models/identity/friend.model.ts new file mode 100644 index 0000000..22290cd --- /dev/null +++ b/src/models/identity/friend.model.ts @@ -0,0 +1,3 @@ +export class Friend { + public userName: string; +} diff --git a/src/models/identity/friend.ts b/src/models/identity/friend.ts deleted file mode 100644 index 22290cd..0000000 --- a/src/models/identity/friend.ts +++ /dev/null @@ -1,3 +0,0 @@ -export class Friend { - public userName: string; -} diff --git a/src/models/identity/role.model.ts b/src/models/identity/role.model.ts new file mode 100644 index 0000000..132b0b0 --- /dev/null +++ b/src/models/identity/role.model.ts @@ -0,0 +1,3 @@ +export class Role { + public name: string; +} diff --git a/src/models/identity/role.ts b/src/models/identity/role.ts deleted file mode 100644 index 132b0b0..0000000 --- a/src/models/identity/role.ts +++ /dev/null @@ -1,3 +0,0 @@ -export class Role { - public name: string; -} diff --git a/src/models/identity/user.model.ts b/src/models/identity/user.model.ts new file mode 100644 index 0000000..e0038e0 --- /dev/null +++ b/src/models/identity/user.model.ts @@ -0,0 +1,100 @@ +import { Guid } from 'guid-typescript'; +import { Language } from '../language'; +import { Technology } from '../technology'; +import { Friend } from './friend'; +import { Role } from './role'; + +export class User { + private _id : Guid; + private _lastName : string; + private _firstName : string; + private _userName : string; + private _email: string; + private _profilePictureURL : string; + private _languages: Language[]; + private _technologies: Technology[]; + private _roles: Role[]; + private _friends: Friend[]; + + constructor(id: Guid, userName: string, firstName: string, lastName: string, email: string, profilePictureURL: string, languages: Language[], technologies: Technology[], roles: Role[], friends: Friend[]) { + this.id = id; + this.userName = userName; + this.firstName = firstName; + this.lastName = lastName; + this.email = email; + this._profilePictureURL = profilePictureURL; + this.languages = languages; + this.technologies = technologies; + this.roles = roles; + } + + public get id(): Guid { + return this._id; + } + public set id(v: Guid) { + this._id = v; + } + + public get userName(): string { + return this._userName; + } + public set userName(v: string) { + this._userName = v; + } + + public get firstName(): string { + return this._firstName; + } + public set firstName(v: string) { + this._firstName = v; + } + + public get lastName(): string { + return this._lastName; + } + public set lastName(v: string) { + this._lastName = v; + } + + public get email(): string { + return this._email; + } + public set email(v: string) { + this._email = v; + } + + public get profilePictureURL(): string { + return this._profilePictureURL; + } + public set profilePictureURL(v: string) { + this._profilePictureURL = v; + } + + public get languages(): Language[] { + return this._languages; + } + public set languages(v: Language[]) { + this._languages = v; + } + + public get technologies(): Technology[] { + return this._technologies; + } + public set technologies(v: Technology[]) { + this._technologies = v; + } + + public get roles(): Role[] { + return this._roles; + } + public set roles(v: Role[]) { + this._roles = v; + } + + public get friends(): Friend[] { + return this._friends; + } + public set friends(v: Friend[]) { + this._friends = v; + } +} diff --git a/src/models/identity/user.ts b/src/models/identity/user.ts deleted file mode 100644 index e0038e0..0000000 --- a/src/models/identity/user.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { Guid } from 'guid-typescript'; -import { Language } from '../language'; -import { Technology } from '../technology'; -import { Friend } from './friend'; -import { Role } from './role'; - -export class User { - private _id : Guid; - private _lastName : string; - private _firstName : string; - private _userName : string; - private _email: string; - private _profilePictureURL : string; - private _languages: Language[]; - private _technologies: Technology[]; - private _roles: Role[]; - private _friends: Friend[]; - - constructor(id: Guid, userName: string, firstName: string, lastName: string, email: string, profilePictureURL: string, languages: Language[], technologies: Technology[], roles: Role[], friends: Friend[]) { - this.id = id; - this.userName = userName; - this.firstName = firstName; - this.lastName = lastName; - this.email = email; - this._profilePictureURL = profilePictureURL; - this.languages = languages; - this.technologies = technologies; - this.roles = roles; - } - - public get id(): Guid { - return this._id; - } - public set id(v: Guid) { - this._id = v; - } - - public get userName(): string { - return this._userName; - } - public set userName(v: string) { - this._userName = v; - } - - public get firstName(): string { - return this._firstName; - } - public set firstName(v: string) { - this._firstName = v; - } - - public get lastName(): string { - return this._lastName; - } - public set lastName(v: string) { - this._lastName = v; - } - - public get email(): string { - return this._email; - } - public set email(v: string) { - this._email = v; - } - - public get profilePictureURL(): string { - return this._profilePictureURL; - } - public set profilePictureURL(v: string) { - this._profilePictureURL = v; - } - - public get languages(): Language[] { - return this._languages; - } - public set languages(v: Language[]) { - this._languages = v; - } - - public get technologies(): Technology[] { - return this._technologies; - } - public set technologies(v: Technology[]) { - this._technologies = v; - } - - public get roles(): Role[] { - return this._roles; - } - public set roles(v: Role[]) { - this._roles = v; - } - - public get friends(): Friend[] { - return this._friends; - } - public set friends(v: Friend[]) { - this._friends = v; - } -} diff --git a/src/models/language.model.ts b/src/models/language.model.ts new file mode 100644 index 0000000..e3aa61e --- /dev/null +++ b/src/models/language.model.ts @@ -0,0 +1,6 @@ +import { Guid } from 'guid-typescript'; + +export class Language { + public id: Guid; + public name: string; +} diff --git a/src/models/language.ts b/src/models/language.ts deleted file mode 100644 index e3aa61e..0000000 --- a/src/models/language.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Guid } from 'guid-typescript'; - -export class Language { - public id: Guid; - public name: string; -} diff --git a/src/models/post-comment.model.ts b/src/models/post-comment.model.ts new file mode 100644 index 0000000..5d1e346 --- /dev/null +++ b/src/models/post-comment.model.ts @@ -0,0 +1,5 @@ +import { Guid } from 'guid-typescript'; + +export class PostComment { + public id: Guid; +} diff --git a/src/models/post-comment.ts b/src/models/post-comment.ts deleted file mode 100644 index 5d1e346..0000000 --- a/src/models/post-comment.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Guid } from 'guid-typescript'; - -export class PostComment { - public id: Guid; -} diff --git a/src/models/post.model.ts b/src/models/post.model.ts new file mode 100644 index 0000000..8e58bea --- /dev/null +++ b/src/models/post.model.ts @@ -0,0 +1,81 @@ +import { Guid } from 'guid-typescript'; +import { Comment } from './comment'; +import { PostComment } from './post-comment'; + +export class Post { + private _postId: Guid; + private _creatorFirstName: string; + private _creatorLastName: string; + private _creatorUsername: string; + private _message: string; + private _timeCreated: Date; + private _comments: PostComment[]; + private _fileURLs: string[]; + + constructor(postId: Guid, creatorFirstName: string, creatorLastName: string, creatorUsername: string, message: string, timeCreated: Date, comments: PostComment[], fileURLs: string[]) { + this.postId = postId; + this.creatorFirstName = creatorFirstName; + this.creatorLastName = creatorLastName; + this.creatorUsername = creatorUsername; + this.message = message; + this.timeCreated = timeCreated; + this.comments = comments; + this.fileURLs = fileURLs; + } + + public get postId(): Guid { + return this._postId; + } + public set postId(v: Guid) { + this._postId = v; + } + + public get creatorFirstName(): string { + return this._creatorFirstName; + } + public set creatorFirstName(v: string) { + this._creatorFirstName = v; + } + + public get creatorLastName(): string { + return this._creatorLastName; + } + public set creatorLastName(v: string) { + this._creatorLastName = v; + } + + public get creatorUsername(): string { + return this._creatorUsername; + } + public set creatorUsername(v: string) { + this._creatorUsername = v; + } + + public get message(): string { + return this._message; + } + public set message(v: string) { + this._message = v; + } + + public get timeCreated(): Date { + return this._timeCreated; + } + public set timeCreated(v: Date) { + this._timeCreated = v; + } + + public get comments(): PostComment[] { + return this._comments; + } + public set comments(v: PostComment[]) { + this._comments = v; + } + + public get fileURLs(): string[] { + return this._fileURLs; + } + public set fileURLs(v: string[]) { + this._fileURLs = v; + } +} diff --git a/src/models/post.ts b/src/models/post.ts deleted file mode 100644 index 8e58bea..0000000 --- a/src/models/post.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { Guid } from 'guid-typescript'; -import { Comment } from './comment'; -import { PostComment } from './post-comment'; - -export class Post { - private _postId: Guid; - private _creatorFirstName: string; - private _creatorLastName: string; - private _creatorUsername: string; - private _message: string; - private _timeCreated: Date; - private _comments: PostComment[]; - private _fileURLs: string[]; - - constructor(postId: Guid, creatorFirstName: string, creatorLastName: string, creatorUsername: string, message: string, timeCreated: Date, comments: PostComment[], fileURLs: string[]) { - this.postId = postId; - this.creatorFirstName = creatorFirstName; - this.creatorLastName = creatorLastName; - this.creatorUsername = creatorUsername; - this.message = message; - this.timeCreated = timeCreated; - this.comments = comments; - this.fileURLs = fileURLs; - } - - public get postId(): Guid { - return this._postId; - } - public set postId(v: Guid) { - this._postId = v; - } - - public get creatorFirstName(): string { - return this._creatorFirstName; - } - public set creatorFirstName(v: string) { - this._creatorFirstName = v; - } - - public get creatorLastName(): string { - return this._creatorLastName; - } - public set creatorLastName(v: string) { - this._creatorLastName = v; - } - - public get creatorUsername(): string { - return this._creatorUsername; - } - public set creatorUsername(v: string) { - this._creatorUsername = v; - } - - public get message(): string { - return this._message; - } - public set message(v: string) { - this._message = v; - } - - public get timeCreated(): Date { - return this._timeCreated; - } - public set timeCreated(v: Date) { - this._timeCreated = v; - } - - public get comments(): PostComment[] { - return this._comments; - } - public set comments(v: PostComment[]) { - this._comments = v; - } - - public get fileURLs(): string[] { - return this._fileURLs; - } - public set fileURLs(v: string[]) { - this._fileURLs = v; - } -} diff --git a/src/models/technology.model.ts b/src/models/technology.model.ts new file mode 100644 index 0000000..1869d14 --- /dev/null +++ b/src/models/technology.model.ts @@ -0,0 +1,6 @@ +import { Guid } from 'guid-typescript'; + +export class Technology { + public id: Guid; + public name: string; +} diff --git a/src/models/technology.ts b/src/models/technology.ts deleted file mode 100644 index 1869d14..0000000 --- a/src/models/technology.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Guid } from 'guid-typescript'; - -export class Technology { - public id: Guid; - public name: string; -} -- cgit v1.2.3 From 8434044dcf8cec14765aa5d96072feaa2560a823 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 14 Mar 2021 09:06:08 +0200 Subject: Fixed includes (for models) of all components --- src/app/components/admin-panel-page/admin-panel-page.component.ts | 6 +++--- src/app/components/comment-page/comment-page.component.ts | 2 +- src/app/components/comment/comment.component.ts | 4 ++-- src/app/components/feed/feed.component.ts | 4 ++-- src/app/components/post-page/post-page.component.ts | 2 +- src/app/components/post/post.component.ts | 4 ++-- src/app/components/profile-settings/profile-settings.component.ts | 6 +++--- src/app/components/profile/profile.component.ts | 6 +++--- src/app/components/register/register.component.ts | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/app/components/admin-panel-page/admin-panel-page.component.ts b/src/app/components/admin-panel-page/admin-panel-page.component.ts index d5ecc71..9beb8bc 100644 --- a/src/app/components/admin-panel-page/admin-panel-page.component.ts +++ b/src/app/components/admin-panel-page/admin-panel-page.component.ts @@ -11,9 +11,9 @@ import { PostService } from 'src/app/services/post.service'; import { TechnologyService } from 'src/app/services/technology.service'; import { TokenService } from 'src/app/services/token.service'; import { UserService } from 'src/app/services/user.service'; -import { User } from 'src/models/identity/user'; -import { Language } from 'src/models/language'; -import { Technology } from 'src/models/technology'; +import { User } from 'src/models/identity/user.model'; +import { Language } from 'src/models/language.model'; +import { Technology } from 'src/models/technology.model'; import { ErrorBarComponent } from '../error-bar/error-bar.component'; import { SuccessBarComponent } from '../success-bar/success-bar.component'; diff --git a/src/app/components/comment-page/comment-page.component.ts b/src/app/components/comment-page/comment-page.component.ts index 9bbdc59..5d256bf 100644 --- a/src/app/components/comment-page/comment-page.component.ts +++ b/src/app/components/comment-page/comment-page.component.ts @@ -5,7 +5,7 @@ import { Router } from '@angular/router'; import { Guid } from 'guid-typescript'; import { CommentService } from 'src/app/services/comment.service'; import { TokenService } from 'src/app/services/token.service'; -import { Comment } from 'src/models/comment'; +import { Comment } from 'src/models/comment.model'; @Component({ selector: 'app-comment-page', diff --git a/src/app/components/comment/comment.component.ts b/src/app/components/comment/comment.component.ts index d4dd9f4..7da896d 100644 --- a/src/app/components/comment/comment.component.ts +++ b/src/app/components/comment/comment.component.ts @@ -3,8 +3,8 @@ import { Router } from '@angular/router'; import { Guid } from 'guid-typescript'; import { CommentService } from 'src/app/services/comment.service'; import { UserService } from 'src/app/services/user.service'; -import { Comment } from 'src/models/comment'; -import { User } from 'src/models/identity/user'; +import { Comment } from 'src/models/comment.model'; +import { User } from 'src/models/identity/user.model'; @Component({ selector: 'app-comment', diff --git a/src/app/components/feed/feed.component.ts b/src/app/components/feed/feed.component.ts index a9a042c..895bf76 100644 --- a/src/app/components/feed/feed.component.ts +++ b/src/app/components/feed/feed.component.ts @@ -1,11 +1,11 @@ import { Component, OnInit } from '@angular/core'; import { Title } from '@angular/platform-browser'; import { Router } from '@angular/router'; -import { User } from 'src/models/identity/user'; +import { User } from 'src/models/identity/user.model'; import { UserService } from '../../services/user.service'; import { AppConstants } from 'src/app/app-constants.module'; import { FeedService } from 'src/app/services/feed.service'; -import { Post } from 'src/models/post'; +import { Post } from 'src/models/post.model'; import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; import { PostService } from 'src/app/services/post.service'; import { TokenService } from 'src/app/services/token.service'; diff --git a/src/app/components/post-page/post-page.component.ts b/src/app/components/post-page/post-page.component.ts index 7c32ce0..a60f4da 100644 --- a/src/app/components/post-page/post-page.component.ts +++ b/src/app/components/post-page/post-page.component.ts @@ -6,7 +6,7 @@ import { Guid } from 'guid-typescript'; import { CommentService } from 'src/app/services/comment.service'; import { PostService } from 'src/app/services/post.service'; import { TokenService } from 'src/app/services/token.service'; -import { Post } from 'src/models/post'; +import { Post } from 'src/models/post.model'; import { CloudinaryService } from 'src/app/services/cloudinary.service'; @Component({ diff --git a/src/app/components/post/post.component.ts b/src/app/components/post/post.component.ts index a46811d..fa5ac2f 100644 --- a/src/app/components/post/post.component.ts +++ b/src/app/components/post/post.component.ts @@ -3,8 +3,8 @@ import { Router } from '@angular/router'; import { Guid } from 'guid-typescript'; import { PostService } from 'src/app/services/post.service'; import { UserService } from 'src/app/services/user.service'; -import { User } from 'src/models/identity/user'; -import { Post } from 'src/models/post'; +import { User } from 'src/models/identity/user.model'; +import { Post } from 'src/models/post.model'; @Component({ selector: 'app-post', diff --git a/src/app/components/profile-settings/profile-settings.component.ts b/src/app/components/profile-settings/profile-settings.component.ts index ba1fbb6..b856bef 100644 --- a/src/app/components/profile-settings/profile-settings.component.ts +++ b/src/app/components/profile-settings/profile-settings.component.ts @@ -6,11 +6,11 @@ import { Router } from '@angular/router'; import { LanguageService } from 'src/app/services/language.service'; import { UserService } from 'src/app/services/user.service'; import { TechnologyService } from 'src/app/services/technology.service'; -import { User } from 'src/models/identity/user'; +import { User } from 'src/models/identity/user.model'; import { ErrorBarComponent } from '../error-bar/error-bar.component'; import { SuccessBarComponent } from '../success-bar/success-bar.component'; -import { Language } from 'src/models/language'; -import { Technology } from 'src/models/technology'; +import { Language } from 'src/models/language.model'; +import { Technology } from 'src/models/technology.model'; import { TokenService } from 'src/app/services/token.service'; import { Title } from '@angular/platform-browser'; import { AppConstants } from 'src/app/app-constants.module'; diff --git a/src/app/components/profile/profile.component.ts b/src/app/components/profile/profile.component.ts index 73e1e96..ed17f33 100644 --- a/src/app/components/profile/profile.component.ts +++ b/src/app/components/profile/profile.component.ts @@ -1,16 +1,16 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { UserService } from 'src/app/services/user.service'; -import { User } from 'src/models/identity/user'; +import { User } from 'src/models/identity/user.model'; import { AppConstants } from 'src/app/app-constants.module'; import { Location } from '@angular/common'; import { LanguageService } from 'src/app/services/language.service'; import { TechnologyService } from 'src/app/services/technology.service'; -import { Post } from 'src/models/post'; +import { Post } from 'src/models/post.model'; import { FeedService } from 'src/app/services/feed.service'; import { TokenService } from 'src/app/services/token.service'; import { Title } from '@angular/platform-browser'; -import { Friend } from 'src/models/identity/friend'; +import { Friend } from 'src/models/identity/friend.model'; import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; @Component({ diff --git a/src/app/components/register/register.component.ts b/src/app/components/register/register.component.ts index b5800ad..07b8976 100644 --- a/src/app/components/register/register.component.ts +++ b/src/app/components/register/register.component.ts @@ -1,6 +1,6 @@ import { HttpErrorResponse } from '@angular/common/http'; import { Component, OnInit, ViewChild } from '@angular/core'; -import { AbstractControl, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { Title } from '@angular/platform-browser'; import { Router } from '@angular/router'; import { TokenService } from 'src/app/services/token.service'; -- cgit v1.2.3 From e3a8875e64c25a6e46380c4d003beac5953fd3e9 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 14 Mar 2021 09:07:01 +0200 Subject: Fixed model imports of post and user models --- src/models/identity/user.model.ts | 8 ++++---- src/models/post.model.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/models/identity/user.model.ts b/src/models/identity/user.model.ts index e0038e0..e2f54a4 100644 --- a/src/models/identity/user.model.ts +++ b/src/models/identity/user.model.ts @@ -1,8 +1,8 @@ import { Guid } from 'guid-typescript'; -import { Language } from '../language'; -import { Technology } from '../technology'; -import { Friend } from './friend'; -import { Role } from './role'; +import { Language } from '../language.model'; +import { Technology } from '../technology.model'; +import { Friend } from './friend.model'; +import { Role } from './role.model'; export class User { private _id : Guid; diff --git a/src/models/post.model.ts b/src/models/post.model.ts index 8e58bea..e0fcd5b 100644 --- a/src/models/post.model.ts +++ b/src/models/post.model.ts @@ -1,6 +1,6 @@ import { Guid } from 'guid-typescript'; -import { Comment } from './comment'; -import { PostComment } from './post-comment'; +import { Comment } from './comment.model'; +import { PostComment } from './post-comment.model'; export class Post { private _postId: Guid; -- cgit v1.2.3