Alex Trofimov преди 4 години
родител
ревизия
83276c8072

+ 107 - 0
inc/classes/BxDolGridQueues.php

@@ -0,0 +1,107 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+class BxDolGridQueues extends BxTemplGrid
+{
+    protected $_aSources = [
+            "emails" => [
+                'id' => "emails", 
+                'name' => "_sys_queue_emails", 
+                'all' => "SELECT COUNT(*) FROM `sys_queue_email`",
+                'action' => "DELETE FROM `sys_queue_email`"],
+            "push" => [
+                'id' => "push", 
+                'name' => "_sys_queue_push", 
+                'all' => "SELECT COUNT(*) FROM `sys_queue_push`",
+                'action' => "DELETE FROM `sys_queue_push`"],
+            "transcoding" => [
+                'id' => "transcoding", 
+                'name' => "_sys_queue_transcoding", 
+                'all' => "SELECT COUNT(*) FROM `sys_transcoder_queue`",
+                'failed'  => "SELECT COUNT(*) FROM `sys_transcoder_queue` WHERE `status` = 'failed'",
+                'action'  => "DELETE FROM `sys_transcoder_queue` WHERE `status` != 'processing'"],
+            "storage" => [
+                'id' => "storage",
+                'name' => "_sys_queue_storage",
+                'all' => "SELECT COUNT(*) FROM `sys_storage_deletions`"],
+    ];
+
+	protected function _getDataArray($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
+    {
+    	$this->_aOptions['source'] = $this->_aSources;
+
+        return parent::_getDataArray($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
+    }
+
+    public function __construct ($aOptions, $oTemplate = false)
+    {
+        parent::__construct ($aOptions, $oTemplate);
+    }
+    
+    protected function _getCellFailed ($mixedValue, $sKey, $aField, $aRow)
+    {
+        return $this->_getCellCount ('failed', $sKey, $aField, $aRow);
+    }
+
+    protected function _getCellAll ($mixedValue, $sKey, $aField, $aRow)
+    {
+        return $this->_getCellCount ('all', $sKey, $aField, $aRow);
+    }
+
+    protected function _getCellCount ($sField, $sKey, $aField, $aRow)
+    {
+        if (empty($aRow[$sField]))
+            $mixedValue = _t('_sys_not_available');
+        else
+            $mixedValue = BxDolDb::getInstance()->getOne($aRow[$sField]);
+        return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
+    }
+
+    public function performActionClear()
+    {
+        $sAction = 'edit';
+        
+        $aIds = bx_get('ids');
+        
+        if(!$aIds || !is_array($aIds)) {
+            $sId = bx_get('id');
+            if(!$sId)
+                return echoJson(array());
+
+            $aIds = array($sId);
+        }
+
+        $sId = array_shift($aIds);
+        if (empty($this->_aSources[$sId]) || empty($this->_aSources[$sId]['action'])) {
+print_r($this->_aSources);
+            $sRes = echoJson(array('msg' => _t('_error occured')));
+            exit;
+        } 
+        else {
+            $sQuery = $this->_aSources[$sId]['action'];
+            $i = BxDolDb::getInstance()->query($sQuery);
+            echoJson(array('grid' => $this->getCode(false), 'blink' => $sId));
+        }
+    }
+
+	protected function _isVisibleGrid ($a)
+    {
+        return isAdmin();
+    }
+    
+    protected function _getActionClear($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
+    {
+        if(empty($aRow['action']))
+            return '';
+
+        return parent::_getActionDefault($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
+    }        
+}
+
+/** @} */

+ 15 - 1
install/sql/system.sql

@@ -4959,6 +4959,19 @@ INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `icon
 ('sys_grid_related_me', 'single', 'decline', '_sys_decline', 'times-circle', 1, 1, 2),
 ('sys_grid_related_me', 'single', 'add', '_sys_add_relation', 'plus-circle', 1, 0, 3);
 
+-- GRID: queues
+INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `field_active`, `order_get_field`, `order_get_dir`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_fields_translatable`, `filter_mode`, `filter_get`, `sorting_fields`, `sorting_fields_translatable`, `visible_for_levels`, `responsive`, `show_total_count`, `override_class_name`, `override_class_file`) VALUES
+('sys_queues', 'Array', '', '', 'id', '', '', 'order_field', 'order_dir', '', 10, NULL, 'start', '', '', '', 'auto', 'filter', '', '', 128, 0, 0, 'BxDolGridQueues', '');
+
+INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable`, `chars_limit`, `params`, `hidden_on`, `order`) VALUES
+('sys_queues', 'name', '_Name', '40%', 1, 0, '', '', 1),
+('sys_queues', 'all', '_all', '20%', 0, 0, '', '', 2),
+('sys_queues', 'failed', '_Failed', '20%', 0, 0, '', '', 3),
+('sys_queues', 'actions', '', '20%', 0, 0, '', '', 4);
+
+INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `icon_only`, `confirm`, `order`) VALUES
+('sys_queues', 'single', 'clear', '', 'eraser', 0, 1, 1);
+
 -- --------------------------------------------------------
 
 
@@ -5445,8 +5458,9 @@ INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title_system`, `
 
 ('sys_std_dashboard', 2, 'system', '', '_sys_page_block_title_std_dash_host_tools', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:20:"get_block_host_tools";s:6:"params";a:0:{}s:5:"class";s:20:"TemplStudioDashboard";}', 0, 0, 1, 1),
 
-('sys_std_dashboard', 2, 'system', '', '_sys_page_block_title_std_dash_cache', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:15:"get_block_cache";s:6:"params";a:0:{}s:5:"class";s:20:"TemplStudioDashboard";}', 0, 0, 1, 2);
+('sys_std_dashboard', 2, 'system', '', '_sys_page_block_title_std_dash_cache', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:15:"get_block_cache";s:6:"params";a:0:{}s:5:"class";s:20:"TemplStudioDashboard";}', 0, 0, 1, 2),
 
+('sys_std_dashboard', 2, 'system', '', '_sys_page_block_title_std_dash_queues', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:16:"get_block_queues";s:6:"params";a:0:{}s:5:"class";s:20:"TemplStudioDashboard";}', 0, 0, 1, 3);
 
 -- --------------------------------------------------------
 

+ 5 - 1
modules/boonex/english/data/langs/system/en.xml

@@ -3133,6 +3133,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_page_block_title_std_dash_space"><![CDATA[Space Usage]]></string>
 	<string name="_sys_page_block_title_std_dash_host_tools"><![CDATA[Host Tools]]></string>
 	<string name="_sys_page_block_title_std_dash_cache"><![CDATA[Cache]]></string>
+    <string name="_sys_page_block_title_std_dash_queues"><![CDATA[Queues]]></string>
 	<string name="_sys_page_block_title_terms"><![CDATA[Terms of Service]]></string>
         <string name="_sys_page_block_title_sys_std_site_submenu"><![CDATA[Site submenu]]></string>
         <string name="_sys_page_block_title_std_site_submenu"><![CDATA[Site submenu]]></string>
@@ -3668,6 +3669,9 @@ If it is not enabled then please consider implement this optimization, since it
     <string name="_sys_txt_quill_tooltip_embed"><![CDATA[Insert an embed]]></string>
     <string name="_sys_txt_quill_tooltip_embed_popup_header"><![CDATA[Paste an URL for embed]]></string>
     <string name="_sys_txt_quill_tooltip_link_popup_header"><![CDATA[Paste an URL]]></string>
-    
+    <string name="_sys_queue_emails"><![CDATA[Emails]]></string>
+    <string name="_sys_queue_push"><![CDATA[PUSH]]></string>
+    <string name="_sys_queue_transcoding"><![CDATA[Video transcoding]]></string>
+    <string name="_sys_queue_storage"><![CDATA[Files storage]]></string>    
 </resources>
 

+ 5 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -3100,6 +3100,7 @@
 	<string name="_sys_page_block_title_std_dash_space"><![CDATA[Использование дискового пространства]]></string>
 	<string name="_sys_page_block_title_std_dash_host_tools"><![CDATA[Инструменты хоста]]></string>
 	<string name="_sys_page_block_title_std_dash_cache"><![CDATA[Кэш]]></string>
+    <string name="_sys_page_block_title_std_dash_queues"><![CDATA[Очереди]]></string>
 	<string name="_sys_page_block_title_terms"><![CDATA[Правила пользования]]></string>
 	<string name="_sys_page_lang_block_about"><![CDATA[Этот сайт сделан на UNA. Остальное - тайна, покрытая мраком.]]></string>
 	<string name="_sys_page_lang_block_terms"><![CDATA[Правила пользования нашим сайтом.]]></string>
@@ -3622,4 +3623,8 @@
   <string name="_sys_txt_quill_tooltip_embed"><![CDATA[Вставить ембед]]></string>
   <string name="_sys_txt_quill_tooltip_embed_popup_header"><![CDATA[Вставить адрес дла ембеда]]></string>
   <string name="_sys_txt_quill_tooltip_link_popup_header"><![CDATA[Вставить адрес]]></string>
+  <string name="_sys_queue_emails"><![CDATA[Emails]]></string>
+  <string name="_sys_queue_push"><![CDATA[PUSH]]></string>
+  <string name="_sys_queue_transcoding"><![CDATA[Транскодирование видео]]></string>
+  <string name="_sys_queue_storage"><![CDATA[Хранилище файлов]]></string>
 </resources>

+ 5 - 0
studio/template/css/dashboard.css

@@ -58,3 +58,8 @@ div.bx-dbd-htools .bx-dbd-htools-item {
     float: left;
     width: 50%;
 }
+
+/*--- Queues block ---*/
+#bx-grid-table-sys_queues {
+    width:100%;
+}

+ 6 - 0
studio/template/scripts/BxBaseStudioDashboard.php

@@ -298,6 +298,12 @@ class BxBaseStudioDashboard extends BxDolStudioDashboard
             return array('content' => $sContent, 'menu' => $aMenu);
 	}
 
+	public function serviceGetBlockQueues()
+    {
+        $o = BxDolGrid::getObjectInstance('sys_queues', BxDolStudioTemplate::getInstance());
+        return $o->getCode();
+    }
+
     private function getVersionUpgradeAvailable()
     {
     	$oUpgrader = bx_instance('BxDolUpgrader');