glpi icon indicating copy to clipboard operation
glpi copied to clipboard

feat(socket): add several socket from item

Open stonebuzz opened this issue 3 years ago ‱ 35 comments

Permit to add several Socket from an item

image

image

Compared to the standard add form

Position field is hidden (compute on add) and NetworkPort field is hidden too (useless here)

image

Q A
Bug fix? yes/no
New feature? yes/no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #number

stonebuzz avatar Jun 14 '22 08:06 stonebuzz

@rbrannath, @KongNan can you test this PR ?

stonebuzz avatar Jun 14 '22 13:06 stonebuzz

@KongNan can you test this PR ?

Sorry , I use a 3rd party environment called PhpStudy( like xampp ), I can install and use glpi releases, but when I try this, I get "Application dependencies are not up to date. Run 'php bin/console dependencies install' in the glpi tree to fix this". I can't test that :(

KongNan avatar Jul 01 '22 00:07 KongNan

@KongNan can you test this PR ?

And I searched the web, and was told it's not easy đŸ€„ă€‚ How can I do that ? "Vous essayez d'installer GLPI depuis les sources, ce qui n'est pas simple si vous n'ĂȘtes pas un dĂ©veloppeur smile Nous vous conseillons d'utiliser directement les releases prĂȘte Ă  ĂȘtre installĂ©es ..."

KongNan avatar Jul 01 '22 03:07 KongNan

@KongNan It will be quite complicated to explain here how

  • git clone
  • git fetch
  • git checkout
  • install dependencies
  • compile locales
  • install / update GLPI

stonebuzz avatar Jul 01 '22 06:07 stonebuzz

@KongNan can you test this PR ?

And I searched the web, and was told it's not easy lying_face。 How can I do that ? "Vous essayez d'installer GLPI depuis les sources, ce qui n'est pas simple si vous n'ĂȘtes pas un dĂ©veloppeur smile Nous vous conseillons d'utiliser directement les releases prĂȘte Ă  ĂȘtre installĂ©es ..."

Hi @KongNan

you can download a build for this PR (just install it as an official release)

https://github.com/stonebuzz/glpi/actions/runs/2595021249

stonebuzz avatar Jul 01 '22 09:07 stonebuzz

Hi @KongNan you can download a build for this PR (just install it as an official release) https://github.com/stonebuzz/glpi/actions/runs/2595021249

Thank you, I think this could work, let me try later :)

KongNan avatar Jul 01 '22 10:07 KongNan

image

When I try to Add several sockets, the content in the Name box is ignored (the content in From, To, Pre, Suf is retained) . I'm not sure if this is the expected behavior. (Sorry for my English)

KongNan avatar Jul 01 '22 13:07 KongNan

image

In addition I will get an error message whether I add several sockets or just one, and whether DebugMode is enabled or disabled. ( ! ) Deprecated: Called method is deprecated in F:\Profile\User\Downloads\GlpiTest11893\glpi\src\Toolbox.php on line 550

KongNan avatar Jul 01 '22 13:07 KongNan

If I use the glpi "socket" to description (for connection purposes), as you know, then for the patchpanel, the front socket and the rear socket are actually connected internally on a one-to-one basis.

To be precise, in many cases, for copper cables, the patchpanel may not have a rear socket but only a front socket, it is a module whose rear side holds the horizontal cable from the work area. If glpi needs to use the concept of "sockets" for network interfacing and needs both front and rear, then I would like to have an option to automatically create both front and rear sockets when adding sockets in bulk simultaneously, and have them automatically "connected" internally" but still be able to connected to the switch, wall socket or other socket on the back end of the fiber patch panel respectively without the connection being considered occupied by the socket on the opposite side of it.

Sorry for my poor English, thank you very much for your efforts! Hope I didn't give you too much trouble :)

KongNan avatar Jul 02 '22 11:07 KongNan

image a classic copper patch panel that has only "front socket". Certainly, you can think that's also front&rear, and fiber patch panel and Feed-Through patch panel have both front and rear sockets. So it's okay to have 2, but I still hope to have that auto option :)

KongNan avatar Jul 02 '22 12:07 KongNan

@stonebuzz, I have tested this PR and I have the same result regarding the missing "name" of the socket as @KongNan As I saw, you changed the socket_form.php, but now the original value of the "name" field is missing. Instead, the value of name is just a composition of the prefix, iterating number and the suffix.

This:

for ($i = $_POST["_from"]; $i <= $_POST["_to"]; $i++) {
      $_POST["name"] = $_POST["_before"] . $i . $_POST["_after"];

Should be (or similar):

$initialName = $_POST["name"];
for ($i = $_POST["_from"]; $i <= $_POST["_to"]; $i++) {
   $_POST["name"] = $_POST["_before"] . $initialName . $i . $_POST["_after"];

rbrannath avatar Aug 02 '22 18:08 rbrannath

@stonebuzz, an addition: It would be great to have the possibility to add multiple sockets when opening the "add" form via Cables -> Sockets. It is just another way, but it would be more convenient

rbrannath avatar Aug 02 '22 18:08 rbrannath

In addition I will get an error message whether I add several sockets or just one, and whether DebugMode is enabled or disabled. ( ! ) Deprecated: Called method is deprecated in F:\Profile\User\Downloads\GlpiTest11893\glpi\src\Toolbox.php on line 550

Fixed by this PR -> https://github.com/glpi-project/glpi/pull/11895 you can ignore the message

stonebuzz avatar Aug 09 '22 13:08 stonebuzz

@stonebuzz, I have tested this PR and I have the same result regarding the missing "name" of the socket as @KongNan As I saw, you changed the socket_form.php, but now the original value of the "name" field is missing. Instead, the value of name is just a composition of the prefix, iterating number and the suffix.

Fixed =)

stonebuzz avatar Aug 09 '22 13:08 stonebuzz

Then I would like to have an option to automatically create both front and rear sockets when adding sockets in bulk simultaneously, and have them automatically "connected" internally"

Added by new option from wiring side dropdown

image

stonebuzz avatar Aug 09 '22 13:08 stonebuzz

@trasher as I can see, there is a pending review. May I ask you to take a look?

rbrannath avatar Aug 23 '22 08:08 rbrannath

I'll wait for original requesters to do a functional review

trasher avatar Aug 23 '22 08:08 trasher

Then I would like to have an option to automatically create both front and rear sockets when adding sockets in bulk simultaneously, and have them automatically "connected" internally"

Added by new option from wiring side dropdown image

Just to be complete, I'd like to ramble on: there is a difference between the ports on a switch and a patch panel. Some switches have a number of expansion ports on the back in addition to the front panel ports. Of course, at this point, port 1 on the front panel has nothing to do with port 1 on the back panel.

image image from h3c website

And for patchpanel, the ports on both sides are obviously internally connected. So what I said earlier about automatic internal connectivity is for the patch panel, not the switch.

Of course, the vast majority of people are not really bothered. Unless they want to use the data from the CMDB in the GLPI for automation, etc. and want their links to form a complete chain with end-to-end connections.

(Again, sorry for my poor English, thank you very much for your efforts! Hope I didn't give you too much trouble :) )

KongNan avatar Aug 24 '22 10:08 KongNan

Hi @KongNan

This PR is made for add several socket at the same time

"Expansion ports" is another subject which requires further development

Best regards

stonebuzz avatar Aug 24 '22 13:08 stonebuzz

@cedric-anne I am not sure, but @stonebuzz has completed your change requests, right? Could you take a look pleased? It would be nice, if these PRs can be merged soon

rbrannath avatar Sep 07 '22 06:09 rbrannath

@rbrannath original requester has still not provided functional review of current PR, unless I missed something

trasher avatar Sep 07 '22 06:09 trasher

@rbrannath original requester has still not provided functional review of current PR, unless I missed something

Thank you @trasher, Can you please tell us : who do we need to ask for help, @stonebuzz or @cedric-anne ?

KongNan avatar Sep 07 '22 06:09 KongNan

@rbrannath original requester has still not provided functional review of current PR, unless I missed something

Thank you @trasher, Can you please tell us : who do we need to ask for help, @stonebuzz or @cedric-anne ?

Hi @KongNan can you do a functional review of current PR?

Best regards

stonebuzz avatar Sep 07 '22 06:09 stonebuzz

functional review By "functional review" do you mean "testing whether the functionality of the PR meets the description"? I think @rbrannath and I would be happy to try it. (But I'm afraid I'll run into "Application dependencies" issues)

KongNan avatar Sep 07 '22 06:09 KongNan

I think @rbrannath and I would be happy to try it. (But I'm afraid I'll run into "Application dependencies" issues)

You can find a build here

https://github.com/stonebuzz/glpi/actions/runs/3005612477

Best regards

stonebuzz avatar Sep 07 '22 07:09 stonebuzz

You can find a build here https://github.com/stonebuzz/glpi/actions/runs/3005612477

Here is my test, I don't know if I can call it a "functional review"

I envisioned an 8-port switch: Test8P_Sw_Front4GE_2SFP_Rear2Stack. I tried to add multiple sockets using the "Add several sockets" option. 1、first I try GePorts: Name is GEPorts, type is GE, located is frontpanel, from 1 to 4, prefix is GE, From 1 to 4, prefix GE , suffix is #. I get GEGePorts1#... GEGePorts4# 2、Then I try SfpPorts and Stack. The operation is similar to the above. Then I got what is shown in the figure and I think the function is working.

Test8P_Sw_Front4GE 2SFP_Rear2Stack

KongNan avatar Sep 09 '22 11:09 KongNan

Here are other things I found that I don't consider as "functional review", just for your information.

I don't expect that what I've said will cause the PR to not fit. We expect to use the PR.

1, When I use the from and to of the socket in reverse order (from 4 to 1), no content is added, which can be considered normal.

2, Port has "add multiple ports" and Socket has "add multiple sockets", users may feel confused. Of course, this is not the problem of the PR.

  1. As before, I still get some warning messages:

( ! ) Warning: Undefined array key "from_items_id" in F:\Profile\User\Downloads\add_several_socket_from_item.657561f.tar.gz\add_several_socket_from_item.657561f\glpi\src\Socket.php on line 209

Call Stack

Time Memory Function Location

1 0.0002 377864 {main}( ) ...\common.tabs.php:0 2 0.1097 2956592 CommonGLPI::displayStandardTab( $item = class Glpi\Socket { public $dohistory = TRUE; public $can_be_translated = FALSE; public $fields = ['id' => '', 'position' => -1, 'locations_id' => '', 'name' => '', 'socketmodels_id' => '', 'wiring_side' => '', 'itemtype' => 'Computer', 'items_id' => '', 'networkports_id' => '', 'comment' => '', 'date_mod' => '', 'date_creation' => '']; public $input = ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => '']; public $updates = []; public $oldvalues = []; public $history_blacklist = []; public $auto_message_on_action = TRUE; public $no_form_page = FALSE; public $additional_fields_for_dictionnary = []; protected $fkfield = ''; protected $searchopt = FALSE; public $taborientation = 'vertical'; public $get_item_to_display_tab = TRUE; protected $usenotepad = FALSE; public $deduplicate_queued_notifications = TRUE; public $right = NULL; protected $type = -1; protected $displaylist = TRUE; public $showdebug = FALSE; protected $last_clone_index = NULL }, $tab = 'Glpi\Socket$main', $withtemplate = '', $options = ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => ['_from_itemtype' => 'NetworkEquipment', '_from_items_id' => '1']] ) ...\common.tabs.php:111 3 0.1097 2957768 Glpi\Socket->showForm( $ID = '', $options = ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => ['_from_itemtype' => 'NetworkEquipment', '_from_items_id' => '1'], 'withtemplate' => ''] ) ...\CommonGLPI.php:657

( ! ) Deprecated: Called method is deprecated in F:\Profile\User\Downloads\add_several_socket_from_item.657561f.tar.gz\add_several_socket_from_item.657561f\glpi\src\Toolbox.php on line 550

Call Stack

Time Memory Function Location

1 0.0002 377864 {main}( ) ...\common.tabs.php:0 2 0.1097 2956592 CommonGLPI::displayStandardTab( $item = class Glpi\Socket { public $dohistory = TRUE; public $can_be_translated = FALSE; public $fields = ['id' => '', 'position' => -1, 'locations_id' => '', 'name' => '', 'socketmodels_id' => '', 'wiring_side' => '', 'itemtype' => 'Computer', 'items_id' => '', 'networkports_id' => '', 'comment' => '', 'date_mod' => '', 'date_creation' => '']; public $input = ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => '']; public $updates = []; public $oldvalues = []; public $history_blacklist = []; public $auto_message_on_action = TRUE; public $no_form_page = FALSE; public $additional_fields_for_dictionnary = []; protected $fkfield = ''; protected $searchopt = FALSE; public $taborientation = 'vertical'; public $get_item_to_display_tab = TRUE; protected $usenotepad = FALSE; public $deduplicate_queued_notifications = TRUE; public $right = NULL; protected $type = -1; protected $displaylist = TRUE; public $showdebug = FALSE; protected $last_clone_index = NULL }, $tab = 'Glpi\Socket$main', $withtemplate = '', $options = ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => ['_from_itemtype' => 'NetworkEquipment', '_from_items_id' => '1']] ) ...\common.tabs.php:111 3 0.1097 2957768 Glpi\Socket->showForm( $ID = '', $options = ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => ['_from_itemtype' => 'NetworkEquipment', '_from_items_id' => '1'], 'withtemplate' => ''] ) ...\CommonGLPI.php:657 4 0.1417 3052328 Glpi\Application\View\TemplateRenderer->display( $template = 'pages/assets/socket.html.twig', $variables = ['item' => class Glpi\Socket { public $dohistory = TRUE; public $can_be_translated = FALSE; public $fields = [...]; public $input = [...]; public $updates = [...]; public $oldvalues = [...]; public $history_blacklist = [...]; public $auto_message_on_action = TRUE; public $no_form_page = FALSE; public $additional_fields_for_dictionnary = [...]; protected $fkfield = ''; protected $searchopt = FALSE; public $taborientation = 'vertical'; public $get_item_to_display_tab = TRUE; protected $usenotepad = FALSE; public $deduplicate_queued_notifications = TRUE; public $right = NULL; protected $type = -1; protected $displaylist = TRUE; public $showdebug = FALSE; protected $last_clone_index = NULL }, 'params' => ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => '']] ) ...\Socket.php:214 5 0.1703 3696016 Twig\TemplateWrapper->display( $context = ['item' => class Glpi\Socket { public $dohistory = TRUE; public $can_be_translated = FALSE; public $fields = [...]; public $input = [...]; public $updates = [...]; public $oldvalues = [...]; public $history_blacklist = [...]; public $auto_message_on_action = TRUE; public $no_form_page = FALSE; public $additional_fields_for_dictionnary = [...]; protected $fkfield = ''; protected $searchopt = FALSE; public $taborientation = 'vertical'; public $get_item_to_display_tab = TRUE; protected $usenotepad = FALSE; public $deduplicate_queued_notifications = TRUE; public $right = NULL; protected $type = -1; protected $displaylist = TRUE; public $showdebug = FALSE; protected $last_clone_index = NULL }, 'params' => ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => '']] ) ...\TemplateRenderer.php:179 6 0.1703 3696016 __TwigTemplate_a2f1081340b2d68e3d69b898d1a986a4248ebefb2d6300a27b2597860c02fcff->display( $context = ['item' => class Glpi\Socket { public $dohistory = TRUE; public $can_be_translated = FALSE; public $fields = [...]; public $input = [...]; public $updates = [...]; public $oldvalues = [...]; public $history_blacklist = [...]; public $auto_message_on_action = TRUE; public $no_form_page = FALSE; public $additional_fields_for_dictionnary = [...]; protected $fkfield = ''; protected $searchopt = FALSE; public $taborientation = 'vertical'; public $get_item_to_display_tab = TRUE; protected $usenotepad = FALSE; public $deduplicate_queued_notifications = TRUE; public $right = NULL; protected $type = -1; protected $displaylist = TRUE; public $showdebug = FALSE; protected $last_clone_index = NULL }, 'params' => ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => '']], $blocks = [] ) ...\TemplateWrapper.php:47 7 0.1703 3696392 __TwigTemplate_a2f1081340b2d68e3d69b898d1a986a4248ebefb2d6300a27b2597860c02fcff->displayWithErrorHandling( $context = ['item' => class Glpi\Socket { public $dohistory = TRUE; public $can_be_translated = FALSE; public $fields = [...]; public $input = [...]; public $updates = [...]; public $oldvalues = [...]; public $history_blacklist = [...]; public $auto_message_on_action = TRUE; public $no_form_page = FALSE; public $additional_fields_for_dictionnary = [...]; protected $fkfield = ''; protected $searchopt = FALSE; public $taborientation = 'vertical'; public $get_item_to_display_tab = TRUE; protected $usenotepad = FALSE; public $deduplicate_queued_notifications = TRUE; public $right = NULL; protected $type = -1; protected $displaylist = TRUE; public $showdebug = FALSE; protected $last_clone_index = NULL }, 'params' => ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => ''], '_post' => [], '_get' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'sort' => '', 'order' => '', 'withtemplate' => ''], '_request' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...]]], $blocks = ['more_fields' => [0 => class __TwigTemplate_a2f1081340b2d68e3d69b898d1a986a4248ebefb2d6300a27b2597860c02fcff { ... }, 1 => 'block_more_fields']] ) ...\Template.php:367 8 0.1703 3696392 __TwigTemplate_a2f1081340b2d68e3d69b898d1a986a4248ebefb2d6300a27b2597860c02fcff->doDisplay( $context = ['item' => class Glpi\Socket { public $dohistory = TRUE; public $can_be_translated = FALSE; public $fields = [...]; public $input = [...]; public $updates = [...]; public $oldvalues = [...]; public $history_blacklist = [...]; public $auto_message_on_action = TRUE; public $no_form_page = FALSE; public $additional_fields_for_dictionnary = [...]; protected $fkfield = ''; protected $searchopt = FALSE; public $taborientation = 'vertical'; public $get_item_to_display_tab = TRUE; protected $usenotepad = FALSE; public $deduplicate_queued_notifications = TRUE; public $right = NULL; protected $type = -1; protected $displaylist = TRUE; public $showdebug = FALSE; protected $last_clone_index = NULL }, 'params' => ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => ''], '_post' => [], '_get' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'sort' => '', 'order' => '', 'withtemplate' => ''], '_request' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...]]], $blocks = ['more_fields' => [0 => class __TwigTemplate_a2f1081340b2d68e3d69b898d1a986a4248ebefb2d6300a27b2597860c02fcff { ... }, 1 => 'block_more_fields']] ) ...\Template.php:394 9 0.1713 3706664 __TwigTemplate_9bda0aaaee2f164eff6e878237571404d2733c8b3c017036471d085eed70e06f->display( $context = ['item' => class Glpi\Socket { public $dohistory = TRUE; public $can_be_translated = FALSE; public $fields = [...]; public $input = [...]; public $updates = [...]; public $oldvalues = [...]; public $history_blacklist = [...]; public $auto_message_on_action = TRUE; public $no_form_page = FALSE; public $additional_fields_for_dictionnary = [...]; protected $fkfield = ''; protected $searchopt = FALSE; public $taborientation = 'vertical'; public $get_item_to_display_tab = TRUE; protected $usenotepad = FALSE; public $deduplicate_queued_notifications = TRUE; public $right = NULL; protected $type = -1; protected $displaylist = TRUE; public $showdebug = FALSE; protected $last_clone_index = NULL }, 'params' => ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => ''], '_post' => [], '_get' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'sort' => '', 'order' => '', 'withtemplate' => ''], '_request' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...]]], $blocks = ['more_fields' => [0 => class __TwigTemplate_a2f1081340b2d68e3d69b898d1a986a4248ebefb2d6300a27b2597860c02fcff { ... }, 1 => 'block_more_fields']] ) ...\cab33e1951939d39ba9b8864c42b54c203a0bcc907d498e44657c6c56ecd2435.php:47 10 0.1713 3707040 __TwigTemplate_9bda0aaaee2f164eff6e878237571404d2733c8b3c017036471d085eed70e06f->displayWithErrorHandling( $context = ['item' => class Glpi\Socket { public $dohistory = TRUE; public $can_be_translated = FALSE; public $fields = [...]; public $input = [...]; public $updates = [...]; public $oldvalues = [...]; public $history_blacklist = [...]; public $auto_message_on_action = TRUE; public $no_form_page = FALSE; public $additional_fields_for_dictionnary = [...]; protected $fkfield = ''; protected $searchopt = FALSE; public $taborientation = 'vertical'; public $get_item_to_display_tab = TRUE; protected $usenotepad = FALSE; public $deduplicate_queued_notifications = TRUE; public $right = NULL; protected $type = -1; protected $displaylist = TRUE; public $showdebug = FALSE; protected $last_clone_index = NULL }, 'params' => ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => ''], '_post' => [], '_get' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'sort' => '', 'order' => '', 'withtemplate' => ''], '_request' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...]]], $blocks = ['form_fields' => [0 => class __TwigTemplate_9bda0aaaee2f164eff6e878237571404d2733c8b3c017036471d085eed70e06f { ... }, 1 => 'block_form_fields'], 'more_fields' => [0 => class __TwigTemplate_a2f1081340b2d68e3d69b898d1a986a4248ebefb2d6300a27b2597860c02fcff { ... }, 1 => 'block_more_fields']] ) ...\Template.php:367 11 0.1713 3707040 __TwigTemplate_9bda0aaaee2f164eff6e878237571404d2733c8b3c017036471d085eed70e06f->doDisplay( $context = ['item' => class Glpi\Socket { public $dohistory = TRUE; public $can_be_translated = FALSE; public $fields = [...]; public $input = [...]; public $updates = [...]; public $oldvalues = [...]; public $history_blacklist = [...]; public $auto_message_on_action = TRUE; public $no_form_page = FALSE; public $additional_fields_for_dictionnary = [...]; protected $fkfield = ''; protected $searchopt = FALSE; public $taborientation = 'vertical'; public $get_item_to_display_tab = TRUE; protected $usenotepad = FALSE; public $deduplicate_queued_notifications = TRUE; public $right = NULL; protected $type = -1; protected $displaylist = TRUE; public $showdebug = FALSE; protected $last_clone_index = NULL }, 'params' => ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => ''], '_post' => [], '_get' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'sort' => '', 'order' => '', 'withtemplate' => ''], '_request' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...]]], $blocks = ['form_fields' => [0 => class __TwigTemplate_9bda0aaaee2f164eff6e878237571404d2733c8b3c017036471d085eed70e06f { ... }, 1 => 'block_form_fields'], 'more_fields' => [0 => class __TwigTemplate_a2f1081340b2d68e3d69b898d1a986a4248ebefb2d6300a27b2597860c02fcff { ... }, 1 => 'block_more_fields']] ) ...\Template.php:394 12 0.1731 3807200 __TwigTemplate_9bda0aaaee2f164eff6e878237571404d2733c8b3c017036471d085eed70e06f->displayBlock( $name = 'form_fields', $context = ['item' => class Glpi\Socket { public $dohistory = TRUE; public $can_be_translated = FALSE; public $fields = [...]; public $input = [...]; public $updates = [...]; public $oldvalues = [...]; public $history_blacklist = [...]; public $auto_message_on_action = TRUE; public $no_form_page = FALSE; public $additional_fields_for_dictionnary = [...]; protected $fkfield = ''; protected $searchopt = FALSE; public $taborientation = 'vertical'; public $get_item_to_display_tab = TRUE; protected $usenotepad = FALSE; public $deduplicate_queued_notifications = TRUE; public $right = NULL; protected $type = -1; protected $displaylist = TRUE; public $showdebug = FALSE; protected $last_clone_index = NULL }, 'params' => ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => ''], '_post' => [], '_get' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'sort' => '', 'order' => '', 'withtemplate' => ''], '_request' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...]], 'bg' => '', 'rand' => 1347159150, 'target' => '/front/socket.form.php', 'withtemplate' => '', 'item_type' => 'Glpi\Socket', 'item_has_pictures' => FALSE, 'field_options' => ['locked_fields' => [...]]], $blocks = ['form_fields' => [0 => class __TwigTemplate_9bda0aaaee2f164eff6e878237571404d2733c8b3c017036471d085eed70e06f { ... }, 1 => 'block_form_fields'], 'more_fields' => [0 => class __TwigTemplate_a2f1081340b2d68e3d69b898d1a986a4248ebefb2d6300a27b2597860c02fcff { ... }, 1 => 'block_more_fields']], $useBlocks = ???, $templateContext = ??? ) ...\0894b69370037108283b227629fbfc1fd11428833abae018bbdbf3fa783a24f2.php:99 13 0.1731 3807200 __TwigTemplate_9bda0aaaee2f164eff6e878237571404d2733c8b3c017036471d085eed70e06f->block_form_fields( $context = ['item' => class Glpi\Socket { public $dohistory = TRUE; public $can_be_translated = FALSE; public $fields = [...]; public $input = [...]; public $updates = [...]; public $oldvalues = [...]; public $history_blacklist = [...]; public $auto_message_on_action = TRUE; public $no_form_page = FALSE; public $additional_fields_for_dictionnary = [...]; protected $fkfield = ''; protected $searchopt = FALSE; public $taborientation = 'vertical'; public $get_item_to_display_tab = TRUE; protected $usenotepad = FALSE; public $deduplicate_queued_notifications = TRUE; public $right = NULL; protected $type = -1; protected $displaylist = TRUE; public $showdebug = FALSE; protected $last_clone_index = NULL }, 'params' => ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => ''], '_post' => [], '_get' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'sort' => '', 'order' => '', 'withtemplate' => ''], '_request' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...]], 'bg' => '', 'rand' => 1347159150, 'target' => '/front/socket.form.php', 'withtemplate' => '', 'item_type' => 'Glpi\Socket', 'item_has_pictures' => FALSE, 'field_options' => ['locked_fields' => [...]]], $blocks = ['form_fields' => [0 => class __TwigTemplate_9bda0aaaee2f164eff6e878237571404d2733c8b3c017036471d085eed70e06f { ... }, 1 => 'block_form_fields'], 'more_fields' => [0 => class __TwigTemplate_a2f1081340b2d68e3d69b898d1a986a4248ebefb2d6300a27b2597860c02fcff { ... }, 1 => 'block_more_fields']] ) ...\Template.php:171 14 0.1790 3834608 __TwigTemplate_9bda0aaaee2f164eff6e878237571404d2733c8b3c017036471d085eed70e06f->displayBlock( $name = 'more_fields', $context = ['item' => class Glpi\Socket { public $dohistory = TRUE; public $can_be_translated = FALSE; public $fields = [...]; public $input = [...]; public $updates = [...]; public $oldvalues = [...]; public $history_blacklist = [...]; public $auto_message_on_action = TRUE; public $no_form_page = FALSE; public $additional_fields_for_dictionnary = [...]; protected $fkfield = ''; protected $searchopt = FALSE; public $taborientation = 'vertical'; public $get_item_to_display_tab = TRUE; protected $usenotepad = FALSE; public $deduplicate_queued_notifications = TRUE; public $right = NULL; protected $type = -1; protected $displaylist = TRUE; public $showdebug = FALSE; protected $last_clone_index = NULL }, 'params' => ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => ''], '_post' => [], '_get' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'sort' => '', 'order' => '', 'withtemplate' => ''], '_request' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...]], 'bg' => '', 'rand' => 1347159150, 'target' => '/front/socket.form.php', 'withtemplate' => '', 'item_type' => 'Glpi\Socket', 'item_has_pictures' => FALSE, 'field_options' => ['locked_fields' => [...]], 'fk' => 'sockets_id', 'dc_breadcrumbs' => class Twig\Markup { private $content = ' '; private $charset = 'UTF-8' }, 'type_itemtype' => NULL, 'type_fk' => NULL, 'model_itemtype' => 'Glpi\SocketModel', 'model_fk' => 'socketmodels_id'], $blocks = ['form_fields' => [0 => class __TwigTemplate_9bda0aaaee2f164eff6e878237571404d2733c8b3c017036471d085eed70e06f { ... }, 1 => 'block_form_fields'], 'more_fields' => [0 => class __TwigTemplate_a2f1081340b2d68e3d69b898d1a986a4248ebefb2d6300a27b2597860c02fcff { ... }, 1 => 'block_more_fields']], $useBlocks = ???, $templateContext = ??? ) ...\0894b69370037108283b227629fbfc1fd11428833abae018bbdbf3fa783a24f2.php:1061 15 0.1790 3834608 __TwigTemplate_a2f1081340b2d68e3d69b898d1a986a4248ebefb2d6300a27b2597860c02fcff->block_more_fields( $context = ['item' => class Glpi\Socket { public $dohistory = TRUE; public $can_be_translated = FALSE; public $fields = [...]; public $input = [...]; public $updates = [...]; public $oldvalues = [...]; public $history_blacklist = [...]; public $auto_message_on_action = TRUE; public $no_form_page = FALSE; public $additional_fields_for_dictionnary = [...]; protected $fkfield = ''; protected $searchopt = FALSE; public $taborientation = 'vertical'; public $get_item_to_display_tab = TRUE; protected $usenotepad = FALSE; public $deduplicate_queued_notifications = TRUE; public $right = NULL; protected $type = -1; protected $displaylist = TRUE; public $showdebug = FALSE; protected $last_clone_index = NULL }, 'params' => ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => ''], '_post' => [], '_get' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'sort' => '', 'order' => '', 'withtemplate' => ''], '_request' => ['_target' => '/front/socket.form.php', '_itemtype' => 'Glpi\Socket', '_glpi_tab' => 'Glpi\\Socket$main', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...]], 'bg' => '', 'rand' => 1347159150, 'target' => '/front/socket.form.php', 'withtemplate' => '', 'item_type' => 'Glpi\Socket', 'item_has_pictures' => FALSE, 'field_options' => ['locked_fields' => [...]], 'fk' => 'sockets_id', 'dc_breadcrumbs' => class Twig\Markup { private $content = ' '; private $charset = 'UTF-8' }, 'type_itemtype' => NULL, 'type_fk' => NULL, 'model_itemtype' => 'Glpi\SocketModel', 'model_fk' => 'socketmodels_id'], $blocks = ['form_fields' => [0 => class __TwigTemplate_9bda0aaaee2f164eff6e878237571404d2733c8b3c017036471d085eed70e06f { ... }, 1 => 'block_form_fields'], 'more_fields' => [0 => class __TwigTemplate_a2f1081340b2d68e3d69b898d1a986a4248ebefb2d6300a27b2597860c02fcff { ... }, 1 => 'block_more_fields']] ) ...\Template.php:171 16 0.1793 3861536 Glpi\Application\View\Extension\PhpExtension->call( $callable = 'Glpi\Socket::showNetworkPortForm', $parameters = [0 => 'Computer', 1 => '', 2 => '', 3 => ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => '']] ) ...\cab33e1951939d39ba9b8864c42b54c203a0bcc907d498e44657c6c56ecd2435.php:126 17 0.1793 3861536 call_user_func_array:{F:\Profile\User\Downloads\add_several_socket_from_item.657561f.tar.gz\add_several_socket_from_item.657561f\glpi\src\Application\View\Extension\PhpExtension.php:88}( $callback = 'Glpi\Socket::showNetworkPortForm', $args = [0 => 'Computer', 1 => '', 2 => '', 3 => ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => [...], 'withtemplate' => '']] ) ...\PhpExtension.php:88 18 0.1793 3861608 Glpi\Socket::showNetworkPortForm( $itemtype = 'Computer', $items_id = '', $networkports_id = '', $options = ['_target' => '/front/socket.form.php', 'id' => '', 'items_id' => '', 'itemtype' => 'Computer', 'several' => '1', '_add_fromitem' => ['_from_itemtype' => 'NetworkEquipment', '_from_items_id' => '1'], 'withtemplate' => ''] ) ...\PhpExtension.php:88 19 4.1698 4070576 CommonDBTM::dropdown( $options = ['name' => 'items_id', 'value' => '1', 'display_emptychoice' => TRUE, 'display_dc_position' => TRUE, 'rand' => 828883563] ) ...\Socket.php:142 20 4.1698 4070576 Dropdown::show( $itemtype = 'NetworkEquipment', $options = ['name' => 'items_id', 'value' => '1', 'display_emptychoice' => TRUE, 'display_dc_position' => TRUE, 'rand' => 828883563] ) ...\CommonDBTM.php:3999 21 4.1726 4090536 NetworkEquipment->isRackPart( $itemtype = 'NetworkEquipment', $items_id = '1', $getobj = TRUE ) ...\Dropdown.php:348 22 4.1726 4090536 Toolbox::deprecated( $message = ??? ) ...\DCBreadcrumb.php:177 23 4.1726 4090536 trigger_error( $message = 'Called method is deprecated', $error_level = 16384 ) ...\Toolbox.php:550

