File tree Expand file tree Collapse file tree
openwisp_controller/config
templates/admin/device_group Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,10 +105,7 @@ django.jQuery(function ($) {
105105 url . searchParams . set ( "backend" , backend ) ;
106106 }
107107 if ( isDeviceGroup ( ) && ! $ ( ".add-form" ) . length ) {
108- // Get the group id from the URL
109- // TODO: This is fragile, consider using a more robust way to get the group id.
110- var pathParts = window . location . pathname . split ( "/" ) ;
111- url . searchParams . set ( "group_id" , pathParts [ pathParts . length - 3 ] ) ;
108+ url . searchParams . set ( "group_id" , window . _deviceGroupId ) ;
112109 } else if ( $ ( 'input[name="config-0-id"]' ) . length ) {
113110 url . searchParams . set ( "config_id" , $ ( 'input[name="config-0-id"]' ) . val ( ) ) ;
114111 }
Original file line number Diff line number Diff line change 1313 $ ( document ) . ready ( function ( ) {
1414 window . _relevantTemplateUrl = "{{ relevant_template_url | safe }}" ;
1515 window . _deviceGroup = true ;
16+ window . _deviceGroupId = "{{ original.pk }}" ;
1617 window . bindDefaultTemplateLoading ( ) ;
1718 } )
1819 } ) ( django . jQuery ) ;
You can’t perform that action at this time.
0 commit comments