aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Angular
diff options
context:
space:
mode:
Diffstat (limited to 'src/DevHive.Angular')
-rw-r--r--src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts2
-rw-r--r--src/DevHive.Angular/src/app/services/user.service.ts15
-rw-r--r--src/DevHive.Angular/src/models/identity/friend.ts3
-rw-r--r--src/DevHive.Angular/src/models/identity/role.ts3
-rw-r--r--src/DevHive.Angular/src/models/identity/user.ts22
5 files changed, 36 insertions, 9 deletions
diff --git a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts
index 1989a4d..83a5501 100644
--- a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts
+++ b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts
@@ -165,7 +165,7 @@ export class ProfileSettingsComponent implements OnInit {
this.patchLanguagesControl();
this.patchTechnologiesControl();
- this._userService.putUserFromSessionStorageRequest(this.updateUserFormGroup).subscribe(
+ this._userService.putUserFromSessionStorageRequest(this.updateUserFormGroup, this.user.roles, this.user.friends).subscribe(
res => this._successBar.showMsg('Profile updated successfully!'),
(err: HttpErrorResponse) => this._errorBar.showError(err)
);
diff --git a/src/DevHive.Angular/src/app/services/user.service.ts b/src/DevHive.Angular/src/app/services/user.service.ts
index 6badf94..128e94b 100644
--- a/src/DevHive.Angular/src/app/services/user.service.ts
+++ b/src/DevHive.Angular/src/app/services/user.service.ts
@@ -8,6 +8,8 @@ import { FormGroup } from '@angular/forms';
import { AppConstants } from 'src/app/app-constants.module';
import {HttpClient, HttpErrorResponse, HttpHeaders, HttpParams} from '@angular/common/http';
import {Observable} from 'rxjs';
+import {Role} from 'src/models/identity/role';
+import {Friend} from 'src/models/identity/friend';
@Injectable({
providedIn: 'root'
@@ -16,7 +18,7 @@ export class UserService {
constructor(private http: HttpClient) { }
getDefaultUser(): User {
- return new User(Guid.createEmpty(), 'gosho_trapov', 'Gosho', 'Trapov', 'gotra@bg.com', AppConstants.FALLBACK_PROFILE_ICON, new Array(), new Array());
+ return new User(Guid.createEmpty(), 'gosho_trapov', 'Gosho', 'Trapov', 'gotra@bg.com', AppConstants.FALLBACK_PROFILE_ICON, [], [], [], []);
}
getUserIdFromSessionStorageToken(): Guid {
@@ -38,12 +40,12 @@ export class UserService {
return this.getUserRequest(userCred.ID, jwt.token);
}
- putUserFromSessionStorageRequest(updateUserFormGroup: FormGroup): Observable<object> {
+ putUserFromSessionStorageRequest(updateUserFormGroup: FormGroup, userRoles: Role[], userFriends: Friend[]): Observable<object> {
// Get the token and userid from session storage
const jwt: IJWTPayload = { token: sessionStorage.getItem('UserCred') ?? '' };
const userCred = jwt_decode<IUserCredentials>(jwt.token);
- return this.putUserRequest(userCred.ID, jwt.token, updateUserFormGroup);
+ return this.putUserRequest(userCred.ID, jwt.token, updateUserFormGroup, userRoles, userFriends);
}
deleteUserFromSessionStorageRequest(): Observable<object> {
@@ -93,16 +95,15 @@ export class UserService {
return this.http.get(AppConstants.API_USER_URL + '/GetUser', options);
}
- putUserRequest(userId: Guid, authToken: string, updateUserFormGroup: FormGroup): Observable<object> {
+ putUserRequest(userId: Guid, authToken: string, updateUserFormGroup: FormGroup, userRoles: Role[], userFriends: Friend[]): Observable<object> {
const body = {
UserName: updateUserFormGroup.get('username')?.value,
Email: updateUserFormGroup.get('email')?.value,
FirstName: updateUserFormGroup.get('firstName')?.value,
LastName: updateUserFormGroup.get('lastName')?.value,
Password: updateUserFormGroup.get('password')?.value,
- // TODO: make the following fields dynamically selectable
- Roles: [ { Name: 'User' } ],
- Friends: [],
+ Roles: userRoles,
+ Friends: userFriends,
Languages: updateUserFormGroup.get('languages')?.value,
Technologies: updateUserFormGroup.get('technologies')?.value
};
diff --git a/src/DevHive.Angular/src/models/identity/friend.ts b/src/DevHive.Angular/src/models/identity/friend.ts
new file mode 100644
index 0000000..22290cd
--- /dev/null
+++ b/src/DevHive.Angular/src/models/identity/friend.ts
@@ -0,0 +1,3 @@
+export class Friend {
+ public userName: string;
+}
diff --git a/src/DevHive.Angular/src/models/identity/role.ts b/src/DevHive.Angular/src/models/identity/role.ts
new file mode 100644
index 0000000..132b0b0
--- /dev/null
+++ b/src/DevHive.Angular/src/models/identity/role.ts
@@ -0,0 +1,3 @@
+export class Role {
+ public name: string;
+}
diff --git a/src/DevHive.Angular/src/models/identity/user.ts b/src/DevHive.Angular/src/models/identity/user.ts
index 045d1d9..f7b922c 100644
--- a/src/DevHive.Angular/src/models/identity/user.ts
+++ b/src/DevHive.Angular/src/models/identity/user.ts
@@ -1,6 +1,8 @@
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;
@@ -11,15 +13,19 @@ export class User {
private _imageUrl : string;
private _languages: Language[];
private _technologies: Technology[];
+ private _roles: Role[];
+ private _friends: Friend[];
- constructor(id: Guid, userName: string, firstName: string, lastName: string, email: string, imageUrl: string, languages: Language[], technologies: Technology[]) {
+ constructor(id: Guid, userName: string, firstName: string, lastName: string, email: string, imageUrl: 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.imageUrl = imageUrl;
+ this.languages = languages;
this.technologies = technologies;
+ this.roles = roles;
}
public get id(): Guid {
@@ -77,4 +83,18 @@ export class User {
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;
+ }
}