TestSwitch

KongNan avatar Sep 09 '22 11:09 KongNan

@KongNan

1, When I use the from and to of the socket in reverse order (from 4 to 1), no content is added, which can be considered normal.

This is by design. The "for"-method is used, which increments the given value by 1 and stops when the "to"-value is reached. Since 4 is already greater than 1, the incrementation is not going to be executed.

2, Port has "add multiple ports" and Socket has "add multiple sockets", users may feel confused. Of course, this is not the problem of the PR.

This question has been answered here: https://github.com/glpi-project/glpi/issues/10720 A socket is the physical representation while a port is the logical representation. You can think of a port as an interface, while a socket is the component where you plug the cable in. I had struggled there too :)

  1. As before, I still get some warning messages: ( ! ) Warning: Undefined array key "from_items_id" in F:\Profile\User\Downloads\add_several_socket_from_item.657561f.tar.gz\add_several_socket_from_item.657561f\glpi\src\Socket.php on line 209

@stonebuzz, to avoid this message, inf file "src/Socket.php" the line 209 must corrected as follows:

// /src/Socket.php
... line 209
$item->getFromDB($options['_add_fromitem']['_from_items_id']);
...

rbrannath avatar Sep 11 '22 08:09 rbrannath

Hi @KongNan can you do a functional review of current PR?

Best regards

Hi @stonebuzz, I have done a functional review as well. Here is my checklist:

  1. add single socket via asset -> passed
  2. add multiple sockets via asset -> passed
  3. change socket connected to an asset -> passed
  4. add multiple sockets via asset with "create both" -> passed
  5. add single socket via location -> passed
  6. add single socket via location, but select no itemtype -> failed (socket is created, but cannot be edited because of PHP-Error)
  7. add multiple sockets via location, but select no itemtype -> failed (socket is created, but cannot be edited because of PHP-Error)

This is the PHP-Error for tests 6 and 7: Uncaught Exception RuntimeException: Unable to retrieve itemtype in /vagrant/src/Socket.php at line 200

This exception is shown by design, when no itemtype is given. To avoid this, the creation of the socket should be not performed, when there is not itemtype selected OR (looking at https://github.com/glpi-project/glpi/pull/11895#issuecomment-1242906066) the exception should not be thrown, when it is a "location only" socket.

rbrannath avatar Sep 11 '22 08:09 rbrannath

Hi @KongNan , @rbrannath

can you try this new build https://github.com/stonebuzz/glpi/actions/runs/3036830293

Best regards

stonebuzz avatar Sep 12 '22 11:09 stonebuzz