Add graph view

This commit is contained in:
sarah committed 2026-10-09 09:16:38 +02:00
1 parent f851ecd820
commit 57a07874ee
12 files changed
+1152 -2

No files matched your search

+11
View File
@@ -113,6 +113,7 @@ class Source:
def Upload(self, Root: str, DirectoryPath: str, LocalFile: Path, OnProgress: Optional[Callable[[float], None]] = None) -> str: ...
def LocalFile(self, Root: str, RelativePath: str) -> Path: ...
def Book(self, Root: str, RelativePath: str) -> dict: ...
def Graph(self, Root: str, RelativePath: str) -> dict: ...
@property
def CanWrite(self) -> bool:
@@ -268,6 +269,12 @@ class LocalSource(Source):
def Book(self, Root: str, RelativePath: str) -> dict:
return {} # SaraTag tags are only read through a server for now
def Graph(self, Root: str, RelativePath: str) -> dict:
"""The graph view's data, built here the way the server builds it."""
from Graph import BuildLocalGraph # Graph.py imports this module
return BuildLocalGraph(self, Root, RelativePath)
class ServerSource(Source):
"""A SaraView server, through the same /api endpoints the web frontend
@@ -453,6 +460,10 @@ class ServerSource(Source):
except SourceError:
return {} # tags are extra; a file without them still opens
def Graph(self, Root: str, RelativePath: str) -> dict:
# A big root takes the server a while to read through.
return self._Json("GET", "/graph", params=self._At(Root, RelativePath), timeout=120)
def MakeSource(Config: AppConfig, Token: str = "") -> Source:
return ServerSource(Config, Token) if Config.Mode == "Server" else LocalSource(Config)