Skip to content

Commit

Permalink
fix exec dryExecute without save topolgy
Browse files Browse the repository at this point in the history
  • Loading branch information
baisui1981 committed Apr 25, 2023
1 parent 38a319f commit 30ffd61
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 92 deletions.
11 changes: 8 additions & 3 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

157 changes: 76 additions & 81 deletions src/offline/workflow.add.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import {NzModalService} from "ng-zorro-antd/modal";
import {NzDrawerService} from "ng-zorro-antd/drawer";
import {TerminalComponent} from "../common/terminal.component";
import {DataxDTO} from "../base/datax.add.component";
import {TisResponseResult} from "../common/tis.plugin";
// import {} from 'ng-sidebar';
// import {Droppable} from '@shopify/draggable';
// @ts-ignore
Expand Down Expand Up @@ -385,8 +386,65 @@ export class WorkflowAddComponent extends BasicWFComponent
// this._opened = true;
}

// 保存图形
executeWorkflow(dataflow: Dataflow, dryRun?: boolean) {
this._saveTopology().then((biz) => {
if(!biz.er){
dataflow.id = biz.biz.bizresult.id;
super.executeWorkflow(dataflow, dryRun);
}else{

}
})

}

saveTopology() {
this._saveTopology().then(r => {

let result = r.biz;

if (r.er) {
this.router.navigate(['/offline/wf']);
this.notification.create('success', '成功', result.msg[0]);
} else {

let biz = result.bizresult;
if (!biz.erExist) {
// 跳转到ER编辑Tab
this.modal.confirm({
nzTitle: '尚未定义ER关系,是否现在定义?',
nzCancelText: "跳过",
nzOkText: "开始",
nzOnOk: () => {
this.tabSelectedIndex = 1;
},
nzOnCancel: () => {
this.notifyAndRedirect(result);
}
});
return;
}
if (!biz.erPrimaryTabSet) {
this.modal.confirm({
nzTitle: '尚未定义DF的主表,是否现在定义主表?',
nzCancelText: "跳过",
nzOnOk: () => {
this.tabSelectedIndex = 1;
},
nzOnCancel: () => {
this.notifyAndRedirect(result);
}
});
return;
}
this.notifyAndRedirect(result);
}

});
}

