Skip to content

Commit

Permalink
Reformatted
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Oct 3, 2023
1 parent 7c136e6 commit 51863a0
Show file tree
Hide file tree
Showing 23 changed files with 800 additions and 798 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/push-ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: 'push-ghcr'
on:
push:
branches:
- main
- main
workflow_dispatch:

jobs:
Expand All @@ -20,4 +20,4 @@ jobs:
username: "WillFP"
password: ${{ secrets.ACCESS_TOKEN }}
repository: auxilor/lrcdb
tags: latest
tags: latest
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# lrcdb

libreforge config database

An open online database of config for all [libreforge](https://github.com/Auxilor/libreforge)-based plugins
128 changes: 64 additions & 64 deletions components/AdminCardOptions.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
import { Button } from "@mui/joy"
import { useState } from "react"
import { FaShare, FaSpinner, FaTrash } from "react-icons/fa"
import {Button} from "@mui/joy"
import {useState} from "react"
import {FaShare, FaSpinner, FaTrash} from "react-icons/fa"

export default function AdminOptions(props) {
const [deleting, setDeleting] = useState(false)
const [publicizing, setPublicizing] = useState(false)
const [deleting, setDeleting] = useState(false)
const [publicizing, setPublicizing] = useState(false)

const config = props.config
const apiKey = props.apiKey
const updateConfigs = props.updateConfigs
const config = props.config
const apiKey = props.apiKey
const updateConfigs = props.updateConfigs

return (
<div className="self-center flex flex-row gap-4">
{config.isPrivate &&
<Button
variant="outlined"
size="md"
className="text-l"
color="success"
onClick={() => {
setPublicizing(true)
return (
<div className="self-center flex flex-row gap-4">
{config.isPrivate &&
<Button
variant="outlined"
size="md"
className="text-l"
color="success"
onClick={() => {
setPublicizing(true)

fetch(`/api/v1/publicizeConfig`, {
method: 'PATCH',
body: JSON.stringify({
apiKey: apiKey,
id: config.id
}),
headers: {
"Content-Type": "application/json"
}
})
.then(() => updateConfigs())
.catch(err => console.error(err))
.finally(() => setPublicizing(false))
}}
>
{publicizing ? <FaSpinner className="animate-spin" /> : <FaShare />}
</Button>
}
fetch(`/api/v1/publicizeConfig`, {
method: 'PATCH',
body: JSON.stringify({
apiKey: apiKey,
id: config.id
}),
headers: {
"Content-Type": "application/json"
}
})
.then(() => updateConfigs())
.catch(err => console.error(err))
.finally(() => setPublicizing(false))
}}
>
{publicizing ? <FaSpinner className="animate-spin"/> : <FaShare/>}
</Button>
}

<Button
variant="outlined"
size="md"
className="text-l"
color="danger"
onClick={() => {
setDeleting(true)
<Button
variant="outlined"
size="md"
className="text-l"
color="danger"
onClick={() => {
setDeleting(true)

fetch(`/api/v1/deleteConfig`, {
method: 'DELETE',
body: JSON.stringify({
apiKey: apiKey,
id: config.id
}),
headers: {
"Content-Type": "application/json"
}
})
.then(() => updateConfigs())
.catch(err => {
console.error(err)
})
.finally(() => setDeleting(false))
}}
>
{deleting ? <FaSpinner className="animate-spin" /> : <FaTrash />}
</Button>
</div>
)
fetch(`/api/v1/deleteConfig`, {
method: 'DELETE',
body: JSON.stringify({
apiKey: apiKey,
id: config.id
}),
headers: {
"Content-Type": "application/json"
}
})
.then(() => updateConfigs())
.catch(err => {
console.error(err)
})
.finally(() => setDeleting(false))
}}
>
{deleting ? <FaSpinner className="animate-spin"/> : <FaTrash/>}
</Button>
</div>
)
}
154 changes: 77 additions & 77 deletions components/ConfigCard.js
Original file line number Diff line number Diff line change
@@ -1,86 +1,86 @@
import { Button, Card, Typography } from "@mui/joy";
import { useState } from "react";
import { FaDownload, FaEye, FaSpinner } from "react-icons/fa";
import { getPluginByName } from "../lib/plugins";
import {Button, Card, Typography} from "@mui/joy";
import {useState} from "react";
import {FaDownload, FaEye, FaSpinner} from "react-icons/fa";
import {getPluginByName} from "../lib/plugins";
import AdminCardOptions from "./AdminCardOptions"

export default function ConfigCard(props) {
const [loadingPreview, setLoadingPreview] = useState(false)
const [loadingPreview, setLoadingPreview] = useState(false)

const config = props.config
const plugin = getPluginByName(config.plugin)
const apiKey = props.apiKey
const authorized = props.authorized
const setConfigPreview = props.setConfigPreview
const updateConfigs = props.updateConfigs
const config = props.config
const plugin = getPluginByName(config.plugin)
const apiKey = props.apiKey
const authorized = props.authorized
const setConfigPreview = props.setConfigPreview
const updateConfigs = props.updateConfigs

return (
<Card variant="outlined transition ease-in-out hover:-translate-y-1 hover:shadow-lg">
<div className="flex flex-row gap-4">
<img src={plugin.image} className="h-0 w-0 md:h-16 md:w-16 col-span-3" />
<div className="flex flex-col place-content-center mb-1 col-span-7 overflow-hidden">
<div className="flex">
<Typography className="text-xl">
{config.name}
</Typography>
<Typography className="text-slate-400 text-xl">
.yml
</Typography>
</div>
<div className="flex gap-2">
<Typography
className="text-slate-600 text-sm"
>
by {config.author}
</Typography>
</div>
</div>
<div className="flex flex-row gap-4 ml-auto">
<div className="flex flex-col place-content-center items-end">
<Typography
className="text-slate-600 text-sm"
endDecorator={<FaEye />}
>
{config.views}
</Typography>
<Typography
className="text-slate-600 text-sm"
endDecorator={<FaDownload />}
>
{config.downloads}
</Typography>
</div>
return (
<Card variant="outlined transition ease-in-out hover:-translate-y-1 hover:shadow-lg">
<div className="flex flex-row gap-4">
<img src={plugin.image} className="h-0 w-0 md:h-16 md:w-16 col-span-3"/>
<div className="flex flex-col place-content-center mb-1 col-span-7 overflow-hidden">
<div className="flex">
<Typography className="text-xl">
{config.name}
</Typography>
<Typography className="text-slate-400 text-xl">
.yml
</Typography>
</div>
<div className="flex gap-2">
<Typography
className="text-slate-600 text-sm"
>
by {config.author}
</Typography>
</div>
</div>
<div className="flex flex-row gap-4 ml-auto">
<div className="flex flex-col place-content-center items-end">
<Typography
className="text-slate-600 text-sm"
endDecorator={<FaEye/>}
>
{config.views}
</Typography>
<Typography
className="text-slate-600 text-sm"
endDecorator={<FaDownload/>}
>
{config.downloads}
</Typography>
</div>

{
authorized && <AdminCardOptions
updateConfigs={updateConfigs}
apiKey={apiKey}
config={config}
/>
}
{
authorized && <AdminCardOptions
updateConfigs={updateConfigs}
apiKey={apiKey}
config={config}
/>
}

<Button
variant="outlined"
size="md"
className="self-center text-l"
onClick={() => {
setLoadingPreview(true)
<Button
variant="outlined"
size="md"
className="self-center text-l"
onClick={() => {
setLoadingPreview(true)

fetch(`/api/v1/getConfigByID?id=${config.id}`)
.then(res => res.json())
.then(data => {
setConfigPreview(data.config)
})
.catch(err => {
console.error(err)
})
.finally(() => setLoadingPreview(false))
}}
>
{loadingPreview ? <FaSpinner className="animate-spin" /> : "Preview"}
</Button>
</div>
</div>
</Card>
)
fetch(`/api/v1/getConfigByID?id=${config.id}`)
.then(res => res.json())
.then(data => {
setConfigPreview(data.config)
})
.catch(err => {
console.error(err)
})
.finally(() => setLoadingPreview(false))
}}
>
{loadingPreview ? <FaSpinner className="animate-spin"/> : "Preview"}
</Button>
</div>
</div>
</Card>
)
}
Loading

0 comments on commit 51863a0

Please sign in to comment.