feat: application publish (#3342)
This commit is contained in:
parent
b496a2b2c5
commit
06e910b630
@ -599,6 +599,7 @@ class ApplicationOperateSerializer(serializers.Serializer):
|
|||||||
application.desc = node_data.get('desc')
|
application.desc = node_data.get('desc')
|
||||||
application.prologue = node_data.get('prologue')
|
application.prologue = node_data.get('prologue')
|
||||||
application.work_flow = work_flow
|
application.work_flow = work_flow
|
||||||
|
application.is_publish = True
|
||||||
application.save()
|
application.save()
|
||||||
work_flow_version = WorkFlowVersion(work_flow=work_flow, application=application,
|
work_flow_version = WorkFlowVersion(work_flow=work_flow, application=application,
|
||||||
name=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
name=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
@ -606,7 +607,7 @@ class ApplicationOperateSerializer(serializers.Serializer):
|
|||||||
publish_user_name=user.username,
|
publish_user_name=user.username,
|
||||||
workspace_id=workspace_id)
|
workspace_id=workspace_id)
|
||||||
work_flow_version.save()
|
work_flow_version.save()
|
||||||
return True
|
return self.one(with_valid=False)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def update_work_flow_model(instance):
|
def update_work_flow_model(instance):
|
||||||
@ -673,7 +674,8 @@ class ApplicationOperateSerializer(serializers.Serializer):
|
|||||||
if 'work_flow' in instance:
|
if 'work_flow' in instance:
|
||||||
# 修改语音配置相关
|
# 修改语音配置相关
|
||||||
self.update_work_flow_model(instance)
|
self.update_work_flow_model(instance)
|
||||||
|
if application.type == ApplicationTypeChoices.SIMPLE.value:
|
||||||
|
application.is_publish = True
|
||||||
update_keys = ['name', 'desc', 'model_id', 'multiple_rounds_dialogue', 'prologue', 'status',
|
update_keys = ['name', 'desc', 'model_id', 'multiple_rounds_dialogue', 'prologue', 'status',
|
||||||
'dataset_setting', 'model_setting', 'problem_optimization', 'dialogue_number',
|
'dataset_setting', 'model_setting', 'problem_optimization', 'dialogue_number',
|
||||||
'stt_model_id', 'tts_model_id', 'tts_model_enable', 'stt_model_enable', 'tts_type',
|
'stt_model_id', 'tts_model_id', 'tts_model_enable', 'stt_model_enable', 'tts_type',
|
||||||
|
|||||||
@ -11,6 +11,8 @@ urlpatterns = [
|
|||||||
path('workspace/<str:workspace_id>/application/<int:current_page>/<int:page_size>',
|
path('workspace/<str:workspace_id>/application/<int:current_page>/<int:page_size>',
|
||||||
views.ApplicationAPI.Page.as_view(), name='application_page'),
|
views.ApplicationAPI.Page.as_view(), name='application_page'),
|
||||||
path('workspace/<str:workspace_id>/application/<str:application_id>', views.ApplicationAPI.Operate.as_view()),
|
path('workspace/<str:workspace_id>/application/<str:application_id>', views.ApplicationAPI.Operate.as_view()),
|
||||||
|
path('workspace/<str:workspace_id>/application/<str:application_id>/publish',
|
||||||
|
views.ApplicationAPI.Publish.as_view()),
|
||||||
path('workspace/<str:workspace_id>/application/<str:application_id>/application_key',
|
path('workspace/<str:workspace_id>/application/<str:application_id>/application_key',
|
||||||
views.ApplicationKey.as_view()),
|
views.ApplicationKey.as_view()),
|
||||||
path('workspace/<str:workspace_id>/application/<str:application_id>/application_stats',
|
path('workspace/<str:workspace_id>/application/<str:application_id>/application_stats',
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
import {Result} from '@/request/Result'
|
import { Result } from '@/request/Result'
|
||||||
import {get, post, postStream, del, put, request, download, exportFile} from '@/request/index'
|
import { get, post, postStream, del, put, request, download, exportFile } from '@/request/index'
|
||||||
import type {pageRequest} from '@/api/type/common'
|
import type { pageRequest } from '@/api/type/common'
|
||||||
import type {ApplicationFormType} from '@/api/type/application'
|
import type { ApplicationFormType } from '@/api/type/application'
|
||||||
import {type Ref} from 'vue'
|
import { type Ref } from 'vue'
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
|
|
||||||
const prefix: any = {_value: '/workspace/'}
|
const prefix: any = { _value: '/workspace/' }
|
||||||
Object.defineProperty(prefix, 'value', {
|
Object.defineProperty(prefix, 'value', {
|
||||||
get: function () {
|
get: function () {
|
||||||
const {user} = useStore()
|
const { user } = useStore()
|
||||||
return this._value + user.getWorkspaceId() + '/application'
|
return this._value + user.getWorkspaceId() + '/application'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -199,7 +199,7 @@ const getPlatformStatus: (application_id: string) => Promise<Result<any>> = (app
|
|||||||
*/
|
*/
|
||||||
const updatePlatformStatus: (application_id: string, data: any) => Promise<Result<any>> = (
|
const updatePlatformStatus: (application_id: string, data: any) => Promise<Result<any>> = (
|
||||||
application_id,
|
application_id,
|
||||||
data
|
data,
|
||||||
) => {
|
) => {
|
||||||
return post(`${prefix.value}/${application_id}/platform/status`, data)
|
return post(`${prefix.value}/${application_id}/platform/status`, data)
|
||||||
}
|
}
|
||||||
@ -208,11 +208,23 @@ const updatePlatformStatus: (application_id: string, data: any) => Promise<Resul
|
|||||||
*/
|
*/
|
||||||
const getPlatformConfig: (application_id: string, type: string) => Promise<Result<any>> = (
|
const getPlatformConfig: (application_id: string, type: string) => Promise<Result<any>> = (
|
||||||
application_id,
|
application_id,
|
||||||
type
|
type,
|
||||||
) => {
|
) => {
|
||||||
return get(`${prefix.value}/${application_id}/platform/${type}`)
|
return get(`${prefix.value}/${application_id}/platform/${type}`)
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 应用发布
|
||||||
|
* @param application_id
|
||||||
|
* @param loading
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
const publish: (
|
||||||
|
application_id: string,
|
||||||
|
data: any,
|
||||||
|
loading?: Ref<boolean>,
|
||||||
|
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||||
|
return put(`${prefix.value}/${application_id}/publish`, data, {}, loading)
|
||||||
|
}
|
||||||
export default {
|
export default {
|
||||||
getAllApplication,
|
getAllApplication,
|
||||||
getApplication,
|
getApplication,
|
||||||
@ -231,5 +243,6 @@ export default {
|
|||||||
getApplicationSetting,
|
getApplicationSetting,
|
||||||
getPlatformStatus,
|
getPlatformStatus,
|
||||||
updatePlatformStatus,
|
updatePlatformStatus,
|
||||||
getPlatformConfig
|
getPlatformConfig,
|
||||||
|
publish,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
<AppIcon iconName="app-save-outlined" class="mr-4"></AppIcon>
|
<AppIcon iconName="app-save-outlined" class="mr-4"></AppIcon>
|
||||||
{{ $t('common.save') }}
|
{{ $t('common.save') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" @click="publicHandle">
|
<el-button type="primary" @click="publish">
|
||||||
{{ $t('views.applicationWorkflow.setting.public') }}
|
{{ $t('views.applicationWorkflow.setting.public') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
||||||
@ -256,29 +256,20 @@ function onmousedown(item: any) {
|
|||||||
function clickoutside() {
|
function clickoutside() {
|
||||||
showPopover.value = false
|
showPopover.value = false
|
||||||
}
|
}
|
||||||
async function publicHandle() {
|
const publish = () => {
|
||||||
// 后执行发布
|
const workflow = getGraphData()
|
||||||
workflowRef.value
|
const workflowInstance = new WorkFlowInstance(workflow)
|
||||||
?.validate()
|
try {
|
||||||
.then(async () => {
|
workflowInstance.is_valid()
|
||||||
const obj = {
|
} catch (e: any) {
|
||||||
work_flow: getGraphData(),
|
MsgError(e.toString())
|
||||||
}
|
return
|
||||||
await application.asyncPutApplication(id, obj, loading)
|
}
|
||||||
const workflow = new WorkFlowInstance(obj.work_flow)
|
applicationApi
|
||||||
try {
|
.publish(id, { work_flow: workflow }, loading)
|
||||||
workflow.is_valid()
|
.then((ok: any) => {
|
||||||
} catch (e: any) {
|
detail.value.name = ok.data.name
|
||||||
MsgError(e.toString())
|
MsgSuccess(t('views.applicationWorkflow.tip.publicSuccess'))
|
||||||
return
|
|
||||||
}
|
|
||||||
// applicationApi.putPublishApplication(id as string, obj, loading).then(() => {
|
|
||||||
|
|
||||||
// application.asyncGetApplicationDetail(id, loading).then((res: any) => {
|
|
||||||
// detail.value.name = res.data.name
|
|
||||||
// MsgSuccess(t('views.applicationWorkflow.tip.publicSuccess'))
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
})
|
})
|
||||||
.catch((res: any) => {
|
.catch((res: any) => {
|
||||||
const node = res.node
|
const node = res.node
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user