Skip to content

Commit

Permalink
Merge pull request #48 from victoralvesf/development
Browse files Browse the repository at this point in the history
Update main base with version 0.1.3
  • Loading branch information
victoralvesf authored Oct 2, 2024
2 parents b046624 + fef2ccd commit 306af2a
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ dist-ssr

cypress/screenshots
cypress/videos

# Docker env file
env-config.js
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@ FROM node:20-alpine AS build

WORKDIR /app

COPY package*.json ./
RUN npm install --legacy-peer-deps
RUN npm install -g pnpm
COPY package.json ./
COPY pnpm-lock.yaml ./
RUN pnpm install --ignore-scripts
COPY . .
RUN npm run build
RUN pnpm run build

# Final stage
FROM nginx:alpine

COPY --chown=nginx:nginx --from=build /app/dist /usr/share/nginx/html
COPY env-config.js.template /usr/share/nginx/html/env-config.js.template
COPY nginx.conf.template /etc/nginx/templates/default.conf.template

COPY set-variables.sh /docker-entrypoint.d/99-set-variables.sh
RUN chmod +x /docker-entrypoint.d/99-set-variables.sh

EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ services:
restart: unless-stopped
ports:
- 8080:8080
environment:
- SERVER_URL=http://address:port
- HIDE_SERVER=true # When it's true AND SERVER_URL is set, only username and password will be visible on login.
```
### Recommended IDE Setup
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ services:
restart: unless-stopped
ports:
- 8080:8080
environment:
# When it's true AND SERVER_URL is set, only username and password will be visible on login.
# - HIDE_SERVER=true
# - SERVER_URL=http://address:port
3 changes: 3 additions & 0 deletions env-config.js.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";
window.SERVER_URL="${SERVER_URL}" || undefined;
window.HIDE_SERVER="${HIDE_SERVER}" === "true";
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

<body>
<div id="root"></div>
<script src="/env-config.js"></script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "aonsoku",
"private": true,
"version": "0.1.2",
"version": "0.1.3",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
17 changes: 9 additions & 8 deletions public/favicons/site.webmanifest
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{
"name": "",
"short_name": "",
"name": "Aonsoku",
"short_name": "Aonsoku",
"description": "A modern desktop client for Navidrome/Subsonic servers.",
"theme_color": "#060E23",
"background_color": "#20b358",
"display": "standalone",
"icons": [
{
"src": "/android-chrome-192x192.png",
"src": "/favicons/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"src": "/favicons/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#060E23",
"background_color": "#20b358",
"display": "standalone"
]
}
4 changes: 4 additions & 0 deletions set-variables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# Replace environment variables on the template and create the definitive config file.
envsubst < /usr/share/nginx/html/env-config.js.template > /usr/share/nginx/html/env-config.js
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aonsoku"
version = "0.1.2"
version = "0.1.3"
description = "A modern desktop client for Navidrome/Subsonic servers."
authors = ["Victor Alves"]
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "Aonsoku",
"version": "0.1.2"
"version": "0.1.3"
},
"tauri": {
"allowlist": {
Expand Down
20 changes: 15 additions & 5 deletions src/app/components/login/form.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { zodResolver } from '@hookform/resolvers/zod'
import { useQueryClient } from '@tanstack/react-query'
import clsx from 'clsx'
import { Loader2 } from 'lucide-react'
import { useState } from 'react'
import { useForm } from 'react-hook-form'
Expand Down Expand Up @@ -30,7 +31,7 @@ import {
} from '@/app/components/ui/form'
import { Input } from '@/app/components/ui/input'
import { ROUTES } from '@/routes/routesList'
import { useAppActions } from '@/store/app.store'
import { useAppActions, useAppData } from '@/store/app.store'
import { removeSlashFromUrl } from '@/utils/removeSlashFromUrl'

const loginSchema = z.object({
Expand All @@ -50,17 +51,26 @@ const loginSchema = z.object({

type FormData = z.infer<typeof loginSchema>

const defaultUrl = 'http://'
const url = window.SERVER_URL || defaultUrl
const urlIsValid = url !== defaultUrl

export function LoginForm() {
const [loading, setLoading] = useState(false)
const { saveConfig } = useAppActions()
const { hideServer } = useAppData()
const navigate = useNavigate()
const { t } = useTranslation()
const queryClient = useQueryClient()

const shouldHideUrlInput = urlIsValid && hideServer

const form = useForm<FormData>({
resolver: zodResolver(loginSchema),
defaultValues: {
url: 'http://',
values: {
url,
username: '',
password: '',
},
})

Expand Down Expand Up @@ -102,7 +112,7 @@ export function LoginForm() {
control={form.control}
name="url"
render={({ field }) => (
<FormItem>
<FormItem className={clsx(shouldHideUrlInput && 'hidden')}>
<FormLabel className="required">
{t('login.form.url')}
</FormLabel>
Expand All @@ -129,7 +139,7 @@ export function LoginForm() {
control={form.control}
name="username"
render={({ field }) => (
<FormItem>
<FormItem className={clsx(shouldHideUrlInput && '!mt-0')}>
<FormLabel className="required">
{t('login.form.username')}
</FormLabel>
Expand Down
9 changes: 8 additions & 1 deletion src/store/app.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { pingServer } from '@/api/pingServer'
import { AuthType, IAppContext, IServerConfig } from '@/types/serverConfig'
import { saltWord, toHex } from '@/utils/salt'

const { HIDE_SERVER } = window

export const useAppStore = createWithEqualityFn<IAppContext>()(
subscribeWithSelector(
persist(
Expand All @@ -21,6 +23,7 @@ export const useAppStore = createWithEqualityFn<IAppContext>()(
password: '',
authType: AuthType.TOKEN,
logoutDialogState: false,
hideServer: HIDE_SERVER ?? false,
},
command: {
open: false,
Expand Down Expand Up @@ -110,7 +113,11 @@ export const useAppStore = createWithEqualityFn<IAppContext>()(
return merge(currentState, persistedState)
},
partialize: (state) => {
const appStore = omit(state, 'data.logoutDialogState')
const appStore = omit(
state,
'data.logoutDialogState',
'data.hideServer',
)

return appStore
},
Expand Down
8 changes: 8 additions & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export {}

declare global {
interface Window {
SERVER_URL: string | undefined
HIDE_SERVER: boolean | undefined
}
}
1 change: 1 addition & 0 deletions src/types/serverConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface IAppData extends IServerConfig {
isServerConfigured: boolean
osType: string
logoutDialogState: boolean
hideServer: boolean
}

export interface IAppActions {
Expand Down
7 changes: 5 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"typeRoots": [
"./node_modules/@types",
"./src/types"
],
"types": [
"cypress",
"node"
"cypress"
]
},
"include": [
Expand Down

0 comments on commit 306af2a

Please sign in to comment.