mirror of
https://github.com/Radiquum/YAMPD.git
synced 2025-05-20 07:39:35 +05:00
feat: mod delete
This commit is contained in:
parent
e453f336a8
commit
34df17d4dd
3 changed files with 133 additions and 399 deletions
|
@ -1,4 +1,7 @@
|
|||
import { MOD_ENDPOINT } from "@/api/ENDPOINTS";
|
||||
import { Mod } from "@/types/mod";
|
||||
import {
|
||||
Button,
|
||||
Checkbox,
|
||||
Table,
|
||||
TableBody,
|
||||
|
@ -7,8 +10,33 @@ import {
|
|||
TableHeadCell,
|
||||
TableRow,
|
||||
} from "flowbite-react";
|
||||
import { HiDownload, HiTrash } from "react-icons/hi";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
export const ModTable = (props: {
|
||||
mods: Mod[];
|
||||
updatePack: () => void;
|
||||
packID: string;
|
||||
}) => {
|
||||
async function deleteMod(slug: string, title: string) {
|
||||
if (!window) return;
|
||||
if (window.confirm(`Delete mod ${title}?`)) {
|
||||
const res = await fetch(MOD_ENDPOINT("deleteMod", props.packID, slug));
|
||||
const data = await res.json();
|
||||
|
||||
if (data.status != "ok") {
|
||||
toast.error(data.message, {
|
||||
autoClose: 2500,
|
||||
closeOnClick: true,
|
||||
draggable: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
props.updatePack();
|
||||
}
|
||||
}
|
||||
|
||||
export const ModTable = () => {
|
||||
return (
|
||||
<div className="overflow-x-auto">
|
||||
<Table hoverable>
|
||||
|
@ -17,395 +45,66 @@ export const ModTable = () => {
|
|||
<TableHeadCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableHeadCell>
|
||||
<TableHeadCell>Product name</TableHeadCell>
|
||||
<TableHeadCell>Color</TableHeadCell>
|
||||
<TableHeadCell>Category</TableHeadCell>
|
||||
<TableHeadCell>Price</TableHeadCell>
|
||||
<TableHeadCell>Icon</TableHeadCell>
|
||||
<TableHeadCell>Title</TableHeadCell>
|
||||
<TableHeadCell>Version</TableHeadCell>
|
||||
<TableHeadCell>Developer</TableHeadCell>
|
||||
<TableHeadCell>Source</TableHeadCell>
|
||||
<TableHeadCell>Source URL</TableHeadCell>
|
||||
<TableHeadCell>
|
||||
<span className="sr-only">Edit</span>
|
||||
<span className="sr-only">Actions</span>
|
||||
</TableHeadCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody className="divide-y">
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Apple MacBook Pro 17
|
||||
</TableCell>
|
||||
<TableCell>Sliver</TableCell>
|
||||
<TableCell>Laptop</TableCell>
|
||||
<TableCell>$2999</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Microsoft Surface Pro
|
||||
</TableCell>
|
||||
<TableCell>White</TableCell>
|
||||
<TableCell>Laptop PC</TableCell>
|
||||
<TableCell>$1999</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow className="bg-white dark:border-gray-700 dark:bg-gray-800">
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
Magic Mouse 2
|
||||
</TableCell>
|
||||
<TableCell>Black</TableCell>
|
||||
<TableCell>Accessories</TableCell>
|
||||
<TableCell>$99</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href="#"
|
||||
className="font-medium text-cyan-600 hover:underline dark:text-cyan-500"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
</TableCell>
|
||||
{props.mods &&
|
||||
props.mods.length > 0 &&
|
||||
props.mods.map((mod) => {
|
||||
return (
|
||||
<TableRow
|
||||
key={`mod-${mod.slug}`}
|
||||
className="bg-white dark:border-gray-700 dark:bg-gray-800"
|
||||
>
|
||||
<TableCell className="p-4">
|
||||
<Checkbox />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img alt="" src={mod.icon} className="w-8 h-8 rounded-lg" />
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap font-medium text-gray-900 dark:text-white">
|
||||
{mod.title}
|
||||
</TableCell>
|
||||
<TableCell>{mod.file.version}</TableCell>
|
||||
<TableCell>{mod.developers.join(", ")}</TableCell>
|
||||
<TableCell>{mod.source}</TableCell>
|
||||
<TableCell>{mod.url}</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex gap-2">
|
||||
<Button size="sm">
|
||||
Download <HiDownload className="ml-2 h-4 w-4" />
|
||||
</Button>
|
||||
<Button
|
||||
color={"red"}
|
||||
size="sm"
|
||||
onClick={() => deleteMod(mod.slug, mod.title)}
|
||||
>
|
||||
Delete <HiTrash className="ml-2 h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
<TableRow className="bg-white dark:bg-[#374151] hover:bg-white! hover:dark:bg-[#374151]! dark:border-gray-700">
|
||||
<TableCell className="p-4"></TableCell>
|
||||
<TableCell></TableCell>
|
||||
<TableCell></TableCell>
|
||||
<TableCell></TableCell>
|
||||
<TableCell></TableCell>
|
||||
<TableCell></TableCell>
|
||||
<TableCell></TableCell>
|
||||
<TableCell></TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
|
|
@ -18,11 +18,9 @@ import { Modal, ModalBody, ModalFooter, ModalHeader } from "flowbite-react";
|
|||
import { HiDownload, HiPlusCircle, HiTrash } from "react-icons/hi";
|
||||
import { ModTable } from "../components/ModTable";
|
||||
import { toast } from "react-toastify";
|
||||
import { Mod } from "@/types/mod";
|
||||
|
||||
export default function PackPage() {
|
||||
const [packData, setPackData] = useState<Pack | null>(null);
|
||||
const [packMods, setPackMods] = useState<Mod[]>([]);
|
||||
const [packDataLoading, setPackDataLoading] = useState(true);
|
||||
const router = useRouter();
|
||||
const id = useSearchParams().get("id") || "";
|
||||
|
@ -43,15 +41,15 @@ export default function PackPage() {
|
|||
// version: null,
|
||||
// });
|
||||
|
||||
async function _getPacksData() {
|
||||
const res = await fetch(PACK_ENDPOINT("getPack", id));
|
||||
if (!res.ok) router.push("/404");
|
||||
const data: Pack = await res.json();
|
||||
setPackData(data);
|
||||
setPackDataLoading(false);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
async function _getPacksData() {
|
||||
const res = await fetch(PACK_ENDPOINT("getPack", id));
|
||||
if (!res.ok) router.push("/404");
|
||||
const data: Pack = await res.json();
|
||||
setPackData(data);
|
||||
setPackMods(data.mods);
|
||||
setPackDataLoading(false);
|
||||
}
|
||||
if (id) {
|
||||
_getPacksData();
|
||||
} else {
|
||||
|
@ -205,7 +203,6 @@ export default function PackPage() {
|
|||
return;
|
||||
}
|
||||
|
||||
setPackMods([...packMods, data.mod]);
|
||||
toast.update(tid, {
|
||||
render: data.message,
|
||||
type: "success",
|
||||
|
@ -214,7 +211,9 @@ export default function PackPage() {
|
|||
closeOnClick: true,
|
||||
draggable: true,
|
||||
});
|
||||
setModUrl({ ...modUrl, value: "" })
|
||||
setModUrl({ ...modUrl, value: "" });
|
||||
|
||||
_getPacksData();
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -253,7 +252,15 @@ export default function PackPage() {
|
|||
<p className="text-sm text-gray-400">by {packData.author}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<div className="flex gap-2 items-center">
|
||||
<div>
|
||||
<p className="text-lg font-semibold">
|
||||
{packData.mods.length} mods
|
||||
</p>
|
||||
<p className="text-sm text-gray-400">
|
||||
v{packData.modpackVersion}
|
||||
</p>
|
||||
</div>
|
||||
<Button onClick={() => setAddModModalOpen(true)}>
|
||||
Add mod <HiPlusCircle className="ml-2 h-5 w-5" />
|
||||
</Button>
|
||||
|
@ -267,7 +274,7 @@ export default function PackPage() {
|
|||
</div>
|
||||
</Card>
|
||||
<div className="mt-4">
|
||||
<ModTable />
|
||||
<ModTable mods={packData.mods} updatePack={_getPacksData} packID={id} />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
|
|
@ -106,3 +106,31 @@ def addMod(id):
|
|||
"mod": mod.get("mod"),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@apiPack.route("/<id>/mod/<slug>/delete", methods=["GET"])
|
||||
def deleteMod(id, slug):
|
||||
pack = {}
|
||||
with open(f"{PACKS_FOLDER}/{id}/packfile.json") as fp:
|
||||
pack = json.load(fp)
|
||||
fp.close()
|
||||
|
||||
for mod in pack.get("mods"):
|
||||
if mod.get("slug") == slug:
|
||||
pack["mods"].remove(mod)
|
||||
pack["modpackVersion"] += 1
|
||||
if os.path.exists(
|
||||
f"{PACKS_FOLDER}/{id}/mods/{mod.get('file').get('filename')}"
|
||||
):
|
||||
os.remove(f"{PACKS_FOLDER}/{id}/mods/{mod.get('file').get('filename')}")
|
||||
|
||||
with open(f"{PACKS_FOLDER}/{id}/packfile.json", mode="w", encoding="utf-8") as fp:
|
||||
json.dump(pack, fp)
|
||||
fp.close()
|
||||
|
||||
return jsonify(
|
||||
{
|
||||
"status": "ok",
|
||||
"message": f"mod {slug} has been removed",
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue