summaryrefslogtreecommitdiffstatshomepage
path: root/scripts/minimaws
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2017-08-04 11:39:32 +1000
committer Vas Crabb <vas@vastheman.com>2017-08-04 11:42:23 +1000
commit00f6156cbbadfc01dcd2a7e91d26d55fa210dfab (patch)
treec8b7b3756c4a0d1bf64a78356bb438221fffdceb /scripts/minimaws
parent0fbad045de7da6883d1930f81e895f59dc49c0b4 (diff)
minimaws: show compatible slots for devices [Vas Crabb]
(nw) Identify Donkey Kong Junior (Japan set F-1) [Corrado Comaselli]
Diffstat (limited to 'scripts/minimaws')
-rw-r--r--scripts/minimaws/lib/dbaccess.py7
-rw-r--r--scripts/minimaws/lib/htmltmpl.py14
-rw-r--r--scripts/minimaws/lib/wsgiserve.py29
3 files changed, 48 insertions, 2 deletions
diff --git a/scripts/minimaws/lib/dbaccess.py b/scripts/minimaws/lib/dbaccess.py
index b1cc48b87b8..147986e0039 100644
--- a/scripts/minimaws/lib/dbaccess.py
+++ b/scripts/minimaws/lib/dbaccess.py
@@ -198,6 +198,13 @@ class QueryCursor(object):
'WHERE machine.id IN (SELECT machine FROM devicereference WHERE device = ?)',
(device, ))
+ def get_compatible_slots(self, device):
+ return self.dbcurs.execute(
+ 'SELECT machine.shortname AS shortname, machine.description AS description, slot.name AS slot, slotoption.name AS slotoption, sourcefile.filename AS sourcefile ' \
+ 'FROM slotoption JOIN slot ON slotoption.slot = slot.id JOIN machine on slot.machine = machine.id JOIN sourcefile ON machine.sourcefile = sourcefile.id '
+ 'WHERE slotoption.device = ?',
+ (device, ))
+
def get_sourcefile_id(self, filename):
return (self.dbcurs.execute('SELECT id FROM sourcefile WHERE filename = ?', (filename, )).fetchone() or (None, ))[0]
diff --git a/scripts/minimaws/lib/htmltmpl.py b/scripts/minimaws/lib/htmltmpl.py
index d465f0d993d..815905a59bb 100644
--- a/scripts/minimaws/lib/htmltmpl.py
+++ b/scripts/minimaws/lib/htmltmpl.py
@@ -19,6 +19,11 @@ ERROR_PAGE = string.Template(
'</html>\n')
+SORTABLE_TABLE_EPILOGUE = string.Template(
+ ' </tbody>\n'
+ '</table>\n'
+ '<script>make_table_sortable(document.getElementById("${id}"));</script>\n')
+
MACHINE_PROLOGUE = string.Template(
'<!DOCTYPE html>\n' \
'<html>\n' \
@@ -64,6 +69,15 @@ EXCL_MACHINE_ROW = string.Template(
' <td></td>\n' \
' </tr>\n')
+COMPATIBLE_SLOT_ROW = string.Template(
+ ' <tr>\n' \
+ ' <td><a href="${machinehref}">${shortname}</a></td>\n' \
+ ' <td><a href="${machinehref}">${description}</a></td>\n' \
+ ' <td>${slot}</td>\n' \
+ ' <td>${slotoption}</td>\n' \
+ ' <td><a href="${sourcehref}">${sourcefile}</a></td>\n' \
+ ' </tr>\n')
+
SOURCEFILE_PROLOGUE = string.Template(
'<!DOCTYPE html>\n' \
diff --git a/scripts/minimaws/lib/wsgiserve.py b/scripts/minimaws/lib/wsgiserve.py
index fe96a60f4f4..1743178dbb7 100644
--- a/scripts/minimaws/lib/wsgiserve.py
+++ b/scripts/minimaws/lib/wsgiserve.py
@@ -211,6 +211,7 @@ class MachineHandler(QueryPageHandler):
yield htmltmpl.MACHINE_SLOTS_PLACEHOLDER.substitute(
machine=self.js_escape(self.shortname)).encode('utf=8')
+ # list devices referenced by this system/device
first = True
for name, desc, src in self.dbcurs.get_devices_referenced(id):
if first:
@@ -224,8 +225,32 @@ class MachineHandler(QueryPageHandler):
first = False
yield self.machine_row(name, desc, src)
if not first:
- yield ' </tbody>\n</table>\n<script>make_table_sortable(document.getElementById("tbl-dev-refs"));</script>\n'.encode('utf-8')
+ yield htmltmpl.SORTABLE_TABLE_EPILOGUE.substitute(id='tbl-dev-refs').encode('utf-8')
+ # list slots where this device is an option
+ first = True
+ for name, desc, slot, opt, src in self.dbcurs.get_compatible_slots(id):
+ if (first):
+ yield \
+ '<h2>Compatible Slots</h2>\n' \
+ '<table id="tbl-comp-slots">\n' \
+ ' <thead>\n' \
+ ' <tr><th>Short name</th><th>Description</th><th>Slot</th><th>Choice</th><th>Source file</th></tr>\n' \
+ ' </thead>\n' \
+ ' <tbody>\n'.encode('utf-8')
+ first = False
+ yield htmltmpl.COMPATIBLE_SLOT_ROW.substitute(
+ machinehref=self.machine_href(name),
+ sourcehref=self.sourcefile_href(src),
+ shortname=cgi.escape(name),
+ description=cgi.escape(desc),
+ sourcefile=cgi.escape(src),
+ slot=cgi.escape(slot),
+ slotoption=cgi.escape(opt)).encode('utf-8')
+ if not first:
+ yield htmltmpl.SORTABLE_TABLE_EPILOGUE.substitute(id='tbl-comp-slots').encode('utf-8')
+
+ # list systems/devices that reference this device
first = True
for name, desc, src in self.dbcurs.get_device_references(id):
if first:
@@ -239,7 +264,7 @@ class MachineHandler(QueryPageHandler):
first = False
yield self.machine_row(name, desc, src)
if not first:
- yield ' </tbody>\n</table>\n<script>make_table_sortable(document.getElementById("tbl-ref-by"));</script>\n'.encode('utf-8')
+ yield htmltmpl.SORTABLE_TABLE_EPILOGUE.substitute(id='tbl-ref-by').encode('utf-8')
yield '</html>\n'.encode('utf-8')