mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-13 17:05:47 +01:00
v0.10.7
Add grid grow and service search in search bar
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
export const REPO_URL = 'ajnart/homarr';
|
||||
export const CURRENT_VERSION = 'v0.10.6';
|
||||
export const CURRENT_VERSION = 'v0.10.7';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "homarr",
|
||||
"version": "0.10.6",
|
||||
"version": "0.10.7",
|
||||
"description": "Homarr - A homepage for your server.",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "Lavet med ❤️ af @"
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "Gemacht mit ❤️ von @"
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "Made with ❤️ by @"
|
||||
}
|
||||
},
|
||||
"grow": "Grow grid (take all space)"
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "Hecho con ❤️ por @"
|
||||
}
|
||||
},
|
||||
"grow": "Aumentar cuadrícula (toma todo el espacio)"
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "Fait avec ❤️ par @"
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "נעשה ב- ❤️ ע״י @"
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "Realizzato con ❤️ da @"
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "で作った❤️ by @さん"
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "Made with ❤️ by @"
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "Maded wif ❤️ by @"
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "Gemaakt met ❤️ door @"
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "Wykonane z ❤️ przez @"
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "Feito com ❤️ por @"
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "Сделано с ❤️ по @."
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "Narejeno s ❤️ od @"
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -6,25 +6,25 @@
|
||||
"input": {
|
||||
"placeholder": "Sök på webben..."
|
||||
},
|
||||
"switched-to": "",
|
||||
"switched-to": "Växlade till",
|
||||
"searchEngines": {
|
||||
"search": {
|
||||
"name": "",
|
||||
"description": ""
|
||||
"name": "Webb",
|
||||
"description": "Sök med din sökmotor (definierad i inställningar)"
|
||||
},
|
||||
"youtube": {
|
||||
"name": "",
|
||||
"description": ""
|
||||
"name": "YouTube",
|
||||
"description": "Sök på YouTube"
|
||||
},
|
||||
"torrents": {
|
||||
"name": "",
|
||||
"description": ""
|
||||
"name": "Torrents",
|
||||
"description": "Sök torrents"
|
||||
},
|
||||
"overseerr": {
|
||||
"name": "Overseerr",
|
||||
"description": ""
|
||||
"description": "Sök efter filmer och TV-program med Overseerr (modulen måste vara aktiverad)"
|
||||
}
|
||||
},
|
||||
"tip": "",
|
||||
"switchedSearchEngine": ""
|
||||
"tip": "Du kan välja sökfältet med kortkommandot ",
|
||||
"switchedSearchEngine": "Växlade till att söka med {{searchEngine}}"
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "Gjort med ❤️ av @"
|
||||
}
|
||||
},
|
||||
"grow": "Växande rutnät (ta allt utrymme)"
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "Зроблено з ❤️ by @"
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "From @ with ❤️"
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"credits": {
|
||||
"madeWithLove": "用❤️创造,出品于"
|
||||
}
|
||||
},
|
||||
"grow": ""
|
||||
}
|
||||
@@ -95,7 +95,7 @@ const AppShelf = (props: any) => {
|
||||
onDragEnd={handleDragEnd}
|
||||
>
|
||||
<SortableContext items={config.services}>
|
||||
<Grid gutter="lg" align="center">
|
||||
<Grid gutter="lg" grow={config.settings.grow}>
|
||||
{filtered.map((service) => (
|
||||
<Grid.Col key={service.id} span="content">
|
||||
<SortableItem service={service} key={service.id} id={service.id}>
|
||||
@@ -143,7 +143,14 @@ const AppShelf = (props: any) => {
|
||||
value={idx.toString()}
|
||||
>
|
||||
<Accordion.Control>
|
||||
<Title order={5}>{category}</Title>
|
||||
<Title
|
||||
order={5}
|
||||
style={{
|
||||
minWidth: 0,
|
||||
}}
|
||||
>
|
||||
{category}
|
||||
</Title>
|
||||
</Accordion.Control>
|
||||
<Accordion.Panel>{getItems(category)}</Accordion.Panel>
|
||||
</Accordion.Item>
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ColorSelector } from './ColorSelector';
|
||||
import { OpacitySelector } from './OpacitySelector';
|
||||
import { AppCardWidthSelector } from './AppCardWidthSelector';
|
||||
import { ShadeSelector } from './ShadeSelector';
|
||||
import { GrowthSelector } from './GrowthSelector';
|
||||
|
||||
export default function TitleChanger() {
|
||||
const { config, setConfig } = useConfig();
|
||||
@@ -74,6 +75,7 @@ export default function TitleChanger() {
|
||||
<Button type="submit">{t('buttons.submit')}</Button>
|
||||
</Stack>
|
||||
</form>
|
||||
<GrowthSelector />
|
||||
<ColorSelector type="primary" />
|
||||
<ColorSelector type="secondary" />
|
||||
<ShadeSelector />
|
||||
|
||||
30
src/components/Settings/GrowthSelector.tsx
Normal file
30
src/components/Settings/GrowthSelector.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Switch } from '@mantine/core';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useState } from 'react';
|
||||
import { useConfig } from '../../tools/state';
|
||||
|
||||
export function GrowthSelector() {
|
||||
const { config, setConfig } = useConfig();
|
||||
const defaultPosition = config?.settings?.grow || false;
|
||||
const [growState, setGrowState] = useState(defaultPosition);
|
||||
const { t } = useTranslation('settings/common.json');
|
||||
const toggleGrowState = () => {
|
||||
setGrowState(!growState);
|
||||
setConfig({
|
||||
...config,
|
||||
settings: {
|
||||
...config.settings,
|
||||
grow: !growState,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Switch
|
||||
label={t('settings/common:grow')}
|
||||
checked={growState === true}
|
||||
onChange={() => toggleGrowState()}
|
||||
size="md"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -48,15 +48,11 @@ export function WidgetsPositionSwitch() {
|
||||
};
|
||||
|
||||
return (
|
||||
<Group>
|
||||
<div className={classes.root}>
|
||||
<Switch
|
||||
checked={widgetPosition === 'left'}
|
||||
onChange={() => toggleWidgetPosition()}
|
||||
size="md"
|
||||
/>
|
||||
</div>
|
||||
{t('label')}
|
||||
</Group>
|
||||
<Switch
|
||||
label={t('label')}
|
||||
checked={widgetPosition === 'left'}
|
||||
onChange={() => toggleWidgetPosition()}
|
||||
size="md"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
ActionIcon,
|
||||
Autocomplete,
|
||||
Box,
|
||||
createStyles,
|
||||
Divider,
|
||||
@@ -11,7 +12,7 @@ import {
|
||||
Tooltip,
|
||||
} from '@mantine/core';
|
||||
import { IconSearch, IconBrandYoutube, IconDownload, IconMovie } from '@tabler/icons';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import React, { forwardRef, useEffect, useRef, useState } from 'react';
|
||||
import { useDebouncedValue, useHotkeys } from '@mantine/hooks';
|
||||
import { showNotification } from '@mantine/notifications';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
@@ -21,6 +22,7 @@ import { useConfig } from '../../tools/state';
|
||||
import { OverseerrModule } from '../overseerr';
|
||||
import Tip from '../../components/layout/Tip';
|
||||
import { OverseerrMediaDisplay } from '../common';
|
||||
import SmallServiceItem from '../../components/AppShelf/SmallServiceItem';
|
||||
|
||||
export const SearchModule: IModule = {
|
||||
title: 'Search',
|
||||
@@ -97,6 +99,25 @@ export function SearchModuleComponent() {
|
||||
},
|
||||
];
|
||||
const [selectedSearchEngine, setSearchEngine] = useState<ItemProps>(searchEnginesList[0]);
|
||||
const matchingServices = config.services.filter((service) => {
|
||||
if (searchQuery === '' || searchQuery === undefined) {
|
||||
return false;
|
||||
}
|
||||
return service.name.toLowerCase().includes(searchQuery.toLowerCase());
|
||||
});
|
||||
const autocompleteData = matchingServices.map((service) => ({
|
||||
label: service.name,
|
||||
value: service.name,
|
||||
icon: service.icon,
|
||||
url: service.openedUrl ?? service.url,
|
||||
}));
|
||||
const AutoCompleteItem = forwardRef<HTMLDivElement, any>(
|
||||
({ label, value, icon, url, ...others }: any, ref) => (
|
||||
<div ref={ref} {...others}>
|
||||
<SmallServiceItem service={{ label, value, icon, url }} />
|
||||
</div>
|
||||
)
|
||||
);
|
||||
useEffect(() => {
|
||||
// Refresh the default search engine every time the config for it changes #521
|
||||
setSearchEngine(searchEnginesList[0]);
|
||||
@@ -123,7 +144,7 @@ export function SearchModuleComponent() {
|
||||
//TODO: Fix the bug where clicking anything inside the Modal to ask for a movie
|
||||
// will close it (Because it closes the underlying Popover)
|
||||
return (
|
||||
<Box style={{ width: '100%', maxWidth: 400, minWidth: 300 }}>
|
||||
<Box style={{ width: '100%', maxWidth: 400 }}>
|
||||
<Popover
|
||||
opened={OverseerrResults.length > 0 && opened && searchQuery.length > 3}
|
||||
position="bottom"
|
||||
@@ -134,17 +155,30 @@ export function SearchModuleComponent() {
|
||||
transition="pop-top-right"
|
||||
>
|
||||
<Popover.Target>
|
||||
<TextInput
|
||||
<Autocomplete
|
||||
ref={textInput}
|
||||
onFocusCapture={() => setOpened(true)}
|
||||
autoFocus
|
||||
rightSection={<SearchModuleMenu />}
|
||||
placeholder={t(`searchEngines.${selectedSearchEngine.value}.description`)}
|
||||
value={searchQuery}
|
||||
onChange={(event) => tryMatchSearchEngine(event.currentTarget.value, setSearchQuery)}
|
||||
onChange={(currentString) => tryMatchSearchEngine(currentString, setSearchQuery)}
|
||||
itemComponent={AutoCompleteItem}
|
||||
data={autocompleteData}
|
||||
onItemSubmit={(item) => {
|
||||
setOpened(false);
|
||||
if (item.url) {
|
||||
setSearchQuery('');
|
||||
window.open(item.openedUrl ? item.openedUrl : item.url, openInNewTab);
|
||||
}
|
||||
}}
|
||||
// Replace %s if it is in selectedSearchEngine.url with searchQuery, otherwise append searchQuery at the end of it
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === 'Enter' && searchQuery.length > 0) {
|
||||
if (
|
||||
event.key === 'Enter' &&
|
||||
searchQuery.length > 0 &&
|
||||
autocompleteData.length === 0
|
||||
) {
|
||||
if (selectedSearchEngine.url.includes('%s')) {
|
||||
window.open(selectedSearchEngine.url.replace('%s', searchQuery), openInNewTab);
|
||||
} else {
|
||||
@@ -152,6 +186,8 @@ export function SearchModuleComponent() {
|
||||
}
|
||||
}
|
||||
}}
|
||||
radius="md"
|
||||
size="md"
|
||||
/>
|
||||
</Popover.Target>
|
||||
<Popover.Dropdown>
|
||||
|
||||
@@ -14,6 +14,7 @@ export interface Settings {
|
||||
customCSS?: string;
|
||||
appOpacity?: number;
|
||||
widgetPosition?: string;
|
||||
grow?: boolean;
|
||||
appCardWidth?: number;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user