* Finish custom metric implement.

This commit is contained in:
qixinzhi
2023-11-15 16:13:16 +08:00
parent c02ef0f520
commit 40dbcd96bd
7 changed files with 148 additions and 50 deletions
+1 -6
View File
@@ -18,7 +18,7 @@ $config->metric->actionList['implement']['icon'] = 'code';
$config->metric->actionList['implement']['text'] = $lang->metric->implement->common;
$config->metric->actionList['implement']['hint'] = $lang->metric->implement->common;
$config->metric->actionList['implement']['data-toggle'] = 'modal';
$config->metric->actionList['implement']['url'] = helper::createLink('metric', 'implement', 'metricID={id}&isVerify=true');
$config->metric->actionList['implement']['url'] = helper::createLink('metric', 'implement', 'metricID={id}');
$config->metric->actionList['delist']['icon'] = 'ban-circle';
$config->metric->actionList['delist']['text'] = $lang->metric->delist;
@@ -55,8 +55,3 @@ $config->metric->oldObjectMap['stage'] = 'execution';
$config->metric->oldObjectMap['program'] = 'project';
$config->metric->oldObjectMap['softRequest'] = 'story';
$config->metric->oldObjectMap['userRequest'] = 'requirement';
$config->metric->verifyList = array();
$config->metric->verifyList['checkCustomCalcExists'] = $lang->metric->verifyList['checkCustomCalcExists'];
$config->metric->verifyList['checkCalcClass'] = $lang->metric->verifyList['checkCalcClass'];
$config->metric->verifyList['checkCalcMethods'] = $lang->metric->verifyList['checkCalcMethods'];
+59
View File
@@ -0,0 +1,59 @@
var methods = [];
$(document).ready(function()
{
if(!isVerify) verify();
});
function verify(method)
{
if(!method)
{
methods = Object.keys(verifyCustomMethods);
$('.verify-content').empty();
method = methods.shift();
}
verifyStep(method, function(status, error){
if(!status) return;
if(methods.length == 0)
{
var url = $.createLink('metric', 'implement', 'metricID=' + metricId + '&isVerify=true');
var modal = $('.verify-content').closest('.modal');
modalId = modal.attr('id');
setTimeout(function(){
openUrl(url, {load: 'modal', target: modalId});
}, 1000);
return;
}
method = methods.shift();
verify(method);
});
}
function verifyStep(step, callback)
{
var url = $.createLink('metric', 'ajaxCheck', 'code=' + code + '&step=' + step);
$.get(url, function(resp){
resp = JSON.parse(resp);
var status = resp[0];
var error = resp[1];
var $html = genVerifyResult(verifyCustomMethods[step].text, status, error);
$('.verify-content').append($html);
if(typeof callback == 'function') callback(status, error);
});
}
function genVerifyResult(tip, status, error)
{
var sentenceClass = status ? 'pass' : 'error';
var iconClass = status ? 'check' : 'close';
var html = '<p class="verify-sentence ' + sentenceClass + '">';
html += tip;
html += '<i class="icon icon-' + iconClass + '"></i>';
if(error && error.length) html += '<input class="bg-danger ml-5 ellipsis w-96" value="' + error + '"/>';
html += '</p>';
return $(html);
}
+20 -4
View File
@@ -237,10 +237,26 @@ $lang->metric->implement->instructionTips[] = '1.Download the measurement templa
$lang->metric->implement->instructionTips[] = '2.Please put the developed file in the following directory,<strong>Keep the file name consistent with the measurement code</strong>。<br/> <span class="label code-slate">{tmpRoot}metric</span>';
$lang->metric->implement->instructionTips[] = '3.Execute commands to grant executable permissions to files:<p><span class="label code-slate">chmod 777 {tmpRoot}metric</span></p><p><span class="label code-slate">chmod 777 {tmpRoot}metric/{code}.php</span></p>';
$lang->metric->verifyList = array();
$lang->metric->verifyList['checkCustomCalcExists'] = 'Check whether the metric exists';
$lang->metric->verifyList['checkCalcClass'] = 'Check the metric class name is correct';
$lang->metric->verifyList['checkCalcMethods'] = 'Check whether the metrics defines the required methods';
$lang->metric->verifyCustom = new stdclass();
$lang->metric->verifyCustom->checkCustomCalcExists = array();
$lang->metric->verifyCustom->checkCustomCalcExists['text'] = 'Check if the metric file exists';
$lang->metric->verifyCustom->checkCustomCalcExists['error'] = 'The metric file does not exist';
$lang->metric->verifyCustom->checkCustomCalcSyntax = array();
$lang->metric->verifyCustom->checkCustomCalcSyntax['text'] = 'Check if the metric file syntax is correct';
$lang->metric->verifyCustom->checkCustomCalcSyntax['error'] = 'The metric file syntax is incorrect';
$lang->metric->verifyCustom->checkCustomCalcClassName = array();
$lang->metric->verifyCustom->checkCustomCalcClassName['text'] = 'Check if the metric file class name is correct';
$lang->metric->verifyCustom->checkCustomCalcClassName['error'] = 'The metric file class name is incorrect';
$lang->metric->verifyCustom->checkCustomCalcClassMethod = array();
$lang->metric->verifyCustom->checkCustomCalcClassMethod['text'] = 'Check if the metric file class method is correct';
$lang->metric->verifyCustom->checkCustomCalcClassMethod['error'] = 'The metric file class method is incorrect';
$lang->metric->verifyCustom->checkCustomCalcRuntime = array();
$lang->metric->verifyCustom->checkCustomCalcRuntime['text'] = 'Check if the metric file can be executed';
$lang->metric->verifyCustom->checkCustomCalcRuntime['error'] = '';
$lang->metric->weekList = array();
$lang->metric->weekList['1'] = 'Monday';
+20 -4
View File
@@ -237,10 +237,26 @@ $lang->metric->implement->instructionTips[] = '1.Download the measurement templa
$lang->metric->implement->instructionTips[] = '2.Please put the developed file in the following directory,<strong>Keep the file name consistent with the measurement code</strong>。<br/> <span class="label code-slate">{tmpRoot}metric</span>';
$lang->metric->implement->instructionTips[] = '3.Execute commands to grant executable permissions to files:<p><span class="label code-slate">chmod 777 {tmpRoot}metric</span></p><p><span class="label code-slate">chmod 777 {tmpRoot}metric/{code}.php</span></p>';
$lang->metric->verifyList = array();
$lang->metric->verifyList['checkCustomCalcExists'] = 'Check whether the metric exists';
$lang->metric->verifyList['checkCalcClass'] = 'Check the metric class name is correct';
$lang->metric->verifyList['checkCalcMethods'] = 'Check whether the metrics defines the required methods';
$lang->metric->verifyCustom = new stdclass();
$lang->metric->verifyCustom->checkCustomCalcExists = array();
$lang->metric->verifyCustom->checkCustomCalcExists['text'] = 'Check if the metric file exists';
$lang->metric->verifyCustom->checkCustomCalcExists['error'] = 'The metric file does not exist';
$lang->metric->verifyCustom->checkCustomCalcSyntax = array();
$lang->metric->verifyCustom->checkCustomCalcSyntax['text'] = 'Check if the metric file syntax is correct';
$lang->metric->verifyCustom->checkCustomCalcSyntax['error'] = 'The metric file syntax is incorrect';
$lang->metric->verifyCustom->checkCustomCalcClassName = array();
$lang->metric->verifyCustom->checkCustomCalcClassName['text'] = 'Check if the metric file class name is correct';
$lang->metric->verifyCustom->checkCustomCalcClassName['error'] = 'The metric file class name is incorrect';
$lang->metric->verifyCustom->checkCustomCalcClassMethod = array();
$lang->metric->verifyCustom->checkCustomCalcClassMethod['text'] = 'Check if the metric file class method is correct';
$lang->metric->verifyCustom->checkCustomCalcClassMethod['error'] = 'The metric file class method is incorrect';
$lang->metric->verifyCustom->checkCustomCalcRuntime = array();
$lang->metric->verifyCustom->checkCustomCalcRuntime['text'] = 'Check if the metric file can be executed';
$lang->metric->verifyCustom->checkCustomCalcRuntime['error'] = '';
$lang->metric->weekList = array();
$lang->metric->weekList['1'] = 'Monday';
+20 -4
View File
@@ -237,10 +237,26 @@ $lang->metric->implement->instructionTips[] = '1.Download the measurement templa
$lang->metric->implement->instructionTips[] = '2.Please put the developed file in the following directory,<strong>Keep the file name consistent with the measurement code</strong>。<br/> <span class="label code-slate">{tmpRoot}metric</span>';
$lang->metric->implement->instructionTips[] = '3.Execute commands to grant executable permissions to files:<p><span class="label code-slate">chmod 777 {tmpRoot}metric</span></p><p><span class="label code-slate">chmod 777 {tmpRoot}metric/{code}.php</span></p>';
$lang->metric->verifyList = array();
$lang->metric->verifyList['checkCustomCalcExists'] = 'Check whether the metric exists';
$lang->metric->verifyList['checkCalcClass'] = 'Check the metric class name is correct';
$lang->metric->verifyList['checkCalcMethods'] = 'Check whether the metrics defines the required methods';
$lang->metric->verifyCustom = new stdclass();
$lang->metric->verifyCustom->checkCustomCalcExists = array();
$lang->metric->verifyCustom->checkCustomCalcExists['text'] = 'Check if the metric file exists';
$lang->metric->verifyCustom->checkCustomCalcExists['error'] = 'The metric file does not exist';
$lang->metric->verifyCustom->checkCustomCalcSyntax = array();
$lang->metric->verifyCustom->checkCustomCalcSyntax['text'] = 'Check if the metric file syntax is correct';
$lang->metric->verifyCustom->checkCustomCalcSyntax['error'] = 'The metric file syntax is incorrect';
$lang->metric->verifyCustom->checkCustomCalcClassName = array();
$lang->metric->verifyCustom->checkCustomCalcClassName['text'] = 'Check if the metric file class name is correct';
$lang->metric->verifyCustom->checkCustomCalcClassName['error'] = 'The metric file class name is incorrect';
$lang->metric->verifyCustom->checkCustomCalcClassMethod = array();
$lang->metric->verifyCustom->checkCustomCalcClassMethod['text'] = 'Check if the metric file class method is correct';
$lang->metric->verifyCustom->checkCustomCalcClassMethod['error'] = 'The metric file class method is incorrect';
$lang->metric->verifyCustom->checkCustomCalcRuntime = array();
$lang->metric->verifyCustom->checkCustomCalcRuntime['text'] = 'Check if the metric file can be executed';
$lang->metric->verifyCustom->checkCustomCalcRuntime['error'] = '';
$lang->metric->weekList = array();
$lang->metric->weekList['1'] = 'Monday';
+20 -4
View File
@@ -237,10 +237,26 @@ $lang->metric->implement->instructionTips[] = '1.下载度量项模板文件,
$lang->metric->implement->instructionTips[] = '2.请将开发后的文件放到下方目录,<strong>需保持文件名称与度量代号一致</strong>。<br/> <span class="label code-slate">{tmpRoot}metric</span>';
$lang->metric->implement->instructionTips[] = '3.执行命令赋予文件可执行权限:<p><span class="label code-slate">chmod 777 {tmpRoot}metric</span></p><p><span class="label code-slate">chmod 777 {tmpRoot}metric/{code}.php</span></p>';
$lang->metric->verifyList = array();
$lang->metric->verifyList['checkCustomCalcExists'] = '检查度量项是否存在';
$lang->metric->verifyList['checkCalcClass'] = '检查度量项类名是否正确';
$lang->metric->verifyList['checkCalcMethods'] = '检查度量项是否定义了必须的方法';
$lang->metric->verifyCustom = new stdclass();
$lang->metric->verifyCustom->checkCustomCalcExists = array();
$lang->metric->verifyCustom->checkCustomCalcExists['text'] = '检查度量项文件是否存在';
$lang->metric->verifyCustom->checkCustomCalcExists['error'] = '度量项文件不存在';
$lang->metric->verifyCustom->checkCustomCalcSyntax = array();
$lang->metric->verifyCustom->checkCustomCalcSyntax['text'] = '检查语法错误';
$lang->metric->verifyCustom->checkCustomCalcSyntax['error'] = '语法错误';
$lang->metric->verifyCustom->checkCustomCalcClassName = array();
$lang->metric->verifyCustom->checkCustomCalcClassName['text'] = '检查度量项类名是否正确';
$lang->metric->verifyCustom->checkCustomCalcClassName['error'] = '度量项类名错误';
$lang->metric->verifyCustom->checkCustomCalcClassMethod = array();
$lang->metric->verifyCustom->checkCustomCalcClassMethod['text'] = '检查度量项是否定义了必须的方法';
$lang->metric->verifyCustom->checkCustomCalcClassMethod['error'] = '度量项没有定义必须的方法';
$lang->metric->verifyCustom->checkCustomCalcRuntime = array();
$lang->metric->verifyCustom->checkCustomCalcRuntime['text'] = '检查度量项运行时错误';
$lang->metric->verifyCustom->checkCustomCalcRuntime['error'] = '';
$lang->metric->weekList = array();
$lang->metric->weekList['1'] = '星期一';
+8 -28
View File
@@ -10,6 +10,10 @@ declare(strict_types=1);
* @link http://www.zentao.net
*/
namespace zin;
jsVar('metricId', $metric->id);
jsVar('code', $metric->code);
jsVar('verifyCustomMethods', $verifyCustom);
jsVar('isVerify', $isVerify);
detailHeader
(
@@ -33,30 +37,6 @@ detailHeader
)
);
$fnGenerateVerifyResult = function() use($verifyResult)
{
if(empty($verifyResult)) return null;
$results = array();
foreach($verifyResult as $result)
{
$class = 'verify-sentence';
$class .= $result->result ? ' pass' : ' error';
$icon = $result->result ? 'check' : 'close';
$results[] = p
(
setClass($class),
$result->tip,
icon
(
$icon
)
);
}
return $results;
};
$fnGenerateInstructions = function() use($lang)
{
$instructions = array();
@@ -143,8 +123,7 @@ panel
empty($result) ? div
(
setClass('verify-content'),
$fnGenerateVerifyResult()
) : $fnGenerateDataDisplay()
) : $fnGenerateDataDisplay(),
),
set::footerClass('footer-actions'),
@@ -152,8 +131,9 @@ panel
([
[
'type' => 'secondary',
'class' => 'btn-verify',
'text' => $lang->metric->verifyFile,
'url' => helper::createLink('metric', 'implement', "metricID={$metric->id}&isVerify=true")
'url' => helper::createLink('metric', 'implement', "metricID={$metric->id}")
],
[
'type' => 'primary',
@@ -161,7 +141,7 @@ panel
'btnType' => 'submit',
'disabled' => empty($result),
'url' => helper::createLink('metric', 'publish', "metricID={$metric->id}")
]
],
])
);