* Fix bugs.
This commit is contained in:
@@ -356,6 +356,37 @@ class instance extends control
|
||||
$this->locate($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建手工配置外部应用。
|
||||
* Create a external app.
|
||||
*
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return viod
|
||||
*/
|
||||
public function createExternalApp(string $type)
|
||||
{
|
||||
$this->app->loadModuleConfig('sonarqube');
|
||||
$this->app->loadLang('pipeline');
|
||||
|
||||
$externalApp = form::data($this->config->sonarqube->form->create)
|
||||
->add('type', $type)
|
||||
->add('private',md5(rand(10,113450)))
|
||||
->add('createdBy', $this->app->user->account)
|
||||
->add('createdDate', helper::now())
|
||||
->trim('url,account,password')
|
||||
->skipSpecial('url,token,account,password')
|
||||
->remove('token,appType')
|
||||
->get();
|
||||
if(!$this->instance->checkAppNameUnique($externalApp->name)) return $this->send(array('result' => false, 'message' => array('name' => sprintf($this->lang->error->repeat, $this->lang->pipeline->name, $externalApp->name))));
|
||||
|
||||
$appID = $this->loadModel('pipeline')->create($externalApp);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$this->loadModel('action')->create($type, $appID, 'created');
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('space', 'browse')));
|
||||
}
|
||||
|
||||
/**
|
||||
* (Not used at present.) Install app by custom settings.
|
||||
*
|
||||
@@ -414,6 +445,13 @@ class instance extends control
|
||||
|
||||
if(isset($this->config->instance->keepDomainList[$customData->customDomain]) || $this->instance->domainExists($customData->customDomain)) return $this->send(array('result' => 'fail', 'message' => $customData->customDomain . $this->lang->instance->errors->domainExists));
|
||||
|
||||
if(!$customData->customName)
|
||||
{
|
||||
dao::$errors['customName'] = sprintf($this->lang->error->notempty, $this->lang->instance->name);
|
||||
return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
}
|
||||
if(!$this->instance->checkAppNameUnique($customData->customName)) return $this->send(array('result' => false, 'message' => array('customName' => sprintf($this->lang->error->repeat, $this->lang->instance->name, $customData->customName))));
|
||||
|
||||
if(!validater::checkLength($customData->customDomain, 20, 2)) return $this->send(array('result' => 'fail', 'message' => $this->lang->instance->errors->domainLength));
|
||||
if(!validater::checkREG($customData->customDomain, '/^[a-z\d]+$/')) return $this->send(array('result' => 'fail', 'message' => $this->lang->instance->errors->wrongDomainCharacter));
|
||||
|
||||
|
||||
@@ -2064,4 +2064,19 @@ class InstanceModel extends model
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check app name unique.
|
||||
*
|
||||
* @param string $name
|
||||
* @access protected
|
||||
* @return bool
|
||||
*/
|
||||
public function checkAppNameUnique(string $name): bool
|
||||
{
|
||||
$existInstance = $this->dao->select('*')->from(TABLE_INSTANCE)->where('name')->eq($name)->andWhere('deleted')->eq(0)->fetch();
|
||||
$existExternal = $this->dao->select('*')->from(TABLE_PIPELINE)->where('name')->eq($name)->andWhere('deleted')->eq('0')->fetch();
|
||||
|
||||
return ($existInstance || $existExternal) ? false : true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ function onChangeAppType(event)
|
||||
{
|
||||
const appType = $(event.target).val();
|
||||
|
||||
if(appType == 'jenkins' || appType == 'sonarqube')
|
||||
if(appType == 'jenkins' || appType == 'sonarqube' || appType == 'nexus')
|
||||
{
|
||||
$('div.jenkins').removeClass('hidden');
|
||||
if(appType == 'jenkins')
|
||||
@@ -67,6 +67,9 @@ function onChangeAppType(event)
|
||||
$('#url').attr('placeholder', sonarqubeUrlTips);
|
||||
$('#account').attr('placeholder', sonarqubeAccountTips);
|
||||
break;
|
||||
case 'nexus':
|
||||
$('#createAppForm').attr('action', $.createLink('instance', 'createExternalApp', 'type=nexus'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +109,6 @@ function onChangeStoreAppType(event)
|
||||
|
||||
$('#app_version').val(app.app_version);
|
||||
$('#version').val(app.version);
|
||||
$('#customName').val(app.alias);
|
||||
if((app.dependencies.mysql && mysqlList) || (app.dependencies.postgresql && pgList))
|
||||
{
|
||||
$('div.dbType').removeClass('hidden');
|
||||
|
||||
@@ -28,3 +28,4 @@ $lang->space->appType['gitea'] = 'Gitea';
|
||||
$lang->space->appType['gogs'] = 'Gogs';
|
||||
$lang->space->appType['jenkins'] = 'Jenkins';
|
||||
$lang->space->appType['sonarqube'] = 'SonarQube';
|
||||
$lang->space->appType['nexus'] = 'Nexus';
|
||||
|
||||
@@ -31,3 +31,4 @@ $lang->space->appType['gitea'] = 'Gitea';
|
||||
$lang->space->appType['gogs'] = 'Gogs';
|
||||
$lang->space->appType['jenkins'] = 'Jenkins';
|
||||
$lang->space->appType['sonarqube'] = 'SonarQube';
|
||||
$lang->space->appType['nexus'] = 'Nexus';
|
||||
|
||||
@@ -37,19 +37,6 @@ if($config->inQuickon)
|
||||
$appID ? set::submitBtnText($lang->instance->install) : null,
|
||||
$appID ? set::actions(array('submit', array('text' => $lang->instance->stop, 'data-type' => 'submit', 'data-dismiss' => 'modal'))) : null,
|
||||
formRow
|
||||
(
|
||||
setStyle('display', $appID ? 'block' : 'none'),
|
||||
formGroup
|
||||
(
|
||||
set::width('2/3'),
|
||||
set::label($lang->instance->name),
|
||||
set::name('customName'),
|
||||
set::control('input'),
|
||||
set::value($appID ? $apps[$appID] : ''),
|
||||
set::required(true),
|
||||
)
|
||||
),
|
||||
formRow
|
||||
(
|
||||
setStyle('display', $appID ? 'none' : 'block'),
|
||||
formGroup
|
||||
@@ -79,6 +66,19 @@ if($config->inQuickon)
|
||||
on::change('onChangeType'),
|
||||
)
|
||||
),
|
||||
formRow
|
||||
(
|
||||
setStyle('display', 'block'),
|
||||
formGroup
|
||||
(
|
||||
set::width('2/3'),
|
||||
set::label($lang->instance->name),
|
||||
set::name('customName'),
|
||||
set::control('input'),
|
||||
set::value($appID ? $apps[$appID] : ''),
|
||||
set::required(true),
|
||||
)
|
||||
),
|
||||
$showVersion ? formGroup
|
||||
(
|
||||
set::width('2/3'),
|
||||
|
||||
Reference in New Issue
Block a user