Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
feat(agent): show online status in form
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Oct 20, 2018
1 parent 9b47fdc commit 38f3840
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion inc/agent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ public function showForm($ID, array $options = []) {
'value' => $this->fields['plugin_flyvemdm_fleets_id'],
'entity' => $this->fields['entities_id']
]);
$fields['is_online'] = self::getSpecificValueToDisplay('is_online', $fields['is_online']);
if (empty($fields['last_contact'])) {
$fields['last_contact'] = __('Never seen online', 'flyvemdm');
}
Expand Down Expand Up @@ -1998,8 +1999,12 @@ public static function getSpecificValueToDisplay($field, $values, array $options
switch ($field) {
case 'is_online':
if (!isAPI()) {
$style = '';
if (isset($options['center']) && $options['center']) {
$style = 'style="text-align: center"';
}
$class = $values[$field] == 0 ? "plugin-flyvemdm-offline" : "plugin-flyvemdm-online";
$output = '<div style="text-align: center"><i class="fa fa-circle '
$output = '<div ' . $style . '><i class="fa fa-circle '
. $class
. '" aria-hidden="true" ></i></div>';
return $output;
Expand Down
8 changes: 5 additions & 3 deletions tpl/agent.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<tr class='tab_bg_1'>
<td>
{{ __('Name') }}{{ withTemplate }}
{{ __('Name') }}{{ withTemplate }}
</td>
<td>
{{ agent.name|raw }}
Expand Down Expand Up @@ -28,14 +28,16 @@
</tr>
<tr class='tab_bg_1'>
<td>
{{ __('Last contact', 'flyvemdm') }}
{{ __('Is online', 'flyvemdm') }}
</td>
<td>
{{ agent.last_contact }}
{{ agent.is_online|raw }}
</td>
<td>
{{ __('Last contact', 'flyvemdm') }}
</td>
<td>
{{ agent.last_contact }}
</td>
</tr>
{% if canUpdate == true %}
Expand Down

0 comments on commit 38f3840

Please sign in to comment.