Render "all objects" table using SlotsSequenceElement

This commit is contained in:
Sajith Sasidharan 2020-06-12 14:01:41 -04:00
parent 3783349ea7
commit cfb1560d15
2 changed files with 18 additions and 22 deletions

View File

@ -24,6 +24,7 @@ from allmydata.web.common import (
get_root, get_root,
WebError, WebError,
MultiFormatResource, MultiFormatResource,
SlotsSequenceElement,
) )
from allmydata.web.operations import ReloadMixin from allmydata.web.operations import ReloadMixin
from allmydata.interfaces import ( from allmydata.interfaces import (
@ -825,30 +826,25 @@ class DeepCheckAndRepairResultsRendererElement(Element, ResultsBase, ReloadMixin
return tags.div(tags.a("Return to file/directory.", href=return_to)) return tags.div(tags.a("Return to file/directory.", href=return_to))
return "" return ""
# TODO: use SlotsSequenceElement
@renderer @renderer
def all_objects(self, req, tag): def all_objects(self, req, tag):
r = self.monitor.get_status().get_all_results() results = self.monitor.get_status().get_all_results()
for path in sorted(r.keys()): objects = []
yield (path, r[path])
@renderer for path in sorted(results.keys()):
def object(self, req, tag): result = results[path]
# TODO: figure this out storage_index = result.get_storage_index()
# path, r = data obj = {
tag.fillSlots("path", self._join_pathstring(path)) "path": self._join_pathstring(path),
tag.fillSlots("healthy_pre_repair", "healthy_pre_repair": str(result.get_pre_repair_results().is_healthy()),
str(r.get_pre_repair_results().is_healthy())) "recoverable_pre_repair": str(result.get_pre_repair_results().is_recoverable()),
tag.fillSlots("recoverable_pre_repair", "healthy_post_repair": str(result.get_post_repair_results().is_healthy()),
str(r.get_pre_repair_results().is_recoverable())) "storage_index": self._render_si_link(req, storage_index),
tag.fillSlots("healthy_post_repair", "summary": self._html(result.get_pre_repair_results().get_summary()),
str(r.get_post_repair_results().is_healthy())) }
storage_index = r.get_storage_index() objects.append(obj)
tag.fillSlots("storage_index",
self._render_si_link(ctx, storage_index)) return SlotsSequenceElement(tag, objects)
tag.fillSlots("summary",
self._html(r.get_pre_repair_results().get_summary()))
return tag
@renderer @renderer
def runtime(self, req, tag): def runtime(self, req, tag):

View File

@ -78,7 +78,7 @@
<td>Storage Index</td> <td>Storage Index</td>
<td>Summary</td> <td>Summary</td>
</tr> </tr>
<tr t:pattern="item" t:render="object"> <tr t:render="item">
<td><t:slot name="path"/></td> <td><t:slot name="path"/></td>
<td><t:slot name="healthy_pre_repair"/></td> <td><t:slot name="healthy_pre_repair"/></td>
<td><t:slot name="recoverable_pre_repair"/></td> <td><t:slot name="recoverable_pre_repair"/></td>