mirror of
				https://github.com/1Panel-dev/1Panel.git
				synced 2025-10-31 19:26:02 +08:00 
			
		
		
		
	fix: Fix the issue of the container creation not popping up the task box (#7989)
This commit is contained in:
		
							parent
							
								
									79b8d17887
								
							
						
					
					
						commit
						d64ed8c718
					
				
					 4 changed files with 22 additions and 17 deletions
				
			
		|  | @ -804,10 +804,7 @@ func (u *ContainerService) StreamLogs(ctx *gin.Context, params dto.StreamLog) { | |||
| 		select { | ||||
| 		case msg, ok := <-messageChan: | ||||
| 			if !ok { | ||||
| 				if msg == "" { | ||||
| 					return true | ||||
| 				} | ||||
| 				return false | ||||
| 				return msg == "" | ||||
| 			} | ||||
| 			_, err := fmt.Fprintf(w, "data: %v\n\n", msg) | ||||
| 			if err != nil { | ||||
|  | @ -1495,12 +1492,12 @@ func loadContainerPortForInfo(itemPorts []types.Port) []dto.PortHelper { | |||
| 	var exposedPorts []dto.PortHelper | ||||
| 	samePortMap := make(map[string]dto.PortHelper) | ||||
| 	ports := transPortToStr(itemPorts) | ||||
| 	var itemPort dto.PortHelper | ||||
| 	for _, item := range ports { | ||||
| 		itemStr := strings.Split(item, "->") | ||||
| 		if len(itemStr) < 2 { | ||||
| 			continue | ||||
| 		} | ||||
| 		var itemPort dto.PortHelper | ||||
| 		lastIndex := strings.LastIndex(itemStr[0], ":") | ||||
| 		if lastIndex == -1 { | ||||
| 			itemPort.HostPort = itemStr[0] | ||||
|  |  | |||
|  | @ -49,6 +49,7 @@ export namespace Container { | |||
|         memory: number; | ||||
|     } | ||||
|     export interface ContainerHelper { | ||||
|         taskID: string; | ||||
|         containerID: string; | ||||
|         name: string; | ||||
|         image: string; | ||||
|  |  | |||
|  | @ -75,10 +75,10 @@ | |||
|                 </el-button> | ||||
|                 <el-button-group> | ||||
|                     <el-button :disabled="checkStatus('start', null)" @click="onOperate('start', null)"> | ||||
|                         {{ $t('app.start') }} | ||||
|                         {{ $t('commons.operate.start') }} | ||||
|                     </el-button> | ||||
|                     <el-button :disabled="checkStatus('stop', null)" @click="onOperate('stop', null)"> | ||||
|                         {{ $t('app.stop') }} | ||||
|                         {{ $t('commons.operate.stop') }} | ||||
|                     </el-button> | ||||
|                     <el-button :disabled="checkStatus('restart', null)" @click="onOperate('restart', null)"> | ||||
|                         {{ $t('commons.button.restart') }} | ||||
|  | @ -158,13 +158,13 @@ | |||
|                                             :disabled="checkStatus('start', row)" | ||||
|                                             @click="onOperate('start', row)" | ||||
|                                         > | ||||
|                                             {{ $t('app.start') }} | ||||
|                                             {{ $t('commons.operate.start') }} | ||||
|                                         </el-dropdown-item> | ||||
|                                         <el-dropdown-item | ||||
|                                             :disabled="checkStatus('stop', row)" | ||||
|                                             @click="onOperate('stop', row)" | ||||
|                                         > | ||||
|                                             {{ $t('app.stop') }} | ||||
|                                             {{ $t('commons.operate.stop') }} | ||||
|                                         </el-dropdown-item> | ||||
|                                         <el-dropdown-item | ||||
|                                             :disabled="checkStatus('restart', row)" | ||||
|  |  | |||
|  | @ -196,7 +196,7 @@ | |||
|                                 <el-tab-pane :label="$t('container.mount')"> | ||||
|                                     <el-form-item> | ||||
|                                         <el-table v-if="form.volumes.length !== 0" :data="form.volumes"> | ||||
|                                             <el-table-column :label="$t('container.server')" min-width="120"> | ||||
|                                             <el-table-column :label="$t('container.server')" min-width="150"> | ||||
|                                                 <template #default="{ row }"> | ||||
|                                                     <el-radio-group v-model="row.type"> | ||||
|                                                         <el-radio-button value="volume"> | ||||
|  | @ -234,7 +234,7 @@ | |||
|                                                     <el-input v-else v-model="row.sourceDir" /> | ||||
|                                                 </template> | ||||
|                                             </el-table-column> | ||||
|                                             <el-table-column :label="$t('container.mode')" min-width="120"> | ||||
|                                             <el-table-column :label="$t('container.mode')" min-width="130"> | ||||
|                                                 <template #default="{ row }"> | ||||
|                                                     <el-radio-group v-model="row.mode"> | ||||
|                                                         <el-radio value="rw">{{ $t('container.modeRW') }}</el-radio> | ||||
|  | @ -425,6 +425,7 @@ | |||
|         </LayoutContent> | ||||
|         <Command ref="commandRef" /> | ||||
|         <Confirm ref="confirmRef" @submit="submit" /> | ||||
|         <TaskLog ref="taskLogRef" width="70%" /> | ||||
|     </div> | ||||
| </template> | ||||
| 
 | ||||
|  | @ -446,14 +447,16 @@ import { | |||
|     loadContainerInfo, | ||||
| } from '@/api/modules/container'; | ||||
| import { Container } from '@/api/interface/container'; | ||||
| import { MsgError, MsgSuccess } from '@/utils/message'; | ||||
| import { checkIpV4V6, checkPort } from '@/utils/util'; | ||||
| import { MsgError } from '@/utils/message'; | ||||
| import TaskLog from '@/components/task-log/index.vue'; | ||||
| import { checkIpV4V6, checkPort, newUUID } from '@/utils/util'; | ||||
| import router from '@/routers'; | ||||
| 
 | ||||
| const loading = ref(false); | ||||
| const isCreate = ref(); | ||||
| const confirmRef = ref(); | ||||
| const form = reactive<Container.ContainerHelper>({ | ||||
|     taskID: '', | ||||
|     containerID: '', | ||||
|     name: '', | ||||
|     image: '', | ||||
|  | @ -557,6 +560,7 @@ const search = async () => { | |||
| }; | ||||
| 
 | ||||
| const commandRef = ref(); | ||||
| const taskLogRef = ref(); | ||||
| const images = ref(); | ||||
| const volumes = ref(); | ||||
| const networks = ref(); | ||||
|  | @ -654,6 +658,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => { | |||
| }; | ||||
| const submit = async () => { | ||||
|     form.cmd = []; | ||||
|     form.taskID = newUUID(); | ||||
|     if (form.cmdStr) { | ||||
|         let itemCmd = splitStringIgnoringQuotes(form.cmdStr); | ||||
|         for (const item of itemCmd) { | ||||
|  | @ -682,8 +687,7 @@ const submit = async () => { | |||
|         await createContainer(form) | ||||
|             .then(() => { | ||||
|                 loading.value = false; | ||||
|                 MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); | ||||
|                 goBack(); | ||||
|                 openTaskLog(form.taskID); | ||||
|             }) | ||||
|             .catch(() => { | ||||
|                 loading.value = false; | ||||
|  | @ -692,8 +696,7 @@ const submit = async () => { | |||
|         await updateContainer(form) | ||||
|             .then(() => { | ||||
|                 loading.value = false; | ||||
|                 MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); | ||||
|                 goBack(); | ||||
|                 openTaskLog(form.taskID); | ||||
|             }) | ||||
|             .catch(() => { | ||||
|                 updateContainerID(); | ||||
|  | @ -702,6 +705,10 @@ const submit = async () => { | |||
|     } | ||||
| }; | ||||
| 
 | ||||
| const openTaskLog = (taskID: string) => { | ||||
|     taskLogRef.value.openWithTaskID(taskID); | ||||
| }; | ||||
| 
 | ||||
| const updateContainerID = async () => { | ||||
|     let params = { | ||||
|         page: 1, | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue