From 03997075bec3a0fd436c881a748b108acc7a98fd Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 6 Jul 2017 13:12:21 +0200 Subject: [locationinfo] Support runmode module --- .../locationinfo/hooks/runmode/config.json | 4 ++++ modules-available/locationinfo/inc/locationinfo.inc.php | 11 +++++++++++ modules-available/locationinfo/page.inc.php | 9 ++++++++- .../templates/page-config-panel-default.html | 17 ++++++++--------- .../locationinfo/templates/page-panels.html | 15 +++++++++++++-- 5 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 modules-available/locationinfo/hooks/runmode/config.json (limited to 'modules-available') diff --git a/modules-available/locationinfo/hooks/runmode/config.json b/modules-available/locationinfo/hooks/runmode/config.json new file mode 100644 index 00000000..8c1ebad8 --- /dev/null +++ b/modules-available/locationinfo/hooks/runmode/config.json @@ -0,0 +1,4 @@ +{ + "getModeName": "LocationInfo::getPanelName", + "isClient": false +} \ No newline at end of file diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php index 473804cc..36a77d4f 100644 --- a/modules-available/locationinfo/inc/locationinfo.inc.php +++ b/modules-available/locationinfo/inc/locationinfo.inc.php @@ -75,4 +75,15 @@ class LocationInfo ); } + /** + * @param string $uuid panel uuid + * @return bool|string panel name if exists, false otherwise + */ + public static function getPanelName($uuid) + { + $ret = Database::queryFirst('SELECT panelname FROM locationinfo_panel WHERE paneluuid = :uuid', compact('uuid')); + if ($ret === false) return false; + return $ret['panelname']; + } + } diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index e8ce7b78..f5e64209 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -440,6 +440,10 @@ class Page_LocationInfo extends Page $res = Database::simpleQuery('SELECT p.paneluuid, p.panelname, p.locationids, p.paneltype FROM locationinfo_panel p ORDER BY panelname ASC'); + $hasRunmode = Module::isAvailable('runmode'); + if ($hasRunmode) { + $runmodes = RunMode::getForModule(Page::getModule(), true); + } $panels = array(); $locations = Location::getLocationsAssoc(); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { @@ -452,9 +456,12 @@ class Page_LocationInfo extends Page if ($len < 5) { $row['panelname'] .= str_repeat('…', 5 - $len); } + if ($hasRunmode && isset($runmodes[$row['paneluuid']])) { + $row['assignedMachineCount'] = count($runmodes[$row['paneluuid']]); + } $panels[] = $row; } - Render::addTemplate('page-panels', array('panels' => $panels)); + Render::addTemplate('page-panels', compact('panels', 'hasRunmode')); } /** diff --git a/modules-available/locationinfo/templates/page-config-panel-default.html b/modules-available/locationinfo/templates/page-config-panel-default.html index fac1db03..4632a718 100644 --- a/modules-available/locationinfo/templates/page-config-panel-default.html +++ b/modules-available/locationinfo/templates/page-config-panel-default.html @@ -300,15 +300,14 @@ diff --git a/modules-available/locationinfo/templates/page-panels.html b/modules-available/locationinfo/templates/page-panels.html index 51998cea..8b567410 100644 --- a/modules-available/locationinfo/templates/page-panels.html +++ b/modules-available/locationinfo/templates/page-panels.html @@ -8,8 +8,11 @@ {{lang_panel}} {{lang_panelType}} {{lang_locations}} - - + {{#hasRunmode}} + {{lang_runmodeTHead}} + {{/hasRunmode}} + + @@ -27,6 +30,14 @@ {{locations}} + {{#hasRunmode}} + + + + + {{assignedMachineCount}} + + {{/hasRunmode}} -- cgit v1.2.3-55-g7522