Skip to content

Commit

Permalink
feat: add version to footer
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrodriguez committed Nov 22, 2023
1 parent 1cc14da commit bb3705e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
11 changes: 10 additions & 1 deletion ui/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// import React from "react";

import type { Movies, OptionsParams, Movie } from "~/types";
import type { Movies, OptionsParams, Movie, ConfigState } from "~/types";

const encode = (params: OptionsParams): string => {
const str = [];
Expand All @@ -18,6 +18,15 @@ export const wsEndpoint = `${
document.location.protocol === "http:" ? "ws:" : "wss:"
}//${document.location.host}/ws`;

export async function getConfig(): Promise<ConfigState> {
const response = await fetch(`${apiEndpoint}/config`);
// if (!response.ok) {
// throw new Error(response.statusText);
// }

return await response.json();
}

export async function getMovies(params: {
url: string;
args: OptionsParams;
Expand Down
17 changes: 15 additions & 2 deletions ui/src/shared/footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import React from "react";

import useSWR from "swr";

import { getConfig } from "~/api";
import { Spinner } from "~/shared/components/spinner";

export const Footer: React.FC = () => {
const { data, isLoading } = useSWR("/config", getConfig);

return (
<section className="flex flex-row items-center justify-between bg-neutral-100 p-2 mt-4 mb-4">
<div>
Expand All @@ -10,8 +17,14 @@ export const Footer: React.FC = () => {
</a>
</div>
<div className="text-red-600">
<span>mediaGUI &nbsp;</span>
<span>v1.0</span>
{isLoading ? (
<Spinner />
) : (
<>
<span>mediaGUI &nbsp;</span>
<span>v{data?.version}</span>
</>
)}
</div>
<div className="flex flex-row items-center">
<a
Expand Down
3 changes: 1 addition & 2 deletions ui/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ export interface RootState {

export interface ConfigState {
version: string;
unraidMode: boolean;
unraidHosts: string[];
mediaFolders: string[];
mediaFolder: string[];
}

export interface OptionsState {
Expand Down

0 comments on commit bb3705e

Please sign in to comment.