Merge branch '761-pandora-ux-widget-dev' into 'develop'

761 pandora ux widget dev

See merge request !414
This commit is contained in:
vgilc 2017-05-17 17:39:52 +02:00
commit 8be3e434c8
3 changed files with 235 additions and 12 deletions

View File

@ -1640,20 +1640,12 @@ function ui_pagination ($count, $url = false, $offset = 0,
}
$number_of_pages = ceil($count / $pagination);
//~ html_debug_print('number_of_pages');
//~ html_debug_print($number_of_pages);
$actual_page = floor($offset / $pagination);
//~ html_debug_print('actual_page');
//~ html_debug_print($actual_page);
$ini_page = floor($actual_page / $block_limit) * $block_limit;
//~ html_debug_print('ini_page');
//~ html_debug_print($ini_page);
$end_page = $ini_page + $block_limit - 1;
if ($end_page > $number_of_pages) {
$end_page = $number_of_pages - 1;
}
//~ html_debug_print('end_page');
//~ html_debug_print($end_page);
$output = "<div class='pagination $other_class'>";
@ -2910,6 +2902,11 @@ function ui_print_agent_autocomplete_input($parameters) {
$input_id_server_value = $parameters['input_id_server_value'];
}
$from_ux_transaction = ''; //Default value
if (isset($parameters['from_ux'])) {
$from_ux_transaction = $parameters['from_ux'];
}
$metaconsole_enabled = false; //Default value
if (isset($parameters['metaconsole_enabled'])) {
@ -2997,8 +2994,37 @@ function ui_print_agent_autocomplete_input($parameters) {
$javascript_name_function_select = $parameters['javascript_name_function_select'];
}
if ($from_ux_transaction != "") {
$javascript_code_function_select = '
function function_select_' . $input_name . '(agent_name) {
console.log(agent_name);
$("#' . $selectbox_id . '").empty();
var inputs = [];
inputs.push ("id_agent=" + $("#' . $hidden_input_idagent_id . '").val());
inputs.push ("get_agent_transactions=1");
inputs.push ("page=enterprise/include/ajax/ux_transaction.ajax");
jQuery.ajax ({
data: inputs.join ("&"),
type: "POST",
url: action="' . $javascript_ajax_page . '",
dataType: "json",
success: function (data) {
if (data) {
$("#' . $selectbox_id . '").append ($("<option value=0>None</option>"));
jQuery.each (data, function (id, value) {
$("#' . $selectbox_id . '").append ($("<option value=" + id + ">" + value + "</option>"));
});
}
}
});
return false;
}
';
}
else {
$javascript_code_function_select = '
function function_select_' . $input_name . '(agent_name) {
@ -3060,6 +3086,8 @@ function ui_print_agent_autocomplete_input($parameters) {
return false;
}
';
}
if (isset($parameters['javascript_code_function_select'])) {
$javascript_code_function_select = $parameters['javascript_code_function_select'];
}

View File

@ -278,4 +278,35 @@ function d3_gauges($chart_data, $width, $height, $color, $legend,
return $output;
}
function ux_console_phases_donut ($phases, $id, $return = false) {
global $config;
foreach ($phases as $i => $phase) {
$phases[$i]['phase_name'] = io_safe_output($phase['phase_name']);
}
if (is_array($phases))
$phases = json_encode($phases);
$recipient_name = "phases_donut_" . $id;
$recipient_name_to_js = "#phases_donut_" . $id;
$output = "<div id=" . $recipient_name . " style='overflow: hidden;'></div>";
$output .= include_javascript_d3(true);
$output .= "<style type=\"text/css\">
path {
stroke: #fff;
fill-rule: evenodd;
}
</style>";
$output .= "<script language=\"javascript\" type=\"text/javascript\">
print_phases_donut('" . $recipient_name_to_js . "', " . $phases . ");
</script>";
if (!$return)
echo $output;
return $output;
}
?>

View File

@ -1327,3 +1327,167 @@ function Gauge(placeholderName, configuration, font)
// initialization
this.configure(configuration);
}
function print_phases_donut (recipient, phases) {
var svg = d3.select(recipient)
.append("svg")
.attr("width", 600)
.attr("height", 300)
.append("g");
svg.append("g")
.attr("class", "slices");
svg.append("g")
.attr("class", "labels");
svg.append("g")
.attr("class", "lines");
var width = 550,
height = 300,
radius = Math.min(width, height) / 2;
var pie = d3.layout.pie()
.sort(null)
.value(function(d) {
return parseFloat(d.label2);
});
var arc = d3.svg.arc()
.outerRadius(radius * 0.8)
.innerRadius(radius * 0.4);
var outerArc = d3.svg.arc()
.innerRadius(radius * 0.9)
.outerRadius(radius * 0.9);
svg.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
var key = function(d){ return d.data.label; };
function phasesData (){
return phases.map(function(phase){
return { label: phase_name(phase, 1), label2: phase_name(phase, 2), value: phase.status }
});
}
function phase_name (phase, index) {
if (index == 1) {
return phase.phase_name;
}
else {
return phase.phase_time;
}
}
print_phases(phasesData());
function print_phases(data) {
/* ------- PIE SLICES -------*/
var slice = svg.select(".slices").selectAll("path.slice")
.data(pie(data), key);
slice.enter()
.insert("path")
.style("fill", function(d) {
if (d.data.value == 0) {
return "#80BA27";
}
else {
return "#FC4444";
}
})
.attr("class", "slice");
slice
.transition().duration(0)
.attrTween("d", function(d) {
this._current = this._current || d;
var interpolate = d3.interpolate(this._current, d);
this._current = interpolate(0);
return function(t) {
return arc(interpolate(t));
};
});
slice.exit()
.remove();
/* ------- TEXT LABELS -------*/
var text = svg.select(".labels").selectAll("text")
.data(pie(data), key);
text.enter()
.append("text")
.append("tspan")
.attr("dy", ".1em")
.text(function(d) {
return d.data.label;
})
.style("font-family", "Verdana")
.style("font-size", "10px")
.append("tspan")
.attr("dy", "1.4em")
.attr("dx", "-6em")
.text(function(d) {
return d.data.label2 + "ms";
})
.style("font-family", "Verdana")
.style("font-size", "10px");
function midAngle(d){
return d.startAngle + (d.endAngle - d.startAngle)/2;
}
text.transition().duration(0)
.attrTween("transform", function(d) {
this._current = this._current || d;
var interpolate = d3.interpolate(this._current, d);
this._current = interpolate(0);
return function(t) {
var d2 = interpolate(t);
var pos = outerArc.centroid(d2);
pos[0] = radius * (midAngle(d2) < Math.PI ? 1 : -1);
return "translate("+ pos +")";
};
})
.styleTween("text-anchor", function(d){
this._current = this._current || d;
var interpolate = d3.interpolate(this._current, d);
this._current = interpolate(0);
return function(t) {
var d2 = interpolate(t);
return midAngle(d2) < Math.PI ? "start":"end";
};
});
text.exit()
.remove();
/* ------- SLICE TO TEXT POLYLINES -------*/
var polyline = svg.select(".lines").selectAll("polyline")
.data(pie(data), key);
polyline.enter()
.append("polyline");
polyline.transition().duration(0)
.attrTween("points", function(d){
this._current = this._current || d;
var interpolate = d3.interpolate(this._current, d);
this._current = interpolate(0);
return function(t) {
var d2 = interpolate(t);
var pos = outerArc.centroid(d2);
pos[0] = radius * 0.95 * (midAngle(d2) < Math.PI ? 1 : -1);
return [arc.centroid(d2), outerArc.centroid(d2), pos];
};
})
.style("stroke", "black")
.style("opacity", ".3")
.style("stroke-width", "2px")
.style("fill", "none");
polyline.exit()
.remove();
}
}