mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-28 23:03:25 +09:00
Add code samples to Queue config screen
This commit is contained in:
parent
d4cd5e3d75
commit
097cecece8
6 changed files with 124 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
<config autoescape="on" />
|
||||
|
||||
<include target="config_header.html" />
|
||||
<load target="css/queue_config.scss" />
|
||||
<load target="js/queue_config.js" />
|
||||
|
||||
<div class="message">
|
||||
|
|
@ -96,6 +97,69 @@
|
|||
|
||||
<h2>{$lang->cmd_queue_call_script}</h2>
|
||||
|
||||
<div class="queue-script-setup">
|
||||
<ul class="qss-tabs x_nav x_nav-tabs">
|
||||
<li class="x_active"><a href="#" data-value="crontab">crontab</a></li>
|
||||
<li><a href="#" data-value="webcron">webcron</a></li>
|
||||
<li><a href="#" data-value="systemd-timer">systemd timer</a></li>
|
||||
</ul>
|
||||
<div class="qss-content crontab active">
|
||||
{@
|
||||
if (function_exists('posix_getpwuid') && function_exists('posix_getuid')):
|
||||
$user_info = posix_getpwuid(posix_getuid());
|
||||
if (!empty($user_info['dir'])):
|
||||
$user_info['dir'] .= DIRECTORY_SEPARATOR;
|
||||
endif;
|
||||
else:
|
||||
$user_info = [];
|
||||
$user_info['name'] = $lang->msg_queue_instructions['same_as_php'];
|
||||
endif;
|
||||
}
|
||||
<p class="qss-instruction">
|
||||
{sprintf($lang->msg_queue_instructions['crontab1'], $user_info['name'] ?? 'PHP', $user_info['dir'] . 'logs')|noescape}
|
||||
</p>
|
||||
<pre><code>* * * * * php {\RX_BASEDIR}index.php common.cron >> {$user_info['dir']}logs{\DIRECTORY_SEPARATOR}queue.log 2>&1</code></pre>
|
||||
<p class="qss-instruction">
|
||||
{$lang->msg_queue_instructions['crontab2']|noescape}
|
||||
</p>
|
||||
</div>
|
||||
<div class="qss-content webcron">
|
||||
<p class="qss-instruction">
|
||||
{$lang->msg_queue_instructions['webcron']|noescape}
|
||||
</p>
|
||||
<pre><code class="webcron-url">{getFullUrl('')}common/scripts/cron.php?key={config('queue.key')}</code></pre>
|
||||
</div>
|
||||
<div class="qss-content systemd-timer">
|
||||
<p class="qss-instruction">
|
||||
{$lang->msg_queue_instructions['systemd1']|noescape}
|
||||
</p>
|
||||
<pre><code>[Unit]
|
||||
Description=Rhymix Queue Service
|
||||
|
||||
[Service]
|
||||
ExecStart=php {\RX_BASEDIR}index.php common.cron
|
||||
User={$user_info['name']}</code></pre>
|
||||
<p class="qss-instruction">
|
||||
{$lang->msg_queue_instructions['systemd2']|noescape}
|
||||
</p>
|
||||
<pre><code>[Unit]
|
||||
Description=Rhymix Queue Timer
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* *:*:00
|
||||
Unit=rhymix-queue.service
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target</code></pre>
|
||||
<p class="qss-instruction">
|
||||
{$lang->msg_queue_instructions['systemd3']|noescape}
|
||||
</p>
|
||||
<pre><code>systemctl daemon-reload
|
||||
systemctl start rhymix-queue.timer
|
||||
systemctl enable rhymix-queue.timer</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="queue_key">{$lang->cmd_queue_webcron_key}</label>
|
||||
<div class="x_controls">
|
||||
|
|
|
|||
27
modules/admin/tpl/css/queue_config.scss
Normal file
27
modules/admin/tpl/css/queue_config.scss
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
.queue-script-setup {
|
||||
.qss-content {
|
||||
display: none;
|
||||
&.active {
|
||||
display: block;
|
||||
border: 1px solid #ddd;
|
||||
border-top: 0;
|
||||
margin-top: -20px;
|
||||
padding: 20px 12px 10px 12px;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.qss-instruction {
|
||||
margin-bottom: 10px;
|
||||
code {
|
||||
color: #333;
|
||||
border: 0;
|
||||
background-color: transparent;
|
||||
padding: 0 1px;
|
||||
}
|
||||
}
|
||||
.pre {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
$(function() {
|
||||
|
||||
$("#queue_driver").on("change", function() {
|
||||
var selected_driver = $(this).val();
|
||||
const selected_driver = $(this).val();
|
||||
$(this).parents("section").find("div.x_control-group.hidden-by-default, p.x_help-block.hidden-by-default").each(function() {
|
||||
if ($(this).hasClass("show-for-" + selected_driver)) {
|
||||
$(this).show();
|
||||
|
|
@ -12,5 +12,22 @@
|
|||
});
|
||||
}).triggerHandler("change");
|
||||
|
||||
$("#queue_key").on('change keyup paste', function() {
|
||||
const key = encodeURIComponent(String($(this).val()));
|
||||
$('.webcron-url').text($('.webcron-url').text().replace(/\?key=[a-zA-Z0-9]+/g, '?key=' + key));
|
||||
});
|
||||
|
||||
const qss = $('.queue-script-setup');
|
||||
const qss_tabs = qss.find('.qss-tabs');
|
||||
const qss_content = qss.find('.qss-content');
|
||||
qss_tabs.on('click', 'a', function(event) {
|
||||
const selected_tab = $(this).data('value');
|
||||
qss_tabs.find('li').removeClass('x_active');
|
||||
$(this).parent().addClass('x_active');
|
||||
qss_content.removeClass('active');
|
||||
qss_content.filter('.' + selected_tab).addClass('active');
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
});
|
||||
})(jQuery);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue