Skip to content

Commit

Permalink
Merge pull request #191 from SayakMukhopadhyay/eddb-redirect
Browse files Browse the repository at this point in the history
Added EDDB Redirect
  • Loading branch information
SayakMukhopadhyay authored Oct 19, 2020
2 parents 2beff7b + 7d9aa3c commit 3539104
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elitebgs",
"version": "6.1.5",
"version": "6.2.0",
"license": "Apache-2.0",
"scripts": {
"ng": "ng",
Expand Down
2 changes: 1 addition & 1 deletion server/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = '6.1.5';
module.exports = '6.2.0';
13 changes: 12 additions & 1 deletion src/app/main/factions/faction-view.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AfterViewInit, Component, HostBinding, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { Title } from '@angular/platform-browser';
import { FactionsService } from '../../services/factions.service';
import { AuthenticationService } from '../../services/authentication.service';
Expand Down Expand Up @@ -38,6 +38,7 @@ export class FactionViewComponent implements OnInit, AfterViewInit {
constructor(
private factionService: FactionsService,
private route: ActivatedRoute,
private router: Router,
private authenticationService: AuthenticationService,
private titleService: Title,
private ingameIdsService: IngameIdsService,
Expand All @@ -52,6 +53,7 @@ export class FactionViewComponent implements OnInit, AfterViewInit {
}

async ngOnInit() {
this.checkRedirect();
this.getAuthentication();
this.FDevIDs = await this.ingameIdsService.getAllIds().toPromise();
this.chartLoading = true;
Expand All @@ -69,6 +71,15 @@ export class FactionViewComponent implements OnInit, AfterViewInit {
});
}

checkRedirect() {
const routerParam = this.route.snapshot.paramMap.get('factionId')
if (routerParam.startsWith('eddbId-')) {
this.factionService.getFactionIdByEDDBId(routerParam.slice(7)).subscribe(factions => {
this.router.navigateByUrl('/faction/' + factions.docs[0]._id)
})
}
}

async getFactionData(): Promise<EBGSFactionSchemaDetailed[]> {
return await this.factionService
.parseFactionDataId([this.route.snapshot.paramMap.get('factionId')], this.fromDateFilter, this.toDateFilter);
Expand Down
13 changes: 12 additions & 1 deletion src/app/main/stations/station-view.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, HostBinding, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { Title } from '@angular/platform-browser';
import { AuthenticationService } from '../../services/authentication.service';
import { EBGSStationSchemaDetailed, EBGSUser } from '../../typings';
Expand All @@ -21,13 +21,15 @@ export class StationViewComponent implements OnInit {
constructor(
private stationService: StationsService,
private route: ActivatedRoute,
private router: Router,
private authenticationService: AuthenticationService,
private titleService: Title,
private ingameIdsService: IngameIdsService
) {
}

async ngOnInit() {
this.checkRedirect();
this.getAuthentication();
const FDevIDs = await this.ingameIdsService.getAllIds().toPromise();
const station = await this.stationService
Expand All @@ -45,6 +47,15 @@ export class StationViewComponent implements OnInit {
this.titleService.setTitle(this.stationData.name + ' - Elite BGS');
}

checkRedirect() {
const routerParam = this.route.snapshot.paramMap.get('stationId')
if (routerParam.startsWith('eddbId-')) {
this.stationService.getStationIdByEDDBId(routerParam.slice(7)).subscribe(stations => {
this.router.navigateByUrl('/station/' + stations.docs[0]._id)
})
}
}

getAuthentication() {
this.authenticationService
.isAuthenticated()
Expand Down
13 changes: 12 additions & 1 deletion src/app/main/systems/system-view.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AfterViewInit, Component, HostBinding, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { Title } from '@angular/platform-browser';
import { ClrDatagrid } from '@clr/angular';
import { SystemsService } from '../../services/systems.service';
Expand Down Expand Up @@ -34,6 +34,7 @@ export class SystemViewComponent implements OnInit, AfterViewInit {
constructor(
private systemService: SystemsService,
private route: ActivatedRoute,
private router: Router,
private authenticationService: AuthenticationService,
private titleService: Title,
private ingameIdsService: IngameIdsService,
Expand All @@ -48,6 +49,7 @@ export class SystemViewComponent implements OnInit, AfterViewInit {
}

async ngOnInit() {
this.checkRedirect();
this.getAuthentication();
this.FDevIDs = await this.ingameIdsService.getAllIds().toPromise();
this.chartLoading = true;
Expand All @@ -65,6 +67,15 @@ export class SystemViewComponent implements OnInit, AfterViewInit {
});
}

checkRedirect() {
const routerParam = this.route.snapshot.paramMap.get('systemId')
if (routerParam.startsWith('eddbId-')) {
this.systemService.getSystemIdByEDDBId(routerParam.slice(7)).subscribe(systems => {
this.router.navigateByUrl('/system/' + systems.docs[0]._id)
})
}
}

async getSystemData(): Promise<EBGSSystemSchemaDetailed[]> {
return await this.systemService
.parseSystemDataId([this.route.snapshot.paramMap.get('systemId')], this.fromDateFilter, this.toDateFilter);
Expand Down
6 changes: 6 additions & 0 deletions src/app/services/factions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export class FactionsService {
});
}

getFactionIdByEDDBId(eddbid: string): Observable<EBGSFactionsMinimal> {
return this.http.get<EBGSFactionsMinimal>('/api/ebgs/v5/factions', {
params: new HttpParams({encoder: new CustomEncoder()}).set('eddbId', eddbid).set('minimal', 'true')
})
}

parseFactionDataName(factionsList: string[]): Promise<EBGSFactionSchemaDetailed[]> {
return this.parseFactionData(factionsList, 'name');
}
Expand Down
6 changes: 6 additions & 0 deletions src/app/services/stations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export class StationsService {
});
}

getStationIdByEDDBId(eddbid: string): Observable<EBGSStations> {
return this.http.get<EBGSStations>('/api/ebgs/v5/stations', {
params: new HttpParams({encoder: new CustomEncoder()}).set('eddbId', eddbid).set('minimal', 'true')
})
}

parseStationDataName(systemsList: string[]): Promise<EBGSStationSchemaDetailed[]> {
return this.parseStationData(systemsList, 'name');
}
Expand Down
6 changes: 6 additions & 0 deletions src/app/services/systems.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export class SystemsService {
});
}

getSystemIdByEDDBId(eddbid: string): Observable<EBGSSystemsMinimal> {
return this.http.get<EBGSSystemsMinimal>('/api/ebgs/v5/systems', {
params: new HttpParams({encoder: new CustomEncoder()}).set('eddbId', eddbid).set('minimal', 'true')
})
}

parseSystemDataName(systemsList: string[]): Promise<EBGSSystemSchemaDetailed[]> {
return this.parseSystemData(systemsList, 'name');
}
Expand Down
2 changes: 1 addition & 1 deletion src/environments/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = '6.1.5';
export const version = '6.2.0';

0 comments on commit 3539104

Please sign in to comment.