Skip to content
This repository has been archived by the owner on Feb 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #103 from LT-Students/feature/userdata-for-employe…
Browse files Browse the repository at this point in the history
…e-page

Feature/userdata for employee page
  • Loading branch information
NikGurev authored May 18, 2021
2 parents 5424973 + 2025f28 commit 34f7a93
Show file tree
Hide file tree
Showing 31 changed files with 3,252 additions and 1,631 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"@typescript-eslint/type-annotation-spacing": "error",
"space-infix-ops": "error",
"object-curly-spacing": ["error", "always"],
"arrow-body-style": "error",
"arrow-body-style": "off",
"arrow-parens": ["off", "always"],
"brace-style": ["off", "off"],
"comma-dangle": "off",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
],
"src/**/*.{ts,html}, !src/data/api/**/*.ts": [
"prettier --write",
"eslint"
"eslint --fix"
]
}
}
66 changes: 40 additions & 26 deletions src/app/core/models/education.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// eslint-disable-next-line no-shadow
import { CertificateInfo } from '@data/api/user-service/models/certificate-info';
import { EducationType } from '@data/api/user-service/models/education-type';
import { ImageInfo } from '@data/api/user-service/models/image-info';

export enum StudyType {
/* заочно */
ABSENTIA = 'заочно',
Expand All @@ -10,13 +14,7 @@ export enum StudyType {
ONLINE = 'online',
}

export interface EducationPlace {
educationInstitution: string;
specialization: string;
studyType: StudyType;
endYear: Date;
startYear?: Date;
certificateId?: string;
export interface CertificateInfoExtended extends CertificateInfo {
isEditing?: boolean;
}

Expand All @@ -31,11 +29,11 @@ export class EducationModel {
public get specialization(): string {
return this._specialization;
}
private _studyType: StudyType;
public get studyType(): StudyType {
private _studyType: EducationType;
public get studyType(): EducationType {
return this._studyType;
}
public set studyType(studyType: StudyType) {
public set studyType(studyType: EducationType) {
this._studyType = studyType;
}
private _startYear: Date;
Expand All @@ -45,33 +43,49 @@ export class EducationModel {
public set startYear(year: Date) {
this._startYear = year;
}
private _endYear: Date;
private _endYear: string;
public get endYear(): Date {
return this._endYear;
}
public set endYear(year: Date) {
this._endYear = year;
return new Date(this._endYear);
}
// public set endYear(year: Date) {
// this._endYear = year;
// }
private _certificateId: string;
public get certificateId(): string {
return this._certificateId;
}

constructor(data: EducationPlace) {
this._educationInstitution = data.educationInstitution
? data.educationInstitution
: null;
this._specialization = data.specialization ? data.specialization : null;
this._studyType = data.studyType ? data.studyType : null;
this._startYear = data.startYear ? data.startYear : null;
this._endYear = data.endYear ? data.endYear : null;
this._certificateId = data.certificateId ? data.certificateId : null;
private _image: ImageInfo;
public get imageInBase64(): string {
return this._image.content;
}

// constructor(data: EducationPlace) {
// this._educationInstitution = data.educationInstitution
// ? data.educationInstitution
// : null;
// this._specialization = data.specialization ? data.specialization : null;
// this._studyType = data.studyType ? data.studyType : null;
// this._startYear = data.startYear ? data.startYear : null;
// this._endYear = data.endYear ? data.endYear : null;
// this._certificateId = data.certificateId ? data.certificateId : null;
// this.isEditing = false;
// }

constructor(data: CertificateInfo) {
this._educationInstitution = data.schoolName ? data.schoolName : null;
this._specialization = data.name ? data.name : null;
this._studyType = data.educationType ? data.educationType : null;
// this._startYear = data.startYear ? data.startYear : null;
this._endYear = data.receivedAt ? data.receivedAt : null;
this._certificateId = data.id ? data.id : null;
this._image = data.image ? data.image : null;
this.isEditing = false;
}

public getEducationalPeriod(): string {
return this._startYear
? `${this._startYear.getFullYear()}-${this._endYear.getFullYear()}`
: this._endYear.getFullYear().toString();
? `${this._startYear.getFullYear()}-${this.endYear.getFullYear()}`
: this.endYear.getFullYear().toString();
}
}
8 changes: 2 additions & 6 deletions src/app/core/models/user-status.model.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// eslint-disable-next-line no-shadow
// TODO: use enum from API
export enum UserStatus {
Vacation,
Sick,
WorkFromOffice,
WorkFromHome
}

import { UserStatus } from '@data/api/user-service/models/user-status';

export interface IUserStatus {
emojiIcon: string;
Expand Down
85 changes: 85 additions & 0 deletions src/app/core/models/user.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { UserResponse } from '@data/api/user-service/models/user-response';
import { UserAchievementInfo } from '@data/api/user-service/models/user-achievement-info';
import { ImageInfo } from '@data/api/user-service/models/image-info';
import { CertificateInfo } from '@data/api/user-service/models/certificate-info';
import { CommunicationInfo } from '@data/api/user-service/models/communication-info';
import { DepartmentInfo } from '@data/api/user-service/models/department-info';
import { PositionInfo } from '@data/api/user-service/models/position-info';
import { ProjectInfo } from '@data/api/user-service/models/project-info';
import { UserInfo } from '@data/api/user-service/models/user-info';
import { IUserStatus, UserStatusModel } from '@app/models/user-status.model';


export class User implements UserResponse {
achievements: Array<UserAchievementInfo>;
avatar: ImageInfo;
certificates: Array<CertificateInfo>;
communications: Array<CommunicationInfo>;
department: DepartmentInfo;
errors: Array<string>;
position: PositionInfo;
projects: Array<ProjectInfo>;
skills: Array<string>;
user: UserInfo;

constructor(data: UserResponse) {
this.achievements = this._setProperty(data.achievements);
this.avatar = this._setProperty(data.avatar);
this.certificates = this._setProperty(data.certificates);
this.communications = this._setProperty(data.communications);
this.department = this._setProperty(data.department);
this.errors = this._setProperty(data.errors);
this.position = this._setProperty(data.position);
this.projects = this._setProperty(data.projects);
this.skills = this._setProperty(data.skills);
this.user = this._setProperty(data.user);
}

public get id(): string {
return this.user.id;
}

public get startWorkingDate(): Date {
return new Date(this.user.startWorkingAt);
}

public get isAdmin(): boolean {
return this.user.isAdmin;
}

public get firstName(): string {
return this.user.firstName;
}

public set firstName(firstName: string) {
this.user.firstName = firstName;
}

public get lastName(): string {
return this.user.lastName;
}

public set lastName(lastName: string) {
this.user.lastName = lastName;
}

public get middleName(): string {
return this.user.middleName;
}

public set middleName(middleName: string) {
this.user.middleName = middleName;
}

public get status(): IUserStatus {
return UserStatusModel.getUserStatusInfoByType(this.user.status);
}

public getFioFull() {
return [this.lastName, this.firstName, this.middleName].filter(Boolean).join(' ');
}

private _setProperty<T>(property: T) {
return (property) ? property : null;
}
}
1 change: 0 additions & 1 deletion src/app/core/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@ export class AuthService {

private _setCredentialsToLocalStorage(authenticationInfo: AuthenticationResponse) {
this.localStorageService.set('access_token', authenticationInfo.token);
this.localStorageService.set('userId', authenticationInfo.userId);
}
}
20 changes: 20 additions & 0 deletions src/app/core/services/department.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { DepartmentApiService } from '@data/api/company-service/services/department-api.service';
import { DepartmentInfo } from '@data/api/user-service/models/department-info';
import { Injectable } from '@angular/core';
import { switchMap } from 'rxjs/operators';
import { Observable, of } from 'rxjs';
import { ProjectsResponse } from '@data/api/project-service/models/projects-response';
import { departments } from '../../modules/employee/mock';

@Injectable({
providedIn: 'root'
})
export class DepartmentService {

constructor(private _departmentService: DepartmentApiService) {
}

public getDepartments(): Observable<DepartmentInfo[]> {
return of(departments);
}
}
33 changes: 31 additions & 2 deletions src/app/core/services/project.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Injectable } from '@angular/core';
import { ProjectApiService } from '@data/api/project-service/services/project-api.service';
import { ProjectRequest } from '@data/api/project-service/models/project-request';
import { Observable } from 'rxjs';
import { ProjectInfo } from '@data/api/user-service/models/project-info';
import { forkJoin, Observable, of } from 'rxjs';
import { ProjectInfo } from '@data/api/project-service/models/project-info';
import { switchMap } from 'rxjs/operators';
import { ProjectExpandedResponse, ProjectsResponse } from '@data/api/project-service/models';
import { departments, positions, projects } from '../../modules/employee/mock';
import { PositionInfo } from '@data/api/user-service/models/position-info';

@Injectable({
providedIn: 'root'
Expand All @@ -15,4 +19,29 @@ export class ProjectService {
public createProject(request: ProjectRequest): Observable<ProjectInfo> {
return this._projectApiService.createProject({ body: request });
}

public getProjects(): Observable<ProjectInfo[]> {
return this._projectApiService.findprojects({ skipCount: 0, takeCount: 10 })
.pipe(
switchMap((projects: ProjectsResponse) => of(projects.body)),
);
}

public getUserProjectsInfo(projects: ProjectInfo[]): Observable<ProjectInfo[]> {
return forkJoin(projects.map((project: ProjectInfo) => {
return this._projectApiService.getProjectById({ projectId: project.id })
.pipe(
switchMap((projectExpanded: ProjectExpandedResponse) => of(projectExpanded.project)),
);
}),
);
}

public getMockUserProjectsInfo(): Observable<ProjectInfo[]> {
return of(projects);
}

public getProjectPositions(): Observable<PositionInfo[]> {
return of(positions);
}
}
Loading

0 comments on commit 34f7a93

Please sign in to comment.