diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessDefinitionController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessDefinitionController.java index aa7615fe74..aabd44b832 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessDefinitionController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessDefinitionController.java @@ -30,9 +30,11 @@ import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; +import javax.servlet.http.HttpServletResponse; import java.util.Map; import static cn.escheduler.api.enums.Status.*; +import static cn.escheduler.api.enums.Status.EXPORT_PROCESS_DEFINE_BY_ID_ERROR; /** @@ -430,4 +432,31 @@ public class ProcessDefinitionController extends BaseController{ } } + /** + * export process definition by id + * + * @param loginUser + * @param projectName + * @param processDefinitionId + * @return + */ + @ApiOperation(value = "exportProcessDefinitionById", notes= "EXPORT_PROCCESS_DEFINITION_BY_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100") + }) + @GetMapping(value="/export") + @ResponseBody + public void exportProcessDefinitionById(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @PathVariable String projectName, + @RequestParam("processDefinitionId") Integer processDefinitionId, + HttpServletResponse response){ + try{ + logger.info("export process definition by id, login user:{}, project name:{}, process definition id:{}", + loginUser.getUserName(), projectName, processDefinitionId); + processDefinitionService.exportProcessDefinitionById(loginUser, projectName, processDefinitionId,response); + }catch (Exception e){ + logger.error(EXPORT_PROCESS_DEFINE_BY_ID_ERROR.getMsg(),e); + } + } + } diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/ProjectController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/ProjectController.java index fbb650c42d..c0bc085d0f 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/ProjectController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/ProjectController.java @@ -18,6 +18,7 @@ package cn.escheduler.api.controller; import cn.escheduler.api.enums.Status; +import cn.escheduler.api.service.ProcessDefinitionService; import cn.escheduler.api.service.ProjectService; import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; @@ -32,6 +33,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import springfox.documentation.annotations.ApiIgnore; import java.util.Map; @@ -51,6 +53,9 @@ public class ProjectController extends BaseController { @Autowired private ProjectService projectService; + @Autowired + private ProcessDefinitionService processDefinitionService; + /** * create project * @@ -249,5 +254,30 @@ public class ProjectController extends BaseController { } } + /** + * import process definition + * + * @param loginUser + * @param file + * @return + */ + @ApiOperation(value = "importProcessDefinition", notes= "EXPORT_PROCCESS_DEFINITION_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "file", value = "RESOURCE_FILE", required = true, dataType = "MultipartFile") + }) + @PostMapping(value="/importProcessDefinition") + public Result importProcessDefinition(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @RequestParam("file") MultipartFile file){ + try{ + logger.info("import process definition by id, login user:{}", + loginUser.getUserName()); + Map result = processDefinitionService.importProcessDefinition(loginUser,file); + return returnDataList(result); + }catch (Exception e){ + logger.error(IMPORT_PROCESS_DEFINE_ERROR.getMsg(),e); + return error(IMPORT_PROCESS_DEFINE_ERROR.getCode(), IMPORT_PROCESS_DEFINE_ERROR.getMsg()); + } + } + } diff --git a/escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java b/escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java index bf2e4527a0..802dddfb99 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java @@ -213,6 +213,8 @@ public enum Status { BATCH_DELETE_PROCESS_DEFINE_ERROR(50025,"batch delete process definition error"), BATCH_DELETE_PROCESS_DEFINE_BY_IDS_ERROR(50026,"batch delete process definition by ids {0} error"), TENANT_NOT_SUITABLE(50027,"there is not any tenant suitable, please choose a tenant available."), + EXPORT_PROCESS_DEFINE_BY_ID_ERROR(50028,"export process definition by id error"), + IMPORT_PROCESS_DEFINE_ERROR(50029,"import process definition error"), HDFS_NOT_STARTUP(60001,"hdfs not startup"), HDFS_TERANT_RESOURCES_FILE_EXISTS(60002,"resource file exists,please delete resource first"), diff --git a/escheduler-api/src/main/java/cn/escheduler/api/service/ProcessDefinitionService.java b/escheduler-api/src/main/java/cn/escheduler/api/service/ProcessDefinitionService.java index 7b4b1ee063..897cab46a3 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/service/ProcessDefinitionService.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/service/ProcessDefinitionService.java @@ -21,10 +21,7 @@ import cn.escheduler.api.dto.treeview.TreeViewDto; import cn.escheduler.api.enums.Status; import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.PageInfo; -import cn.escheduler.common.enums.Flag; -import cn.escheduler.common.enums.ReleaseState; -import cn.escheduler.common.enums.TaskType; -import cn.escheduler.common.enums.UserType; +import cn.escheduler.common.enums.*; import cn.escheduler.common.graph.DAG; import cn.escheduler.common.model.TaskNode; import cn.escheduler.common.model.TaskNodeRelation; @@ -38,14 +35,25 @@ import cn.escheduler.dao.ProcessDao; import cn.escheduler.dao.mapper.*; import cn.escheduler.dao.model.*; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.core.JsonProcessingException; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; - +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -86,6 +94,12 @@ public class ProcessDefinitionService extends BaseDAGService { @Autowired private ProcessDao processDao; + @Autowired + private DataSourceMapper dataSourceMapper; + + @Autowired + private WorkerGroupMapper workerGroupMapper; + /** * create process definition * @@ -142,7 +156,7 @@ public class ProcessDefinitionService extends BaseDAGService { processDefine.setFlag(Flag.YES); processDefineMapper.insert(processDefine); putMsg(result, Status.SUCCESS); - + result.put("processDefinitionId",processDefine.getId()); return result; } @@ -504,6 +518,239 @@ public class ProcessDefinitionService extends BaseDAGService { return result; } + /** + * export process definition by id + * + * @param loginUser + * @param projectName + * @param processDefinitionId + * @return + */ + public void exportProcessDefinitionById(User loginUser, String projectName, Integer processDefinitionId, HttpServletResponse response) { + Project project = projectMapper.queryByName(projectName); + + Map checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName); + Status resultStatus = (Status) checkResult.get(Constants.STATUS); + if (resultStatus == Status.SUCCESS) { + ProcessDefinition processDefinition = processDefineMapper.queryByDefineId(processDefinitionId); + if (processDefinition != null) { + JSONObject jsonObject = JSONUtils.parseObject(processDefinition.getProcessDefinitionJson()); + JSONArray jsonArray = (JSONArray) jsonObject.get("tasks"); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject taskNode = jsonArray.getJSONObject(i); + if (taskNode.get("type") != null && taskNode.get("type") != "") { + String taskType = taskNode.getString("type"); + if(taskType.equals(TaskType.SQL.name()) || taskType.equals(TaskType.PROCEDURE.name())){ + JSONObject sqlParameters = JSONUtils.parseObject(taskNode.getString("params")); + DataSource dataSource = dataSourceMapper.queryById((Integer) sqlParameters.get("datasource")); + if (dataSource != null) { + sqlParameters.put("datasourceName", dataSource.getName()); + } + taskNode.put("params", sqlParameters); + } + } + } + jsonObject.put("tasks", jsonArray); + processDefinition.setProcessDefinitionJson(jsonObject.toString()); + + Map row = new LinkedHashMap<>(); + row.put("projectName", processDefinition.getProjectName()); + row.put("processDefinitionName", processDefinition.getName()); + row.put("processDefinitionJson", processDefinition.getProcessDefinitionJson()); + row.put("processDefinitionDesc", processDefinition.getDesc()); + row.put("processDefinitionLocations", processDefinition.getLocations()); + row.put("processDefinitionConnects", processDefinition.getConnects()); + + List schedules = scheduleMapper.queryByProcessDefinitionId(processDefinitionId); + if (schedules.size() > 0) { + Schedule schedule = schedules.get(0); + row.put("scheduleWarningType", schedule.getWarningType()); + row.put("scheduleWarningGroupId", schedule.getWarningGroupId()); + row.put("scheduleStartTime", schedule.getStartTime()); + row.put("scheduleEndTime", schedule.getEndTime()); + row.put("scheduleCrontab", schedule.getCrontab()); + row.put("scheduleFailureStrategy", schedule.getFailureStrategy()); + row.put("scheduleReleaseState", schedule.getReleaseState()); + row.put("scheduleProcessInstancePriority", schedule.getProcessInstancePriority()); + if(schedule.getId() == -1){ + row.put("scheduleWorkerGroupId", -1); + }else{ + WorkerGroup workerGroup = workerGroupMapper.queryById(schedule.getId()); + if(workerGroup != null){ + row.put("scheduleWorkerGroupName", workerGroup.getName()); + } + } + + } + String rowsJson = JSONUtils.toJsonString(row); + response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); + response.setHeader("Content-Disposition", "attachment;filename="+processDefinition.getName()+".json"); + BufferedOutputStream buff = null; + ServletOutputStream out = null; + try { + out = response.getOutputStream(); + buff = new BufferedOutputStream(out); + buff.write(rowsJson.getBytes("UTF-8")); + buff.flush(); + buff.close(); + } catch (IOException e) { + e.printStackTrace(); + }finally { + try { + buff.close(); + out.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } + + @Transactional(value = "TransactionManager", rollbackFor = Exception.class) + public Map importProcessDefinition(User loginUser, MultipartFile file) { + Map result = new HashMap<>(5); + + JSONObject json = null; + try(InputStreamReader inputStreamReader = new InputStreamReader( file.getInputStream(), "UTF-8" )) { + BufferedReader streamReader = new BufferedReader(inputStreamReader); + StringBuilder respomseStrBuilder = new StringBuilder(); + String inputStr = ""; + while ((inputStr = streamReader.readLine())!= null){ + respomseStrBuilder.append( inputStr ); + } + json = JSONObject.parseObject( respomseStrBuilder.toString() ); + if(json != null){ + String projectName = null; + String processDefinitionName = null; + String processDefinitionJson = null; + String processDefinitionDesc = null; + String processDefinitionLocations = null; + String processDefinitionConnects = null; + + String scheduleWarningType = null; + String scheduleWarningGroupId = null; + String scheduleStartTime = null; + String scheduleEndTime = null; + String scheduleCrontab = null; + String scheduleFailureStrategy = null; + String scheduleReleaseState = null; + String scheduleProcessInstancePriority = null; + String scheduleWorkerGroupId = null; + String scheduleWorkerGroupName = null; + + if (ObjectUtils.allNotNull(json.get("projectName"))) { + projectName = json.get("projectName").toString(); + } else { + putMsg(result, Status.DATA_IS_NULL, "processDefinitionName"); + } + if (ObjectUtils.allNotNull(json.get("processDefinitionName"))) { + processDefinitionName = json.get("processDefinitionName").toString(); + } else { + putMsg(result, Status.DATA_IS_NULL, "processDefinitionName"); + } + if (ObjectUtils.allNotNull(json.get("processDefinitionJson"))) { + processDefinitionJson = json.get("processDefinitionJson").toString(); + } else { + putMsg(result, Status.DATA_IS_NULL, "processDefinitionJson"); + } + if (ObjectUtils.allNotNull(json.get("processDefinitionDesc"))) { + processDefinitionDesc = json.get("processDefinitionDesc").toString(); + } + if (ObjectUtils.allNotNull(json.get("processDefinitionLocations"))) { + processDefinitionLocations = json.get("processDefinitionLocations").toString(); + } + if (ObjectUtils.allNotNull(json.get("processDefinitionConnects"))) { + processDefinitionConnects = json.get("processDefinitionConnects").toString(); + } + + JSONObject jsonObject = JSONUtils.parseObject(processDefinitionJson); + JSONArray jsonArray = (JSONArray) jsonObject.get("tasks"); + for (int j = 0; j < jsonArray.size(); j++) { + JSONObject taskNode = jsonArray.getJSONObject(j); + JSONObject sqlParameters = JSONUtils.parseObject(taskNode.getString("params")); + List dataSources = dataSourceMapper.queryDataSourceByName(sqlParameters.getString("datasourceName")); + if (dataSources.size() > 0) { + DataSource dataSource = dataSources.get(0); + sqlParameters.put("datasource", dataSource.getId()); + } + taskNode.put("params", sqlParameters); + } + jsonObject.put("tasks", jsonArray); + + Map createProcessDefinitionResult = createProcessDefinition(loginUser,projectName,processDefinitionName,jsonObject.toString(),processDefinitionDesc,processDefinitionLocations,processDefinitionConnects); + Integer processDefinitionId = null; + if (ObjectUtils.allNotNull(createProcessDefinitionResult.get("processDefinitionId"))) { + processDefinitionId = Integer.parseInt(createProcessDefinitionResult.get("processDefinitionId").toString()); + } + if (ObjectUtils.allNotNull(json.get("scheduleCrontab")) && processDefinitionId != null) { + Date now = new Date(); + Schedule scheduleObj = new Schedule(); + scheduleObj.setProjectName(projectName); + scheduleObj.setProcessDefinitionId(processDefinitionId); + scheduleObj.setProcessDefinitionName(processDefinitionName); + scheduleObj.setCreateTime(now); + scheduleObj.setUpdateTime(now); + scheduleObj.setUserId(loginUser.getId()); + scheduleObj.setUserName(loginUser.getUserName()); + + scheduleCrontab = json.get("scheduleCrontab").toString(); + scheduleObj.setCrontab(scheduleCrontab); + if (ObjectUtils.allNotNull(json.get("scheduleStartTime"))) { + scheduleStartTime = json.get("scheduleStartTime").toString(); + scheduleObj.setStartTime(DateUtils.stringToDate(scheduleStartTime)); + } + if (ObjectUtils.allNotNull(json.get("scheduleEndTime"))) { + scheduleEndTime = json.get("scheduleEndTime").toString(); + scheduleObj.setEndTime(DateUtils.stringToDate(scheduleEndTime)); + } + if (ObjectUtils.allNotNull(json.get("scheduleWarningType"))) { + scheduleWarningType = json.get("scheduleWarningType").toString(); + scheduleObj.setWarningType(WarningType.valueOf(scheduleWarningType)); + } + if (ObjectUtils.allNotNull(json.get("scheduleWarningGroupId"))) { + scheduleWarningGroupId = json.get("scheduleWarningGroupId").toString(); + scheduleObj.setWarningGroupId(Integer.parseInt(scheduleWarningGroupId)); + } + if (ObjectUtils.allNotNull(json.get("scheduleFailureStrategy"))) { + scheduleFailureStrategy = json.get("scheduleFailureStrategy").toString(); + scheduleObj.setFailureStrategy(FailureStrategy.valueOf(scheduleFailureStrategy)); + } + if (ObjectUtils.allNotNull(json.get("scheduleReleaseState"))) { + scheduleReleaseState = json.get("scheduleReleaseState").toString(); + scheduleObj.setReleaseState(ReleaseState.valueOf(scheduleReleaseState)); + } + if (ObjectUtils.allNotNull(json.get("scheduleProcessInstancePriority"))) { + scheduleProcessInstancePriority = json.get("scheduleProcessInstancePriority").toString(); + scheduleObj.setProcessInstancePriority(Priority.valueOf(scheduleProcessInstancePriority)); + } + if (ObjectUtils.allNotNull(json.get("scheduleWorkerGroupId"))) { + scheduleWorkerGroupId = json.get("scheduleWorkerGroupId").toString(); + if(scheduleWorkerGroupId != null){ + scheduleObj.setWorkerGroupId(Integer.parseInt(scheduleWorkerGroupId)); + }else{ + if (ObjectUtils.allNotNull(json.get("scheduleWorkerGroupName"))) { + scheduleWorkerGroupName = json.get("scheduleWorkerGroupName").toString(); + List workerGroups = workerGroupMapper.queryWorkerGroupByName(scheduleWorkerGroupName); + if(workerGroups.size() > 0){ + scheduleObj.setWorkerGroupId(workerGroups.get(0).getId()); + } + } + } + } + scheduleMapper.insert(scheduleObj); + } + }else{ + putMsg(result, Status.EXPORT_PROCESS_DEFINE_BY_ID_ERROR); + return result; + } + } catch (IOException e) { + throw new RuntimeException(e.getMessage(), e); + } + putMsg(result, Status.SUCCESS); + return result; + } + /** * check the process definition node meets the specifications diff --git a/escheduler-common/src/main/java/cn/escheduler/common/utils/JSONUtils.java b/escheduler-common/src/main/java/cn/escheduler/common/utils/JSONUtils.java index 9dad6ac542..f48c7306aa 100644 --- a/escheduler-common/src/main/java/cn/escheduler/common/utils/JSONUtils.java +++ b/escheduler-common/src/main/java/cn/escheduler/common/utils/JSONUtils.java @@ -226,6 +226,22 @@ public class JSONUtils { } } + public static JSONObject parseObject(String text) { + try{ + return JSONObject.parseObject(text); + } catch (Exception e) { + throw new RuntimeException("Json deserialization exception.", e); + } + } + + public static JSONArray parseArray(String text) { + try{ + return JSONObject.parseArray(text); + } catch (Exception e) { + throw new RuntimeException("Json deserialization exception.", e); + } + } + /** diff --git a/escheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/list.vue b/escheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/list.vue index f9e8dba231..f5eaddacc0 100644 --- a/escheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/list.vue +++ b/escheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/list.vue @@ -15,10 +15,10 @@ {{$t('State')}} - + {{$t('Create Time')}} - + {{$t('Update Time')}} @@ -27,7 +27,7 @@ {{$t('Timing state')}} - + {{$t('Operation')}} @@ -86,6 +86,8 @@ + + @@ -129,7 +131,7 @@ pageSize: Number }, methods: { - ...mapActions('dag', ['editProcessState', 'getStartCheck', 'getReceiver', 'deleteDefinition', 'batchDeleteDefinition']), + ...mapActions('dag', ['editProcessState', 'getStartCheck', 'getReceiver', 'deleteDefinition', 'batchDeleteDefinition','exportDefinition']), _rtPublishStatus (code) { return _.filter(publishStatus, v => v.code === code)[0].desc }, @@ -276,6 +278,14 @@ releaseState: 1 }) }, + _export (item) { + this.exportDefinition({ + processDefinitionId: item.id, + processDefinitionName: item.name + }).catch(e => { + this.$message.error(e.msg || '') + }) + }, /** * Edit state */ diff --git a/escheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/timing.vue b/escheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/timing.vue index 5262aac9fa..bdd9fa40ba 100644 --- a/escheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/timing.vue +++ b/escheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/timing.vue @@ -165,7 +165,7 @@ warningGroupId: {}, spinnerLoading: false, scheduleTime: '', - crontab: '* * * * * ? *', + crontab: '0 0 * * * ? *', cronPopover: false, receivers: [], receiversCc: [], diff --git a/escheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/index.vue b/escheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/index.vue index bf8612dd98..dbac9015d6 100644 --- a/escheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/index.vue +++ b/escheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/index.vue @@ -4,6 +4,8 @@ @@ -32,6 +34,7 @@ import mConditions from '@/module/components/conditions/conditions' import mSecondaryMenu from '@/module/components/secondaryMenu/secondaryMenu' import mListConstruction from '@/module/components/listConstruction/listConstruction' + import { findComponentDownward } from '@/module/util/' export default { name: 'definition-list-index', @@ -53,6 +56,12 @@ }, methods: { ...mapActions('dag', ['getProcessListP']), + /** + * File Upload + */ + _uploading () { + findComponentDownward(this.$root, 'roof-nav')._fileUpdate('DEFINITION') + }, /** * page */ @@ -82,6 +91,11 @@ }, _onUpdate () { this._debounceGET('false') + }, + _updateList () { + this.searchParams.pageNo = 1 + this.searchParams.searchVal = '' + this._debounceGET() } }, watch: { diff --git a/escheduler-ui/src/js/conf/home/store/dag/actions.js b/escheduler-ui/src/js/conf/home/store/dag/actions.js index c93505eead..7482dbed9b 100644 --- a/escheduler-ui/src/js/conf/home/store/dag/actions.js +++ b/escheduler-ui/src/js/conf/home/store/dag/actions.js @@ -496,6 +496,39 @@ export default { }) }) }, + /** + * export definition + */ + exportDefinition ({ state }, payload) { + const downloadBlob = (data, fileNameS = 'json') => { + if (!data) { + return + } + let blob = new Blob([data]) + let fileName = `${fileNameS}.json` + if ('download' in document.createElement('a')) { // 不是IE浏览器 + let url = window.URL.createObjectURL(blob) + let link = document.createElement('a') + link.style.display = 'none' + link.href = url + link.setAttribute('download', fileName) + document.body.appendChild(link) + link.click() + document.body.removeChild(link) // 下载完成移除元素 + window.URL.revokeObjectURL(url) // 释放掉blob对象 + } else { // IE 10+ + window.navigator.msSaveBlob(blob, fileName) + } + } + + io.get(`projects/${state.projectName}/process/export`,{processDefinitionId: payload.processDefinitionId,}, res => { + downloadBlob(res, payload.processDefinitionName) + }, e => { + + }, { + responseType: 'blob' + }) + }, /** * Process instance get variable */ diff --git a/escheduler-ui/src/js/module/components/fileUpdate/definitionUpdate.vue b/escheduler-ui/src/js/module/components/fileUpdate/definitionUpdate.vue new file mode 100644 index 0000000000..5bcc5f2101 --- /dev/null +++ b/escheduler-ui/src/js/module/components/fileUpdate/definitionUpdate.vue @@ -0,0 +1,264 @@ + + + + diff --git a/escheduler-ui/src/js/module/components/nav/nav.vue b/escheduler-ui/src/js/module/components/nav/nav.vue index 01d2c03960..149ed8464e 100644 --- a/escheduler-ui/src/js/module/components/nav/nav.vue +++ b/escheduler-ui/src/js/module/components/nav/nav.vue @@ -139,6 +139,7 @@ import { mapState, mapActions } from 'vuex' import { findComponentDownward } from '@/module/util/' import mFileUpdate from '@/module/components/fileUpdate/fileUpdate' + import mDefinitionUpdate from '@/module/components/fileUpdate/definitionUpdate' import mProgressBar from '@/module/components/progressBar/progressBar' import { findLocale, localeList } from '@/module/i18n/config' @@ -191,29 +192,55 @@ className: 'update-file-modal', transitionName: 'opacityp', render (h) { - return h(mFileUpdate, { - on: { - onProgress (val) { - self.progress = val + if(type === 'DEFINITION'){ + return h(mDefinitionUpdate, { + on: { + onProgress (val) { + self.progress = val + }, + onUpdate () { + findComponentDownward(self.$root, `definition-list-index`)._updateList() + self.isUpdate = false + self.progress = 0 + modal.remove() + }, + onArchive () { + self.isUpdate = true + }, + close () { + self.progress = 0 + modal.remove() + } }, - onUpdate () { - findComponentDownward(self.$root, `resource-list-index-${type}`)._updateList() - self.isUpdate = false - self.progress = 0 - modal.remove() - }, - onArchive () { - self.isUpdate = true + props: { + type: type + } + }) + }else{ + return h(mFileUpdate, { + on: { + onProgress (val) { + self.progress = val + }, + onUpdate () { + findComponentDownward(self.$root, `resource-list-index-${type}`)._updateList() + self.isUpdate = false + self.progress = 0 + modal.remove() + }, + onArchive () { + self.isUpdate = true + }, + close () { + self.progress = 0 + modal.remove() + } }, - close () { - self.progress = 0 - modal.remove() + props: { + type: type } - }, - props: { - type: type - } - }) + }) + } } }) }, @@ -247,7 +274,7 @@ computed: { ...mapState('user', ['userInfo']) }, - components: { mFileUpdate, mProgressBar } + components: { mFileUpdate, mProgressBar, mDefinitionUpdate } } diff --git a/escheduler-ui/src/js/module/i18n/locale/en_US.js b/escheduler-ui/src/js/module/i18n/locale/en_US.js index cea14afc1a..e90e7fcf6d 100644 --- a/escheduler-ui/src/js/module/i18n/locale/en_US.js +++ b/escheduler-ui/src/js/module/i18n/locale/en_US.js @@ -253,6 +253,7 @@ export default { 'Size': 'Size', 'Rename': 'Rename', 'Download': 'Download', + 'Export': 'Export', 'Submit': 'Submit', 'Edit UDF Function': 'Edit UDF Function', 'type': 'type', @@ -324,6 +325,7 @@ export default { 'Edit password': 'Edit password', 'Ordinary users': 'Ordinary users', 'Create process': 'Create process', + 'Import process': 'Import process', 'Timing state': 'Timing state', 'Timing': 'Timing', 'TreeView': 'TreeView', diff --git a/escheduler-ui/src/js/module/i18n/locale/zh_CN.js b/escheduler-ui/src/js/module/i18n/locale/zh_CN.js index 5e82ac63e9..7ac3dda87e 100644 --- a/escheduler-ui/src/js/module/i18n/locale/zh_CN.js +++ b/escheduler-ui/src/js/module/i18n/locale/zh_CN.js @@ -253,6 +253,7 @@ export default { 'Size': '大小', 'Rename': '重命名', 'Download': '下载', + 'Export': '导出', 'Submit': '提交', 'Edit UDF Function': '编辑UDF函数', 'type': '类型', @@ -324,6 +325,7 @@ export default { 'Edit password': '修改密码', 'Ordinary users': '普通用户', 'Create process': '创建工作流', + 'Import process': '导入工作流', 'Timing state': '定时状态', 'Timing': '定时', 'TreeView': '树形图',