From c1b185a27a630e67916bca76db7610cfc4fba18f Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 29 Jan 2021 17:41:32 +0200 Subject: Implemented functionality and rough UI in profile settings forUpdated profile component to use language and technology service methods --- .../app/components/profile/profile.component.ts | 42 +++++++--------------- 1 file changed, 12 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/DevHive.Angular/src/app/components/profile/profile.component.ts b/src/DevHive.Angular/src/app/components/profile/profile.component.ts index 5bc1976..69d7e72 100644 --- a/src/DevHive.Angular/src/app/components/profile/profile.component.ts +++ b/src/DevHive.Angular/src/app/components/profile/profile.component.ts @@ -42,21 +42,12 @@ export class ProfileComponent implements OnInit { Object.assign(this.user, res); if (this.user.languages.length > 0) { - // For each language in the user, request it's name and assign it, - // when you finally finish with them, start loading technologies - const lastGuid = this.user.languages[this.user.languages.length - 1].id; - for (const lang of this.user.languages) { - this._languageService.getLanguageRequest(lang.id).subscribe( - (result: object) => { - // this only assigns the response "name" property to language - Object.assign(lang, result); - - if (lastGuid === lang.id) { - this.loadTechnologies(); - } - } - ); - } + // When user has languages, get their names and load technologies + this._languageService.getFullLanguagesFromIncomplete(this.user.languages) + .then(value => { + this.user.languages = value; + this.loadTechnologies(); + }); } else { this.showNoLangMsg = true; @@ -66,21 +57,12 @@ export class ProfileComponent implements OnInit { private loadTechnologies(): void { if (this.user.technologies.length > 0) { - // For each language in the user, request it's name and assign it, - // when you finish with them, finally finish user loading - const lastGuid = this.user.technologies[this.user.technologies.length - 1].id; - for (const tech of this.user.technologies) { - this._technologyService.getTechnologyRequest(tech.id).subscribe( - (result: object) => { - // this only assigns the response "name" property to technology - Object.assign(tech, result); - - if (lastGuid === tech.id) { - this.finishUserLoading(); - } - } - ); - } + // When user has technologies, get their names and finally finish loading + this._technologyService.getFullTechnologiesFromIncomplete(this.user.technologies) + .then(value => { + this.user.technologies = value; + this.finishUserLoading(); + }); } else { this.showNoTechMsg = true; -- cgit v1.2.3