@@ -66,7 +87,7 @@ function onNavigate(event) {
v-if="isHovering || !rom.has_cover"
class="rom-title d-flex transition-fast-in-fast-out bg-tooltip text-caption"
>
- {{ rom.file_name }}
+ {{ rom.r_name || rom.file_name }}
@@ -79,7 +100,7 @@ function onNavigate(event) {
+ v-model="romsStore._selectedIDs"
+ >
{
+ //TODO: check if authenticated/session expired
+})
+
+export default router;
\ No newline at end of file
diff --git a/frontend/src/services/api.js b/frontend/src/services/api.js
index 9467a52ca..99b8e7a84 100644
--- a/frontend/src/services/api.js
+++ b/frontend/src/services/api.js
@@ -71,24 +71,42 @@ export async function downloadRomApi(rom, files) {
}
}
-export async function updateRomApi(rom, updatedData, renameAsIGDB) {
- const updatedRom = {
- r_igdb_id: updatedData.r_igdb_id,
- r_slug: updatedData.r_slug,
- summary: updatedData.summary,
- url_cover: updatedData.url_cover,
- url_screenshots: updatedData.url_screenshots,
- r_name: updatedData.r_name,
- file_name: renameAsIGDB
- ? rom.file_name.replace(rom.file_name_no_tags, updatedData.r_name)
- : updatedData.file_name,
- };
-
- return api.patch(`/platforms/${rom.p_slug}/roms/${rom.id}`, {
- updatedRom,
+export async function uploadRomsApi(romsToUpload, platform) {
+ let formData = new FormData();
+ romsToUpload.forEach((rom) => formData.append("roms", rom));
+ return api.put(`/platforms/${platform}/roms/upload`, formData, {
+ headers: {
+ "Content-Type": "multipart/form-data",
+ },
});
}
+export async function updateRomApi({
+ id,
+ r_igdb_id,
+ p_slug,
+ r_name,
+ r_slug,
+ file_name,
+ summary,
+ artwork,
+ url_cover,
+ url_screenshots,
+}) {
+ var formData = new FormData();
+ formData.append("r_igdb_id", r_igdb_id);
+ formData.append("r_name", r_name);
+ formData.append("r_slug", r_slug);
+ formData.append("file_name", file_name);
+ formData.append("url_cover", url_cover);
+ formData.append("summary", summary);
+ formData.append("url_screenshots", JSON.stringify(url_screenshots));
+ if (artwork) {
+ formData.append("artwork", artwork[0]);
+ }
+ return api.patch(`/platforms/${p_slug}/roms/${id}`, formData);
+}
+
export async function deleteRomApi(rom, deleteFromFs) {
return api.delete(
`/platforms/${rom.p_slug}/roms/${rom.id}?filesystem=${deleteFromFs}`
@@ -133,14 +151,14 @@ export async function updateUserApi({
enabled,
avatar,
}) {
- return api.put(
+ return api.patch(
`/users/${id}`,
{
avatar: avatar ? avatar[0] : null,
},
{
headers: {
- "Content-Type": avatar ? "multipart/form-data" : "text/text",
+ "Content-Type": avatar ? "multipart/form-data" : "application/json",
},
params: { username, password, role, enabled },
}
diff --git a/frontend/src/stores/galleryFilter.js b/frontend/src/stores/galleryFilter.js
index 4bfc29ad8..ced2ea4c9 100644
--- a/frontend/src/stores/galleryFilter.js
+++ b/frontend/src/stores/galleryFilter.js
@@ -2,11 +2,11 @@ import { defineStore } from "pinia";
import { normalizeString } from "@/utils/utils";
export default defineStore("galleryFilter", {
- state: () => ({ value: "" }),
+ state: () => ({ filter: "" }),
actions: {
set(filter) {
- this.value = normalizeString(filter);
+ this.filter = normalizeString(filter);
},
},
});
diff --git a/frontend/src/stores/galleryView.js b/frontend/src/stores/galleryView.js
index 44d64a89a..d8667c2b2 100644
--- a/frontend/src/stores/galleryView.js
+++ b/frontend/src/stores/galleryView.js
@@ -2,19 +2,19 @@ import { defineStore } from "pinia";
export default defineStore("galleryView", {
state: () => ({
- value: JSON.parse(localStorage.getItem("currentView")) || 0,
+ current: JSON.parse(localStorage.getItem("currentView")) || 0,
}),
actions: {
set(view) {
- this.value = view;
- localStorage.setItem("currentView", this.value);
+ this.current = view;
+ localStorage.setItem("currentView", this.current);
},
next() {
- if (this.value == 2) {
+ if (this.current == 2) {
this.set(0);
} else {
- this.set(this.value + 1);
+ this.set(this.current + 1);
}
},
},
diff --git a/frontend/src/stores/roms.js b/frontend/src/stores/roms.js
index 3f17d2bbe..9ee189450 100644
--- a/frontend/src/stores/roms.js
+++ b/frontend/src/stores/roms.js
@@ -1,26 +1,89 @@
import { defineStore } from "pinia";
export default defineStore("roms", {
- state: () => ({ selected: [], lastSelectedIndex: -1 }),
+ state: () => ({
+ _all: [],
+ _filteredIDs: [],
+ _searchIDs: [],
+ _selectedIDs: [],
+ lastSelectedIndex: -1,
+ cursor: "",
+ searchCursor: "",
+ touchScreen: false,
+ }),
+
+ getters: {
+ allRoms: (state) => state._all,
+ filteredRoms: (state) =>
+ state._all.filter((rom) => state._filteredIDs.includes(rom.id)),
+ searchRoms: (state) =>
+ state._all.filter((rom) => state._searchIDs.includes(rom.id)),
+ selectedRoms: (state) =>
+ state._all.filter((rom) => state._selectedIDs.includes(rom.id)),
+ },
actions: {
- updateSelectedRoms(roms) {
- this.selected = roms;
+ // All roms
+ set(roms) {
+ this._all = roms;
},
- addSelectedRoms(rom) {
- this.selected.push(rom);
+ add(roms) {
+ this._all = this._all.concat(roms);
},
- removeSelectedRoms(rom) {
- this.selected = this.selected.filter(function (value) {
- return value.id != rom.id;
+ update(rom) {
+ this._all = this._all.map((value) => {
+ if (value.id === rom.id) {
+ return rom;
+ }
+ return value;
});
},
- updateLastSelectedRom(index) {
+ remove(roms) {
+ this._all = this._all.filter((value) => {
+ return !roms.find((rom) => {
+ return rom.id === value.id;
+ });
+ });
+ },
+ reset() {
+ this._all = [];
+ this._filteredIDs = [];
+ this._searchIDs = [];
+ this._selectedIDs = [];
+ this.lastSelectedIndex = -1;
+ },
+
+ // Filtered roms
+ setFiltered(roms) {
+ this._filteredIDs = roms.map((rom) => rom.id);
+ },
+
+ // Search roms
+ setSearch(roms) {
+ this._searchIDs = roms.map((rom) => rom.id);
+ },
+
+ // Selected roms
+ setSelection(roms) {
+ this._selectedIDs = roms.map((rom) => rom.id);
+ },
+ addToSelection(rom) {
+ this._selectedIDs.push(rom.id);
+ },
+ removeFromSelection(rom) {
+ this._selectedIDs = this._selectedIDs.filter((id) => {
+ return id !== rom.id;
+ });
+ },
+ updateLastSelected(index) {
this.lastSelectedIndex = index;
},
- reset(){
- this.selected = [];
+ isTouchScreen(touchScreen) {
+ this.touchScreen = touchScreen;
+ },
+ resetSelection() {
+ this._selectedIDs = [];
this.lastSelectedIndex = -1;
- }
+ },
},
});
diff --git a/frontend/src/stores/users.js b/frontend/src/stores/users.js
new file mode 100644
index 000000000..bfe38b839
--- /dev/null
+++ b/frontend/src/stores/users.js
@@ -0,0 +1,36 @@
+import { defineStore } from "pinia";
+
+export default defineStore("users", {
+ state: () => ({
+ all: [],
+ }),
+
+ getters: {
+ admins: (state) => state.all.filter((user) => user.role === "admin"),
+ },
+
+ actions: {
+ set(users) {
+ this.all = users;
+ },
+ add(user) {
+ this.all = this.all.concat(user);
+ },
+ update(user) {
+ this.all = this.all.map((value) => {
+ if (value.id === user.id) {
+ return user;
+ }
+ return value;
+ })
+ },
+ remove(user) {
+ this.all = this.all.filter((value) => {
+ return value.id !== user.id;
+ })
+ },
+ reset() {
+ this.all = [];
+ }
+ }
+});
diff --git a/frontend/src/views/Details/Base.vue b/frontend/src/views/Details/Base.vue
index d7536dbd5..50454b99a 100644
--- a/frontend/src/views/Details/Base.vue
+++ b/frontend/src/views/Details/Base.vue
@@ -2,7 +2,9 @@
import { ref, inject, onBeforeMount } from "vue";
import { useRoute } from "vue-router";
import { useDisplay } from "vuetify";
+import { storeToRefs } from "pinia";
import { fetchRomApi, downloadRomApi } from "@/services/api";
+import storeRoms from "@/stores/roms";
import storeDownload from "@/stores/download";
import storeAuth from "@/stores/auth";
import BackgroundHeader from "@/components/Game/Details/BackgroundHeader.vue";
@@ -14,10 +16,11 @@ import LoadingDialog from "@/components/Dialog/Loading.vue";
// Props
const route = useRoute();
+const romsStore = storeRoms();
+const { allRoms } = storeToRefs(romsStore);
+const rom = ref(allRoms.value.find((rom) => rom.id == route.params.rom));
const downloadStore = storeDownload();
const auth = storeAuth();
-const rom = ref();
-const updatedRom = ref();
const saveFiles = ref(false);
const filesToDownload = ref();
const tab = ref("details");
@@ -30,18 +33,27 @@ const emitter = inject("emitter");
// Functions
onBeforeMount(async () => {
emitter.emit("showLoadingDialog", { loading: true, scrim: false });
- await fetchRomApi(route.params.platform, route.params.rom)
- .then((response) => {
- rom.value = response.data;
- updatedRom.value = response.data;
- downloadUrl.value = `${window.location.origin}${rom.value.download_path}`;
- })
- .catch((error) => {
- console.log(error);
- })
- .finally(() => {
- emitter.emit("showLoadingDialog", { loading: false, scrim: false });
- });
+ if (rom.value) {
+ emitter.emit("showLoadingDialog", { loading: false, scrim: false });
+ } else {
+ await fetchRomApi(route.params.platform, route.params.rom)
+ .then((response) => {
+ rom.value = response.data;
+ romsStore.update(response.data);
+ downloadUrl.value = `${window.location.origin}${rom.value.download_path}`;
+ })
+ .catch((error) => {
+ console.log(error);
+ emitter.emit("snackbarShow", {
+ msg: error.response.data.detail,
+ icon: "mdi-close-circle",
+ color: "red",
+ });
+ })
+ .finally(() => {
+ emitter.emit("showLoadingDialog", { loading: false, scrim: false });
+ });
+ }
});
@@ -69,11 +81,10 @@ onBeforeMount(async () => {
+
{
-
+
diff --git a/frontend/src/views/Gallery/Base.vue b/frontend/src/views/Gallery/Base.vue
index 2e2ec3340..f465ed84c 100644
--- a/frontend/src/views/Gallery/Base.vue
+++ b/frontend/src/views/Gallery/Base.vue
@@ -1,18 +1,17 @@
-
-
-
-
-
-
+
-
-
+
+
@@ -280,32 +228,30 @@ onBeforeRouteUpdate(async (to, _) => {
{{ romsStore.selected.length }}{{ romsStore._selectedIDs.length }}
-
+
+