From f401bcf87938e65117351ea68869a8cec5d54f0a Mon Sep 17 00:00:00 2001 From: vikingowl Date: Sat, 6 Nov 2021 01:44:39 +0100 Subject: [PATCH] #5 added Hitgroup-Puppet to DamageSite --- package.json | 1 + src/assets/images/icons/hitgroup-puppet.svg | 90 +++++ src/assets/images/icons/hostage_transit.svg | 47 --- src/components/DamageSite.vue | 54 +++ src/components/EqValueGraph.vue | 4 +- src/components/HitgroupPuppet.vue | 364 ++++++++++++++++++ .../{DamageChart.vue => TotalDamage.vue} | 0 src/main.js | 7 +- src/router/index.js | 2 +- src/store/index.js | 13 +- src/utils/ApiRequests.js | 21 +- src/utils/Utils.js | 8 + src/utils/index.js | 17 +- src/views/Match.vue | 19 +- src/views/Player.vue | 12 +- yarn.lock | 8 + 16 files changed, 589 insertions(+), 78 deletions(-) create mode 100644 src/assets/images/icons/hitgroup-puppet.svg delete mode 100644 src/assets/images/icons/hostage_transit.svg create mode 100644 src/components/DamageSite.vue create mode 100644 src/components/HitgroupPuppet.vue rename src/components/{DamageChart.vue => TotalDamage.vue} (100%) diff --git a/package.json b/package.json index 893a547..7875a80 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "bootstrap": "^5.1.2", "core-js": "^3.18.2", "echarts": "^5.2.1", + "jquery": "^3.6.0", "luxon": "^2.0.2", "string-sanitizer": "^2.0.2", "vue": "^3.2.19", diff --git a/src/assets/images/icons/hitgroup-puppet.svg b/src/assets/images/icons/hitgroup-puppet.svg new file mode 100644 index 0000000..2c95c02 --- /dev/null +++ b/src/assets/images/icons/hitgroup-puppet.svg @@ -0,0 +1,90 @@ + + + + + + + + + + + + diff --git a/src/assets/images/icons/hostage_transit.svg b/src/assets/images/icons/hostage_transit.svg deleted file mode 100644 index 5079cc3..0000000 --- a/src/assets/images/icons/hostage_transit.svg +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/components/DamageSite.vue b/src/components/DamageSite.vue new file mode 100644 index 0000000..699bc6a --- /dev/null +++ b/src/components/DamageSite.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/src/components/EqValueGraph.vue b/src/components/EqValueGraph.vue index 34e6bf9..34fed1b 100644 --- a/src/components/EqValueGraph.vue +++ b/src/components/EqValueGraph.vue @@ -8,7 +8,7 @@ + + diff --git a/src/components/DamageChart.vue b/src/components/TotalDamage.vue similarity index 100% rename from src/components/DamageChart.vue rename to src/components/TotalDamage.vue diff --git a/src/main.js b/src/main.js index 178e5bb..9da77be 100644 --- a/src/main.js +++ b/src/main.js @@ -1,8 +1,11 @@ -import { createApp } from 'vue' +import {createApp} from 'vue' import App from './App.vue' import router from './router' import store from './store' import 'bootstrap' import '@/scss/custom.scss' -createApp(App).use(store).use(router).mount('#app') +createApp(App) + .use(store) + .use(router) + .mount('#app') diff --git a/src/router/index.js b/src/router/index.js index 4e45411..301c7b8 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -73,7 +73,7 @@ const routes = [ { path: 'damage', components: { - score: lazyLoadComponent('DamageChart') + score: lazyLoadComponent('DamageSite') } } ] diff --git a/src/store/index.js b/src/store/index.js index 0b98194..6721540 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -5,7 +5,8 @@ export default createStore({ id64: '', vanityUrl: '', matchDetails: {}, - playerDetails: {} + playerDetails: {}, + playersArr: [] }, mutations: { changeId64(state, payload) { @@ -20,6 +21,9 @@ export default createStore({ changePlayerDetails(state, payload) { state.playerDetails = payload.data }, + changePlayesArr(state, payload) { + state.playersArr = payload.data + }, resetId64(state) { state.id64 = '' }, @@ -27,10 +31,13 @@ export default createStore({ state.vanityUrl = '' }, resetMatchDetails(state) { - state.matchDetails = '' + state.matchDetails = {} }, resetPlayerDetails(state) { - state.playerDetails = '' + state.playerDetails = {} + }, + resetPlayesArr(state) { + state.playersArr = [] }, }, actions: { diff --git a/src/utils/ApiRequests.js b/src/utils/ApiRequests.js index 2d90775..be1f81c 100644 --- a/src/utils/ApiRequests.js +++ b/src/utils/ApiRequests.js @@ -55,7 +55,7 @@ export const TrackMe = async (id64, authcode, sharecode = '') => { return [status, statusError] } -export const getPlayerValue = async (match_id) => { +export const GetPlayerValue = async (match_id) => { try { const res = await axios.get(`${API_URL}/match/${match_id}/rounds`) @@ -67,7 +67,7 @@ export const getPlayerValue = async (match_id) => { } } -export const getMatchDetails = async (match_id) => { +export const GetMatchDetails = async (match_id) => { try { const res = await axios.get(`${API_URL}/match/${match_id}`) @@ -80,7 +80,7 @@ export const getMatchDetails = async (match_id) => { } } -export const loadMoreMatches = async (player_id, date) => { +export const LoadMoreMatches = async (player_id, date) => { try { const res = await axios.get(`${API_URL}/player/${player_id}/next/${date}`) @@ -93,7 +93,7 @@ export const loadMoreMatches = async (player_id, date) => { } } -export const getPlayerMeta = async (player_id, limit = 4) => { +export const GetPlayerMeta = async (player_id, limit = 4) => { try { const res = await axios.get(`${API_URL}/player/${player_id}/meta/${limit}`) @@ -105,3 +105,16 @@ export const getPlayerMeta = async (player_id, limit = 4) => { console.log(err.response.status, err.response.statusText) } } + +export const GetWeaponDmg = async (match_id) => { + try { + const res = await axios.get(`${API_URL}/match/${match_id}/weapons`) + + if (res.status === 200) { + return res.data + } + } catch (e) { + // TODO: 400, 404 + console.log(e) + } +} diff --git a/src/utils/Utils.js b/src/utils/Utils.js index 565b6a9..6a93065 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -99,3 +99,11 @@ export const sortObjectValue = (obj, direction = 'asc') => { return sortable } + +export const CreatePlayersArray = (stats) => { + let arr = [] + for (let i in stats) { + arr.push({team_id: stats[i].team_id, player: stats[i].player}) + } + return arr +} diff --git a/src/utils/index.js b/src/utils/index.js index 22a4707..6524065 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -3,7 +3,7 @@ import {GoToLink, GoToMatch, GoToPlayer} from "./GoTo"; import {SaveLastVisitedToLocalStorage} from "./LocalStorage"; import {GetHLTV_1} from "./HLTV"; import {DisplayRank, LoadImage} from "./Display"; -import {getMatchDetails, getPlayerMeta, getPlayerValue, GetUser, loadMoreMatches, TrackMe} from "./ApiRequests"; +import {GetMatchDetails, GetPlayerMeta, GetPlayerValue, GetUser, LoadMoreMatches, TrackMe, GetWeaponDmg} from "./ApiRequests"; import { checkStatEmpty, closeNav, @@ -14,7 +14,8 @@ import { GetWinLoss, setTitle, truncate, - sortObjectValue + sortObjectValue, + CreatePlayersArray } from "./Utils"; export { @@ -32,10 +33,10 @@ export { LoadImage, GetUser, TrackMe, - getPlayerValue, - loadMoreMatches, - getPlayerMeta, - getMatchDetails, + GetPlayerValue, + LoadMoreMatches, + GetPlayerMeta, + GetMatchDetails, setTitle, GetWinLoss, truncate, @@ -45,5 +46,7 @@ export { GetAvgRank, FixMapName, closeNav, - sortObjectValue + sortObjectValue, + GetWeaponDmg, + CreatePlayersArray } diff --git a/src/views/Match.vue b/src/views/Match.vue index c30b6ca..55056d1 100644 --- a/src/views/Match.vue +++ b/src/views/Match.vue @@ -14,10 +14,12 @@
+ :title="data.matchDetails.map" class="map-icon" + > Map icon + class="map-icon" title="Map unknown" + >

