pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/Drop-OSS/drop/commit/329c74d3ce3a72ca2d4a0777a4e19ccb3e1556d9

0fcd9af82350aeda.css" /> game version re-ordering · Drop-OSS/drop@329c74d · GitHub
Skip to content

Commit 329c74d

Browse files
committed
game version re-ordering
1 parent 8674ac7 commit 329c74d

File tree

18 files changed

+354
-50
lines changed

18 files changed

+354
-50
lines changed

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"postinstall": "nuxt prepare"
1111
},
1212
"dependencies": {
13-
"@drop/droplet": "^0.4.4",
13+
"@drop/droplet": "^0.5.0",
1414
"@headlessui/vue": "^1.7.23",
1515
"@heroicons/vue": "^2.1.5",
1616
"@prisma/client": "5.20.0",
@@ -28,7 +28,8 @@
2828
"turndown": "^7.2.0",
2929
"uuid": "^10.0.0",
3030
"vue": "latest",
31-
"vue-router": "latest"
31+
"vue-router": "latest",
32+
"vuedraggable": "^4.1.0"
3233
},
3334
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
3435
"devDependencies": {
@@ -46,7 +47,7 @@
4647
"tailwindcss": "^3.4.13"
4748
},
4849
"optionalDependencies": {
49-
"@drop/droplet-linux-x64-gnu": "^0.4.4",
50-
"@drop/droplet-win32-x64-msvc": "^0.4.4"
50+
"@drop/droplet-linux-x64-gnu": "^0.5.0",
51+
"@drop/droplet-win32-x64-msvc": "^0.5.0"
5152
}
5253
}

pages/admin/library/[id]/import.vue

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
</div>
7575
</Listbox>
7676

77-
<div class="flex flex-col gap-4 max-w-md" v-if="versionSettings">
77+
<div class="flex flex-col gap-8 max-w-md" v-if="versionSettings">
7878
<div>
7979
<label
8080
for="startup"
@@ -130,7 +130,41 @@
130130
<PlatformSelector v-model="versionSettings.platform">
131131
Version platform
132132
</PlatformSelector>
133-
<LoadingButton @click="startImport_wrapper" class="w-fit" :loading="importLoading">
133+
<SwitchGroup as="div" class="flex items-center justify-between">
134+
<span class="flex flex-grow flex-col">
135+
<SwitchLabel
136+
as="span"
137+
class="text-sm font-medium leading-6 text-zinc-100"
138+
passive
139+
>Update mode</SwitchLabel
140+
>
141+
<SwitchDescription as="span" class="text-sm text-zinc-400"
142+
>When enabled, these files will be installed on top of (overwriting)
143+
the previous version's. If multiple "update modes" are chained
144+
together, they are applied in order.</SwitchDescription
145+
>
146+
</span>
147+
<Switch
148+
v-model="delta"
149+
:class="[
150+
delta ? 'bg-blue-600' : 'bg-zinc-800',
151+
'relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2',
152+
]"
153+
>
154+
<span
155+
aria-hidden="true"
156+
:class="[
157+
delta ? 'translate-x-5' : 'translate-x-0',
158+
'pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out',
159+
]"
160+
/>
161+
</Switch>
162+
</SwitchGroup>
163+
<LoadingButton
164+
@click="startImport_wrapper"
165+
class="w-fit"
166+
:loading="importLoading"
167+
>
134168
Import
135169
</LoadingButton>
136170
<div v-if="importError" class="mt-4 w-fit rounded-md bg-red-600/10 p-4">
@@ -180,6 +214,10 @@ import {
180214
ListboxLabel,
181215
ListboxOption,
182216
ListboxOptions,
217+
Switch,
218+
SwitchDescription,
219+
SwitchGroup,
220+
SwitchLabel,
183221
} from "@headlessui/vue";
184222
import { XCircleIcon } from "@heroicons/vue/16/solid";
185223
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/20/solid";
@@ -203,6 +241,7 @@ const currentlySelectedVersion = ref(-1);
203241
const versionSettings = ref<
204242
{ platform: string; startup: string; setup: string } | undefined
205243
>();
244+
const delta = ref(false);
206245
207246
const importLoading = ref(false);
208247
const importError = ref<string | undefined>();
@@ -233,6 +272,7 @@ async function startImport() {
233272
platform: versionSettings.value.platform,
234273
startup: versionSettings.value.startup,
235274
setup: versionSettings.value.setup,
275+
delta: delta.value
236276
},
237277
});
238278
router.push(`/admin/task/${taskId.taskId}`);

