Skip to content

Commit

Permalink
fix: fixed about page github errors and other minor improvements (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushSehrawat authored Jun 6, 2024
1 parent 03cd45c commit 0c87f47
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 107 deletions.
13 changes: 10 additions & 3 deletions frontend/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@
export let data: PageData;
const MandatoryServices = ['plexlibrary', 'scraping', 'realdebrid', 'symlinklibrary'];
const ContentServices = ['mdblist', 'overseerr', 'plex_watchlist'];
const CoreServices = [
'symlinklibrary',
'plexlibrary',
'realdebrid',
'symlink',
'torbox',
'torbox_downloader'
];
const ContentServices = ['mdblist', 'overseerr', 'plex_watchlist', 'listrr', 'trakt'];
const ScrapingServices = ['torrentio', 'annatar', 'jackett', 'orionoid'];
function sortServices(services: string[], data: Record<string, boolean>) {
Expand Down Expand Up @@ -48,7 +55,7 @@
</div>
{:then services}
<h2 class="text-lg font-semibold md:text-xl">Core services</h2>
<ServiceStatus statusData={sortServices(MandatoryServices, services.data)} />
<ServiceStatus statusData={sortServices(CoreServices, services.data)} />
<br />
<h2 class="text-lg font-semibold md:text-xl">Content services</h2>
<ServiceStatus statusData={sortServices(ContentServices, services.data)} />
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/routes/api/items/[id]/+server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { json } from '@sveltejs/kit';
// We can only access api from server-side so this needs to be made into a server route

export const GET = async ({ fetch, params }) => {
const id: number = Number(params.id);
Expand Down
59 changes: 1 addition & 58 deletions frontend/src/routes/settings/about/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,63 +12,6 @@ export const load: PageServerLoad = async ({ fetch }) => {
error(503, 'Unable to fetch settings data. API is down.');
}
}
async function getContributors() {
try {
const results = await fetch('https://api.github.com/repos/dreulavelle/iceburg/contributors');
const data = await results.json();
return data
.filter((contributor: any) => contributor.type !== 'Bot' && contributor.type !== 'Organization')
.map((contributor: any) => ({
avatar: contributor.avatar_url,
name: contributor.login,
profile: contributor.html_url
}));

} catch (e) {
console.error(e);
error(503, 'Unable to fetch contributors data. API is down.');
}
}
async function getSponsors() {
try {
// graphql query to get sponsors
const query = `
query {
user(login: "dreulavelle") {
... on Sponsorable {
sponsors(first: 100) {
totalCount
nodes {
... on User { login, avatarUrl, url }
... on Organization { login, avatarUrl, url }
}
}
}
}
}
`
const results = await fetch('https://api.github.com/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ query })
});
if (results.status !== 200) {
console.error(results);
return []
}
const data = await results.json();
return data.data.user.sponsors.nodes.map((sponsor: any) => ({
avatar: sponsor.avatarUrl,
name: sponsor.login,
profile: sponsor.url
}));
} catch (e) {
console.error(e);
error(503, 'Unable to fetch sponsors data. API is down.');
}
}

return { settings: await getAboutInfo(), contributors: await getContributors(), sponsors: await getSponsors()};
return { settings: await getAboutInfo() };
};
59 changes: 14 additions & 45 deletions frontend/src/routes/settings/about/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
const version = data.settings.data.version;
const rclone_path = data.settings.data.symlink.rclone_path;
const library_path = data.settings.data.symlink.library_path;
const contributors = data.contributors;
const sponsors = data.sponsors;
interface AboutData {
[key: string]: any;
Expand All @@ -40,18 +38,16 @@
async function getLatestVersion() {
updateLoading = true;
const data = await fetch(
'https://raw.githubusercontent.com/dreulavelle/iceberg/main/backend/utils/default_settings.json'
);
const data = await fetch('https://raw.githubusercontent.com/dreulavelle/iceberg/main/VERSION');
if (data.status !== 200) {
toast.error('Failed to fetch latest version.');
updateLoading = false;
return;
}
const json = await data.json();
const remoteVersion = await data.text();
updateLoading = false;
if (json.version !== version) {
if (remoteVersion !== version) {
toast.warning('A new version is available! Checkout the changelog on GitHub.');
} else {
toast.success('You are running the latest version.');
Expand All @@ -64,13 +60,6 @@
</svelte:head>

<div class="flex flex-col">
<Alert.Root class="text-sm">
<Alert.Title>Heads up!</Alert.Title>
<Alert.Description class=""
>Iceberg is in rapid development. Expect bugs and breaking changes.</Alert.Description
>
</Alert.Root>

<h2 class="mt-2 text-xl font-semibold md:text-2xl">About</h2>
<p class="mb-2 text-sm md:text-base text-muted-foreground">Know what you're running.</p>
<div class="flex flex-col w-full gap-4">
Expand Down Expand Up @@ -136,37 +125,17 @@

<h2 class="mt-2 text-xl font-semibold md:text-2xl">Contributors</h2>
<p class="mb-2 text-sm md:text-base text-muted-foreground">
Thanks to the following people for their contributions to Iceberg:
Thanks to the following people for their contributions to Iceberg
</p>
<div class="flex flex-wrap w-full gap-4">
{#each contributors as contributor}
<a href={contributor.profile} target="_blank" class="flex flex-col items-start gap-2 mb-2 md:flex-row md:items-center">
<img src={contributor.avatar} alt={contributor.name} class="w-12 h-12 rounded-full" />
<h3 class="w-48 text-sm font-semibold md:text-base min-w-48 text-muted-foreground">
{formatWords(contributor.name)}
</h3>
</a>
{/each}
</div>

<h2 class="mt-2 text-xl font-semibold md:text-2xl">Sponsors</h2>
<p class="mb-2 text-sm md:text-base text-muted-foreground">
Thanks to the following people for sponsoring Iceberg:
</p>
<div class="flex flex-wrap w-full gap-4">
{#each sponsors as sponsor}
<a href={sponsor.profile} target="_blank" class="flex flex-col items-start gap-2 mb-2 md:flex-row md:items-center">
<img src={sponsor.avatar} alt={sponsor.name} class="w-12 h-12 rounded-full" />
<h3 class="w-48 text-sm font-semibold md:text-base min-w-48 text-muted-foreground">
{formatWords(sponsor.name)}
</h3>
</a>
{/each}
{#if sponsors.length === 0}
<p class="font-semibold text-muted-foreground">No sponsors yet.</p>
<p class="">Interested in sponsoring Iceberg? <a href="https://github.com/sponsors/dreulavelle" target="_blank" class="underline break-words"> Do it here!</a></p>
{:else}
<p class="text-muted-foreground">Interested in sponsoring Iceberg? <a href="https://github.com/sponsors/dreulavelle" target="_blank" class="underline break-words"> Do it here!</a></p>
{/if}
</div>
<a
href="https://github.com/dreulavelle/iceberg/graphs/contributors"
target="_blank"
rel="noopener noreferrer"
><img
alt="contributors"
src="https://contrib.rocks/image?repo=dreulavelle/iceberg"
class="mt-2 max-w-lg"
/></a
>
</div>

0 comments on commit 0c87f47

Please sign in to comment.