Worked on the tables for each section.
Adding functionality to the plugin detail page.
Plugin detail page can now edit the prod_version and dev_version
columns. They'll update the actual database record.
public function modelAction( $actionData = false ) {
- // $where = "T.prod_server = 2"; // norax
- $where = "T.prod_server = 1"; // eleusis
+ $where = "T.prod_server = 2"; // norax
+ // $where = "T.prod_server = 1"; // eleusis
$where .= "
AND T.id IN (SELECT site
FROM " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "site_plugins
- WHERE plugin = 7)
+ WHERE plugin = 15)
";
$config = array(
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * PDF Output by admin-ajax
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+require_once GLM_MEMBERS_PLUGINS_PLUGIN_CLASS_PATH.'/data/dataSitePlugins.php';
+/**
+ * Steve Note
+ *
+ * You can get to this using the following URL.
+ *
+ *
+ {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=runQueue
+ *
+ * You should be able to do this as POST or GET and should be able to add and read additional parameters.
+ * I added a "mystuff" parameter to the URL above and it does output from the code in the
+ * modelAction() function below.
+ *
+ * To add another model under models/admin/ajax all you need to do is create it and add it to the
+ * setup/validActions.php file.
+ *
+ */
+
+// Load Members data abstract
+// require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataImages.php';
+
+/**
+ * This class performs the work of handling images passed to it via
+ * an AJAX call that goes through the WorPress AJAX Handler.
+ *
+ */
+class GlmMembersAdmin_ajax_sitePluginUpdate extends GlmDataSitePlugin
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ // Run constructor for members data class
+ parent::__construct( false, false );
+
+ }
+
+ public function modelAction( $actionData = false ) {
+ if ( isset( $_REQUEST['id'] ) && $id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ) ) {
+
+ $return = array(
+ 'prodStatus' => false,
+ 'devStatus' => false,
+ 'id' => $id,
+ );
+
+ $this->wpdb->update(
+ $this->table,
+ array(
+ 'prod_version' => $_REQUEST['prodVersion'],
+ 'dev_version' => $_REQUEST['devVersion']
+ ),
+ array( 'id' => $id ),
+ array( '%s', '%s' ),
+ array( '%d' )
+ );
+ // Get entry.
+ $sitePlugin = $this->getEntry( $id );
+ if ( $sitePlugin ) {
+
+ // Now check to see prod and dev version status are ok or not and return.
+ $latestVersion = $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT latest_version
+ FROM " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "plugins
+ WHERE id = %d",
+ $sitePlugin['plugin']['value']
+ )
+ );
+ if ( $latestVersion ) {
+ if ( $sitePlugin['prod_version'] && version_compare( $latestVersion, $sitePlugin['prod_version'], '>' ) ) {
+ $return['prodStatus'] = false;
+ } elseif ( $sitePlugin['prod_version'] ) {
+ $return['prodStatus'] = true;
+ }
+ if ( $sitePlugin['dev_version'] && version_compare( $latestVersion, $sitePlugin['dev_version'], '>' ) ) {
+ $return['devStatus'] = false;
+ } elseif ( $sitePlugin['dev_version'] ) {
+ $return['devStatus'] = true;
+ }
+ }
+ }
+ }
+
+ echo json_encode( $return );
+
+ exit;
+ }
+}
// Find all sites for this plugin.
$tData['sites'] = $this->wpdb->get_results(
$this->wpdb->prepare(
- "SELECT S.name as site_name,S.id,SP.prod_version,SP.dev_version,PS.name as prod_server,DS.name as dev_server
+ "SELECT S.name as site_name,S.id,SP.id as site_plugin_id,SP.prod_version,SP.dev_version,PS.name as prod_server,DS.name as dev_server
FROM " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "site_plugins SP
LEFT OUTER JOIN " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "sites S ON (S.id = SP.site)
LEFT OUTER JOIN " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "servers PS ON (PS.id = S.prod_server)
$glmMemberPluginsAddOnValidActions = array(
'adminActions' => array(
'ajax' => array(
- 'pluginListSites' => GLM_MEMBERS_PLUGINS_PLUGIN_SLUG,
+ 'pluginListSites' => GLM_MEMBERS_PLUGINS_PLUGIN_SLUG,
+ 'sitePluginUpdate' => GLM_MEMBERS_PLUGINS_PLUGIN_SLUG,
),
'plugins' => array(
- 'index' => GLM_MEMBERS_PLUGINS_PLUGIN_SLUG,
+ 'index' => GLM_MEMBERS_PLUGINS_PLUGIN_SLUG,
'plugins' => GLM_MEMBERS_PLUGINS_PLUGIN_SLUG,
'sites' => GLM_MEMBERS_PLUGINS_PLUGIN_SLUG,
'servers' => GLM_MEMBERS_PLUGINS_PLUGIN_SLUG,
</div>
</div>
+<div class="grid-x grid-margin-x">
+ <div class="cell small-12 medium-3">
+ <input type="text" id="filter-value" placeholder="Search">
+ </div>
+ <div class="cell small-12 medium-4">
+ <button id="filter-clear" class="button primary">Clear</button>
+ </div>
+</div>
<div id="dashboard-plugins"></div>
<script>
];
{literal}
+
+ function updateFilter(){
+ table.setFilter( 'name', 'like', $('#filter-value').val() );
+ }
+
+ $('#filter-value').keyup(updateFilter);
+
+ // Clear filter on "Clear" button click
+ $('#filter-clear').on( 'click', function(){
+ $('#filter-value').val('');
+ table.clearFilter();
+ } );
+
var table = new Tabulator("#dashboard-plugins",{
height: "350px",
data: tabledata,
{* Grid End *}
{include file='ui/f6/grid-end.html'}
-
+{debug}
<script>
jQuery(document).ready(function($){
$(document).foundation();
var tabledata = [
{foreach $sites as $site}
- { id:"{$site.id}", name:"{$site.site_name|escape:'quotes'}",
+ { id:"{$site.site_plugin_id}", siteId: "{$site.id}", name:"{$site.site_name|escape:'quotes'}",
prodServer: "{$site.prod_server}", prodVersion: "{$site.prod_version}",
prodUpToDate: {if !empty($site.prod_version) && version_compare( $plugin.fieldData.latest_version, $site.prod_version, '>' )}false{elseif !empty($site.prod_version)}true{else}null{/if},
devServer: "{$site.dev_server}", devVersion: "{$site.dev_version}",
];
{literal}
+ function updateVersion( cell ) {
+ if ( cell == undefined ) {
+ console.log('ERROR');
+ return false;
+ }
+ // Get data from row.
+ var data = cell.getRow().getData();
+ // Call ajax page to update the sitePlugin record.
+ $.ajax({
+ cache: false,
+ url: '{/literal}{$ajaxUrl}{literal}?action=glm_members_admin_ajax&glm_action=sitePluginUpdate',
+ data: data,
+ dataType: 'json',
+ }).done(function( rsp ){
+ console.log( 'return: ', rsp );
+ table.updateData([{id: rsp.id, prodUpToDate: rsp.prodStatus, devUpToDate: rsp.devStatus}]);
+ });
+ }
+
var table = new Tabulator("#siteList",{
height: "350px",
data: tabledata,
columns:[
{title:"Site Name", field:"name", width:"250"},
{title:"Prod Server", field:"prodServer", align:"left"},
- {title:"Prod Version", field:"prodVersion", align:"left", editor:true, cellEdited: function(cell){
- console.log('Edit: ', cell );
- }},
+ {title:"Prod Version", field:"prodVersion", align:"left", editor:true, cellEdited: updateVersion },
{title:"Status", field:"prodUpToDate", formatter:"tickCross"},
{title:"Dev Server", field:"devServer", align:"left"},
- {title:"Dev Version", field:"devVersion", align:"left", editor: true},
+ {title:"Dev Version", field:"devVersion", align:"left", editor: true, cellEdited: updateVersion },
{title:"Status", field:"devUpToDate", formatter:"tickCross"},
],
rowClick:function(e, row){
console.log('Row ' + row.getData().id + ' Clicked!!!');
- window.location.href="{/literal}{$baseUrl}&option=pluginSite{if !empty($smarty.request.order)}&order={$smarty.request.order}{/if}&site_id={literal}" + row.getData().id;
+ window.location.href="{/literal}{$baseUrl}&option=pluginSite{if !empty($smarty.request.order)}&order={$smarty.request.order}{/if}&site_id={literal}" + row.getData().siteId;
}
});
{/literal}
</table>
+<div class="grid-x grid-margin-x">
+ <div class="cell small-12 medium-4">
+ <input type="text" id="filter-value" placeholder="Search">
+ </div>
+ <div class="cell small-12 medium-4">
+ <button id="filter-clear" class="button primary">Clear</button>
+ </div>
+</div>
<div id="pluginList"></div>
<script>
{/foreach}
];
{literal}
+
+ function updateFilter(){
+ table.setFilter( 'name', 'like', $('#filter-value').val() );
+ }
+
+ $('#filter-value').keyup(updateFilter);
+
+ // Clear filter on "Clear" button click
+ $('#filter-clear').on( 'click', function(){
+ $('#filter-value').val('');
+ table.clearFilter();
+ } );
+
var table = new Tabulator("#pluginList",{
height: "350px",
data: tabledata,
</table>
+<div class="grid-x grid-margin-x">
+ <div class="cell small-12 medium-3">
+ <input type="text" id="filter-value" placeholder="Search">
+ </div>
+ <div class="cell small-12 medium-4">
+ <button id="filter-clear" class="button primary">Clear</button>
+ </div>
+</div>
<div id="siteList"></div>
<script>
];
{literal}
+
+ function updateFilter(){
+ table.setFilter( 'name', 'like', $('#filter-value').val() );
+ }
+
+ $('#filter-value').keyup(updateFilter);
+
+ // Clear filter on "Clear" button click
+ $('#filter-clear').on( 'click', function(){
+ $('#filter-value').val('');
+ table.clearFilter();
+ } );
+
var table = new Tabulator("#siteList",{
height: "350px",
data: tabledata,
addRowPos: "top",
initialSort: [ {column: "name", dir: "asc"} ],
columns:[
- {title:"Site Name", field:"name", width:"350", headerFilter: true},
+ {title:"Site Name", field:"name", width:"350"},
{title:"Prod Url", field:"prodUrl", align:"left"},
{title:"Dev Url", field:"devUrl", align:"left"},
],
rowClick:function(e, row){
console.log('Row ' + row.getData().id + ' Clicked!!!');
window.location.href="{/literal}{$thisUrl}?page={$thisPage}&glm_action={$thisAction}&option=view&site_id={literal}" + row.getData().id;
- }
+ },
+ initialFilter: [
+ {field:"name", type:"like", value:""}
+ ]
});
{/literal}
});