Update sync to use new API with progress modal
- Replace /sync endpoint (which now just starts sync) with polling /sync/progress - Add SyncProgressModal.vue component to show live progress and results - Update extraButtons.vue to use new sync flow with modal Update character modal to use API - Fetch character list from /characters endpoint - Load character images from /character?name=<filename> endpoint - Add object-fit: contain to preserve aspect ratios - Fallback to hardcoded list if API fails - Store API URLs for profile images Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -0,0 +1,357 @@
|
|||||||
|
<template>
|
||||||
|
<div class="modal" v-if="isOpen">
|
||||||
|
<div class="modalContainer syncProgressContainer">
|
||||||
|
<span class="closeModalImg" @click="closeModal">×</span>
|
||||||
|
<h1>Sync in Progress</h1>
|
||||||
|
|
||||||
|
<div v-if="!syncComplete" class="progressSection">
|
||||||
|
<div class="progressBarContainer">
|
||||||
|
<div class="progressBar" :style="{ width: progress + '%' }"></div>
|
||||||
|
</div>
|
||||||
|
<p class="progressText">{{ progress }}% complete</p>
|
||||||
|
<p class="timeText">Time spent: {{ timeSpent }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="resultsSection">
|
||||||
|
<h2>Sync Complete!</h2>
|
||||||
|
<p>Total time: {{ syncData.total_time }}</p>
|
||||||
|
|
||||||
|
<div v-if="syncData.games_added && syncData.games_added.length > 0" class="resultItem">
|
||||||
|
<h3>Games Added: {{ syncData.games_added.length }}</h3>
|
||||||
|
<ul class="gameList">
|
||||||
|
<li v-for="game in syncData.games_added" :key="game">{{ game }}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="syncData.games_re_added && syncData.games_re_added.length > 0" class="resultItem">
|
||||||
|
<h3>Games Re-added: {{ syncData.games_re_added.length }}</h3>
|
||||||
|
<ul class="gameList">
|
||||||
|
<li v-for="game in syncData.games_re_added" :key="game">{{ game }}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="syncData.games_removed && syncData.games_removed.length > 0" class="resultItem">
|
||||||
|
<h3>Games Removed: {{ syncData.games_removed.length }}</h3>
|
||||||
|
<ul class="gameList">
|
||||||
|
<li v-for="game in syncData.games_removed" :key="game">{{ game }}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="Object.keys(syncData.games_changed_title || {}).length > 0" class="resultItem">
|
||||||
|
<h3>Games with Changed Title: {{ Object.keys(syncData.games_changed_title || {}).length }}</h3>
|
||||||
|
<ul class="gameList">
|
||||||
|
<li v-for="(newTitle, oldTitle) in syncData.games_changed_title" :key="oldTitle">{{ oldTitle }} → {{ newTitle }}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="syncData.games_changed_content && syncData.games_changed_content.length > 0" class="resultItem">
|
||||||
|
<h3>Games with Changed Content: {{ syncData.games_changed_content.length }}</h3>
|
||||||
|
<ul class="gameList">
|
||||||
|
<li v-for="game in syncData.games_changed_content" :key="game">{{ game }}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="syncData.catched_errors && syncData.catched_errors.length > 0" class="resultItem errors">
|
||||||
|
<h3>Errors: {{ syncData.catched_errors.length }}</h3>
|
||||||
|
<ul class="gameList">
|
||||||
|
<li v-for="error in syncData.catched_errors" :key="error">{{ error }}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p v-if="noChanges" class="noChanges">No changes detected.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
isOpen: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
syncInProgress: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
progress: 0,
|
||||||
|
timeSpent: "00:00:00",
|
||||||
|
syncComplete: false,
|
||||||
|
syncData: {
|
||||||
|
games_added: [],
|
||||||
|
games_re_added: [],
|
||||||
|
games_changed_title: {},
|
||||||
|
games_changed_content: [],
|
||||||
|
games_removed: [],
|
||||||
|
catched_errors: [],
|
||||||
|
total_time: "",
|
||||||
|
},
|
||||||
|
pollInterval: null,
|
||||||
|
hasFetchedInitialData: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
noChanges() {
|
||||||
|
return (
|
||||||
|
this.syncData.games_added.length === 0 &&
|
||||||
|
this.syncData.games_re_added.length === 0 &&
|
||||||
|
Object.keys(this.syncData.games_changed_title).length === 0 &&
|
||||||
|
this.syncData.games_changed_content.length === 0 &&
|
||||||
|
this.syncData.games_removed.length === 0 &&
|
||||||
|
this.syncData.catched_errors.length === 0
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
closeModal() {
|
||||||
|
this.$emit("close");
|
||||||
|
},
|
||||||
|
startPolling() {
|
||||||
|
if (this.pollInterval) {
|
||||||
|
clearInterval(this.pollInterval);
|
||||||
|
}
|
||||||
|
this.pollInterval = setInterval(() => {
|
||||||
|
this.fetchProgress();
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
|
stopPolling() {
|
||||||
|
if (this.pollInterval) {
|
||||||
|
clearInterval(this.pollInterval);
|
||||||
|
this.pollInterval = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async fetchProgress() {
|
||||||
|
try {
|
||||||
|
const response = await this.axios({
|
||||||
|
method: "get",
|
||||||
|
url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/sync/progress`,
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = response.data;
|
||||||
|
|
||||||
|
// Check if we got a progress response or a result response
|
||||||
|
if (data.progress !== undefined) {
|
||||||
|
// Still syncing - update progress
|
||||||
|
this.progress = parseInt(data.progress) || 0;
|
||||||
|
this.timeSpent = data.time_spent || this.timeSpent;
|
||||||
|
this.syncComplete = false;
|
||||||
|
// If we're not actively polling but sync is in progress, start polling
|
||||||
|
if (this.syncInProgress && !this.pollInterval) {
|
||||||
|
this.startPolling();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Sync complete - show results
|
||||||
|
this.syncComplete = true;
|
||||||
|
this.syncData = {
|
||||||
|
games_added: data.games_added || [],
|
||||||
|
games_re_added: data.games_re_added || [],
|
||||||
|
games_changed_title: data.games_changed_title || {},
|
||||||
|
games_changed_content: data.games_changed_content || [],
|
||||||
|
games_removed: data.games_removed || [],
|
||||||
|
catched_errors: data.catched_errors || [],
|
||||||
|
total_time: data.total_time || "",
|
||||||
|
};
|
||||||
|
this.progress = 100;
|
||||||
|
this.stopPolling();
|
||||||
|
}
|
||||||
|
this.hasFetchedInitialData = true;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching sync progress:", error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async fetchInitialData() {
|
||||||
|
// Fetch once to check current state
|
||||||
|
await this.fetchProgress();
|
||||||
|
// If we got progress data, start polling
|
||||||
|
if (!this.syncComplete && !this.pollInterval) {
|
||||||
|
this.startPolling();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isOpen(newVal) {
|
||||||
|
if (newVal) {
|
||||||
|
this.hasFetchedInitialData = false;
|
||||||
|
if (this.syncInProgress) {
|
||||||
|
// New sync in progress - start polling
|
||||||
|
this.progress = 0;
|
||||||
|
this.timeSpent = "00:00:00";
|
||||||
|
this.syncComplete = false;
|
||||||
|
this.syncData = {
|
||||||
|
games_added: [],
|
||||||
|
games_re_added: [],
|
||||||
|
games_changed_title: {},
|
||||||
|
games_changed_content: [],
|
||||||
|
games_removed: [],
|
||||||
|
catched_errors: [],
|
||||||
|
total_time: "",
|
||||||
|
};
|
||||||
|
// Small delay to ensure sync has started before first poll
|
||||||
|
setTimeout(() => {
|
||||||
|
this.startPolling();
|
||||||
|
}, 200);
|
||||||
|
} else {
|
||||||
|
// Check current state - might be in progress or have results
|
||||||
|
this.fetchInitialData();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.stopPolling();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
beforeUnmount() {
|
||||||
|
this.stopPolling();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.syncProgressContainer {
|
||||||
|
background-color: #eeeeee;
|
||||||
|
margin: 10% auto;
|
||||||
|
border: 1px solid #888;
|
||||||
|
width: 70%;
|
||||||
|
max-width: 800px;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.closeModalImg {
|
||||||
|
position: absolute;
|
||||||
|
right: 8px;
|
||||||
|
top: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
opacity: 70%;
|
||||||
|
font-size: 2rem;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
.closeModalImg:hover {
|
||||||
|
opacity: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.syncProgressContainer h1 {
|
||||||
|
color: black;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
padding-top: 10px;
|
||||||
|
font-size: 1.9rem;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.syncProgressContainer h2 {
|
||||||
|
color: black;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.syncProgressContainer p {
|
||||||
|
color: black;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressSection {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressBarContainer {
|
||||||
|
width: 100%;
|
||||||
|
height: 30px;
|
||||||
|
background-color: #ddd;
|
||||||
|
border-radius: 15px;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressBar {
|
||||||
|
height: 100%;
|
||||||
|
background: linear-gradient(90deg, #4CAF50, #8BC34A);
|
||||||
|
border-radius: 15px;
|
||||||
|
transition: width 0.3s ease;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 30px;
|
||||||
|
color: white;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressText {
|
||||||
|
font-size: 1.3rem;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeText {
|
||||||
|
font-size: 1rem;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resultsSection {
|
||||||
|
max-height: 60vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resultItem {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding: 10px;
|
||||||
|
background-color: #f8f8f8;
|
||||||
|
border-radius: 8px;
|
||||||
|
border-left: 4px solid #4CAF50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resultItem.errors {
|
||||||
|
border-left-color: #f44336;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resultItem h3 {
|
||||||
|
color: #333;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameList {
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 5px 0 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameList li {
|
||||||
|
padding: 3px 0;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
.noChanges {
|
||||||
|
text-align: center;
|
||||||
|
color: #666;
|
||||||
|
font-style: italic;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 1000px) {
|
||||||
|
.syncProgressContainer {
|
||||||
|
width: 93%;
|
||||||
|
margin: 5% auto;
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.syncProgressContainer h1 {
|
||||||
|
font-size: 1.6rem;
|
||||||
|
padding-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressBarContainer {
|
||||||
|
height: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressText {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,160 +1,173 @@
|
|||||||
<template>
|
<template>
|
||||||
<transition name="modalAni">
|
<transition name="modalAni">
|
||||||
<div v-if="show" class="modal" @click="checkIfClickShouldCloseModal">
|
<div v-if="show" class="modal" @click="checkIfClickShouldCloseModal">
|
||||||
<div class="modalContainer">
|
<div class="modalContainer">
|
||||||
<div class="modalWrapper">
|
<div class="modalWrapper">
|
||||||
<img
|
<img
|
||||||
class="closeModalImg"
|
class="closeModalImg"
|
||||||
src="cancel-black-36dp.svg"
|
src="cancel-black-36dp.svg"
|
||||||
alt="closeModalIMG"
|
alt="closeModalIMG"
|
||||||
@click="closeModal"
|
@click="closeModal"
|
||||||
/>
|
/>
|
||||||
<h1 @click="test">{{ playerName }}, choose your fighter!</h1>
|
<h1>{{ playerName }}, choose your fighter!</h1>
|
||||||
<div class="fighterDiv">
|
<div v-if="isLoading" class="loading">Loading characters...</div>
|
||||||
<div class="fighter" @click="chooseFighter('Adol')">
|
<div class="fighterDiv" v-else>
|
||||||
<img src="characters/Adol.png" alt="adol" />
|
<div
|
||||||
<p>Adol Christin</p>
|
v-for="character in characters"
|
||||||
</div>
|
:key="character"
|
||||||
<div class="fighter" @click="chooseFighter('Link')">
|
class="fighter"
|
||||||
<img src="characters/Link.png" alt="link" />
|
@click="chooseFighter(character)"
|
||||||
<p>Link</p>
|
>
|
||||||
</div>
|
<img
|
||||||
<div class="fighter" @click="chooseFighter('Barbarian')">
|
:src="getCharacterImageUrl(character)"
|
||||||
<img src="characters/Barbarian.png" alt="barbarian" />
|
:alt="getCharacterName(character)"
|
||||||
<p>Barbarian</p>
|
/>
|
||||||
</div>
|
<p>{{ getCharacterName(character) }}</p>
|
||||||
<div class="fighter" @click="chooseFighter('Layton')">
|
</div>
|
||||||
<img src="characters/Layton.png" alt="layton" />
|
</div>
|
||||||
<p>Professor Layton</p>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fighter" @click="chooseFighter('Kiryu')">
|
</div>
|
||||||
<img src="characters/Kiryu.png" alt="kiryu" />
|
</transition>
|
||||||
<p>Kazuma Kiryu</p>
|
</template>
|
||||||
</div>
|
|
||||||
<div class="fighter" @click="chooseFighter('Miles')">
|
<script>
|
||||||
<img src="characters/Miles.png" alt="miles" />
|
export default {
|
||||||
<p>Miles Edgeworth</p>
|
data() {
|
||||||
</div>
|
return {
|
||||||
<div class="fighter" @click="chooseFighter('Lemmings')">
|
show: false,
|
||||||
<img src="characters/Lemmings.png" alt="lemmings" />
|
playerName: "",
|
||||||
<p>Lemmings</p>
|
characters: [],
|
||||||
</div>
|
isLoading: false,
|
||||||
<div class="fighter" @click="chooseFighter('Samus')">
|
};
|
||||||
<img src="characters/Samus.png" alt="samus" />
|
},
|
||||||
<p>Samus</p>
|
methods: {
|
||||||
</div>
|
closeModal() {
|
||||||
<div class="fighter" @click="chooseFighter('Kratos')">
|
this.show = false;
|
||||||
<img src="characters/Kratos.png" alt="kratos" />
|
},
|
||||||
<p>Kratos</p>
|
async openModal(playerName) {
|
||||||
</div>
|
this.playerName = playerName;
|
||||||
<div class="fighter" @click="chooseFighter('Aloy')">
|
this.show = true;
|
||||||
<img src="characters/Aloy.png" alt="aloy" />
|
await this.fetchCharacters();
|
||||||
<p>Aloy</p>
|
},
|
||||||
</div>
|
checkIfClickShouldCloseModal(event) {
|
||||||
<div class="fighter" @click="chooseFighter('Sora')">
|
if (event.target.classList[0] === "modal") {
|
||||||
<img src="characters/Sora.png" alt="sora" />
|
this.closeModal();
|
||||||
<p>Sora</p>
|
}
|
||||||
</div>
|
},
|
||||||
<div class="fighter" @click="chooseFighter('Raiden')">
|
async fetchCharacters() {
|
||||||
<img src="characters/Raiden.png" alt="raiden" />
|
this.isLoading = true;
|
||||||
<p>Raiden</p>
|
try {
|
||||||
</div>
|
const response = await this.axios({
|
||||||
<div class="fighter" @click="chooseFighter('PaperMario')">
|
method: "get",
|
||||||
<img src="characters/PaperMario.png" alt="paper mario" />
|
url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/characters`,
|
||||||
<p>Paper Mario</p>
|
});
|
||||||
</div>
|
this.characters = response.data || [];
|
||||||
</div>
|
} catch (error) {
|
||||||
</div>
|
console.error("Failed to fetch characters:", error);
|
||||||
</div>
|
// Fallback to hardcoded list if API fails
|
||||||
</div>
|
this.characters = [
|
||||||
</transition>
|
"Adol.png",
|
||||||
</template>
|
"Link.png",
|
||||||
|
"Barbarian.png",
|
||||||
<script>
|
"Layton.png",
|
||||||
export default {
|
"Kiryu.png",
|
||||||
data() {
|
"Miles.png",
|
||||||
return {
|
"Lemmings.png",
|
||||||
show: false,
|
"Samus.png",
|
||||||
playerName: "",
|
"Kratos.png",
|
||||||
};
|
"Aloy.png",
|
||||||
},
|
"Sora.png",
|
||||||
methods: {
|
"Raiden.png",
|
||||||
closeModal() {
|
"PaperMario.png",
|
||||||
this.show = false;
|
];
|
||||||
},
|
} finally {
|
||||||
openModal(playerName) {
|
this.isLoading = false;
|
||||||
this.playerName = playerName;
|
}
|
||||||
this.show = true;
|
},
|
||||||
},
|
getCharacterImageUrl(character) {
|
||||||
checkIfClickShouldCloseModal(event) {
|
return `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/character?name=${encodeURIComponent(character)}`;
|
||||||
if (event.target.classList[0] === "modal") {
|
},
|
||||||
this.closeModal();
|
getCharacterName(character) {
|
||||||
}
|
// Remove file extension
|
||||||
},
|
return character.replace(/\.(png|jpg|jpeg|gif)$/i, "");
|
||||||
chooseFighter(profilePicSrc) {
|
},
|
||||||
let payload = {
|
chooseFighter(characterFilename) {
|
||||||
playerName: this.playerName,
|
const apiHostname = window.__RUNTIME_CONFIG__.API_HOSTNAME;
|
||||||
profile: "characters/" + profilePicSrc + ".png",
|
const profile = `${apiHostname}/character?name=${encodeURIComponent(characterFilename)}`;
|
||||||
};
|
|
||||||
this.$store.dispatch("changePlayerProfile", payload);
|
let payload = {
|
||||||
this.closeModal();
|
playerName: this.playerName,
|
||||||
},
|
profile: profile,
|
||||||
},
|
};
|
||||||
};
|
this.$store.dispatch("changePlayerProfile", payload);
|
||||||
</script>
|
this.closeModal();
|
||||||
|
},
|
||||||
<style scoped>
|
},
|
||||||
.modalContainer {
|
};
|
||||||
width: 80%; /* Could be more or less, depending on screen size */
|
</script>
|
||||||
}
|
|
||||||
.fighterDiv {
|
<style scoped>
|
||||||
display: flex;
|
.modalContainer {
|
||||||
width: 100%;
|
width: 80%; /* Could be more or less, depending on screen size */
|
||||||
justify-content: center;
|
}
|
||||||
margin-top: 30px;
|
.fighterDiv {
|
||||||
flex-wrap: wrap;
|
display: flex;
|
||||||
}
|
width: 100%;
|
||||||
|
justify-content: center;
|
||||||
.fighterDiv img {
|
margin-top: 30px;
|
||||||
width: 180px;
|
flex-wrap: wrap;
|
||||||
height: 90px;
|
}
|
||||||
}
|
|
||||||
|
.fighterDiv img {
|
||||||
.fighter {
|
width: 180px;
|
||||||
display: flex;
|
height: 90px;
|
||||||
flex-wrap: wrap;
|
object-fit: contain;
|
||||||
justify-content: center;
|
}
|
||||||
text-align: center;
|
|
||||||
width: 14vw;
|
.fighter {
|
||||||
margin-top: 30px;
|
display: flex;
|
||||||
}
|
flex-wrap: wrap;
|
||||||
.fighter > * {
|
justify-content: center;
|
||||||
width: 100%;
|
text-align: center;
|
||||||
}
|
width: 14vw;
|
||||||
.fighter:hover {
|
margin-top: 30px;
|
||||||
outline: 1px solid rgb(128, 83, 0);
|
}
|
||||||
outline-offset: 2px;
|
.fighter > * {
|
||||||
cursor: pointer;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.fighter p {
|
.fighter:hover {
|
||||||
margin-top: 8px;
|
outline: 1px solid rgb(128, 83, 0);
|
||||||
font-size: 1.3rem;
|
outline-offset: 2px;
|
||||||
}
|
cursor: pointer;
|
||||||
|
}
|
||||||
@media only screen and (max-width: 1000px) {
|
.fighter p {
|
||||||
.modalContainer {
|
margin-top: 8px;
|
||||||
width: 95%; /* Could be more or less, depending on screen size */
|
font-size: 1.3rem;
|
||||||
}
|
}
|
||||||
.fighterDiv {
|
|
||||||
margin-top: 30px;
|
.loading {
|
||||||
}
|
text-align: center;
|
||||||
.fighterDiv img {
|
padding: 40px;
|
||||||
width: 80px;
|
font-size: 1.2rem;
|
||||||
height: 40px;
|
color: #666;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fighter {
|
@media only screen and (max-width: 1000px) {
|
||||||
width: 25vw;
|
.modalContainer {
|
||||||
}
|
width: 95%; /* Could be more or less, depending on screen size */
|
||||||
}
|
}
|
||||||
</style>
|
.fighterDiv {
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
.fighterDiv img {
|
||||||
|
width: 80px;
|
||||||
|
height: 40px;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fighter {
|
||||||
|
width: 25vw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -2,16 +2,29 @@
|
|||||||
<div class="extraButtonsDiv">
|
<div class="extraButtonsDiv">
|
||||||
<button @click="resetPlaylist">Reset playlist</button>
|
<button @click="resetPlaylist">Reset playlist</button>
|
||||||
<button @click="resetPoints">Reset points</button>
|
<button @click="resetPoints">Reset points</button>
|
||||||
<button @click="syncGames">Sync games</button>
|
<button @click="handleSyncButtonClick">Sync games</button>
|
||||||
<button @click="startSoundTest">Sound test</button>
|
<button @click="startSoundTest">Sound test</button>
|
||||||
|
<sync-progress-modal
|
||||||
|
:isOpen="showSyncModal"
|
||||||
|
:syncInProgress="syncInProgress"
|
||||||
|
@close="handleSyncComplete"
|
||||||
|
></sync-progress-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import SyncProgressModal from "./SyncProgressModal.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
SyncProgressModal,
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
emptyPlaylist: [],
|
emptyPlaylist: [],
|
||||||
|
showSyncModal: false,
|
||||||
|
syncInProgress: false,
|
||||||
|
syncCompleted: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -27,8 +40,47 @@ export default {
|
|||||||
this.$store.dispatch("setCurrentlyLoadingTrack", "N/A");
|
this.$store.dispatch("setCurrentlyLoadingTrack", "N/A");
|
||||||
this.$store.dispatch("setCurrentTrackHidden", false);
|
this.$store.dispatch("setCurrentTrackHidden", false);
|
||||||
},
|
},
|
||||||
async syncGames() {
|
async startSync() {
|
||||||
await this.APIsyncGames();
|
try {
|
||||||
|
// Start the sync
|
||||||
|
const response = await this.APIsyncGames();
|
||||||
|
// Check if sync was actually started or if one is in progress
|
||||||
|
if (response && (response.status === 423 || (response.data && response.data.includes("in progress")))) {
|
||||||
|
// Sync is already in progress - show modal with polling
|
||||||
|
this.syncInProgress = true;
|
||||||
|
} else {
|
||||||
|
this.syncInProgress = true;
|
||||||
|
}
|
||||||
|
// Show the modal which will poll for progress
|
||||||
|
this.showSyncModal = true;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to start sync:", error);
|
||||||
|
// If error is 423, sync is already in progress
|
||||||
|
if (error.response && error.response.status === 423) {
|
||||||
|
this.syncInProgress = true;
|
||||||
|
this.showSyncModal = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleSyncButtonClick() {
|
||||||
|
// If we have a completed sync result, just show it
|
||||||
|
// Otherwise start a new sync
|
||||||
|
if (this.syncCompleted) {
|
||||||
|
this.showSyncResults();
|
||||||
|
} else {
|
||||||
|
this.startSync();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
showSyncResults() {
|
||||||
|
// Show modal with existing results (no new sync)
|
||||||
|
this.syncInProgress = false;
|
||||||
|
this.showSyncModal = true;
|
||||||
|
},
|
||||||
|
async handleSyncComplete() {
|
||||||
|
this.syncInProgress = false;
|
||||||
|
this.syncCompleted = true;
|
||||||
|
this.showSyncModal = false;
|
||||||
|
// Refresh data after sync completes
|
||||||
await this.APIresetPlaylist();
|
await this.APIresetPlaylist();
|
||||||
this.$store.dispatch("resetPlayerScore");
|
this.$store.dispatch("resetPlayerScore");
|
||||||
this.$store.dispatch("resetPlayerWelcomed");
|
this.$store.dispatch("resetPlayerWelcomed");
|
||||||
@@ -63,12 +115,12 @@ export default {
|
|||||||
method: "get",
|
method: "get",
|
||||||
url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/sync`,
|
url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/sync`,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then((response) => {
|
||||||
resolve();
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
reject();
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user