Added target bandwidth value for yearly graph.
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 23 Aug 2016 17:40:51 +0000 (13:40 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 23 Aug 2016 17:40:51 +0000 (13:40 -0400)
Fixed a couple glitches with the PHPGraphLib.
Updated some of the bandwidth graphics.

classes/data/dataManagement.php
classes/serverBandwidthSupport.php
index.php
models/admin/ajax/serverBandwidthGraphs.php
setup/databaseScripts/create_database_V0.0.1.sql
setup/databaseScripts/dbVersions.php
setup/databaseScripts/drop_database_V0.0.1.sql [new file with mode: 0644]
setup/databaseScripts/update_database_V0.0.2.sql [new file with mode: 0644]
views/admin/dashboardWidget/serverStats.html
views/admin/management/serverStats.html

index 68a4f3c..2cc8b08 100644 (file)
@@ -159,13 +159,20 @@ class GlmDataServerStatsManagement extends GlmDataAbstract
                 'type' => 'text',
                 'required' => true,
                 'use' => 'a'
+            ),
+
+            // Target Bandwidth in Megabytes
+            'target' => array (
+                'field' => 'target',
+                'type' => 'integer',
+                'required' => true,
+                'use' => 'a'
             )
 
         );
 
     }
 
-
 }
 
 ?>