pages/admin/library/[id]/index.vue

Lines changed: 74 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,18 @@
1111
class="mt-5 pt-5 border-t border-zinc-700 prose prose-invert prose-blue"
1212
></div>
1313
</div>
14-
<div>
14+
<div class="space-y-8">
1515
<div class="px-4 py-3 bg-gray-950 rounded">
1616
<div class="border-b border-zinc-800 pb-3">
1717
<div
18-
class="-ml-4 -mt-2 flex flex-wrap items-center justify-between sm:flex-nowrap"
18+
class="flex flex-wrap items-center justify-between sm:flex-nowrap"
1919
>
20-
<div class="ml-4 mt-2">
21-
<h3
22-
class="text-base font-semibold font-display leading-6 text-zinc-100"
23-
>
24-
Images
25-
</h3>
26-
</div>
27-
<div class="ml-4 mt-2 flex-shrink-0">
20+
<h3
21+
class="text-base font-semibold font-display leading-6 text-zinc-100"
22+
>
23+
Images
24+
</h3>
25+
<div class="flex-shrink-0">
2826
<button
2927
@click="() => (showUploadModal = true)"
3028
type="button"
@@ -90,6 +88,39 @@
9088
</div>
9189
</div>
9290
</div>
91+
<div class="py-5 px-6 bg-gray-950 rounded">
92+
<h1 class="text-2xl font-semibold font-display text-zinc-100">
93+
Manage version order
94+
</h1>
95+
<div class="text-center w-full text-sm text-zinc-600">lowest</div>
96+
<draggable
97+
@update="() => updateVersionOrder()"
98+
:list="game.versions"
99+
handle=".handle"
100+
class="mt-2 space-y-4"
101+
>
102+
<template #item="{ element: item }: { element: GameVersion }">
103+
<div
104+
class="w-full inline-flex items-center px-4 py-2 bg-zinc-900 rounded justify-between"
105+
>
106+
<div class="text-zinc-100 font-semibold">
107+
{{ item.versionName }}
108+
</div>
109+
<div class="text-zinc-400">
110+
{{ item.delta ? "Upgrade mode" : "" }}
111+
</div>
112+
<div class="inline-flex gap-x-2">
113+
<Bars3Icon class="cursor-move w-6 h-6 text-zinc-400 handle" />
114+
<button @click="() => deleteVersion(item.versionName)">
115+
<TrashIcon class="w-5 h-5 text-red-600" />
116+
</button>
117+
</div>
118+
</div>
119+
</template>
120+
</draggable>
121+
<div class="mt-2 text-center w-full text-sm text-zinc-600">highest</div>
122+
<span class="text-zinc-100">{{ game.versions }}</span>
123+
</div>
93124
</div>
94125
</div>
95126
<UploadFileDialog
@@ -102,7 +133,8 @@
102133
</template>
103134

104135
<script setup lang="ts">
105-
import type { Game } from "@prisma/client";
136+
import { Bars3Icon, TrashIcon } from "@heroicons/vue/16/solid";
137+
import type { Game, GameVersion } from "@prisma/client";
106138
import markdownit from "markdown-it";
107139
import UploadFileDialog from "~/components/UploadFileDialog.vue";
108140
@@ -116,9 +148,12 @@ const route = useRoute();
116148
const gameId = route.params.id.toString();
117149
const headers = useRequestHeaders(["cookie"]);
118150
const game = ref(
119-
await $fetch<Game>(`/api/v1/admin/game?id=${encodeURIComponent(gameId)}`, {
120-
headers,
121-
})
151+
await $fetch(
152+
`/api/v1/admin/game?id=${encodeURIComponent(gameId)}`,
153+
{
154+
headers,
155+
}
156+
)
122157
);
123158
124159
const md = markdownit();
@@ -167,4 +202,29 @@ async function uploadAfterImageUpload(result: Game) {
167202
if (!game.value) return;
168203
game.value.mImageLibrary = result.mImageLibrary;
169204
}
205+
206+
async function deleteVersion(versionName: string) {
207+
await $fetch("/api/v1/admin/game/version", {
208+
method: "DELETE",
209+
body: {
210+
id: gameId,
211+
versionName: versionName,
212+
},
213+
});
214+
game.value.versions.splice(
215+
game.value.versions.findIndex((e) => e.versionName === versionName),
216+
1
217+
);
218+
}
219+
220+
async function updateVersionOrder() {
221+
const newVersions = await $fetch("/api/v1/admin/game/version", {
222+
method: "POST",
223+
body: {
224+
id: gameId,
225+
versions: game.value.versions.map((e) => e.versionName),
226+
},
227+
});
228+
game.value.versions = newVersions;
229+
}
170230
</script>

