generated from Dicken/dickendock
round24: Favicon-Groesse und Wort-Erkennung verbessert, ausgeblendet-Badge entfernt, Proxmox-Port-Bug gefixt, Suche um Geraete und Spaeter-lesen erweitert
This commit is contained in:
@@ -4,7 +4,7 @@ import { Link } from "@tanstack/react-router";
|
||||
import { SearchInput, StatusBadge, ResultsList, FavoritesBar, Favicon, Button } from "@launchpad/ui";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faGear, faPlus } from "@fortawesome/free-solid-svg-icons";
|
||||
import { rankServices, type SearchResult } from "@launchpad/shared";
|
||||
import { rankSearchResults, type SearchResult } from "@launchpad/shared";
|
||||
import { useServices } from "../hooks/useServices.js";
|
||||
import { useBookmarks } from "../hooks/useBookmarks.js";
|
||||
import { useDevices } from "../hooks/useDevices.js";
|
||||
@@ -133,8 +133,9 @@ export function HomePage() {
|
||||
const isLoading = servicesLoading || bookmarksLoading;
|
||||
|
||||
function openItem(item: SearchResult | { url: string; id?: string; kind?: "service" | "bookmark" }) {
|
||||
if ("kind" in item && item.kind === "device") return; // Geräte haben keine eigene URL, nicht anklickbar
|
||||
window.open(item.url, "_blank", "noopener,noreferrer");
|
||||
if ("kind" in item && item.kind && item.id) {
|
||||
if ("kind" in item && (item.kind === "service" || item.kind === "bookmark") && item.id) {
|
||||
recordVisit(item.kind, item.id).then(() => {
|
||||
queryClient.invalidateQueries({ queryKey: ["recent-visits"] });
|
||||
});
|
||||
@@ -167,24 +168,57 @@ export function HomePage() {
|
||||
});
|
||||
|
||||
// Ausgeblendete Dienste (z. B. Fehlerseiten/nicht erreichbare Scan-Treffer,
|
||||
// siehe Admin -> Dienste) tauchen in der Suche nicht auf.
|
||||
// siehe Admin -> Dienste) tauchen in der Suche nicht auf. Geräte und
|
||||
// Später-lesen-Einträge sind jetzt ebenfalls durchsuchbar (siehe
|
||||
// rankSearchResults: Dienste stehen dabei immer zuerst, Geräte immer
|
||||
// zuletzt - Geräte haben keine eigene URL zum Öffnen, siehe ResultsList).
|
||||
const allItems: SearchResult[] = useMemo(() => {
|
||||
const deviceHostnameById = new Map((devices ?? []).map((d) => [d.id, d.hostname]));
|
||||
const deviceOnlineById = new Map((devices ?? []).map((d) => [d.id, d.online]));
|
||||
const visibleServices: SearchResult[] = (services ?? [])
|
||||
.filter((s) => s.visible)
|
||||
.map((s) => ({
|
||||
...s,
|
||||
kind: "service" as const,
|
||||
deviceHostname: deviceHostnameById.get(s.deviceId) ?? null,
|
||||
deviceOnline: deviceOnlineById.get(s.deviceId) ?? false,
|
||||
}));
|
||||
const bookmarkItems: SearchResult[] = (bookmarks ?? []).map((b) => ({
|
||||
...b,
|
||||
kind: "bookmark" as const,
|
||||
}));
|
||||
return [...visibleServices, ...bookmarkItems];
|
||||
}, [services, bookmarks, devices]);
|
||||
const deviceItems: SearchResult[] = (devices ?? []).map((d) => ({
|
||||
kind: "device" as const,
|
||||
id: d.id,
|
||||
displayName: d.hostname,
|
||||
hostname: d.hostname,
|
||||
ip: d.ip,
|
||||
mac: d.mac,
|
||||
online: d.online,
|
||||
favicon: null,
|
||||
category: null,
|
||||
favorite: false,
|
||||
order: 0,
|
||||
alias: [d.ip, d.mac].filter((v): v is string => !!v),
|
||||
description: d.ip,
|
||||
}));
|
||||
const readLaterSearchItems: SearchResult[] = (readLaterItems ?? []).map((r) => ({
|
||||
kind: "readlater" as const,
|
||||
id: r.id,
|
||||
displayName: r.displayName,
|
||||
hostname: "",
|
||||
url: r.url,
|
||||
favicon: r.favicon,
|
||||
category: null,
|
||||
favorite: false,
|
||||
order: 0,
|
||||
alias: [],
|
||||
description: null,
|
||||
}));
|
||||
return [...visibleServices, ...bookmarkItems, ...deviceItems, ...readLaterSearchItems];
|
||||
}, [services, bookmarks, devices, readLaterItems]);
|
||||
|
||||
const results = useMemo(() => rankServices(allItems, query), [allItems, query]);
|
||||
const results = useMemo(() => rankSearchResults(allItems, query), [allItems, query]);
|
||||
|
||||
const favoriteServices = useMemo(
|
||||
() =>
|
||||
@@ -390,7 +424,7 @@ export function HomePage() {
|
||||
>
|
||||
<Favicon src={item.favicon} fallbackLetter={item.displayName} size="md" />
|
||||
</span>
|
||||
<span className="w-full truncate text-center text-[10px] leading-tight text-black/55 dark:text-white/55">
|
||||
<span className="line-clamp-2 w-full text-center text-[10px] leading-tight text-black/55 dark:text-white/55">
|
||||
{item.displayName}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
@@ -402,11 +402,6 @@ function ServiceRow({
|
||||
<FontAwesomeIcon icon={faUserPen} className="text-black/40 dark:text-white/40" />
|
||||
</span>
|
||||
) : null}
|
||||
{!service.visible ? (
|
||||
<span className="rounded-full bg-black/10 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-black/50 dark:bg-white/10 dark:text-white/50">
|
||||
ausgeblendet
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@@ -586,7 +581,7 @@ function FaviconSuggestionsPanel() {
|
||||
disabled={applyMutation.isPending}
|
||||
className="rounded p-0.5 hover:bg-black/5 dark:hover:bg-white/10"
|
||||
>
|
||||
<Favicon src={c.url} fallbackLetter={c.name} size="sm" />
|
||||
<Favicon src={c.url} fallbackLetter={c.name} size="lg" />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user