feature: show page title in pagelists

This commit is contained in:
zombieyang
2024-07-16 13:56:51 +08:00
parent ec7fd0173c
commit f46f13b463
6 changed files with 39 additions and 27 deletions
+10 -7
View File
@@ -131,12 +131,9 @@ def registerSocketEvents(sdppp, sio):
@sio.event
async def b_get_pages(sid, data = {}):
pages = []
if sdppp.server_type == "comfy":
pages = list(sdppp.comfyui_instances.keys())
elif sdppp.server_type == "SD":
pages = list(sdppp.sd_instances.keys())
pages = list(sdppp.page_instances.values())
pages.reverse()
return {
'pages': pages
}
@@ -147,7 +144,7 @@ def registerSocketEvents(sdppp, sio):
await sdppp.sio.emit('s_run', to=data['sid'])
@sio.event
async def check_changes(sid):
async def c_check_changes(sid):
instance = sdppp.get_ps_instance()
if instance is None:
return
@@ -156,8 +153,14 @@ def registerSocketEvents(sdppp, sio):
await sio.emit('s_trigger_graph_change', to=sid)
@sio.event
async def reset_changes(sid):
async def c_reset_changes(sid):
instance = sdppp.get_ps_instance()
if instance is None:
return
instance.reset_change_tracker()
@sio.event
async def c_reset_instance_name(sid, data):
instance = sdppp.page_instances[sid]
instance["name"] = data["name"]
+14 -9
View File
@@ -5,8 +5,7 @@ from .apis import registerSocketEvents, registerComfyHTTPEndpoints, registerSDHT
class SDPPP:
def __init__(self):
self.photoshop_instances = dict()
self.comfyui_instances = dict()
self.sd_instances = dict()
self.page_instances = dict()
def attach_to_comfyui(self, PromptServer):
self.sio = socketio.AsyncServer(async_mode='aiohttp', cors_allowed_origins="*")
@@ -47,10 +46,18 @@ class SDPPP:
self.photoshop_instances[sid] = PhotoshopInstance(self, sid)
elif qsobj['type'] == 'comfyui':
self.comfyui_instances[sid] = True
self.page_instances[sid] = {
"sid": sid,
"type": "comfy",
"name": ""
}
elif qsobj['type'] == 'sd':
self.sd_instances[sid] = True
self.page_instances[sid] = {
"sid": sid,
"type": "sd",
"name": ""
}
else:
raise socketio.exceptions.ConnectionRefusedError('unknown instance type ' + qsobj['type'])
@@ -59,13 +66,11 @@ class SDPPP:
"server_type": self.server_type
})
# only emit by photoshop instance
@sio.event
async def disconnect(sid):
if sid in self.photoshop_instances:
self.photoshop_instances.pop(sid, None)
elif sid in self.comfyui_instances:
self.comfyui_instances.pop(sid, None)
elif sid in self.page_instances:
self.page_instances.pop(sid, None)
registerSocketEvents(self, self.sio)
@@ -77,4 +82,4 @@ class SDPPP:
return None
if sid is None:
sid = list(self.photoshop_instances.keys())[0]
return self.photoshop_instances[sid]
return self.photoshop_instances[sid]