Initial commit: add a dedicated page for managing the knowledge base

- One current issue in the Khoj application is that managing the files being referenced as the user's knowledge base is slightly opaque and difficult to access
- Add a migration for associating the fileobjects directly with the Entry objects, making it easier to get data via foreign key
- Add the new page that shows all indexed files in the search view, also allowing you to upload new docs directly from that page
- Support new APIs for getting / deleting files
This commit is contained in:
sabaimran
2025-01-10 16:24:50 -08:00
parent 65f1c27963
commit 454a752071
10 changed files with 788 additions and 56 deletions

View File

@@ -94,3 +94,33 @@ export function useDebounce<T>(value: T, delay: number): T {
return debouncedValue;
}
export const formatDateTime = (isoString: string): string => {
try {
const date = new Date(isoString);
const now = new Date();
const diffInMinutes = Math.floor((now.getTime() - date.getTime()) / 60000);
// Show relative time for recent dates
if (diffInMinutes < 1) return "just now";
if (diffInMinutes < 60) return `${diffInMinutes} minutes ago`;
if (diffInMinutes < 120) return "1 hour ago";
if (diffInMinutes < 1440) return `${Math.floor(diffInMinutes / 60)} hours ago`;
// For older dates, show full formatted date
const formatter = new Intl.DateTimeFormat("en-US", {
month: "long",
day: "numeric",
year: "numeric",
hour: "numeric",
minute: "2-digit",
hour12: true,
timeZoneName: "short",
});
return formatter.format(date);
} catch (error) {
console.error("Error formatting date:", error);
return isoString;
}
};