Skip to content

Commit

Permalink
refact: [community/profile-list] modifie le design de la page
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieuaudemard committed Apr 28, 2023
1 parent 1ca002a commit 576634b
Show file tree
Hide file tree
Showing 36 changed files with 79 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import com.dynonuggets.refonteimplicaction.community.profile.service.ProfileService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
Expand All @@ -14,7 +17,6 @@
import static com.dynonuggets.refonteimplicaction.community.profile.utils.ProfileUris.GET_PROFILE_BY_USERNAME;
import static com.dynonuggets.refonteimplicaction.community.profile.utils.ProfileUris.PROFILES_BASE_URI;
import static com.dynonuggets.refonteimplicaction.filemanagement.utils.FileUris.POST_PROFILE_AVATAR;
import static org.springframework.data.domain.PageRequest.of;

@RestController
@AllArgsConstructor
Expand All @@ -26,9 +28,12 @@ public class ProfileController {
@GetMapping
public ResponseEntity<Page<ProfileDto>> getAllProfiles(
@RequestParam(defaultValue = "0") final int page,
@RequestParam(defaultValue = "10") final int rows
@RequestParam(defaultValue = "10") final int rows,
@RequestParam(value = "sortBy", defaultValue = "id") final String[] sortBy,
@RequestParam(value = "sortOrder", defaultValue = "ASC") final String sortOrder
) {
return ResponseEntity.ok(profileService.getAllProfiles(of(page, rows)));
final Pageable pageable = PageRequest.of(page, rows, Sort.by(Sort.Direction.valueOf(sortOrder), sortBy));
return ResponseEntity.ok(profileService.getAllProfiles(pageable));
}

@PutMapping
Expand Down
2 changes: 1 addition & 1 deletion frontend-implicaction/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {AuthService} from './core/services/auth.service';
import {take, takeUntil} from 'rxjs/operators';
import {ProfileContextService} from './core/services/profile-context.service';
import {Principal} from './shared/models/principal';
import {Profile} from './community/models/profile/profile';
import {Profile} from './community/models/profile';
import {ProfileService} from './community/services/profile/profile.service';
import {AppService} from './core/services/app.service';
import {AppStatusEnum} from './shared/enums/app-status-enum';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<ul class="list-group list-group-flush">
<ul class="list-group list-group-flush py-2">
<ng-container *ngFor="let menuItem of menuItems">
<li class="list-group-item">
<a
[routerLinkActive]="'active'"
[routerLink]=menuItem.routerLink
[routerLinkActiveOptions]="{exact: true}"
[routerLink]="menuItem.routerLink"
[queryParams]="menuItem.queryParams"
[routerLinkActiveOptions]="menuItem.routerLinkActiveOptions"
>
{{menuItem.label}}
</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
@import "src/assets/variables";

.list-group-item {
padding: 0;

a {
padding: 8px 16px;
text-decoration: none;
display: flex;
justify-content: space-between;
Expand All @@ -11,6 +14,7 @@

&:hover, &.active {
font-weight: 600;
background-color: $secondary;
}

&:after {
Expand All @@ -19,8 +23,3 @@
}
}
}


li:has(a.active) {
background-color: $secondary;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Component, Input} from '@angular/core';
import {MenuItem} from "primeng/api";

@Component({
selector: 'app-community-sidemenu',
Expand All @@ -7,6 +8,6 @@ import {Component, Input} from '@angular/core';
})
export class CommunitySidemenuComponent {

@Input() menuItems: any[];
@Input() menuItems: MenuItem[];

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {AbstractControl, NonNullableFormBuilder, Validators} from '@angular/forms';
import {Profile} from '../../../../models/profile/profile';
import {ProfileUpdateRequest} from '../../../../models/profile/profile-update-request';
import {Profile} from '../../../../models/profile';
import {ProfileUpdateRequest} from '../../../../models/profile-update-request';
import {BaseFormComponent} from '../../../../../shared/components/base-form/base-form.component';

@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, Input, OnChanges, SimpleChanges} from '@angular/core';
import {Profile} from "../../../models/profile/profile";
import {Profile} from "../../../models/profile";
import {ToasterService} from "../../../../core/services/toaster.service";
import {ProfileContextService} from "../../../../core/services/profile-context.service";
import {finalize} from "rxjs/operators";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Component, Input, OnDestroy} from '@angular/core';
import {Profile} from '../../../../models/profile/profile';
import {Profile} from '../../../../models/profile';
import {ProfileContextService} from '../../../../../core/services/profile-context.service';
import {ProfileService} from '../../../../services/profile/profile.service';
import {ToasterService} from '../../../../../core/services/toaster.service';
import {Subject} from 'rxjs';
import {ProfileUpdateRequest} from '../../../../models/profile/profile-update-request';
import {ProfileUpdateRequest} from '../../../../models/profile-update-request';
import {finalize} from 'rxjs/operators';

@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, Input} from '@angular/core';
import {Profile} from "../../../../../models/profile/profile";
import {Profile} from "../../../../../models/profile";

