mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-15 17:21:13 +10:00
feat: beginnings of platform & redist management
This commit is contained in:
@ -73,6 +73,10 @@ export const systemACLDescriptions: ObjectFromList<typeof systemACLs> = {
|
||||
"game:image:new": "Upload an image for a game.",
|
||||
"game:image:delete": "Delete an image for a game.",
|
||||
|
||||
"redist:read": "Fetch redistributables on this instance.",
|
||||
"redist:update": "Update redistributables on this instance.",
|
||||
"redist:delete": "Delete redistributables on this instance.",
|
||||
|
||||
"company:read": "Fetch companies.",
|
||||
"company:create": "Create a new company.",
|
||||
"company:update": "Update existing companies.",
|
||||
|
||||
@ -67,6 +67,10 @@ export const systemACLs = [
|
||||
"game:image:new",
|
||||
"game:image:delete",
|
||||
|
||||
"redist:read",
|
||||
"redist:update",
|
||||
"redist:delete",
|
||||
|
||||
"company:read",
|
||||
"company:update",
|
||||
"company:create",
|
||||
|
||||
@ -128,29 +128,23 @@ class LibraryManager {
|
||||
}
|
||||
}
|
||||
|
||||
async fetchGamesWithStatus() {
|
||||
const games = await prisma.game.findMany({
|
||||
include: {
|
||||
versions: {
|
||||
select: {
|
||||
versionName: true,
|
||||
},
|
||||
},
|
||||
library: true,
|
||||
},
|
||||
orderBy: {
|
||||
mName: "asc",
|
||||
},
|
||||
});
|
||||
|
||||
async fetchLibraryObjectWithStatus<T>(
|
||||
objects: Array<
|
||||
{
|
||||
libraryId: string;
|
||||
libraryPath: string;
|
||||
versions: Array<unknown>;
|
||||
} & T
|
||||
>,
|
||||
) {
|
||||
return await Promise.all(
|
||||
games.map(async (e) => {
|
||||
objects.map(async (e) => {
|
||||
const versions = await this.fetchUnimportedGameVersions(
|
||||
e.libraryId ?? "",
|
||||
e.libraryPath,
|
||||
);
|
||||
return {
|
||||
game: e,
|
||||
value: e,
|
||||
status: versions
|
||||
? {
|
||||
noVersions: e.versions.length == 0,
|
||||
@ -162,6 +156,55 @@ class LibraryManager {
|
||||
);
|
||||
}
|
||||
|
||||
async fetchGamesWithStatus() {
|
||||
const games = await prisma.game.findMany({
|
||||
include: {
|
||||
versions: {
|
||||
select: {
|
||||
versionId: true,
|
||||
versionName: true,
|
||||
},
|
||||
},
|
||||
library: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
mName: "asc",
|
||||
},
|
||||
});
|
||||
|
||||
return await this.fetchLibraryObjectWithStatus(games);
|
||||
}
|
||||
|
||||
async fetchRedistsWithStatus() {
|
||||
const redists = await prisma.redist.findMany({
|
||||
include: {
|
||||
versions: {
|
||||
select: {
|
||||
versionId: true,
|
||||
versionName: true,
|
||||
},
|
||||
},
|
||||
library: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
platform: true,
|
||||
},
|
||||
orderBy: {
|
||||
mName: "asc",
|
||||
},
|
||||
});
|
||||
|
||||
return await this.fetchLibraryObjectWithStatus(redists);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches recommendations and extra data about the version. Doesn't actually check if it's been imported.
|
||||
* @param gameId
|
||||
|
||||
Reference in New Issue
Block a user