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