From 5317a20269bd39459ca22737a35e494ca972bf88 Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Wed, 23 Dec 2015 23:23:12 +0100 Subject: haproxy-devel, small fixes for showing/hiding acl fields not applicable, fix custom action, pkg v0.36 --- config/haproxy-devel/haproxy.xml | 2 +- config/haproxy-devel/pkg/haproxy.inc | 2 +- config/haproxy-devel/pkg/haproxy_htmllist.inc | 24 +++++++++++++++++---- .../haproxy-devel/www/haproxy_listeners_edit.php | 25 +++++++++++++++++++--- 4 files changed, 44 insertions(+), 9 deletions(-) (limited to 'config') diff --git a/config/haproxy-devel/haproxy.xml b/config/haproxy-devel/haproxy.xml index a096b850..07dc53d1 100644 --- a/config/haproxy-devel/haproxy.xml +++ b/config/haproxy-devel/haproxy.xml @@ -42,7 +42,7 @@ ]]> haproxy - 0.35 + 0.36 HAProxy /pkg_edit.php?xml=haproxy_pools.php /usr/local/pkg/haproxy.inc diff --git a/config/haproxy-devel/pkg/haproxy.inc b/config/haproxy-devel/pkg/haproxy.inc index 8dce42ee..c8a225a3 100644 --- a/config/haproxy-devel/pkg/haproxy.inc +++ b/config/haproxy-devel/pkg/haproxy.inc @@ -253,7 +253,7 @@ $a_action["use_server"] = array('name' => "Use Server", 'mode' => '', 'syntax' = 'server' => array('name'=>"server",'columnheader'=>"Server",'type'=>"select",'size'=>"50",'mask'=>'server') )); // -$a_action["custom"] = array('name' => "Custom", 'mode' => '', +$a_action["custom"] = array('name' => "Custom", 'mode' => '', 'syntax' => '{customaction}', 'fields' => array( array('name'=>"customaction",'columnheader'=>"Custom action",'type'=>"textbox",'size'=>"50",'mask'=>'freetext') )); diff --git a/config/haproxy-devel/pkg/haproxy_htmllist.inc b/config/haproxy-devel/pkg/haproxy_htmllist.inc index 7eaad023..d5386fcd 100644 --- a/config/haproxy-devel/pkg/haproxy_htmllist.inc +++ b/config/haproxy-devel/pkg/haproxy_htmllist.inc @@ -42,8 +42,8 @@ class HaproxyHtmlList _field_changed(tableId, rowNr, fieldId, field) */ - private $tablename = ""; - private $fields = array(); + public $tablename = ""; + public $fields = array(); public $editmode = false; public $fields_details = null; public $keyfield = ""; @@ -269,7 +269,13 @@ class HaproxyHtmlList foreach($itemdetails as $item) { $itemname = $item['name']; $itemvalue = $value[$itemname]; - //TODO don't filter empty items, filter context un-related items through customizable function.. + if ($this->fields_details_showfieldfunction != null) { + // filter context un-related items through customizable function. + $fn = &$this->fields_details_showfieldfunction; + if ($fn($this, $itemname, $value) == false) { + continue; + } + } else if (empty($itemvalue)) { continue; } @@ -488,7 +494,10 @@ function haproxy_htmllist_js(){ subtr.appendChild(subtd); subtd = d.createElement("td"); subtd.setAttribute("class","vncell"); - subtd.innerHTML = field['description'] + "
" + fieldhtml; + if (field['description']) { + fieldhtml = field['description'] + "
" + fieldhtml; + } + subtd.innerHTML = fieldhtml; subtr.appendChild(subtd); table.appendChild(subtr); } @@ -539,6 +548,13 @@ function haproxy_htmllist_js(){ if (typeof fn === 'function'){ fn(tableId, totalrows); } + + // show/hide conditional fields if applicable using a custom function. + javascript_event = tableId + "_listitem_change"; + var fn = window[javascript_event]; + if (typeof fn === 'function'){ + fn(tableId, "toggle_details", totalrows, null); + } } function editRow(num) { var trview = document.getElementById('tr_view_' + num); diff --git a/config/haproxy-devel/www/haproxy_listeners_edit.php b/config/haproxy-devel/www/haproxy_listeners_edit.php index f26341b2..8c37332e 100644 --- a/config/haproxy-devel/www/haproxy_listeners_edit.php +++ b/config/haproxy-devel/www/haproxy_listeners_edit.php @@ -251,14 +251,33 @@ function customdrawcell_actions($object, $item, $itemvalue, $editable, $itemname $htmllist_extaddr = new HaproxyHtmlList("table_extaddr", $fields_externalAddress); $htmllist_extaddr->editmode = true; +function fields_details_showfieldfunction($items, $action, $itemname) { + if (is_array($items[$action]) && is_array($items[$action]['fields'])) { + foreach($items[$action]['fields'] as $item) { + if ($action . "" . $item['name'] == $itemname) { + return true; + } + } + } + return false; +} +function fields_acls_details_showfieldfunction($htmltable, $itemname, $values) { + $items = $htmltable->fields[1]['items']; + $action = $values['expression']; + return fields_details_showfieldfunction($items, $action, $itemname); +} $htmllist_acls = new HaproxyHtmlList("table_acls", $fields_aclSelectionList); $htmllist_acls->fields_details = $fields_acl_details; -//$htmllist_acls->editmode = true; +$htmllist_acls->fields_details_showfieldfunction = fields_acls_details_showfieldfunction; +function fields_actions_details_showfieldfunction($htmltable, $itemname, $values) { + $items = $htmltable->fields[0]['items']; + $action = $values['action']; + return fields_details_showfieldfunction($items, $action, $itemname); +} $htmllist_actions = new HaproxyHtmlList("table_actions", $fields_actions); $htmllist_actions->fields_details = $fields_actions_details; -//$htmllist_actions->keyfield = "name"; -//$htmllist_actions->editmode = true; +$htmllist_actions->fields_details_showfieldfunction = fields_actions_details_showfieldfunction; $htmllist_sslCertificates = new HaproxyHtmlList("tbl_sslCerts", $fields_sslCertificates); $htmllist_caCertificates = new HaproxyHtmlList("tbl_caCerts", $fields_caCertificates ); -- cgit v1.2.3 From af34a668b3f3816a110357dac18dfe0f769ed0ee Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Thu, 24 Dec 2015 22:09:30 +0100 Subject: haproxy-devel, move icon usage to separate file for easy changing 'themes' / prepare for 2.3 --- config/haproxy-devel/haproxy.xml | 4 ++ config/haproxy-devel/pkg/haproxy_gui.inc | 75 ++++++++++++++++++++++++++ config/haproxy-devel/pkg/haproxy_htmllist.inc | 29 +++++----- config/haproxy-devel/www/haproxy_listeners.php | 60 ++++++++++++--------- config/haproxy-devel/www/haproxy_pools.php | 37 ++++++++----- 5 files changed, 153 insertions(+), 52 deletions(-) create mode 100644 config/haproxy-devel/pkg/haproxy_gui.inc (limited to 'config') diff --git a/config/haproxy-devel/haproxy.xml b/config/haproxy-devel/haproxy.xml index 07dc53d1..68637209 100644 --- a/config/haproxy-devel/haproxy.xml +++ b/config/haproxy-devel/haproxy.xml @@ -109,6 +109,10 @@ /usr/local/www/ https://packages.pfsense.org/packages/config/haproxy-devel/www/haproxy_templates.php + + /usr/local/pkg/ + https://packages.pfsense.org/packages/config/haproxy-devel/pkg/haproxy_gui.inc + /usr/local/pkg/ https://packages.pfsense.org/packages/config/haproxy-devel/pkg/haproxy_socketinfo.inc diff --git a/config/haproxy-devel/pkg/haproxy_gui.inc b/config/haproxy-devel/pkg/haproxy_gui.inc new file mode 100644 index 00000000..5392e87a --- /dev/null +++ b/config/haproxy-devel/pkg/haproxy_gui.inc @@ -0,0 +1,75 @@ + array( + "faicon" => "fa-arrow-up", + "icon" => "icon_up.gif", + "iconsize" => 17), + 'movedown' => array( + "faicon" => "fa-arrow-down", + "icon" => "icon_down.gif", + "iconsize" => 17), + 'add' => array( + "faicon" => "fa-level-down", + "icon" => "icon_plus.gif", + "iconsize" => 17), + 'delete' => array( + "faicon" => "fa-trash", + "icon" => "icon_x.gif", + "iconsize" => 17), + 'edit' => array( + "faicon" => "fa-pencil", + "icon" => "icon_e.gif", + "iconsize" => 17), + 'clone' => array( + "faicon" => "fa-clone", + "icon" => "icon_plus.gif"), + 'acl' => array( + "faicon" => "fa-random", + "icon" => "icon_ts_rule.gif", + "iconsize" => 11), + 'cert' => array( + "faicon" => "fa-lock", + "icon" => "icon_frmfld_cert.png", + "iconsize" => 11), + 'advanced' => array( + "faicon" => "fa-cog", + "icon" => "icon_advanced.gif", + "iconsize" => 11), + 'enabled' => array( + "faicon" => "fa-check", + "icon" => "icon_pass.gif", + "iconsize" => 11), + 'disabled' => array( + "faicon" => "fa-ban", + "icon" => "icon_reject.gif", + "iconsize" => 11), + 'stats' => array( + "faicon" => "fa-tasks", + "icon" => "icon_log_s.gif", + "iconsize" => 11) +); + +global $pf_version; +$pf_version = substr(trim(file_get_contents("/etc/version")), 0, 3); + +function pf_version() { + global $pf_version; + return $pf_version; +} + +function haproxyicon($iconname, $title) { + global $g, $haproxy_icons; + $title = htmlspecialchars($title); + $title = str_replace("'", "'", $title); + + $faicon = $haproxy_icons[$iconname]["faicon"]; + if (pf_version() < "2.3") { + $icon = $haproxy_icons[$iconname]["icon"]; + $iconsize = $haproxy_icons[$iconname]["iconsize"]; + return ""; + } else { + return ""; + } + +} diff --git a/config/haproxy-devel/pkg/haproxy_htmllist.inc b/config/haproxy-devel/pkg/haproxy_htmllist.inc index d5386fcd..70a53c86 100644 --- a/config/haproxy-devel/pkg/haproxy_htmllist.inc +++ b/config/haproxy-devel/pkg/haproxy_htmllist.inc @@ -33,6 +33,7 @@ require_once("config.inc"); require_once("haproxy_utils.inc"); +require_once("haproxy_gui.inc"); class HaproxyHtmlList { @@ -193,20 +194,20 @@ class HaproxyHtmlList "; if (empty($this->noindex)) { echo ""; } echo "
- + ".haproxyicon('edit','edit entry')." - + ".haproxyicon('delete','delete entry')." - + ".haproxyicon('clone','duplicate entry')." - + ".haproxyicon('moveup','move row up')." - + ".haproxyicon('movedown','move row down')."
@@ -232,17 +233,17 @@ class HaproxyHtmlList "; if (empty($this->noindex)) { echo ""; } echo "
- + ".haproxyicon('delete','delete entry')." - + ".haproxyicon('clone','duplicate entry')." - + ".haproxyicon('moveup','move row up')." - + ".haproxyicon('movedown','move row down')."
@@ -328,7 +329,7 @@ class HaproxyHtmlList echo " - + ".haproxyicon('add','add another entry')." "; } } @@ -445,12 +446,12 @@ function haproxy_htmllist_js(){ btd.setAttribute("valign", "middle"); btd.innerHTML = '' + - '"; + '"; btr.appendChild(btd); btd = document.createElement("td"); btd.setAttribute("valign", "middle"); - btd.innerHTML = '"; + btd.innerHTML = '"; btr.appendChild(btd); @@ -458,12 +459,12 @@ function haproxy_htmllist_js(){ if (tabledefinition && tabledefinition['keyfield'] == "") { btd = document.createElement("td"); btd.setAttribute("valign", "middle"); - btd.innerHTML = '"; + btd.innerHTML = '"; btr.appendChild(btd); btd = document.createElement("td"); btd.setAttribute("valign", "middle"); - btd.innerHTML = '"; + btd.innerHTML = '"; btr.appendChild(btd); } diff --git a/config/haproxy-devel/www/haproxy_listeners.php b/config/haproxy-devel/www/haproxy_listeners.php index c7288e7d..e3dc7120 100644 --- a/config/haproxy-devel/www/haproxy_listeners.php +++ b/config/haproxy-devel/www/haproxy_listeners.php @@ -35,6 +35,7 @@ require_once("haproxy.inc"); require_once("certs.inc"); require_once("haproxy_utils.inc"); require_once("pkg_haproxy_tabs.inc"); +require_once("haproxy_gui.inc"); $changedesc = "Services: HAProxy: Frontends"; @@ -132,23 +133,24 @@ echo "
"; ?> @@ -197,9 +199,6 @@ function js_callback(req) { } ksort($a_frontend_grouped); - $img_cert = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png"; - $img_adv = "/themes/{$g['theme']}/images/icons/icon_advanced.gif"; - $img_acl = "/themes/{$g['theme']}/images/icons/icon_ts_rule.gif"; $textgray = ""; $first = true; $last_frontend_shared = false; @@ -218,13 +217,12 @@ function js_callback(req) { - - " alt="icon" /> + + " ondblclick="document.location='haproxy_listeners_edit.php?id=';"> @@ -235,11 +233,12 @@ function js_callback(req) { $acls = get_frontend_acls($frontend); $isaclset = ""; foreach ($acls as $acl) { - $isaclset .= " " . htmlspecialchars($acl['descr']); + $isaclset .= "\n" . htmlspecialchars($acl['descr']); + } + if ($isaclset) { + echo haproxyicon("acl", gettext("acl's used") . ": {$isaclset}"); } - if ($isaclset) - echo ""; - + if (get_frontend_uses_ssl($frontend)) { $cert = lookup_cert($frontend['ssloffloadcert']); $descr = htmlspecialchars($cert['descr']); @@ -252,14 +251,15 @@ function js_callback(req) { } } } - echo 'SSL offloading'; + echo haproxyicon("cert", "SSL offloading cert: {$descr}"); } $isadvset = ""; if ($frontend['advanced_bind']) $isadvset .= "Advanced bind: ".htmlspecialchars($frontend['advanced_bind'])."\r\n"; if ($frontend['advanced']) $isadvset .= "Advanced pass thru setting used\r\n"; - if ($isadvset) - echo ""; + if ($isadvset) { + echo haproxyicon("advanced", gettext("Advanced settings set") . ": {$isadvset}"); + } ?> @@ -277,7 +277,7 @@ function js_callback(req) { print "
"; print "{$addr['addr']}:{$addr['port']}"; if ($addr['ssl'] == 'yes') { - echo 'SSL'; + echo haproxyicon("cert", "SSL offloading"); } print " - - - + + +
" width="17" height="17" border="0" />" width="17" height="17" border="0" />" width="17" height="17" border="0" /> + + + + + +
@@ -342,7 +348,9 @@ function js_callback(req) { - +
" width="17" height="17" border="0" /> + +
diff --git a/config/haproxy-devel/www/haproxy_pools.php b/config/haproxy-devel/www/haproxy_pools.php index d98c7f41..ca449246 100644 --- a/config/haproxy-devel/www/haproxy_pools.php +++ b/config/haproxy-devel/www/haproxy_pools.php @@ -33,7 +33,7 @@ $shortcut_section = "haproxy"; require_once("guiconfig.inc"); require_once("haproxy.inc"); require_once("pkg_haproxy_tabs.inc"); - +require_once("haproxy_gui.inc"); if (!is_array($config['installedpackages']['haproxy']['ha_pools']['item'])) { $config['installedpackages']['haproxy']['ha_pools']['item'] = array(); @@ -97,7 +97,6 @@ haproxy_css(); "> '; + if ($pool['stats_enabled']=='yes') { + echo haproxyicon("stats", gettext("stats enabled")); } $isadvset = ""; - if ($pool['advanced']) $isadvset .= "Per server pass thru\r\n"; - if ($pool['advanced_backend']) $isadvset .= "Backend pass thru\r\n"; - if ($isadvset) - echo ""; + if ($pool['advanced']) { + $isadvset .= "Per server pass thru\r\n"; + } + if ($pool['advanced_backend']) { + $isadvset .= "Backend pass thru\r\n"; + } + if ($isadvset) { + echo haproxyicon("advanced", gettext("advanced settings set") . ": {$isadvset}"); + } ?> @@ -156,9 +160,15 @@ haproxy_css(); - - - + + +
" width="17" height="17" border="0" />" width="17" height="17" border="0" />" width="17" height="17" border="0" /> + + + + + +
@@ -173,7 +183,10 @@ haproxy_css(); - +
" width="17" height="17" border="0" /> + + +
-- cgit v1.2.3 From e4e35fcdd04ad128ab5c4a69b5459504caab5915 Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Sat, 26 Dec 2015 19:40:50 +0100 Subject: haproxy-devel, widget updated for better refresh configuration handling + prepare 2.3 --- config/haproxy-devel/pkg/haproxy_gui.inc | 20 ++++ config/haproxy-devel/www/haproxy_listeners.php | 3 +- config/haproxy-devel/www/haproxy_pools.php | 2 +- .../www/widgets/widgets/haproxy.widget.php | 128 +++++++++++---------- 4 files changed, 91 insertions(+), 62 deletions(-) (limited to 'config') diff --git a/config/haproxy-devel/pkg/haproxy_gui.inc b/config/haproxy-devel/pkg/haproxy_gui.inc index 5392e87a..8fbc0dd0 100644 --- a/config/haproxy-devel/pkg/haproxy_gui.inc +++ b/config/haproxy-devel/pkg/haproxy_gui.inc @@ -47,6 +47,26 @@ $haproxy_icons = array( 'stats' => array( "faicon" => "fa-tasks", "icon" => "icon_log_s.gif", + "iconsize" => 11), + 'stop' => array( + "faicon" => "fa-stop-circle-o", + "icon" => "icon_service_stop.gif", + "iconsize" => 17), + 'start' => array( + "faicon" => "fa-play-circle", + "icon" => "icon_service_start.gif", + "iconsize" => 17), + 'up' => array( + "faicon" => "fa-check-circle", + "icon" => "icon_interface_up.gif", + "iconsize" => 11), + 'down' => array( + "faicon" => "fa-times-circle", + "icon" => "icon_interface_down.gif", + "iconsize" => 11), + 'resolvedns' => array( + "faicon" => "fa-info ", + "icon" => "icon_log.gif", "iconsize" => 11) ); diff --git a/config/haproxy-devel/www/haproxy_listeners.php b/config/haproxy-devel/www/haproxy_listeners.php index e3dc7120..35d9ba54 100644 --- a/config/haproxy-devel/www/haproxy_listeners.php +++ b/config/haproxy-devel/www/haproxy_listeners.php @@ -86,7 +86,8 @@ if ($_GET['act'] == "del") { if (isset($a_frontend[$id])) { if (!$input_errors) { unset($a_frontend[$id]); - write_config(); + $changedesc .= " Frontend delete"; + write_config($changedesc); touch($d_haproxyconfdirty_path); } header("Location: haproxy_listeners.php"); diff --git a/config/haproxy-devel/www/haproxy_pools.php b/config/haproxy-devel/www/haproxy_pools.php index ca449246..ef1768db 100644 --- a/config/haproxy-devel/www/haproxy_pools.php +++ b/config/haproxy-devel/www/haproxy_pools.php @@ -58,7 +58,7 @@ if ($_POST) { if ($_GET['act'] == "del") { if (isset($a_pools[$_GET['id']])) { unset($a_pools[$_GET['id']]); - write_config(); + write_config("Services: HAProxy: Backend delete"); touch($d_haproxyconfdirty_path); } header("Location: haproxy_pools.php"); diff --git a/config/haproxy-devel/www/widgets/widgets/haproxy.widget.php b/config/haproxy-devel/www/widgets/widgets/haproxy.widget.php index 5d664e81..92fd9025 100644 --- a/config/haproxy-devel/www/widgets/widgets/haproxy.widget.php +++ b/config/haproxy-devel/www/widgets/widgets/haproxy.widget.php @@ -30,10 +30,15 @@ Some mods made from pfBlocker widget to make this for HAProxy on Pfsense Copyleft 2012 by jvorhees */ + +$nocsrf = true; + require_once("guiconfig.inc"); require_once("pfsense-utils.inc"); require_once("functions.inc"); require_once("haproxy_socketinfo.inc"); +require_once("haproxy_gui.inc"); + $first_time = false; if (!is_array($config["widgets"]["haproxy"])) { $first_time = true; @@ -59,7 +64,7 @@ if ($_POST) { foreach($simplefields as $fieldname) $a_config[$fieldname] = $_POST[$fieldname]; - write_config("Updated traffic graph settings via dashboard."); + write_config("Services: HAProxy: Widget: Updated settings via dashboard."); header("Location: /"); exit(0); } @@ -77,13 +82,13 @@ $show_frontends = $a_config['haproxy_widget_showfrontends']=='yes'; $show_clients = $a_config['haproxy_widget_showclients']=='yes'; $show_clients_traffic = $a_config['haproxy_widget_showclienttraffic']=='yes'; -$out=""; -$in=""; -$running=""; -$stopped=""; -$log=""; -$start=""; -$stop=""; +$out = haproxyicon("down", ""); +$in = haproxyicon("up", ""); +$running = haproxyicon("enabled", ""); +$stopped = haproxyicon("disabled", ""); +$log = haproxyicon("resolvedns", ""); +$start = haproxyicon("start","Enable this backend/server"); +$stop = haproxyicon("stop","Disable this backend/server"); $clients=array(); $clientstraffic=array(); @@ -98,35 +103,11 @@ if ($show_clients == "YES") { } if (!$getupdatestatus) { ?> - -
+
"; #Frontends if ($show_frontends == "YES") { print "FrontEnd(s)"; @@ -236,7 +217,17 @@ if (!$getupdatestatus) { echo "
"; ?> - + - '; +} else { + echo '