Compare commits
7
Commits
2d7c620c6a
...
v1.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b5aa3adf0 | ||
|
|
fb36038cc8 | ||
|
|
f7763c97ae | ||
|
|
168ba205be | ||
|
|
99e6419d09 | ||
|
|
ef1f9386e1 | ||
|
|
bc32ce5fc5 |
@@ -0,0 +1,4 @@
|
|||||||
|
node_modules
|
||||||
|
.git
|
||||||
|
dist
|
||||||
|
.DS_Store
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
name: Build and Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- develop
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: https://github.com/actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: https://github.com/docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
config-inline: |
|
||||||
|
[registry."gitea.sanplex.xyz/sansan"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: false
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
name: Publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '*.*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: https://github.com/actions/checkout@v4
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: https://github.com/docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
config-inline: |
|
||||||
|
[registry."gitea.sanplex.xyz/sansan"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
|
- name: Login to Gitea
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: gitea.sanplex.xyz
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.TOKEN }}
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: https://github.com/docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: "gitea.sanplex.xyz/sansan/musicfrontend:${{gitea.ref_name}}, gitea.sanplex.xyz/sansan/musicfrontend:latest"
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
name: Release Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: https://github.com/actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: https://github.com/docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: https://github.com/docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
config-inline: |
|
||||||
|
[registry."gitea.sanplex.xyz/sansan"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
|
|
||||||
|
- name: Login to Gitea Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: gitea.sanplex.xyz
|
||||||
|
username: sansan
|
||||||
|
password: ${{ secrets.TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push multi-arch image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
gitea.sanplex.xyz/sansan/musicfrontend:${{ gitea.ref_name }}
|
||||||
|
gitea.sanplex.xyz/sansan/musicfrontend:latest
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
# Build stage
|
||||||
|
FROM node:18-alpine AS builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Runtime stage
|
||||||
|
FROM nginx:alpine
|
||||||
|
RUN apk add --no-cache gettext
|
||||||
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
COPY public/config.template.js /usr/share/nginx/html/
|
||||||
|
COPY docker-entrypoint.sh /entrypoint.sh
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Generate config.js from template at runtime
|
||||||
|
envsubst < /usr/share/nginx/html/config.template.js > /usr/share/nginx/html/config.js
|
||||||
|
|
||||||
|
# Start nginx
|
||||||
|
exec "$@"
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
const express = require("express");
|
|
||||||
const path = require("path");
|
|
||||||
const routes = require("./routes.js");
|
|
||||||
const app = express();
|
|
||||||
const cors = require("cors");
|
|
||||||
/* const bodyParser = require("body-parser"); */
|
|
||||||
const PORT = process.env.PORT || 5005;
|
|
||||||
const mainUrl = "test";
|
|
||||||
|
|
||||||
|
|
||||||
console.log(`Server started on port ${PORT}`);
|
|
||||||
|
|
||||||
//app.use(bodyParser.json());
|
|
||||||
|
|
||||||
//Routes
|
|
||||||
/* app.use(express.static(path.join(__dirname, "public"))); */
|
|
||||||
/* app.use(express.static(path.join(__dirname, "assets"))); */
|
|
||||||
app.use(express.static(path.join(__dirname)));
|
|
||||||
app.use(express.static(path.join(__dirname, "dist")));
|
|
||||||
/* app.use(express.static(path.join(__dirname, "public"))); */
|
|
||||||
|
|
||||||
/* console.log(__dirname); */
|
|
||||||
app.use(cors());
|
|
||||||
app.use(routes);
|
|
||||||
|
|
||||||
app.listen(PORT, "0.0.0.0");
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
window.__RUNTIME_CONFIG__ = {
|
||||||
|
API_HOSTNAME: '${API_HOSTNAME}'
|
||||||
|
};
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
|
||||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||||
|
<script src="<%= BASE_URL %>config.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<noscript>
|
<noscript>
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
export default {
|
|
||||||
hostname: "$HOSTNAME",
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<div class="textWrapper">
|
<div class="textWrapper">
|
||||||
<transition-group name="displayingInfo" appear>
|
<transition-group name="displayingInfo" appear>
|
||||||
<p v-if="currentTrackHidden" :key="1">????????</p>
|
<p v-if="currentTrackHidden" :key="1">????????</p>
|
||||||
<p v-else :key="2">{{ currentGame }}</p>
|
<p v-else :key="2">{{ currentSoundtrack }}</p>
|
||||||
<p v-if="currentTrackHidden" :key="3">??????</p>
|
<p v-if="currentTrackHidden" :key="3">??????</p>
|
||||||
<p v-else :key="4">{{ currentTrack }}</p>
|
<p v-else :key="4">{{ currentTrack }}</p>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<p>??????</p>
|
<p>??????</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="textWrapper">
|
<div v-else class="textWrapper">
|
||||||
<p>{{ currentGame }}</p>
|
<p>{{ currentSoundtrack }}</p>
|
||||||
<p>{{ currentTrack }}</p>
|
<p>{{ currentTrack }}</p>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
import { mapState } from "vuex";
|
import { mapState } from "vuex";
|
||||||
export default {
|
export default {
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(["currentGame", "currentTrack", "currentTrackHidden"]),
|
...mapState(["currentSoundtrack", "currentTrack", "currentTrackHidden"]),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<input
|
<input
|
||||||
v-model="searchInputText"
|
v-model="searchInputText"
|
||||||
type="text"
|
type="text"
|
||||||
@input="searchGame()"
|
@input="searchSoundtrack()"
|
||||||
ref="inputField"
|
ref="inputField"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -20,52 +20,51 @@
|
|||||||
class="inspirationList"
|
class="inspirationList"
|
||||||
ref="inspirationList"
|
ref="inspirationList"
|
||||||
>
|
>
|
||||||
<li v-for="game in showingGamesList" class="inspirationEntry" :key="game">
|
<li v-for="soundtrack in showingSoundtracksList" class="inspirationEntry" :key="soundtrack">
|
||||||
{{ game }}
|
{{ soundtrack }}
|
||||||
</li>
|
</li>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import arne from '../../arne.js'
|
|
||||||
import {mapState} from "vuex";
|
import {mapState} from "vuex";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
allGamesList: [],
|
allSoundtracksList: [],
|
||||||
showingGamesList: [],
|
showingSoundtracksList: [],
|
||||||
scrollDown: true,
|
scrollDown: true,
|
||||||
searchInputText: "",
|
searchInputText: "",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(["reloadGamesList"]),
|
...mapState(["reloadSoundtracksList"]),
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
reloadGamesList(newValue) {
|
reloadSoundtracksList(newValue) {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
this.reloadGames();
|
this.reloadSoundtracks();
|
||||||
this.$store.dispatch("reloadGamesList", false);
|
this.$store.dispatch("reloadSoundtracksList", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
clearSearch() {
|
clearSearch() {
|
||||||
this.searchInputText = "";
|
this.searchInputText = "";
|
||||||
this.searchGame();
|
this.searchSoundtrack();
|
||||||
},
|
},
|
||||||
searchGame() {
|
searchSoundtrack() {
|
||||||
this.showingGamesList = [];
|
this.showingSoundtracksList = [];
|
||||||
for (const game of this.allGamesList) {
|
for (const soundtrack of this.allSoundtracksList) {
|
||||||
if (this.searchInputText === "" ||
|
if (this.searchInputText === "" ||
|
||||||
game.toLowerCase().replace(/\s/g, "")
|
soundtrack.toLowerCase().replace(/\s/g, "")
|
||||||
.includes(this.searchInputText.toLowerCase().replace(/\s/g, ""))) {
|
.includes(this.searchInputText.toLowerCase().replace(/\s/g, ""))) {
|
||||||
this.showingGamesList.push(game);
|
this.showingSoundtracksList.push(soundtrack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.searchInputText.replace(/\s/g, "") !== "") {
|
if (this.searchInputText.replace(/\s/g, "") !== "") {
|
||||||
this.showingGamesList.sort((n1, n2) => {
|
this.showingSoundtracksList.sort((n1, n2) => {
|
||||||
if (n1 > n2) {
|
if (n1 > n2) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -90,16 +89,16 @@ export default {
|
|||||||
this.scrollDown = !this.scrollDown;
|
this.scrollDown = !this.scrollDown;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
reloadGames() {
|
reloadSoundtracks() {
|
||||||
this.axios({
|
this.axios({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: `${arne.hostname}/music/all`,
|
url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/music/all`,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.allGamesList = response.data;
|
this.allSoundtracksList = response.data;
|
||||||
this.searchInputText = "";
|
this.searchInputText = "";
|
||||||
this.searchGame();
|
this.searchSoundtrack();
|
||||||
this.$store.dispatch("updateHowManyGames", this.allGamesList.length);
|
this.$store.dispatch("updateHowManySoundtracks", this.allSoundtracksList.length);
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
@@ -107,7 +106,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.reloadGames();
|
this.reloadSoundtracks();
|
||||||
window.setInterval(() => {
|
window.setInterval(() => {
|
||||||
this.scrollInspiration();
|
this.scrollInspiration();
|
||||||
}, 40);
|
}, 40);
|
||||||
|
|||||||
@@ -0,0 +1,232 @@
|
|||||||
|
<template>
|
||||||
|
<transition name="modalAni">
|
||||||
|
<div v-if="show" class="modal" @click="checkIfClickShouldCloseModal">
|
||||||
|
<div class="modalContainer">
|
||||||
|
<div class="modalWrapper">
|
||||||
|
<span class="closeModalImg" @click="closeModal">×</span>
|
||||||
|
<h1>Search Soundtracks</h1>
|
||||||
|
<div class="searchTypeContainer">
|
||||||
|
<label class="radioLabel">
|
||||||
|
<input type="radio" v-model="searchType" value="fuzzy">
|
||||||
|
<span>Fuzzy Search</span>
|
||||||
|
</label>
|
||||||
|
<label class="radioLabel">
|
||||||
|
<input type="radio" v-model="searchType" value="exact">
|
||||||
|
<span>Exact Search</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="searchContainer">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="searchTerm"
|
||||||
|
@input="debouncedSearch"
|
||||||
|
placeholder="Search for soundtracks..."
|
||||||
|
class="searchInput"
|
||||||
|
/>
|
||||||
|
<div v-if="searchTerm.length > 0" class="searchResults">
|
||||||
|
<div v-if="loading" class="loading">Searching...</div>
|
||||||
|
<div v-else-if="results.length > 0" class="resultsList">
|
||||||
|
<div v-for="soundtrack in results" :key="soundtrack" class="resultItem">
|
||||||
|
{{ soundtrack }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else class="noResults">No results found</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
show: false,
|
||||||
|
searchTerm: "",
|
||||||
|
results: [],
|
||||||
|
loading: false,
|
||||||
|
searchTimeout: null,
|
||||||
|
searchType: "fuzzy",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
openModal() {
|
||||||
|
this.show = true;
|
||||||
|
this.searchTerm = "";
|
||||||
|
this.results = [];
|
||||||
|
this.searchType = "fuzzy";
|
||||||
|
},
|
||||||
|
closeModal() {
|
||||||
|
this.show = false;
|
||||||
|
this.searchTerm = "";
|
||||||
|
this.results = [];
|
||||||
|
this.loading = false;
|
||||||
|
if (this.searchTimeout) {
|
||||||
|
clearTimeout(this.searchTimeout);
|
||||||
|
this.searchTimeout = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
checkIfClickShouldCloseModal(event) {
|
||||||
|
if (event.target.classList[0] === "modal") {
|
||||||
|
this.closeModal();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
debouncedSearch() {
|
||||||
|
// Clear existing timeout
|
||||||
|
if (this.searchTimeout) {
|
||||||
|
clearTimeout(this.searchTimeout);
|
||||||
|
}
|
||||||
|
// Set new timeout
|
||||||
|
this.searchTimeout = setTimeout(() => {
|
||||||
|
this.performSearch();
|
||||||
|
}, 250);
|
||||||
|
},
|
||||||
|
async performSearch() {
|
||||||
|
if (this.searchTerm.length === 0) {
|
||||||
|
this.results = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.loading = true;
|
||||||
|
try {
|
||||||
|
const endpoint = this.searchType === 'fuzzy' ? '/findfuzzy' : '/find';
|
||||||
|
const response = await this.axios({
|
||||||
|
method: "post",
|
||||||
|
url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}${endpoint}`,
|
||||||
|
data: new URLSearchParams({ search_term: this.searchTerm }),
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// Parse soundtracks from HTML response
|
||||||
|
this.results = this.parseSoundtracksFromResponse(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error searching soundtracks:", error);
|
||||||
|
this.results = [];
|
||||||
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
parseSoundtracksFromResponse(htmlData) {
|
||||||
|
// The server returns HTML from FoundSoundtracks templ component
|
||||||
|
// It generates divs containing soundtrack names in <p> tags
|
||||||
|
const soundtracks = [];
|
||||||
|
const parser = new DOMParser();
|
||||||
|
const doc = parser.parseFromString(htmlData, "text/html");
|
||||||
|
|
||||||
|
// Find all p tags inside divs (the templ generates <div><p>{soundtrack}</p></div>)
|
||||||
|
const pTags = doc.querySelectorAll("div p");
|
||||||
|
for (const p of pTags) {
|
||||||
|
const soundtrackName = p.textContent.trim();
|
||||||
|
if (soundtrackName) {
|
||||||
|
soundtracks.push(soundtrackName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return soundtracks;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.searchTypeContainer {
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
margin-top: 15px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.radioLabel {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.radioLabel input[type="radio"] {
|
||||||
|
margin: 0;
|
||||||
|
accent-color: #ff9c00;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchContainer {
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchInput {
|
||||||
|
width: 100%;
|
||||||
|
padding: 12px;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchInput:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #ff9c00;
|
||||||
|
box-shadow: 0 0 5px rgba(255, 156, 0, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchResults {
|
||||||
|
margin-top: 15px;
|
||||||
|
max-height: 400px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading {
|
||||||
|
color: #666;
|
||||||
|
font-style: italic;
|
||||||
|
text-align: center;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resultsList {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resultItem {
|
||||||
|
padding: 12px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
background-color: #f8f8f8;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resultItem:hover {
|
||||||
|
background-color: #e8e8e8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.noResults {
|
||||||
|
color: #666;
|
||||||
|
text-align: center;
|
||||||
|
padding: 20px;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 1000px) {
|
||||||
|
.searchTypeContainer {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.radioLabel {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchInput {
|
||||||
|
font-size: 1rem;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resultItem {
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -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.soundtracks_added && syncData.soundtracks_added.length > 0" class="resultItem">
|
||||||
|
<h3>Soundtracks Added: {{ syncData.soundtracks_added.length }}</h3>
|
||||||
|
<ul class="soundtrackList">
|
||||||
|
<li v-for="soundtrack in syncData.soundtracks_added" :key="soundtrack">{{ soundtrack }}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="syncData.soundtracks_re_added && syncData.soundtracks_re_added.length > 0" class="resultItem">
|
||||||
|
<h3>Soundtracks Re-added: {{ syncData.soundtracks_re_added.length }}</h3>
|
||||||
|
<ul class="soundtrackList">
|
||||||
|
<li v-for="soundtrack in syncData.soundtracks_re_added" :key="soundtrack">{{ soundtrack }}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="syncData.soundtracks_removed && syncData.soundtracks_removed.length > 0" class="resultItem">
|
||||||
|
<h3>Soundtracks Removed: {{ syncData.soundtracks_removed.length }}</h3>
|
||||||
|
<ul class="soundtrackList">
|
||||||
|
<li v-for="soundtrack in syncData.soundtracks_removed" :key="soundtrack">{{ soundtrack }}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="Object.keys(syncData.soundtracks_changed_title || {}).length > 0" class="resultItem">
|
||||||
|
<h3>Soundtracks with Changed Title: {{ Object.keys(syncData.soundtracks_changed_title || {}).length }}</h3>
|
||||||
|
<ul class="soundtrackList">
|
||||||
|
<li v-for="(newTitle, oldTitle) in syncData.soundtracks_changed_title" :key="oldTitle">{{ oldTitle }} → {{ newTitle }}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="syncData.soundtracks_changed_content && syncData.soundtracks_changed_content.length > 0" class="resultItem">
|
||||||
|
<h3>Soundtracks with Changed Content: {{ syncData.soundtracks_changed_content.length }}</h3>
|
||||||
|
<ul class="soundtrackList">
|
||||||
|
<li v-for="soundtrack in syncData.soundtracks_changed_content" :key="soundtrack">{{ soundtrack }}</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="soundtrackList">
|
||||||
|
<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: {
|
||||||
|
soundtracks_added: [],
|
||||||
|
soundtracks_re_added: [],
|
||||||
|
soundtracks_changed_title: {},
|
||||||
|
soundtracks_changed_content: [],
|
||||||
|
soundtracks_removed: [],
|
||||||
|
catched_errors: [],
|
||||||
|
total_time: "",
|
||||||
|
},
|
||||||
|
pollInterval: null,
|
||||||
|
hasFetchedInitialData: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
noChanges() {
|
||||||
|
return (
|
||||||
|
this.syncData.soundtracks_added.length === 0 &&
|
||||||
|
this.syncData.soundtracks_re_added.length === 0 &&
|
||||||
|
Object.keys(this.syncData.soundtracks_changed_title).length === 0 &&
|
||||||
|
this.syncData.soundtracks_changed_content.length === 0 &&
|
||||||
|
this.syncData.soundtracks_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 = {
|
||||||
|
soundtracks_added: data.soundtracks_added || [],
|
||||||
|
soundtracks_re_added: data.soundtracks_re_added || [],
|
||||||
|
soundtracks_changed_title: data.soundtracks_changed_title || {},
|
||||||
|
soundtracks_changed_content: data.soundtracks_changed_content || [],
|
||||||
|
soundtracks_removed: data.soundtracks_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 = {
|
||||||
|
soundtracks_added: [],
|
||||||
|
soundtracks_re_added: [],
|
||||||
|
soundtracks_changed_title: {},
|
||||||
|
soundtracks_changed_content: [],
|
||||||
|
soundtracks_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
.soundtrackList {
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 5px 0 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.soundtrackList 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>
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
/>
|
/>
|
||||||
<h1>Music Player Randomizer v0.1</h1>
|
<h1>Music Player Randomizer v0.1</h1>
|
||||||
<p class="descriptionText">
|
<p class="descriptionText">
|
||||||
Try your video game music knowledge with this VGM randomizer,
|
Try your video game soundtrack knowledge with this VGM randomizer,
|
||||||
invite your friends and see who is the best.
|
invite your friends and see who is the best.
|
||||||
</p>
|
</p>
|
||||||
<p class="creditText">
|
<p class="creditText">
|
||||||
|
|||||||
@@ -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,17 +2,33 @@
|
|||||||
<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 soundtracks</button>
|
||||||
<button @click="startSoundTest">Sound test</button>
|
<button @click="startSoundTest">Sound test</button>
|
||||||
|
<button @click="showSearchModal">Search</button>
|
||||||
|
<sync-progress-modal
|
||||||
|
:isOpen="showSyncModal"
|
||||||
|
:syncInProgress="syncInProgress"
|
||||||
|
@close="handleSyncComplete"
|
||||||
|
></sync-progress-modal>
|
||||||
|
<search-modal ref="searchModal"></search-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import arne from '../../arne.js'
|
import SyncProgressModal from "./SyncProgressModal.vue";
|
||||||
|
import SearchModal from "./SearchModal.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
SyncProgressModal,
|
||||||
|
SearchModal,
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
emptyPlaylist: [],
|
emptyPlaylist: [],
|
||||||
|
showSyncModal: false,
|
||||||
|
syncInProgress: false,
|
||||||
|
syncCompleted: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -28,8 +44,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.APIsyncSoundtracks();
|
||||||
|
// 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");
|
||||||
@@ -38,16 +93,19 @@ export default {
|
|||||||
this.$store.dispatch("updatePlaylistHistory", this.emptyPlaylist);
|
this.$store.dispatch("updatePlaylistHistory", this.emptyPlaylist);
|
||||||
this.$store.dispatch("setCurrentlyLoadingTrack", "N/A");
|
this.$store.dispatch("setCurrentlyLoadingTrack", "N/A");
|
||||||
this.$store.dispatch("setCurrentTrackHidden", false);
|
this.$store.dispatch("setCurrentTrackHidden", false);
|
||||||
this.$store.dispatch("reloadGamesList", true);
|
this.$store.dispatch("reloadSoundtracksList", true);
|
||||||
},
|
},
|
||||||
startSoundTest() {
|
startSoundTest() {
|
||||||
this.$emit("start-sound-test");
|
this.$emit("start-sound-test");
|
||||||
},
|
},
|
||||||
|
showSearchModal() {
|
||||||
|
this.$refs.searchModal.openModal();
|
||||||
|
},
|
||||||
APIresetPlaylist() {
|
APIresetPlaylist() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.axios({
|
this.axios({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: `${arne.hostname}/music/reset`,
|
url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/music/reset`,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
resolve();
|
resolve();
|
||||||
@@ -58,18 +116,18 @@ export default {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
APIsyncGames() {
|
APIsyncSoundtracks() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.axios({
|
this.axios({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: `${arne.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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
>
|
>
|
||||||
??? - ???
|
??? - ???
|
||||||
</p>
|
</p>
|
||||||
<p v-else-if="track.Game !== ''" :class="{ activeTrack: track.CurrentlyPlaying }">
|
<p v-else-if="track.Soundtrack !== ''" :class="{ activeTrack: track.CurrentlyPlaying }">
|
||||||
{{ track.SongNo + 1 }}. {{ track.Game }} -
|
{{ track.SongNo + 1 }}. {{ track.Soundtrack }} -
|
||||||
{{ displayTrack(track.Song) }}
|
{{ displayTrack(track.Song) }}
|
||||||
</p>
|
</p>
|
||||||
<span v-if="currentlyLoadingTrack === track.SongNo" class="loadingTrack">
|
<span v-if="currentlyLoadingTrack === track.SongNo" class="loadingTrack">
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
@click="closeModal"
|
@click="closeModal"
|
||||||
/>
|
/>
|
||||||
<h1>Statistics</h1>
|
<h1>Statistics</h1>
|
||||||
<p>Total amount of games in the playlist: {{ howManyGames }}</p>
|
<p>Total amount of soundtracks in the playlist: {{ howManySoundtracks }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -26,7 +26,7 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(["howManyGames"]),
|
...mapState(["howManySoundtracks"]),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
closeModal() {
|
closeModal() {
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from "vuex";
|
import { mapState } from "vuex";
|
||||||
import arne from "../../arne.js";
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -168,7 +167,7 @@ export default {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.axios({
|
this.axios({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: `${arne.hostname}/music/rand`,
|
url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/music/rand`,
|
||||||
responseType: "blob",
|
responseType: "blob",
|
||||||
onDownloadProgress: (progressEvent) => {
|
onDownloadProgress: (progressEvent) => {
|
||||||
let percentCompleted = Math.round(
|
let percentCompleted = Math.round(
|
||||||
@@ -198,7 +197,7 @@ export default {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.axios({
|
this.axios({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: `${arne.hostname}/music/rand/low`,
|
url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/music/rand/low`,
|
||||||
responseType: "blob",
|
responseType: "blob",
|
||||||
onDownloadProgress: (progressEvent) => {
|
onDownloadProgress: (progressEvent) => {
|
||||||
let percentCompleted = Math.round(
|
let percentCompleted = Math.round(
|
||||||
@@ -228,7 +227,7 @@ export default {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.axios({
|
this.axios({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: `${arne.hostname}/music/addPlayed`,
|
url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/music/addPlayed`,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
resolve(false);
|
resolve(false);
|
||||||
@@ -243,7 +242,7 @@ export default {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.axios({
|
this.axios({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: `${arne.hostname}/music/addQue`,
|
url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/music/addQue`,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
resolve(false);
|
resolve(false);
|
||||||
@@ -258,16 +257,16 @@ export default {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.axios({
|
this.axios({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: `${arne.hostname}/music/info`,
|
url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/music/info`,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
let gameInfoObject = {
|
let soundtrackInfoObject = {
|
||||||
game: response.data.Game,
|
soundtrack: response.data.Soundtrack,
|
||||||
track: response.data.Song.replace(".mp3", ""),
|
track: response.data.Song.replace(".mp3", ""),
|
||||||
songNo: response.data.SongNo,
|
songNo: response.data.SongNo,
|
||||||
};
|
};
|
||||||
this.$store.dispatch("setCurrentGame", gameInfoObject.game);
|
this.$store.dispatch("setCurrentSoundtrack", soundtrackInfoObject.soundtrack);
|
||||||
this.$store.dispatch("setCurrentTrack", gameInfoObject.track);
|
this.$store.dispatch("setCurrentTrack", soundtrackInfoObject.track);
|
||||||
resolve(false);
|
resolve(false);
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
@@ -280,7 +279,7 @@ export default {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.axios({
|
this.axios({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: `${arne.hostname}/music/list`,
|
url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/music/list`,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
let tracklistArray = response.data;
|
let tracklistArray = response.data;
|
||||||
@@ -297,7 +296,7 @@ export default {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.axios({
|
this.axios({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: `${arne.hostname}/music?song=${trackNumber}`,
|
url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/music?song=${trackNumber}`,
|
||||||
responseType: "blob",
|
responseType: "blob",
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
|||||||
+16
-16
@@ -7,7 +7,7 @@ import VueAxios from "vue-axios";
|
|||||||
const store = createStore({
|
const store = createStore({
|
||||||
state() {
|
state() {
|
||||||
return {
|
return {
|
||||||
currentGame: "",
|
currentSoundtrack: "",
|
||||||
currentTrack: ``,
|
currentTrack: ``,
|
||||||
currentTrackHidden: false,
|
currentTrackHidden: false,
|
||||||
currentlyLoadingTrack: "",
|
currentlyLoadingTrack: "",
|
||||||
@@ -15,18 +15,18 @@ const store = createStore({
|
|||||||
someoneHasWon: false,
|
someoneHasWon: false,
|
||||||
winningScore: 20,
|
winningScore: 20,
|
||||||
roundStarted: false,
|
roundStarted: false,
|
||||||
reloadGamesList: false,
|
reloadSoundtracksList: false,
|
||||||
listOfPlayers: [],
|
listOfPlayers: [],
|
||||||
localPlaylist: [],
|
localPlaylist: [],
|
||||||
playlistHistory: [
|
playlistHistory: [
|
||||||
{
|
{
|
||||||
SongNo: "",
|
SongNo: "",
|
||||||
Game: "",
|
Soundtrack: "",
|
||||||
Song: "",
|
Song: "",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
/* Stats */
|
/* Stats */
|
||||||
howManyGames: 0,
|
howManySoundtracks: 0,
|
||||||
/* Options */
|
/* Options */
|
||||||
stopAfterCurrent: true,
|
stopAfterCurrent: true,
|
||||||
hideNextTrack: true,
|
hideNextTrack: true,
|
||||||
@@ -35,8 +35,8 @@ const store = createStore({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
setCurrentGame(state, payload) {
|
setCurrentSoundtrack(state, payload) {
|
||||||
state.currentGame = payload;
|
state.currentSoundtrack = payload;
|
||||||
},
|
},
|
||||||
setCurrentTrack(state, payload) {
|
setCurrentTrack(state, payload) {
|
||||||
state.currentTrack = payload;
|
state.currentTrack = payload;
|
||||||
@@ -89,11 +89,11 @@ const store = createStore({
|
|||||||
updatePlaylistHistory(state, payload) {
|
updatePlaylistHistory(state, payload) {
|
||||||
state.playlistHistory = payload;
|
state.playlistHistory = payload;
|
||||||
},
|
},
|
||||||
updateHowManyGames(state, payload) {
|
updateHowManySoundtracks(state, payload) {
|
||||||
state.howManyGames = payload;
|
state.howManySoundtracks = payload;
|
||||||
},
|
},
|
||||||
reloadGamesList(state, payload) {
|
reloadSoundtracksList(state, payload) {
|
||||||
state.reloadGamesList = payload;
|
state.reloadSoundtracksList = payload;
|
||||||
},
|
},
|
||||||
updateStopAfterCurrent(state, payload) {
|
updateStopAfterCurrent(state, payload) {
|
||||||
state.stopAfterCurrent = payload;
|
state.stopAfterCurrent = payload;
|
||||||
@@ -109,8 +109,8 @@ const store = createStore({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setCurrentGame(context, payload) {
|
setCurrentSoundtrack(context, payload) {
|
||||||
context.commit("setCurrentGame", payload);
|
context.commit("setCurrentSoundtrack", payload);
|
||||||
},
|
},
|
||||||
setCurrentTrack(context, payload) {
|
setCurrentTrack(context, payload) {
|
||||||
context.commit("setCurrentTrack", payload);
|
context.commit("setCurrentTrack", payload);
|
||||||
@@ -225,11 +225,11 @@ const store = createStore({
|
|||||||
updatePlaylistHistory(context, payload) {
|
updatePlaylistHistory(context, payload) {
|
||||||
context.commit("updatePlaylistHistory", payload);
|
context.commit("updatePlaylistHistory", payload);
|
||||||
},
|
},
|
||||||
updateHowManyGames(context, payload) {
|
updateHowManySoundtracks(context, payload) {
|
||||||
context.commit("updateHowManyGames", payload);
|
context.commit("updateHowManySoundtracks", payload);
|
||||||
},
|
},
|
||||||
reloadGamesList(context, payload) {
|
reloadSoundtracksList(context, payload) {
|
||||||
context.commit("reloadGamesList", payload);
|
context.commit("reloadSoundtracksList", payload);
|
||||||
},
|
},
|
||||||
updateStopAfterCurrent(context, payload) {
|
updateStopAfterCurrent(context, payload) {
|
||||||
context.commit("updateStopAfterCurrent", payload);
|
context.commit("updateStopAfterCurrent", payload);
|
||||||
|
|||||||
Reference in New Issue
Block a user