updated api-call error-handling
This commit is contained in:
@@ -31,9 +31,11 @@ export default {
|
|||||||
|
|
||||||
const getWeaponDamage = async () => {
|
const getWeaponDamage = async () => {
|
||||||
const resData = await GetWeaponDmg(store, store.state.matchDetails.match_id)
|
const resData = await GetWeaponDmg(store, store.state.matchDetails.match_id)
|
||||||
|
if (resData !== null) {
|
||||||
data.equipment_map = resData.equipment_map
|
data.equipment_map = resData.equipment_map
|
||||||
data.stats = resData.stats
|
data.stats = resData.stats
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getWeaponDamage()
|
getWeaponDamage()
|
||||||
|
@@ -30,8 +30,10 @@ export default {
|
|||||||
|
|
||||||
const getWeaponDamage = async () => {
|
const getWeaponDamage = async () => {
|
||||||
const resData = await GetWeaponDmg(store, store.state.matchDetails.match_id)
|
const resData = await GetWeaponDmg(store, store.state.matchDetails.match_id)
|
||||||
|
if (resData !== null) {
|
||||||
data.spray = resData.spray
|
data.spray = resData.spray
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getWeaponDamage()
|
getWeaponDamage()
|
||||||
|
@@ -55,6 +55,8 @@ export default {
|
|||||||
|
|
||||||
const parseObject = async () => {
|
const parseObject = async () => {
|
||||||
data.rounds = await GetPlayerValue(store, store.state.matchDetails.match_id)
|
data.rounds = await GetPlayerValue(store, store.state.matchDetails.match_id)
|
||||||
|
if (data.rounds === null)
|
||||||
|
data.rounds = {}
|
||||||
|
|
||||||
for (const round in data.rounds) {
|
for (const round in data.rounds) {
|
||||||
for (const player in data.rounds[round]) {
|
for (const player in data.rounds[round]) {
|
||||||
|
@@ -122,7 +122,7 @@ export default {
|
|||||||
if (store.state.id64 !== '' || store.state.vanityUrl !== '') {
|
if (store.state.id64 !== '' || store.state.vanityUrl !== '') {
|
||||||
const resData = await GetUser(store, store.state.vanityUrl || store.state.id64)
|
const resData = await GetUser(store, store.state.vanityUrl || store.state.id64)
|
||||||
|
|
||||||
if (resData) {
|
if (resData !== null) {
|
||||||
data.searchInput = ''
|
data.searchInput = ''
|
||||||
document.activeElement.blur()
|
document.activeElement.blur()
|
||||||
|
|
||||||
|
@@ -15,47 +15,29 @@ export const GetUser = async (store, id) => {
|
|||||||
response = res.data
|
response = res.data
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
let message = ''
|
||||||
|
|
||||||
switch (err.response.status) {
|
switch (err.response.status) {
|
||||||
case STATUS.BAD_REQUEST:
|
case STATUS.BAD_REQUEST:
|
||||||
store.commit({
|
message = 'Bad request'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.BAD_REQUEST,
|
|
||||||
message: 'Bad request',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
case STATUS.NOT_FOUND:
|
case STATUS.NOT_FOUND:
|
||||||
store.commit({
|
message = 'Player not found'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.NOT_FOUND,
|
|
||||||
message: 'Player not found',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
case STATUS.INTERNAL_SERVER_ERROR:
|
case STATUS.INTERNAL_SERVER_ERROR:
|
||||||
store.commit({
|
message = 'Unable to get meta-stats or player'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.INTERNAL_SERVER_ERROR,
|
|
||||||
message: 'Unable to get meta-stats or player',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
message = 'An unknown error occurred'
|
||||||
|
}
|
||||||
store.commit({
|
store.commit({
|
||||||
type: 'changeInfoState',
|
type: 'changeInfoState',
|
||||||
data: {
|
data: {
|
||||||
statuscode: err.response.status,
|
statuscode: err.response.status,
|
||||||
message: 'An unknown error occured',
|
message: message,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return response
|
return response
|
||||||
@@ -72,47 +54,29 @@ export const GetPlayerMeta = async (store, player_id, limit = 4) => {
|
|||||||
response = res.data
|
response = res.data
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
let message = ''
|
||||||
|
|
||||||
switch (err.response.status) {
|
switch (err.response.status) {
|
||||||
case STATUS.BAD_REQUEST:
|
case STATUS.BAD_REQUEST:
|
||||||
store.commit({
|
message = 'Bad request'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.BAD_REQUEST,
|
|
||||||
message: 'Bad request',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
case STATUS.NOT_FOUND:
|
case STATUS.NOT_FOUND:
|
||||||
store.commit({
|
message = 'Player not found'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.BAD_REQUEST,
|
|
||||||
message: 'Player not found',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
case STATUS.INTERNAL_SERVER_ERROR:
|
case STATUS.INTERNAL_SERVER_ERROR:
|
||||||
store.commit({
|
message = 'Unable to get player meta'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.INTERNAL_SERVER_ERROR,
|
|
||||||
message: 'Unable to get player meta',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
message = 'An unknown error occurred'
|
||||||
|
}
|
||||||
store.commit({
|
store.commit({
|
||||||
type: 'changeInfoState',
|
type: 'changeInfoState',
|
||||||
data: {
|
data: {
|
||||||
statuscode: err.response.status,
|
statuscode: err.response.status,
|
||||||
message: 'An unknown error occured',
|
message: message,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return response
|
return response
|
||||||
@@ -129,47 +93,29 @@ export const LoadMoreMatches = async (store, player_id, date) => {
|
|||||||
response = res.data
|
response = res.data
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
let message = ''
|
||||||
|
|
||||||
switch (err.response.status) {
|
switch (err.response.status) {
|
||||||
case STATUS.BAD_REQUEST:
|
case STATUS.BAD_REQUEST:
|
||||||
store.commit({
|
message = 'Bad request'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.BAD_REQUEST,
|
|
||||||
message: 'Bad request',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
case STATUS.NOT_FOUND:
|
case STATUS.NOT_FOUND:
|
||||||
store.commit({
|
message = 'Player not found'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.NOT_FOUND,
|
|
||||||
message: 'Player not found',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
case STATUS.INTERNAL_SERVER_ERROR:
|
case STATUS.INTERNAL_SERVER_ERROR:
|
||||||
store.commit({
|
message = 'Unable to get meta-stats or player'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.INTERNAL_SERVER_ERROR,
|
|
||||||
message: 'Unable to get meta-stats or player',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
message = 'An unknown error occurred'
|
||||||
|
}
|
||||||
store.commit({
|
store.commit({
|
||||||
type: 'changeInfoState',
|
type: 'changeInfoState',
|
||||||
data: {
|
data: {
|
||||||
statuscode: err.response.status,
|
statuscode: err.response.status,
|
||||||
message: 'An unknown error occured',
|
message: message,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return response
|
return response
|
||||||
@@ -177,118 +123,63 @@ export const LoadMoreMatches = async (store, player_id, date) => {
|
|||||||
|
|
||||||
// /player/<id>/track POST Track player <id> FORM_DATA: authcode, [sharecode]
|
// /player/<id>/track POST Track player <id> FORM_DATA: authcode, [sharecode]
|
||||||
export const TrackMe = async (store, id64, authcode, sharecode = '') => {
|
export const TrackMe = async (store, id64, authcode, sharecode = '') => {
|
||||||
|
let status = null
|
||||||
|
let message = ''
|
||||||
|
|
||||||
if (sharecode !== '' && !SHARECODE_REGEX.test(sharecode)) {
|
if (sharecode !== '' && !SHARECODE_REGEX.test(sharecode)) {
|
||||||
store.commit({
|
status = STATUS.IM_A_TEAPOT
|
||||||
type: 'changeInfoState',
|
message = 'Sharecode is invalid'
|
||||||
data: {
|
|
||||||
statuscode: STATUS.IM_A_TEAPOT,
|
|
||||||
message: 'Sharecode is invalid or missing',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return STATUS.IM_A_TEAPOT
|
|
||||||
}
|
}
|
||||||
if (authcode === '' || !AUTHCODE_REGEX.test(authcode.toUpperCase())) {
|
if (authcode === '' || !AUTHCODE_REGEX.test(authcode.toUpperCase())) {
|
||||||
store.commit({
|
status = STATUS.IM_A_TEAPOT
|
||||||
type: 'changeInfoState',
|
message = 'Authcode is invalid'
|
||||||
data: {
|
|
||||||
statuscode: STATUS.IM_A_TEAPOT,
|
|
||||||
message: 'Authcode is invalid or missing',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return STATUS.IM_A_TEAPOT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status === null && message === '') {
|
||||||
await axios
|
await axios
|
||||||
.post(`${API_URL}/player/${id64}/track`, `authcode=${authcode.toUpperCase()}&sharecode=${sharecode}`)
|
.post(`${API_URL}/player/${id64}/track`, `authcode=${authcode.toUpperCase()}&sharecode=${sharecode}`)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === STATUS.ACCEPTED) {
|
if (res.status === STATUS.ACCEPTED) {
|
||||||
store.commit({
|
status = STATUS.ACCEPTED
|
||||||
type: 'changeInfoState',
|
message = 'Tracking successful'
|
||||||
data: {
|
|
||||||
statuscode: STATUS.ACCEPTED,
|
|
||||||
message: 'Tracking successful',
|
|
||||||
type: 'success'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return STATUS.ACCEPTED
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
switch (err.response.status) {
|
switch (err.response.status) {
|
||||||
case STATUS.BAD_REQUEST:
|
case STATUS.BAD_REQUEST:
|
||||||
store.commit({
|
message = 'Invalid arguments'
|
||||||
type: 'changeInfoState',
|
break
|
||||||
data: {
|
|
||||||
statuscode: STATUS.BAD_REQUEST,
|
|
||||||
message: 'Invalid arguments',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return STATUS.BAD_REQUEST
|
|
||||||
case STATUS.NOT_FOUND:
|
case STATUS.NOT_FOUND:
|
||||||
store.commit({
|
message = 'Player not found'
|
||||||
type: 'changeInfoState',
|
break
|
||||||
data: {
|
|
||||||
statuscode: STATUS.NOT_FOUND,
|
|
||||||
message: 'Player not found',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return STATUS.NOT_FOUND
|
|
||||||
case STATUS.SERVICE_UNAVAILABLE:
|
case STATUS.SERVICE_UNAVAILABLE:
|
||||||
store.commit({
|
message = 'Service currently unavailable - Please try again later'
|
||||||
type: 'changeInfoState',
|
break
|
||||||
data: {
|
|
||||||
statuscode: STATUS.SERVICE_UNAVAILABLE,
|
|
||||||
message: 'Service currently unavailable - Please try again later',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return STATUS.SERVICE_UNAVAILABLE
|
|
||||||
case STATUS.UNAUTHORIZED:
|
case STATUS.UNAUTHORIZED:
|
||||||
store.commit({
|
message = 'Authcode is invalid'
|
||||||
type: 'changeInfoState',
|
break
|
||||||
data: {
|
|
||||||
statuscode: STATUS.UNAUTHORIZED,
|
|
||||||
message: 'Authcode is invalid',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return STATUS.UNAUTHORIZED
|
|
||||||
case STATUS.PRECONDITION_FAILED:
|
case STATUS.PRECONDITION_FAILED:
|
||||||
store.commit({
|
message = 'Sharecode is invalid or missing'
|
||||||
type: 'changeInfoState',
|
break
|
||||||
data: {
|
|
||||||
statuscode: STATUS.PRECONDITION_FAILED,
|
|
||||||
message: 'Sharecode is invalid or missing',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return STATUS.PRECONDITION_FAILED
|
|
||||||
case STATUS.INTERNAL_SERVER_ERROR:
|
case STATUS.INTERNAL_SERVER_ERROR:
|
||||||
store.commit({
|
message = 'Service is currently unavailable - Please try again later'
|
||||||
type: 'changeInfoState',
|
break
|
||||||
data: {
|
|
||||||
statuscode: STATUS.INTERNAL_SERVER_ERROR,
|
|
||||||
message: 'Service currently unavailable - please try again later',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return STATUS.INTERNAL_SERVER_ERROR
|
|
||||||
default:
|
default:
|
||||||
|
message = 'An unknown error occurred'
|
||||||
|
}
|
||||||
|
status = err.response.status
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
store.commit({
|
store.commit({
|
||||||
type: 'changeInfoState',
|
type: 'changeInfoState',
|
||||||
data: {
|
data: {
|
||||||
statuscode: err.response.status,
|
statuscode: status,
|
||||||
message: 'An unknown error occured',
|
message: message,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return err.response.status
|
return status
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// /match/<id> GET returns details for match <id>
|
// /match/<id> GET returns details for match <id>
|
||||||
@@ -302,47 +193,29 @@ export const GetMatchDetails = async (store, match_id) => {
|
|||||||
response = res.data
|
response = res.data
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
let message = ''
|
||||||
|
|
||||||
switch (err.response.status) {
|
switch (err.response.status) {
|
||||||
case STATUS.BAD_REQUEST:
|
case STATUS.BAD_REQUEST:
|
||||||
store.commit({
|
message = 'Error parsing matchID'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.BAD_REQUEST,
|
|
||||||
message: 'Error parsing matchID',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
case STATUS.NOT_FOUND:
|
case STATUS.NOT_FOUND:
|
||||||
store.commit({
|
message = 'Match not found'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.NOT_FOUND,
|
|
||||||
message: 'Match not found',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
case STATUS.INTERNAL_SERVER_ERROR:
|
case STATUS.INTERNAL_SERVER_ERROR:
|
||||||
store.commit({
|
message = 'Unable to get match data'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.INTERNAL_SERVER_ERROR,
|
|
||||||
message: 'Unable to get match data',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
message = 'An unknown error occurred'
|
||||||
|
}
|
||||||
store.commit({
|
store.commit({
|
||||||
type: 'changeInfoState',
|
type: 'changeInfoState',
|
||||||
data: {
|
data: {
|
||||||
statuscode: err.response.status,
|
statuscode: err.response.status,
|
||||||
message: 'An unknown error occured',
|
message: message,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return response
|
return response
|
||||||
@@ -359,47 +232,29 @@ export const GetPlayerValue = async (store, match_id) => {
|
|||||||
response = res.data
|
response = res.data
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
let message = ''
|
||||||
|
|
||||||
switch (err.response.status) {
|
switch (err.response.status) {
|
||||||
case STATUS.BAD_REQUEST:
|
case STATUS.BAD_REQUEST:
|
||||||
store.commit({
|
message = 'Error parsing matchID'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.BAD_REQUEST,
|
|
||||||
message: 'Error parsing matchID',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
case STATUS.NOT_FOUND:
|
case STATUS.NOT_FOUND:
|
||||||
store.commit({
|
message = 'Match not found'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.NOT_FOUND,
|
|
||||||
message: 'Match not found',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
case STATUS.INTERNAL_SERVER_ERROR:
|
case STATUS.INTERNAL_SERVER_ERROR:
|
||||||
store.commit({
|
message = 'Unable to get match data'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.INTERNAL_SERVER_ERROR,
|
|
||||||
message: 'Unable to get match data',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
message = 'An unknown error occurred'
|
||||||
|
}
|
||||||
store.commit({
|
store.commit({
|
||||||
type: 'changeInfoState',
|
type: 'changeInfoState',
|
||||||
data: {
|
data: {
|
||||||
statuscode: err.response.status,
|
statuscode: err.response.status,
|
||||||
message: 'An unknown error occured',
|
message: message,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return response
|
return response
|
||||||
@@ -416,47 +271,29 @@ export const GetWeaponDmg = async (store, match_id) => {
|
|||||||
response = res.data
|
response = res.data
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
let message = ''
|
||||||
|
|
||||||
switch (err.response.status) {
|
switch (err.response.status) {
|
||||||
case STATUS.BAD_REQUEST:
|
case STATUS.BAD_REQUEST:
|
||||||
store.commit({
|
message = 'Bad request'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.BAD_REQUEST,
|
|
||||||
message: 'Bad request',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
case STATUS.NOT_FOUND:
|
case STATUS.NOT_FOUND:
|
||||||
store.commit({
|
message = 'Weapon damage not found'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.NOT_FOUND,
|
|
||||||
message: 'Weapon damage not found',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
case STATUS.INTERNAL_SERVER_ERROR:
|
case STATUS.INTERNAL_SERVER_ERROR:
|
||||||
store.commit({
|
message = 'Unable to get weapon damage'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.INTERNAL_SERVER_ERROR,
|
|
||||||
message: 'Unable to get weapon damage',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
message = 'An unknown error occurred'
|
||||||
|
}
|
||||||
store.commit({
|
store.commit({
|
||||||
type: 'changeInfoState',
|
type: 'changeInfoState',
|
||||||
data: {
|
data: {
|
||||||
statuscode: err.response.status,
|
statuscode: err.response.status,
|
||||||
message: 'An unknown error occured',
|
message: message,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return response
|
return response
|
||||||
@@ -473,37 +310,26 @@ export const GetMatches = async (store) => {
|
|||||||
response = res.data
|
response = res.data
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
let message = ''
|
||||||
|
|
||||||
switch (err.response.status) {
|
switch (err.response.status) {
|
||||||
case STATUS.BAD_REQUEST:
|
case STATUS.BAD_REQUEST:
|
||||||
store.commit({
|
message = 'Bad request'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.BAD_REQUEST,
|
|
||||||
message: 'Bad request',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
case STATUS.INTERNAL_SERVER_ERROR:
|
case STATUS.INTERNAL_SERVER_ERROR:
|
||||||
store.commit({
|
message = 'Unable to marshal JSON'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.INTERNAL_SERVER_ERROR,
|
|
||||||
message: 'Unable to marshal JSON',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
message = 'An unknown error occurred'
|
||||||
|
}
|
||||||
store.commit({
|
store.commit({
|
||||||
type: 'changeInfoState',
|
type: 'changeInfoState',
|
||||||
data: {
|
data: {
|
||||||
statuscode: err.response.status,
|
statuscode: err.response.status,
|
||||||
message: 'An unknown error occured',
|
message: message,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return response
|
return response
|
||||||
@@ -520,37 +346,26 @@ export const LoadMoreMatchesExplore = async (store, date) => {
|
|||||||
response = res.data
|
response = res.data
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
let message = ''
|
||||||
|
|
||||||
switch (err.response.status) {
|
switch (err.response.status) {
|
||||||
case STATUS.BAD_REQUEST:
|
case STATUS.BAD_REQUEST:
|
||||||
store.commit({
|
message = 'Bad request'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.BAD_REQUEST,
|
|
||||||
message: 'Bad request',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
case STATUS.INTERNAL_SERVER_ERROR:
|
case STATUS.INTERNAL_SERVER_ERROR:
|
||||||
store.commit({
|
message = 'Unable to load more matches'
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.INTERNAL_SERVER_ERROR,
|
|
||||||
message: 'Unable to load more matches',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
message = 'An unknown error occurred'
|
||||||
|
}
|
||||||
store.commit({
|
store.commit({
|
||||||
type: 'changeInfoState',
|
type: 'changeInfoState',
|
||||||
data: {
|
data: {
|
||||||
statuscode: err.response.status,
|
statuscode: err.response.status,
|
||||||
message: 'An unknown error occured',
|
message: message,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
@@ -45,6 +45,7 @@ export default {
|
|||||||
const setMoreMatches = async () => {
|
const setMoreMatches = async () => {
|
||||||
const res = await LoadMoreMatchesExplore(store, data.matches[data.matches.length - 1].date)
|
const res = await LoadMoreMatchesExplore(store, data.matches[data.matches.length - 1].date)
|
||||||
|
|
||||||
|
if (res !== null)
|
||||||
res.forEach(e => data.matches.push(e))
|
res.forEach(e => data.matches.push(e))
|
||||||
|
|
||||||
scrollToPos(window.scrollY)
|
scrollToPos(window.scrollY)
|
||||||
@@ -55,7 +56,7 @@ export default {
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
data.matches = await GetMatches(store)
|
data.matches = await GetMatches(store)
|
||||||
|
|
||||||
if (data.matches) {
|
if (data.matches !== null) {
|
||||||
if (data.matches[0].map) {
|
if (data.matches[0].map) {
|
||||||
await LoadImage(data.matches[0].map)
|
await LoadImage(data.matches[0].map)
|
||||||
} else if (!data.matches[0].map && MatchNotParsedTime(data.matches[0].date) && data.matches[1].map) {
|
} else if (!data.matches[0].map && MatchNotParsedTime(data.matches[0].date) && data.matches[1].map) {
|
||||||
|
@@ -196,7 +196,7 @@ export default {
|
|||||||
if (matchIdPattern.test(props.match_id)) {
|
if (matchIdPattern.test(props.match_id)) {
|
||||||
const res = await GetMatchDetails(store, props.match_id)
|
const res = await GetMatchDetails(store, props.match_id)
|
||||||
|
|
||||||
if (res) {
|
if (res !== null) {
|
||||||
if (res.map)
|
if (res.map)
|
||||||
document.title = `${FixMapName(res.map)} ► ${res.score[0]} : ${res.score[1]} ◄ ${DateTime.fromSeconds(res.date).toLocaleString(DateTime.DATETIME_SHORT)} | csgoWTF`
|
document.title = `${FixMapName(res.map)} ► ${res.score[0]} : ${res.score[1]} ◄ ${DateTime.fromSeconds(res.date).toLocaleString(DateTime.DATETIME_SHORT)} | csgoWTF`
|
||||||
else
|
else
|
||||||
|
@@ -165,7 +165,7 @@ import {FOOTER_HEIGHT, NAV_HEIGHT} from "@/constants";
|
|||||||
import MatchesTable from "@/components/MatchesTable";
|
import MatchesTable from "@/components/MatchesTable";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import PlayerSideInfo from "@/components/PlayerSideInfo";
|
import PlayerSideInfo from "@/components/PlayerSideInfo";
|
||||||
import {StatusCodes as STATUS} from "http-status-codes/build/cjs/status-codes";
|
import {StatusCodes as STATUS} from "http-status-codes";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Player',
|
name: 'Player',
|
||||||
@@ -258,7 +258,7 @@ export default {
|
|||||||
if (props.id) {
|
if (props.id) {
|
||||||
const resData = await GetUser(store, props.id)
|
const resData = await GetUser(store, props.id)
|
||||||
|
|
||||||
if (resData) {
|
if (resData !== null) {
|
||||||
if (resData.steamid64 !== store.state.playerDetails.steamid64 || reset) {
|
if (resData.steamid64 !== store.state.playerDetails.steamid64 || reset) {
|
||||||
resData.name = ProcessName(resData.name)
|
resData.name = ProcessName(resData.name)
|
||||||
|
|
||||||
@@ -277,6 +277,7 @@ export default {
|
|||||||
const setMoreMatches = async () => {
|
const setMoreMatches = async () => {
|
||||||
const res = await LoadMoreMatches(store, store.state.playerDetails.steamid64, data.matches[data.matches.length - 1].date)
|
const res = await LoadMoreMatches(store, store.state.playerDetails.steamid64, data.matches[data.matches.length - 1].date)
|
||||||
|
|
||||||
|
if (res !== null)
|
||||||
await res.matches.forEach(e => data.matches.push(e))
|
await res.matches.forEach(e => data.matches.push(e))
|
||||||
|
|
||||||
scrollToPos(window.scrollY)
|
scrollToPos(window.scrollY)
|
||||||
@@ -302,58 +303,49 @@ export default {
|
|||||||
})
|
})
|
||||||
|
|
||||||
data.playerMeta = await GetPlayerMeta(store, props.id, displayCounter)
|
data.playerMeta = await GetPlayerMeta(store, props.id, displayCounter)
|
||||||
|
if (data.playerMeta === null)
|
||||||
|
data.playerMeta = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const TrackPlayer = async () => {
|
const TrackPlayer = async () => {
|
||||||
let res
|
let message = ''
|
||||||
|
|
||||||
if (data.matches === []) {
|
if (data.matches.length === 0) {
|
||||||
if (data.userData.sharecode !== '') {
|
if (data.userData.sharecode === '') {
|
||||||
if (data.userData.authcode !== '') {
|
message = 'Sharecode is missing'
|
||||||
res = await TrackMe(store, store.state.playerDetails.steamid64, data.userData.authcode, data.userData.sharecode)
|
|
||||||
} else {
|
|
||||||
store.commit({
|
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.IM_A_TEAPOT,
|
|
||||||
message: 'Authcode is invalid or missing',
|
|
||||||
type: 'error'
|
|
||||||
}
|
}
|
||||||
})
|
if (data.userData.authcode === '') {
|
||||||
|
message = 'Authcode is missing'
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
store.commit({
|
if (data.userData.authcode === '') {
|
||||||
type: 'changeInfoState',
|
message = 'Authcode is missing'
|
||||||
data: {
|
|
||||||
statuscode: STATUS.IM_A_TEAPOT,
|
|
||||||
message: 'Sharecode is invalid or missing',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (data.userData.authcode !== '') {
|
|
||||||
res = await TrackMe(store, store.state.playerDetails.steamid64, data.userData.authcode, data.userData.sharecode)
|
|
||||||
} else {
|
|
||||||
store.commit({
|
|
||||||
type: 'changeInfoState',
|
|
||||||
data: {
|
|
||||||
statuscode: STATUS.IM_A_TEAPOT,
|
|
||||||
message: 'Authcode is invalid or missing',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res === 202) {
|
if (message !== '') {
|
||||||
|
store.commit({
|
||||||
|
type: 'changeInfoState',
|
||||||
|
data: {
|
||||||
|
statuscode: STATUS.IM_A_TEAPOT,
|
||||||
|
message: message,
|
||||||
|
type: 'error'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const res = await TrackMe(store, store.state.playerDetails.steamid64, data.userData.authcode, data.userData.sharecode)
|
||||||
|
|
||||||
|
if (res !== null && res === STATUS.ACCEPTED) {
|
||||||
location.reload()
|
location.reload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
watch(() => props.id, async () => {
|
watch(() => props.id, async () => {
|
||||||
await GetPlayer()
|
await GetPlayer()
|
||||||
data.playerMeta = await GetPlayerMeta(store, props.id, displayCounter)
|
data.playerMeta = await GetPlayerMeta(store, props.id, displayCounter)
|
||||||
|
if (data.playerMeta === null)
|
||||||
|
data.playerMeta = {}
|
||||||
})
|
})
|
||||||
|
|
||||||
// watch(() => data.playerMeta, () => {
|
// watch(() => data.playerMeta, () => {
|
||||||
@@ -367,6 +359,8 @@ export default {
|
|||||||
|
|
||||||
await GetPlayer()
|
await GetPlayer()
|
||||||
data.playerMeta = await GetPlayerMeta(store, props.id, displayCounter)
|
data.playerMeta = await GetPlayerMeta(store, props.id, displayCounter)
|
||||||
|
if (data.playerMeta === null)
|
||||||
|
data.playerMeta = {}
|
||||||
|
|
||||||
scrollToPos(store.state.scroll_state)
|
scrollToPos(store.state.scroll_state)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user