Skip to content

Commit

Permalink
ench: fetch proper versions;
Browse files Browse the repository at this point in the history
  • Loading branch information
twiddli committed Apr 4, 2023
1 parent 2ad4bb2 commit e0146dc
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 77 deletions.
50 changes: 30 additions & 20 deletions packages/client/components/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,39 @@ import { ModalWithBack } from './misc/BackSupport';
import { TrashTabView } from './Trash';

function InfoPane() {
const packageJson = useGlobalValue('packageJson');
const { data } = useQueryType(QueryType.PROPERTIES, {
keys: ['version'],
});

return (
<Grid as={Segment} basic>
<Grid.Row textAlign="center">
<Grid.Column>
{data?.data?.version?.beta && <Label color="violet">{t`Beta`}</Label>}
{data?.data?.version?.alpha && <Label color="red">{t`Alpha`}</Label>}
<Label basic>
{t`Webclient`} <Label.Detail>1.1.1</Label.Detail>
{t`Webclient`} <Label.Detail>{packageJson?.version}</Label.Detail>
</Label>
<Label basic>
{t`Server`} <Label.Detail>1.1.1</Label.Detail>
{t`Server`}{' '}
<Label.Detail>
{data?.data?.version?.core?.join?.('.')}
</Label.Detail>
</Label>
<Label basic>
{t`Database`} <Label.Detail>1.1.1</Label.Detail>
{t`Database`}{' '}
<Label.Detail>{data?.data?.version?.db?.join?.('.')}</Label.Detail>
</Label>
<Label basic>
{t`Torrent`} <Label.Detail>1.1.1</Label.Detail>
{t`Torrent`}{' '}
<Label.Detail>
{data?.data?.version?.torrent?.join?.('.')}
</Label.Detail>
</Label>
<Label basic color="grey">
{t`#`}
{data?.data?.version?.build}
</Label>
</Grid.Column>
</Grid.Row>
Expand All @@ -49,8 +67,7 @@ function InfoPane() {
rel="noreferrer"
target="_blank"
size="small"
color="orange"
>
color="orange">
<Icon name="heart" />
{t`Support on Patreon`}
</Button>
Expand All @@ -60,8 +77,7 @@ function InfoPane() {
rel="noreferrer"
target="_blank"
size="small"
color="blue"
>
color="blue">
<Icon name="coffee" />
{t`Buy me a Coffee`}
</Button>
Expand All @@ -72,8 +88,7 @@ function InfoPane() {
rel="noreferrer"
target="_blank"
size="small"
floated="right"
>
floated="right">
<Icon name="github" />
{t`View on Github`}
</Button>
Expand All @@ -94,8 +109,7 @@ function InfoPane() {
<a
href="https://github.com/twiddli"
target="_blank"
rel="noreferrer"
>
rel="noreferrer">
Twiddly
</a>
</Table.Cell>
Expand All @@ -111,8 +125,7 @@ function InfoPane() {
<a
href="https://twitter.com/twiddly_"
target="_blank"
rel="noreferrer"
>
rel="noreferrer">
@twiddly_
</a>
</Table.Cell>
Expand Down Expand Up @@ -244,8 +257,7 @@ export default function AboutModal({
dimmer="inverted"
closeIcon
{...props}
className={classNames('min-300-h', className)}
>
className={classNames('min-300-h', className)}>
<Modal.Content as={Segment} basic>
<Header icon textAlign="center">
<Icon className="hpx-standard" circular />
Expand All @@ -260,8 +272,7 @@ export default function AboutModal({
inverted
color="violet"
tertiary
className="no-margins"
>
className="no-margins">
{t`Running in debug mode`}
</Segment>
)}
Expand All @@ -270,8 +281,7 @@ export default function AboutModal({
attached="bottom"
textAlign="center"
secondary
className="no-margins"
>
className="no-margins">
{t`HappyPanda X is a cross platform manga/doujinshi manager made out of pure`}
<Icon name="heart" color="red" size="large" />
{t`by`}{' '}
Expand Down
4 changes: 4 additions & 0 deletions packages/client/next.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
const { merge } = require('webpack-merge');
const pkg = require('./package.json');

const nextConfig = (phase, { defaultConfig }) => {
/** @type {import('next').NextConfig} */
const config = {
// output: phase === PHASE_PRODUCTION_BUILD ? 'standalone' : undefined,
poweredByHeader: false,
env: {
PACKAGE_JSON: JSON.stringify(pkg),
},
swcMinify: true,
experimental: {
appDir: false,
Expand Down
7 changes: 7 additions & 0 deletions packages/client/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
HPX_SERVER_HOST,
HPX_SERVER_PORT,
IS_SERVER,
PACKAGE_JSON,
ServiceType,
} from '../server/constants';
import { NotificationData, ServerUser } from '../shared/types';
Expand All @@ -38,6 +39,7 @@ const Theme = dynamic(() => import('../components/Theme'), { ssr: false });
interface AppPageProps extends AppInitialProps {
pageProps: {
notifications: NotificationData[];
packageJson: Record<string, any>;
user: ServerUser | null;
loggedIn: boolean;
connected: boolean;
Expand Down Expand Up @@ -180,6 +182,7 @@ export function AppRoot({
pageProps?: AppPageProps['pageProps'];
}) {
const setConnected = useSetGlobalState('connected');
const setPackageJson = useSetGlobalState('packageJson');
const setLoggedIn = useSetGlobalState('loggedIn');
const setSameMachine = useSetGlobalState('sameMachine');
const setUser = useSetGlobalState('user');
Expand All @@ -189,6 +192,7 @@ export function AppRoot({

useEffect(() => {
setConnected(pageProps.connected);
setPackageJson(pageProps.packageJson);
setLoggedIn(pageProps.loggedIn);
setSameMachine(pageProps.sameMachine);
setUser(pageProps.user);
Expand Down Expand Up @@ -264,6 +268,7 @@ function redirect(params: {
HappyPandaApp.getInitialProps = async function (
context: AppContext
): Promise<AppPageProps> {
let packageJson = PACKAGE_JSON;
let serverHost = HPX_SERVER_HOST;
let serverPort = HPX_SERVER_PORT;
let disableServerConnect = DISABLE_SERVER_CONNECT;
Expand Down Expand Up @@ -316,6 +321,7 @@ HappyPandaApp.getInitialProps = async function (
let propsData: AppPageProps['pageProps'] = {
disableServerConnect,
serverHost,
packageJson,
serverPort,
pathname,
loggedIn,
Expand Down Expand Up @@ -346,6 +352,7 @@ HappyPandaApp.getInitialProps = async function (
propsData = {
disableServerConnect: data.disableServerConnect,
serverHost: data.serverHost,
packageJson: data.packageJson,
serverPort: data.serverPort,
pathname: data.pathname,
loggedIn: data.loggedIn,
Expand Down
25 changes: 25 additions & 0 deletions packages/client/pages/api/properties.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ServiceType } from '../../server/constants';
import { handler, RequestOptions } from '../../server/requests';
import { urlparse } from '../../shared/utility';

export default handler().get(async (req, res) => {
const server = await global.app.service
.get(ServiceType.Server)
.context({ req, res });

const { keys, __options } = urlparse(
req.url
).query;

return server
.properties(
{
keys: keys as any[],
},
undefined,
__options as RequestOptions
)
.then((r) => {
res.status(200).json(r);
});
});
20 changes: 7 additions & 13 deletions packages/client/pages/library.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ function FilterPageMessage({
hidden={isLoading}
color="blue"
size="tiny"
onDismiss={useCallback(() => setFilter(undefined), [])}
>
onDismiss={useCallback(() => setFilter(undefined), [])}>
<Message.Header className="text-center">
{t`Filter`}: {data?.data?.name}
</Message.Header>
Expand All @@ -283,8 +282,7 @@ function LibrarySidebar() {
<StickySidebar
className={classNames('sticky-page-sidebar', { mobile: isMobileMax })}
visible={sidebarVisible}
onHide={onHide}
>
onHide={onHide}>
{sidebarData && <GalleryDataTable data={sidebarData} />}
</StickySidebar>
</Portal>
Expand Down Expand Up @@ -347,8 +345,7 @@ function LibrarySettings({
if (reload) {
router.reload();
}
}, [reload, router])}
>
}, [reload, router])}>
<Modal.Header>{t`Library Settings`}</Modal.Header>
<Modal.Content>
<Form>
Expand Down Expand Up @@ -441,7 +438,7 @@ function LibrarySettings({
/> */}

<Form.Field>
<label>{t`Group galleries in series`}</label>
<label>{t`Collapse series`}</label>
<Checkbox
toggle
checked={series}
Expand Down Expand Up @@ -564,8 +561,7 @@ function ActionsMenu({
button
basic
className={cls}
text={t`View actions`}
>
text={t`View actions`}>
<Dropdown.Menu>
{actions.map((action) => {
if (action.view === false) return null;
Expand Down Expand Up @@ -1003,8 +999,7 @@ export default function Page({
</>
),
[favorites, filter, sort, sortDesc, itemType]
)}
>
)}>
<PageTitle title={t`Library`} />
{children}
{!count && !errorLimited && <EmptySegment />}
Expand All @@ -1018,8 +1013,7 @@ export default function Page({
{t`Please refine your search query to retrieve results.`}
</p>
</div>
}
>
}>
<Segment basic textAlign="center">
<Button color="red" onClick={goBack}>{t`Go back`}</Button>
</Segment>
Expand Down
2 changes: 2 additions & 0 deletions packages/client/server/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export enum ServiceType {

export const IS_SERVER = typeof window === 'undefined';

export const PACKAGE_JSON = process.env.PACKAGE_JSON ? JSON.parse(process.env.PACKAGE_JSON) : {};

export const THUMB_STATIC_FOLDER = process.env.HPX_THUMB_STATIC_FOLDER
? process.env.HPX_THUMB_STATIC_FOLDER
: '.';
Expand Down

1 comment on commit e0146dc

@DennoCoil
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goddamn, this thing is getting finished? I thought this project was dead.

Please sign in to comment.