From 0ff7bf98b50a2057e76d252f5e044dc48908e350 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 30 Oct 2019 11:11:58 +0100 Subject: [minilinux] Split version list and source list into separate sub-menus --- modules-available/minilinux/lang/de/module.json | 2 + modules-available/minilinux/page.inc.php | 56 ++++++++++++++----------- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/modules-available/minilinux/lang/de/module.json b/modules-available/minilinux/lang/de/module.json index 687b4a71..3e5ed495 100644 --- a/modules-available/minilinux/lang/de/module.json +++ b/modules-available/minilinux/lang/de/module.json @@ -7,6 +7,8 @@ "file-size-mismatch": "Dateigr\u00f6\u00dfe stimmt nicht", "ipxe-debug": "Debug-Ausgaben statt Bootlogo", "ipxe-kcl-extra": "Modifikation der Kernel-Command-Line", + "menu-sources": "Update-Quellen", + "menu-versions": "Verf\u00fcgbare Versionen", "module_name": "Netboot Grundsystem", "not_installed_hint": "(nicht installiert)", "page_title": "Linuxvarianten f\u00fcr Netboot verwalten" diff --git a/modules-available/minilinux/page.inc.php b/modules-available/minilinux/page.inc.php index 29169807..575177a8 100644 --- a/modules-available/minilinux/page.inc.php +++ b/modules-available/minilinux/page.inc.php @@ -25,6 +25,8 @@ class Page_MiniLinux extends Page } User::assertPermission('view'); + Dashboard::addSubmenu('?do=minilinux', Dictionary::translate('menu-versions', true)); + Dashboard::addSubmenu('?do=minilinux&show=sources', Dictionary::translate('menu-sources', true)); } protected function doRender() @@ -34,33 +36,39 @@ class Page_MiniLinux extends Page if (!MiniLinux::updateCurrentBootSetting()) { Message::addError('default-not-installed', Property::get(MiniLinux::PROPERTY_DEFAULT_BOOT)); } - // List branches and versions - $branches = Database::queryAll('SELECT sourceid, branchid, title, description FROM minilinux_branch ORDER BY title ASC'); - $versions = MiniLinux::queryAllVersionsByBranch(); - // Group by branch for detailed listing - foreach ($branches as &$branch) { - if (isset($versions[$branch['branchid']])) { - $branch['versionlist'] = $this->renderVersionList($versions[$branch['branchid']]); - } - } - unset($branch); - Render::addTemplate('branches', ['branches' => $branches]); - // List sources - $res = Database::simpleQuery('SELECT sourceid, title, url, lastupdate, pubkey FROM minilinux_source ORDER BY title, sourceid'); - $data = ['list' => [], 'show_refresh' => true]; - $tooOld = strtotime('-7 days'); - $showRefresh = strtotime('-10 minutes'); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { - $row['lastupdate_s'] = Util::prettyTime($row['lastupdate']); - if ($row['lastupdate'] != 0 && $row['lastupdate'] < $tooOld) { - $row['update_class'] = 'text-danger'; + $show = Request::get('show', 'list', 'string'); + if ($show === 'list') { + // List branches and versions + $branches = Database::queryAll('SELECT sourceid, branchid, title, description FROM minilinux_branch ORDER BY title ASC'); + $versions = MiniLinux::queryAllVersionsByBranch(); + // Group by branch for detailed listing + foreach ($branches as &$branch) { + if (isset($versions[$branch['branchid']])) { + $branch['versionlist'] = $this->renderVersionList($versions[$branch['branchid']]); + } } - if ($row['lastupdate'] > $showRefresh) { - $data['show_refresh'] = false; + unset($branch); + Render::addTemplate('branches', ['branches' => $branches]); + } elseif ($show === 'sources') { + // List sources + $res = Database::simpleQuery('SELECT sourceid, title, url, lastupdate, pubkey FROM minilinux_source ORDER BY title, sourceid'); + $data = ['list' => [], 'show_refresh' => true]; + $tooOld = strtotime('-7 days'); + $showRefresh = strtotime('-10 minutes'); + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $row['lastupdate_s'] = Util::prettyTime($row['lastupdate']); + if ($row['lastupdate'] != 0 && $row['lastupdate'] < $tooOld) { + $row['update_class'] = 'text-danger'; + } + if ($row['lastupdate'] > $showRefresh) { + $data['show_refresh'] = false; + } + $data['list'][] = $row; } - $data['list'][] = $row; + Render::addTemplate('sources', $data); + } else { + Message::addError('main.invalid-action', $show); } - Render::addTemplate('sources', $data); } protected function doAjax() -- cgit v1.2.3-55-g7522