From 7df6d5941af007c212d37b9b36bd1e99d291e1ac Mon Sep 17 00:00:00 2001 From: Sayak Mukhopadhyay Date: Mon, 19 Oct 2020 15:14:16 +0530 Subject: [PATCH 1/2] EliteBGS UI can now redirect from EDDB Ids as the url --- src/app/main/factions/faction-view.component.ts | 13 ++++++++++++- src/app/main/stations/station-view.component.ts | 13 ++++++++++++- src/app/main/systems/system-view.component.ts | 13 ++++++++++++- src/app/services/factions.service.ts | 6 ++++++ src/app/services/stations.service.ts | 6 ++++++ src/app/services/systems.service.ts | 6 ++++++ 6 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/app/main/factions/faction-view.component.ts b/src/app/main/factions/faction-view.component.ts index 8b92bcff..15dafadc 100644 --- a/src/app/main/factions/faction-view.component.ts +++ b/src/app/main/factions/faction-view.component.ts @@ -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'; @@ -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, @@ -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; @@ -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 { return await this.factionService .parseFactionDataId([this.route.snapshot.paramMap.get('factionId')], this.fromDateFilter, this.toDateFilter); diff --git a/src/app/main/stations/station-view.component.ts b/src/app/main/stations/station-view.component.ts index ba0d10ff..6a389d45 100644 --- a/src/app/main/stations/station-view.component.ts +++ b/src/app/main/stations/station-view.component.ts @@ -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'; @@ -21,6 +21,7 @@ export class StationViewComponent implements OnInit { constructor( private stationService: StationsService, private route: ActivatedRoute, + private router: Router, private authenticationService: AuthenticationService, private titleService: Title, private ingameIdsService: IngameIdsService @@ -28,6 +29,7 @@ export class StationViewComponent implements OnInit { } async ngOnInit() { + this.checkRedirect(); this.getAuthentication(); const FDevIDs = await this.ingameIdsService.getAllIds().toPromise(); const station = await this.stationService @@ -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() diff --git a/src/app/main/systems/system-view.component.ts b/src/app/main/systems/system-view.component.ts index a4411e07..56c3327c 100644 --- a/src/app/main/systems/system-view.component.ts +++ b/src/app/main/systems/system-view.component.ts @@ -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'; @@ -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, @@ -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; @@ -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 { return await this.systemService .parseSystemDataId([this.route.snapshot.paramMap.get('systemId')], this.fromDateFilter, this.toDateFilter); diff --git a/src/app/services/factions.service.ts b/src/app/services/factions.service.ts index b564b5e7..b5c43e2d 100644 --- a/src/app/services/factions.service.ts +++ b/src/app/services/factions.service.ts @@ -16,6 +16,12 @@ export class FactionsService { }); } + getFactionIdByEDDBId(eddbid: string): Observable { + return this.http.get('/api/ebgs/v5/factions', { + params: new HttpParams({encoder: new CustomEncoder()}).set('eddbId', eddbid).set('minimal', 'true') + }) + } + parseFactionDataName(factionsList: string[]): Promise { return this.parseFactionData(factionsList, 'name'); } diff --git a/src/app/services/stations.service.ts b/src/app/services/stations.service.ts index 5288e5d3..30e22b11 100644 --- a/src/app/services/stations.service.ts +++ b/src/app/services/stations.service.ts @@ -16,6 +16,12 @@ export class StationsService { }); } + getStationIdByEDDBId(eddbid: string): Observable { + return this.http.get('/api/ebgs/v5/stations', { + params: new HttpParams({encoder: new CustomEncoder()}).set('eddbId', eddbid).set('minimal', 'true') + }) + } + parseStationDataName(systemsList: string[]): Promise { return this.parseStationData(systemsList, 'name'); } diff --git a/src/app/services/systems.service.ts b/src/app/services/systems.service.ts index 737a5001..f203950c 100644 --- a/src/app/services/systems.service.ts +++ b/src/app/services/systems.service.ts @@ -16,6 +16,12 @@ export class SystemsService { }); } + getSystemIdByEDDBId(eddbid: string): Observable { + return this.http.get('/api/ebgs/v5/systems', { + params: new HttpParams({encoder: new CustomEncoder()}).set('eddbId', eddbid).set('minimal', 'true') + }) + } + parseSystemDataName(systemsList: string[]): Promise { return this.parseSystemData(systemsList, 'name'); } From 7d9aa3cc19f6f082ab0435999e697c4d73187a72 Mon Sep 17 00:00:00 2001 From: Sayak Mukhopadhyay Date: Mon, 19 Oct 2020 15:16:07 +0530 Subject: [PATCH 2/2] Bumped version --- package-lock.json | 2 +- package.json | 2 +- server/version.js | 2 +- src/environments/version.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8904e5ca..7826a3b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "elitebgs", - "version": "6.1.5", + "version": "6.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 25bfe7a4..3e9bb594 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "elitebgs", - "version": "6.1.5", + "version": "6.2.0", "license": "Apache-2.0", "scripts": { "ng": "ng", diff --git a/server/version.js b/server/version.js index f931f1d6..0d069d7d 100644 --- a/server/version.js +++ b/server/version.js @@ -1 +1 @@ -module.exports = '6.1.5'; +module.exports = '6.2.0'; diff --git a/src/environments/version.ts b/src/environments/version.ts index 7e7e4a7b..485c5d64 100644 --- a/src/environments/version.ts +++ b/src/environments/version.ts @@ -1 +1 @@ -export const version = '6.1.5'; +export const version = '6.2.0';