Ad Widget

Collapse

Open link trigger URL in a new tab - zbx v6.0.2

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • verde
    Member
    • Jul 2021
    • 39

    #1

    Open link trigger URL in a new tab - zbx v6.0.2

    Hi, I set a trigger URL, it works but opens in the same browser tab.
    Is there a way to configure or code to open it in a new browser tab?

    Trigger config:
    Click image for larger version

Name:	2022-06-06_12-54-toZbxForum-pic2.png
Views:	1512
Size:	22.0 KB
ID:	445750

    Triggered:
    Click image for larger version

Name:	2022-06-06_12-54-toZbxForum.png
Views:	1644
Size:	22.6 KB
ID:	445749


  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    No (or maybe if you take a deep dive into frontend code...) ... But just hold Ctrl key while you press this link.. I am so used to it, that I don't even notice doing it..

    Comment

    • verde
      Member
      • Jul 2021
      • 39

      #3

      Yes, but not all users have the level to do that, for temporary or very entry-level users (not talking about Gen-Y, Z, or younger), it would be convenient to open a new tab.
      Thanks anyway!

      Comment


      • Hamardaban
        Hamardaban commented
        Editing a comment
        There is also the dark magic of the right mouse click and the context menu :-)
    • speedfox
      Junior Member
      • Sep 2023
      • 1

      #4
      Same request here, I understand that it may be a considerable improvement for some of us.

      Comment

      • markosa
        Senior Member
        Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
        • Aug 2022
        • 104

        #5
        If someone really wants to have maintenace hell, then go ahead and modify menupopup.js, function createMenuItem(options). That's atleast one location to do such modification, either modify options or add link.attr('target', '_blank'); to proper location.

        Comment

        • Helliarch
          Junior Member
          • Feb 2025
          • 1

          #6
          It is a bit late but I want to share the method to exactly implement new tab for only url trigger elements in the menupopup.js, let's take a look:

          Inside of the function getMenuPopupURLData:

          Code:
          function getMenuPopupURLData(urls, trigger_element, hostid, eventid) {
              let tree = {};
          // Parse URLs and create tree.
              for (let key in urls) {
                  const url = urls[key];
          if (typeof url.menu_path !== 'undefined') {
                      const items = (url.menu_path.length > 0) ? splitPath(url.menu_path) : [];
          appendTreeItem(tree, url.label, items, {
                          url: url.url,
                          target: '_blank', // add here the target _blank
                          confirmation: url.confirmation,
                          manualinput: url.manualinput,
                          manualinput_prompt: url.manualinput_prompt,
                          manualinput_validator_type: url.manualinput_validator_type,
                          manualinput_validator: url.manualinput_validator,
                          manualinput_default_value: url.manualinput_default_value,
                          scriptid: url.scriptid,
                          hostid,
                          eventid
                      });
                  }
              }
          return getMenuPopupURLItems(tree, trigger_element);
          }
          And add this two lines on the function getMenuPopupURLItems:

          Code:
          function getMenuPopupURLItems(tree, trigger_elm) {
              let items = [];
          if (objectSize(tree) > 0) {
                  Object.values(tree).map((data) => {
                      const item = {label: data.name};
          if (typeof data.items !== 'undefined' && objectSize(data.items) > 0) {
                          item.items = getMenuPopupURLItems(data.items, trigger_elm);
                      }
          if (typeof data.params !== 'undefined') {
                          item.clickCallback = function(e) {
                              jQuery(this)
                                  .closest('.menu-popup-top')
                                  .menuPopup('close', trigger_elm, false);
                              Script.openUrl(data.params.scriptid, data.params.confirmation, trigger_elm,
                                  data.params.hostid, data.params.eventid, data.params.url, data.params.target,
                                  data.params.manualinput, data.params.manualinput_prompt, data.params.manualinput_validator_type,
                                  data.params.manualinput_validator, data.params.manualinput_default_value
                              );
                              cancelEvent(e);
                          };
          // add item.url reference to the params of url, and also the item.target _blank to manage the new tabs
                          item.url = data.params.url;
                          item.target = '_blank';
                      }
          items.push(item);
                  });
              }
          return items;
          }
          It should do the trick, I hope it works for you aswell!

          Comment

          Working...