Bug fix +
Meilleur chargement du cache après login
This commit is contained in:
@@ -8,10 +8,6 @@ import { AuthenticationService } from "../services/authentication.service";
|
|||||||
import { ServiceComm } from "../services/service-comm.service";
|
import { ServiceComm } from "../services/service-comm.service";
|
||||||
import { ConfigurationHelper } from "../services/configuration-helper";
|
import { ConfigurationHelper } from "../services/configuration-helper";
|
||||||
import { ServiceCacheApi } from "../services/service-cache-api.service";
|
import { ServiceCacheApi } from "../services/service-cache-api.service";
|
||||||
import { AircraftService } from "../services/aircraft.service";
|
|
||||||
import { GearService } from "../services/gear.service";
|
|
||||||
import { JumpTypeService } from "../services/jump-type.service";
|
|
||||||
import { DropzoneService } from "../services/dropzone.service";
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-root",
|
selector: "app-root",
|
||||||
@@ -26,11 +22,7 @@ export class AppComponent implements OnInit {
|
|||||||
constructor(private router: Router,
|
constructor(private router: Router,
|
||||||
private authenticationService: AuthenticationService,
|
private authenticationService: AuthenticationService,
|
||||||
private serviceComm: ServiceComm,
|
private serviceComm: ServiceComm,
|
||||||
private serviceCacheApi : ServiceCacheApi,
|
private serviceCacheApi : ServiceCacheApi)
|
||||||
private serviceApiAircraft : AircraftService,
|
|
||||||
private serviceApiJumpType : JumpTypeService,
|
|
||||||
private serviceApiDropzone : DropzoneService,
|
|
||||||
private serviceApiGear : GearService)
|
|
||||||
{
|
{
|
||||||
this.authenticationService.currentUser.subscribe(user => { this.currentUser = user; });
|
this.authenticationService.currentUser.subscribe(user => { this.currentUser = user; });
|
||||||
|
|
||||||
@@ -44,13 +36,6 @@ export class AppComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.serviceComm.componentTitle.subscribe(title => (this.title = title));
|
this.serviceComm.componentTitle.subscribe(title => (this.title = title));
|
||||||
|
|
||||||
if (this.authenticationService.currentUserValue != undefined) {
|
|
||||||
this.serviceApiAircraft.getListOfAircrafts(false).subscribe();
|
|
||||||
this.serviceApiJumpType.getListOfJumpTypes().subscribe();
|
|
||||||
this.serviceApiDropzone.getListOfDropZones(false).subscribe();
|
|
||||||
this.serviceApiGear.getListOfGears().subscribe();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { MatDialog } from "@angular/material/dialog";
|
|||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
import { AddAction } from '../../models/add-action.enum';
|
import { AddAction } from '../../models/add-action.enum';
|
||||||
import { JumpResp } from '../../models/jump';
|
import { Jump } from '../../models/jump';
|
||||||
import { JumpService } from '../../services/jump.service';
|
import { JumpService } from '../../services/jump.service';
|
||||||
import { ServiceComm } from '../../services/service-comm.service';
|
import { ServiceComm } from '../../services/service-comm.service';
|
||||||
import { JumpInfosComponent } from "../jump-infos/jump-infos.component";
|
import { JumpInfosComponent } from "../jump-infos/jump-infos.component";
|
||||||
@@ -16,7 +16,7 @@ import { JumpInfosComponent } from "../jump-infos/jump-infos.component";
|
|||||||
styleUrls: ['./list-of-jumps.component.css']
|
styleUrls: ['./list-of-jumps.component.css']
|
||||||
})
|
})
|
||||||
export class ListOfJumpsComponent implements OnInit {
|
export class ListOfJumpsComponent implements OnInit {
|
||||||
public listOfJumps: Observable<Array<JumpResp>>;
|
public listOfJumps: Observable<Array<Jump>>;
|
||||||
public displayedColumns: Array<string> = [
|
public displayedColumns: Array<string> = [
|
||||||
'infos',
|
'infos',
|
||||||
'id',
|
'id',
|
||||||
@@ -56,7 +56,7 @@ export class ListOfJumpsComponent implements OnInit {
|
|||||||
return b.jumpDate > a.jumpDate ? 1 : -1;
|
return b.jumpDate > a.jumpDate ? 1 : -1;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.dataSourceTable = new MatTableDataSource<JumpResp>(data);
|
this.dataSourceTable = new MatTableDataSource<Jump>(data);
|
||||||
this.dataSourceTable.paginator = this.paginator;
|
this.dataSourceTable.paginator = this.paginator;
|
||||||
this.paginator.pageSize
|
this.paginator.pageSize
|
||||||
this.resultsLength = data.length;
|
this.resultsLength = data.length;
|
||||||
@@ -64,7 +64,7 @@ export class ListOfJumpsComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
openDialog(item: JumpResp, editMode: boolean) {
|
openDialog(item: Jump, editMode: boolean) {
|
||||||
this.dialog.open(JumpInfosComponent,
|
this.dialog.open(JumpInfosComponent,
|
||||||
{ data: { "jump": item, "editMode": editMode},
|
{ data: { "jump": item, "editMode": editMode},
|
||||||
maxHeight: "400px",
|
maxHeight: "400px",
|
||||||
@@ -72,8 +72,8 @@ export class ListOfJumpsComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(item: JumpResp) {
|
delete(item: Jump) {
|
||||||
let data : Array<JumpResp> = this.dataSourceTable.data;
|
let data : Array<Jump> = this.dataSourceTable.data;
|
||||||
data = data.filter(d => d.id !== item.id);
|
data = data.filter(d => d.id !== item.id);
|
||||||
|
|
||||||
this.dataSourceTable.data = data;
|
this.dataSourceTable.data = data;
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ import { MatInput } from '@angular/material/input';
|
|||||||
import { first } from 'rxjs/operators';
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
import { AuthenticationService } from '../../services/authentication.service';
|
import { AuthenticationService } from '../../services/authentication.service';
|
||||||
|
import { AircraftService } from "../../services/aircraft.service";
|
||||||
|
import { GearService } from "../../services/gear.service";
|
||||||
|
import { JumpTypeService } from "../../services/jump-type.service";
|
||||||
|
import { DropzoneService } from "../../services/dropzone.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login-user',
|
selector: 'app-login-user',
|
||||||
@@ -20,13 +24,14 @@ export class LoginUserComponent implements OnInit, AfterViewInit {
|
|||||||
error = '';
|
error = '';
|
||||||
@ViewChild('username') userNameInput: MatInput;
|
@ViewChild('username') userNameInput: MatInput;
|
||||||
|
|
||||||
constructor(
|
constructor(private formBuilder: FormBuilder,
|
||||||
private formBuilder: FormBuilder,
|
private route: ActivatedRoute,
|
||||||
private route: ActivatedRoute,
|
private router: Router,
|
||||||
private router: Router,
|
private authenticationService: AuthenticationService,
|
||||||
private authenticationService: AuthenticationService
|
private serviceApiAircraft : AircraftService,
|
||||||
) {
|
private serviceApiJumpType : JumpTypeService,
|
||||||
// redirect to home if already logged in
|
private serviceApiDropzone : DropzoneService,
|
||||||
|
private serviceApiGear : GearService) {
|
||||||
if (this.authenticationService.currentUserValue) {
|
if (this.authenticationService.currentUserValue) {
|
||||||
this.router.navigate(['/']);
|
this.router.navigate(['/']);
|
||||||
}
|
}
|
||||||
@@ -40,12 +45,7 @@ export class LoginUserComponent implements OnInit, AfterViewInit {
|
|||||||
this.loginForm = this.formBuilder.group(
|
this.loginForm = this.formBuilder.group(
|
||||||
{
|
{
|
||||||
username: ['', [Validators.required, Validators.minLength(3)]],
|
username: ['', [Validators.required, Validators.minLength(3)]],
|
||||||
password: [
|
password: ['', [Validators.required]]
|
||||||
'',
|
|
||||||
[
|
|
||||||
Validators.required
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{ updateOn: 'blur' }
|
{ updateOn: 'blur' }
|
||||||
);
|
);
|
||||||
@@ -68,17 +68,21 @@ export class LoginUserComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.authenticationService
|
this.authenticationService.login(this.formCtrls.username.value, this.formCtrls.password.value)
|
||||||
.login(this.formCtrls.username.value, this.formCtrls.password.value)
|
.pipe(first())
|
||||||
.pipe(first())
|
.subscribe(
|
||||||
.subscribe(
|
() => {
|
||||||
data => {
|
this.serviceApiAircraft.getListOfAircrafts(false).subscribe();
|
||||||
this.router.navigate([this.returnUrl]);
|
this.serviceApiJumpType.getListOfJumpTypes().subscribe();
|
||||||
},
|
this.serviceApiDropzone.getListOfDropZones(false).subscribe();
|
||||||
error => {
|
this.serviceApiGear.getListOfGears().subscribe();
|
||||||
this.error = error;
|
|
||||||
this.loading = false;
|
this.router.navigate([this.returnUrl]);
|
||||||
}
|
},
|
||||||
);
|
error => {
|
||||||
|
this.error = error;
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<label class="left130">Last jump</label>
|
<label class="left130">Last jump</label>
|
||||||
<span>: {{ lastJump | date: 'yyyy-MM-dd' }}</span>
|
<span>: {{ lastJump }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="paragraph" style="margin-top: 20px;">
|
<div class="paragraph" style="margin-top: 20px;">
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<mat-tab-group mat-align-tabs="left" animationDuration="0ms"
|
<mat-tab-group mat-align-tabs="left" animationDuration="0ms"
|
||||||
(selectedTabChange)="onTabChanged($event);">
|
(selectedIndex)="0" (selectedTabChange)="onTabChanged($event);">
|
||||||
<mat-tab label="Jumps in the last month">
|
<mat-tab label="Jumps in the last month">
|
||||||
<ng-template matTabContent>
|
<ng-template matTabContent>
|
||||||
<div class="containerFlex">
|
<div class="containerFlex">
|
||||||
|
|||||||
@@ -50,8 +50,6 @@ export class SummaryComponent implements OnInit {
|
|||||||
data.byJumpType
|
data.byJumpType
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.tabGroup.selectedIndex = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public refreshStats() {
|
public refreshStats() {
|
||||||
|
|||||||
@@ -45,3 +45,22 @@ export class JumpResp {
|
|||||||
public jumpDate: Date;
|
public jumpDate: Date;
|
||||||
public isSpecial: boolean;
|
public isSpecial: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Jump {
|
||||||
|
constructor(data: any) {
|
||||||
|
Object.assign(this, data);
|
||||||
|
this.jumpDate = new Date(data.jumpDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public id: number;
|
||||||
|
public jumpType: JumpTypeResp;
|
||||||
|
public aircraft: AircraftResp;
|
||||||
|
public dropZone: DropZoneResp;
|
||||||
|
public gear: GearResp;
|
||||||
|
public exitAltitude: number;
|
||||||
|
public deployAltitude: number;
|
||||||
|
public withCutaway: boolean;
|
||||||
|
public notes: string;
|
||||||
|
public jumpDate: Date;
|
||||||
|
public isSpecial: boolean;
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { JumpResp } from './jump';
|
import { Jump, JumpResp } from './jump';
|
||||||
|
|
||||||
export class StatsResp {
|
export class StatsResp {
|
||||||
public simpleSummary: Observable<SimpleSummary>;
|
public simpleSummary: Observable<SimpleSummary>;
|
||||||
@@ -14,14 +14,10 @@ export class StatsResp {
|
|||||||
public statsForLastMonth: Observable<StatsForLastMonthResp>;
|
public statsForLastMonth: Observable<StatsForLastMonthResp>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SimpleSummary {
|
export class SimpleSummaryResp {
|
||||||
constructor(data: any) {
|
constructor(data: any) {
|
||||||
this.totalJumps = data.totalJumps;
|
this.totalJumps = data.totalJumps;
|
||||||
this.totalCutaways = data.totalCutaways;
|
this.totalCutaways = data.totalCutaways;
|
||||||
|
|
||||||
if (data.lastJump !== null) {
|
|
||||||
this.lastJump = new JumpResp(data.lastJump);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public totalJumps: number;
|
public totalJumps: number;
|
||||||
@@ -29,6 +25,17 @@ export class SimpleSummary {
|
|||||||
public lastJump: JumpResp;
|
public lastJump: JumpResp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class SimpleSummary {
|
||||||
|
constructor(data: any) {
|
||||||
|
this.totalJumps = data.totalJumps;
|
||||||
|
this.totalCutaways = data.totalCutaways;
|
||||||
|
}
|
||||||
|
|
||||||
|
public totalJumps: number;
|
||||||
|
public totalCutaways: number;
|
||||||
|
public lastJump: Jump;
|
||||||
|
}
|
||||||
|
|
||||||
export class StatsByDzResp {
|
export class StatsByDzResp {
|
||||||
constructor(data: any) {
|
constructor(data: any) {
|
||||||
Object.assign(this, data);
|
Object.assign(this, data);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { DatePipe } from '@angular/common';
|
|||||||
import { Observable } from "rxjs";
|
import { Observable } from "rxjs";
|
||||||
import { map } from "rxjs/operators";
|
import { map } from "rxjs/operators";
|
||||||
|
|
||||||
import { JumpResp, JumpReq } from "../models/jump";
|
import { JumpResp, JumpReq, Jump } from "../models/jump";
|
||||||
|
|
||||||
import { DateService } from "./date.service";
|
import { DateService } from "./date.service";
|
||||||
import { BaseService } from "./base.service";
|
import { BaseService } from "./base.service";
|
||||||
@@ -21,27 +21,25 @@ export class JumpService extends BaseService {
|
|||||||
private dropzoneService: DropzoneService,
|
private dropzoneService: DropzoneService,
|
||||||
private aircraftService: AircraftService,
|
private aircraftService: AircraftService,
|
||||||
private jumpTypeService: JumpTypeService,
|
private jumpTypeService: JumpTypeService,
|
||||||
private gearService: GearService,) {
|
private gearService: GearService) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GetListOfJumps(): Observable<Array<JumpResp>> {
|
public GetListOfJumps(): Observable<Array<Jump>> {
|
||||||
return this.http.get<Array<JumpResp>>(`${this.apiUrl}/Jump`,
|
return this.http.get<Array<JumpResp>>(`${this.apiUrl}/Jump`,
|
||||||
{ headers: this.headers })
|
{ headers: this.headers })
|
||||||
.pipe(
|
.pipe(map((response) => {
|
||||||
map((response) => {
|
|
||||||
let details = response.map((data) =>
|
let details = response.map((data) =>
|
||||||
{
|
{
|
||||||
let t = new JumpResp(data);
|
let tmp = new Jump(data);
|
||||||
this.dropzoneService.getById(t.dropZoneId).subscribe((d)=> t.dropZone = d );
|
this.dropzoneService.getById(data.dropZoneId).subscribe((d)=> tmp.dropZone = d );
|
||||||
this.aircraftService.getById(t.aircraftId).subscribe((d)=> t.aircraft = d );
|
this.aircraftService.getById(data.aircraftId).subscribe((d)=> tmp.aircraft = d );
|
||||||
this.jumpTypeService.getById(t.jumpTypeId).subscribe((d)=> t.jumpType = d );
|
this.jumpTypeService.getById(data.jumpTypeId).subscribe((d)=> tmp.jumpType = d );
|
||||||
this.gearService.getById(t.gearId).subscribe((d)=> t.gear = d );
|
this.gearService.getById(data.gearId).subscribe((d)=> tmp.gear = d );
|
||||||
return t;
|
return tmp;
|
||||||
});
|
});
|
||||||
return details;
|
return details;
|
||||||
})
|
}));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddListOfJump(selectedJumpType: number,
|
public AddListOfJump(selectedJumpType: number,
|
||||||
@@ -91,10 +89,10 @@ export class JumpService extends BaseService {
|
|||||||
isSpecial);
|
isSpecial);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeleteJump(item: JumpResp) {
|
public DeleteJump(item: Jump) {
|
||||||
this.http.delete(`${this.apiUrl}/Jump/${item.id}`,
|
this.http.delete(`${this.apiUrl}/Jump/${item.id}`,
|
||||||
{ headers: this.headers, })
|
{ headers: this.headers, })
|
||||||
.subscribe((data) => console.log(data));
|
.subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UpdateJump(id: number,
|
public UpdateJump(id: number,
|
||||||
@@ -144,7 +142,7 @@ export class JumpService extends BaseService {
|
|||||||
this.http.post(`${this.apiUrl}/Jump`,
|
this.http.post(`${this.apiUrl}/Jump`,
|
||||||
bodyNewjump,
|
bodyNewjump,
|
||||||
{ headers: this.headers, })
|
{ headers: this.headers, })
|
||||||
.subscribe((data) => console.log(data));
|
.subscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,15 +5,24 @@ import { map } from 'rxjs/operators';
|
|||||||
|
|
||||||
import { StatsByDzResp, StatsByAircraftResp, StatsByJumpTypeResp,
|
import { StatsByDzResp, StatsByAircraftResp, StatsByJumpTypeResp,
|
||||||
StatsByGearResp, StatsByYearResp, StatsForLastMonthResp,
|
StatsByGearResp, StatsByYearResp, StatsForLastMonthResp,
|
||||||
StatsForLastYearResp, SimpleSummary } from '../models/stats';
|
StatsForLastYearResp, SimpleSummary, SimpleSummaryResp } from '../models/stats';
|
||||||
|
|
||||||
import { BaseService } from './base.service';
|
import { BaseService } from './base.service';
|
||||||
|
import { DropzoneService } from "./dropzone.service";
|
||||||
|
import { AircraftService } from "./aircraft.service";
|
||||||
|
import { JumpTypeService } from "./jump-type.service";
|
||||||
|
import { GearService } from "./gear.service";
|
||||||
import { CacheApiKey } from '../models/cache-api-key.enum';
|
import { CacheApiKey } from '../models/cache-api-key.enum';
|
||||||
|
import { Jump } from '../models/jump';
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class StatsService extends BaseService {
|
export class StatsService extends BaseService {
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient,
|
||||||
|
private dropzoneService: DropzoneService,
|
||||||
|
private aircraftService: AircraftService,
|
||||||
|
private jumpTypeService: JumpTypeService,
|
||||||
|
private gearService: GearService) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,10 +38,16 @@ export class StatsService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getSimpleSummary(): Observable<SimpleSummary> {
|
public getSimpleSummary(): Observable<SimpleSummary> {
|
||||||
let callToApi = this.http.get<Array<SimpleSummary>>(`${this.apiUrl}/Stats/Simple`, { headers: this.headers })
|
let callToApi = this.http.get<SimpleSummaryResp>(`${this.apiUrl}/Stats/Simple`, { headers: this.headers })
|
||||||
.pipe(
|
.pipe(map(response => {
|
||||||
map(response => {
|
let tmp = new Jump(response.lastJump);
|
||||||
const stats = new SimpleSummary(response);
|
this.dropzoneService.getById(response.lastJump.dropZoneId).subscribe((d)=> tmp.dropZone = d );
|
||||||
|
this.aircraftService.getById(response.lastJump.aircraftId).subscribe((d)=> tmp.aircraft = d );
|
||||||
|
this.jumpTypeService.getById(response.lastJump.jumpTypeId).subscribe((d)=> tmp.jumpType = d );
|
||||||
|
this.gearService.getById(response.lastJump.gearId).subscribe((d)=> tmp.gear = d );
|
||||||
|
|
||||||
|
let stats = new SimpleSummary(response);
|
||||||
|
stats.lastJump = tmp;
|
||||||
return stats;
|
return stats;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user