Skip to content

Commit

Permalink
feat: 增加应用profile 设置参数
Browse files Browse the repository at this point in the history
  • Loading branch information
shaohuzhang1 committed Sep 19, 2024
1 parent 204676f commit f2dae7b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 36 deletions.
16 changes: 15 additions & 1 deletion apps/application/serializers/application_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,19 @@ def profile(self, with_valid=True):
application_access_token = QuerySet(ApplicationAccessToken).filter(application_id=application.id).first()
if application_access_token is None:
raise AppUnauthorizedFailed(500, "非法用户")
application_setting_model = DBModelManage.get_model('application_setting')
X_PACK_LICENSE_IS_VALID = (settings.XPACK_LICENSE_IS_VALID if hasattr(settings,
'XPACK_LICENSE_IS_VALID') else False)
application_setting_dict = {}
if application_setting_model is not None and X_PACK_LICENSE_IS_VALID:
application_setting = QuerySet(application_setting_model).filter(
application_id=application_access_token.application_id).first()
application_setting_dict = {'show_source': application_access_token.show_source,
'show_history': application_setting.show_history,
'draggable': application_setting.draggable,
'show_guide': application_setting.show_guide,
'avatar': application_setting.avatar,
'float_icon': application_setting.float_icon}
return ApplicationSerializer.Query.reset_application(
{**ApplicationSerializer.ApplicationModel(application).data,
'stt_model_id': application.stt_model_id,
Expand All @@ -724,7 +737,8 @@ def profile(self, with_valid=True):
'tts_model_enable': application.tts_model_enable,
'tts_type': application.tts_type,
'work_flow': application.work_flow,
'show_source': application_access_token.show_source})
'show_source': application_access_token.show_source,
**application_setting_dict})

@transaction.atomic
def edit(self, instance: Dict, with_valid=True):
Expand Down
4 changes: 1 addition & 3 deletions apps/application/serializers/chat_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
from typing import Dict

import openpyxl
import xlwt
from django.core import validators
from django.core.cache import caches
from django.db import transaction, models
from django.db.models import QuerySet, Q
from django.http import HttpResponse, StreamingHttpResponse, HttpResponseServerError
from openpyxl.workbook import Workbook
from django.http import StreamingHttpResponse
from rest_framework import serializers

from application.flow.workflow_manage import Flow
Expand Down
14 changes: 1 addition & 13 deletions ui/src/api/application-xpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,7 @@ const putAccessToken: (
return put(`${prefix}/${application_id}/setting`, data, undefined, loading)
}

/**
* 对话获取应用相关信息
* @param 参数
{
"access_token": "string"
}
*/
const getAppXpackProfile: (loading?: Ref<boolean>) => Promise<any> = (loading) => {
return get(`${prefix}/xpack/profile`, undefined, loading)
}

export default {
getAccessToken,
putAccessToken,
getAppXpackProfile
putAccessToken
}
27 changes: 8 additions & 19 deletions ui/src/stores/modules/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,14 @@ const useApplicationStore = defineStore({
async asyncGetAppProfile(loading?: Ref<boolean>) {
return new Promise((resolve, reject) => {
const user = useUserStore()
if (user.isEnterprise()) {
applicationXpackApi
.getAppXpackProfile(loading)
.then((data) => {
resolve(data)
})
.catch((error) => {
reject(error)
})
} else {
applicationApi
.getAppProfile(loading)
.then((data) => {
resolve(data)
})
.catch((error) => {
reject(error)
})
}
applicationApi
.getAppProfile(loading)
.then((data) => {
resolve(data)
})
.catch((error) => {
reject(error)
})
})
},

Expand Down

0 comments on commit f2dae7b

Please sign in to comment.