DetailPage.vue
6.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<template>
<div class="detail">
<div class="header">
<h1>{{ userId }}</h1>
</div>
<div class="body">
<div class="assist">
<b-button v-b-toggle.collapse-predict variant="outline-primary">Pick Assistant</b-button>
<b-collapse id="collapse-predict">
<b-button v-b-toggle.collapse-team variant="outline-primary">Team</b-button>
<b-collapse id="collapse-team">
<h1>Team Combination</h1>
<h1 v-if="teamData">{{ teamData }}</h1>
<span v-for="championId in championList">
<button v-on:click="inputTeamData(championId)">
<img v-bind:src="splashLoader(championId)">
</button>
</span>
</b-collapse>
<b-button v-b-toggle.collapse-enemy variant="outline-primary">Enemy</b-button>
<b-collapse id="collapse-enemy">
<h1>Enemy Combination</h1>
<h1 v-if="enemyData">{{ enemyData }}</h1>
<span v-for="championId in championList">
<button v-on:click="inputEnemyData(championId)">
<img v-bind:src="splashLoader(championId)">
</button>
</span>
</b-collapse>
<b-button v-on:click="makePredict(userPk)">Predict</b-button>
<div v-for="result in predictResult">
<b-card :title="nameTranslator(result['champion'])" :img-src="splashLoader(result['champion'])"></b-card>
</div>
</b-collapse>
</div>
<b-button v-b-toggle.collapse-team_combination variant="outline-primary">Best Team Combination</b-button>
<b-collapse id="collapse-team_combination">
<div class="team">
<div class="team_summary">
<div class="team_best">
<h1>Best : {{ nameTranslator(inference_team[0]['id']) }}</h1>
<img v-bind:src="splashLoader(inference_team[0]['id'])">
</div>
<div class="team_worst">
<h1>Worst {{ nameTranslator(inference_team[inference_team.length - 1]['id']) }}</h1>
<img v-bind:src="splashLoader(inference_team[inference_team.length - 1]['id'])">
</div>
</div>
<b-button v-b-toggle.collapse-1 variant="primary">More</b-button>
<b-collapse id="collapse-1">
<b-container fluid class="wrap">
<b-row class="items flex-row flex-nowrap">
<template v-for="team, index in inference_team">
<b-card class="card">
<img v-bind:src="splashLoader(team['id'])">
<h3>{{ index + 1 }}. {{ nameTranslator(team['id']) }}</h3>
</b-card>
</template>
</b-row>
</b-container>
</b-collapse>
</div>
</b-collapse>
<b-button v-b-toggle.collapse-enemy_combination variant="outline-primary">Best Enemy Counterpart</b-button>
<b-collapse id="collapse-enemy_combination">
<div class="enemy">
<div class="enemy_summary">
<div class="enemy_best">
<h1>Best : {{ nameTranslator(inference_enemy[0]['id']) }}</h1>
<img v-bind:src="splashLoader(inference_enemy[0]['id'])">
</div>
<div class="enemy_worst">
<h1>Worst {{ nameTranslator(inference_enemy[inference_enemy.length - 1]['id']) }}</h1>
<img v-bind:src="splashLoader(inference_enemy[inference_enemy.length - 1]['id'])">
</div>
</div>
<b-button v-b-toggle.collapse-1 variant="primary">More</b-button>
<b-collapse id="collapse-1">
<b-container fluid class="wrap">
<b-row class="items flex-row flex-nowrap">
<template v-for="enemy, index in inference_enemy">
<b-card class="card">
<img v-bind:src="splashLoader(enemy['id'])">
<h3>{{ index + 1 }}. {{ nameTranslator(enemy['id']) }}</h3>
</b-card>
</template>
</b-row>
</b-container>
</b-collapse>
</div>
</b-collapse>
</div>
</div>
</template>
<script>
import championTable from '../assets/champion_table.json';
export default {
name: 'DetailPage',
data () {
return {
userId: null,
userPk: null,
inference_team: [],
inference_enemy: [],
inference_secondary: [],
myPick: [],
splash: [],
championList: Array.from(Array(145).keys()),
teamData: [],
enemyData: [],
predictResult: {}
}
},
created () {
this.axios.get('http://127.0.0.1:8000/GameData/search/', { params: { game_id: 'laurelwoods' }})
.then((response) => {
this.userPk = response.data.id;
this.userId = response.data.game_id;
// inference : team
this.axios.get('http://127.0.0.1:8000/GameData/' + this.userPk + '/inference/', { params: { model_type: 'team' } })
.then((response) => { this.inference_team = response.data; })
// inference : enemy
this.axios.get('http://127.0.0.1:8000/GameData/' + this.userPk + '/inference/', { params: { model_type: 'enemy' } })
.then((response) => { this.inference_enemy = response.data; })
// inference : secondary
this.axios.get('http://127.0.0.1:8000/GameData/' + this.userPk + '/inference/', { params: { model_type: 'secondary' } })
.then((response) => {
this.inference_secondary = response.data; })
// average : myPick
this.axios.get('http://127.0.0.1:8000/GameData/' + this.userPk + '/average/')
.then((response) => { this.myPick = response.data; })
})
.catch((error) => {
console.log(error.response)
})
},
methods: {
nameTranslator: function (championId) {
return championTable[championId]['name_ko']
},
splashLoader: function (championId) {
const path = require('../assets/splash/' + String(championId) + '.png')
return path
},
inputTeamData: function (championId) { this.teamData.push(championId) },
inputEnemyData: function (championId) { this.enemyData.push(championId) },
makePredict: function (pk) {
this.axios.post('http://127.0.0.1:8000/GameData/' + String(pk) + '/predict/', { team: this.teamData, enemy: this.enemyData })
.then((response) => {
console.log(response.data)
this.predictResult = response.data
})
}
}
}
</script>
<style scoped>
.warp {
display: flex;
flex-direction: column;
height: 500px;
}
.items {
display: flex;
flex: 1;
overflow: auto;
}
.card {
min-height: 200px;
min-width: 250px;
}
</style>