\ No newline at end of file
index 24f4637..d1d3b7e 100644 (file)
@@ -164,7 +164,7 @@ class GlmServerBandwidthSupport
     }
 
     /*
-     * Get bandwidth graph data for Today, This month, Two years
+     * Get bandwidth graph data for Today, Last two months, Last two years
      */
     public function bandwidthGetGraphData($graphType = false)
     {
@@ -238,7 +238,7 @@ class GlmServerBandwidthSupport
                       FROM rollup
                      WHERE websitefk = ".$this->siteId."
                        AND date BETWEEN '$firstMonth' AND '$lastMonth'
-                  GROUP BY MONTH(date)
+                  GROUP BY YEAR(date), MONTH(date)
                   ORDER BY date ASC
                 ;";
                 $twoYearData = $this->bwdb->query($sql);
index cccb1b9..87a8584 100644 (file)
--- a/index.php
+++ b/index.php
  *  version from this plugin.
  */
 define('GLM_MEMBERS_SERVERSTATS_PLUGIN_VERSION', '0.0.1');
-define('GLM_MEMBERS_SERVERSTATS_PLUGIN_DB_VERSION', '0.0.1');
+define('GLM_MEMBERS_SERVERSTATS_PLUGIN_DB_VERSION', '1.0.0');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.
-define('GLM_MEMBERS_SERVERSTATS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.5.0');
+define('GLM_MEMBERS_SERVERSTATS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.5.1');
 
 // Check if plugin version is not current in WordPress option and if needed updated it
 if (GLM_MEMBERS_SERVERSTATS_PLUGIN_VERSION != get_option('glmMembersDatabaseServerStatsPluginVersion')) {
index d77be8a..4b42861 100644 (file)
@@ -36,6 +36,13 @@ class GlmMembersAdmin_ajax_serverBandwidthGraphs  extends GlmServerBandwidthSupp
      * @access public
      */
     public $config;
+    /**
+     * Target Monthly Bandwidth
+     *
+     * @var $target
+     * @access public
+     */
+    public $target;
 
     /*
      * Constructor
@@ -67,6 +74,8 @@ class GlmMembersAdmin_ajax_serverBandwidthGraphs  extends GlmServerBandwidthSupp
             $dbData['website']
         );
 
+        $this->target = $dbData['target'];
+
     }
 
     /*
@@ -86,6 +95,7 @@ class GlmMembersAdmin_ajax_serverBandwidthGraphs  extends GlmServerBandwidthSupp
         $graphType = $_REQUEST['graphType'];
 
         $interval = 1;
+        $useTarget = false;
         switch($graphType) {
             case 'twoDay':
                 $interval = 8;
@@ -95,6 +105,7 @@ class GlmMembersAdmin_ajax_serverBandwidthGraphs  extends GlmServerBandwidthSupp
                 break;
             case 'twoYear':
                 $interval = 1;
+                $useTarget = true;
                 break;
             default:
                 die("Invalid bandwidth graph type: $graphType");
@@ -107,7 +118,7 @@ class GlmMembersAdmin_ajax_serverBandwidthGraphs  extends GlmServerBandwidthSupp
         // Load PHPGraphLib
         require_once(GLM_MEMBERS_PLUGIN_LIB_PATH.'/phpgraphlib-master/phpgraphlib.php');
 
-        // Create graph object
+        // Create graph object and set parameters
         $graph = new PHPGraphLib(1200,300);
         $graph->setXValues(true);
         $graph->setYValues(true);
@@ -125,6 +136,11 @@ class GlmMembersAdmin_ajax_serverBandwidthGraphs  extends GlmServerBandwidthSupp
         $graph->addData($data['data_in']);
         $graph->addData($data['data_out']);
 
+        // Set target bandwidth line. Must be set after data sets
+        if ($useTarget) {
+            $graph->setGoalLine(($this->target/1000), "black", "dashed");
+        }
+
         // $graph->setTitle($graphTitle); - In this case the graph title is on the pop-up dialog box.
         $graph->createGraph();
 
index 5d7fb94..ad11d0d 100644 (file)
@@ -15,6 +15,7 @@ CREATE TABLE {prefix}management (
   db_user TINYTEXT NULL,        -- User name for database
   db_pass TINYTEXT NULL,        -- Password for access to database 
   website TINYTEXT NULL,        -- Website name as used in database
+  target INT NULL,              -- Target Bandwidth per Month in Megabytes
   PRIMARY KEY (id)
 );
 
@@ -24,5 +25,5 @@ CREATE TABLE {prefix}management (
 INSERT INTO {prefix}management
     ( id, enabled, db_name, db_host, db_user, db_pass, website )
    VALUES
-    ( 1, true, 'bandwidth', 'angelia.gaslightmedia.com', 'bandwidthRO', ',Wv4W*~^bL_vF3F4PbGsS', '' )
+    ( 1, true, 'bandwidth', 'angelia.gaslightmedia.com', 'bandwidthRO', ',Wv4W*~^bL_vF3F4PbGsS', '', '500' )
 ;
index adefd76..a844606 100644 (file)
@@ -15,5 +15,6 @@
 
 $glmMembersServerStatsDbVersions = array(
     '0.0.1' => array('version' => '0.0.1', 'tables' => 1, 'date' => '8/19/16'),
+    '1.0.0' => array('version' => '1.0.0', 'tables' => 1, 'date' => '8/22/16')
 );
 
diff --git a/setup/databaseScripts/drop_database_V0.0.1.sql b/setup/databaseScripts/drop_database_V0.0.1.sql
new file mode 100644 (file)
index 0000000..fec830b
--- /dev/null
@@ -0,0 +1,12 @@
+-- Gaslight Media Members Database 
+-- File Created: 12/09/14 15:27:15
+-- Database Version: 1.1.5
+-- Database Deletion Script
+-- Note: Tables with DELETE CASCADE must appear before referenced table
+--
+-- Multiple tables may be separated by ",".
+
+DROP TABLE IF EXISTS
+    {prefix}management
+;
+
diff --git a/setup/databaseScripts/update_database_V0.0.2.sql b/setup/databaseScripts/update_database_V0.0.2.sql
new file mode 100644 (file)
index 0000000..e5cd062
--- /dev/null
@@ -0,0 +1,10 @@
+-- Gaslight Media Members Database 
+-- File Created: 12/09/14 15:27:15
+-- Database Version: 0.0.2
+-- Database Update From Previous Version Script
+-- 
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashses
+
+-- Add target bandwidth for bandwidth reports
+ALTER TABLE {prefix}management ADD COLUMN target INT;
index 07502d7..919fb17 100644 (file)
         <center><h3>{$glmSiteTitle}</h3></center>
         <p>
             <span class="glm-right">{$thisDate}</span>
-            <span class="glm-left">Server Bandwidth Stats for Today - Megabytes</span>
+            <span class="glm-left">Server Bandwidth Stats for Today by 10 Min Intervals - Megabytes</span>
         </p>
         <img src="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=serverBandwidthGraphs&graphType=twoDay">
         <p>
             <span class="glm-right">{$thisDate}</span>
-            <span class="glm-left">Server Bandwidth Stats for this Month - Gigabytes</span>
+            <span class="glm-left">Server Bandwidth Stats for last 2 Months by Day - Gigabytes</span>
         </p>
         <img src="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=serverBandwidthGraphs&graphType=twoMonth">
         <p>
             <span class="glm-right">{$thisDate}</span>
-            <span class="glm-left">Server Bandwidth Stats for 2 Years - Gigabytes</span>
+            <span class="glm-left">Server Bandwidth Stats for last 2 Years by Month - Gigabytes</span>
         </p>
         <img src="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=serverBandwidthGraphs&graphType=twoYear">
         <center>Color Key: <span style="color: red;">Incoming</span>, <span style="color: green;">Outgoing</span>, <span style="color: blue;">Total</span></center>
index 7fdd3c8..fb3484b 100644 (file)
                     {if $serverStatsSettings.fieldFail.website}<p>{$serverStatsSettings.fieldFail.website}</p>{/if}
                 </td>
             </tr>
+            <tr>
+                <th {if $serverStatsSettings.fieldRequired.target}class="glm-required"{/if}>Monthly Target Bandwidth:</th>
+                <td {if $serverStatsSettings.fieldFail.target}class="glm-form-bad-input glm-form-bad-input-misc"{/if}>
+                    <input type="text" name="target" value="{$serverStatsSettings.fieldData.target}" class="glm-form-text-input-medium">
+                    <br>Monthly target bandwidth is entered in Megabytes without any fractions.
+                    {if $serverStatsSettings.fieldFail.target}<p>{$serverStatsSettings.fieldFail.target}</p>{/if}
+                </td>
+            </tr>
         </table>
         <input type="submit" value="Update Settings" class="button-primary">
     </form>