Merge pull request 'chore(silo): add root package.xml and migrate setup to silo addon (#373)' (#374) from chore/silo-sdk-standardize into main
Some checks failed
Build and Test / build (push) Has been cancelled
Some checks failed
Build and Test / build (push) Has been cancelled
Reviewed-on: #374
This commit was merged in pull request #374.
This commit is contained in:
Submodule mods/silo updated: 65b87ef605...9187622239
@@ -42,6 +42,14 @@ install(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Install Silo addon
|
# Install Silo addon
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
${CMAKE_SOURCE_DIR}/mods/silo/package.xml
|
||||||
|
${CMAKE_SOURCE_DIR}/mods/silo/Init.py
|
||||||
|
${CMAKE_SOURCE_DIR}/mods/silo/InitGui.py
|
||||||
|
DESTINATION
|
||||||
|
mods/silo
|
||||||
|
)
|
||||||
install(
|
install(
|
||||||
DIRECTORY
|
DIRECTORY
|
||||||
${CMAKE_SOURCE_DIR}/mods/silo/freecad/
|
${CMAKE_SOURCE_DIR}/mods/silo/freecad/
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
# GUI initialization - loads Kindred addon workbenches via manifest-driven loader
|
# GUI initialization - loads Kindred addon workbenches via manifest-driven loader
|
||||||
|
|
||||||
import FreeCAD
|
import FreeCAD
|
||||||
import FreeCADGui
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from addon_loader import load_addons
|
from addon_loader import load_addons
|
||||||
@@ -24,99 +23,6 @@ def _register_kc_format():
|
|||||||
FreeCAD.Console.PrintLog(f"Create: kc_format registration skipped: {e}\n")
|
FreeCAD.Console.PrintLog(f"Create: kc_format registration skipped: {e}\n")
|
||||||
|
|
||||||
|
|
||||||
def _register_silo_document_observer():
|
|
||||||
"""Register the Silo document observer for .kc tree building."""
|
|
||||||
try:
|
|
||||||
import silo_document
|
|
||||||
|
|
||||||
silo_document.register()
|
|
||||||
except Exception as e:
|
|
||||||
FreeCAD.Console.PrintLog(f"Create: silo_document registration skipped: {e}\n")
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
# Silo integration enhancements
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
def _check_silo_first_start():
|
|
||||||
"""Show Silo settings dialog on first startup if not yet configured."""
|
|
||||||
try:
|
|
||||||
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/KindredSilo")
|
|
||||||
if not param.GetBool("FirstStartChecked", False):
|
|
||||||
param.SetBool("FirstStartChecked", True)
|
|
||||||
if not param.GetString("ApiUrl", ""):
|
|
||||||
FreeCADGui.runCommand("Silo_Settings")
|
|
||||||
except Exception as e:
|
|
||||||
FreeCAD.Console.PrintLog(f"Create: Silo first-start check skipped: {e}\n")
|
|
||||||
|
|
||||||
|
|
||||||
def _register_silo_origin():
|
|
||||||
"""Register Silo as a file origin so the origin selector can offer it."""
|
|
||||||
try:
|
|
||||||
import silo_commands # noqa: F401 - registers Silo commands
|
|
||||||
import silo_origin
|
|
||||||
|
|
||||||
silo_origin.register_silo_origin()
|
|
||||||
except Exception as e:
|
|
||||||
FreeCAD.Console.PrintLog(f"Create: Silo origin registration skipped: {e}\n")
|
|
||||||
|
|
||||||
|
|
||||||
def _setup_silo_auth_panel():
|
|
||||||
"""Dock the Silo authentication panel in the right-hand side panel."""
|
|
||||||
try:
|
|
||||||
from kindred_sdk import register_dock_panel
|
|
||||||
|
|
||||||
def _factory():
|
|
||||||
import silo_commands
|
|
||||||
|
|
||||||
auth = silo_commands.SiloAuthDockWidget()
|
|
||||||
# Prevent GC of the auth timer by stashing on the widget
|
|
||||||
auth.widget._auth = auth
|
|
||||||
return auth.widget
|
|
||||||
|
|
||||||
register_dock_panel("SiloDatabaseAuth", "Database Auth", _factory)
|
|
||||||
except Exception as e:
|
|
||||||
FreeCAD.Console.PrintLog(f"Create: Silo auth panel skipped: {e}\n")
|
|
||||||
|
|
||||||
|
|
||||||
def _setup_silo_activity_panel():
|
|
||||||
"""Show a dock widget with recent Silo database activity."""
|
|
||||||
try:
|
|
||||||
from kindred_sdk import register_dock_panel
|
|
||||||
|
|
||||||
def _factory():
|
|
||||||
from PySide import QtWidgets
|
|
||||||
|
|
||||||
widget = QtWidgets.QWidget()
|
|
||||||
layout = QtWidgets.QVBoxLayout(widget)
|
|
||||||
activity_list = QtWidgets.QListWidget()
|
|
||||||
layout.addWidget(activity_list)
|
|
||||||
|
|
||||||
try:
|
|
||||||
import silo_commands
|
|
||||||
|
|
||||||
items = silo_commands._client.list_items()
|
|
||||||
if isinstance(items, list):
|
|
||||||
for item in items[:20]:
|
|
||||||
pn = item.get("part_number", "")
|
|
||||||
desc = item.get("description", "")
|
|
||||||
updated = item.get("updated_at", "")
|
|
||||||
if updated:
|
|
||||||
updated = updated[:10]
|
|
||||||
activity_list.addItem(f"{pn} - {desc} - {updated}")
|
|
||||||
if activity_list.count() == 0:
|
|
||||||
activity_list.addItem("(No items in database)")
|
|
||||||
except Exception:
|
|
||||||
activity_list.addItem("(Unable to connect to Silo database)")
|
|
||||||
|
|
||||||
return widget
|
|
||||||
|
|
||||||
register_dock_panel("SiloDatabaseActivity", "Database Activity", _factory)
|
|
||||||
except Exception as e:
|
|
||||||
FreeCAD.Console.PrintLog(f"Create: Silo activity panel skipped: {e}\n")
|
|
||||||
|
|
||||||
|
|
||||||
def _check_for_updates():
|
def _check_for_updates():
|
||||||
"""Check for application updates in the background."""
|
"""Check for application updates in the background."""
|
||||||
try:
|
try:
|
||||||
@@ -132,11 +38,6 @@ try:
|
|||||||
from PySide.QtCore import QTimer
|
from PySide.QtCore import QTimer
|
||||||
|
|
||||||
QTimer.singleShot(500, _register_kc_format)
|
QTimer.singleShot(500, _register_kc_format)
|
||||||
QTimer.singleShot(600, _register_silo_document_observer)
|
|
||||||
QTimer.singleShot(1500, _register_silo_origin)
|
|
||||||
QTimer.singleShot(2000, _setup_silo_auth_panel)
|
|
||||||
QTimer.singleShot(3000, _check_silo_first_start)
|
|
||||||
QTimer.singleShot(4000, _setup_silo_activity_panel)
|
|
||||||
QTimer.singleShot(10000, _check_for_updates)
|
QTimer.singleShot(10000, _check_for_updates)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user