Skip to content

Commit

Permalink
Settings page
Browse files Browse the repository at this point in the history
Create settings page where users can change their email and password.
Throw error if something fails. Fix csv issues
  • Loading branch information
iliasmentz committed Sep 29, 2018
1 parent eb68334 commit 48a261b
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 26 deletions.
2 changes: 1 addition & 1 deletion database_files/User.csv
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Id,Name,Surname,Email,Username,Birthdate,DateCreated,Address,PhoneNumber
70,Glori,Snadden,[email protected],gsnadden1p,5/29/2018,3/1/2018,86 Spohn Trail,104-865-7034
71,Jaymee,Bayns,[email protected],jbayns1q,12/27/2017,7/30/2018,67105 Twin Pines Hill,568-814-2856
72,Giustina,Wilstead,[email protected],gwilstead1r,5/2/2018,6/4/2018,3340 Ronald Regan Lane,890-787-5413
73 ,LeilaStar ,Bruneton ,[email protected] ,lbruneton1s ,5/19/2018 ,10/8/2017 ,3952 Karstens Lane ,252-315-0574
73 ,LeilaStar ,Bruneton ,[email protected] ,lbruneton1s ,5/19/2018 ,10/8/2017 ,3952 KarstensLane ,252-315-0574
74,Rudolf,Hargraves,[email protected],rhargraves1t,2/18/2018,6/6/2018,43 Pond Street,739-541-4640
75,Edsel,McMechan,[email protected],emcmechan1u,10/10/2017,5/10/2018,0 Corscot Road,646-704-5446
76,Dorita,Mathes,[email protected],dmathes1v,9/23/2017,11/24/2017,391 Stone Corner Hill,438-619-3889
Expand Down
2 changes: 2 additions & 0 deletions src/main/client/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import {ConversationComponent} from "./chat/conversation/conversation.component"
import {ConversationResolver} from "./chat/conversation/conversation.resolver";
import {AdminComponent} from "./admin/admin.component";
import {AdminResolver} from "./admin/admin.resolver";
import {SettingsComponent} from "./settings/settings.component";

