* [task#152541] remove the useless code of ai.
This commit is contained in:
@@ -1,118 +0,0 @@
|
||||
$(function()
|
||||
{
|
||||
function markBusy()
|
||||
{
|
||||
$('input[type=submit]').attr('readonly', true).addClass('busy');
|
||||
$('textarea[name=message]').attr('readonly', true).addClass('busy');
|
||||
$('#retry').addClass('busy');
|
||||
$('#reset').addClass('busy');
|
||||
$('form').addClass('busy');
|
||||
}
|
||||
|
||||
function reset(e)
|
||||
{
|
||||
if($(e.target).hasClass('busy') || $(e.target).hasClass('disabled')) return;
|
||||
markBusy();
|
||||
$.ajax({
|
||||
url: createLink('ai', 'chat'),
|
||||
dataType: 'html',
|
||||
success: function(response)
|
||||
{
|
||||
$('.chat').html($($.parseHTML(response)).filter('.chat').html());
|
||||
init();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function retry(e)
|
||||
{
|
||||
if($(e.target).hasClass('busy')) return;
|
||||
markBusy();
|
||||
$.ajax({
|
||||
url: createLink('ai', 'chat'),
|
||||
type: 'POST',
|
||||
dataType: 'html',
|
||||
data: {retry: 'true', history: $('input[name=history]').val()},
|
||||
success: function(response)
|
||||
{
|
||||
$('.chat').html($($.parseHTML(response)).filter('.chat').html());
|
||||
init();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function init()
|
||||
{
|
||||
$('textarea[name=message]').keydown(function(e)
|
||||
{
|
||||
/* Send message on enter, allowing linebreak inputs. */
|
||||
if((e.keyCode == 13 || e.keyCode == 10))
|
||||
{
|
||||
if($(this).hasClass('busy')) return;
|
||||
|
||||
if(e.ctrlKey || e.metaKey)
|
||||
{
|
||||
$('textarea[name=message]').val($('textarea[name=message]').val() + '\n');
|
||||
$('textarea[name=message]').trigger('input');
|
||||
}
|
||||
else
|
||||
{
|
||||
if($('textarea[name=message]').val().trim().length == 0)
|
||||
{
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
$('form').submit();
|
||||
}
|
||||
}
|
||||
});
|
||||
$('form').on('submit', function(e)
|
||||
{
|
||||
if($(this).hasClass('busy')) return false;
|
||||
|
||||
/* Disable form and add message. */
|
||||
markBusy();
|
||||
const message = $('textarea[name=message]').val().trim();
|
||||
$('.messages').prepend("<div class='message-container-user'><div class='message-content'>" + message + '</div></div>');
|
||||
|
||||
/* Send message to server and re-render the chat. */
|
||||
e.preventDefault();
|
||||
$.ajax({
|
||||
url: createLink('ai', 'chat'),
|
||||
type: 'POST',
|
||||
data: {message, history: $('input[name=history]').val()},
|
||||
dataType: 'html',
|
||||
success: function(response)
|
||||
{
|
||||
$('.chat').html($($.parseHTML(response)).filter('.chat').html());
|
||||
init();
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#reset').click(reset);
|
||||
$('#retry').click(retry);
|
||||
$('textarea[name=message]').focus();
|
||||
$('textarea[name=message]').on('input', function()
|
||||
{
|
||||
/* Toggle send button. */
|
||||
const hasMessage = $(this).val().trim().length > 0;
|
||||
$('input[type=submit]').attr('disabled', !hasMessage).toggleClass('disabled', !hasMessage);
|
||||
|
||||
/* Resize textarea to fit content. */
|
||||
const clientHeight = +$(this).prop('clientHeight');
|
||||
const scrollHeight = +$(this).prop('scrollHeight');
|
||||
if(clientHeight < scrollHeight)
|
||||
{
|
||||
if(clientHeight < 150)
|
||||
{
|
||||
$(this).css('height', (scrollHeight + 2) + 'px');
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).addClass('has-scrollbar');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
init();
|
||||
});
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Chat view 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.lite.html.php';?>
|
||||
<div class="chat">
|
||||
<div class="messages">
|
||||
<?php
|
||||
if(!empty($error))
|
||||
{
|
||||
echo "<div class='message-container-error'><div class='message-content'>$error</div></div>";
|
||||
}
|
||||
$shownMessages = array_reverse(array_filter($messages, function($message) { return $message->role != 'system'; }));
|
||||
if(!empty($shownMessages))
|
||||
{
|
||||
foreach($shownMessages as $message)
|
||||
{
|
||||
if($message->role != 'system') echo "<div class='message-container-$message->role'><div class='message-content'>" . htmlspecialchars($message->content) . '</div></div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<div class='message-container-assistant'><div class='message-content'>{$lang->ai->chatPlaceholderMessage}</div></div>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="chat-input">
|
||||
<textarea name="message" placeholder="<?php echo $lang->ai->chatPlaceholderInput; ?>" autocomplete="off"></textarea>
|
||||
<input type="submit" value class="disabled" disabled />
|
||||
<input type="button" id="reset" <?php if(empty($shownMessages)) echo 'class="disabled"'; ?> value="<?php echo $lang->ai->chatReset; ?>" />
|
||||
</div>
|
||||
<input type="hidden" name="history" value="<?php echo htmlspecialchars(json_encode($messages)); ?>" />
|
||||
</form>
|
||||
</div>
|
||||
<?php include '../../common/view/footer.lite.html.php';?>
|
||||
@@ -3948,13 +3948,6 @@ $config->group->package->exportDatatable->subset = 'dataview';
|
||||
$config->group->package->exportDatatable->privs = array();
|
||||
$config->group->package->exportDatatable->privs['dataview-export'] = array('edition' => 'biz,max,ipd', 'vision' => 'rnd', 'order' => 30, 'depend' => array('dataview-browse', 'dataview-query'), 'recommend' => array());
|
||||
|
||||
/* Temporarily hide */
|
||||
// $config->group->package->aiChatting = new stdclass();
|
||||
// $config->group->package->aiChatting->order = 2020;
|
||||
// $config->group->package->aiChatting->subset = 'aiapp';
|
||||
// $config->group->package->aiChatting->privs = array();
|
||||
// $config->group->package->aiChatting->privs['ai-chat'] = array('edition' => 'open,biz,max,ipd', 'vision' => 'rnd,lite,or', 'order' => 10, 'depend' => array(), 'recommend' => array());
|
||||
|
||||
$config->group->package->aiConversation = new stdclass();
|
||||
$config->group->package->aiConversation->order = 2030;
|
||||
$config->group->package->aiConversation->subset = 'aiapp';
|
||||
|
||||
@@ -27,7 +27,6 @@ $config->index->oldPages[] = 'screen-burn';
|
||||
$config->index->oldPages[] = 'screen-viewold';
|
||||
$config->index->oldPages[] = 'screen-staticdataold';
|
||||
$config->index->oldPages[] = 'report-annualdata';
|
||||
$config->index->oldPages[] = 'ai-chat';
|
||||
$config->index->oldPages[] = 'api-debug';
|
||||
$config->index->oldPages[] = 'datatable-ajaxoldcustom';
|
||||
$config->index->oldPages[] = 'kanban-importticket';
|
||||
|
||||
Reference in New Issue
Block a user