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

Commit

Permalink
feat(agent): display prefs, and online status
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry authored and DIOHz0r committed May 8, 2018
1 parent 4290a52 commit 5b2c6f4
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
8 changes: 8 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ ul#menu ul.ssmenu {
z-index: 10000;
}

.plugin-flyvemdm-online {
color: #009933;
}

.plugin-flyvemdm-offline {
color: #e62e00;
}

/*---------------- GEOLOCATION TAB ----------------*/

.plugin_flyvemdm_clear::after {
Expand Down
31 changes: 31 additions & 0 deletions inc/agent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1945,4 +1945,35 @@ public function refreshPersistedNotifications() {
public function isNotifiable() {
return true;
}

/**
* Define how to display a specific value in search result table
*
* @param String $field Name of the field as define in $this->getSearchOptions()
* @param Mixed $values The value as it is stored in DB
* @param Array $options Options (optional)
* @return Mixed Value to be displayed
*/
public static function getSpecificValueToDisplay($field, $values, array $options = []) {
global $CFG_GLPI;
if (!is_array($values)) {
$values = [$field => $values];
}
switch ($field) {
case 'is_online':
if (!isAPI()) {
if ($values[$field] == 0) {
$class = "plugin-flyvemdm-offline";
} else {
$class = "plugin-flyvemdm-online";
}
$output = '<div style="text-align: center"><i class="fa fa-circle '
. $class
. '" aria-hidden="true" ></i></div>';
return $output;
}
break;
}
return parent::getSpecificValueToDisplay($field, $values, $options);
}
}
33 changes: 33 additions & 0 deletions install/installer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,39 @@ protected function createDisplayPreferences() {
User::getForeignKeyField() => '0'
]);
}

$itemtype = PluginFlyvemdmAgent::class;
$rank = 1;
$criteria = "`itemtype` = '$itemtype' AND `num` = '11' AND `users_id` = '0'";
if (count($displayPreference->find($criteria)) == 0) {
$displayPreference->add([
'itemtype' => $itemtype,
'num' => '11',
'rank' => $rank,
User::getForeignKeyField() => '0'
]);
}
$rank++;
$criteria = "`itemtype` = '$itemtype' AND `num` = '12' AND `users_id` = '0'";
if (count($displayPreference->find($criteria)) == 0) {
$displayPreference->add([
'itemtype' => $itemtype,
'num' => '12',
'rank' => $rank,
User::getForeignKeyField() => '0'
]);
}
$rank++;
$criteria = "`itemtype` = '$itemtype' AND `num` = '3' AND `users_id` = '0'";
if (count($displayPreference->find($criteria)) == 0) {
$displayPreference->add([
'itemtype' => $itemtype,
'num' => '3',
'rank' => $rank,
User::getForeignKeyField() => '0'
]);
}

}

protected function deleteDisplayPreferences() {
Expand Down

0 comments on commit 5b2c6f4

Please sign in to comment.