Update about the showing the user images
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -37,3 +37,5 @@
|
|||||||
/Back/skydiveLogs-api.Domain/bin/Release/net5.0/skydiveLogs-api.Domain.pdb
|
/Back/skydiveLogs-api.Domain/bin/Release/net5.0/skydiveLogs-api.Domain.pdb
|
||||||
/Back/skydiveLogs-api/Data/JumpsDb-log.db
|
/Back/skydiveLogs-api/Data/JumpsDb-log.db
|
||||||
/Back/skydiveLogs-api/Data/JumpsDb.db
|
/Back/skydiveLogs-api/Data/JumpsDb.db
|
||||||
|
Back/skydiveLogs-api/Data/JumpsDb.db
|
||||||
|
Back/skydiveLogs-api/Data/JumpsDb-log.db
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
{
|
{
|
||||||
return _col.Include(x => x.User)
|
return _col.Include(x => x.User)
|
||||||
.Query()
|
.Query()
|
||||||
.Where(j => j.User == user)
|
.Where(j => j.User.Id == user.Id)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ by editing this MSBuild file. In order to learn more about this please visit htt
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TimeStampOfAssociatedLegacyPublishXmlFile />
|
<TimeStampOfAssociatedLegacyPublishXmlFile />
|
||||||
<_PublishTargetUrl>C:\Projects\SkydiveLogs\Back\dist</_PublishTargetUrl>
|
<_PublishTargetUrl>C:\Projects\SkydiveLogs\Back\dist</_PublishTargetUrl>
|
||||||
<History>True|2021-03-18T15:30:10.7797171Z;True|2021-03-18T14:10:46.8227017+01:00;True|2021-03-15T15:33:07.2658649+01:00;</History>
|
<History>True|2021-03-25T15:58:36.4354616Z;True|2021-03-18T16:30:10.7797171+01:00;True|2021-03-18T14:10:46.8227017+01:00;True|2021-03-15T15:33:07.2658649+01:00;</History>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -70,8 +70,7 @@ export class CreateUserComponent implements OnInit {
|
|||||||
createUser.lastName = this.formCtrls.lastname.value;
|
createUser.lastName = this.formCtrls.lastname.value;
|
||||||
createUser.email = this.formCtrls.email.value;
|
createUser.email = this.formCtrls.email.value;
|
||||||
|
|
||||||
this.authenticationService
|
this.authenticationService.create(createUser)
|
||||||
.create(createUser)
|
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
data => {
|
data => {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
|
import { AuthenticationService } from "../../services/authentication.service";
|
||||||
import { ServiceComm } from "../../services/service-comm.service";
|
import { ServiceComm } from "../../services/service-comm.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -7,9 +8,11 @@ import { ServiceComm } from "../../services/service-comm.service";
|
|||||||
styleUrls: ["./default.component.css"]
|
styleUrls: ["./default.component.css"]
|
||||||
})
|
})
|
||||||
export class DefaultComponent implements OnInit {
|
export class DefaultComponent implements OnInit {
|
||||||
constructor(private serviceComm: ServiceComm) {}
|
constructor(private serviceComm: ServiceComm,
|
||||||
|
private authenticationService: AuthenticationService) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.serviceComm.UpdatedComponentTitle("Home");
|
this.serviceComm.UpdatedComponentTitle("Home");
|
||||||
|
this.authenticationService.alwaysLogin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,13 +22,13 @@
|
|||||||
<div *ngIf="resultsLength > 0">
|
<div *ngIf="resultsLength > 0">
|
||||||
<table mat-table [dataSource]="dataSourceTable">
|
<table mat-table [dataSource]="dataSourceTable">
|
||||||
<ng-container matColumnDef="comment">
|
<ng-container matColumnDef="comment">
|
||||||
<th mat-header-cell *matHeaderCellDef>Name</th>
|
<th mat-header-cell *matHeaderCellDef style="text-align: center;">Comments</th>
|
||||||
<td mat-cell *matCellDef="let element">{{element.comment}}</td>
|
<td mat-cell *matCellDef="let element" style="text-align: left;"><span style="white-space:nowrap;">{{element.comment}}</span></td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="data">
|
<ng-container matColumnDef="data">
|
||||||
<th mat-header-cell *matHeaderCellDef>Image</th>
|
<th mat-header-cell *matHeaderCellDef style="text-align: center;">Image</th>
|
||||||
<td mat-cell *matCellDef="let element"><img src="{{element.data}}" alt="toto"></td>
|
<td mat-cell *matCellDef="let element" style="text-align: center;"><img src="{{element.data}}" alt="toto" style="width:50%;"></td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
|
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ export class ListOfImagesComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getListOfImages() {
|
private getListOfImages() {
|
||||||
this.serviceApi.getListOfImages().subscribe((data) => {
|
this.serviceApi.getListOfImages()
|
||||||
|
.subscribe((data) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.dataSourceTable = new MatTableDataSource<ImageResp>(data);
|
this.dataSourceTable = new MatTableDataSource<ImageResp>(data);
|
||||||
this.dataSourceTable.paginator = this.paginator;
|
this.dataSourceTable.paginator = this.paginator;
|
||||||
|
|||||||
@@ -19,16 +19,12 @@ export class CachingInterceptor implements HttpInterceptor {
|
|||||||
|
|
||||||
intercept(req: HttpRequest<any>, next: HttpHandler) {
|
intercept(req: HttpRequest<any>, next: HttpHandler) {
|
||||||
const cachedResponse = this.cache.get(req);
|
const cachedResponse = this.cache.get(req);
|
||||||
return cachedResponse
|
return cachedResponse ? Observable.of(cachedResponse) : this.sendRequest(req, next);
|
||||||
? Observable.of(cachedResponse)
|
|
||||||
: this.sendRequest(req, next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendRequest(
|
sendRequest(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||||
req: HttpRequest<any>,
|
return next.handle(req)
|
||||||
next: HttpHandler
|
.pipe(
|
||||||
): Observable<HttpEvent<any>> {
|
|
||||||
return next.handle(req).pipe(
|
|
||||||
tap(event => {
|
tap(event => {
|
||||||
if (event instanceof HttpResponse) {
|
if (event instanceof HttpResponse) {
|
||||||
this.cache.put(req, event);
|
this.cache.put(req, event);
|
||||||
|
|||||||
@@ -5,20 +5,25 @@ import { catchError } from 'rxjs/operators';
|
|||||||
|
|
||||||
import { AuthenticationService } from '../services/authentication.service';
|
import { AuthenticationService } from '../services/authentication.service';
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ErrorInterceptor implements HttpInterceptor {
|
export class ErrorInterceptor implements HttpInterceptor {
|
||||||
|
|
||||||
constructor(private authenticationService: AuthenticationService) { }
|
constructor(private authenticationService: AuthenticationService) { }
|
||||||
|
|
||||||
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||||
return next.handle(request).pipe(catchError(err => {
|
return next.handle(request)
|
||||||
|
.pipe(
|
||||||
|
catchError(err => {
|
||||||
if (err.status === 401) {
|
if (err.status === 401) {
|
||||||
// auto logout if 401 response returned from api
|
// auto logout if 401 response returned from api
|
||||||
this.authenticationService.logout();
|
this.authenticationService.logout();
|
||||||
location.reload(true);
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
const error = err.error.message || err.statusText;
|
const error = err.error.message || err.statusText;
|
||||||
return throwError(error);
|
return throwError(error);
|
||||||
}));
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,19 @@
|
|||||||
import { Injectable } from "@angular/core";
|
import { Injectable } from "@angular/core";
|
||||||
import {
|
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from "@angular/common/http";
|
||||||
HttpRequest,
|
|
||||||
HttpHandler,
|
|
||||||
HttpEvent,
|
|
||||||
HttpInterceptor
|
|
||||||
} from "@angular/common/http";
|
|
||||||
import { Observable } from "rxjs";
|
import { Observable } from "rxjs";
|
||||||
|
|
||||||
import { AuthenticationService } from "../services/authentication.service";
|
import { AuthenticationService } from "../services/authentication.service";
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class JwtAuthInterceptor implements HttpInterceptor {
|
export class JwtAuthInterceptor implements HttpInterceptor {
|
||||||
|
|
||||||
constructor(private authenticationService: AuthenticationService) {}
|
constructor(private authenticationService: AuthenticationService) {}
|
||||||
|
|
||||||
intercept(
|
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||||
request: HttpRequest<any>,
|
|
||||||
next: HttpHandler
|
|
||||||
): Observable<HttpEvent<any>> {
|
|
||||||
// add authorization header with basic auth credentials if available
|
// add authorization header with basic auth credentials if available
|
||||||
const currentUser = this.authenticationService.currentUserValue;
|
const currentUser = this.authenticationService.currentUserValue;
|
||||||
|
|
||||||
if (currentUser && currentUser.token) {
|
if (currentUser && currentUser.token) {
|
||||||
request = request.clone({
|
request = request.clone({
|
||||||
setHeaders: {
|
setHeaders: {
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ export class AuthenticationService extends BaseService {
|
|||||||
JSON.parse(localStorage.getItem("currentUser"))
|
JSON.parse(localStorage.getItem("currentUser"))
|
||||||
);
|
);
|
||||||
this.currentUser = this.currentUserSubject.asObservable();
|
this.currentUser = this.currentUserSubject.asObservable();
|
||||||
|
|
||||||
this.alwaysLogin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public get currentUserValue(): User {
|
public get currentUserValue(): User {
|
||||||
@@ -71,13 +69,13 @@ export class AuthenticationService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private alwaysLogin() {
|
public alwaysLogin() {
|
||||||
return this.http.get(`${this.apiUrl}/User/AlwaysLogin`, {
|
this.http.get(`${this.apiUrl}/User/AlwaysLogin`,
|
||||||
headers: this.headers
|
{ headers: this.headers })
|
||||||
}).subscribe();
|
.subscribe(data => { console.log(data); });
|
||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
public logout() {
|
||||||
localStorage.removeItem("currentUser");
|
localStorage.removeItem("currentUser");
|
||||||
this.currentUserSubject.next(null);
|
this.currentUserSubject.next(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,11 @@ export class ImageService extends BaseService {
|
|||||||
data: dataImg,
|
data: dataImg,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.http
|
this.http.post(`${this.apiUrl}/Image`,
|
||||||
.post(`${this.apiUrl}/Image`, bodyNewImage, {
|
bodyNewImage,
|
||||||
headers: this.headers,
|
{ headers: this.headers })
|
||||||
})
|
.subscribe(
|
||||||
.subscribe((data) => console.log(data));
|
error => { console.error(error); }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user