<?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs title="All templates statistics">
    <Require feature="dynamic-height" />
    <Locale messages="locale/default.xml" />
    <Locale lang="fr" messages="locale/fr.xml" />
  </ModulePrefs>
  <Content type="html">
    <![CDATA[ 
    <head>
      <title>All templates statistics</title>
      <link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/ui-lightness/jquery-ui.css" />
      <link rel="stylesheet" type="text/css" href="/exo-gadget-resources/skin/exo-gadget/gadget-common.css" />
      
      <script language="javascript" type="text/javascript" src="/social-resources/javascript/eXo/social/SocialUtil.js"></script>
      <script language="javascript" type="text/javascript" src="/exo-gadget-resources/script/jquery/1.6.2/jquery.min.js"></script>
      <script language="javascript" type="text/javascript" src="script/jquery-plugins/jquery.number_format.js"></script>
      <!-- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script> -->
      <script language="javascript" type="text/javascript" src="script/utils.js"></script>
      <!-- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/i18n/jquery-ui-i18n.min.js"></script> -->
      <script type="text/javascript">
        function loadInfos(){      
          
          $.getJSON('/rest/statistics/template/all', function(data) {
            var items = [];
            
            $.each(data, function(i, statistics) {
              $('#template-number').empty();
              $('#template-number').append(statistics.length);
              var nbb = statistics.length;
              var nbbb = $(statistics.length);
              $.each(statistics, function(key, statistic) {
                items.push('<p><div class="IconLink">' + statistic.name + '</div>');
                items.push('<div class="Detail">(nb exec: ' + formatExecTime(statistic.execution) + ' - min: ' + formatExecTime(statistic.minTime) + ' '+ statistic.timeUnit + ' - max: ' + formatExecTime(statistic.maxTime) + ' '+ statistic.timeUnit + ' - avg: ' + formatExecTime(round2decimals(statistic.averageTime)) + ' '+ statistic.timeUnit + ')</div></p>');
                //items.push('<div class="Detail">(nb exec: ' + statistic.execution + ' - min: ' + statistic.minTime + ' - max: ' + statistic.maxTime + ' - avg: ' + round2decimals(statistic.averageTime) + ')</div></p>');
              });
            });
            
            $('<div/>', { 'class': 'users', html: items.join('') }).appendTo('#templates');
            
            // adjust the gadget size
            // the standard version is buggy so i use the eXo Social fixed version
            //gadgets.window.adjustHeight();
            //eXo.social.SocialUtil.adjustHeight($("body").get(0));
            gadgets.window.adjustHeight($("#gadget-templates-all").get(0).offsetHeight);
          });
        }
        
        function init() {
          loadInfos();
          //$(document).everyTime("15s", "reloadPage", function() { 
          //  loadInfos(); 
          //}, 0);
        }
        gadgets.util.registerOnLoadHandler(init);
      </script>
    </head>
    <body id="gadget-templates-all">
      <div class="UIGadgetThemes">
        <div class="TitGad ClearFix">
          <a target="_blank" id="ShowAll" class="IconDropDown"> </a>
          <div title="Setting" id="SettingButton" class="SettingButton">
            <a href="javascript:eXoEventGadget.showHideSetting(true);"></a>
          </div>
          <div class="ContTit">__MSG_title-all__&nbsp;&nbsp;(<span id="template-number">?</span>)</div>
        </div>
        <div id="templates" class="GadCont templates">
        </div>    
      </div>
    </body>
    ]]></Content></Module>