// 保存图形
_saveTopology(): Promise<{ er: boolean, biz: TisResponseResult }> {
if (this.erRuleComponent) {
let g6 = this.erRuleComponent.g6Graph;
let dumpNodes: any[] = [];
Expand All @@ -403,7 +461,6 @@ export class WorkflowAddComponent extends BasicWFComponent
});
let deges: any[] = [];
g6._cfg.edges.forEach((r: any) => {
// console.log(r._cfg.model);
deges.push({
'id': r._cfg.model.id,
'sourceNode': r._cfg.model.sourceNode._cfg.model,
Expand All @@ -413,101 +470,39 @@ export class WorkflowAddComponent extends BasicWFComponent
});

let postData = {'nodes': dumpNodes, 'edges': deges, 'topologyName': this.topologyName};
// postData = $.extend(postData, {});
// console.log(postData);
this.jsonPost(`/offline/datasource.ajax?emethod=save_er_rule&action=offline_datasource_action`
, postData)
.then(result => {
if (result.success) {
this.router.navigate(['/offline/wf']);
this.notification.create('success', '成功', result.msg[0]);
}
});
return this.jsonPost(`/offline/datasource.ajax?emethod=save_er_rule&action=offline_datasource_action`, postData).then((result) => {
if (result.success) {
return {er: true, biz: result};
} else {
return Promise.reject();
}
});

} else {

let j = this.graph.save();
if (j.nodes.length < 1) {
this.notification.create('error', '错误', '请选择节点');
return;
}
// if (this.isAdd) {
// 打开输入名称对话框
//this.isSaveTopologyDialogVisible = true;
// } else {
this.applyTopology2Server(() => {
return this.applyTopology2Server().then(result => {
if (result.success) {
return {er: false, biz: result};
} else {
return Promise.reject();
}
});
//}
}
}

// handleSaveTopologyDialogCancel(evt: any) {
// this.isSaveTopologyDialogVisible = false;
// }

// submitSaveTopologyDialogForm() {
// for (const i in this.validateSaveTopologyDialogForm.controls) {
// this.validateSaveTopologyDialogForm.controls[i].markAsDirty();
// this.validateSaveTopologyDialogForm.controls[i].updateValueAndValidity();
// }
// }

handleSaveTopologyDialogOk() {
// this.submitSaveTopologyDialogForm();
// if (!this.validateSaveTopologyDialogForm.valid) {
// return;
// }
this.applyTopology2Server((topologyName) => {
// this.topologyName = topologyName;
});
}

private applyTopology2Server(saveSuccessCallback: (topologyName) => void): void {
private applyTopology2Server(): Promise<TisResponseResult> {
// 关闭对话框
// this.isSaveTopologyDialogVisible = false;
let j = this.graph.save();
j.topologyName = this.topologyName;
// console.log(j);
// console.log(`topologyName:${this.topologyName}`);
// j = $.extend(j, this.validateSaveTopologyDialogForm.getRawValue());
// if (!this.isAdd) {

// }
this.jsonPost(`/offline/datasource.ajax?emethod=${this.isAdd ? 'save' : 'update'}_topology&action=offline_datasource_action`, j)
.then(result => {
if (result.success) {
saveSuccessCallback(j.topologyName);
let biz = result.bizresult;
if (!biz.erExist) {
// 跳转到ER编辑Tab
this.modal.confirm({
nzTitle: '尚未定义ER关系,是否现在定义?',
nzCancelText: "跳过",
nzOkText: "开始",
nzOnOk: () => {
this.tabSelectedIndex = 1;
},
nzOnCancel: () => {
this.notifyAndRedirect(result);
}
});
return;
}
if (!biz.erPrimaryTabSet) {
this.modal.confirm({
nzTitle: '尚未定义DF的主表,是否现在定义主表?',
nzCancelText: "跳过",
nzOnOk: () => {
this.tabSelectedIndex = 1;
},
nzOnCancel: () => {
this.notifyAndRedirect(result);
}
});
return;
}
this.notifyAndRedirect(result);
}
});

return this.jsonPost(`/offline/datasource.ajax?emethod=${this.isAdd ? 'save' : 'update'}_topology&action=offline_datasource_action`, j);
}

private notifyAndRedirect(result) {
Expand Down
5 changes: 3 additions & 2 deletions src/offline/workflow.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class BasicWFComponent extends BasicFormComponent {
}

executeWorkflow(dataflow: Dataflow, dryRun?: boolean): void {

let action = `event_submit_do_execute_workflow=y&action=offline_datasource_action&id=${dataflow.id}&dryRun=${dryRun}`;
this.httpPost('/offline/datasource.ajax', action)
.then(d => {
Expand All @@ -50,7 +51,7 @@ export class BasicWFComponent extends BasicFormComponent {
let msg: any = [];
msg.push({
'content': '数据流构建已经触发'
, 'link': {'content': `查看构建状态(${taskid})`, 'href': `./build_history/${dataflow.id}/${taskid}`}
, 'link': {'content': `查看构建状态(${taskid})`, 'href': `/offline/wf_update/${dataflow.name}/build_history/${dataflow.id}/${taskid}`}
});

this.processResult({success: true, 'msg': msg});
Expand Down Expand Up @@ -199,7 +200,7 @@ export class WorkflowComponent extends BasicWFComponent implements OnInit {
let action = 'event_submit_do_delete_workflow_change=y&action=offline_datasource_action&id=' + id;
this.httpPost('/offline/datasource.ajax', action)
.then(result => {
console.log(result);
// console.log(result);
this.processResult(result);
if (result.success) {
// this.initWorkflows(result.bizresult);
Expand Down
12 changes: 6 additions & 6 deletions src/runtime/root-welcome-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {Application} from "../common/application";
<nz-content style=" opacity: 0.8;">
<div nz-row [nzGutter]="8">
<div nz-col nzSpan="8">
<nz-card [nzHoverable]="true" (click)="gotoIndexList()">
<nz-card id="pipeline" [nzHoverable]="true" (click)="gotoIndexList()">
<div class="tis-card-content">
<div class="compose">
<h1>实例</h1>
Expand All @@ -43,7 +43,7 @@ import {Application} from "../common/application";
</nz-card>
</div>
<div nz-col nzSpan="8">
<nz-card [nzHoverable]="true" (click)="routerTo('/offline/wf')">
<nz-card id="dataflow" [nzHoverable]="true" (click)="routerTo('/offline/wf')">
<div class="tis-card-content">
<div class="compose">
<h1><i nz-icon nzType="import" nzTheme="outline"></i>数据流</h1>
Expand All @@ -53,7 +53,7 @@ import {Application} from "../common/application";
</nz-card>
</div>
<div nz-col nzSpan="8">
<nz-card [nzHoverable]="true" (click)="routerTo('/offline/ds')">
<nz-card id="datasource" [nzHoverable]="true" (click)="routerTo('/offline/ds')">
<div class="tis-card-content">
<div class="compose">
<h1><i nz-icon nzType="database" nzTheme="outline"></i>数据源</h1>
Expand All @@ -65,7 +65,7 @@ import {Application} from "../common/application";
</div>
<div nz-row [nzGutter]="8">
<div nz-col nzSpan="8">
<nz-card [nzHoverable]="true" (click)="routerTo('/base/basecfg')">
<nz-card id="basecfg" [nzHoverable]="true" (click)="routerTo('/base/basecfg')">
<div class="tis-card-content">
<div class="compose">
<h1><i nz-icon nzType="setting" nzTheme="outline"></i>插件配置</h1>
Expand All @@ -75,7 +75,7 @@ import {Application} from "../common/application";
</nz-card>
</div>
<div nz-col nzSpan="8">
<nz-card [nzHoverable]="true" (click)="routerTo('/base/operationlog')">
<nz-card id="operationlog" [nzHoverable]="true" (click)="routerTo('/base/operationlog')">
<div class="tis-card-content">
<div class="compose">
<h1><i nz-icon nzType="snippets" nzTheme="outline"></i>操作日志</h1>
Expand All @@ -85,7 +85,7 @@ import {Application} from "../common/application";
</nz-card>
</div>
<div nz-col nzSpan="8">
<nz-card [nzHoverable]="true">
<nz-card id="users" [nzHoverable]="true">
<div class="tis-card-content">
<h1 class="compose"><i nz-icon nzType="user" nzTheme="outline"></i>会员</h1>
</div>
Expand Down

0 comments on commit 30ffd61

Please sign in to comment.