improve admin git info card
This commit is contained in:
parent
54204ead13
commit
22a14e6937
23
www/commands/site_gitinfo.php
Normal file
23
www/commands/site_gitinfo.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
require_once (__DIR__ . '/../internals/website.php');
|
||||
|
||||
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
|
||||
/** @var URLRoute $ROUTE */ global $ROUTE;
|
||||
/** @var Website $SITE */ global $SITE;
|
||||
|
||||
|
||||
if (!isset($API_OPTIONS['field'])) { $FRAME_OPTIONS->forceResult(400, "Wrong parameters."); return; }
|
||||
|
||||
$field = strtolower($API_OPTIONS['field']);
|
||||
|
||||
if ($field === 'branch') { echo exec('git rev-parse --abbrev-ref HEAD'); return; }
|
||||
if ($field === 'head') { echo exec('git rev-parse HEAD'); return; }
|
||||
if ($field === 'timestamp') { echo (new DateTime(exec('git log -1 --format=%cd --date=iso')))->format('Y-m-d H:i:s'); return; }
|
||||
if ($field === 'origin') { echo exec('git config --get remote.origin.url'); return; }
|
||||
if ($field === 'message') { echo trim(shell_exec('git log -1 --format=%B')); return; }
|
||||
|
||||
|
||||
$FRAME_OPTIONS->statuscode = 400;
|
||||
echo 'Unknown field';
|
||||
|
||||
return;
|
@ -971,6 +971,10 @@ html, body {
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
.admin_ajax_gitfield_error {
|
||||
color: #FF0000;
|
||||
}
|
||||
|
||||
/* 400px */
|
||||
#loginform div {
|
||||
display: flex;
|
||||
|
1
www/data/css/styles.min.css
vendored
1
www/data/css/styles.min.css
vendored
@ -188,6 +188,7 @@ html,body{margin:0;padding:0;height:100%}
|
||||
.boxedcontent.graybox .bc_data{padding-top:2px;padding-bottom:2px}
|
||||
.boxedcontent.successbox{background-color:#168b00;color:#222;border:1px solid #444;font-weight:bold;text-align:center}
|
||||
.boxedcontent.successbox .bc_data{padding-top:2px;padding-bottom:2px}
|
||||
.admin_ajax_gitfield_error{color:red}
|
||||
#loginform div{display:flex;flex-direction:column}
|
||||
#loginform div button{margin:10px 0;padding:0}
|
||||
.loginerror{display:flex;background:#f44;color:#222;border:1px solid #a44;border-radius:2px;font-weight:bold;padding:0 5px;margin:5px 0 20px 0}
|
||||
|
@ -136,3 +136,7 @@
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.admin_ajax_gitfield_error {
|
||||
color: $COL_ADMIN_ERROR;
|
||||
}
|
@ -148,8 +148,33 @@ function refreshSingle(apibutton, then)
|
||||
});
|
||||
}
|
||||
|
||||
function queryGitField(dest)
|
||||
{
|
||||
const ddest = $(dest);
|
||||
|
||||
let config =
|
||||
{
|
||||
url: '/api/site::gitinfo?field=' + ddest.attr('data-ajax_gitfield'),
|
||||
type: 'GET',
|
||||
dataType: 'text',
|
||||
cache : false,
|
||||
};
|
||||
|
||||
$.ajax(config)
|
||||
.done((data, status, xhr) =>
|
||||
{
|
||||
ddest.text(data);
|
||||
})
|
||||
.fail((xhr, status, err) =>
|
||||
{
|
||||
ddest.addClass('admin_ajax_gitfield_error');
|
||||
ddest.text('ERROR');
|
||||
});
|
||||
}
|
||||
|
||||
$(function()
|
||||
{
|
||||
for (let apibutton of $('.selftest_sequential').toArray()) setTimeout(() => refreshConsistencyDisplaySequential(0), 200);
|
||||
for (let apibutton of $('.selftest_parallel').toArray()) setTimeout(() => refreshConsistencyDisplayParallel(), 200);
|
||||
for (let elem of $('.selftest_sequential').toArray()) setTimeout(() => refreshConsistencyDisplaySequential(0), 200);
|
||||
for (let elem of $('.selftest_parallel').toArray()) setTimeout(() => refreshConsistencyDisplayParallel(), 200);
|
||||
for (let elem of $('.admin_ajax_gitfield').toArray()) setTimeout(() => queryGitField(elem), 0);
|
||||
});
|
@ -41,10 +41,11 @@ $connected = true; try { $SITE->modules->Database(); } catch (Exception $e) { $c
|
||||
<div class="bc_header">Version</div>
|
||||
|
||||
<div class="bc_data keyvaluelist kvl_100">
|
||||
<div><span>Branch:</span> <span><?php echo exec('git rev-parse --abbrev-ref HEAD'); ?></span></div>
|
||||
<div><span>Commit:</span> <span><?php echo exec('git rev-parse HEAD'); ?></span></div>
|
||||
<div><span>Date:</span> <span><?php echo exec('git log -1 --format=%cd'); ?></span></div>
|
||||
<div><span>Message:</span><span><?php echo nl2br(trim(exec('git log -1'))); ?></span></div>
|
||||
<div><span>Branch:</span> <span class="admin_ajax_gitfield" data-ajax_gitfield="branch" >...</span></div>
|
||||
<div><span>Commit:</span> <span class="admin_ajax_gitfield" data-ajax_gitfield="head" >...</span></div>
|
||||
<div><span>Date:</span> <span class="admin_ajax_gitfield" data-ajax_gitfield="timestamp">...</span></div>
|
||||
<div><span>Origin:</span> <span class="admin_ajax_gitfield" data-ajax_gitfield="origin" >...</span></div>
|
||||
<div><span>Message:</span><span class="admin_ajax_gitfield" data-ajax_gitfield="message" >...</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -20,6 +20,7 @@ $API_COMMANDS =
|
||||
'site::createprogramthumbnails' => [ 'src' => __DIR__.'/../commands/site_createProgramThumbnails.php', 'auth' => 'admin' ],
|
||||
'site::createbookthumbnails' => [ 'src' => __DIR__.'/../commands/site_createBookThumbnails.php', 'auth' => 'admin' ],
|
||||
'site::selftest' => [ 'src' => __DIR__.'/../commands/site_selftest.php', 'auth' => 'admin' ],
|
||||
'site::gitinfo' => [ 'src' => __DIR__.'/../commands/site_gitinfo.php', 'auth' => 'admin' ],
|
||||
|
||||
'server::setselfaddress' => [ 'src' => __DIR__.'/../commands/server_setselfaddress.php', 'auth' => 'none' ],
|
||||
'server::gitwebhook' => [ 'src' => __DIR__.'/../commands/server_gitwebhook.php', 'auth' => 'webhook_secret' ],
|
||||
|
Loading…
Reference in New Issue
Block a user