plugins/vuedraggable.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import draggable from "vuedraggable";
2+
3+
export default defineNuxtPlugin((nuxtApp) => {
4+
nuxtApp.vueApp.component("draggable", draggable);
5+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
Warnings:
3+
4+
- Added the required column `versionIndex` to the `GameVersion` table without a default value. This is not possible if the table is not empty.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "GameVersion" ADD COLUMN "delta" BOOLEAN NOT NULL DEFAULT false,
9+
ADD COLUMN "versionIndex" INTEGER NOT NULL;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `versionOrder` on the `Game` table. All the data in the column will be lost.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "Game" DROP COLUMN "versionOrder";

prisma/schema.prisma

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ model Game {
9191
mCoverId String
9292
mImageLibrary String[] // linked to objects in s3
9393
94-
versionOrder String[]
9594
versions GameVersion[]
9695
libraryBasePath String @unique // Base dir for all the game versions
9796
@@ -109,6 +108,9 @@ model GameVersion {
109108
setupCommand String // Command to setup game (dependencies and such)
110109
dropletManifest Json // Results from droplet
111110
111+
versionIndex Int
112+
delta Boolean @default(false)
113+
112114
@@id([gameId, versionName])
113115
}
114116

server/api/v1/admin/game/index.get.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ export default defineEventHandler(async (h3) => {
1616
where: {
1717
id: gameId,
1818
},
19+
include: {
20+
versions: {
21+
orderBy: {
22+
versionIndex: "asc",
23+
},
24+
select: {
25+
versionIndex: true,
26+
versionName: true,
27+
platform: true,
28+
delta: true,
29+
}
30+
},
31+
},
1932
});
2033

2134
if (!game)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import prisma from "~/server/internal/db/database";
2+
3+
export default defineEventHandler(async (h3) => {
4+
const user = await h3.context.session.getAdminUser(h3);
5+
if (!user) throw createError({ statusCode: 403 });
6+
7+
const body = await readBody(h3);
8+
const gameId = body.id.toString();
9+
const version = body.versionName.toString();
10+
if (!gameId || !version)
11+
throw createError({
12+
statusCode: 400,
13+
statusMessage: "Missing ID or versionName in body",
14+
});
15+
16+
await prisma.gameVersion.delete({
17+
where: {
18+
gameId_versionName: {
19+
gameId: gameId,
20+
versionName: version,
21+
},
22+
},
23+
});
24+
25+
return {};
26+
});
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import prisma from "~/server/internal/db/database";
2+
3+
export default defineEventHandler(async (h3) => {
4+
const user = await h3.context.session.getAdminUser(h3);
5+
if (!user) throw createError({ statusCode: 403 });
6+
7+
const body = await readBody(h3);
8+
const gameId = body.id?.toString();
9+
// We expect an array of the version names for this game
10+
const versions: string[] | undefined = body.versions;
11+
if (!gameId || !versions || !Array.isArray(versions))
12+
throw createError({
13+
statusCode: 400,
14+
statusMessage: "Missing id, versions or versions is not an array",
15+
});
16+
17+
const newVersions = await prisma.$transaction(
18+
versions.map((versionName, versionIndex) =>
19+
prisma.gameVersion.update({
20+
where: {
21+
gameId_versionName: {
22+
gameId: gameId,
23+
versionName: versionName,
24+
},
25+
},
26+
data: {
27+
versionIndex: versionIndex,
28+
},
29+
select: {
30+
versionIndex: true,
31+
versionName: true,
32+
platform: true,
33+
delta: true,
34+
}
35+
})
36+
)
37+
);
38+
39+
return newVersions;
40+
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy