diff options
Diffstat (limited to 'js/controller/generations.js')
-rw-r--r-- | js/controller/generations.js | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/js/controller/generations.js b/js/controller/generations.js index 011dfa2..2b17a59 100644 --- a/js/controller/generations.js +++ b/js/controller/generations.js @@ -15,16 +15,43 @@ // License along with this program. If not, see // <http://www.gnu.org/licenses/>. -(function(generations) { - generations.controller = (function() { - function controller() { - this.generations = m.prop([]); +guix.generations.controller = function() { + var generations = K.fromPromise(guix.generations.Generations()); - generations.Generations() - .then(this.generations) - .then(m.redraw); - } + return guix.ui.spinUntil(generations.map(function(generations) { + return [ + guix.ui.headerWithBadge("Generations", generations.length), + m("table.table.table-bordered", [ + m("thead", m("tr", [ + m("th", "#"), + m("th", "Name"), + m("th", "Version"), + m("th", "Output"), + m("th", "Location") + ])), + m("tbody", [ + generations.map(function(generation) { + var entries = generation.manifestEntries; - return controller; - })(); -})(guix.generations); + function renderRow(entry, isFirst) { + return m("tr", [ + isFirst ? m("td", { + rowspan: entries.length + }, m("strong", generation.number)) : null, + m("td", entry.name), + m("td", entry.version), + m("td", entry.output), + m("td", entry.location) + ]); + } + + return [renderRow(entries[0], true)] + .concat(entries.slice(1).map(function (entry) { + return renderRow(entry, false); + })); + }) + ]) + ]) + ]; + })).map(guix.withLayout); +}; |