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

Commit

Permalink
feat(ui): added Flyvemdm Agent tab on Computer details
Browse files Browse the repository at this point in the history
  • Loading branch information
DIOHz0r committed Dec 12, 2017
1 parent 51278d1 commit 7c8489b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
25 changes: 25 additions & 0 deletions inc/agent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
return self::createTabEntry(self::getTypeName($pluralNumber), $nb);
}
break;

case Computer::class:
return __('FlyveMDM Agent', 'flyvemdm');
break;
}
}
}
Expand All @@ -193,6 +197,10 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem
self::showForFleet($item);
return true;
break;

case Computer::class:
self::displayTabContentForComputer($item);
break;
}
}

Expand Down Expand Up @@ -328,6 +336,23 @@ public static function showForFleet(PluginFlyvemdmFleet $item) {
echo $twig->render('agent_fleet.html', $data);
}

/**
* @param PluginFlyvemdmAgent $item
*/
public static function displayTabContentForComputer($item) {
global $CFG_GLPI;

$agent = new static();
$agent->getFromDBByCrit(['computers_id' => $item->getID()]);
$fields = $agent->fields;
$fields['fleet']=$agent->getFleet();
if (empty($fields['last_contact'])) {
$fields['last_contact'] = __('Never seen online', 'flyvemdm');
}
$twig = plugin_flyvemdm_getTemplateEngine();
echo $twig->render('agentComputerTab.html', ['agent' => $fields, 'glpi_root_doc' => $CFG_GLPI['root_doc']]);
}

/**
* @see CommonDBTM::canViewItem()
*/
Expand Down
2 changes: 1 addition & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function plugin_init_flyvemdm() {
* Register classes
*/
function plugin_flyvemdm_registerClasses() {
Plugin::registerClass(PluginFlyvemdmAgent::class);
Plugin::registerClass(PluginFlyvemdmAgent::class, ['addtabon' => Computer::class]);
Plugin::registerClass(PluginFlyvemdmFleet::class);
Plugin::registerClass(PluginFlyvemdmPolicy::class);
Plugin::registerClass(PluginFlyvemdmTask::class);
Expand Down
18 changes: 18 additions & 0 deletions tpl/agentComputerTab.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<table class="tab_cadre">
<tr>
<th colspan="4" class="">{{ __('Flyve MDM') }}</th>
</tr>
<tr class="tab_bg_1">
<td>{{ __('Name') }}{{ withTemplate }}</td>
<td><a href="{{ glpi_root_doc }}/plugins/flyvemdm/front/agent.form.php?id={{ agent.id }}">{{ agent.name }}</a></td>
<td>{{ __('Version') }}</td>
<td>{{ agent.version }}</td>
</tr>
<tr class="tab_bg_1">
<td>{{ __('Fleet', 'flyvemdm') }}</td>
<td><a href="{{ glpi_root_doc }}/plugins/flyvemdm/front/fleet.form.php?id={{ agent.plugin_flyvemdm_fleets_id }}">{{ agent.fleet.name }}</a>
</td>
<td>{{ __('Last contact', 'flyvemdm') }}</td>
<td>{{ agent.last_contact }}</td>
</tr>
</table>

0 comments on commit 7c8489b

Please sign in to comment.