* seperate view and edit pages of language model parameters, part of task #94375.
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* The control file of ai module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @author Wenrui LI <liwenrui@easycorp.ltd>
|
||||
* @package ai
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
class ai extends control
|
||||
{
|
||||
/**
|
||||
* List models.
|
||||
*
|
||||
* TODO: not fully implemented yet, currently shows the only model config.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function models()
|
||||
{
|
||||
$modelConfig = new stdclass();
|
||||
$modelConfig->type = '';
|
||||
$modelConfig->key = '';
|
||||
$modelConfig->proxyType = '';
|
||||
$modelConfig->proxyAddr = '';
|
||||
$modelConfig->description = '';
|
||||
$modelConfig->status = '';
|
||||
|
||||
$storedModelConfig = $this->loadModel('setting')->getItems('owner=system&module=ai');
|
||||
foreach($storedModelConfig as $item) $modelConfig->{$item->key} = $item->value;
|
||||
|
||||
$this->view->modelConfig = $modelConfig;
|
||||
$this->view->title = $this->lang->ai->models->title;
|
||||
$this->view->position[] = $this->lang->ai->models->common;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit model configuration, store in system.ai settings.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function editModel()
|
||||
{
|
||||
if(strtolower($this->server->request_method) == 'post')
|
||||
{
|
||||
$modelConfig = fixer::input('post')->get();
|
||||
$this->loadModel('setting')->setItems('system.ai', $modelConfig);
|
||||
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->inlink('models') . '#app=admin'));
|
||||
}
|
||||
|
||||
$modelConfig = new stdclass();
|
||||
$modelConfig->type = '';
|
||||
$modelConfig->key = '';
|
||||
$modelConfig->proxyType = '';
|
||||
$modelConfig->proxyAddr = '';
|
||||
$modelConfig->description = '';
|
||||
$modelConfig->status = '';
|
||||
|
||||
$storedModelConfig = $this->loadModel('setting')->getItems('owner=system&module=ai');
|
||||
foreach($storedModelConfig as $item) $modelConfig->{$item->key} = $item->value;
|
||||
|
||||
$this->view->modelConfig = $modelConfig;
|
||||
$this->view->title = $this->lang->ai->models->title;
|
||||
$this->view->position[] = $this->lang->ai->models->common;
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* The ai module zh-cn file of ZenTaoPMS.
|
||||
* The ai module de file of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
@@ -25,6 +25,8 @@ $lang->ai->models->proxyType = 'Proxy Type';
|
||||
$lang->ai->models->proxyAddr = 'Proxy Address';
|
||||
$lang->ai->models->description = 'Description';
|
||||
$lang->ai->models->testConnection = 'Test Connection';
|
||||
$lang->ai->models->unconfigured = 'Unconfigured';
|
||||
$lang->ai->models->edit = 'Edit Parameters';
|
||||
|
||||
$lang->ai->models->statusList = array();
|
||||
$lang->ai->models->statusList['on'] = 'Enable';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* The ai module zh-cn file of ZenTaoPMS.
|
||||
* The ai module en file of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
@@ -25,6 +25,8 @@ $lang->ai->models->proxyType = 'Proxy Type';
|
||||
$lang->ai->models->proxyAddr = 'Proxy Address';
|
||||
$lang->ai->models->description = 'Description';
|
||||
$lang->ai->models->testConnection = 'Test Connection';
|
||||
$lang->ai->models->unconfigured = 'Unconfigured';
|
||||
$lang->ai->models->edit = 'Edit Parameters';
|
||||
|
||||
$lang->ai->models->statusList = array();
|
||||
$lang->ai->models->statusList['on'] = 'Enable';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* The ai module zh-cn file of ZenTaoPMS.
|
||||
* The ai module fr file of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
@@ -25,6 +25,8 @@ $lang->ai->models->proxyType = 'Proxy Type';
|
||||
$lang->ai->models->proxyAddr = 'Proxy Address';
|
||||
$lang->ai->models->description = 'Description';
|
||||
$lang->ai->models->testConnection = 'Test Connection';
|
||||
$lang->ai->models->unconfigured = 'Unconfigured';
|
||||
$lang->ai->models->edit = 'Edit Parameters';
|
||||
|
||||
$lang->ai->models->statusList = array();
|
||||
$lang->ai->models->statusList['on'] = 'Enable';
|
||||
|
||||
@@ -25,6 +25,8 @@ $lang->ai->models->proxyType = '代理类型';
|
||||
$lang->ai->models->proxyAddr = '代理地址';
|
||||
$lang->ai->models->description = '描述';
|
||||
$lang->ai->models->testConnection = '测试连接';
|
||||
$lang->ai->models->unconfigured = '未配置';
|
||||
$lang->ai->models->edit = '编辑模型参数';
|
||||
|
||||
$lang->ai->models->statusList = array();
|
||||
$lang->ai->models->statusList['on'] = '启用';
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* The ai editModels view file of ai module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @author Wenrui LI <liwenrui@easycorp.ltd>
|
||||
* @package ai
|
||||
* @link https://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<div id='mainContent' class='main-content'>
|
||||
<form class="load-indicator main-form form-ajax" method='post'>
|
||||
<table class='table table-form mw-800px'>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->type;?></th>
|
||||
<td><div class="required required-wrapper"></div><?php echo html::select('type', $lang->ai->models->typeList, $modelConfig->type, "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->apiKey;?></th>
|
||||
<td><div class="required required-wrapper"></div><?php echo html::input('key', $modelConfig->key, "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->proxyType;?></th>
|
||||
<td>
|
||||
<div class='row'>
|
||||
<div class='col-md-4'>
|
||||
<div class="required required-wrapper"></div>
|
||||
<?php echo html::select('proxyType', $lang->ai->models->proxyTypes, $modelConfig->proxyType, "class='form-control chosen' data-disable_search='true'");?>
|
||||
</div>
|
||||
<div class='col-md-8' id='proxyAddrContainer' <?php if(empty($modelConfig->proxyType)) echo 'style="display: none;"'; ?>>
|
||||
<div class='row'>
|
||||
<div class='col-md-3 text-right' style='padding-top: 6px;'><strong><?php echo $lang->ai->models->proxyAddr;?></strong></div>
|
||||
<div class='col-md-9'><div class="required required-wrapper"></div><?php echo html::input('proxyAddr', $modelConfig->proxyAddr, "class='form-control'");?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->description;?></th>
|
||||
<td><?php echo html::textarea('description', $modelConfig->description, "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->statusAB;?></th>
|
||||
<td><?php echo html::radio('status', $lang->ai->models->statusList, empty($modelConfig->status) ? 'on' : $modelConfig->status);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2' class='text-center'>
|
||||
<?php echo html::submitButton();?>
|
||||
<?php echo html::commonButton($lang->ai->models->testConnection, '', 'btn btn-secondary btn-wide');?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
$(function() {
|
||||
$('select[name="proxyType"]').change(function() {
|
||||
var proxyType = $(this).val();
|
||||
$('#proxyAddrContainer').toggle(proxyType != '');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
@@ -11,56 +11,36 @@
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<div id='mainContent' class='main-content'>
|
||||
<form class="load-indicator main-form form-ajax" method='post'>
|
||||
<table class='table table-form mw-800px'>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->type;?></th>
|
||||
<td><div class="required required-wrapper"></div><?php echo html::select('type', $lang->ai->models->typeList, $modelConfig->type, "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->apiKey;?></th>
|
||||
<td><div class="required required-wrapper"></div><?php echo html::input('key', $modelConfig->key, "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->proxyType;?></th>
|
||||
<td>
|
||||
<div class='row'>
|
||||
<div class='col-md-4'>
|
||||
<div class="required required-wrapper"></div>
|
||||
<?php echo html::select('proxyType', $lang->ai->models->proxyTypes, $modelConfig->proxyType, "class='form-control chosen' data-disable_search='true'");?>
|
||||
</div>
|
||||
<div class='col-md-8' id='proxyAddrContainer' <?php if(empty($modelConfig->proxyType)) echo 'style="display: none;"'; ?>>
|
||||
<div class='row'>
|
||||
<div class='col-md-3 text-right' style='padding-top: 6px;'><strong><?php echo $lang->ai->models->proxyAddr;?></strong></div>
|
||||
<div class='col-md-9'><div class="required required-wrapper"></div><?php echo html::input('proxyAddr', $modelConfig->proxyAddr, "class='form-control'");?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->description;?></th>
|
||||
<td><?php echo html::textarea('description', $modelConfig->description, "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->statusAB;?></th>
|
||||
<td><?php echo html::radio('status', $lang->ai->models->statusList, empty($modelConfig->status) ? 'on' : $modelConfig->status);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2' class='text-center'>
|
||||
<?php echo html::submitButton();?>
|
||||
<?php echo html::commonButton($lang->ai->models->testConnection, '', 'btn btn-secondary btn-wide');?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<table class='table table-form mw-600px'>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->type;?></th>
|
||||
<td><?php echo zget($lang->ai->models->typeList, $modelConfig->type, $lang->ai->models->unconfigured);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->apiKey;?></th>
|
||||
<td><?php echo $modelConfig->key;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->proxyType;?></th>
|
||||
<td><?php echo zget($lang->ai->models->proxyTypes, $modelConfig->proxyType, $lang->ai->models->unconfigured);?></td>
|
||||
</tr>
|
||||
<tr <?php if(empty($modelConfig->proxyType)) echo 'style="display: none;"'; ?>>
|
||||
<th><?php echo $lang->ai->models->proxyAddr;?></th>
|
||||
<td><?php echo $modelConfig->proxyAddr;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->description;?></th>
|
||||
<td><?php echo $modelConfig->description;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->statusAB;?></th>
|
||||
<td><?php echo zget($lang->ai->models->statusList, $modelConfig->status, $lang->ai->models->statusList['off']);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2' class='text-center'>
|
||||
<?php echo html::linkButton($lang->ai->models->edit, inlink('editmodel') . '#app=admin', 'self', '', 'btn btn-primary btn-wide');?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<script>
|
||||
$(function() {
|
||||
$('select[name="proxyType"]').change(function() {
|
||||
var proxyType = $(this).val();
|
||||
$('#proxyAddrContainer').toggle(proxyType != '');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
Reference in New Issue
Block a user