Commit abe0685c authored by PERRIER Guillaume's avatar PERRIER Guillaume
Browse files

Correctif appel google charts et bind de fonction de callback pour supprimer...

Correctif appel google charts et bind de fonction de callback pour supprimer les erreur js. Lègère adaptation du format de date hAxis (MMM yy) afin qu'il soit lisible (non superposition). Enfin déport du graph vers la gauche (gain de place).
parent d86c20d9
......@@ -55,10 +55,9 @@
</section>
{% endblock %}
{% block javascripts %}
<script type="text/javascript" src="{{ asset('build/js/metrics/metrics.min.js') }}"></script>
<script type="text/javascript"
src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['line', 'corechart']}]}"></script>
<script src="{{ asset('build/js/gstatic.charts.min.js') }}"></script>
<script src="{{ asset('build/js/metrics/metrics.min.js') }}"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.bootstrap4.min.js"></script>
......@@ -71,14 +70,16 @@
<script>
google.load("visualization", "1.1", {packages:["line", "corechart"]});
google.setOnLoadCallback(function(){
buildUserMetricsChart("TOP 10 {{ entity }}s Users Numbers");
});
$(document).ready(function () {
//build report list tab
buildUsersMetricsTable();
buildUserMetricsChart("TOP 10 {{ entity }}s Users Numbers");
});
</script>
{% endblock %}
var rbCertListTable;function buildUsersMetricsTable(){$("#usersMetricsTable").DataTable({pageLength:50,lengthChange:!1,searchable:!1,buttons:["copy","excel","pdf"]}).buttons().container().appendTo("#usersMetricsTable_wrapper .col-md-6:eq(0)")}function buildInternationalUsersMetricsTable(){$("#internationalUsersMetricsTable").DataTable({pageLength:50,searchable:!1,columns:[{data:"Period",orderable:!1,searchable:!1},{data:"New VO -Total"},{data:"New International VO"},{data:" \tNew National VO"},{data:"Details",orderable:!1,searchable:!1}],buttons:["copy","excel","pdf"]}).buttons().container().appendTo("#internationalUsersMetricsTable_wrapper .col-md-6:eq(0)")}function buildVoActivitiesMetricsTable(){$("#voActivitiesMetricsTable").DataTable({pageLength:50,searchable:!1,columns:[{data:"VO"},{data:"Status"},{data:"Scope"},{data:"CPU Consumption"},{data:"AppDBChanges"},{data:"Diff"},{data:"Month 1"},{data:"Month 2"}],buttons:["copy","excel","pdf"]}).buttons().container().appendTo("#voActivitiesMetricsTable_wrapper .col-md-6:eq(0)")}function buildRbCertificateTable(){$("#rbCertListTable").DataTable({pageLength:25,columns:[{data:"Vo"},{data:"Robot DN"},{data:"Contact Email"},{data:"use per-user sub-proxies"},{data:"Service Name"},{data:"Service Url"},{data:"Validation date"},{data:"Action",orderable:!1,searchable:!1},{data:"Id",orderable:!1,searchable:!1}],order:[[6,"asc"]],searchable:!1,buttons:["copy","excel","pdf","colvis"]}).buttons().container().appendTo("#rbCertListTable_wrapper .col-md-6:eq(0)")}function buildUserMetricsChart(e){var t=$("#UsersMetricschart_div")[0],a=$("div.dataCSV").text().split("\n"),o=new google.visualization.DataTable;o.addColumn("date","Month");var r=[],i=[];$.each(a,function(e,t){var a=[];$.each(t.split(","),function(e,t){$.trim(t)&&(t.match(/^\d{4}-((0\d)|(1[012]))$/)?a.push(new Date($.trim(t))):$.isNumeric(t)?a.push(parseFloat($.trim(t))):-1===$.inArray($.trim(t),i)&&i.push($.trim(t)))}),r.push(a)}),$.each(i,function(e,t){o.addColumn("number",t)}),o.addRows(r);for(var n=[],l=0;l<o.getNumberOfColumns();l++)n.push(l);var s,d=["#00CC33","#3333FF","#FF0000","#FF9933","#660099","#FF00FF","#660099","#FFFF33","#FF99FF","#00FF33","#0099FF","#606060","#003366","#999933","#996600","#CCCCFF","#333300","#CC99CC","#FF0099","#999999","#CC3333","#00FFFF"],c=[],u={title:e,height:500,width:1700,hAxis:{title:"Month"},vAxis:{title:"Number"},chartArea:{left:"200",width:"60%"},legend:{textStyle:{fontName:"Arial",fontSize:12,bold:!1}},colors:d};s=new google.visualization.LineChart(t),google.visualization.events.addListener(s,"ready",function(){document.getElementById("chart_div_png").outerHTML='<a class="btn btn-default" target="_blank" href="'+s.getImageURI()+'">PNG printable version</a>'}),s.draw(o,u),google.visualization.events.addListener(s,"select",function(){var e=s.getSelection();0<e.length&&null===e[0].row&&(e=e[0].column,n[e]==e?(n[e]={label:o.getColumnLabel(e),type:o.getColumnType(e),calc:function(){return null}},c[e-1]=d[e-1],d[e-1]="#CCCCCC"):(n[e]=e,d[e-1]=c[e-1]),(e=new google.visualization.DataView(o)).setColumns(n),s.draw(e,u))})}function buildUserMetricsAreaBarColumn(e,r){var a,e=$.parseJSON(e),i={height:200,width:700,explorer:{},legend:{position:"top"}};$.each(e,function(e,t){var o=new google.visualization.DataTable;a="area"==r?($("#UsersMetricschart_Area").append("<div id='areaChart_"+e.replace(/ /g,"")+"'></div><br><br>"),document.getElementById("areaChart_"+e.replace(/ /g,""))):($("#UsersMetricschart_Bar").append("<div id='barChart_"+e.replace(/ /g,"")+"'></div><br><br>"),document.getElementById("barChart_"+e.replace(/ /g,""))),o.addColumn("string","Month"),o.addColumn("number",e),"bar"==r&&o.addColumn({type:"string",role:"style"}),$.each(t,function(e,t){var a=[];$.isNumeric(t)&&(a.push(e),a.push(parseFloat($.trim(t))),"bar"==r&&(parseFloat($.trim(t))<0?a.push("color: red"):a.push("color: blue"))),0!=a.length&&o.addRows([a])}),new("area"==r?google.visualization.AreaChart:google.visualization.ColumnChart)(a).draw(o,i)})}function buildUserPerMetricsHistoryChart(n,l){function e(){var e=document.getElementById("chart_div"),t=n.split("\n"),a=new google.visualization.DataTable;a.addColumn("date","Month"),a.addColumn("number",l);var o=[],r=[];$.each(t,function(e,t){var a;t&&(a=[],$.each(t.split(","),function(e,t){$.trim(t)&&(0<=t.indexOf("-")?a.push(new Date($.trim(t))):$.isNumeric(t)&&(a.push(parseFloat($.trim(t))),r.push(parseFloat($.trim(t)))))}),o.push(a))}),a.addRows(o);var t={title:"Users Number for "+l,subtitle:"Use scroll button in the plot area to zoom in",height:500,width:1500,explorer:{},chartArea:{left:"200",width:"80%"},vAxis:{title:"User Number",minValue:Math.min.apply(null,r)-1,maxValue:Math.max.apply(null,r)+3},legend:{position:"bottom",textStyle:{fontName:"Arial",fontSize:12,bold:!1}}},i=new google.visualization.AreaChart(e);google.visualization.events.addListener(i,"ready",function(){document.getElementById("chart_div_png").outerHTML='<a class="btn btn-default" target="_blank" href="'+i.getImageURI()+'">PNG printable version</a>'}),i.draw(a,t)}google.charts.load("current",{packages:["corechart"]}),google.charts.setOnLoadCallback(e),e()}function getVOCreationDetails(t,e,a,o){$.ajax({type:"POST",url:e,data:{date_start:a,date_end:o},beforeSend:function(){$(t).html("<span class='loader'></span>"),$("#voCreatedDetails").remove()},complete:function(e){$(t).html("<span class='fas fa-link'></span>"),$("#homeSection").append(e.responseText),$("#voCreatedDetails").slideDown(),$("#createdVoDetailsTable"+a+o).DataTable({pageLength:25,lengthChange:!1,searchable:!1,buttons:["copy","excel","pdf"]}).buttons().container().appendTo("#usersMetricsTable_wrapper .col-md-6:eq(0)")},error:function(e){$("#flashes").append("<div class='alert alert-danger' role='alert'>"+e.status+" "+e.responseText+"</div>"),$("#voCreatedDetails").remove()}})}function buildDisciplinesMetricsPieChart(l,s,d){google.charts.load("current",{packages:["corechart"]}),google.charts.setOnLoadCallback(function(){var e=document.getElementById("pieChartNbVo"),t=$.parseJSON(l),a=[];$.each(t,function(e,t){a.push([e,t])});var o=google.visualization.arrayToDataTable(a),r={title:"Vo Distribution : "+d,is3D:!0},i=new google.visualization.PieChart(e);google.visualization.events.addListener(i,"ready",function(){document.getElementById("chartPngNbVO").outerHTML='<a class="btn btn-default" target="_blank" href="'+i.getImageURI()+'">VO Distribution PNG printable version</a>'}),i.draw(o,r);var t=document.getElementById("pieChartNbUsers"),e=$.parseJSON(s),n=[];$.each(e,function(e,t){n.push([e,t])}),o=google.visualization.arrayToDataTable(n),r={title:"User Distribution : "+d,is3D:!0},i=new google.visualization.PieChart(t),google.visualization.events.addListener(i,"ready",function(){document.getElementById("chartPngNbUsers").outerHTML='<a class="btn btn-default" target="_blank" href="'+i.getImageURI()+'">User Distribution PNG printable version</a>'}),i.draw(o,r)})}function completeRbModal(e){var t=$(e).closest("tr"),t=rbCertListTable.row(t);$("#modalVoRbCert #formContactEGI #vo_robot_certificate_id").val(t.data().Id),$("#modalVoRbCert #formContactEGI #vo_robot_certificate_vo_name").val($.trim($($.parseHTML(t.data().Vo)).text())),$("#modalVoRbCert #formContactEGI #vo_robot_certificate_email").val($.trim($($.parseHTML(t.data()["Contact Email"])).text())),$("#modalVoRbCert #formContactEGI #vo_robot_certificate_service_name").val(t.data()["Service Name"]),$("#modalVoRbCert #formContactEGI #vo_robot_certificate_service_url").val(t.data()["Service Url"]),$("#modalVoRbCert #formContactEGI #vo_robot_certificate_robot_dn").val(t.data()["Robot DN"]),"Yes"==t.data()["use per-user sub-proxies"]&&$("#modalVoRbCert #formContactEGI #vo_robot_certificate_use_sub_proxies").prop("checked",!0),$(e).children(".glyphicon").is(".glyphicon-remove")?($("#modalVoRbCert .modal-title span:nth-child(2)").text("Remove Robot Certificate for VO "+$.trim($($.parseHTML(t.data().Vo)).text())+" of Service "+t.data()["Service Name"]),$("#modalVoRbCert #rbCertRemButton").show(),$("#modalVoRbCert #deleteWarning").show(),$("#modalVoRbCert #formContactEGI #vo_robot_certificate_save").hide(),$("#modalVoRbCert #formContactEGI :input").attr("readonly","readonly")):($("#modalVoRbCert .modal-title span:nth-child(2)").text("Edit Robot Certificate for VO "+$.trim($($.parseHTML(t.data().Vo)).text())+" of Service "+t.data()["Service Name"]),$("#modalVoRbCert #rbCertRemButton").hide(),$("#modalVoRbCert #deleteWarning").hide(),$("#modalVoRbCert #formContactEGI :input").removeAttr("readonly"),$("#modalVoRbCert #formContactEGI #vo_robot_certificate_save").show(),$("#subProxiesInfo").trigger("change"))}function removeRbCert(e){$.ajax({type:"POST",url:e,data:{rbCertId:$("#modalVoRbCert #formContactEGI #vo_robot_certificate_id").val()},success:function(e){$("#modalVoRbCert .modal-body .alert-danger").remove()},error:function(e){$("#modalVoRbCert .modal-body").prepend('<div class="alert alert-danger"> '+e.responseText+"</div>")},complete:function(e){window.location.reload()}})}
\ No newline at end of file
var rbCertListTable;function buildUsersMetricsTable(){$("#usersMetricsTable").DataTable({pageLength:50,lengthChange:!1,searchable:!1,buttons:["copy","excel","pdf"]}).buttons().container().appendTo("#usersMetricsTable_wrapper .col-md-6:eq(0)")}function buildInternationalUsersMetricsTable(){$("#internationalUsersMetricsTable").DataTable({pageLength:50,searchable:!1,columns:[{data:"Period",orderable:!1,searchable:!1},{data:"New VO -Total"},{data:"New International VO"},{data:" \tNew National VO"},{data:"Details",orderable:!1,searchable:!1}],buttons:["copy","excel","pdf"]}).buttons().container().appendTo("#internationalUsersMetricsTable_wrapper .col-md-6:eq(0)")}function buildVoActivitiesMetricsTable(){$("#voActivitiesMetricsTable").DataTable({pageLength:50,searchable:!1,columns:[{data:"VO"},{data:"Status"},{data:"Scope"},{data:"CPU Consumption"},{data:"AppDBChanges"},{data:"Diff"},{data:"Month 1"},{data:"Month 2"}],buttons:["copy","excel","pdf"]}).buttons().container().appendTo("#voActivitiesMetricsTable_wrapper .col-md-6:eq(0)")}function buildRbCertificateTable(){$("#rbCertListTable").DataTable({pageLength:25,columns:[{data:"Vo"},{data:"Robot DN"},{data:"Contact Email"},{data:"use per-user sub-proxies"},{data:"Service Name"},{data:"Service Url"},{data:"Validation date"},{data:"Action",orderable:!1,searchable:!1},{data:"Id",orderable:!1,searchable:!1}],order:[[6,"asc"]],searchable:!1,buttons:["copy","excel","pdf","colvis"]}).buttons().container().appendTo("#rbCertListTable_wrapper .col-md-6:eq(0)")}function buildUserMetricsChart(e){var a=$("#UsersMetricschart_div")[0],t=$("div.dataCSV").text().split("\n"),o=new google.visualization.DataTable;google.setOnLoadCallback(function(){var t=new google.visualization.LineChart(a);google.visualization.events.addListener(t,"ready",function(){document.getElementById("chart_div_png").outerHTML='<a class="btn btn-default" target="_blank" href="'+t.getImageURI()+'">PNG printable version</a>'}),t.draw(o,c),google.visualization.events.addListener(t,"select",function(){var e=t.getSelection();0<e.length&&null===e[0].row&&(e=e[0].column,n[e]==e?(n[e]={label:o.getColumnLabel(e),type:o.getColumnType(e),calc:function(){return null}},d[e-1]=s[e-1],s[e-1]="#CCCCCC"):(n[e]=e,s[e-1]=d[e-1]),(e=new google.visualization.DataView(o)).setColumns(n),t.draw(e,c))})}),o.addColumn("date","Month");var r=[],i=[];$.each(t,function(e,t){var a=[];$.each(t.split(","),function(e,t){$.trim(t)&&(t.match(/^\d{4}-((0\d)|(1[012]))$/)?a.push(new Date($.trim(t))):$.isNumeric(t)?a.push(parseFloat($.trim(t))):-1===$.inArray($.trim(t),i)&&i.push($.trim(t)))}),r.push(a)}),$.each(i,function(e,t){o.addColumn("number",t)}),o.addRows(r);for(var n=[],l=0;l<o.getNumberOfColumns();l++)n.push(l);var s=["#00CC33","#3333FF","#FF0000","#FF9933","#660099","#FF00FF","#660099","#FFFF33","#FF99FF","#00FF33","#0099FF","#606060","#003366","#999933","#996600","#CCCCFF","#333300","#CC99CC","#FF0099","#999999","#CC3333","#00FFFF"],d=[],c={title:e,height:500,width:1700,hAxis:{title:"Month",format:"MMM yy"},vAxis:{title:"Number"},chartArea:{left:"20",width:"60%"},legend:{textStyle:{fontName:"Arial",fontSize:12,bold:!1}},colors:s}}function buildUserMetricsAreaBarColumn(e,r){var a,e=$.parseJSON(e),i={height:200,width:700,explorer:{},legend:{position:"top"}};$.each(e,function(e,t){var o=new google.visualization.DataTable;a="area"==r?($("#UsersMetricschart_Area").append("<div id='areaChart_"+e.replace(/ /g,"")+"'></div><br><br>"),document.getElementById("areaChart_"+e.replace(/ /g,""))):($("#UsersMetricschart_Bar").append("<div id='barChart_"+e.replace(/ /g,"")+"'></div><br><br>"),document.getElementById("barChart_"+e.replace(/ /g,""))),o.addColumn("string","Month"),o.addColumn("number",e),"bar"==r&&o.addColumn({type:"string",role:"style"}),$.each(t,function(e,t){var a=[];$.isNumeric(t)&&(a.push(e),a.push(parseFloat($.trim(t))),"bar"==r&&(parseFloat($.trim(t))<0?a.push("color: red"):a.push("color: blue"))),0!=a.length&&o.addRows([a])}),new("area"==r?google.visualization.AreaChart:google.visualization.ColumnChart)(a).draw(o,i)})}function buildUserPerMetricsHistoryChart(n,l){function e(){var e=document.getElementById("chart_div"),t=n.split("\n"),a=new google.visualization.DataTable;a.addColumn("date","Month"),a.addColumn("number",l);var o=[],r=[];$.each(t,function(e,t){var a;t&&(a=[],$.each(t.split(","),function(e,t){$.trim(t)&&(0<=t.indexOf("-")?a.push(new Date($.trim(t))):$.isNumeric(t)&&(a.push(parseFloat($.trim(t))),r.push(parseFloat($.trim(t)))))}),o.push(a))}),a.addRows(o);var t={title:"Users Number for "+l,subtitle:"Use scroll button in the plot area to zoom in",height:500,width:1500,explorer:{},chartArea:{left:"200",width:"80%"},vAxis:{title:"User Number",minValue:Math.min.apply(null,r)-1,maxValue:Math.max.apply(null,r)+3},legend:{position:"bottom",textStyle:{fontName:"Arial",fontSize:12,bold:!1}}},i=new google.visualization.AreaChart(e);google.visualization.events.addListener(i,"ready",function(){document.getElementById("chart_div_png").outerHTML='<a class="btn btn-default" target="_blank" href="'+i.getImageURI()+'">PNG printable version</a>'}),i.draw(a,t)}google.charts.load("current",{packages:["corechart"]}),google.charts.setOnLoadCallback(e),e()}function getVOCreationDetails(t,e,a,o){$.ajax({type:"POST",url:e,data:{date_start:a,date_end:o},beforeSend:function(){$(t).html("<span class='loader'></span>"),$("#voCreatedDetails").remove()},complete:function(e){$(t).html("<span class='fas fa-link'></span>"),$("#homeSection").append(e.responseText),$("#voCreatedDetails").slideDown(),$("#createdVoDetailsTable"+a+o).DataTable({pageLength:25,lengthChange:!1,searchable:!1,buttons:["copy","excel","pdf"]}).buttons().container().appendTo("#usersMetricsTable_wrapper .col-md-6:eq(0)")},error:function(e){$("#flashes").append("<div class='alert alert-danger' role='alert'>"+e.status+" "+e.responseText+"</div>"),$("#voCreatedDetails").remove()}})}function buildDisciplinesMetricsPieChart(l,s,d){google.charts.load("current",{packages:["corechart"]}),google.charts.setOnLoadCallback(function(){var e=document.getElementById("pieChartNbVo"),t=$.parseJSON(l),a=[];$.each(t,function(e,t){a.push([e,t])});var o=google.visualization.arrayToDataTable(a),r={title:"Vo Distribution : "+d,is3D:!0},i=new google.visualization.PieChart(e);google.visualization.events.addListener(i,"ready",function(){document.getElementById("chartPngNbVO").outerHTML='<a class="btn btn-default" target="_blank" href="'+i.getImageURI()+'">VO Distribution PNG printable version</a>'}),i.draw(o,r);var t=document.getElementById("pieChartNbUsers"),e=$.parseJSON(s),n=[];$.each(e,function(e,t){n.push([e,t])}),o=google.visualization.arrayToDataTable(n),r={title:"User Distribution : "+d,is3D:!0},i=new google.visualization.PieChart(t),google.visualization.events.addListener(i,"ready",function(){document.getElementById("chartPngNbUsers").outerHTML='<a class="btn btn-default" target="_blank" href="'+i.getImageURI()+'">User Distribution PNG printable version</a>'}),i.draw(o,r)})}function completeRbModal(e){var t=$(e).closest("tr"),t=rbCertListTable.row(t);$("#modalVoRbCert #formContactEGI #vo_robot_certificate_id").val(t.data().Id),$("#modalVoRbCert #formContactEGI #vo_robot_certificate_vo_name").val($.trim($($.parseHTML(t.data().Vo)).text())),$("#modalVoRbCert #formContactEGI #vo_robot_certificate_email").val($.trim($($.parseHTML(t.data()["Contact Email"])).text())),$("#modalVoRbCert #formContactEGI #vo_robot_certificate_service_name").val(t.data()["Service Name"]),$("#modalVoRbCert #formContactEGI #vo_robot_certificate_service_url").val(t.data()["Service Url"]),$("#modalVoRbCert #formContactEGI #vo_robot_certificate_robot_dn").val(t.data()["Robot DN"]),"Yes"==t.data()["use per-user sub-proxies"]&&$("#modalVoRbCert #formContactEGI #vo_robot_certificate_use_sub_proxies").prop("checked",!0),$(e).children(".glyphicon").is(".glyphicon-remove")?($("#modalVoRbCert .modal-title span:nth-child(2)").text("Remove Robot Certificate for VO "+$.trim($($.parseHTML(t.data().Vo)).text())+" of Service "+t.data()["Service Name"]),$("#modalVoRbCert #rbCertRemButton").show(),$("#modalVoRbCert #deleteWarning").show(),$("#modalVoRbCert #formContactEGI #vo_robot_certificate_save").hide(),$("#modalVoRbCert #formContactEGI :input").attr("readonly","readonly")):($("#modalVoRbCert .modal-title span:nth-child(2)").text("Edit Robot Certificate for VO "+$.trim($($.parseHTML(t.data().Vo)).text())+" of Service "+t.data()["Service Name"]),$("#modalVoRbCert #rbCertRemButton").hide(),$("#modalVoRbCert #deleteWarning").hide(),$("#modalVoRbCert #formContactEGI :input").removeAttr("readonly"),$("#modalVoRbCert #formContactEGI #vo_robot_certificate_save").show(),$("#subProxiesInfo").trigger("change"))}function removeRbCert(e){$.ajax({type:"POST",url:e,data:{rbCertId:$("#modalVoRbCert #formContactEGI #vo_robot_certificate_id").val()},success:function(e){$("#modalVoRbCert .modal-body .alert-danger").remove()},error:function(e){$("#modalVoRbCert .modal-body").prepend('<div class="alert alert-danger"> '+e.responseText+"</div>")},complete:function(e){window.location.reload()}})}
\ No newline at end of file
......@@ -107,6 +107,8 @@ function buildUserMetricsChart(title) {
var data = new google.visualization.DataTable();
google.setOnLoadCallback(drawMaterialChart);
data.addColumn('date', "Month");
var dataRows = [];
......@@ -161,12 +163,13 @@ function buildUserMetricsChart(title) {
width: 1700,
hAxis: {
title: 'Month',
format: 'MMM yy',
},
vAxis: {
title: 'Number',
},
chartArea: {left: '200', width: '60%'},
chartArea: {left: '20', width: '60%'},
legend: {textStyle: {fontName: 'Arial', fontSize: 12, bold: false}},
colors: colors
......@@ -222,9 +225,6 @@ function buildUserMetricsChart(title) {
});
}
drawMaterialChart();
//end of line chart
//--------------------------------------------------------------------------------//
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment