]> git.proxmox.com Git - pmg-gui.git/blobdiff - js/GeneralMailStatistics.js
attachement grid: set configs used on all use-sites as defaults
[pmg-gui.git] / js / GeneralMailStatistics.js
index df4a1e8540eea13d3d36496bb0fcbc50be35bfa3..5b370da26487f51e920e90fa93ead372c7100b20 100644 (file)
@@ -3,15 +3,19 @@ Ext.define('PMG.GeneralMailStatistics', {
     xtype: 'pmgGeneralMailStatistics',
 
     scrollable: true,
-    
-    bodyPadding: '0 0 10 0',
+
+    bodyPadding: '10 0 0 0',
+    border: false,
     defaults: {
-       margin: '10 10 0 10'
+       width: 700,
+       padding: '0 0 10 10',
     },
 
-    title: gettext('General Mail Statistics'),
+    layout: 'column',
+
+    title: gettext('Statistics') + ': ' + gettext('Mail'),
 
-    tbar: [ { xtype: 'pmgStatTimeSelector' } ],
+    tbar: [{ xtype: 'pmgStatTimeSelector' }],
 
     getInData: function(data) {
        var res = [];
@@ -19,67 +23,67 @@ Ext.define('PMG.GeneralMailStatistics', {
        res.push({
            name: gettext("Incoming Mails"),
            value: data.count_in,
-           percentage: 1
+           percentage: 1,
        });
-           
+
        res.push({
            name: gettext("Junk Mails"),
            value: data.junk_in,
-           percentage: data.junk_in/data.count_in
+           percentage: data.junk_in/data.count_in,
        });
-           
+
        res.push({
            name: gettext("Greylisted Mails"),
            value: data.glcount,
-           percentage: data.glcount/data.count_in
+           percentage: data.glcount/data.count_in,
        });
 
        res.push({
            name: gettext("Spam Mails"),
            value: data.spamcount_in,
-           percentage: data.spamcount_in/data.count_in
+           percentage: data.spamcount_in/data.count_in,
        });
-       
+
        res.push({
            name: gettext("SPF rejects"),
            value: data.spfcount,
-           percentage: data.spfcount/data.count_in
+           percentage: data.spfcount/data.count_in,
        });
 
        res.push({
            name: gettext("Bounces"),
            value: data.bounces_in,
-           percentage: data.bounces_in/data.count_in
+           percentage: data.bounces_in/data.count_in,
        });
 
        res.push({
            name: gettext("Virus Mails"),
            value: data.viruscount_in,
-           percentage: data.viruscount_in/data.count_in
+           percentage: data.viruscount_in/data.count_in,
        });
 
        return res;
     },
-           
+
    getOutData: function(data) {
        var res = [];
 
        res.push({
            name: gettext("Outgoing Mails"),
            value: data.count_out,
-           percentage: 1
+           percentage: 1,
        });
-           
+
        res.push({
            name: gettext("Bounces"),
            value: data.bounces_out,
-           percentage: data.bounces_out/data.count_out
+           percentage: data.bounces_out/data.count_out,
        });
 
        res.push({
            name: gettext("Virus Mails"),
            value: data.viruscount_out,
-           percentage: data.viruscount_out/data.count_out
+           percentage: data.viruscount_out/data.count_out,
        });
 
        return res;
@@ -87,44 +91,44 @@ Ext.define('PMG.GeneralMailStatistics', {
 
     getGeneralData: function(data) {
        var res = [];
-       
+
        res.push({
            name: gettext("Total Mails"),
            value: data.count,
-           percentage: 1
+           percentage: 1,
        });
-       
+
        res.push({
            name: gettext("Incoming Mails"),
            value: data.count_in,
-           percentage: data.count_in/data.count
+           percentage: data.count_in/data.count,
        });
 
        res.push({
            name: gettext("Outgoing Mails"),
            value: data.count_out,
-           percentage: data.count_out/data.count
+           percentage: data.count_out/data.count,
        });
-           
+
        res.push({
            name: gettext("Virus Outbreaks"),
-           value: data.viruscount_out
+           value: data.viruscount_out,
        });
-           
+
        res.push({
-           name: gettext("Avg. Mail Precessing Time"),
+           name: gettext("Avg. Mail Processing Time"),
            value: Ext.String.format(gettext("{0} seconds"),
-                                    Ext.Number.toFixed(data.avptime, 2))
+                                    Ext.Number.toFixed(data.avptime, 2)),
        });
 
        res.push({
            name: gettext("Incoming Mail Traffic"),
-           value: Ext.Number.toFixed(data.bytes_in/(1024*1024), 2) + ' MByte'
+           value: Ext.Number.toFixed(data.bytes_in/(1024*1024), 2) + ' MiB',
        });
 
        res.push({
            name: gettext("Outgoing Mail Traffic"),
-           value: Ext.Number.toFixed(data.bytes_out/(1024*1024), 2) + ' MByte'
+           value: Ext.Number.toFixed(data.bytes_out/(1024*1024), 2) + ' MiB',
        });
        return res;
     },
@@ -145,10 +149,10 @@ Ext.define('PMG.GeneralMailStatistics', {
                { type: 'integer', name: 'viruscount_out' },
                { type: 'integer', name: 'bounces_in' },
                { type: 'integer', name: 'bounces_out' },
-               { type: 'date', dateFormat: 'timestamp', name: 'time' }
-           ]
+               { type: 'date', dateFormat: 'timestamp', name: 'time' },
+           ],
        });
-       
+
        var totalgrid = Ext.createWidget('pmgMailStatGrid', {
            dockedItems: [
                {
@@ -159,11 +163,11 @@ Ext.define('PMG.GeneralMailStatistics', {
                    fieldTitles: [
                        gettext('Total Mail Count'),
                        gettext('Incoming Mails'), gettext('Outgoing Mails')],
-                   store: countstore
-               }
-           ]
+                   store: countstore,
+               },
+           ],
        });
-       
+
        var ingrid = Ext.createWidget('pmgMailStatGrid', {
            dockedItems: [
                {
@@ -172,13 +176,13 @@ Ext.define('PMG.GeneralMailStatistics', {
                    xtype: 'proxmoxRRDChart',
                    fields: ['count_in', 'spamcount_in', 'viruscount_in', 'bounces_in'],
                    fieldTitles: [
-                       gettext('Incoming Mails'), gettext('Spam Mails'),
+                       gettext('Incoming Mails'), gettext('Junk Mails'),
                        gettext('Virus Mails'), gettext('Bounces')],
-                   store: countstore
-               }
-           ]
+                   store: countstore,
+               },
+           ],
        });
-       
+
        var outgrid = Ext.createWidget('pmgMailStatGrid', {
            dockedItems: [
                {
@@ -189,31 +193,34 @@ Ext.define('PMG.GeneralMailStatistics', {
                    fieldTitles: [
                        gettext('Outgoing Mails'),
                        gettext('Virus Mails'), gettext('Bounces')],
-                   store: countstore
-               }
-           ]
+                   store: countstore,
+               },
+           ],
        });
 
        var infostore = Ext.create('PMG.data.StatStore', {
            staturl: "/api2/json/statistics/mail",
-           fields: [ 'name', 'value', 'percentage' ],
+           fields: ['name', 'value', 'percentage'],
            listeners: {
-               load: function(store, records) {
+               load: function(store, records, success) {
+                   if (!success || records.length <= 0) {
+                       return;
+                   }
                    var data = me.getGeneralData(records[0].data);
                    totalgrid.store.setData(data);
                    data = me.getInData(records[0].data);
                    ingrid.store.setData(data);
                    data = me.getOutData(records[0].data);
                    outgrid.store.setData(data);
-               }
-           }
+               },
+           },
        });
 
-       me.items = [ totalgrid, ingrid, outgrid ];
-       
+       me.items = [totalgrid, ingrid, outgrid];
+
        me.callParent();
 
        me.on('destroy', infostore.destroy, infostore);
        me.on('destroy', countstore.destroy, countstore);
-    }
+    },
 });