fix warcraftlogs api calls unknown item
This commit is contained in:
@@ -2,6 +2,6 @@ import { SubscriptionResponse } from "rpclibrary"
|
||||
|
||||
export class IPubSub<UpdateType>{
|
||||
publish: (topic: string, p: UpdateType) => Promise<void>
|
||||
subscribe: (topic:string, callback: (p:UpdateType)=>any) => Promise<SubscriptionResponse>
|
||||
subscribe: (topic:string, callback: (p:UpdateType)=>any) => Promise<SubscriptionResponse&{data:any}>
|
||||
unsubscribe: (uuid: string) => Promise<void>
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ status="control">
|
||||
|
||||
<nb-card-body>
|
||||
<div>
|
||||
<input name="Character" [(ngModel)]="charactername" placeholder="Character Name" nbInput>
|
||||
|
||||
<input name="Character" [(ngModel)]="charactername" (keydown.enter)="submit()" placeholder="Character Name" nbInput>
|
||||
<nb-select [(selected)]="server" placeholder="Spec">
|
||||
<nb-option *ngFor="let sv of servers" [value]="sv">{{sv}}</nb-option>
|
||||
</nb-select>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Item } from '../../../../../../backend/Types/Types';
|
||||
import { NbToastrService } from '@nebular/theme';
|
||||
|
||||
@Component({
|
||||
selector: 'armory',
|
||||
@@ -14,6 +15,7 @@ export class FrontcraftArmoryComponent implements OnInit{
|
||||
gear:string[] = []
|
||||
|
||||
constructor(
|
||||
private toastr: NbToastrService
|
||||
){}
|
||||
|
||||
async submit(){
|
||||
@@ -22,23 +24,27 @@ export class FrontcraftArmoryComponent implements OnInit{
|
||||
fetch(dataLink).then(raw => raw.json().then((json:any[]) => {
|
||||
if(json.length < 1) return
|
||||
let min = -1
|
||||
let data = null
|
||||
let data
|
||||
|
||||
json.forEach(item => {
|
||||
if(item.startTime > min){
|
||||
if(item.gear[0].name != "Unknown Item"){
|
||||
min = item.startTime
|
||||
data = item
|
||||
}
|
||||
for(let i = json.length-1; i > 0; i--){
|
||||
if(json[i].startTime > min && json[i].gear[0].name != "Unknown Item"){
|
||||
data = json[i]
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
if(!data){
|
||||
this.toastr.danger('Unknown character, or no warcraftlogs', "Error", {
|
||||
duration: 2000
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.gear = data.gear.map(item => {return <Item>{
|
||||
itemname: item.name,
|
||||
iconname: item.icon.replace('.jpg', ''),
|
||||
quality: item.quality.replace(/^\w/, c => c.toUpperCase()),
|
||||
url: "https://classic.wowhead.com/item="+item.id,
|
||||
}})
|
||||
}}).filter(item => item.itemname != "Unknown Item")
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
@@ -35,16 +35,11 @@ status="control">
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<h3>Gear of the last two reported kills <a target="_blank" *ngIf="dataLink != null && dataLink != ''" style="size: 0.5em;" [href]="dataLink">(data)</a></h3>
|
||||
<h3>Gear of the last reported kill <a target="_blank" *ngIf="dataLink != null && dataLink != ''" style="size: 0.5em;" [href]="dataLink">(data)</a></h3>
|
||||
<h5>{{boss2.name}} {{boss2.date | date : 'MMM d @ HH : mm'}}</h5>
|
||||
<ng-container *ngFor="let item of gear2">
|
||||
<wowhead [item]="item"></wowhead><br />
|
||||
</ng-container>
|
||||
|
||||
<h5>{{boss1.name}} {{boss1.date | date : 'MMM d @ HH : mm'}}</h5>
|
||||
<ng-container *ngFor="let item of gear1">
|
||||
<wowhead [item]="item"></wowhead><br />
|
||||
</ng-container>
|
||||
|
||||
</nb-card-body>
|
||||
</nb-card>
|
||||
|
||||
@@ -48,11 +48,18 @@ export class FrontcraftCharacterComponent implements OnInit{
|
||||
|
||||
this.dataLink = "https://classic.warcraftlogs.com:443/v1/parses/character/"+this.char.charactername.replace(/^\w/, c => c.toUpperCase())+"/Gandling/EU?api_key=c698515ab4f592cdb848d80b3abe616c&metric=dps"
|
||||
|
||||
|
||||
|
||||
fetch(this.dataLink).then(raw => raw.json().then((json) => {
|
||||
fetch(this.dataLink).then(raw => raw.json().then((json:any[]) => {
|
||||
if(json.length < 1) return
|
||||
const data = json[0]
|
||||
let data
|
||||
let min = -1
|
||||
|
||||
for(let i = json.length-1; i > 0; i--){
|
||||
if(json[i].startTime > min && json[i].gear[0].name != "Unknown Item"){
|
||||
data = json[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if(!data) return
|
||||
|
||||
this.boss2 = {
|
||||
name: data.encounterName,
|
||||
@@ -63,26 +70,6 @@ export class FrontcraftCharacterComponent implements OnInit{
|
||||
iconname: item.icon.replace('.jpg', ''),
|
||||
quality: item.quality.replace(/^\w/, c => c.toUpperCase()),
|
||||
url: "https://classic.wowhead.com/item="+item.id,
|
||||
tooltip: "unavailable"
|
||||
}}).filter(item => item.itemname != "Unknown Item")
|
||||
}))
|
||||
|
||||
fetch(this.dataLink).then(raw => raw.json().then((json) => {
|
||||
if(json.length < 2) return
|
||||
|
||||
const data = json[1]
|
||||
|
||||
this.boss1 = {
|
||||
name: data.encounterName,
|
||||
date: data.startTime
|
||||
}
|
||||
|
||||
this.gear1 = data.gear.map(item => {return <Item>{
|
||||
itemname: item.name,
|
||||
iconname: item.icon.replace('.jpg', ''),
|
||||
quality: item.quality.replace(/^\w/, c => c.toUpperCase()),
|
||||
url: "https://classic.wowhead.com/item="+item.id,
|
||||
tooltip: "unavailable"
|
||||
}}).filter(item => item.itemname != "Unknown Item")
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user