@Component({
selector: 'app-profile-details-section',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {Profile} from "../../../../../models/profile/profile";
import {Profile} from "../../../../../models/profile";

@Component({
selector: 'app-profile-overview-tab',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, Input} from '@angular/core';
import {Profile} from "../../../../../models/profile/profile";
import {Profile} from "../../../../../models/profile";

@Component({
selector: 'app-profile-presentation-section',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges} from '@angular/core';
import {Profile} from "../../models/profile/profile";
import {Profile} from "../../models/profile";
import {ProfileContextService} from "../../../core/services/profile-context.service";
import {RelationAction, RelationActionEnum, RelationActionEnumCode} from "../../models/relation/relation-action";
import {RelationAction, RelationActionEnum, RelationActionEnumCode} from "../../models/relation-action";
import {take} from "rxjs/operators";

@Component({
Expand Down Expand Up @@ -36,7 +36,6 @@ export class RelationButtonComponent implements OnInit, OnChanges {

ngOnChanges(changes: SimpleChanges): void {
if (changes.hasOwnProperty('profile')) {
console.log(changes['profile'].currentValue);
this.okButton = this.getOkButton();
this.cancelButton = this.getCancelButton();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {EnumCodeLabelAbstract} from "../../../../shared/enums/enum-code-label-abstract.enum";
import {EnumCodeLabelAbstract} from "../../../shared/enums/enum-code-label-abstract.enum";

export enum RelationActionButton {
RELATION_DELETE = 'RELATION_CANCEL',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {WorkExperience} from "../../../shared/models/work-experience";
import {Training} from "../../../shared/models/training";
import {Relation} from "../relation/relation";
import {WorkExperience} from "../../shared/models/work-experience";
import {Training} from "../../shared/models/training";
import {Relation} from "./relation";

export interface Profile {
username?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Relation} from "./relation";
import {EnumCodeLabelAbstract} from "../../../shared/enums/enum-code-label-abstract.enum";
import {EnumCodeLabelAbstract} from "../../shared/enums/enum-code-label-abstract.enum";

export enum RelationActionEnumCode {
CREATE = 'CREATE', DELETE = 'DELETE', CONFIRM = 'CONFIRM'
Expand Down
9 changes: 9 additions & 0 deletions frontend-implicaction/src/app/community/models/relation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {Profile} from "./profile";

export interface Relation {
id?: string;
confirmedAt?: string;
sentAt?: string;
receiver?: Profile;
sender?: Profile;
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Component, OnDestroy, OnInit} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {ProfileService} from '../../services/profile/profile.service';
import {Profile} from '../../models/profile/profile';
import {Profile} from '../../models/profile';
import {Univers} from '../../../shared/enums/univers';
import {Observable, Subject} from 'rxjs';
import {ProfileTabEnum} from '../../models/profile/enums/profile-tab-enum';
import {ProfileTabEnum} from '../../models/enums/profile-tab-enum';
import {filter, takeUntil} from 'rxjs/operators';
import {AuthService} from '../../../core/services/auth.service';
import {ProfileContextService} from '../../../core/services/profile-context.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<div class="row col-lg-8 col-xl-9 mt-4 mt-lg-0 m-0 p-0 align-items-baseline">
<ng-container *ngIf="!loading; else templateLoading">
<p *ngIf="!profiles.length">Aucun résultat</p>
<div
*ngFor="let profile of profiles; trackBy: trackByUsername"
class="col-md-6 col-xl-6 px-0 px-md-2 profile-card"
Expand All @@ -22,7 +23,7 @@
<a
tooltipPosition="top"
pTooltip="{{profile?.firstname}} {{profile?.lastname}}"
[routerLink]="['/', univer.COMMUNITY.url, 'profiles', profile?.username]"
[routerLink]="['/', univers.COMMUNITY.url, 'profiles', profile?.username]"
>
{{profile?.firstname}} {{profile?.lastname}}
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {Univers} from '../../../shared/enums/univers';
import {ProfileService} from "../../services/profile/profile.service";
import {MenuItem} from "primeng/api";
import {Pageable} from "../../../shared/models/pageable";
import {Profile} from "../../models/profile/profile";
import {Profile} from "../../models/profile";
import {Constants} from "../../../config/constants";
import {RelationAction, RelationActionEnumCode} from "../../models/relation/relation-action";
import {Relation} from "../../models/relation/relation";
import {RelationAction, RelationActionEnumCode} from "../../models/relation-action";
import {Relation} from "../../models/relation";
import {Subject} from "rxjs";

@Component({
Expand All @@ -21,24 +21,30 @@ import {Subject} from "rxjs";
})
export class ProfileListPageComponent implements OnInit, OnDestroy {

readonly univer = Univers;
pageable: Pageable<Profile> = Constants.PAGEABLE_DEFAULT;
readonly univers = Univers;

pageable: Pageable<Profile> = {...Constants.PAGEABLE_DEFAULT, sortBy: 'user.lastname,user.firstname'};
profiles: Profile[] = [];
currentUser: User;
action: string;
loading = true;
menuItems: MenuItem[] = [
{
label: 'Tous les utilisateurs',
routerLink: `/${Univers.COMMUNITY.url}/profiles`
routerLink: `/${Univers.COMMUNITY.url}/profiles`,
routerLinkActiveOptions: {exact: true}
},
{
label: 'Mes amis',
routerLink: `/${Univers.COMMUNITY.url}/relations`
routerLink: `/${Univers.COMMUNITY.url}/profiles`,
queryParams: {filter: 'friends'},
routerLinkActiveOptions: {exact: true}
},
{
label: 'Invitations',
routerLink: `/${Univers.COMMUNITY.url}/relations/received`
routerLink: `/${Univers.COMMUNITY.url}/relations`,
queryParams: {filter: 'friendRequests'},
routerLinkActiveOptions: {exact: true}
}
];

Expand Down Expand Up @@ -131,7 +137,8 @@ export class ProfileListPageComponent implements OnInit, OnDestroy {
)
.subscribe({
next: pageable => {
this.pageable = pageable;
this.pageable = {...this.pageable, ...pageable};
console.log(this.pageable);
this.profiles = [...this.pageable.content];
},
error: () => this.toastService.error('Oops', 'Une erreur est survenue lors de la récupération de la liste des utilisateurs')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {Injectable} from '@angular/core';
import {Observable} from "rxjs";
import {ProfileUpdateRequest} from "../../models/profile/profile-update-request";
import {ProfileUpdateRequest} from "../../models/profile-update-request";
import {HttpClient, HttpEvent, HttpRequest} from "@angular/common/http";
import {ApiEndpointsService} from "../../../core/services/api-endpoints.service";
import {Profile} from "../../models/profile/profile";
import {Profile} from "../../models/profile";
import {Pageable} from "../../../shared/models/pageable";

@Injectable({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
import {Relation} from '../models/relation/relation';
import {Relation} from '../models/relation';
import {ApiEndpointsService} from '../../core/services/api-endpoints.service';
import {Pageable} from "../../shared/models/pageable";
import {RelationRequest} from "../models/relation/relation-request";
import {RelationRequest} from "../models/relation-request";

@Injectable({
providedIn: 'root'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {JobCriteriaFilter} from '../../job/models/job-criteria-filter';
import {Criteria} from '../../shared/models/criteria';
import {Response} from '../../forum/model/response';
import {GetCategoriesOptions} from '../../forum/services/category.service';
import {Profile} from '../../community/models/profile/profile';
import {Relation} from '../../community/models/relation/relation';
import {Profile} from '../../community/models/profile';
import {Relation} from '../../community/models/relation';

export type QueryStringHandler = (queryStringParameters: QueryStringParameters) => void;
export type CreateUrlOptions = { isMockApi?: boolean, queryStringHandler?: QueryStringHandler, pathVariables?: any[] };
Expand Down Expand Up @@ -97,7 +97,8 @@ export class ApiEndpointsService {
qs.push('rows', pageable.rows);
}
if (pageable.sortBy) {
qs.push('sortBy', pageable.sortBy);
const sortBys = pageable.sortBy.split(',');
sortBys.forEach(sortBy => qs.push('sortBy', sortBy));
}
if (pageable.sortOrder) {
qs.push('sortOrder', pageable.sortOrder);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Injectable} from '@angular/core';
import {BehaviorSubject, Observable} from "rxjs";
import {Profile} from "../../community/models/profile/profile";
import {Profile} from "../../community/models/profile";

@Injectable({
providedIn: 'root'
Expand Down
2 changes: 1 addition & 1 deletion frontend-implicaction/src/app/forum/model/response.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Topic} from "./topic"
import {Profile} from "../../community/models/profile/profile";
import {Profile} from "../../community/models/profile";

export interface Response {
id: number;
Expand Down
2 changes: 1 addition & 1 deletion frontend-implicaction/src/app/forum/model/topic.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Category} from "./category";
import {Response} from "./response";
import {Profile} from "../../community/models/profile/profile";
import {Profile} from "../../community/models/profile";

export interface Topic {
id: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {ToasterService} from '../../../core/services/toaster.service';
import {Univers} from '../../../shared/enums/univers';
import {RoleEnumCode} from '../../../shared/enums/role.enum';
import {Subject} from 'rxjs';
import {Profile} from '../../../community/models/profile/profile';
import {Profile} from '../../../community/models/profile';

@Component({
selector: 'app-header',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {RoleEnumCode} from "../../../shared/enums/role.enum";
import {Univers} from "../../../shared/enums/univers";
import {Profile} from "../../../community/models/profile/profile";
import {Profile} from "../../../community/models/profile";

@Component({
selector: 'app-navbar-profile-dropdown',
Expand Down
Loading

0 comments on commit 576634b

Please sign in to comment.