diff --git a/ceurws/volume_view.py b/ceurws/volume_view.py
index c0161bf..61bbc21 100644
--- a/ceurws/volume_view.py
+++ b/ceurws/volume_view.py
@@ -3,6 +3,7 @@
@author: wf
"""
+from ngwidgets.lod_grid import GridConfig,ListOfDictsGrid
from ngwidgets.widgets import Link
from nicegui import ui
@@ -148,7 +149,7 @@ def showVolume(self, volume):
# template=self.templateEnv.getTemplate('volume_index_body.html')
# html=template.render(volume=volume)
- headerHtml = f"""{links}
{volume.h1}
+ headerHtml = f"""{links}{volume.h1}
{volume.acronym}
{volume.title}
{volume.desc}
@@ -192,3 +193,89 @@ async def onWikidataButtonClick(self, _args):
self.solution.log_view.push(err_msg)
except Exception as ex:
self.solution.handle_exception(ex)
+
+class VolumeListView(View):
+ """
+ show a list of volumes a table
+ """
+
+ def __init__(self, solution, parent):
+ """
+ constructor
+
+ Args:
+ solution: the solution
+ parent: the parent UI container
+
+ """
+ self.solution = solution
+ self.parent = parent
+ self.wdSync=self.solution.wdSync
+ self.get_volume_lod()
+ self.setup_ui()
+
+ def setup_ui(self):
+ """
+ show my volumes as a list
+ """
+ try:
+ with ui.row() as self.button_row:
+ self.wikidataButton = (
+ ui.button(
+ icon="web",
+ on_click=self.onWikidataButtonClick,
+ )
+ .classes("btn btn-primary btn-sm col-1")
+ .tooltip("Export to Wikidata")
+ )
+ pass
+ with ui.row() as self.grid_row:
+ grid_config = GridConfig(
+ key_col="Vol",
+ multiselect=True)
+ self.lod_grid=ListOfDictsGrid(lod=self.lod,config=grid_config)
+ # Modify the columnDefs for the "Title" column after grid initialization
+ for col_def in self.lod_grid.ag_grid.options["columnDefs"]:
+ if col_def["field"] == "Title": # Identify the "Title" column
+ col_def["maxWidth"] = 400 # width in pixels
+ self.lod_grid.sizeColumnsToFit()
+ except Exception as ex:
+ self.handle_exception(ex)
+
+ async def onWikidataButtonClick(self, _args):
+ """
+ handle wikidata sync request
+ """
+ try:
+ selected_rows = await self.lod_grid.get_selected_rows()
+ for row in selected_rows:
+ vol_number=row["#"]
+ volume = self.wdSync.volumesByNumber[vol_number]
+ ui.notify(f"exporting {vol_number}")
+ pass
+ except Exception as ex:
+ self.handle_exception(ex)
+
+ def get_volume_lod(self):
+ """
+ get the list of dict of all volumes
+ """
+ self.lod = []
+ volumeList = self.wdSync.vm.getList()
+ reverseVolumeList = sorted(
+ volumeList, key=lambda volume: volume.number, reverse=True
+ )
+ for volume in reverseVolumeList:
+ validMark = "✅" if volume.valid else "❌"
+ self.lod.append(
+ {
+ "#": volume.number,
+ "Vol": self.createLink(volume.url, f"Vol-{volume.number:04}"),
+ "Acronym": self.getValue(volume, "acronym"),
+ "Title": self.getValue(volume, "title"),
+ "Loctime": self.getValue(volume, "loctime"),
+ "Published": self.getValue(volume, "published"),
+ "SubmittedBy": self.getValue(volume, "submittedBy"),
+ "valid": validMark,
+ }
+ )
diff --git a/ceurws/webserver.py b/ceurws/webserver.py
index c886e00..bc08f1c 100644
--- a/ceurws/webserver.py
+++ b/ceurws/webserver.py
@@ -16,9 +16,9 @@
from ceurws.models.dblp import DblpPaper, DblpProceeding, DblpScholar
from ceurws.version import Version
-from ceurws.volume_view import VolumeView
+from ceurws.volume_view import VolumeView, VolumeListView
from ceurws.wikidatasync import VolumeNotFound, WikidataSync
-
+from ceurws.wikidata_view import WikidataView
class CeurWsWebServer(InputWebserver):
"""
@@ -45,6 +45,25 @@ def __init__(self):
"""
InputWebserver.__init__(self, config=CeurWsWebServer.get_config())
+ @ui.page("/volumes")
+ async def show_volumes(client: Client):
+ return await self.page(
+ client,CeurWsSolution.volumes
+ )
+
+ @ui.page("/volume/{volnumber}")
+ async def show_volume_page(client: Client,vol_number):
+ return await self.page(
+ client,CeurWsSolution.volumePage,vol_number
+ )
+
+ @ui.page("/wikidatasync")
+ async def wikidatasync(client: Client):
+ return await self.page(
+ client,CeurWsSolution.wikidatasync
+ )
+
+
@app.get("/volumes.json")
async def volumes():
"""
@@ -227,25 +246,15 @@ def __init__(self, webserver: CeurWsWebServer, client: Client):
"""
super().__init__(webserver, client) # Call to the superclass constructor
self.wdSync = self.webserver.wdSync
- self.get_volume_options()
-
- def get_volume_options(self):
- """
- get the volume options
- """
- # Initialize an empty dictionary to store volume number as key and title as value
- self.volume_options = {}
- self.volumes_by_number = {}
-
- # Populate the dictionary with volume numbers and titles
- for volume in self.wdSync.vm.getList():
- self.volumes_by_number[volume.number] = volume
-
- reverse_keys = sorted(self.volumes_by_number.keys(), reverse=True)
- for volume_number in reverse_keys:
- volume = self.volumes_by_number[volume_number]
- self.volume_options[volume.number] = f"Vol-{volume.number}:{volume.title}"
- pass
+
+ def configure_menu(self):
+ InputWebSolution.configure_menu(self)
+ self.link_button(
+ name="volumes", icon_name="table", target="/volumes"
+ )
+ self.link_button(
+ name="wikidata",icon_name="cloud_sync",target="/wikidatasync"
+ )
def prepare_ui(self):
"""
@@ -270,6 +279,26 @@ def add_css(self):
ui.add_head_html(
f''
)
+
+ async def wikidatasync(self):
+ """
+ show the wikidata sync table
+ """
+ def show():
+ self.wikidata_view =WikidataView(
+ self, self.container
+ )
+ await self.setup_content_div(show)
+
+ async def volumes(self):
+ """
+ show the volumes table
+ """
+ def show():
+ self.volume_list_view = VolumeListView(
+ self, self.container
+ )
+ await self.setup_content_div(show)
async def home(self):
"""
@@ -282,7 +311,7 @@ def show():
with ui.row() as self.select_container:
self.volume_select = self.add_select(
"Volume",
- selection=self.volume_options,
+ selection=self.wdSync.volumeOptions,
with_input=True,
on_change=self.volume_selected,
)
@@ -297,6 +326,6 @@ async def volume_selected(self, args: ValueChangeEventArguments):
when a volume is selected show the details in the Volume View
"""
vol_number = args.value
- volume = self.volumes_by_number[vol_number]
+ volume = self.wdSync.volumesByNumber[vol_number]
self.volume_view.showVolume(volume)
pass
diff --git a/ceurws/wikidata_view.py b/ceurws/wikidata_view.py
new file mode 100644
index 0000000..f9de888
--- /dev/null
+++ b/ceurws/wikidata_view.py
@@ -0,0 +1,32 @@
+'''
+Created on 2024-02-23
+
+@author: wf
+'''
+from ceurws.view import View
+
+class WikidataView(View):
+ """
+ Wikidata View
+ """
+
+ def __init__(self, solution, parent):
+ """
+ constructor
+
+ Args:
+ solution: the solution
+ parent: the parent UI container
+
+ """
+ self.solution = solution
+ self.parent = parent
+ self.setup_ui()
+
+ def setup_ui(self):
+ """
+ setup my User Interface elements
+ """
+ with self.parent:
+ pass
+
diff --git a/ceurws/wikidatasync.py b/ceurws/wikidatasync.py
index fb7f724..cfe3541 100644
--- a/ceurws/wikidatasync.py
+++ b/ceurws/wikidatasync.py
@@ -143,6 +143,12 @@ def prepareVolumeManager(self):
self.volumesByNumber, _duplicates = LOD.getLookup(self.vm.getList(), "number")
self.volumeList = self.vm.getList()
self.volumeCount = len(self.volumeList)
+ self.volumeOptions = {}
+ reverse_keys = sorted(self.volumesByNumber.keys(), reverse=True)
+ for volume_number in reverse_keys:
+ volume = self.volumesByNumber[volume_number]
+ self.volumeOptions[volume.number] = f"Vol-{volume.number}:{volume.title}"
+
def addVolume(self, volume: Volume):
"""