Started implementation of all posts
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
import {Component, inject, input, signal, viewChild} from '@angular/core';
|
import {Component, inject, input, viewChild} from '@angular/core';
|
||||||
import {IonicModule, LoadingController, ToastController} from "@ionic/angular";
|
import {IonicModule, LoadingController, ToastController} from "@ionic/angular";
|
||||||
import {GetRandomChallengeDto, RandomchallengesService} from "../../services/api";
|
import {GetRandomChallengeDto, RandomchallengesService} from "../../services/api";
|
||||||
import {firstValueFrom} from "rxjs";
|
import {firstValueFrom} from "rxjs";
|
||||||
import {TooltipComponent} from "../tooltip/tooltip.component";
|
import {TooltipComponent} from "../tooltip/tooltip.component";
|
||||||
import {ProofFormComponent} from "../proof-form/proof-form.component";
|
import {ProofFormComponent} from "../proof-form/proof-form.component";
|
||||||
import {SignOnFormComponent} from "../sign-on-form/sign-on-form.component";
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-challenge-card',
|
selector: 'app-challenge-card',
|
||||||
@@ -60,10 +59,10 @@ export class ChallengeCardComponent {
|
|||||||
color: 'success'
|
color: 'success'
|
||||||
});
|
});
|
||||||
await toast.present();
|
await toast.present();
|
||||||
} catch {
|
} catch (e) {
|
||||||
this.isModalOpen = false;
|
this.isModalOpen = false;
|
||||||
const toast = await this.toastCtrl.create({
|
const toast = await this.toastCtrl.create({
|
||||||
message: 'Tu as déjà déposé une preuve pour ce défi',
|
message: e.error ?? "Impossible de déposer une preuve",
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
color: 'danger'
|
color: 'danger'
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
@for (post of posts(); track post.id) {
|
||||||
|
<img [src]="'data:image/jpeg;base64,' + post.proof" alt=""/>
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import {Component, inject, input, OnInit, signal} from '@angular/core';
|
||||||
|
import {FriendsService, GetFriendDto, GetPostDto} from "../../services/api";
|
||||||
|
import {firstValueFrom} from "rxjs";
|
||||||
|
import {LoadingController, ToastController} from "@ionic/angular";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-post',
|
||||||
|
templateUrl: './post.component.html',
|
||||||
|
styleUrls: ['./post.component.scss'],
|
||||||
|
})
|
||||||
|
export class PostComponent implements OnInit {
|
||||||
|
private friendsService = inject(FriendsService);
|
||||||
|
private loadCtrl = inject(LoadingController);
|
||||||
|
private toastCtrl = inject(ToastController);
|
||||||
|
|
||||||
|
friends = signal<GetFriendDto[]>([]);
|
||||||
|
|
||||||
|
posts = input.required<GetPostDto[]>();
|
||||||
|
postsFriends = signal<GetPostDto[]>([]);
|
||||||
|
|
||||||
|
async ngOnInit() {
|
||||||
|
const loading = await this.loadCtrl.create({
|
||||||
|
message: 'Chargement...',
|
||||||
|
spinner: 'lines-sharp-small'
|
||||||
|
});
|
||||||
|
await loading.present();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const friends = await firstValueFrom(this.friendsService.getAllFriendsEndpoint());
|
||||||
|
this.friends.set(friends);
|
||||||
|
this.postsFriends.set(this.posts().filter(post => this.friends().map(x => x.friendId).includes(post.userId)));
|
||||||
|
} catch {
|
||||||
|
const toast = await this.toastCtrl.create({
|
||||||
|
message: 'Erreur lors du chargement des amis.',
|
||||||
|
duration: 2000,
|
||||||
|
color: 'danger'
|
||||||
|
});
|
||||||
|
await toast.present();
|
||||||
|
}
|
||||||
|
await loading.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,4 +5,5 @@
|
|||||||
</ion-header>
|
</ion-header>
|
||||||
|
|
||||||
<ion-content style="--background: #f7f6f2;">
|
<ion-content style="--background: #f7f6f2;">
|
||||||
|
<app-post [posts]="posts()"></app-post>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|||||||
@@ -1,13 +1,43 @@
|
|||||||
import {Component} from '@angular/core';
|
import {Component, inject, signal} from '@angular/core';
|
||||||
import {IonicModule} from "@ionic/angular";
|
import {IonicModule, LoadingController, ToastController} from "@ionic/angular";
|
||||||
|
import {GetPostDto, PostsService} from "../../services/api";
|
||||||
|
import {firstValueFrom} from "rxjs";
|
||||||
|
import {PostComponent} from "../../components/post/post.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-publication',
|
selector: 'app-publication',
|
||||||
templateUrl: './publication.component.html',
|
templateUrl: './publication.component.html',
|
||||||
styleUrls: ['./publication.component.scss'],
|
styleUrls: ['./publication.component.scss'],
|
||||||
imports: [
|
imports: [
|
||||||
IonicModule
|
IonicModule,
|
||||||
|
PostComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class PublicationComponent {
|
export class PublicationComponent {
|
||||||
|
private postsService = inject(PostsService);
|
||||||
|
private loadCtrl = inject(LoadingController);
|
||||||
|
private toastCtrl = inject(ToastController);
|
||||||
|
|
||||||
|
posts = signal<GetPostDto[]>([]);
|
||||||
|
|
||||||
|
async ionViewWillEnter() {
|
||||||
|
const loading = await this.loadCtrl.create({
|
||||||
|
message: 'Chargement...',
|
||||||
|
spinner: 'lines-sharp-small'
|
||||||
|
});
|
||||||
|
await loading.present();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const posts = await firstValueFrom(this.postsService.getAllPostsEndpoint());
|
||||||
|
this.posts.set(posts);
|
||||||
|
} catch {
|
||||||
|
const toast = await this.toastCtrl.create({
|
||||||
|
message: 'Impossible de charger les publications.',
|
||||||
|
duration: 2000,
|
||||||
|
color: 'danger'
|
||||||
|
});
|
||||||
|
await toast.present();
|
||||||
|
}
|
||||||
|
await loading.dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,67 +39,6 @@ export class MessagesService extends BaseService {
|
|||||||
super(basePath, configuration);
|
super(basePath, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @endpoint delete /API/Messages/{id}/Groups/{groupId}
|
|
||||||
* @param id
|
|
||||||
* @param groupId
|
|
||||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
|
||||||
* @param reportProgress flag to report request and response progress.
|
|
||||||
* @param options additional options
|
|
||||||
*/
|
|
||||||
public deleteMessageEndpoint(id: number, groupId: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any>;
|
|
||||||
public deleteMessageEndpoint(id: number, groupId: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<any>>;
|
|
||||||
public deleteMessageEndpoint(id: number, groupId: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<any>>;
|
|
||||||
public deleteMessageEndpoint(id: number, groupId: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
|
||||||
if (id === null || id === undefined) {
|
|
||||||
throw new Error('Required parameter id was null or undefined when calling deleteMessageEndpoint.');
|
|
||||||
}
|
|
||||||
if (groupId === null || groupId === undefined) {
|
|
||||||
throw new Error('Required parameter groupId was null or undefined when calling deleteMessageEndpoint.');
|
|
||||||
}
|
|
||||||
|
|
||||||
let localVarHeaders = this.defaultHeaders;
|
|
||||||
|
|
||||||
// authentication (JWTBearerAuth) required
|
|
||||||
localVarHeaders = this.configuration.addCredentialToHeaders('JWTBearerAuth', 'Authorization', localVarHeaders, 'Bearer ');
|
|
||||||
|
|
||||||
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
|
|
||||||
]);
|
|
||||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
|
||||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
|
||||||
}
|
|
||||||
|
|
||||||
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
|
|
||||||
|
|
||||||
const localVarTransferCache: boolean = options?.transferCache ?? true;
|
|
||||||
|
|
||||||
|
|
||||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
|
||||||
if (localVarHttpHeaderAcceptSelected) {
|
|
||||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
|
||||||
responseType_ = 'text';
|
|
||||||
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
|
||||||
responseType_ = 'json';
|
|
||||||
} else {
|
|
||||||
responseType_ = 'blob';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let localVarPath = `/API/Messages/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}/Groups/${this.configuration.encodeParam({name: "groupId", value: groupId, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}`;
|
|
||||||
const { basePath, withCredentials } = this.configuration;
|
|
||||||
return this.httpClient.request<any>('delete', `${basePath}${localVarPath}`,
|
|
||||||
{
|
|
||||||
context: localVarHttpContext,
|
|
||||||
responseType: <any>responseType_,
|
|
||||||
...(withCredentials ? { withCredentials } : {}),
|
|
||||||
headers: localVarHeaders,
|
|
||||||
observe: observe,
|
|
||||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
|
||||||
reportProgress: reportProgress
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @endpoint get /API/Messages/Groups/{groupId}
|
* @endpoint get /API/Messages/Groups/{groupId}
|
||||||
* @param groupId
|
* @param groupId
|
||||||
|
|||||||
@@ -150,16 +150,15 @@ export class RandomchallengesService extends BaseService {
|
|||||||
/**
|
/**
|
||||||
* @endpoint patch /API/RandomChallenges/{randomChallengeId}/Proof
|
* @endpoint patch /API/RandomChallenges/{randomChallengeId}/Proof
|
||||||
* @param randomChallengeId
|
* @param randomChallengeId
|
||||||
* @param libelle
|
|
||||||
* @param proof
|
* @param proof
|
||||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||||
* @param reportProgress flag to report request and response progress.
|
* @param reportProgress flag to report request and response progress.
|
||||||
* @param options additional options
|
* @param options additional options
|
||||||
*/
|
*/
|
||||||
public patchProofEndpoint(randomChallengeId: number, libelle?: string, proof?: Blob, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any>;
|
public patchProofEndpoint(randomChallengeId: number, proof?: Blob, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any>;
|
||||||
public patchProofEndpoint(randomChallengeId: number, libelle?: string, proof?: Blob, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<any>>;
|
public patchProofEndpoint(randomChallengeId: number, proof?: Blob, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<any>>;
|
||||||
public patchProofEndpoint(randomChallengeId: number, libelle?: string, proof?: Blob, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<any>>;
|
public patchProofEndpoint(randomChallengeId: number, proof?: Blob, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<any>>;
|
||||||
public patchProofEndpoint(randomChallengeId: number, libelle?: string, proof?: Blob, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
public patchProofEndpoint(randomChallengeId: number, proof?: Blob, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||||
if (randomChallengeId === null || randomChallengeId === undefined) {
|
if (randomChallengeId === null || randomChallengeId === undefined) {
|
||||||
throw new Error('Required parameter randomChallengeId was null or undefined when calling patchProofEndpoint.');
|
throw new Error('Required parameter randomChallengeId was null or undefined when calling patchProofEndpoint.');
|
||||||
}
|
}
|
||||||
@@ -198,9 +197,6 @@ export class RandomchallengesService extends BaseService {
|
|||||||
localVarFormParams = new HttpParams({encoder: this.encoder});
|
localVarFormParams = new HttpParams({encoder: this.encoder});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (libelle !== undefined) {
|
|
||||||
localVarFormParams = localVarFormParams.append('libelle', <any>libelle) as any || localVarFormParams;
|
|
||||||
}
|
|
||||||
if (proof !== undefined) {
|
if (proof !== undefined) {
|
||||||
localVarFormParams = localVarFormParams.append('proof', <any>proof) as any || localVarFormParams;
|
localVarFormParams = localVarFormParams.append('proof', <any>proof) as any || localVarFormParams;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export interface GetPostDto {
|
|||||||
creationDate?: string;
|
creationDate?: string;
|
||||||
likes?: number;
|
likes?: number;
|
||||||
isLiked?: boolean;
|
isLiked?: boolean;
|
||||||
|
proof?: string | null;
|
||||||
userId?: number;
|
userId?: number;
|
||||||
username?: string | null;
|
username?: string | null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user