55'require rpc' ;
66'require ui' ;
77'require poll' ;
8+ 'require qmodem.modem_cfg as modemCfg' ;
89
910var callSystemBoard = rpc . declare ( {
1011 object : 'system' ,
@@ -51,6 +52,11 @@ var callGetTtyPorts = rpc.declare({
5152 method : 'get_tty_ports'
5253} ) ;
5354
55+ var callGetAvailableDevices = rpc . declare ( {
56+ object : 'qmodem' ,
57+ method : 'get_available_devices'
58+ } ) ;
59+
5460return view . extend ( {
5561 load : function ( ) {
5662 return Promise . all ( [
@@ -60,13 +66,15 @@ return view.extend({
6066 callGetUsbDevices ( ) ,
6167 callGetLeds ( ) ,
6268 callGetNetworkInterfaces ( ) ,
63- callGetTtyPorts ( )
69+ callGetTtyPorts ( ) ,
70+ callGetAvailableDevices ( )
6471 ] ) . then ( L . bind ( function ( results ) {
6572 this . pcieDevices = results [ 2 ] && results [ 2 ] . devices ? results [ 2 ] . devices : [ ] ;
6673 this . usbDevices = results [ 3 ] && results [ 3 ] . devices ? results [ 3 ] . devices : [ ] ;
6774 this . leds = results [ 4 ] && results [ 4 ] . leds ? results [ 4 ] . leds : [ ] ;
6875 this . networkInterfaces = results [ 5 ] && results [ 5 ] . interfaces ? results [ 5 ] . interfaces : [ ] ;
6976 this . ttyPorts = results [ 6 ] && results [ 6 ] . ports ? results [ 6 ] . ports : [ ] ;
77+ this . availableDevices = results [ 7 ] && results [ 7 ] . devices ? results [ 7 ] . devices : { } ;
7078 return results ;
7179 } , this ) ) ;
7280 } ,
@@ -185,30 +193,92 @@ return view.extend({
185193
186194 // Modem Configuration (Device Settings Only)
187195 s = m . section ( form . GridSection , 'modem-device' , _ ( 'Modem Devices' ) ) ;
188- s . addremove = true ;
189- s . anonymous = false ;
196+ s . anonymous = true ;
190197 s . sortable = true ;
191198 s . modaltitle = L . bind ( function ( section_id ) {
192199 var name = uci . get ( 'qmodem' , section_id , 'name' ) ;
193200 return _ ( 'Modem Device' ) + ': ' + ( name || section_id ) ;
194201 } , this ) ;
195202
203+ // Use available devices from RPC call
204+ var availableDevices = this . availableDevices || { } ;
205+
206+ // Custom add handler
207+ s . addremove = true ;
208+ s . handleAdd = function ( ev , section_id ) {
209+ var deviceKeys = Object . keys ( availableDevices ) ;
210+ if ( deviceKeys . length === 0 ) {
211+ ui . addNotification ( null , E ( 'p' , _ ( 'No devices available. Please scan for devices first.' ) ) , 'warning' ) ;
212+ return ;
213+ }
214+
215+ var selectList = deviceKeys . map ( function ( key ) {
216+ return E ( 'option' , { value : key } , availableDevices [ key ] . label ) ;
217+ } ) ;
218+
219+ ui . showModal ( _ ( 'Add Modem Device' ) , [
220+ E ( 'p' , _ ( 'Select a device to configure:' ) ) ,
221+ E ( 'div' , { 'class' : 'cbi-section' } , [
222+ E ( 'label' , { 'class' : 'cbi-value-title' } , _ ( 'Available Devices' ) ) ,
223+ E ( 'select' , { 'id' : 'device-select' , 'class' : 'cbi-input-select' } , selectList )
224+ ] ) ,
225+ E ( 'div' , { 'class' : 'right' } , [
226+ E ( 'button' , {
227+ 'class' : 'btn cbi-button-neutral' ,
228+ 'click' : ui . hideModal
229+ } , _ ( 'Cancel' ) ) ,
230+ E ( 'button' , {
231+ 'class' : 'btn cbi-button-positive' ,
232+ 'click' : L . bind ( function ( ) {
233+ var select = document . getElementById ( 'device-select' ) ;
234+ var selectedKey = select . value ;
235+ var deviceInfo = availableDevices [ selectedKey ] ;
236+
237+ // Create new section with selected device name
238+ var sid = uci . add ( 'qmodem' , 'modem-device' , selectedKey ) ;
239+
240+ // Set type and path automatically
241+ uci . set ( 'qmodem' , sid , 'data_interface' , deviceInfo . type ) ;
242+ uci . set ( 'qmodem' , sid , 'path' , deviceInfo . path ) ;
243+
244+ ui . hideModal ( ) ;
245+ m . save ( ) . then ( function ( ) {
246+ window . location . reload ( ) ;
247+ } ) ;
248+ } , this )
249+ } , _ ( 'Add' ) )
250+ ] )
251+ ] ) ;
252+ } ;
253+
196254 o = s . option ( form . Flag , 'enabled' , _ ( 'Enabled' ) ) ;
197255 o . default = '1' ;
198256 o . editable = true ;
257+ o . modalonly = true ;
258+
259+ o = s . option ( form . DummyValue , 'data_interface' , _ ( 'Type' ) ) ;
260+ o . editable = true ;
261+ o . cfgvalue = function ( section_id ) {
262+ var type = uci . get ( 'qmodem' , section_id , 'data_interface' ) || '-' ;
263+ return type . toUpperCase ( ) ;
264+ } ;
199265
200266 o = s . option ( form . Flag , 'soft_reboot' , _ ( 'Soft Reboot' ) ) ;
201267 o . description = _ ( 'enable modem soft reboot' ) ;
202268 o . default = '0' ;
203269 o . rmempty = false ;
204270 o . modalonly = true ;
205271
206- o = s . option ( form . Value , 'name' , _ ( 'Model Name' ) ) ;
207- o . placeholder = _ ( 'e.g.' ) + ' RG500Q' ;
208- o . rmempty = false ; o = s . option ( form . Value , 'alias' , _ ( 'Alias' ) ) ;
209- o . placeholder = _ ( 'e.g.' ) + ' Modem1' ; o = s . option ( form . Value , 'path' , _ ( 'Device Path' ) ) ;
272+ o = s . option ( form . Value , 'name' , _ ( 'Model Name' ) ) ;
273+ o . placeholder = _ ( 'e.g.' ) + ' RG500Q' ;
274+ o . rmempty = false ; o = s . option ( form . Value , 'alias' , _ ( 'Alias' ) ) ;
275+ o . placeholder = _ ( 'e.g.' ) + ' Modem1' ;
276+ o . editable = true ;
277+
278+ o = s . option ( form . Value , 'path' , _ ( 'Device Path' ) ) ;
210279 o . placeholder = _ ( 'e.g.' ) + ' /sys/bus/usb/devices/1-1' ;
211- o . rmempty = false ; o = s . option ( form . Value , 'at_port' , _ ( 'AT Port' ) ) ;
280+ o . rmempty = false ;
281+ o . readonly = true ; o = s . option ( form . Value , 'at_port' , _ ( 'AT Port' ) ) ;
212282 o . placeholder = _ ( 'e.g.' ) + ' /dev/ttyUSB2' ;
213283 o . rmempty = false ;
214284 if ( this . ttyPorts && this . ttyPorts . length > 0 ) {
@@ -221,14 +291,68 @@ return view.extend({
221291 this . ttyPorts . forEach ( function ( port ) {
222292 o . value ( port . id , port . label ) ;
223293 } ) ;
224- } o = s . option ( form . Value , 'override_at_port' , _ ( 'Override AT Port' ) ) ;
294+ } o = s . option ( form . Value , 'override_at_port' , _ ( 'Override AT Port' ) ) ;
225295 o . placeholder = _ ( 'e.g.' ) + ' /dev/ttyUSB3' ;
226296 if ( this . ttyPorts && this . ttyPorts . length > 0 ) {
227297 this . ttyPorts . forEach ( function ( port ) {
228298 o . value ( port . id , port . label ) ;
229299 } ) ;
230300 } o = s . option ( form . Flag , 'use_ubus' , _ ( 'Use Ubus AT Daemon' ) ) ;
231301 o . default = '0' ;
302+
303+
304+ // Additional modem configuration (modal only)
305+ //vendor
306+ o = s . option ( form . ListValue , 'vendor' , _ ( 'Vendor' ) ) ;
307+ o . modalonly = true ;
308+ o . optional = true ;
309+ for ( var key in modemCfg . manufacturers ) {
310+ o . value ( key , modemCfg . manufacturers [ key ] ) ;
311+ }
312+
313+ o = s . option ( form . ListValue , 'platform' , _ ( 'Platform' ) ) ;
314+ o . modalonly = true ;
315+ o . optional = true ;
316+ for ( var key in modemCfg . platforms ) {
317+ o . value ( key , modemCfg . platforms [ key ] ) ;
318+ }
319+
320+ o = s . option ( form . DynamicList , 'modes' , _ ( 'Supported Modes' ) ) ;
321+ o . description = _ ( 'Supported driver modes (e.g., RNDIS/NCM/QMI/MBIM/ETH/PPP)' ) ;
322+ o . modalonly = true ;
323+ o . optional = true ;
324+ for ( var key in modemCfg . modes ) {
325+ o . value ( key , modemCfg . modes [ key ] ) ;
326+ }
327+
328+ o = s . option ( form . DynamicList , 'disabled_features' , _ ( 'Disabled Features' ) ) ;
329+ o . description = _ ( 'Select features to disable for this modem.' ) ;
330+ o . modalonly = true ;
331+ o . optional = true ;
332+ for ( var key in modemCfg . disabled_features ) {
333+ o . value ( key , modemCfg . disabled_features [ key ] ) ;
334+ }
335+
336+ o = s . option ( form . Value , 'wcdma_band' , _ ( 'WCDMA Band' ) ) ;
337+ o . placeholder = _ ( 'e.g.' ) + ' 1/2/5/8' ;
338+ o . modalonly = true ;
339+ o . optional = true ;
340+
341+ o = s . option ( form . Value , 'lte_band' , _ ( 'LTE Band' ) ) ;
342+ o . placeholder = _ ( 'e.g.' ) + ' 1/3/5/7/8/20' ;
343+ o . modalonly = true ;
344+ o . optional = true ;
345+
346+ o = s . option ( form . Value , 'nsa_band' , _ ( 'NSA Band' ) ) ;
347+ o . placeholder = _ ( 'e.g.' ) + ' 41/78' ;
348+ o . modalonly = true ;
349+ o . optional = true ;
350+
351+ o = s . option ( form . Value , 'sa_band' , _ ( 'SA Band' ) ) ;
352+ o . placeholder = _ ( 'e.g.' ) + ' 78/79' ;
353+ o . modalonly = true ;
354+ o . optional = true ;
355+
232356 // ===========================================
233357 // Modem Slot Configuration
234358 // ===========================================
0 commit comments