From a7bf5cad6bf66f2cd7e12fc436410fafb7826b10 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 25 Feb 2021 14:31:25 +0200 Subject: Fixed unecessary max-width of 98% on submit buttons in post and comment pages --- src/app/components/comment-page/comment-page.component.css | 1 - 1 file changed, 1 deletion(-) (limited to 'src/app/components/comment-page/comment-page.component.css') diff --git a/src/app/components/comment-page/comment-page.component.css b/src/app/components/comment-page/comment-page.component.css index b886bc1..f9dc390 100644 --- a/src/app/components/comment-page/comment-page.component.css +++ b/src/app/components/comment-page/comment-page.component.css @@ -21,7 +21,6 @@ } .submit-btn { - max-width: 98%; margin: 0 auto; margin-bottom: .5em; } -- cgit v1.2.3 From 578e3408089747fa1cedf59409baf96f27053d21 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 21 Mar 2021 18:13:41 +0200 Subject: Removed comment page component --- src/app/app-routing.module.ts | 2 - src/app/app.module.ts | 2 - .../comment-page/comment-page.component.css | 26 ------ .../comment-page/comment-page.component.html | 18 ----- .../comment-page/comment-page.component.ts | 92 ---------------------- src/app/components/comment/comment.component.ts | 4 - 6 files changed, 144 deletions(-) delete mode 100644 src/app/components/comment-page/comment-page.component.css delete mode 100644 src/app/components/comment-page/comment-page.component.html delete mode 100644 src/app/components/comment-page/comment-page.component.ts (limited to 'src/app/components/comment-page/comment-page.component.css') diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 0d83079..4367db7 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -8,7 +8,6 @@ import { ProfileSettingsComponent } from './components/profile-settings/profile- import { NotFoundComponent } from './components/not-found/not-found.component'; import { PostPageComponent } from './components/post-page/post-page.component'; import {AdminPanelPageComponent} from './components/admin-panel-page/admin-panel-page.component'; -import {CommentPageComponent} from './components/comment-page/comment-page.component'; const routes: Routes = [ { path: '', component: FeedComponent }, @@ -17,7 +16,6 @@ const routes: Routes = [ { path: 'profile/:username', component: ProfileComponent }, { path: 'profile/:username/settings', component: ProfileSettingsComponent }, { path: 'post/:id', component: PostPageComponent }, - { path: 'comment/:id', component: CommentPageComponent }, { path: 'admin-panel', component: AdminPanelPageComponent }, { path: 'not-found', component: NotFoundComponent }, { path: '**', component: NotFoundComponent } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index f582bbc..cd796c2 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -22,7 +22,6 @@ import { SuccessBarComponent } from './components/success-bar/success-bar.compon import { PostPageComponent } from './components/post-page/post-page.component'; import { AdminPanelPageComponent } from './components/admin-panel-page/admin-panel-page.component'; import { CommentComponent } from './components/comment/comment.component'; -import { CommentPageComponent } from './components/comment-page/comment-page.component'; import { PostAttachmentComponent } from './components/post-attachment/post-attachment.component'; import { RouterModule } from '@angular/router'; import { NavbarComponent } from './components/navbar/navbar.component'; @@ -43,7 +42,6 @@ import { NavbarComponent } from './components/navbar/navbar.component'; PostPageComponent, AdminPanelPageComponent, CommentComponent, - CommentPageComponent, PostAttachmentComponent, NavbarComponent, ], diff --git a/src/app/components/comment-page/comment-page.component.css b/src/app/components/comment-page/comment-page.component.css deleted file mode 100644 index f9dc390..0000000 --- a/src/app/components/comment-page/comment-page.component.css +++ /dev/null @@ -1,26 +0,0 @@ -#content { - justify-content: flex-start !important; -} - -#content > * { - width: 100%; -} - -.many-buttons { - width: 100%; - display: flex; -} - -.many-buttons > * { - flex: 1; - margin-right: .3em; -} - -.many-buttons > *:last-of-type { - margin-right: 0; -} - -.submit-btn { - margin: 0 auto; - margin-bottom: .5em; -} diff --git a/src/app/components/comment-page/comment-page.component.html b/src/app/components/comment-page/comment-page.component.html deleted file mode 100644 index 553b545..0000000 --- a/src/app/components/comment-page/comment-page.component.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - -
- - - -
- - -
-
diff --git a/src/app/components/comment-page/comment-page.component.ts b/src/app/components/comment-page/comment-page.component.ts deleted file mode 100644 index 5d256bf..0000000 --- a/src/app/components/comment-page/comment-page.component.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; -import { Title } from '@angular/platform-browser'; -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.model'; - -@Component({ - selector: 'app-comment-page', - templateUrl: './comment-page.component.html', - styleUrls: ['./comment-page.component.css'] -}) -export class CommentPageComponent implements OnInit { - private _title = 'Comment'; - public loaded = false; - public loggedIn = false; - public editable = false; - public editingComment = false; - public commentId: Guid; - public comment: Comment; - public editCommentFormGroup: FormGroup; - - constructor(private _titleService: Title, private _router: Router, private _fb: FormBuilder, private _tokenService: TokenService, private _commentService: CommentService){ - this._titleService.setTitle(this._title); - } - - ngOnInit(): void { - this.loggedIn = this._tokenService.getTokenFromSessionStorage() !== ''; - this.commentId = Guid.parse(this._router.url.substring(9)); - - // 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({ - next: (result: object) => { - this.comment = result as Comment; - if (this.loggedIn) { - this.editable = this.comment.issuerUsername === this._tokenService.getUsernameFromSessionStorageToken(); - this.editCommentFormGroup.get('newCommentMessage')?.setValue(this.comment.message); - } - this.loaded = true; - }, - error: () => { - this._router.navigate(['/not-found']); - } - }); - - this.editCommentFormGroup = this._fb.group({ - newCommentMessage: new FormControl('') - }); - } - - toPost(): void { - this._router.navigate(['/post/' + this.comment.postId]); - } - - editComment(): void { - if (this._tokenService.getTokenFromSessionStorage() === '') { - this._router.navigate(['/login']); - return; - } - - if (this.editingComment) { - const newMessage = this.editCommentFormGroup.get('newCommentMessage')?.value; - - if (newMessage !== '' && newMessage !== this.comment.message) { - console.log(this.commentId); - 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({ - next: () => { - this.toPost(); - } - }); - } - - private reloadPage(): void { - this._router.routeReuseStrategy.shouldReuseRoute = () => false; - this._router.onSameUrlNavigation = 'reload'; - this._router.navigate([this._router.url]); - } -} diff --git a/src/app/components/comment/comment.component.ts b/src/app/components/comment/comment.component.ts index 7da896d..693fd43 100644 --- a/src/app/components/comment/comment.component.ts +++ b/src/app/components/comment/comment.component.ts @@ -47,8 +47,4 @@ export class CommentComponent implements OnInit { goToAuthorProfile(): void { this._router.navigate(['/profile/' + this.comment.issuerUsername]); } - - goToCommentPage(): void { - this._router.navigate(['/comment/' + this.comment.commentId]); - } } -- cgit v1.2.3 From 72a890d1b58fb27529d9dcd6ccd0951725fedebb Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 28 Mar 2021 15:00:19 +0300 Subject: Reimplemented comment page component --- src/app/app-routing.module.ts | 4 ++- src/app/app.module.ts | 2 ++ .../comment-page/comment-page.component.css | 0 .../comment-page/comment-page.component.html | 18 ++++++++++ .../comment-page/comment-page.component.ts | 41 ++++++++++++++++++++++ 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/app/components/comment-page/comment-page.component.css create mode 100644 src/app/components/comment-page/comment-page.component.html create mode 100644 src/app/components/comment-page/comment-page.component.ts (limited to 'src/app/components/comment-page/comment-page.component.css') diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 4367db7..b319abd 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -7,7 +7,8 @@ import { ProfileComponent } from './components/profile/profile.component'; import { ProfileSettingsComponent } from './components/profile-settings/profile-settings.component'; import { NotFoundComponent } from './components/not-found/not-found.component'; import { PostPageComponent } from './components/post-page/post-page.component'; -import {AdminPanelPageComponent} from './components/admin-panel-page/admin-panel-page.component'; +import { AdminPanelPageComponent } from './components/admin-panel-page/admin-panel-page.component'; +import { CommentPageComponent } from './components/comment-page/comment-page.component'; const routes: Routes = [ { path: '', component: FeedComponent }, @@ -16,6 +17,7 @@ const routes: Routes = [ { path: 'profile/:username', component: ProfileComponent }, { path: 'profile/:username/settings', component: ProfileSettingsComponent }, { path: 'post/:id', component: PostPageComponent }, + { path: 'comment/:id', component: CommentPageComponent }, { path: 'admin-panel', component: AdminPanelPageComponent }, { path: 'not-found', component: NotFoundComponent }, { path: '**', component: NotFoundComponent } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 47651d4..c68f919 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -26,6 +26,7 @@ import { CommentComponent } from './components/comment/comment.component'; import { PostAttachmentComponent } from './components/post-attachment/post-attachment.component'; import { RouterModule } from '@angular/router'; import { NavbarComponent } from './components/navbar/navbar.component'; +import { CommentPageComponent } from './components/comment-page/comment-page.component'; @NgModule({ declarations: [ @@ -45,6 +46,7 @@ import { NavbarComponent } from './components/navbar/navbar.component'; CommentComponent, PostAttachmentComponent, NavbarComponent, + CommentPageComponent, ], imports: [ BrowserModule.withServerTransition({ appId: 'serverApp' }), diff --git a/src/app/components/comment-page/comment-page.component.css b/src/app/components/comment-page/comment-page.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/components/comment-page/comment-page.component.html b/src/app/components/comment-page/comment-page.component.html new file mode 100644 index 0000000..8a2ffe1 --- /dev/null +++ b/src/app/components/comment-page/comment-page.component.html @@ -0,0 +1,18 @@ + + + + +
+ +
+
+ +
+
+ ... +
+ + +
diff --git a/src/app/components/comment-page/comment-page.component.ts b/src/app/components/comment-page/comment-page.component.ts new file mode 100644 index 0000000..4281e1c --- /dev/null +++ b/src/app/components/comment-page/comment-page.component.ts @@ -0,0 +1,41 @@ +import { Component, OnInit } from '@angular/core'; +import { Title } from '@angular/platform-browser'; +import { Router } from '@angular/router'; +import { Guid } from 'guid-typescript'; +import { CommentService } from 'src/app/services/comment.service'; + +@Component({ + selector: 'app-comment-page', + templateUrl: './comment-page.component.html', + styleUrls: ['./comment-page.component.css'] +}) +export class CommentPageComponent implements OnInit { + private _title = 'Comment'; + public dataArrived = false; + public postId: Guid; + public commentId: Guid; + + constructor(private _titleService: Title, private _router: Router, private _commentService: CommentService) { + this._titleService.setTitle(this._title); + } + + ngOnInit(): void { + this.commentId = Guid.parse(this._router.url.substring(9)); + this.postId = Guid.createEmpty(); + + this._commentService.getCommentRequest(this.commentId).subscribe({ + next: (result: object) => { + this.postId = Object.values(result)[1]; + + this.dataArrived = true; + }, + error: () => { + this._router.navigate(['/not-found']); + } + }); + } + + goToPostPage(): void { + this._router.navigate(['/post/' + this.postId]); + } +} -- cgit v1.2.3