• 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

      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
      • Tom ElliottT
        Tom Elliott
        last edited by

        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

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

          1 Reply Last reply Reply Quote 0
          • A
            Asthea
            last edited by Asthea

            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
            • Tom ElliottT
              Tom Elliott
              last edited by

              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 Reply Quote 0
              • A
                Asthea @Tom Elliott
                last edited by

                @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

                  @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

                    @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
                    • First post
                      Last post

                    218

                    Online

                    12.0k

                    Users

                    17.3k

                    Topics

                    155.2k

                    Posts
                    Copyright © 2012-2024 FOG Project