Skip to content

Commit 879ad84

Browse files
committed
feat: application publish
1 parent 9c73c8d commit 879ad84

File tree

4 files changed

+45
-37
lines changed

4 files changed

+45
-37
lines changed

apps/application/serializers/application.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,14 +599,15 @@ def publish(self, instance, with_valid=True):
599599
application.desc = node_data.get('desc')
600600
application.prologue = node_data.get('prologue')
601601
application.work_flow = work_flow
602+
application.is_publish = True
602603
application.save()
603604
work_flow_version = WorkFlowVersion(work_flow=work_flow, application=application,
604605
name=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
605606
publish_user_id=user_id,
606607
publish_user_name=user.username,
607608
workspace_id=workspace_id)
608609
work_flow_version.save()
609-
return True
610+
return self.one(with_valid=False)
610611

611612
@staticmethod
612613
def update_work_flow_model(instance):
@@ -673,7 +674,8 @@ def edit(self, instance: Dict, with_valid=True):
673674
if 'work_flow' in instance:
674675
# 修改语音配置相关
675676
self.update_work_flow_model(instance)
676-
677+
if application.type == ApplicationTypeChoices.SIMPLE.value:
678+
application.is_publish = True
677679
update_keys = ['name', 'desc', 'model_id', 'multiple_rounds_dialogue', 'prologue', 'status',
678680
'dataset_setting', 'model_setting', 'problem_optimization', 'dialogue_number',
679681
'stt_model_id', 'tts_model_id', 'tts_model_enable', 'stt_model_enable', 'tts_type',

apps/application/urls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
path('workspace/<str:workspace_id>/application/<int:current_page>/<int:page_size>',
1212
views.ApplicationAPI.Page.as_view(), name='application_page'),
1313
path('workspace/<str:workspace_id>/application/<str:application_id>', views.ApplicationAPI.Operate.as_view()),
14+
path('workspace/<str:workspace_id>/application/<str:application_id>/publish',
15+
views.ApplicationAPI.Publish.as_view()),
1416
path('workspace/<str:workspace_id>/application/<str:application_id>/application_key',
1517
views.ApplicationKey.as_view()),
1618
path('workspace/<str:workspace_id>/application/<str:application_id>/application_stats',

ui/src/api/application/application.ts

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import {Result} from '@/request/Result'
2-
import {get, post, postStream, del, put, request, download, exportFile} from '@/request/index'
3-
import type {pageRequest} from '@/api/type/common'
4-
import type {ApplicationFormType} from '@/api/type/application'
5-
import {type Ref} from 'vue'
1+
import { Result } from '@/request/Result'
2+
import { get, post, postStream, del, put, request, download, exportFile } from '@/request/index'
3+
import type { pageRequest } from '@/api/type/common'
4+
import type { ApplicationFormType } from '@/api/type/application'
5+
import { type Ref } from 'vue'
66
import useStore from '@/stores'
77

8-
const prefix: any = {_value: '/workspace/'}
8+
const prefix: any = { _value: '/workspace/' }
99
Object.defineProperty(prefix, 'value', {
1010
get: function () {
11-
const {user} = useStore()
11+
const { user } = useStore()
1212
return this._value + user.getWorkspaceId() + '/application'
1313
},
1414
})
@@ -199,7 +199,7 @@ const getPlatformStatus: (application_id: string) => Promise<Result<any>> = (app
199199
*/
200200
const updatePlatformStatus: (application_id: string, data: any) => Promise<Result<any>> = (
201201
application_id,
202-
data
202+
data,
203203
) => {
204204
return post(`${prefix.value}/${application_id}/platform/status`, data)
205205
}
@@ -208,11 +208,23 @@ const updatePlatformStatus: (application_id: string, data: any) => Promise<Resul
208208
*/
209209
const getPlatformConfig: (application_id: string, type: string) => Promise<Result<any>> = (
210210
application_id,
211-
type
211+
type,
212212
) => {
213213
return get(`${prefix.value}/${application_id}/platform/${type}`)
214214
}
215-
215+
/**
216+
* 应用发布
217+
* @param application_id
218+
* @param loading
219+
* @returns
220+
*/
221+
const publish: (
222+
application_id: string,
223+
data: any,
224+
loading?: Ref<boolean>,
225+
) => Promise<Result<any>> = (application_id, data, loading) => {
226+
return put(`${prefix.value}/${application_id}/publish`, data, {}, loading)
227+
}
216228
export default {
217229
getAllApplication,
218230
getApplication,
@@ -231,5 +243,6 @@ export default {
231243
getApplicationSetting,
232244
getPlatformStatus,
233245
updatePlatformStatus,
234-
getPlatformConfig
246+
getPlatformConfig,
247+
publish,
235248
}

ui/src/views/application-workflow/index.vue

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<AppIcon iconName="app-save-outlined" class="mr-4"></AppIcon>
3737
{{ $t('common.save') }}
3838
</el-button>
39-
<el-button type="primary" @click="publicHandle">
39+
<el-button type="primary" @click="publish">
4040
{{ $t('views.applicationWorkflow.setting.public') }}
4141
</el-button>
4242

@@ -256,29 +256,20 @@ function onmousedown(item: any) {
256256
function clickoutside() {
257257
showPopover.value = false
258258
}
259-
async function publicHandle() {
260-
// 后执行发布
261-
workflowRef.value
262-
?.validate()
263-
.then(async () => {
264-
const obj = {
265-
work_flow: getGraphData(),
266-
}
267-
await application.asyncPutApplication(id, obj, loading)
268-
const workflow = new WorkFlowInstance(obj.work_flow)
269-
try {
270-
workflow.is_valid()
271-
} catch (e: any) {
272-
MsgError(e.toString())
273-
return
274-
}
275-
// applicationApi.putPublishApplication(id as string, obj, loading).then(() => {
276-
277-
// application.asyncGetApplicationDetail(id, loading).then((res: any) => {
278-
// detail.value.name = res.data.name
279-
// MsgSuccess(t('views.applicationWorkflow.tip.publicSuccess'))
280-
// })
281-
// })
259+
const publish = () => {
260+
const workflow = getGraphData()
261+
const workflowInstance = new WorkFlowInstance(workflow)
262+
try {
263+
workflowInstance.is_valid()
264+
} catch (e: any) {
265+
MsgError(e.toString())
266+
return
267+
}
268+
applicationApi
269+
.publish(id, { work_flow: workflow }, loading)
270+
.then((ok: any) => {
271+
detail.value.name = ok.data.name
272+
MsgSuccess(t('views.applicationWorkflow.tip.publicSuccess'))
282273
})
283274
.catch((res: any) => {
284275
const node = res.node

0 commit comments

Comments
 (0)