const appRoutes: Routes = [
{path: '', component: HomeComponent, canActivate: [AuthGuard], children: [
PROFILE_ROUTE,
{path: '', component: NewsfeedComponent, pathMatch: 'full'},
{path: 'connections/:id', component: ConnectionsComponent, pathMatch: 'full'},
{path: 'jobs', component: JobsComponent, pathMatch: 'full'},
{path: 'settings', component: SettingsComponent, pathMatch: 'full'},
{path: 'admin', component: AdminComponent, pathMatch: 'full', resolve: {users: AdminResolver}},
{
path: 'messages', component: ChatComponent, children: [
Expand Down
7 changes: 6 additions & 1 deletion src/main/client/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {ExperienceComponent} from './profile/experience/experience.component';
import {EducationComponent} from './profile/education/education.component';
import {
AccordionModule,
AlertModule,
BsDatepickerModule,
BsDropdownModule,
BsModalRef,
Expand Down Expand Up @@ -80,6 +81,8 @@ import {ApplicantsComponent} from "./jobs/applicants/applicants.component";
import {PostCommentComponent} from "./profile/posts/post-comments/post-comments.component";
import {AdminComponent} from './admin/admin.component';
import {AdminResolver} from "./admin/admin.resolver";
import {SettingsComponent} from './settings/settings.component';
import {SettingsService} from "./shared/settings/settings.service";


@NgModule({
Expand Down Expand Up @@ -121,6 +124,7 @@ import {AdminResolver} from "./admin/admin.resolver";
ChatComponent,
ConversationComponent,
AdminComponent,
SettingsComponent,
],
imports: [
BrowserModule,
Expand All @@ -136,6 +140,7 @@ import {AdminResolver} from "./admin/admin.resolver";
BsDropdownModule.forRoot(),
AccordionModule.forRoot(),
TabsModule.forRoot(),
AlertModule.forRoot(),
BrowserAnimationsModule,
MatCheckboxModule,
MatTableModule,
Expand All @@ -160,7 +165,7 @@ import {AdminResolver} from "./admin/admin.resolver";
providers: [
Globals, AuthGuard, AuthService, RepoService, UserService, JobService, NotificationService, MessageService,
EducationService, ExperienceService, SkillService, LikeService, ConnectionService,
PostService, CommentService, BsModalRef, FileUploadService,
PostService, CommentService, BsModalRef, FileUploadService, SettingsService,
EducationResolver, ProfileResolver, SkillsResolver, ExperienceResolver, PostsResolver, MyFriendsResolver,
UserFriendsResolver, ConversationResolver, AdminResolver,
{
Expand Down
3 changes: 3 additions & 0 deletions src/main/client/src/app/layout/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
[routerLink]="['/profile', username]" title="My Account">
<img [src]="user.imagePath" class="w3-circle" style="height:23px;width:23px" alt="Avatar">
</a>
<a class="w3-bar-item w3-button w3-hide-small w3-right w3-padding-large w3-hover-white" [routerLink]="['/settings']"
title="Settings"><i class="fa fa-gear"></i>
</a>
<div *ngIf="user.userId === 1">
<a class="w3-bar-item w3-button w3-hide-small w3-right w3-padding-large w3-hover-white" [routerLink]="['/admin']"
title="Admin Page"><i class="fa fa-key"></i>
Expand Down
9 changes: 9 additions & 0 deletions src/main/client/src/app/shared/settings/email-change.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {FormGroup} from "@angular/forms";

export class EmailChange {
newEmail: string;

constructor(form: FormGroup) {
this.newEmail = form.get('newEmail').value;
}
}
13 changes: 13 additions & 0 deletions src/main/client/src/app/shared/settings/password-change.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {FormGroup} from "@angular/forms";

export class PasswordChange {
oldPassword: string;
newPassword: string;
newPasswordRepeat: string;

constructor(form: FormGroup) {
this.oldPassword = form.get('oldPassword').value;
this.newPassword = form.get('newPassword').value;
this.newPasswordRepeat = form.get('newPasswordRepeat').value;
}
}
22 changes: 22 additions & 0 deletions src/main/client/src/app/shared/settings/settings.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {Injectable} from "@angular/core";
import {RepoService} from "../repo/repo.service";
import {EmailChange} from "./email-change.model";
import {PasswordChange} from "./password-change.model";

@Injectable()
export class SettingsService {
constructor(private repoService: RepoService) {
}

updateEmail(dto: EmailChange) {
this.repoService.put("profile/change-email/", dto)
.subscribe(() => {
}, error => console.log(error));
}

updatePassword(dto: PasswordChange) {
this.repoService.put("profile/change-pass/", dto)
.subscribe(() => {
}, error => console.log(error));
}
}
37 changes: 19 additions & 18 deletions src/main/java/com/linkedin/converter/NotificationConverter.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
package com.linkedin.converter;

import com.linkedin.entities.database.Notification;
import com.linkedin.entities.database.User;
import com.linkedin.entities.database.repo.UserRepository;
import com.linkedin.entities.model.notifications.NotificationDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class NotificationConverter {
private final UserRepository userRepository;
private final UserConverter userConverter;
private final UserRepository userRepository;
private final UserConverter userConverter;

@Autowired
public NotificationConverter(UserRepository userRepository, UserConverter userConverter){
@Autowired
public NotificationConverter(UserRepository userRepository, UserConverter userConverter) {

this.userRepository = userRepository;
this.userConverter = userConverter;
}
this.userRepository = userRepository;
this.userConverter = userConverter;
}

public NotificationDto toNotificationDto(Notification notification){
NotificationDto notificationDto = new NotificationDto();
notificationDto.setMessage(notification.getMessage());
notificationDto.setNotificationId(notification.getNotificationId());
notificationDto.setStatus(notification.getStatus());
notificationDto.setType(notification.getType());
notificationDto.setUser( userConverter.toUserSimpleDto( userRepository.findById(notification.getUserId()).orElse(null) ));
notificationDto.setTargetUserId(notification.getTargetUserId());
notificationDto.setLikeCommentConnectionId(notification.getLikeCommentConnectionId());
public NotificationDto toNotificationDto(Notification notification) {
NotificationDto notificationDto = new NotificationDto();
notificationDto.setMessage(notification.getMessage());
notificationDto.setNotificationId(notification.getNotificationId());
notificationDto.setStatus(notification.getStatus());
notificationDto.setType(notification.getType());
notificationDto.setUser(userConverter.toUserSimpleDto(userRepository.findById(notification.getUserId()).orElse(new User())));
notificationDto.setTargetUserId(notification.getTargetUserId());
notificationDto.setLikeCommentConnectionId(notification.getLikeCommentConnectionId());

return notificationDto;
}
return notificationDto;
}
}
15 changes: 9 additions & 6 deletions src/main/java/com/linkedin/dataentry/DatabaseCsvReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@
*/
@Component
public class DatabaseCsvReader {
private final String[] FILE_ARRAY = new String[]{"database_files/Login.csv", "database_files/Notification.csv",
"database_files/Job.csv", "database_files/Connection.csv", "database_files/User.csv",
private final String[] FILE_ARRAY = new String[]{"database_files/Login.csv",
"database_files/Notification.csv",
"database_files/Job.csv", "database_files/Connection.csv",
"database_files/User.csv",
"database_files/Post.csv", "database_files/Comment.csv", "database_files/Like.csv",
"database_files/ConnectionRequest.csv", "database_files/Message.csv"
"database_files/ConnectionRequest.csv",
"database_files/Message.csv"
};
private final String ENTITIES_PACKAGE_NAME = "com.linkedin.entities.database";

private final Repositories repositories;

public final static SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
public final static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
public static final SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");

public static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");

@Autowired
public DatabaseCsvReader(ListableBeanFactory listableBeanFactory) {
Expand Down

0 comments on commit 48a261b

Please sign in to comment.