• Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
  • Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

How to show inventory of devices on the dashboard page using hooks?

Scheduled Pinned Locked Moved
General
2
8
2.5k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A
    Asthea
    last edited by Asthea Oct 16, 2015, 4:44 AM Oct 15, 2015, 10:15 AM

    Not quite sure if this is the correct forum, but I don’t see any more appropriate categories, so I’ll ask my question here (sry if I missed something):

    I’m currently playing around with the (php) code and I was able to pretty much get anything I wanted going. But I seem to have trouble with the following: I want to show the inventory of every device on the dashboard page. I’m not quite sure how to do that though. I have tried several approaches but somehow none of them work (e.g. MySQL query, …). How do I go about when I want to show certain inventory elements of specific devices on the dashboard page, or to be more precise, which classes/functions do I have to call?

    Thanks. 🙂

    Edit: I decided to try to use hooks to solve this problem.

    1 Reply Last reply Reply Quote 0
    • T
      Tom Elliott
      last edited by Oct 15, 2015, 11:11 AM

      You shouldn’t have to make any specific calls, and this is probably better handled by using a hook or a plugin to do what you want.

      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

      Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

      Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

      1 Reply Last reply Reply Quote 1
      • A
        Asthea
        last edited by Asthea Oct 16, 2015, 12:22 AM Oct 16, 2015, 6:21 AM

        Ok thanks. I’ll have a look those options then. 🙂

        1 Reply Last reply Reply Quote 0
        • A
          Asthea
          last edited by Asthea Oct 16, 2015, 2:54 AM Oct 16, 2015, 8:51 AM

          Hmm, am I missing something or why does only the VNC hook work? All other hooks aren’t working when I set $active = true;. Btw, I’m using FOG 4700.

          1 Reply Last reply Reply Quote 0
          • T
            Tom Elliott
            last edited by Oct 16, 2015, 9:38 AM

            Hooks work off the events they are designed for. For example, the vnc hook affects the host management page off the HOST_DATA event. If HOST_DATA doesn’t exist but the hook is active there isn’t going to be anything that needs alteration.

            Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

            Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

            Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

            A 2 Replies Last reply Oct 16, 2015, 9:40 AM Reply Quote 0
            • A
              Asthea @Tom Elliott
              last edited by Oct 16, 2015, 9:40 AM

              @Tom-Elliott I’ve tried to copy and paste the VNC hook into e.g. AddHostSerial hook, they both use HOST_DATA so they should be interchangeable. Copying VNC code to AddHostSerial didn’t work but for some reason, copying AddHostSerial code to VNC did work. I don’t understand why though.

              1 Reply Last reply Reply Quote 0
              • A
                Asthea @Tom Elliott
                last edited by Asthea Oct 16, 2015, 4:12 AM Oct 16, 2015, 10:10 AM

                @Tom-Elliott I modified the VNC hook now to represent a minimal (working) example:

                class HostVNCLink extends Hook {
                	var $name = 'HostVNCLink';
                	var $description = 'Adds a "VNC" link to the Host Lists';
                	var $author = 'Blackout';
                	var $active = true;
                
                	function DashboardData($arguments) {
                		if ($_REQUEST['node'] == 'home') {
                			echo 'test';
                		}
                	}
                }
                $HookManager->register('DashboardData', array(new HostVNCLink(), 'DashboardData'));
                

                If I use the exact same code in e.g. AddHostSerial.hook.php (with the classnames changed ofc), the hook doesn’t work. This is what I don’t understand. Do I have to register AddHostSerial somewhere for it to work?

                1 Reply Last reply Reply Quote 0
                • A
                  Asthea
                  last edited by Asthea Oct 16, 2015, 4:37 AM Oct 16, 2015, 10:34 AM

                  @Tom-Elliott Ok I figured it out. The problem were the comments in the AddHostSerial.hook.php:

                  	/** @var $name the name of the hook */
                  	public $name = 'AddHostSerial';
                  	/** @var $description the description of what the hook does */
                  	public $description = 'Adds host serial to the host lists';
                  	/** @var $author the author of the hook */
                  	public $author = 'Junkhacker with edits from Tom Elliott';
                  	/** @var $active whether or not the hook is to be running */
                  	public $active = true;
                  

                  Those @var $name Symbols are not very PHP friendly it seems. 🙂

                  Thanks for the help, Tom. 😄

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  1 / 1
                  • First post
                    2/8
                    Last post

                  150

                  Online

                  12.0k

                  Users

                  17.3k

                  Topics

                  155.2k

                  Posts
                  Copyright © 2012-2024 FOG Project