mirror of
https://github.com/NebulaServices/Nebula.git
synced 2025-05-13 03:50:02 -04:00
Uninstall button
This commit is contained in:
parent
088071fa38
commit
053f2c1e66
4 changed files with 123 additions and 82 deletions
BIN
database_back.sqlite
Normal file
BIN
database_back.sqlite
Normal file
Binary file not shown.
48
server.js
48
server.js
|
@ -150,31 +150,31 @@ app.use("/scripts/", express.static("./database_assets/scripts"));
|
|||
app.use(ssrHandler);
|
||||
app.use(express.static(publicPath));
|
||||
|
||||
// await catalog_assets.create({
|
||||
// package_name: "com.nebula.cybermonay",
|
||||
// title: "Cyber Monay",
|
||||
// image: "cyber_monay.jpg",
|
||||
// author: "Nebula Services",
|
||||
// version: "1.0.0",
|
||||
// description: 'A parody of the famous "Cyber Monay" hack!',
|
||||
// tags: ["Hacking", "Animated", "Funny"],
|
||||
// payload: "com.nebula.cybermonay.css",
|
||||
// background_video: "cyber_monay_test.mp4",
|
||||
// type: "theme",
|
||||
// });
|
||||
await catalog_assets.create({
|
||||
package_name: "com.nebula.cybermonay",
|
||||
title: "Cyber Monay",
|
||||
image: "cyber_monay.jpg",
|
||||
author: "Nebula Services",
|
||||
version: "1.0.0",
|
||||
description: 'A parody of the famous "Cyber Monay" hack!',
|
||||
tags: ["Hacking", "Animated", "Funny"],
|
||||
payload: "com.nebula.cybermonay.css",
|
||||
background_video: "cyber_monay_test.mp4",
|
||||
type: "theme",
|
||||
});
|
||||
|
||||
// await catalog_assets.create({
|
||||
// package_name: "com.nebula.fortnite.jpg",
|
||||
// title: "Fortnite.jpg",
|
||||
// image: "fortnite.jpg",
|
||||
// author: "Nebula Services",
|
||||
// version: "1.0.0",
|
||||
// description: "Like the image in Ultraviolet, now on Nebula!",
|
||||
// tags: ["Image", "Funny"],
|
||||
// payload: "com.nebula.cybermonay.css",
|
||||
// background_image: "fortnite.jpg",
|
||||
// type: "theme",
|
||||
// });
|
||||
await catalog_assets.create({
|
||||
package_name: "com.nebula.fortnite.jpg",
|
||||
title: "Fortnite.jpg",
|
||||
image: "fortnite.jpg",
|
||||
author: "Nebula Services",
|
||||
version: "1.0.0",
|
||||
description: "Like the image in Ultraviolet, now on Nebula!",
|
||||
tags: ["Image", "Funny"],
|
||||
payload: "com.nebula.cybermonay.css",
|
||||
background_image: "fortnite.jpg",
|
||||
type: "theme",
|
||||
});
|
||||
|
||||
catalog_assets.sync();
|
||||
const server = createServer();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<script>
|
||||
let assetPromise = get_assets();
|
||||
|
||||
async function get_assets() {
|
||||
const response = await fetch("/api/catalog-assets");
|
||||
const data = await response.json();
|
||||
|
@ -11,42 +12,52 @@
|
|||
{#await assetPromise}
|
||||
Loading assets...
|
||||
{:then assets}
|
||||
<div class="flex flex-row gap-6 flex-wrap">
|
||||
{#each Object.entries(assets) as [key, asset]}
|
||||
<a href={"/assets/" + key}>
|
||||
<div
|
||||
class="bg-navbar-color w-64 rounded-3xl shadow-lg overflow-hidden transition-transform duration-300 hover:scale-105"
|
||||
>
|
||||
<img
|
||||
src={"/images/" + asset.image}
|
||||
alt={asset.title}
|
||||
class="w-full h-40 object-cover"
|
||||
/>
|
||||
<div class="p-6 text-sm">
|
||||
<div class="font-semibold text-2xl mb-2">
|
||||
{asset.title}
|
||||
{#if Object.keys(assets).length > 1}
|
||||
<div class="flex flex-row gap-6 flex-wrap">
|
||||
{#each Object.entries(assets) as [key, asset]}
|
||||
<a href={"/assets/" + key}>
|
||||
<div
|
||||
class="bg-navbar-color w-64 rounded-3xl shadow-lg overflow-hidden transition-transform duration-300 hover:scale-105"
|
||||
>
|
||||
<img
|
||||
src={"/images/" + asset.image}
|
||||
alt={asset.title}
|
||||
class="w-full h-40 object-cover"
|
||||
/>
|
||||
<div class="p-6 text-sm">
|
||||
<div class="font-semibold text-2xl mb-2">
|
||||
{asset.title}
|
||||
</div>
|
||||
<div class="mb-4">{asset.description}</div>
|
||||
<div class="flex flex-wrap gap-2 mb-4">
|
||||
{#each asset.tags as tag}
|
||||
<div
|
||||
class="bg-navbar-text-color text-navbar-color font-bold px-3 py-1 rounded-md text-center"
|
||||
>
|
||||
{tag}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
<div>
|
||||
<strong>Version:</strong>
|
||||
{asset.version}
|
||||
</div>
|
||||
<div><strong>Type:</strong> {asset.type}</div>
|
||||
</div>
|
||||
<div class="mb-4">{asset.description}</div>
|
||||
<div class="flex flex-wrap gap-2 mb-4">
|
||||
{#each asset.tags as tag}
|
||||
<div
|
||||
class="bg-navbar-text-color text-navbar-color font-bold px-3 py-1 rounded-md text-center"
|
||||
>
|
||||
{tag}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
<div>
|
||||
<strong>Version:</strong>
|
||||
{asset.version}
|
||||
</div>
|
||||
<div><strong>Type:</strong> {asset.type}</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<div class="text-2xl text-center text-text-color mt-6 w-96">
|
||||
No assets available at the moment. The server host's database is empty.
|
||||
Please contact the maintainer of this site if you think this is an
|
||||
error.
|
||||
</div>
|
||||
{/if}
|
||||
{:catch someError}
|
||||
System error: {someError.message}.
|
||||
<div class="text-lg text-center text-red-500 mt-6">
|
||||
System error: {someError.message}.
|
||||
</div>
|
||||
{/await}
|
||||
</div>
|
||||
|
|
|
@ -62,35 +62,65 @@ const assets_json = await response.json();
|
|||
}
|
||||
</div>
|
||||
<script is:inline define:vars={{ assets_json, package_name }}>
|
||||
// determine if this is installed
|
||||
let items = JSON.parse(localStorage.getItem("installed_themes")) || [];
|
||||
|
||||
const packageExists = items.indexOf(package_name) !== -1;
|
||||
|
||||
if (packageExists) {
|
||||
document.getElementById("install").textContent = "Uninstall";
|
||||
}
|
||||
|
||||
document.getElementById("install").addEventListener("click", install);
|
||||
function install() {
|
||||
let installedThemes = localStorage.getItem("installed_themes");
|
||||
if (packageExists) {
|
||||
const index = items.indexOf(package_name);
|
||||
items.splice(index, 1);
|
||||
localStorage.setItem("installed_themes", JSON.stringify(items));
|
||||
|
||||
if (installedThemes) {
|
||||
// If it exists, append it
|
||||
installedThemes = JSON.parse(installedThemes);
|
||||
installedThemes.push(package_name);
|
||||
} else {
|
||||
// If it doesn't exist, create a new array
|
||||
installedThemes = [package_name];
|
||||
}
|
||||
|
||||
localStorage.setItem("installed_themes", JSON.stringify(installedThemes));
|
||||
|
||||
if (assets_json.background_video) {
|
||||
localStorage.setItem("background_video", assets_json.background_video);
|
||||
} else {
|
||||
localStorage.removeItem("video");
|
||||
}
|
||||
if (assets_json.background_image) {
|
||||
localStorage.setItem("background_image", assets_json.background_image);
|
||||
} else {
|
||||
localStorage.removeItem("background_video");
|
||||
localStorage.removeItem("background_image");
|
||||
localStorage.removeItem("stylesheet");
|
||||
location.reload();
|
||||
} else {
|
||||
console.log("Package does not exist in the items array.");
|
||||
let installedThemes = localStorage.getItem("installed_themes");
|
||||
|
||||
if (installedThemes) {
|
||||
// If it exists, append it
|
||||
installedThemes = JSON.parse(installedThemes);
|
||||
installedThemes.push(package_name);
|
||||
} else {
|
||||
// If it doesn't exist, create a new array
|
||||
installedThemes = [package_name];
|
||||
}
|
||||
|
||||
localStorage.setItem(
|
||||
"installed_themes",
|
||||
JSON.stringify(installedThemes)
|
||||
);
|
||||
|
||||
if (assets_json.background_video) {
|
||||
localStorage.setItem(
|
||||
"background_video",
|
||||
assets_json.background_video
|
||||
);
|
||||
} else {
|
||||
localStorage.removeItem("video");
|
||||
}
|
||||
if (assets_json.background_image) {
|
||||
localStorage.setItem(
|
||||
"background_image",
|
||||
assets_json.background_image
|
||||
);
|
||||
} else {
|
||||
localStorage.removeItem("background_image");
|
||||
}
|
||||
if (assets_json.type == "theme") {
|
||||
localStorage.setItem("stylesheet", "/styles/" + assets_json.payload);
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
if (assets_json.type == "theme") {
|
||||
localStorage.setItem("stylesheet", "/styles/" + assets_json.payload);
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
</script>
|
||||
</Layout>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue