yangdx
commited on
Commit
·
f566759
1
Parent(s):
9982e65
Moved refreshLayout from settings to graph store.
Browse files
lightrag_webui/src/components/graph/Settings.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import Input from '@/components/ui/Input'
|
|
| 8 |
import { controlButtonVariant } from '@/lib/constants'
|
| 9 |
import { useSettingsStore } from '@/stores/settings'
|
| 10 |
import { useBackendState } from '@/stores/state'
|
|
|
|
| 11 |
|
| 12 |
import { SettingsIcon, RefreshCwIcon } from 'lucide-react'
|
| 13 |
import { useTranslation } from 'react-i18next';
|
|
@@ -114,7 +115,7 @@ const LabeledNumberInput = ({
|
|
| 114 |
export default function Settings() {
|
| 115 |
const [opened, setOpened] = useState<boolean>(false)
|
| 116 |
const [tempApiKey, setTempApiKey] = useState<string>('')
|
| 117 |
-
const refreshLayout =
|
| 118 |
|
| 119 |
const showPropertyPanel = useSettingsStore.use.showPropertyPanel()
|
| 120 |
const showNodeSearchBar = useSettingsStore.use.showNodeSearchBar()
|
|
|
|
| 8 |
import { controlButtonVariant } from '@/lib/constants'
|
| 9 |
import { useSettingsStore } from '@/stores/settings'
|
| 10 |
import { useBackendState } from '@/stores/state'
|
| 11 |
+
import { useGraphStore } from '@/stores/graph'
|
| 12 |
|
| 13 |
import { SettingsIcon, RefreshCwIcon } from 'lucide-react'
|
| 14 |
import { useTranslation } from 'react-i18next';
|
|
|
|
| 115 |
export default function Settings() {
|
| 116 |
const [opened, setOpened] = useState<boolean>(false)
|
| 117 |
const [tempApiKey, setTempApiKey] = useState<string>('')
|
| 118 |
+
const refreshLayout = useGraphStore.use.refreshLayout()
|
| 119 |
|
| 120 |
const showPropertyPanel = useSettingsStore.use.showPropertyPanel()
|
| 121 |
const showNodeSearchBar = useSettingsStore.use.showNodeSearchBar()
|
lightrag_webui/src/stores/graph.ts
CHANGED
|
@@ -72,6 +72,7 @@ interface GraphState {
|
|
| 72 |
moveToSelectedNode: boolean
|
| 73 |
isFetching: boolean
|
| 74 |
|
|
|
|
| 75 |
setSelectedNode: (nodeId: string | null, moveToSelectedNode?: boolean) => void
|
| 76 |
setFocusedNode: (nodeId: string | null) => void
|
| 77 |
setSelectedEdge: (edgeId: string | null) => void
|
|
@@ -89,7 +90,7 @@ interface GraphState {
|
|
| 89 |
setIsFetching: (isFetching: boolean) => void
|
| 90 |
}
|
| 91 |
|
| 92 |
-
const useGraphStoreBase = create<GraphState>()((set) => ({
|
| 93 |
selectedNode: null,
|
| 94 |
focusedNode: null,
|
| 95 |
selectedEdge: null,
|
|
@@ -103,6 +104,17 @@ const useGraphStoreBase = create<GraphState>()((set) => ({
|
|
| 103 |
graphLabels: ['*'],
|
| 104 |
allDatabaseLabels: ['*'],
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
setIsFetching: (isFetching: boolean) => set({ isFetching }),
|
| 107 |
setSelectedNode: (nodeId: string | null, moveToSelectedNode?: boolean) =>
|
| 108 |
set({ selectedNode: nodeId, moveToSelectedNode }),
|
|
|
|
| 72 |
moveToSelectedNode: boolean
|
| 73 |
isFetching: boolean
|
| 74 |
|
| 75 |
+
refreshLayout: () => void
|
| 76 |
setSelectedNode: (nodeId: string | null, moveToSelectedNode?: boolean) => void
|
| 77 |
setFocusedNode: (nodeId: string | null) => void
|
| 78 |
setSelectedEdge: (edgeId: string | null) => void
|
|
|
|
| 90 |
setIsFetching: (isFetching: boolean) => void
|
| 91 |
}
|
| 92 |
|
| 93 |
+
const useGraphStoreBase = create<GraphState>()((set, get) => ({
|
| 94 |
selectedNode: null,
|
| 95 |
focusedNode: null,
|
| 96 |
selectedEdge: null,
|
|
|
|
| 104 |
graphLabels: ['*'],
|
| 105 |
allDatabaseLabels: ['*'],
|
| 106 |
|
| 107 |
+
refreshLayout: () => {
|
| 108 |
+
const currentGraph = get().sigmaGraph;
|
| 109 |
+
if (currentGraph) {
|
| 110 |
+
get().clearSelection();
|
| 111 |
+
get().setSigmaGraph(null);
|
| 112 |
+
setTimeout(() => {
|
| 113 |
+
get().setSigmaGraph(currentGraph);
|
| 114 |
+
}, 10);
|
| 115 |
+
}
|
| 116 |
+
},
|
| 117 |
+
|
| 118 |
setIsFetching: (isFetching: boolean) => set({ isFetching }),
|
| 119 |
setSelectedNode: (nodeId: string | null, moveToSelectedNode?: boolean) =>
|
| 120 |
set({ selectedNode: nodeId, moveToSelectedNode }),
|
lightrag_webui/src/stores/settings.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { persist, createJSONStorage } from 'zustand/middleware'
|
|
| 3 |
import { createSelectors } from '@/lib/utils'
|
| 4 |
import { defaultQueryLabel } from '@/lib/constants'
|
| 5 |
import { Message, QueryRequest } from '@/api/lightrag'
|
| 6 |
-
import { useGraphStore } from '@/stores/graph'
|
| 7 |
|
| 8 |
type Theme = 'dark' | 'light' | 'system'
|
| 9 |
type Language = 'en' | 'zh'
|
|
@@ -11,7 +10,6 @@ type Tab = 'documents' | 'knowledge-graph' | 'retrieval' | 'api'
|
|
| 11 |
|
| 12 |
interface SettingsState {
|
| 13 |
// Graph viewer settings
|
| 14 |
-
refreshLayout: () => void
|
| 15 |
showPropertyPanel: boolean
|
| 16 |
showNodeSearchBar: boolean
|
| 17 |
|
|
@@ -64,16 +62,6 @@ const useSettingsStoreBase = create<SettingsState>()(
|
|
| 64 |
(set) => ({
|
| 65 |
theme: 'system',
|
| 66 |
language: 'en',
|
| 67 |
-
refreshLayout: () => {
|
| 68 |
-
const graphState = useGraphStore.getState();
|
| 69 |
-
const currentGraph = graphState.sigmaGraph;
|
| 70 |
-
graphState.clearSelection();
|
| 71 |
-
graphState.setSigmaGraph(null);
|
| 72 |
-
setTimeout(() => {
|
| 73 |
-
graphState.setSigmaGraph(currentGraph);
|
| 74 |
-
}, 10);
|
| 75 |
-
},
|
| 76 |
-
|
| 77 |
showPropertyPanel: true,
|
| 78 |
showNodeSearchBar: true,
|
| 79 |
|
|
|
|
| 3 |
import { createSelectors } from '@/lib/utils'
|
| 4 |
import { defaultQueryLabel } from '@/lib/constants'
|
| 5 |
import { Message, QueryRequest } from '@/api/lightrag'
|
|
|
|
| 6 |
|
| 7 |
type Theme = 'dark' | 'light' | 'system'
|
| 8 |
type Language = 'en' | 'zh'
|
|
|
|
| 10 |
|
| 11 |
interface SettingsState {
|
| 12 |
// Graph viewer settings
|
|
|
|
| 13 |
showPropertyPanel: boolean
|
| 14 |
showNodeSearchBar: boolean
|
| 15 |
|
|
|
|
| 62 |
(set) => ({
|
| 63 |
theme: 'system',
|
| 64 |
language: 'en',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
showPropertyPanel: true,
|
| 66 |
showNodeSearchBar: true,
|
| 67 |
|