{{ data.score[1] }}

@@ -46,10 +48,10 @@ - +

@@ -116,12 +118,13 @@ import {onBeforeMount, onBeforeUnmount, onMounted, reactive, watch} from "vue"; import { closeNav, + CreatePlayersArray, DisplayRank, FixMapName, FormatDuration, FormatFullDate, GetAvgRank, - getMatchDetails, + GetMatchDetails, GoToLink, LoadImage } from "../utils"; @@ -150,7 +153,7 @@ export default { // Functions const GetMatch = async () => { if (matchIdPattern.test(props.match_id)) { - const res = await getMatchDetails(props.match_id) + const res = await GetMatchDetails(props.match_id) if (res.map) document.title = `${FixMapName(res.map)} | csgoWTF` @@ -168,6 +171,10 @@ export default { LoadImage(data.matchDetails.map ? data.matchDetails.map : 'random') + store.commit({ + type: 'changePlayesArr', + data: CreatePlayersArray(data.stats) + }) data.avgRank = GetAvgRank(data.stats) console.log(data.matchDetails) diff --git a/src/views/Player.vue b/src/views/Player.vue index d524940..075f49e 100644 --- a/src/views/Player.vue +++ b/src/views/Player.vue @@ -313,14 +313,14 @@ import { FormatFullDuration, FormatVacDate, GetHLTV_1, - getPlayerMeta, + GetPlayerMeta, GetUser, GetWinLoss, GoToLink, GoToMatch, GoToPlayer, LoadImage, - loadMoreMatches, + LoadMoreMatches, SaveLastVisitedToLocalStorage, setTitle, sortObjectValue, @@ -429,7 +429,7 @@ export default { } const setMoreMatches = async () => { - const res = await loadMoreMatches(store.state.playerDetails.steamid64, data.matches[data.matches.length - 1].date) + const res = await LoadMoreMatches(store.state.playerDetails.steamid64, data.matches[data.matches.length - 1].date) res.matches.forEach(e => data.matches.push(e)) @@ -446,7 +446,7 @@ export default { }, 2000) }) - data.playerMeta = await getPlayerMeta(props.id, displayCounter) + data.playerMeta = await GetPlayerMeta(props.id, displayCounter) } const TrackPlayer = async () => { @@ -512,7 +512,7 @@ export default { watch(() => props.id, async () => { await GetPlayer() - data.playerMeta = await getPlayerMeta(props.id, displayCounter) + data.playerMeta = await GetPlayerMeta(props.id, displayCounter) }) watch(() => data.playerMeta, () => { @@ -530,7 +530,7 @@ export default { wrapper.style.minHeight = height + 'px' await GetPlayer() - data.playerMeta = await getPlayerMeta(props.id, displayCounter) + data.playerMeta = await GetPlayerMeta(props.id, displayCounter) }) return { diff --git a/yarn.lock b/yarn.lock index 60a159a..5b5780d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4037,6 +4037,7 @@ __metadata: echarts: ^5.2.1 eslint: ^6.8.0 eslint-plugin-vue: ^7.19.1 + jquery: ^3.6.0 luxon: ^2.0.2 sass: ^1.42.1 sass-loader: ^10.2.0 @@ -7051,6 +7052,13 @@ fsevents@~2.3.2: languageName: node linkType: hard +"jquery@npm:^3.6.0": + version: 3.6.0 + resolution: "jquery@npm:3.6.0" + checksum: 8fd5fef4aa48fd374ec716dd1c1df1af407814a228e15c1260ca140de3a697c2a77c30c54ff1d238b6a3ab4ddc445ddeef9adce6c6d28e4869d85eb9d3951c0e + languageName: node + linkType: hard + "js-message@npm:1.0.7": version: 1.0.7 resolution: "js-message@npm:1.0.7"