diff --git a/src/app/profile/user/details/details.component.html b/src/app/profile/user/details/details.component.html index d5a0d93..c86833d 100644 --- a/src/app/profile/user/details/details.component.html +++ b/src/app/profile/user/details/details.component.html @@ -7,13 +7,24 @@
- +
-

+

@{{ user.username }}

- + - + - add_circle
@@ -41,14 +60,22 @@

edit - + cancel - + save @@ -62,17 +89,34 @@

Location
-
+
{{ user.location }}
- - + +
Birthday
-
+
{{ user.date_of_birth }}
- + - +
About me
-
+
{{ user.bio }}
- - + +
@@ -102,9 +160,16 @@

+ - + {{ tech }} cancel @@ -124,7 +189,10 @@

PROJECTS

- See all projects
@@ -132,21 +200,39 @@

PROJECTS

Nothing to show

-
+
- No projects to show + + No projects to show +
{{ project.project_name }} | {{ project.current_stage }}
-
{{ project.description }}
- + {{ project.description }} +
+ open_in_new

@@ -157,14 +243,25 @@

PROJECTS

Nothing to show

-
+
No Ideas to show
@@ -172,13 +269,27 @@

IDEAS

- {{ idea.idea_name }} + + {{ idea.idea_name }}
-
{{ idea.description }}
+
+ {{ idea.description }} +
diff --git a/src/app/profile/user/details/details.component.scss b/src/app/profile/user/details/details.component.scss index 32bb7d8..1139a6b 100644 --- a/src/app/profile/user/details/details.component.scss +++ b/src/app/profile/user/details/details.component.scss @@ -28,7 +28,11 @@ .profile-header { height: 35vh; - background-image: linear-gradient(135deg, rgb(102, 126, 234) 0%, rgb(118, 75, 162) 100%); + background-image: linear-gradient( + 135deg, + rgb(102, 126, 234) 0%, + rgb(118, 75, 162) 100% + ); display: flex; flex-direction: column; justify-content: flex-end; @@ -42,10 +46,14 @@ justify-content: center; @media (max-width: 37.5em) { - height:35vh; - background-image: linear-gradient(135deg, rgb(102, 126, 234) 0%, rgb(118, 75, 162) 100%); + height: 35vh; + background-image: linear-gradient( + 135deg, + rgb(102, 126, 234) 0%, + rgb(118, 75, 162) 100% + ); background-repeat: no-repeat; - background-size: 100% 65%; + background-size: 100% 65%; } .container { @@ -99,7 +107,6 @@ @media (max-width: 37.5em) { margin-bottom: 0; } - } &__username { @@ -109,18 +116,16 @@ @media (max-width: 37.5em) { padding-top: 2rem; } - } &__name { font-size: 3rem; font-weight: 700; - padding-top: .5rem; + padding-top: 0.5rem; @media (max-width: 37.5em) { padding-top: 1rem; } - } } diff --git a/src/app/profile/user/details/details.component.ts b/src/app/profile/user/details/details.component.ts index 25d4c91..d18dd8e 100644 --- a/src/app/profile/user/details/details.component.ts +++ b/src/app/profile/user/details/details.component.ts @@ -4,12 +4,17 @@ import { Router, ActivatedRoute } from '@angular/router'; import { finalize } from 'rxjs/internal/operators/finalize'; import { Component, OnInit, ViewEncapsulation, Inject } from '@angular/core'; import { User } from '@app/core/profile/user'; -import { MatChipInputEvent, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; +import { + MatChipInputEvent, + MatDialogRef, + MAT_DIALOG_DATA +} from '@angular/material'; import { COMMA, ENTER } from '@angular/cdk/keycodes'; import { FormGroup, FormControl } from '@angular/forms'; import { ErrorHandlerService } from '@app/core/error-handler.service'; import { MatDialog } from '@angular/material'; import { IdeaCardComponent } from '@app/shared/idea-card/idea-card.component'; +import { ConfirmComponent } from '@app/shared/confirm/confirm.component'; class ImageSnippet { constructor(public src: string, public file: File) {} @@ -29,15 +34,15 @@ export class DetailsComponent implements OnInit { userProjects: Array; userIdeas: Array; user: User = new User(); - isPageLoaded = false; username: string; sociallinks: any = []; isFieldEditable = false; socialLinks: any; - isSameUser = localStorage.getItem('username') === this.router.url.split('/')[2]; + isSameUser = + localStorage.getItem('username') === this.router.url.split('/')[2]; + isPageLoaded = false; editForm: FormGroup; - visible = true; selectable = true; removable = true; @@ -100,6 +105,17 @@ export class DetailsComponent implements OnInit { dialogRef.afterClosed().subscribe(result => {}); } + openConfirmDialog(idea: any): void { + const dialogRef = this.dialog.open(ConfirmComponent, { + width: 'auto', + data: { idea } + }); + + dialogRef.afterClosed().subscribe(data => { + if (data == true) this.deleteIdea(idea.id); + }); + } + openSocialDialog(): void { const dialogRef = this.dialog.open(SocialDialogComponent, { width: 'auto', @@ -112,18 +128,20 @@ export class DetailsComponent implements OnInit { fetchContributions(context: string) { this.username = this.router.url.split('/')[2]; - this.profileService.getUserDetailedContributions(this.username, context).subscribe( - (res: any) => { - if (context === 'projects' || context === 'project') { - this.userProjects = res.user[0].projectsByowner; - } else { - this.userIdeas = res.user[0].ideasByOwner; + this.profileService + .getUserDetailedContributions(this.username, context) + .subscribe( + (res: any) => { + if (context === 'projects' || context === 'project') { + this.userProjects = res.user[0].projectsByowner; + } else { + this.userIdeas = res.user[0].ideasByOwner; + } + }, + (err: any) => { + this.errorHandler.subj_notification.next(err); } - }, - (err: any) => { - this.errorHandler.subj_notification.next(err); - } - ); + ); } toggleFormFields(toggle: boolean) { @@ -136,7 +154,8 @@ export class DetailsComponent implements OnInit { } else { this.profileService.uploadImage(this.selectedFile.file).subscribe( (res: any) => { - const profileUrl = 'v' + res.version + '/' + res.public_id + '.' + res.format; + const profileUrl = + 'v' + res.version + '/' + res.public_id + '.' + res.format; this.updateUserData(profileUrl); }, (err: any) => { @@ -160,7 +179,10 @@ export class DetailsComponent implements OnInit { console.log(userUpdateObject); const trimmedUserChangeObject = {}; Object.keys(userUpdateObject).forEach(key => { - if (userUpdateObject[key] || (key === 'technologies' && userUpdateObject[key].length === 0)) { + if ( + userUpdateObject[key] || + (key === 'technologies' && userUpdateObject[key].length === 0) + ) { trimmedUserChangeObject[key] = userUpdateObject[key]; } }); @@ -169,8 +191,14 @@ export class DetailsComponent implements OnInit { .pipe(finalize(() => {})) .subscribe( (data: any) => { - if (data.data.update_user.returning[0].username !== localStorage.getItem('username')) { - localStorage.setItem('username', data.data.update_user.returning[0].username); + if ( + data.data.update_user.returning[0].username !== + localStorage.getItem('username') + ) { + localStorage.setItem( + 'username', + data.data.update_user.returning[0].username + ); const newUsername = '/user/' + localStorage.getItem('username'); this.router.navigate([newUsername]); } @@ -241,7 +269,10 @@ export class DetailsComponent implements OnInit { export class SocialDialogComponent { socialLinks: FormGroup; - constructor(public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any) {} + constructor( + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) {} onNoClick(): void { this.dialogRef.close(); diff --git a/src/app/profile/user/user.module.ts b/src/app/profile/user/user.module.ts index f66c5f5..2e3fd75 100644 --- a/src/app/profile/user/user.module.ts +++ b/src/app/profile/user/user.module.ts @@ -2,12 +2,19 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { UserRoutingModule } from './user-routing.module'; -import { DetailsComponent, SocialDialogComponent } from './details/details.component'; +import { + DetailsComponent, + SocialDialogComponent +} from './details/details.component'; import { SharedModule } from '@app/shared'; import { MaterialModule } from '@app/material.module'; import { Cloudinary as CloudinaryCore } from 'cloudinary-core'; -import { CloudinaryConfiguration, CloudinaryModule } from '@cloudinary/angular-5.x'; +import { + CloudinaryConfiguration, + CloudinaryModule +} from '@cloudinary/angular-5.x'; import { IdeaCardComponent } from '@app/shared/idea-card/idea-card.component'; +import { ConfirmComponent } from '@app/shared/confirm/confirm.component'; export const cloudinary = { Cloudinary: CloudinaryCore @@ -27,6 +34,6 @@ export const config: CloudinaryConfiguration = { CloudinaryModule.forRoot(cloudinary, config) ], declarations: [DetailsComponent, SocialDialogComponent], - entryComponents: [IdeaCardComponent, SocialDialogComponent] + entryComponents: [IdeaCardComponent, SocialDialogComponent, ConfirmComponent] }) export class UserModule {} diff --git a/src/app/shared/confirm/confirm.component.html b/src/app/shared/confirm/confirm.component.html new file mode 100644 index 0000000..429a3be --- /dev/null +++ b/src/app/shared/confirm/confirm.component.html @@ -0,0 +1,9 @@ +
+

+ Are you sure you want to delete? +

+
+ + +
+
diff --git a/src/app/shared/confirm/confirm.component.scss b/src/app/shared/confirm/confirm.component.scss new file mode 100644 index 0000000..b66da72 --- /dev/null +++ b/src/app/shared/confirm/confirm.component.scss @@ -0,0 +1,44 @@ +@import "../../../sass/declarations"; + +:host { + width: 100%; + overflow: hidden; +} + +.background { + min-height: 30vh; + background-color: darken($color-white, 10%); + position: relative; + display: flex; + justify-content: center; + align-items: center; +} +.btn { + width: fit-content; + font-size: 1.6rem; + margin-top: 2rem; + margin-right: 2rem; + padding-left: 1rem; + padding-right: 1 rem; +} + +.container { + box-shadow: $shadow-light; + + overflow: hidden; + + &--confirm { + width: 40rem; + background-color: white; + min-height: 10rem; + padding: 3rem; + font-size: 1.6rem; + border-radius: $radius-small; + display: flex; + align-items: stretch; + + @media (max-width: $bp-6) { + flex-direction: column; + } + } +} diff --git a/src/app/shared/confirm/confirm.component.spec.ts b/src/app/shared/confirm/confirm.component.spec.ts new file mode 100644 index 0000000..a89f214 --- /dev/null +++ b/src/app/shared/confirm/confirm.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ConfirmComponent } from './confirm.component'; + +describe('ConfirmComponent', () => { + let component: ConfirmComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ConfirmComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ConfirmComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/shared/confirm/confirm.component.ts b/src/app/shared/confirm/confirm.component.ts new file mode 100644 index 0000000..540f2a7 --- /dev/null +++ b/src/app/shared/confirm/confirm.component.ts @@ -0,0 +1,18 @@ +import { Component, Inject } from '@angular/core'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; + +@Component({ + selector: 'app-confirm', + templateUrl: './confirm.component.html', + styleUrls: ['./confirm.component.scss'] +}) +export class ConfirmComponent { + constructor( + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) {} + + onNoClick(): void { + this.dialogRef.close(); + } +} diff --git a/src/app/shared/idea-card/idea-card.component.ts b/src/app/shared/idea-card/idea-card.component.ts index 9f80db6..26131d7 100644 --- a/src/app/shared/idea-card/idea-card.component.ts +++ b/src/app/shared/idea-card/idea-card.component.ts @@ -7,7 +7,10 @@ import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; styleUrls: ['./idea-card.component.scss'] }) export class IdeaCardComponent { - constructor(public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any) {} + constructor( + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) {} onNoClick(): void { this.dialogRef.close(); diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 07f4f2c..60b5037 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -16,8 +16,16 @@ import { CovalentTextEditorModule } from '@covalent/text-editor'; import { CovalentMarkdownModule } from '@covalent/markdown'; import { RouterModule } from '@angular/router'; import { Cloudinary as CloudinaryCore } from 'cloudinary-core'; -import { CloudinaryConfiguration, CloudinaryModule } from '@cloudinary/angular-5.x'; +import { + CloudinaryConfiguration, + CloudinaryModule +} from '@cloudinary/angular-5.x'; import { IdeaCardComponent } from './idea-card/idea-card.component'; +import { ConfirmComponent } from './confirm/confirm.component'; +import { ProfileRoutingModule } from '@app/profile/profile-routing.module'; +import { ProfileService } from '@app/core/profile/profile.service'; +import { UserRoutingModule } from '@app/profile/user/user-routing.module'; +import { CoreModule } from '@app/core'; export const cloudinary = { Cloudinary: CloudinaryCore @@ -46,8 +54,14 @@ export const config: CloudinaryConfiguration = { EditableDirective, EditableCommentComponent, TimeDiffPipe, - IdeaCardComponent + IdeaCardComponent, + ConfirmComponent ], - exports: [LoaderComponent, LikingComponent, CommentsComponent] + exports: [ + LoaderComponent, + LikingComponent, + CommentsComponent, + ConfirmComponent + ] }) export class SharedModule {}