Update Qt interface for vlan.
According with changes in the html-interface.
This commit is contained in:
parent
8d147924f7
commit
35960685e6
@ -130,7 +130,7 @@
|
||||
(begin
|
||||
(form-popup "/net-eth/advanced" 'name name)
|
||||
(form-update-enum "name" (append
|
||||
(woo-list "/net-eth/avail_ifaces")
|
||||
(woo-list "/net-eth/avail_ifaces")))
|
||||
(read-interface name ipv)
|
||||
(form-update-value "prev_name" (or (form-value "name") ""))))))
|
||||
|
||||
@ -251,7 +251,9 @@
|
||||
|
||||
;;
|
||||
(button text (_ "Wireless settings...") name "wireless" align "right" visibility #f)
|
||||
(button text (_ "Advanced...") name "advanced" align "right"))
|
||||
(hbox align "right"
|
||||
(button text (_ "Advanced...") name "advanced" align "right")
|
||||
(button text (_ "Vlan...") name "vlan" align "right")))
|
||||
|
||||
;;
|
||||
(or (global 'frame:next)
|
||||
|
@ -13,222 +13,144 @@
|
||||
(define *debug* #f)
|
||||
(define (dmsg msg . args)
|
||||
(if *debug*
|
||||
(format #t "[ajax, net-eth-advanced]: ~S ~S\n" msg args)))
|
||||
(format #t "[ajax, net-eth-vlan]: ~S ~S\n" msg args)))
|
||||
|
||||
;;; Functions
|
||||
(define (ui-read)
|
||||
(catch/message
|
||||
(lambda()
|
||||
(let* ((cmd (woo-read-first "/net-eth" 'name *name*))
|
||||
(has_infant_vlans (woo-get-option cmd 'has_infant_vlans #f))
|
||||
(is_bridge (woo-get-option cmd 'bridge))
|
||||
(is_etcnet (if (string-ci=? (woo-get-option cmd 'controlled) "etcnet") #t #f))
|
||||
(is_wireless (woo-get-option cmd 'wireless #f)))
|
||||
(form-update-enum "controlled" (woo-list "/net-eth/avail_controlled" 'bridge is_bridge))
|
||||
(form-update-visibility "area-vlan" (and is_etcnet (not is_wireless)))
|
||||
(form-update-visibility "area-vlan-list" (and is_etcnet has_infant_vlans))
|
||||
(form-update-visibility "area-vlan-edit" (and is_etcnet has_infant_vlans))
|
||||
(form-update-visibility "label_bridge" has_infant_vlans)
|
||||
(form-update-activity "bridge" (not has_infant_vlans))
|
||||
(form-update-activity "controlled" (not has_infant_vlans))
|
||||
(form-update-value-list '("name" "controlled" "bridge") cmd)
|
||||
|
||||
; VLAN
|
||||
(and
|
||||
has_infant_vlans
|
||||
(define (ui-read name)
|
||||
(form-update-value "iface_label" (bold name))
|
||||
(form-update-value "iface" name))
|
||||
|
||||
; FILL LISTS
|
||||
(for-each
|
||||
(lambda(lst)
|
||||
(let* ((name (car lst))
|
||||
(select_first (car (cdr lst)))
|
||||
(data (woo-list (string-append "/net-eth/" name)
|
||||
'name *name*
|
||||
'language (form-value "language"))))
|
||||
(form-update-enum name data)
|
||||
; take first, make it active
|
||||
(and
|
||||
select_first
|
||||
(pair? data)
|
||||
; select first item only for general enums, not multi-select lists
|
||||
(= (length (car data)) 5)
|
||||
(let ((xxx (woo-get-option (car data) 'name)))
|
||||
(form-update-value lst (if (string? xxx) xxx ""))))
|
||||
))
|
||||
'(("list_host_vlans_single" #f) ("list_host_vlans2" #t)))
|
||||
; FILL VLAN LIST
|
||||
(define (refresh-vlan)
|
||||
;(format #t "[net-eth/vlan] item ~S\n" (form-value "list"))
|
||||
(form-update-enum "list"
|
||||
(woo-list "/net-eth/list_host_vlans2"
|
||||
'name (form-value "iface")
|
||||
'language (form-value "language")))
|
||||
(if
|
||||
(not (form-value "list"))
|
||||
(begin
|
||||
(form-update-value "name" "")
|
||||
(form-update-value "vlan_name" "")
|
||||
(form-update-value "vlan_vid" "")
|
||||
(form-update-activity "vlan_name" #f)
|
||||
(form-update-activity "vlan_vid" #f)
|
||||
(form-update-activity "apply" #f)
|
||||
(form-update-activity "reset" #f))
|
||||
(begin
|
||||
(form-update-value "name" (form-value "list"))
|
||||
|
||||
; REBIND ACTIONS ON LISTS
|
||||
(form-bind "list_host_vlans2" "change" vlan_selected)
|
||||
; Read vlan info
|
||||
(form-update-value "vlan_name" (form-value "list"))
|
||||
(form-update-value "vlan_vid"
|
||||
(woo-get-option
|
||||
(woo-read-first "/net-eth"
|
||||
'name (form-value "list")
|
||||
'language (form-value "language"))
|
||||
'label_vlan_vid))
|
||||
|
||||
; RESET INTERFACE
|
||||
(for-each (lambda(p) (form-update-value p ""))
|
||||
'("vlan_new_name"
|
||||
"vlan_new_vid"))
|
||||
(form-update-activity "vlan_name" #t)
|
||||
(form-update-activity "vlan_vid" #t)
|
||||
(form-update-activity "apply" #t)
|
||||
(form-update-activity "reset" #t))))
|
||||
|
||||
(vlan_selected))))))
|
||||
|
||||
; REMOVE SELECTED VLAN INTERFACES
|
||||
(define (vlan-remove-selected)
|
||||
|
||||
(dmsg "vlan-remove-selected() -- enter")
|
||||
|
||||
(catch/message
|
||||
(lambda()
|
||||
(woo "vlan_remove_infants" "/net-eth"
|
||||
'name (form-value "name")
|
||||
'infants (form-value "list_host_vlans_single"))))
|
||||
|
||||
(ui-read))
|
||||
; REMOVE SELECTED VLAN INTERFACE
|
||||
(define (vlan-remove)
|
||||
(if
|
||||
(not-empty-string? (form-value "name"))
|
||||
(begin
|
||||
(woo "vlan_remove_infants" "/net-eth"
|
||||
'name (form-value "iface")
|
||||
'infants (list (form-value "name") ))
|
||||
; Update interface fields
|
||||
(form-update-value "name" "")
|
||||
(form-update-value "vlan_name" "")
|
||||
(form-update-value "vlan_vid" "")
|
||||
(form-update-activity "vlan_name" #f)
|
||||
(form-update-activity "vlan_vid" #f)
|
||||
(form-update-activity "apply" #f)
|
||||
(form-update-activity "reset" #f)
|
||||
(refresh-vlan))))
|
||||
|
||||
|
||||
; ADD NEW VLAN INTERFACE FOR SELECTED HOST
|
||||
(define (vlan-add-new)
|
||||
|
||||
(dmsg "vlan-add-new() -- enter")
|
||||
|
||||
(catch/message
|
||||
(lambda()
|
||||
(woo "vlan_add_new" "/net-eth"
|
||||
'name (form-value "name")
|
||||
'vlan_new_name (form-value "vlan_new_name")
|
||||
'vlan_new_vid (form-value "vlan_new_vid"))))
|
||||
|
||||
(ui-read))
|
||||
|
||||
|
||||
; VLAN EDIT
|
||||
(define (vlan-edit)
|
||||
|
||||
(dmsg "vlan-edit() -- enter")
|
||||
|
||||
(catch/message
|
||||
(lambda()
|
||||
(woo "vlan_edit" "/net-eth"
|
||||
'name (form-value "name")
|
||||
'vlan_old_name (form-value "list_host_vlans2")
|
||||
'vlan_new_name (form-value "vlan_new_name_edit")
|
||||
'vlan_new_vid (form-value "vlan_new_vid_edit"))))
|
||||
|
||||
(ui-read))
|
||||
|
||||
|
||||
; REACT TO SELECTED VLAN
|
||||
(define (vlan_selected)
|
||||
|
||||
(dmsg "vlan_selected() -- enter")
|
||||
|
||||
(let ((vlan (form-value "list_host_vlans2")))
|
||||
(if (not (string-null? vlan))
|
||||
(catch/message
|
||||
(lambda()
|
||||
(let* ((cmd (woo "vlan_info" "/net-eth" 'name vlan))
|
||||
(vid (woo-get-option (car cmd) 'vid))
|
||||
(host (woo-get-option (car cmd) 'host))
|
||||
(name (woo-get-option (car cmd) 'name)))
|
||||
(form-update-value "vlan_new_name_edit" name)
|
||||
(form-update-value "vlan_new_vid_edit" vid)))))))
|
||||
(define (vlan-add)
|
||||
(form-update-value "name" "")
|
||||
(form-update-value "vlan_name" "")
|
||||
(form-update-value "vlan_vid" "")
|
||||
(form-update-activity "vlan_name" #t)
|
||||
(form-update-activity "vlan_vid" #t)
|
||||
(form-update-activity "apply" #t)
|
||||
(form-update-activity "reset" #t))
|
||||
|
||||
; VLAN PARAMETERS APPLY
|
||||
(define (vlan-apply)
|
||||
;(format #t "[net-eth/vlan] ~S\n" (form-value "name"))
|
||||
(if
|
||||
(empty-string? (form-value "name"))
|
||||
(begin ; add new vlan
|
||||
;(format #t "[net-eth/vlan] vlan_add_new\n")
|
||||
(woo "vlan_add_new" "/net-eth"
|
||||
'name (form-value "iface")
|
||||
'vlan_new_name (form-value "vlan_name")
|
||||
'vlan_new_vid (form-value "vlan_vid"))
|
||||
(form-update-value "name" (form-value "vlan_name")))
|
||||
(begin ; modify existing vlan
|
||||
;(format #t "[net-eth/vlan] vlan_edit\n")
|
||||
(woo "vlan_edit" "/net-eth"
|
||||
'name (form-value "iface")
|
||||
'vlan_old_name (form-value "name")
|
||||
'vlan_new_name (form-value "vlan_name")
|
||||
'vlan_new_vid (form-value "vlan_vid"))))
|
||||
(refresh-vlan))
|
||||
|
||||
; ON VLAN CHANGE
|
||||
(define (on-vlan-change)
|
||||
(refresh-vlan))
|
||||
|
||||
(define (ui-exit)
|
||||
(document:end))
|
||||
|
||||
(define (ui-write)
|
||||
(catch/message
|
||||
(lambda()
|
||||
(woo-write "/net-eth"
|
||||
'name (form-value "name")
|
||||
'controlled (form-value "controlled")
|
||||
'bridge (form-value "bridge"))
|
||||
(ui-exit))))
|
||||
|
||||
(define (bridge-changed)
|
||||
(let* ((name (form-value "name"))
|
||||
(is_bridge (form-value "bridge"))
|
||||
(new-name (if is_bridge
|
||||
(string-append "br" name)
|
||||
(substring name 2)))
|
||||
(cmd (woo-read-first "/net-eth/controlled" 'name name 'bridge is_bridge)))
|
||||
(form-update-value "name" new-name)
|
||||
(form-update-enum "controlled" (woo-list "/net-eth/avail_controlled" 'bridge is_bridge))
|
||||
(form-update-value "controlled" (woo-get-option cmd 'controlled))))
|
||||
|
||||
;;; UI
|
||||
|
||||
width 600
|
||||
height 500
|
||||
|
||||
(hbox align "left"
|
||||
(label text (bold (_ "VLAN Configuration for Interface ")))(label name "iface_label"))
|
||||
(label name "iface" visibility #f)
|
||||
(label name "name" visibility #f)
|
||||
(button (_ "Back") name "back")
|
||||
|
||||
(separator)
|
||||
(gridbox
|
||||
columns "60;40"
|
||||
(listbox name "list" max-width 155)
|
||||
;;
|
||||
(gridbox
|
||||
columns "0;100"
|
||||
margin "10"
|
||||
|
||||
;;
|
||||
(label text (_ "Interface:") align "right")
|
||||
(label name "name")
|
||||
|
||||
;;
|
||||
(label text (_ "Network subsystem:") align "right" name "controlled")
|
||||
(combobox name "controlled")
|
||||
;;
|
||||
(label text (_ "Use interface as bridge") align "right" name "bridge")
|
||||
(hbox align "left" (checkbox name "bridge")
|
||||
(label text (_ "- remove infants to change") name "label_bridge"))
|
||||
;;
|
||||
(label colspan 2)
|
||||
|
||||
;;
|
||||
(spacer)
|
||||
(hbox align "left"
|
||||
(button (_ "OK") name "ok")
|
||||
(button (_ "Cancel") name "cancel")))
|
||||
|
||||
;;
|
||||
(vbox colspan 2 align "center" name "area-vlan"
|
||||
(separator)
|
||||
(label align "center" text (bold (_ "Add new child VLAN interface")))
|
||||
(hbox
|
||||
(label text (_ "Name for new interface:"))
|
||||
(edit name "vlan_new_name")
|
||||
(label text (_ "VLAN Name:"))
|
||||
(edit name "vlan_name")
|
||||
(label text (_ "VID (1-4095):"))
|
||||
(edit name "vlan_new_vid")
|
||||
(button (_ "Add") name "btn_vlan_add_new")
|
||||
))
|
||||
|
||||
(separator)
|
||||
|
||||
(edit name "vlan_vid")
|
||||
(spacer)
|
||||
(hbox align "right"
|
||||
(button (_ "Apply") name "apply")
|
||||
(button (_ "Reset") name "reset"))
|
||||
)
|
||||
;;
|
||||
(vbox colspan 2 align "center" name "area-vlan-list"
|
||||
(label align "center" text (bold (_ "List of infant VLAN interfaces")))
|
||||
|
||||
(document:id vlans (checklistbox name "list_host_vlans_single"))
|
||||
(vlans columns 1)
|
||||
(vlans header (vector (_ "Infant interface name -- VLAN ID")))
|
||||
|
||||
; form-update-enum
|
||||
|
||||
(button (_ "Remove selected vlans") align "center" name "btn_remove_selected_vlans"))
|
||||
|
||||
;;
|
||||
(separator)
|
||||
|
||||
;;
|
||||
(hbox colspan 2 align "center" name "area-vlan-edit"
|
||||
(combobox name "list_host_vlans2")
|
||||
(label text (_ "Rename to:"))
|
||||
(edit name "vlan_new_name_edit")
|
||||
(label text (_ "VID (1-4095):"))
|
||||
(edit name "vlan_new_vid_edit")
|
||||
(button (_ "Save") align "center" name "btn_vlan_edit"))
|
||||
|
||||
(hbox align "left"
|
||||
(button (_ "Add") name "add_vlan")
|
||||
(button (_ "Remove") name "remove_vlan")))
|
||||
|
||||
;;
|
||||
(document:root
|
||||
(when loaded
|
||||
(ui-read)
|
||||
(form-bind "bridge" "change" bridge-changed)
|
||||
(form-bind "list_host_vlans2" "change" vlan_selected)
|
||||
(form-bind "btn_remove_selected_vlans" "click" vlan-remove-selected)
|
||||
(form-bind "btn_vlan_add_new" "click" vlan-add-new)
|
||||
(form-bind "btn_vlan_edit" "click" vlan-edit)
|
||||
(form-bind "ok" "click" ui-write)
|
||||
(form-bind "cancel" "click" ui-exit)))
|
||||
(ui-read *name*)
|
||||
(form-bind "back" "click" ui-exit)
|
||||
(form-bind "list" "change" on-vlan-change)
|
||||
(form-bind "add_vlan" "click" vlan-add)
|
||||
(form-bind "remove_vlan" "click" vlan-remove)
|
||||
(form-bind "apply" "click" vlan-apply)
|
||||
(on-vlan-change)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user