diff --git a/src/base/datax.worker.add.step3.component.ts b/src/base/datax.worker.add.step3.component.ts
index a1c6af0..ee83b4e 100644
--- a/src/base/datax.worker.add.step3.component.ts
+++ b/src/base/datax.worker.add.step3.component.ts
@@ -16,94 +16,173 @@
* limitations under the License.
*/
-import {AfterViewInit, Component, EventEmitter, Input, OnInit, Output, ViewChild} from "@angular/core";
-import {TISService} from "../common/tis.service";
-import {AppFormComponent, BasicFormComponent, CurrentCollection} from "../common/basic.form.component";
-
-import {ActivatedRoute} from "@angular/router";
+import {
+ AfterContentInit,
+ AfterViewInit,
+ Component,
+ EventEmitter,
+ Input, NgZone,
+ OnDestroy,
+ OnInit,
+ Output,
+ ViewChild
+} from "@angular/core";
+import {EventSourceSubject, EventType, ExecuteStep, MessageData, TISService} from "../common/tis.service";
+import {BasicFormComponent, CurrentCollection} from "../common/basic.form.component";
import {NzModalService} from "ng-zorro-antd/modal";
import {NzNotificationService} from "ng-zorro-antd/notification";
import {K8SReplicsSpecComponent} from "../common/k8s.replics.spec.component";
-import {DataXJobWorkerStatus, DataxWorkerDTO} from "../runtime/misc/RCDeployment";
-import {SavePluginEvent} from "../common/tis.plugin";
-import {PowerjobCptType} from "./datax.worker.component";
+import {DataxWorkerDTO, ScalaLog} from "../runtime/misc/RCDeployment";
+import {DataxWorkerComponent, PowerjobCptType} from "./datax.worker.component";
+import {NzDrawerRef, NzDrawerService} from "ng-zorro-antd/drawer";
+import {NgTerminal} from "ng-terminal";
+import {Subscription} from "rxjs";
+import {HeteroList} from "../common/tis.plugin";
+import {NzStatusType} from "ng-zorro-antd/steps/steps.component";
+
@Component({
+ selector: 'k8s-res-config',
template: `
-
-
-
-
-
-
-
-
PowerJob-Server
-
-
-
-
-
-
-
-
-
- PowerJob-Worker
-
-
-
-
-
-
+
+
+
+
+
+
+
+
- PowerJob-Job
-
-
-
+
+
+
+ {{cpt.cptType.toString()}}
+
+
+ 基本配置
+
+
+
+
+
+
+
+
+
-
+
+
+
+ 资源规格
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
`
, styles: [
`
`]
})
-export class DataxWorkerAddStep3Component extends BasicFormComponent implements AfterViewInit, OnInit {
+export class DataxWorkerAddStep3Component extends BasicFormComponent implements AfterViewInit, OnInit, OnDestroy {
savePlugin = new EventEmitter();
@ViewChild('k8sReplicsSpec', {read: K8SReplicsSpecComponent, static: true}) k8sReplicsSpec: K8SReplicsSpecComponent;
@Output() nextStep = new EventEmitter();
@Output() preStep = new EventEmitter();
@Input() dto: DataxWorkerDTO;
- constructor(tisService: TISService, modalService: NzModalService, notification: NzNotificationService) {
+ @Input() displayHeader = true;
+
+ constructor(tisService: TISService, modalService: NzModalService, notification: NzNotificationService, private drawerService: NzDrawerService) {
super(tisService, modalService, notification);
}
ngOnInit(): void {
- if (this.dto.processMeta.supportK8SReplicsSpecSetter && !this.dto.usingPowderJobUseExistCluster && !this.dto.powderJobServerRCSpec) {
+ // console.log(this.dto);
+ if (this.dto.processMeta.supportK8SReplicsSpecSetter && !this.dto.usingPowderJobUseExistCluster && !this.dto.primaryRCSpec) {
throw new Error("rcSpec can not be null");
}
- // console.log(this.dto.processMeta);
+
let appTisService: TISService = this.tisService;
+ // console.log(this.dto);
appTisService.currentApp = new CurrentCollection(0, this.dto.processMeta.targetName);
+
}
get currentApp(): CurrentCollection {
@@ -111,23 +190,75 @@ export class DataxWorkerAddStep3Component extends BasicFormComponent implements
return new CurrentCollection(0, this.dto.processMeta.targetName);
}
+ // private drawerRef: NzDrawerRef
+
+
launchK8SController() {
- let e = new SavePluginEvent();
- e.notShowBizMsg = true;
- this.jsonPost(`/coredefine/corenodemanage.ajax?action=datax_action&emethod=launch_datax_worker&targetName=${this.dto.processMeta.targetName}`
- , {}, e)
- .then((r) => {
- if (r.success) {
- this.successNotify("已经成功在K8S集群中启动" + this.dto.processMeta.pageHeader);
- let dataXWorkerStatus: DataXJobWorkerStatus
- = Object.assign(new DataXJobWorkerStatus(), r.bizresult, {'processMeta': this.dto.processMeta});
- this.nextStep.emit(dataXWorkerStatus);
- }
- });
+ // console.log(this.dto);
+ let subject = DataxWorkerAddStep3Component.createLaunchingEventSubject(this.dto.processMeta.launchClusterMethod, this.tisService, this.dto.processMeta.targetName);
+
+
+ const drawerRef = this.drawerService.create({
+ nzWidth: "60%",
+ nzHeight: "100%",
+ nzPlacement: "right",
+ nzContent: LaunchK8SClusterWaittingProcessComponent,
+ nzContentParams: {"obserable": subject},
+ nzClosable: false,
+ nzMaskClosable: false
+ });
+
+ drawerRef.afterClose.subscribe((status: NzStatusType) => {
+ subject.close();
+ if (status === 'finish') {
+ this.successNotify("已经成功在K8S集群中启动" + this.dto.processMeta.pageHeader);
+ // let dataXWorkerStatus: DataXJobWorkerStatus
+ // = Object.assign(new DataXJobWorkerStatus(), r.bizresult, {'processMeta': this.dto.processMeta});
+
+ DataxWorkerComponent.getJobWorkerMeta(this, this.dto.processMeta)
+ .then((dataXWorkerStatus) => {
+ this.nextStep.emit(dataXWorkerStatus);
+ });
+
+
+ }
+ })
+
+ // let e = new SavePluginEvent();
+ // e.notShowBizMsg = true;
+ //
+ // this.jsonPost(`/coredefine/corenodemanage.ajax?action=datax_action&emethod=launch_datax_worker&targetName=${this.dto.processMeta.targetName}`
+ // , {'usingPowderJobUseExistCluster': this.dto.usingPowderJobUseExistCluster}, e)
+ // .then((r) => {
+ // if (r.success) {
+ // this.successNotify("已经成功在K8S集群中启动" + this.dto.processMeta.pageHeader);
+ // let dataXWorkerStatus: DataXJobWorkerStatus
+ // = Object.assign(new DataXJobWorkerStatus(), r.bizresult, {'processMeta': this.dto.processMeta});
+ // this.nextStep.emit(dataXWorkerStatus);
+ // }
+ // });
+ }
+
+ /**
+ * 'launch_datax_worker'
+ * @param targetMethodName
+ * @param tisService
+ * @param targetName
+ */
+ public static createLaunchingEventSubject(targetMethodName: string, tisService: TISService, targetName: string, extraParams?: string): EventSourceSubject {
+ let sseUrl = `/coredefine/corenodemanage.ajax?resulthandler=exec_null&action=datax_action&emethod=${targetMethodName}&targetName=${targetName}`;
+ if (extraParams) {
+ sseUrl += ('&' + extraParams);
+ }
+ return tisService.createEventSource(targetName, sseUrl);
+
+ }
+
+ ngOnDestroy(): void {
}
protected initialize(app: CurrentCollection): void {
- console.log(app);
+ // console.log(app);
}
ngAfterViewInit() {
@@ -141,3 +272,244 @@ export class DataxWorkerAddStep3Component extends BasicFormComponent implements
public readonly PowerjobCptType = PowerjobCptType;
}
+/**
+ * private _zone: NgZone
+ */
+@Component({
+ selector: "k8s-cluster-launching",
+ template: `
+
+
+
+
+
+
+
+
+ 启动执行状态
+
+
+
+
+
+
+
+
+
+
+
+
+ `
+ , styles: [
+ `
+ .process-height {
+ height: 800px
+ }
+
+ nz-page-header {
+ padding: 0 0 0 20px;
+ }
+ `
+ ]
+})
+export class LaunchK8SClusterWaittingProcessComponent implements OnInit, OnDestroy, AfterViewInit {
+
+ @ViewChild('term', {static: true}) terminal: NgTerminal;
+ @Input()
+ obserable: EventSourceSubject;
+
+ execSteps: Array = [];
+
+ _execStatus: NzStatusType;
+ _currentExecIndex: number = -1;
+ formDisabled: boolean = true;
+
+ @Input()
+ errScalaLog: ScalaLog;
+
+ constructor(private drawer: NzDrawerRef<{ hetero: HeteroList }>, protected tisService: TISService, public _zone: NgZone) {
+ }
+
+ get execStatus(): NzStatusType {
+ if (!this._execStatus && this.execSteps.length > 0) {
+ let execStep: ExecuteStep = null;
+ let allComplete = true;
+ // console.log(this.execSteps);
+ for (let i = 0; i < this.execSteps.length; i++) {
+ execStep = this.execSteps[i];
+ if (execStep.complete) {
+ if (!execStep.success) {
+ this.execSteps.forEach((s) => s._processing = false);
+ return this._execStatus = 'error'
+
+ }
+ } else {
+ allComplete = false;
+ }
+ }
+ return this._execStatus = allComplete ? 'finish' : 'process';
+ }
+ return this._execStatus;
+ }
+
+ get index(): number {
+ let execStepsLength = this.execSteps.length;
+ if (this._currentExecIndex < 0 && execStepsLength > 0) {
+ let execStep: ExecuteStep = null;
+ try {
+ for (let i = execStepsLength - 1; i >= 0; i--) {
+ execStep = this.execSteps[i];
+ if (execStep.complete) {
+ this._currentExecIndex = i;
+ // 设置当前步骤的后一步为执行的状态
+ if (execStep.success && (i + 1) <= (execStepsLength - 1)) {
+ this.execSteps.forEach((s) => s._processing = false);
+ this.execSteps[i + 1]._processing = true;
+ }
+ return this._currentExecIndex;
+ }
+ }
+ } catch (e) {
+ throw e;
+ }
+ return this._currentExecIndex = 0;
+ }
+ return this._currentExecIndex;
+ }
+
+ private subscript: Subscription;
+
+ ngAfterViewInit(): void {
+ if (this.errScalaLog) {
+ // console.log(this.errScalaLog);
+ //this._zone.runOutsideAngular(()=>{
+
+
+ // throw new Error("errScalaLog shall not be empty");
+ this.errScalaLog.logs.forEach((log) => {
+ if (log) {
+ this.terminal.write(log.msg + "\r\n");
+ }
+ });
+ //});
+
+ }
+ }
+
+
+ reExecute() {
+ this.subscript.unsubscribe();
+ this.obserable.close();
+ this.resortInitState();
+ this.execSteps = [];
+ this.formDisabled = true;
+ this.obserable = DataxWorkerAddStep3Component.createLaunchingEventSubject(
+ "relaunch_datax_worker", this.tisService, this.obserable.targetResName);
+ this.ngOnInit();
+ }
+
+ ngOnInit(): void {
+ // console.log(this.obserable);
+ if (!this.obserable) {
+ this.formDisabled = false;
+ if (this.errScalaLog) {
+ this._execStatus = this.errScalaLog.faild ? 'error' : 'finish';
+ this.execSteps = [];
+ this.errScalaLog.milestones.forEach((mile) => {
+ let et = new ExecuteStep();
+ et.success = mile.success;
+ et.name = mile.name;
+ et.complete = mile.complete;
+ et.describe = mile.describe;
+ this.execSteps.push(et);
+ });
+ }
+ return;
+ }
+ this.subscript = this.obserable.events.subscribe((msg: [EventType, Array | MessageData | ExecuteStep]) => {
+ // console.log(msg[0]);
+ // console.log(msg[1]);
+
+ switch (msg[0]) {
+ case EventType.LOG_MESSAGE:
+ let msgLog: MessageData = msg[1];
+ this.terminal.write(msgLog.msg + "\r\n");
+ break;
+ case EventType.TASK_EXECUTE_STEPS:
+ let steps = >msg[1];
+ let copys = [];
+ for (let i = 0; i < steps.length; i++) {
+ copys.push(Object.assign(new ExecuteStep(), steps[i]));
+ }
+ this.execSteps = copys;
+ this.formDisabled = false;
+ break;
+ case EventType.TASK_MILESTONE:
+
+ let execStep = Object.assign(new ExecuteStep(), msg[1]);
+ let idxOf = this.execSteps.findIndex((s) => s.name === execStep.name);
+
+ if (idxOf > -1) {
+ this.execSteps[idxOf] = execStep;
+ this.resortInitState();
+ }
+ // console.log([execStep, idxOf, this.execStatus, this.index])
+ break;
+ case EventType.SSE_CLOSE:
+ break;
+ default:
+ throw new Error("err event type:" + msg[0]);
+ }
+ }, (err) => {
+ console.log(err);
+ });
+ }
+
+ private resortInitState() {
+ this._currentExecIndex = -1;
+ this._execStatus = undefined;
+ this.execStatus;
+ this.index;
+ }
+
+ ngOnDestroy(): void {
+ if (this.subscript) {
+ this.subscript.unsubscribe();
+ }
+ }
+
+ active(event: any) {
+ }
+
+ onIndexChange($event: number) {
+
+ }
+
+ closeDrawer() {
+ this.drawer.close(this.execStatus);
+ }
+
+
+}
+
diff --git a/src/base/datax.worker.component.ts b/src/base/datax.worker.component.ts
index 0095c3b..fd8017a 100644
--- a/src/base/datax.worker.component.ts
+++ b/src/base/datax.worker.component.ts
@@ -26,7 +26,7 @@ import {
ViewContainerRef
} from "@angular/core";
import {TISService} from "../common/tis.service";
-import {AppFormComponent, CurrentCollection} from "../common/basic.form.component";
+import {AppFormComponent, BasicFormComponent, CurrentCollection} from "../common/basic.form.component";
import {ActivatedRoute} from "@angular/router";
@@ -42,6 +42,7 @@ import {DataxWorkerAddStep22Component} from "./datax.worker.add.step2-2.componen
import {isBooleanLiteralLike} from "codelyzer/util/utils";
import {K8SReplicsSpecComponent} from "../common/k8s.replics.spec.component";
import {DataxWorkerAddExistPowerjobClusterComponent} from "./datax.worker.add.exist.powerjob.cluster.component";
+import {TisResponseResult} from "../common/tis.plugin";
export enum PowerjobCptType {
Server = ("powerjob-server"),
@@ -49,7 +50,8 @@ export enum PowerjobCptType {
JobTpl = ("powerjob-job-tpl"),
UsingExistCluster = ("powerjob-use-exist-cluster"),
// applicationAware
- JobTplAppOverwrite = ("powerjob-job-tpl-app-overwrite")
+ JobTplAppOverwrite = ("powerjob-job-tpl-app-overwrite"),
+ FlinkCluster =("flink-cluster")
}
@Component({
@@ -123,21 +125,45 @@ export class DataxWorkerComponent extends AppFormComponent implements AfterViewI
});
this.multiViewDAG = new MultiViewDAG(configFST, this._componentFactoryResolver, this.containerRef);
- this.httpPost('/coredefine/corenodemanage.ajax'
- , `action=datax_action&emethod=get_job_worker_meta&targetName=${this.processMeta.targetName}`)
- .then((r) => {
- if (r.success) {
- let dataXWorkerStatus: DataXJobWorkerStatus = Object.assign(new DataXJobWorkerStatus(), r.bizresult, {processMeta: this.processMeta});
- if (dataXWorkerStatus.k8sReplicationControllerCreated) {
- this.multiViewDAG.loadComponent(DataxWorkerRunningComponent, dataXWorkerStatus);
- } else {
- this.multiViewDAG.loadComponent(DataxWorkerAddStep0Component, Object.assign(new DataxWorkerDTO(), {processMeta: this.processMeta}));
-
- // this.multiViewDAG.loadComponent(DataxWorkerAddStep3Component, Object.assign(new DataxWorkerDTO(), {processMeta: this.processMeta,powderJobServerRCSpec:K8SReplicsSpecComponent.createInitRcSpec()}));
-
- }
- }
- });
+
+ DataxWorkerComponent.getJobWorkerMeta(this,this.processMeta).then((dataXWorkerStatus)=>{
+ if (dataXWorkerStatus.k8sReplicationControllerCreated) {
+ this.multiViewDAG.loadComponent(DataxWorkerRunningComponent, dataXWorkerStatus);
+ } else {
+ this.multiViewDAG.loadComponent(DataxWorkerAddStep0Component, Object.assign(new DataxWorkerDTO(), {processMeta: this.processMeta}));
+
+ // this.multiViewDAG.loadComponent(DataxWorkerAddStep3Component
+ // , Object.assign(new DataxWorkerDTO(), {processMeta: this.processMeta,powderJobServerRCSpec:K8SReplicsSpecComponent.createInitRcSpec()}));
+
+ }
+ })
+
+ // this.httpPost('/coredefine/corenodemanage.ajax'
+ // , `action=datax_action&emethod=get_job_worker_meta&targetName=${this.processMeta.targetName}`)
+ // .then((r) => {
+ // if (r.success) {
+ // let dataXWorkerStatus: DataXJobWorkerStatus = Object.assign(new DataXJobWorkerStatus(), r.bizresult, {processMeta: this.processMeta});
+ // if (dataXWorkerStatus.k8sReplicationControllerCreated) {
+ // this.multiViewDAG.loadComponent(DataxWorkerRunningComponent, dataXWorkerStatus);
+ // } else {
+ // // this.multiViewDAG.loadComponent(DataxWorkerAddStep0Component, Object.assign(new DataxWorkerDTO(), {processMeta: this.processMeta}));
+ //
+ // this.multiViewDAG.loadComponent(DataxWorkerAddStep3Component, Object.assign(new DataxWorkerDTO(), {processMeta: this.processMeta,powderJobServerRCSpec:K8SReplicsSpecComponent.createInitRcSpec()}));
+ //
+ // }
+ // }
+ // });
+ }
+
+ public static getJobWorkerMeta(cpt:BasicFormComponent,processMeta: ProcessMeta) :Promise{
+ return cpt.httpPost('/coredefine/corenodemanage.ajax'
+ , `action=datax_action&emethod=get_job_worker_meta&targetName=${processMeta.targetName}`)
+ .then((r) => {
+ if (r.success) {
+ let dataXWorkerStatus: DataXJobWorkerStatus = Object.assign(new DataXJobWorkerStatus(), r.bizresult, {processMeta: processMeta});
+ return dataXWorkerStatus
+ }
+ });
}
}
diff --git a/src/base/datax.worker.running.component.ts b/src/base/datax.worker.running.component.ts
index 493fea5..557ad55 100644
--- a/src/base/datax.worker.running.component.ts
+++ b/src/base/datax.worker.running.component.ts
@@ -16,432 +16,830 @@
* limitations under the License.
*/
-import {AfterViewInit, Component, EventEmitter, Input, OnInit, Output} from "@angular/core";
-import {TISService} from "../common/tis.service";
-import {AppFormComponent, CurrentCollection, WSMessage} from "../common/basic.form.component";
+import {AfterViewInit, Component, EventEmitter, Input, NgZone, OnInit, Output} from "@angular/core";
+import {EventSourceSubject, EventType, ExecuteStep, MessageData, TISService} from "../common/tis.service";
+import {AppFormComponent, BasicFormComponent, CurrentCollection, WSMessage} from "../common/basic.form.component";
import {ActivatedRoute, Router} from "@angular/router";
import {NzModalService} from "ng-zorro-antd/modal";
import {NzNotificationService} from "ng-zorro-antd/notification";
-import {Subject} from "rxjs";
+import {interval, Observable, of, Subject, timer} from "rxjs";
import {
- DataXJobWorkerStatus,
- DataxWorkerDTO,
- K8sPodState,
- LogType,
- PowerJobWorkflow,
- RcHpaStatus
+ DataXJobWorkerStatus,
+ DataxWorkerDTO,
+ K8sPodState,
+ LogType,
+ PowerJobWorkflow, ProcessMeta, RCDeployment,
+ RcHpaStatus
} from "../runtime/misc/RCDeployment";
import {ControlPanelComponent} from "../common/control.panel.component";
import {Pager} from "../common/pagination.component";
import {DataxWorkerAddStep0Component} from "./datax.worker.add.step0.component";
+import {
+ debounceTime,
+ distinctUntilChanged,
+ map,
+ reduce,
+ scan,
+ switchMap,
+ takeUntil,
+ throttleTime
+} from 'rxjs/operators';
+import {
+ DataxWorkerAddStep3Component,
+ LaunchK8SClusterWaittingProcessComponent
+} from "./datax.worker.add.step3.component";
+import {NzProgressStatusType} from "ng-zorro-antd/progress/typings";
+import {NzDrawerService} from "ng-zorro-antd/drawer";
+
@Component({
- template: `
-
-
-
-
-
-
-
-
-
-
- 名称 |
- 状态 |
- 重启次数 |
- 创建时间 |
-
-
-
-
-
-
- |
-
- {{pod.phase}}
- |
-
- {{pod.restartCount}}
- |
- {{pod.startTime | date:'yyyy/MM/dd HH:mm:ss'}} |
-
-
-
-
-
-
-
- {{rcHpaStatus.autoscalerSpec.minReplicas}}
- {{rcHpaStatus.autoscalerSpec.maxReplicas}}
- {{rcHpaStatus.autoscalerSpec.targetCPUUtilizationPercentage}}
- %
-
-
-
- {{rcHpaStatus.autoscalerStatus.currentCPUUtilizationPercentage}}
- {{rcHpaStatus.autoscalerStatus.currentReplicas}}
- {{rcHpaStatus.autoscalerStatus.desiredReplicas}}
- 0"
- nzTitle="lastScaleTime">{{rcHpaStatus.autoscalerStatus.lastScaleTime | date: 'yyyy/MM/dd HH:mm'}}
-
-
-
扩缩容事件
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{dto.rcDeployment.dockerImage}}
- {{dto.rcDeployment.creationTimestamp | date : "yyyy/MM/dd HH:mm:ss"}}
-
-
- {{dto.rcDeployment.status.availableReplicas}}
- {{dto.rcDeployment.status.fullyLabeledReplicas}}
- {{dto.rcDeployment.status.observedGeneration}}
- {{dto.rcDeployment.status.readyReplicas}}
- {{dto.rcDeployment.status.replicas}}
-
-
-
- request
- {{dto.rcDeployment.cpuRequest.val + dto.rcDeployment.cpuRequest.unit}}
- limit
- {{dto.rcDeployment.cpuLimit.val + dto.rcDeployment.cpuLimit.unit}}
-
-
- request
- {{dto.rcDeployment.memoryRequest.val + dto.rcDeployment.memoryRequest.unit}}
- limit
- {{dto.rcDeployment.memoryLimit.val + dto.rcDeployment.memoryLimit.unit}}
-
-
-
- {{e.value}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{u.wfName}}
-
-
-
-
-
-
-
-
-
- {{u.gmtCreate|date : "yyyy/MM/dd HH:mm:ss"}}
-
-
-
- {{u.gmtModified|date : "yyyy/MM/dd HH:mm:ss"}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ template: `
+
+
+
+
+
+
+
+
+
+
+
+ 可直接打开PowerJob控制台 控制台
+
+
+
+
+
+
+
+
+
+
+
-
- `
- , styles: [
- ` .h2-header {
- padding: 3px;
- background-color: #e1e1e1;
- }
- .desc-block {
- margin-top: 20px;
- }
+
+ {{dto.rcDeployment.dockerImage}}
+ {{dto.rcDeployment.creationTimestamp | date : "yyyy/MM/dd HH:mm:ss"}}
+
+
+ {{dto.rcDeployment.status.availableReplicas}}
+ {{dto.rcDeployment.status.fullyLabeledReplicas}}
+ {{dto.rcDeployment.status.observedGeneration}}
+ {{dto.rcDeployment.status.readyReplicas}}
+ {{dto.rcDeployment.status.replicas}}
+
+
+
+ request
+ {{dto.rcDeployment.cpuRequest.val + dto.rcDeployment.cpuRequest.unit}}
+ limit
+ {{dto.rcDeployment.cpuLimit.val + dto.rcDeployment.cpuLimit.unit}}
+
+
+ request
+ {{dto.rcDeployment.memoryRequest.val + dto.rcDeployment.memoryRequest.unit}}
+ limit
+ {{dto.rcDeployment.memoryLimit.val + dto.rcDeployment.memoryLimit.unit}}
+
+
+
+ {{e.value}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{u.wfName}}
+
+
+
+
+
+
+
+
+
+ {{u.gmtCreate|date : "yyyy/MM/dd HH:mm:ss"}}
+
+
+
+ {{u.gmtModified|date : "yyyy/MM/dd HH:mm:ss"}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ `
+ , styles: [
+ ` .h2-header {
+ padding: 3px;
+ background-color: #e1e1e1;
+ }
- .danger-control-title {
- margin-top: 10px;
- padding: 0px 0;
- }
+ .desc-block {
+ margin-top: 20px;
+ }
- .ant-advanced-search-form {
- padding: 10px;
- #background: #fbfbfb;
- border: 2px solid #d97f85;
- border-radius: 6px;
- margin-bottom: 10px;
- clear: both;
- }
- `]
+ .danger-control-title {
+ margin-top: 10px;
+ padding: 0px 0;
+ }
+
+ .ant-advanced-search-form {
+ padding: 10px;
+ #background: #fbfbfb;
+ border: 2px solid #d97f85;
+ border-radius: 6px;
+ margin-bottom: 10px;
+ clear: both;
+ }
+ `]
})
export class DataxWorkerRunningComponent extends AppFormComponent implements AfterViewInit, OnInit {
- // savePlugin = new EventEmitter
();
- // @ViewChild('k8sReplicsSpec', {read: K8SReplicsSpecComponent, static: true}) k8sReplicsSpec: K8SReplicsSpecComponent;
- @Output() nextStep = new EventEmitter();
- @Output() preStep = new EventEmitter();
- // @Input() dto: DataxWorkerDTO;
+ // savePlugin = new EventEmitter();
+ // @ViewChild('k8sReplicsSpec', {read: K8SReplicsSpecComponent, static: true}) k8sReplicsSpec: K8SReplicsSpecComponent;
+ @Output() nextStep = new EventEmitter();
+ @Output() preStep = new EventEmitter();
+ // @Input() dto: DataxWorkerDTO;
+
+ msgSubject: Subject;
+ dto: DataXJobWorkerStatus = new DataXJobWorkerStatus();
+ tabSelectIndex = 0;
+ selectedPod: K8sPodState = null;
+ logtype = LogType.DATAX_WORKER_POD_LOG;
+
+ workerCfg: DataxWorkerDTO;
+
+
+ podNameSub;
+
+ /**
+ * ========================
+ */
+ pager: Pager = new Pager(1, 2);
+ workflows: PowerJobWorkflow[] = [];
+
+
+ constructor(tisService: TISService, route: ActivatedRoute, modalService: NzModalService, private router: Router, notification: NzNotificationService, public _zone: NgZone) {
+ super(tisService, route, modalService, notification);
+ }
+
+ public gotoPage(page: number): void {
+ // this.tisService._zone.runOutsideAngular(()=>{
+ this.httpPost('/coredefine/corenodemanage.ajax'
+ , 'action=datax_action&emethod=get_all_powerjob_workflow_record&page=' + page)
+ .then((r) => {
+ if (r.success) {
+ this.workflows = r.bizresult.rows;
+ this.pager = new Pager(r.bizresult.curPage, r.bizresult.totalPage);
+ }
+ });
+ // })
+
+ }
+
+ get currentApp(): CurrentCollection {
+ return new CurrentCollection(0, this.dto.processMeta.targetName);
+ }
+
+ ngOnInit(): void {
+ // super.ngOnInit();
+ // console.log("==========================");
+ this.route.params.subscribe((p) => {
+ let targetTab = p['targetTab'];
+ console.log(targetTab);
+ switch (targetTab) {
+ case 'log':
+ if (!this.podNameSub) {
+ this.podNameSub = this.route.fragment.subscribe((podName) => {
+ // console.log(`podName:${podName}`);
+ if (this.route.snapshot.params['targetTab'] !== 'log') {
+ return;
+ }
+ if (!this.selectedPod) {
+ // 取得容器第一个pod
+ let pods = this.dto.rcDeployment.pods;
+ if (pods.length < 1) {
+ this.errNotify("容器还未分配Pod资源");
+ return;
+ }
+ this.selectedPod = pods[0];
+ }
+ if (!!podName && podName !== this.selectedPod.name) {
+ this.selectedPod = this.dto.findPod(podName);//.pods.find((pp) => (pp.name === podName));
+ if (!this.selectedPod) {
+ throw new Error("can not find podName:" + podName + " in:" + this.dto.rcDeployment.pods.map((pp) => pp.name).join(","));
+ }
+ }
+ let logtype = this.logtype + ":" + this.selectedPod.name;
+ if (!this.msgSubject) {
+ this.msgSubject = this.getWSMsgSubject(logtype);
+ } else {
+ this.msgSubject.next(new WSMessage(logtype));
+ }
+ this.tabSelectIndex = 2;
+ });
+ }
+
+ break;
+ case 'profile':
+ this.profileViewSelect();
+ this.tabSelectIndex = 0;
+ break;
+ case 'config': {
+ this.tisService.currentApp = this.currentApp;
+ if (this.workerCfg) {
+ break;
+ }
+ this.httpPost('/coredefine/corenodemanage.ajax?action=datax_action'
+ , "emethod=get_datax_worker_config&targetName=" + this.dto.processMeta.targetName)
+ .then((r) => {
+ //
+ this._zone.run(() => {
+ if (r.success) {
- msgSubject: Subject;
- dto: DataXJobWorkerStatus = new DataXJobWorkerStatus();
- tabSelectIndex = 0;
- selectedPod: K8sPodState = null;
- logtype = LogType.DATAX_WORKER_POD_LOG;
+ // setTimeout(()=>{
- rcHpaStatus: RcHpaStatus;
+ this.workerCfg = Object.assign(new DataxWorkerDTO(), r.bizresult, {"processMeta": this.dto.processMeta});
- podNameSub;
+ // },3000);
+ // DataxWorkerDTO
+ }
+ });
+ });
+ break;
+ }
+ case 'manage':
+ // this.tabSelectIndex = 3;
+ break;
+ case 'env':
+ break;
+ case 'wf-list':
+ default : {
+ this.tabSelectIndex = 0;
+ // this.workflowSelect();
+ this.gotoPage(this.pager.curPage)
+ break;
+ }
+ }
+ });
+ }
- /**
- * ========================
- */
- pager: Pager = new Pager(1, 2);
- workflows: PowerJobWorkflow[] = [];
+ protected initialize(app: CurrentCollection): void {
+ }
- constructor(tisService: TISService, route: ActivatedRoute, modalService: NzModalService, private router: Router, notification: NzNotificationService) {
- super(tisService, route, modalService, notification);
- }
+ ngAfterViewInit() {
+ }
- public gotoPage(page: number): void {
- this.httpPost('/coredefine/corenodemanage.ajax'
- , 'action=datax_action&emethod=get_all_powerjob_workflow_record&page=' + page)
- .then((r) => {
- if (r.success) {
- this.workflows = r.bizresult.rows;
- this.pager = new Pager(r.bizresult.curPage, r.bizresult.totalPage);
- }
- });
- }
- get currentApp(): CurrentCollection {
- return new CurrentCollection(0, this.dto.processMeta.targetName);
- }
+ prestep() {
+ // this.preStep.next(this.dto);
+ }
- ngOnInit(): void {
- // super.ngOnInit();
- // console.log("==========================");
- this.route.params.subscribe((p) => {
- let targetTab = p['targetTab'];
- switch (targetTab) {
- case 'log':
- if (!this.podNameSub) {
- this.podNameSub = this.route.fragment.subscribe((podName) => {
- // console.log(`podName:${podName}`);
- if (this.route.snapshot.params['targetTab'] !== 'log') {
- return;
- }
- if (!this.selectedPod) {
- // 取得容器第一个pod
- let pods = this.dto.rcDeployment.pods;
- if (pods.length < 1) {
- this.errNotify("容器还未分配Pod资源");
- return;
- }
- this.selectedPod = pods[0];
- }
- if (!!podName && podName !== this.selectedPod.name) {
- this.selectedPod = this.dto.rcDeployment.pods.find((pp) => (pp.name === podName));
- if (!this.selectedPod) {
- throw new Error("can not find podName:" + podName + " in:" + this.dto.rcDeployment.pods.map((pp) => pp.name).join(","));
- }
- }
- let logtype = this.logtype + ":" + this.selectedPod.name;
- if (!this.msgSubject) {
- this.msgSubject = this.getWSMsgSubject(logtype);
- } else {
- this.msgSubject.next(new WSMessage(logtype));
- }
- this.tabSelectIndex = 2;
- });
- }
-
- break;
- case 'profile':
- this.profileViewSelect();
- this.tabSelectIndex = 0;
- break;
- case 'manage':
- this.tabSelectIndex = 3;
- break;
- case 'env':
- break;
- case 'wf-list':
- default : {
- this.tabSelectIndex = 0;
- this.workflowSelect();
- break;
- }
- }
- });
- }
+ dataXWorkerDelete(cpt: ControlPanelComponent) {
+ // this.confirm(`是否确定要将${this.dto.processMeta.pageHeader}从K8S容器中删除`, () => {
+ //
+ // });
- protected initialize(app: CurrentCollection): void {
- }
+ this.jsonPost('/coredefine/corenodemanage.ajax?action=datax_action&emethod=remove_datax_worker&targetName=' + this.dto.processMeta.targetName
+ , {})
+ .then((r) => {
+ // console.log("xxxxxxxx");
+ cpt.enableComponent();
+ if (r.success) {
+ this.nextStep.emit(Object.assign(new DataxWorkerDTO(), {processMeta: this.dto.processMeta}));
+ }
+ });
- ngAfterViewInit() {
- }
+ }
+ profileTabSelect() {
+ this.activeTab('profile');
+ }
- prestep() {
- // this.preStep.next(this.dto);
+ private activeTab(tabName: string) {
+ let currentTab = this.route.snapshot.params['targetTab'];
+ if (currentTab !== tabName) {
+ this.router.navigate([`/base/${this.dto.processMeta.targetName}`, tabName], {relativeTo: this.route});
}
+ }
+
+ envTabSelect() {
+ this.activeTab('env');
+ }
+
+ workflowSelect() {
+ // this.gotoPage(this.pager.curPage)
+ this.activeTab('wf-list');
+ }
+
+ profileViewSelect(): void {
+ this.jsonPost(`/coredefine/corenodemanage.ajax?action=datax_action&emethod=get_datax_worker_hpa&targetName=${this.dto.processMeta.targetName}`
+ , {})
+ .then((r) => {
+ if (r.success) {
+ // this.rcHpaStatus = r.bizresult;
+ }
+ });
+ }
- dataXWorkerDelete(cpt: ControlPanelComponent) {
+ logtypeSelect() {
+ this.activeTab('log');
+ // if (!this.route.snapshot.params['targetTab']) {
+ // this.router.navigate(["/base/datax-worker/log"], {relativeTo: this.route});
+ // }
+ }
- // this.confirm(`是否确定要将${this.dto.processMeta.pageHeader}从K8S容器中删除`, () => {
- //
- // });
- this.jsonPost('/coredefine/corenodemanage.ajax?action=datax_action&emethod=remove_datax_worker&targetName=' + this.dto.processMeta.targetName
- , {})
- .then((r) => {
- // console.log("xxxxxxxx");
- cpt.enableComponent();
- if (r.success) {
- this.nextStep.emit(Object.assign(new DataxWorkerDTO(), {processMeta: this.dto.processMeta}));
- }
- });
+ manageSelect() {
+ this.activeTab('manage');
+ }
- }
+ k8sResConfigSelect() {
+ // dto: DataxWorkerDTO
+ this.activeTab('config');
+ }
- profileTabSelect() {
- this.activeTab('profile');
+ startPowerJobTplAppOverwrite(u: PowerJobWorkflow) {
+ if (!u.wfName) {
+ throw new Error("property wfName can not be null");
}
+ DataxWorkerAddStep0Component.startPowerJobTplAppOverwrite(this, [{
+ key: "appname",
+ val: u.wfName
+ }]).subscribe((plugin: PowerJobWorkflow) => {
+ // console.log(plugin);
+ // this.workflowSelect();
+
+ let idxOf = this.workflows.findIndex((wf) => wf.id === plugin.id);
+ if (idxOf > -1) {
+ this.workflows[idxOf] = plugin;
+ this.workflows = [...this.workflows];
+ }
+ });
+ }
- private activeTab(tabName: string) {
- let currentTab = this.route.snapshot.params['targetTab'];
- if (currentTab !== tabName) {
- this.router.navigate([`/base/${this.dto.processMeta.targetName}`, tabName], {relativeTo: this.route});
- }
- }
- envTabSelect() {
- this.activeTab('env');
- }
+}
- workflowSelect() {
- this.gotoPage(this.pager.curPage)
- this.activeTab('wf-list');
+@Component({
+ selector: `pod-list`,
+ template: `
+
+ {{rcDeployment.name}}
+
+
+
+
+
+
+ {{this.rcDeployment.pods.length}}/{{this.toPodNum.targetPodNum}}
+
+
+
+
+
+
+
+
+
pods
+
+
+
+ 名称 |
+ 状态 |
+ 重启次数 |
+ 创建时间 |
+
+
+
+
+
+
+ |
+
+ {{pod.phase}}
+ |
+
+ {{pod.restartCount}}
+ |
+ {{pod.startTime | date:'yyyy/MM/dd HH:mm:ss'}} |
+
+
+
+
+ hap
+
+
+
+ {{rcHpaStatus.autoscalerSpec.minReplicas}}
+ {{rcHpaStatus.autoscalerSpec.maxReplicas}}
+ {{rcHpaStatus.autoscalerSpec.targetCPUUtilizationPercentage}}
+ %
+
+
+
+ {{rcHpaStatus.autoscalerStatus.currentCPUUtilizationPercentage}}
+ {{rcHpaStatus.autoscalerStatus.currentReplicas}}
+ {{rcHpaStatus.autoscalerStatus.desiredReplicas}}
+ 0"
+ nzTitle="lastScaleTime">{{rcHpaStatus.autoscalerStatus.lastScaleTime | date: 'yyyy/MM/dd HH:mm'}}
+
+
+
扩缩容事件
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ `
+})
+export class PodsListComponent extends BasicFormComponent implements AfterViewInit, OnInit {
+
+ // @Input() caption:string;
+ @Input() rcHpaStatus: RcHpaStatus;
+ @Input() public rcDeployment: RCDeployment;
+ @Input() processMeta: ProcessMeta;
+
+ toPodNum = new PodNumberDebounce(0);
+
+ podNumberChange$ = new Subject();
+ _progressStat: NzProgressStatusType;
+
+
+ constructor(tisService: TISService, modalService: NzModalService, notification: NzNotificationService
+ , private route: ActivatedRoute, private router: Router, private drawerService: NzDrawerService) {
+ super(tisService, modalService, notification);
+ }
+
+ openError(): void {
+ this.rcDeployment.rcScalaLog
+ const drawerRef = this.drawerService.create({
+ nzWidth: "60%",
+ nzHeight: "100%",
+ nzPlacement: "right",
+ nzContent: LaunchK8SClusterWaittingProcessComponent,
+ nzContentParams: {"errScalaLog": this.rcDeployment.rcScalaLog},
+ nzClosable: false,
+ nzMaskClosable: false
+ });
+ }
+
+ get progressPercent(): number {
+ let p = this.rcDeployment.pods.length * 100 / this.toPodNum.targetPodNum;
+ // console.log(p);
+ return p;
+ }
+
+ get showErrorLogs(): boolean {
+ let scalaLog = this.rcDeployment.rcScalaLog;
+ return (scalaLog && scalaLog.faild);
+ }
+
+ get progressStat(): NzProgressStatusType {
+ let scalaLog = this.rcDeployment.rcScalaLog;
+ if (scalaLog && scalaLog.faild) {
+ return 'exception';
}
+ return this._progressStat;
+ }
+
+ ngAfterViewInit(): void {
+ }
+
+ static viewPodLog(processMeta: ProcessMeta, route: ActivatedRoute, router: Router, podname: K8sPodState) {
+ router.navigate([`/base/${processMeta.targetName}/log`], {
+ relativeTo: route,
+ fragment: podname.name
+ });
+ }
+
+
+ minusPod(): void {
+ this.podNumberChange$.next(new PodNumberChange(false, 1));
+ }
+
+ plusPod(): void {
+ console.log("plusPod");
+ this.podNumberChange$.next(new PodNumberChange(true, 1));
+ }
+
+ viewPodLog(podname: K8sPodState) {
+
+ PodsListComponent.viewPodLog(this.processMeta, this.route, this.router, podname);
+
+ // this.router.navigate([`/base/${this.processMeta.targetName}/log`], {
+ // relativeTo: this.route,
+ // fragment: podname.name
+ // });
+ // this.tabSelectIndex = 2;
+ }
+
+ ngOnInit(): void {
+
+ //const getIndeNameList = (podChange: PodNumberChange) => {
+ // return this._http
+ // .get(`/tjs/runtime/applist.ajax?emethod=query_app&action=app_view_action&query=${fuzzName}`)
+ // .pipe(map((res: any) => res.bizresult))
+ // .pipe(
+ // map((list: any) => {
+ // return list.map((item: any) => {
+ // let app = new SelectedIndex(item.projectName, item.appType);
+ // // `${item.projectName}`
+ // return app;
+ // });
+ // })
+ // );
+ // return new Observable();// podChange;
+ // };
+
+ this.toPodNum = new PodNumberDebounce(this.rcDeployment.pods.length);
+ // let podNum = new PodNumberDebounce(this.rcDeployment.pods.length);
+ // const count = ones.pipe(reduce((acc, one) => acc + one, seed));
+ // count.subscribe(x => console.log(x))
+ // this.podNumberChange$.pipe(// restart counter on every click
+ // switchMap((e) => this.podNumberChange$.pipe() ),takeUntil(timer(5000)) ).subscribe(console.log);
+ const optionList$: Observable = this.podNumberChange$
+ .asObservable()
+ .pipe(map((val) => {
+ let pn = this.toPodNum.change(val);
+ if (pn.targetPodNum < 1) {
+ let err = 'Pod数不能小于1';
+ this.toPodNum.targetPodNum = 1;
+ this.errNotify(err, 6000);
+ //throw new Error(err);
- profileViewSelect(): void {
- this.jsonPost(`/coredefine/corenodemanage.ajax?action=datax_action&emethod=get_datax_worker_hpa&targetName=${this.dto.processMeta.targetName}`
- , {})
- .then((r) => {
- if (r.success) {
- this.rcHpaStatus = r.bizresult;
+ }
+ return pn;
+ }))
+ .pipe(debounceTime(3000));//.pipe(distinctUntilChanged());
+
+
+ // reduce((acc, change: PodNumberChange) => {
+ // if (!acc) {
+ // acc = new PodNumberDebounce(this.rcDeployment.pods.length);
+ // }
+ //
+ // let f = acc.change(change);
+ // console.log(['reduce', acc, f.targetPodNum]);
+ // // if (acc.targetPodNum > 7) {
+ // // this.podNumberChange$.complete();
+ // // }
+ // return f;
+ // }, null)
+
+ // // .pipe(debounceTime(2000));
+ // // .pipe(switchMap(getIndeNameList));
+ //
+ optionList$.subscribe(data => {
+ // this.toPodNum = data;
+ // console.log(data);
+ // this.collectionOptionList = data;
+ // this.isLoading = false;
+ this._progressStat = 'active';
+ this.rcDeployment.rcScalaLog = undefined;
+ let evtSubject: EventSourceSubject = DataxWorkerAddStep3Component.createLaunchingEventSubject(
+ "apply_pod_number", this.tisService, this.processMeta.targetName
+ , "cptType=" + this.rcDeployment.name + "&podNumber=" + data.targetPodNum);
+ //
+ //?resulthandler=exec_null&action=datax_action&emethod=apply_pod_number&targetName=datax-worker&cptType=powerjob-worker&podNumber=2
+ evtSubject.events.subscribe((e: [EventType, Array | MessageData | ExecuteStep]) => {
+ ;
+ switch (e[0]) {
+ case EventType.TASK_MILESTONE:
+ let milestone: ExecuteStep = e[1];
+ if (!milestone.success) {
+ this._progressStat = 'exception';
+ }
+ let match = /^(.+?)([+|-]{1})$/.exec(milestone.name)
+ // console.log(match)
+ if (!match) {
+ throw new Error('podName is not illegal:' + milestone.name);
+ }
+ let podName = match[1];
+
+ switch (match[2]) {
+ case '+':
+ this.rcDeployment.pods.push({'name': podName})
+ this.rcDeployment.pods = [...this.rcDeployment.pods];
+ break;
+ case '-':
+ let idxOf = this.rcDeployment.pods.findIndex((pod) => pod.name === podName);
+ if (idxOf > -1) {
+ this.rcDeployment.pods.splice(idxOf, 1);
+ this.rcDeployment.pods = [...this.rcDeployment.pods];
}
- });
- }
- logtypeSelect() {
- this.activeTab('log');
- // if (!this.route.snapshot.params['targetTab']) {
- // this.router.navigate(["/base/datax-worker/log"], {relativeTo: this.route});
- // }
- }
+ break;
+ default:
+ throw new Error('podName:' + milestone.name + ",exec action is illegal:" + match[2]);
+ }
- viewPodLog(podname: K8sPodState) {
- this.router.navigate([`/base/${this.dto.processMeta.targetName}/log`], {
- relativeTo: this.route,
- fragment: podname.name
- });
- // this.tabSelectIndex = 2;
- }
+ // match[2];
+ break;
+ case EventType.SSE_CLOSE:
+ if (this._progressStat === 'active') {
+ this._progressStat = 'success';
+ }
+ case EventType.TASK_EXECUTE_STEPS:
+ break;
+ case EventType.LOG_MESSAGE:
+ break;
+ }
+ });
+ });
+ }
- manageSelect() {
- this.activeTab('manage');
- }
+}
- startPowerJobTplAppOverwrite(u: PowerJobWorkflow) {
- if (!u.wfName) {
- throw new Error("property wfName can not be null");
- }
- DataxWorkerAddStep0Component.startPowerJobTplAppOverwrite(this, [{
- key: "appname",
- val: u.wfName
- }]).subscribe((plugin: PowerJobWorkflow) => {
- // console.log(plugin);
- // this.workflowSelect();
-
- let idxOf = this.workflows.findIndex((wf) => wf.id === plugin.id);
- if (idxOf > -1) {
- this.workflows[idxOf] = plugin;
- this.workflows = [...this.workflows];
- }
- });
- }
+class PodNumberChange {
+ constructor(private _plus: boolean, private _changeNum: number) {
+ }
+
+ get plus(): boolean {
+ return this._plus;
+ }
+
+ get changeNum(): number {
+ return this._changeNum;
+ }
+}
+
+class PodNumberDebounce {
+ change(change: PodNumberChange): PodNumberDebounce {
+ this.targetPodNum += (change.plus ? 1 : -1) * change.changeNum;
+ return this;
+ }
+
+ constructor(public targetPodNum: number) {
+ }
+}
+
+
+@Component({
+ selector: `rc-spec`,
+ template: `
+
+
+ {{rcDeployment.name}}
+
+
+ {{rcDeployment.dockerImage}}
+ {{rcDeployment.creationTimestamp | date : "yyyy/MM/dd HH:mm:ss"}}
+
+
+ {{rcDeployment.status.availableReplicas}}
+ {{rcDeployment.status.fullyLabeledReplicas}}
+ {{rcDeployment.status.observedGeneration}}
+ {{rcDeployment.status.readyReplicas}}
+ {{rcDeployment.status.replicas}}
+
+
+
+ request
+ {{rcDeployment.cpuRequest.val + rcDeployment.cpuRequest.unit}}
+ limit
+ {{rcDeployment.cpuLimit.val + rcDeployment.cpuLimit.unit}}
+
+
+ request
+ {{rcDeployment.memoryRequest.val + rcDeployment.memoryRequest.unit}}
+ limit
+ {{rcDeployment.memoryLimit.val + rcDeployment.memoryLimit.unit}}
+
+
+
+ {{e.value}}
+
+
+
+ `, styles: [
+ ``
+ ]
+})
+export class RCSpecComponent extends BasicFormComponent implements AfterViewInit, OnInit {
+ @Input() public rcDeployment: RCDeployment;
+
+ constructor(tisService: TISService, modalService: NzModalService, notification: NzNotificationService, private route: ActivatedRoute, private router: Router) {
+ super(tisService, modalService, notification);
+ }
+
+
+ ngAfterViewInit(): void {
+ }
+
+
+ ngOnInit(): void {
+ }
}
diff --git a/src/common/basic.form.component.ts b/src/common/basic.form.component.ts
index 9097a10..201cd8c 100644
--- a/src/common/basic.form.component.ts
+++ b/src/common/basic.form.component.ts
@@ -164,10 +164,13 @@ export class BasicFormComponent {
// 发送http post请求
public httpPost(url: string, body: string): Promise {
- this.formDisabled = true;
- NProgress.start();
- this.clearProcessResult();
- return this.tisService.httpPost(url, body).then(this.webExecuteCallback).catch(this.handleError);
+ this.formDisabled = true;
+ NProgress.start();
+ this.clearProcessResult();
+ return this.tisService.httpPost(url, body).then(this.webExecuteCallback).catch(this.handleError);
+ // return this.tisService._zone.runOutsideAngular(()=>{
+ //
+ // })
}
// 发送json表单
diff --git a/src/common/k8s.replics.spec.component.ts b/src/common/k8s.replics.spec.component.ts
index 503c39e..c6dc522 100644
--- a/src/common/k8s.replics.spec.component.ts
+++ b/src/common/k8s.replics.spec.component.ts
@@ -26,289 +26,298 @@ import {Item, ItemPropVal} from "./tis.plugin";
@Component({
- selector: `k8s-replics-spec`,
- template: `
-
-
-
-
-
-
-
{{controlErr('pods')}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{{controlErr('cuprequest')}}
-
-
-
-
-
-
-
-
-
-
-
-
{{controlErr('cuplimit')}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{{controlErr('memoryrequest')}}
-
-
-
-
-
-
-
-
-
-
-
-
{{controlErr('memorylimit')}}
-
-
-
-
-
+ selector: `k8s-replics-spec`,
+ template: `
+
+
+
+
+
+
+
{{controlErr('pods')}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{{controlErr('cuprequest')}}
+
+
+
+
+
+
+
+
+
+
+
+
{{controlErr('cuplimit')}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{{controlErr('memoryrequest')}}
+
+
+
+
+
+
+
+
+
+
+
+
{{controlErr('memorylimit')}}
+
+
+
+
+
-
-
-
-
-
-
-
-
{{controlErr('cpuAverageUtilization')}}
-
-
-
-
-
-
{{controlErr('minHpaPod')}}
-
-
-
-
-
-
{{controlErr('maxHpaPod')}}
-
-
-
-
-
-
个
- `
- , styles: [`
- .resource-spec {
- display: flex;
- }
+
+
+
+
+
+
+
+
{{controlErr('cpuAverageUtilization')}}
+
+
+
+
+
+
{{controlErr('minHpaPod')}}
+
+
+
+
+
+
{{controlErr('maxHpaPod')}}
+
+
+
+
+
+ 个
+ `
+ , styles: [`
+ .resource-spec {
+ display: flex;
+ }
- .resource-spec .spec-unit {
- width: 150px;
- }
+ .resource-spec .spec-unit {
+ width: 150px;
+ }
- .resource-spec div {
- flex: 1;
- margin-right: 20px;
- }
+ .resource-spec div {
+ flex: 1;
+ margin-right: 20px;
+ }
- .input-number {
- width: 100%;
- }
+ .input-number {
+ width: 100%;
+ }
- .spec-form {
- }
- `]
+ .spec-form {
+ }
+ `]
})
export class K8SReplicsSpecComponent extends BasicFormComponent implements AfterContentInit, AfterViewInit, OnInit {
- specForm: FormGroup;
- @Input()
- labelSpan = 2;
- @Input()
- controlSpan = 20;
+ specForm: FormGroup;
+ @Input()
+ labelSpan = 2;
+ @Input()
+ controlSpan = 20;
- @Input()
- disabled = false;
- @Input()
- hpaDisabled = false;
+ @Input()
+ disabled = false;
+ @Input()
+ hpaDisabled = false;
- @Input()
- errorItem: Item;
- @Input()
- rcSpec: K8SRCSpec;
+ @Input()
+ errorItem: Item;
+ @Input()
+ rcSpec: K8SRCSpec;
- @Output()
- rcSpecChange = new EventEmitter();
+ @Output()
+ rcSpecChange = new EventEmitter();
- constructor(tisService: TISService, modalService: NzModalService, private fb: FormBuilder) {
- super(tisService, modalService);
- this.specForm = this.fb.group({
- supportHpa: [false, [Validators.required]],
- minHpaPod: [1],
- maxHpaPod: [3],
- cpuAverageUtilization: [10, [Validators.pattern(new RegExp("\\d+")),Validators.max(100), Validators.min(1)]],
- pods: [1, [Validators.required]],
- cuprequest: [500, [Validators.required]],
- cuprequestunit: ['m', [Validators.required]],
- cuplimitunit: ['cores', [Validators.required]],
- cuplimit: [1, [Validators.required]],
- memoryrequest: [500, [Validators.required]],
- memoryrequestunit: ['M', [Validators.required]],
- memorylimit: [2, [Validators.required]],
- memorylimitunit: ['G', [Validators.required]]
- });
- }
+ constructor(tisService: TISService, modalService: NzModalService, private fb: FormBuilder) {
+ super(tisService, modalService);
+ this.specForm = this.fb.group({
+ supportHpa: [false, [Validators.required]],
+ minHpaPod: [1],
+ maxHpaPod: [3],
+ cpuAverageUtilization: [10, [Validators.pattern(new RegExp("\\d+")), Validators.max(100), Validators.min(1)]],
+ pods: [1, [Validators.required]],
+ cuprequest: [500, [Validators.required]],
+ cuprequestunit: ['m', [Validators.required]],
+ cuplimitunit: ['cores', [Validators.required]],
+ cuplimit: [1, [Validators.required]],
+ memoryrequest: [500, [Validators.required]],
+ memoryrequestunit: ['M', [Validators.required]],
+ memorylimit: [2, [Validators.required]],
+ memorylimitunit: ['G', [Validators.required]]
+ });
+ }
- hasErr(control: string): boolean {
- let field: AbstractControl = this.specForm.controls[control];
+ hasErr(control: string): boolean {
+ let field: AbstractControl = this.specForm.controls[control];
- for(let err in field.errors){
- return true;
- }
- if (!this.errorItem) {
- return false;
- }
- // @ts-ignore
- let itemPP: ItemPropVal = this.errorItem.vals[control];
- return itemPP && itemPP.hasFeedback;
+ for (let err in field.errors) {
+ return true;
}
-
- public validate(): boolean {
- this.rcSpecChange.emit(this.specForm.value);
- return this.specForm.valid;
+ if (!this.errorItem) {
+ return false;
}
+ // @ts-ignore
+ let itemPP: ItemPropVal = this.errorItem.vals[control];
+ return itemPP && itemPP.hasFeedback;
+ }
- controlErr(control: string): string {
+ public validate(): boolean {
+ this.rcSpecChange.emit(this.specForm.value);
+ return this.specForm.valid;
+ }
- let field: AbstractControl = this.specForm.controls[control];
+ controlErr(control: string): string {
- for(let errKey in field.errors){
- switch (errKey) {
- case Validators.required.name:
- return "必须输入";
- case Validators.max.name:
- // console.log(field.errors[errKey])
- return "必须小于"+ field.errors[errKey].max;
- case Validators.min.name:
- return "必须大于"+ field.errors[errKey].min;
- }
- }
+ let field: AbstractControl = this.specForm.controls[control];
- if (!this.errorItem) {
- return '';
- }
- // @ts-ignore
- let itemPP: ItemPropVal = this.errorItem.vals[control];
- if (!itemPP) {
- return '';
- }
- return itemPP.error;
+ for (let errKey in field.errors) {
+ switch (errKey) {
+ case Validators.required.name:
+ return "必须输入";
+ case Validators.max.name:
+ // console.log(field.errors[errKey])
+ return "必须小于" + field.errors[errKey].max;
+ case Validators.min.name:
+ return "必须大于" + field.errors[errKey].min;
+ }
}
- ngAfterContentInit(): void {
- // this.specForm.get
+ if (!this.errorItem) {
+ return '';
}
-
- public get k8sControllerSpec(): K8SRCSpec {
- return this.specForm.value;
+ // @ts-ignore
+ let itemPP: ItemPropVal = this.errorItem.vals[control];
+ if (!itemPP) {
+ return '';
}
+ return itemPP.error;
+ }
- ngAfterViewInit(): void {
- }
+ ngAfterContentInit(): void {
+ // this.specForm.get
+ }
- ngOnInit(): void {
+ public get k8sControllerSpec(): K8SRCSpec {
+ return this.specForm.value;
+ }
- if (!this.rcSpec) {
- this.rcSpec = K8SReplicsSpecComponent.createInitRcSpec();
- }
- // console.log(this.rcSpec);
- this.specForm.setValue(this.rcSpec);
- // this.specForm.valueChanges.subscribe((spec) => {
- //
- // })
- // this.specForm.setErrors({"cuprequest": "dddddddd"});
- // console.log(this.specForm.errors);
- // console.log(this.specForm.value);
- }
+ ngAfterViewInit(): void {
+ }
- public static createInitRcSpec():K8SRCSpec {
- return {
- 'pods': 1,
- supportHpa: false, minHpaPod: 1, maxHpaPod: 3, cpuAverageUtilization: 10, cuprequest: 500,
- cuprequestunit: 'm',
- cuplimitunit: 'cores',
- cuplimit: 1,
- memoryrequest: 500,
- memoryrequestunit: 'M',
- memorylimit: 2,
- memorylimitunit: 'G'
- };
+ ngOnInit(): void {
+
+ if (!this.rcSpec) {
+ this.rcSpec = K8SReplicsSpecComponent.createInitRcSpec();
}
+ // console.log(this.rcSpec);
+ this.specForm.setValue(this.rcSpec);
+ // this.specForm.valueChanges.subscribe((spec) => {
+ //
+ // })
+ // this.specForm.setErrors({"cuprequest": "dddddddd"});
+ // console.log(this.specForm.errors);
+ // console.log(this.specForm.value);
+ }
+
+ public static createInitRcSpec(): K8SRCSpec {
+ return {
+ 'pods': 1,
+ supportHpa: false, minHpaPod: 1, maxHpaPod: 3, cpuAverageUtilization: 10, cuprequest: 500,
+ cuprequestunit: 'm',
+ cuplimitunit: 'cores',
+ cuplimit: 1,
+ memoryrequest: 500,
+ memoryrequestunit: 'M',
+ memorylimit: 2,
+ memorylimitunit: 'G'
+ };
+ }
}
export interface K8SRCSpec {
- supportHpa: boolean,
- minHpaPod: number,
- maxHpaPod: number,
- cpuAverageUtilization: number,
- pods: number,
- cuprequest: number,
- cuprequestunit: string,
- cuplimitunit: string,
- cuplimit: number,
- memoryrequest: number,
- memoryrequestunit: string,
- memorylimit: number,
- memorylimitunit: string
+ /**
+ * HPA ====================================
+ */
+ supportHpa: boolean,
+ minHpaPod: number,
+ maxHpaPod: number,
+ cpuAverageUtilization: number,
+ /**
+ * end HPA ====================================
+ */
+
+ pods: number,
+ cuprequest: number,
+ cuprequestunit: string,
+ cuplimitunit: string,
+ cuplimit: number,
+ memoryrequest: number,
+ memoryrequestunit: string,
+ memorylimit: number,
+ memorylimitunit: string
}
diff --git a/src/common/plugins.component.ts b/src/common/plugins.component.ts
index 4cc17f3..6f7fbd8 100644
--- a/src/common/plugins.component.ts
+++ b/src/common/plugins.component.ts
@@ -17,41 +17,41 @@
*/
import {
- AfterContentInit,
- AfterViewInit,
- ChangeDetectionStrategy,
- ChangeDetectorRef,
- Component,
- EventEmitter,
- Input,
- OnDestroy,
- OnInit,
- Output,
- TemplateRef,
- ViewChild
+ AfterContentInit,
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ EventEmitter,
+ Input,
+ OnDestroy,
+ OnInit,
+ Output,
+ TemplateRef,
+ ViewChild
} from "@angular/core";
import {TISService} from "./tis.service";
import {AppFormComponent, BasicFormComponent, CurrentCollection} from "../common/basic.form.component";
import {ActivatedRoute, Router} from "@angular/router";
import {
- AttrDesc,
- Descriptor,
- HeteroList,
- Item,
- ItemPropVal,
- PluginMeta,
- PluginName,
- PluginSaveResponse,
- PluginType,
- SavePluginEvent,
- TisResponseResult,
- TYPE_ENUM,
- PARAM_END_TYPE,
- TYPE_PLUGIN_SELECTION,
- CONST_FORM_LAYOUT_VERTICAL,
- ValOption,
- OptionEnum, DescribleVal
+ AttrDesc,
+ Descriptor,
+ HeteroList,
+ Item,
+ ItemPropVal,
+ PluginMeta,
+ PluginName,
+ PluginSaveResponse,
+ PluginType,
+ SavePluginEvent,
+ TisResponseResult,
+ TYPE_ENUM,
+ PARAM_END_TYPE,
+ TYPE_PLUGIN_SELECTION,
+ CONST_FORM_LAYOUT_VERTICAL,
+ ValOption,
+ OptionEnum, DescribleVal
} from "./tis.plugin";
import {NzModalRef, NzModalService} from "ng-zorro-antd/modal";
import {NzNotificationService} from "ng-zorro-antd/notification";
@@ -65,741 +65,743 @@ import {FunctionCall} from "@angular/compiler";
@Component({
- selector: 'tis-plugins',
- changeDetection: ChangeDetectionStrategy.OnPush,
- template: `
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1 " class="plugins-nav">
-
-
-
-
-
-
-
-
-
-
-
+ selector: 'tis-plugins',
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ template: `
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1 " class="plugins-nav">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- Notbook功能还未激活,如何在TIS中启用Zeppelin Notebook功能,详细请查看 文档
-
-
- `,
- styles: [
- `
- .plugin-link {
- text-decoration: underline;
- }
-
- .plugin-link:hover {
- background-color: #b7d6ff;
- }
-
- .extension-point {
- margin-bottom: 10px;
- }
-
- .item-block {
- border: 1px solid #9c9c9c;
- margin-bottom: 10px;
- padding: 5px;
- }
-
- .plugins-nav nz-link {
- display: inline-block;
- }
-
- nz-select {
- width: 100%;
- }
- `
- ]
+
+
+
+
+
+
+
+
+
+ Notbook功能还未激活,如何在TIS中启用Zeppelin Notebook功能,详细请查看 文档
+
+
+ `,
+ styles: [
+ `
+ .plugin-link {
+ text-decoration: underline;
+ }
+
+ .plugin-link:hover {
+ background-color: #b7d6ff;
+ }
+
+ .extension-point {
+ margin-bottom: 10px;
+ }
+
+ .item-block {
+ border: 1px solid #9c9c9c;
+ margin-bottom: 10px;
+ padding: 5px;
+ }
+
+ .plugins-nav nz-link {
+ display: inline-block;
+ }
+
+ nz-select {
+ width: 100%;
+ }
+ `
+ ]
})
export class PluginsComponent extends AppFormComponent implements AfterContentInit, AfterViewInit, OnDestroy {
- // private _incrScript: string;
- // @Output() nextStep = new EventEmitter();
- // @Output() preStep = new EventEmitter();
- // @Input() dto: IndexIncrStatus;
- // _validateForm: FormGroup;
- // 是否显示扩展点详细
- // @Input()
- // disabled = false;
+ // private _incrScript: string;
+ // @Output() nextStep = new EventEmitter();
+ // @Output() preStep = new EventEmitter();
+ // @Input() dto: IndexIncrStatus;
+ // _validateForm: FormGroup;
+ // 是否显示扩展点详细
+ // @Input()
+ // disabled = false;
- @Input()
- disableVerify: boolean;
+ @Input()
+ disableVerify: boolean;
- @Input()
- showExtensionPoint: { open: boolean } = {open: false};
+ @Input()
+ showExtensionPoint: { open: boolean } = {open: false};
- @Input()
- errorsPageShow = false;
+ @Input()
+ errorsPageShow = false;
- // 如果该插件用在DbAddComponent中作为添加组件用
- @Input() shallInitializePluginItems = true;
+ // 如果该插件用在DbAddComponent中作为添加组件用
+ @Input() shallInitializePluginItems = true;
- @Input() itemChangeable = true;
+ @Input() itemChangeable = true;
- @Input() _heteroList: HeteroList[] = [];
- private _plugins: PluginType[] = [];
+ @Input() _heteroList: HeteroList[] = [];
+ private _plugins: PluginType[] = [];
- @Output() afterInit: EventEmitter = new EventEmitter();
- @Input() formControlSpan = 13;
+ @Output() afterInit: EventEmitter = new EventEmitter();
+ @Input() formControlSpan = 13;
- // notShowBizMsg: 不需要在客户端显示成功信息
- @Input() savePlugin: EventEmitter;
- // 是否显示保存按钮
- @Input() showSaveButton = false;
+ // notShowBizMsg: 不需要在客户端显示成功信息
+ @Input() savePlugin: EventEmitter;
+ // 是否显示保存按钮
+ @Input() showSaveButton = false;
- // 内部控件是否为只读
- @Input() disabled = false;
+ // 内部控件是否为只读
+ @Input() disabled = false;
- subscription: Subscription;
+ subscription: Subscription;
- @Output() ajaxOccur = new EventEmitter();
- @Output() afterSave = new EventEmitter();
+ @Output() ajaxOccur = new EventEmitter();
+ @Output() afterSave = new EventEmitter();
- @Output() startNotebook = new EventEmitter();
+ @Output() startNotebook = new EventEmitter();
- @ViewChild('notebookNotActivate', {read: TemplateRef, static: true}) notebookNotActivate: TemplateRef;
- @Input() disableNotebook = false;
+ @ViewChild('notebookNotActivate', {read: TemplateRef, static: true}) notebookNotActivate: TemplateRef;
+ @Input() disableNotebook = false;
- /**
- * 当前选中的DS plugin 描述信息
- * @param desc
- */
- public static pluginDesc(desc: Descriptor, pluginCategory: PluginType
- , itemPropSetter?: (key: string, propVal: ItemPropVal) => ItemPropVal, updateModel?: boolean): HeteroList[] {
- if (!desc) {
- throw new Error("param desc can not be null");
- }
- let h = new HeteroList();
- h.pluginCategory = pluginCategory;
- h.extensionPoint = desc.extendPoint;
- h.descriptors.set(desc.impl, desc);
- if (!itemPropSetter) {
- itemPropSetter = (_, p) => p;
- }
- Descriptor.addNewItem(h, desc, updateModel, itemPropSetter);
- // console.log(h);
- return [h];
+ /**
+ * 当前选中的DS plugin 描述信息
+ * @param desc
+ */
+ public static pluginDesc(desc: Descriptor, pluginCategory: PluginType
+ , itemPropSetter?: (key: string, propVal: ItemPropVal) => ItemPropVal, updateModel?: boolean): HeteroList[] {
+ if (!desc) {
+ throw new Error("param desc can not be null");
}
-
- public static openPluginInstanceAddDialog(b: BasicFormComponent, pluginDesc: Descriptor, pluginTp: PluginType, title: string, onSuccess: (biz) => void) {
- PluginsComponent.openPluginDialog({shallLoadSavedItems: false}, b, pluginDesc, pluginTp, title, onSuccess);
+ let h = new HeteroList();
+ h.pluginCategory = pluginCategory;
+ h.extensionPoint = desc.extendPoint;
+ h.descriptors.set(desc.impl, desc);
+ if (!itemPropSetter) {
+ itemPropSetter = (_, p) => p;
}
-
- public static openPluginDialog(opts: OpenPluginDialogOptions, b: BasicFormComponent
- , pluginDesc: Descriptor, pluginTp: PluginType, title: string, onSuccess: (biz) => void): NzModalRef {
- let modalRef = b.openDialog(PluginsComponent, {nzTitle: title});
- let addDb: PluginsComponent = modalRef.getContentComponent();
-
- addDb.errorsPageShow = true;
- addDb.getCurrentAppCache = true;
- addDb.formControlSpan = 19;
- addDb.shallInitializePluginItems = false;
- addDb.disableNotebook = true;
- addDb._heteroList = PluginsComponent.pluginDesc(pluginDesc, pluginTp);
- if (opts.shallLoadSavedItems) {
- addDb.plugins = [pluginTp];
- } else {
- addDb.setPluginMeta([pluginTp])
- }
- if (opts.savePluginEventCreator) {
- addDb.savePluginEventCreator = opts.savePluginEventCreator;
- }
-
- addDb.showSaveButton = true;
- addDb.afterSave.subscribe((r: PluginSaveResponse) => {
- // console.log(r);
- if (r && r.saveSuccess && r.hasBiz()) {
- modalRef.close();
- let db = r.biz();
-
- onSuccess(db);
- }
- });
- return modalRef;
+ Descriptor.addNewItem(h, desc, updateModel, itemPropSetter);
+ // console.log(h);
+ return [h];
+ }
+
+ public static openPluginInstanceAddDialog(b: BasicFormComponent, pluginDesc: Descriptor, pluginTp: PluginType, title: string, onSuccess: (biz) => void) {
+ PluginsComponent.openPluginDialog({shallLoadSavedItems: false}, b, pluginDesc, pluginTp, title, onSuccess);
+ }
+
+ public static openPluginDialog(opts: OpenPluginDialogOptions, b: BasicFormComponent
+ , pluginDesc: Descriptor, pluginTp: PluginType, title: string, onSuccess: (biz) => void): NzModalRef {
+ let modalRef = b.openDialog(PluginsComponent, {nzTitle: title});
+ let addDb: PluginsComponent = modalRef.getContentComponent();
+
+ addDb.errorsPageShow = true;
+ addDb.getCurrentAppCache = true;
+ addDb.formControlSpan = 19;
+ addDb.shallInitializePluginItems = false;
+ addDb.disableNotebook = true;
+ addDb._heteroList = PluginsComponent.pluginDesc(pluginDesc, pluginTp);
+ if (opts.shallLoadSavedItems) {
+ addDb.plugins = [pluginTp];
+ } else {
+ addDb.setPluginMeta([pluginTp])
}
-
-
- public static getPluginMetaParams(pluginMeta: PluginType[]): string {
- return pluginMeta.map((p) => {
- let param: any = p;
- // console.log(param);
- if (param.name) {
- let t: PluginMeta = param;
- let metaParam = `${t.name}:${t.require ? 'require' : ''}${t.extraParam ? (',' + t.extraParam) : ''}`
- if (Array.isArray(t.appendParams) && t.appendParams.length > 0) {
- metaParam += ("&" + t.appendParams.map((p) => p.key + "=" + p.val).join("&"));
- }
- return metaParam;
- } else {
- return p;
- }
- }).join("&plugin=");
- }
-
- public static wrapperHeteroList(he: HeteroList, pm: PluginType): HeteroList {
- let h: HeteroList = Object.assign(new HeteroList(), he, {"pluginCategory": pm});
- let descMap = PluginsComponent.wrapDescriptors(h.descriptors);
- // console.log(descMap);
- h.descriptors = descMap;
- // 遍历item
- let items: Item[] = [];
- let i: Item;
- h.items.forEach((item) => {
-
- let desc: Descriptor = h.descriptors.get(item.impl);
- if (!desc) {
- if ((pm).skipSubformDescNullError) {
- return;
- }
- // console.log([he, pm]);
- throw new Error("desc impl:" + item.impl + " relevant desc can not be null");
- }
- // console.log([item.impl, desc]);
- if (desc.subForm) {
- i = new Item(desc);
- i.displayName = item.displayName;
- // i.containAdvance = item.containAdvance;
- let rawVal = item.vals;
- // delete item.vals;
- let subFrom: Array- ;
- let subFromItems: Array
- ;
- let subFormVals: { [tabname: string]: { [propKey: string]: ItemPropVal } } = {};
-
- for (let subFieldPk in rawVal) {
- subFrom = >rawVal[subFieldPk];
- // console.log([subFrom, subFieldPk]);
- subFromItems = new Array
- ();
- subFrom.forEach((form) => {
- let subformDesc: Descriptor = h.descriptors.get(form.impl);
- // console.log([h.descriptors, form.impl]);
- if (!subformDesc) {
- if ((pm).skipSubformDescNullError) {
- return;
- }
-
- throw new Error("desc impl:" + form.impl + " relevant desc can not be null");
- }
- let ii = Object.assign(new Item(subformDesc), form);
- // ii.vals = subFrom;
- ii.wrapItemVals();
- subFromItems.push(ii);
- });
- // console.log([subFrom, desc]);
- // console.log(i.itemVals);
- // console.log([subFrom, ii.vals]);
- // @ts-ignore
- subFormVals[subFieldPk] = subFromItems;
- }
- i.vals = subFormVals;
- // console.log(i);
- // i.subFormRawVals = rawVal;
- } else {
- i = Object.assign(new Item(desc), item);
- i.wrapItemVals();
- // console.log(i);
- }
- // console.log(i);
- items.push(i);
- });
- h.items = items;
- // console.log(h);
- return h;
+ if (opts.savePluginEventCreator) {
+ addDb.savePluginEventCreator = opts.savePluginEventCreator;
}
- public static initializePluginItems(ctx: BasicFormComponent, pm: PluginType[]
- , useCache: boolean, callback: (success: boolean, _heteroList: HeteroList[], showExtensionPoint: boolean) => void): Promise {
- let pluginMeta = PluginsComponent.getPluginMetaParams(pm);
- let url = '/coredefine/corenodemanage.ajax?event_submit_do_get_plugin_config_info=y&action=plugin_action&plugin=' + pluginMeta + '&use_cache=' + useCache;
-
- return ctx.jsonPost(url, {}).then((r) => {
- let _heteroList: HeteroList[] = [];
- if (r.success) {
- let bizArray: HeteroList[] = r.bizresult.plugins;
- // console.log([pm, bizArray]);
- for (let i = 0; i < pm.length; i++) {
- //
- let h: HeteroList = PluginsComponent.wrapperHeteroList(bizArray[i], pm[i]);
- // console.log([bizArray[i], pm[i], h]);
- _heteroList.push(h);
- }
- }
- callback(r.success, _heteroList, r.success ? r.bizresult.showExtensionPoint : false);
- return r;
- })
- }
-
- public static wrapDescriptors(descriptors: Map)
- : Map {
- let descMap: Map = new Map();
- let d: Descriptor = null;
- let attrs: AttrDesc[];
- let attr: AttrDesc;
- // console.log(descriptors);
- for (let impl in descriptors) {
- d = Object.assign(new Descriptor(), descriptors[impl]);
- attrs = [];
- d.attrs.forEach((a) => {
-
- attr = Object.assign(new AttrDesc(), a);
- if (attr.describable) {
- attr.descriptors = this.wrapDescriptors(attr.descriptors);
- }
- if (attr.options) {
- let opts: ValOption[] = [];
- attr.options.forEach((opt) => {
- opts.push(Object.assign(new ValOption(), opt));
- });
- attr.options = opts;
- }
- attrs.push(attr);
- });
- d.attrs = attrs;
- descMap.set(impl, d);
+ addDb.showSaveButton = true;
+ addDb.afterSave.subscribe((r: PluginSaveResponse) => {
+ // console.log(r);
+ if (r && r.saveSuccess && r.hasBiz()) {
+ modalRef.close();
+ let db = r.biz();
+
+ onSuccess(db);
+ }
+ });
+ return modalRef;
+ }
+
+
+ public static getPluginMetaParams(pluginMeta: PluginType[]): string {
+ return pluginMeta.map((p) => {
+ let param: any = p;
+ // console.log(param);
+ if (param.name) {
+ let t: PluginMeta = param;
+ let metaParam = `${t.name}:${t.require ? 'require' : ''}${t.extraParam ? (',' + t.extraParam) : ''}`
+ if (Array.isArray(t.appendParams) && t.appendParams.length > 0) {
+ metaParam += ("&" + t.appendParams.map((p) => p.key + "=" + p.val).join("&"));
}
- // console.log(descMap);
- return descMap;
- }
-
-
- public static postHeteroList(basicModule: BasicFormComponent, pluginMetas: PluginType[], heteroList: HeteroList[]
- , savePluginEvent: SavePluginEvent, errorsPageShow: boolean, processCallback: (r: TisResponseResult) => void, errProcessCallback?: (r: TisResponseResult) => void): void {
-
- let pluginMeta = PluginsComponent.getPluginMetaParams(pluginMetas);
-
- let url = `/coredefine/corenodemanage.ajax?event_submit_do_save_plugin_config=y&action=plugin_action&plugin=${pluginMeta}&errors_page_show=${errorsPageShow}&verify=${savePluginEvent.verifyConfig}&getNotebook=${savePluginEvent.createOrGetNotebook}`;
-
- let items: Array
- = [];
- heteroList.forEach((h) => {
- items.push(h.items);
- });
- let postData: any = {"items": items};
-
- if (savePluginEvent.serverForward) {
- postData.serverForward = savePluginEvent.serverForward;
- if (savePluginEvent.postPayload) {
- postData = Object.assign(postData, savePluginEvent.postPayload);
- }
+ return metaParam;
+ } else {
+ return p;
+ }
+ }).join("&plugin=");
+ }
+
+ public static wrapperHeteroList(he: HeteroList, pm: PluginType): HeteroList {
+ let h: HeteroList = Object.assign(new HeteroList(), he, {"pluginCategory": pm});
+ let descMap = PluginsComponent.wrapDescriptors(h.descriptors);
+ // console.log(descMap);
+ h.descriptors = descMap;
+ // 遍历item
+ let items: Item[] = [];
+ let i: Item;
+ h.items.forEach((item) => {
+
+ let desc: Descriptor = h.descriptors.get(item.impl);
+ if (!desc) {
+ if ((pm).skipSubformDescNullError) {
+ return;
}
- // console.log([postData,savePluginEvent.postPayload]);
- // console.log([heteroList.length, heteroList]);
-
- basicModule.jsonPost(url, postData, savePluginEvent).then((r) => {
- processCallback(r);
- }).catch((e) => {
- if (errProcessCallback) {
- errProcessCallback(e);
- }
- });
- }
-
- @Input()
- public set getCurrentAppCache(val: boolean) {
- super.getCurrentAppCache = val;
- }
+ // console.log([he, pm]);
+ throw new Error("desc impl:" + item.impl + " relevant desc can not be null");
+ }
+ // console.log([item.impl, desc]);
+ if (desc.subForm) {
+ i = new Item(desc);
+ i.displayName = item.displayName;
+ // i.containAdvance = item.containAdvance;
+ let rawVal = item.vals;
+ // delete item.vals;
+ let subFrom: Array
- ;
+ let subFromItems: Array
- ;
+ let subFormVals: { [tabname: string]: { [propKey: string]: ItemPropVal } } = {};
+
+ for (let subFieldPk in rawVal) {
+ subFrom = >rawVal[subFieldPk];
+ // console.log([subFrom, subFieldPk]);
+ subFromItems = new Array
- ();
+ subFrom.forEach((form) => {
+ let subformDesc: Descriptor = h.descriptors.get(form.impl);
+ // console.log([h.descriptors, form.impl]);
+ if (!subformDesc) {
+ if ((pm).skipSubformDescNullError) {
+ return;
+ }
- filterDescriptor(h: HeteroList, pluginMetas: PluginType[], desc: Descriptor) {
- let pt: PluginType;
- let o: any;
- let meta: PluginMeta;
- for (let i = 0; i < pluginMetas.length; i++) {
- pt = pluginMetas[i];
- o = pt;
- if (o.name && o.descFilter && h.identityId === o.name) {
- meta = o;
- return meta.descFilter.localDescFilter(desc);
+ throw new Error("desc impl:" + form.impl + " relevant desc can not be null");
}
+ let ii = Object.assign(new Item(subformDesc), form);
+ // ii.vals = subFrom;
+ ii.wrapItemVals();
+ subFromItems.push(ii);
+ });
+ // console.log([subFrom, desc]);
+ // console.log(i.itemVals);
+ // console.log([subFrom, ii.vals]);
+ // @ts-ignore
+ subFormVals[subFieldPk] = subFromItems;
}
- return true;
- }
-
-
- configCheck(h: HeteroList, item: Item, event: MouseEvent) {
- let savePlugin = new SavePluginEvent();
- savePlugin.verifyConfig = true;
- savePlugin.notShowBizMsg = false;
- // this.savePluginSetting(event, savePlugin);
- if (!h.pluginCategory) {
- throw new Error("pluginCategory can not be null");
+ i.vals = subFormVals;
+ // console.log(i);
+ // i.subFormRawVals = rawVal;
+ } else {
+ i = Object.assign(new Item(desc), item);
+ i.wrapItemVals();
+ // console.log(i);
+ }
+ // console.log(i);
+ items.push(i);
+ });
+ h.items = items;
+ // console.log(h);
+ return h;
+ }
+
+ public static initializePluginItems(ctx: BasicFormComponent, pm: PluginType[]
+ , useCache: boolean, callback: (success: boolean, _heteroList: HeteroList[], showExtensionPoint: boolean) => void): Promise {
+ let pluginMeta = PluginsComponent.getPluginMetaParams(pm);
+ let url = '/coredefine/corenodemanage.ajax?event_submit_do_get_plugin_config_info=y&action=plugin_action&plugin=' + pluginMeta + '&use_cache=' + useCache;
+
+ return ctx.jsonPost(url, {}).then((r) => {
+ let _heteroList: HeteroList[] = [];
+ if (r.success) {
+ let bizArray: HeteroList[] = r.bizresult.plugins;
+ // console.log([pm, bizArray]);
+ for (let i = 0; i < pm.length; i++) {
+ //
+ let h: HeteroList = PluginsComponent.wrapperHeteroList(bizArray[i], pm[i]);
+ // console.log([bizArray[i], pm[i], h]);
+ _heteroList.push(h);
+ }
+ }
+ callback(r.success, _heteroList, r.success ? r.bizresult.showExtensionPoint : false);
+ return r;
+ })
+ }
+
+ public static wrapDescriptors(descriptors: Map)
+ : Map {
+ let descMap: Map = new Map();
+ let d: Descriptor = null;
+ let attrs: AttrDesc[];
+ let attr: AttrDesc;
+ // console.log(descriptors);
+ for (let impl in descriptors) {
+ d = Object.assign(new Descriptor(), descriptors[impl]);
+ attrs = [];
+ d.attrs.forEach((a) => {
+
+ attr = Object.assign(new AttrDesc(), a);
+ if (attr.describable) {
+ attr.descriptors = this.wrapDescriptors(attr.descriptors);
+ }
+ if (attr.options) {
+ let opts: ValOption[] = [];
+ attr.options.forEach((opt) => {
+ opts.push(Object.assign(new ValOption(), opt));
+ });
+ attr.options = opts;
}
- // console.log([this.plugins, h.pluginCategory]);
- let nh = Object.assign(new HeteroList(), h);
- nh.items = [item];
- this._savePluginInfo(event, savePlugin, [h.pluginCategory], [nh]);
+ attrs.push(attr);
+ });
+ d.attrs = attrs;
+ descMap.set(impl, d);
}
+ // console.log(descMap);
+ return descMap;
+ }
- openNotebook(h: HeteroList, item: Item, event: MouseEvent) {
- if (!item.dspt.notebook.activate) {
- this.modalService.warning({
- nzTitle: "错误",
- nzContent: this.notebookNotActivate,
- nzOkText: "知道啦"
- });
- return;
- }
+ public static postHeteroList(basicModule: BasicFormComponent, pluginMetas: PluginType[], heteroList: HeteroList[]
+ , savePluginEvent: SavePluginEvent, errorsPageShow: boolean, processCallback: (r: TisResponseResult) => void, errProcessCallback?: (r: TisResponseResult) => void): void {
- let savePlugin = new SavePluginEvent();
- savePlugin.createOrGetNotebook = true;
- if (!h.pluginCategory) {
- throw new Error("pluginCategory can not be null");
- }
- let nh = Object.assign(new HeteroList(), h);
- nh.items = [item];
- this._savePluginInfo(event, savePlugin, [h.pluginCategory], [nh]);
- }
+ let pluginMeta = PluginsComponent.getPluginMetaParams(pluginMetas);
- @Input()
- set plugins(metas: PluginType[]) {
- // console.log(metas);
- this.setPluginMeta(metas);
- if (!this.shallInitializePluginItems) {
- this.initializePluginItems();
- }
- }
+ let url = `/coredefine/corenodemanage.ajax?event_submit_do_save_plugin_config=y&action=plugin_action&plugin=${pluginMeta}&errors_page_show=${errorsPageShow}&verify=${savePluginEvent.verifyConfig}&getNotebook=${savePluginEvent.createOrGetNotebook}`;
- @Input()
- set pluginMeta(metas: PluginType[]) {
- this.setPluginMeta(metas);
- }
+ let items: Array
- = [];
+ heteroList.forEach((h) => {
+ items.push(h.items);
+ });
+ let postData: any = {"items": items};
- public setPluginMeta(metas: PluginType[]): void {
- if (!metas || metas.length < 1) {
- return;
- }
- this._plugins = metas;
+ if (savePluginEvent.serverForward) {
+ postData.serverForward = savePluginEvent.serverForward;
+ if (savePluginEvent.postPayload) {
+ postData = Object.assign(postData, savePluginEvent.postPayload);
+ }
}
-
- get plugins(): PluginType[] {
- return this._plugins;
+ // console.log([postData,savePluginEvent.postPayload]);
+ // console.log([heteroList.length, heteroList]);
+
+ basicModule.jsonPost(url, postData, savePluginEvent).then((r) => {
+ processCallback(r);
+ }).catch((e) => {
+ if (errProcessCallback) {
+ errProcessCallback(e);
+ }
+ });
+ }
+
+ @Input()
+ public set getCurrentAppCache(val: boolean) {
+ super.getCurrentAppCache = val;
+ }
+
+ filterDescriptor(h: HeteroList, pluginMetas: PluginType[], desc: Descriptor) {
+ let pt: PluginType;
+ let o: any;
+ let meta: PluginMeta;
+ for (let i = 0; i < pluginMetas.length; i++) {
+ pt = pluginMetas[i];
+ o = pt;
+ if (o.name && o.descFilter && h.identityId === o.name) {
+ meta = o;
+ return meta.descFilter.localDescFilter(desc);
+ }
}
+ return true;
+ }
- constructor(tisService: TISService, private router: Router, route: ActivatedRoute, modalService: NzModalService
- , notification: NzNotificationService
- , private cdr: ChangeDetectorRef, private drawerService: NzDrawerService) {
- super(tisService, route, modalService, notification);
- this.cdr.detach();
+ configCheck(h: HeteroList, item: Item, event: MouseEvent) {
+ let savePlugin = new SavePluginEvent();
+ savePlugin.verifyConfig = true;
+ savePlugin.notShowBizMsg = false;
+ // this.savePluginSetting(event, savePlugin);
+ if (!h.pluginCategory) {
+ throw new Error("pluginCategory can not be null");
}
-
- ngAfterViewInit(): void {
+ // console.log([this.plugins, h.pluginCategory]);
+ let nh = Object.assign(new HeteroList(), h);
+ nh.items = [item];
+ this._savePluginInfo(event, savePlugin, [h.pluginCategory], [nh]);
+ }
+
+ openNotebook(h: HeteroList, item: Item, event: MouseEvent) {
+
+ if (!item.dspt.notebook.activate) {
+ this.modalService.warning({
+ nzTitle: "错误",
+ nzContent: this.notebookNotActivate,
+ nzOkText: "知道啦"
+ });
+ return;
}
- ngOnInit() {
- // super.ngOnInit();
+ let savePlugin = new SavePluginEvent();
+ savePlugin.createOrGetNotebook = true;
+ if (!h.pluginCategory) {
+ throw new Error("pluginCategory can not be null");
}
-
- ngOnDestroy(): void {
- if (this.subscription) {
- this.subscription.unsubscribe();
- }
+ let nh = Object.assign(new HeteroList(), h);
+ nh.items = [item];
+ this._savePluginInfo(event, savePlugin, [h.pluginCategory], [nh]);
+ }
+
+ @Input()
+ set plugins(metas: PluginType[]) {
+ // console.log(metas);
+ this.setPluginMeta(metas);
+ if (!this.shallInitializePluginItems) {
+ this.initializePluginItems();
}
+ }
+ @Input()
+ set pluginMeta(metas: PluginType[]) {
+ this.setPluginMeta(metas);
+ }
- ngAfterContentInit(): void {
- if (this.savePlugin) {
- this.subscription = this.savePlugin.subscribe((e: SavePluginEvent) => {
- this.savePluginSetting(null, e || new SavePluginEvent());
- });
- }
- this.ajaxOccur.emit(new PluginSaveResponse(false, true));
- // console.log("shallInitializePluginItems:"+ this.shallInitializePluginItems);
- if (this.shallInitializePluginItems) {
- if (!this.plugins || this.plugins.length < 1) {
- throw new Error("plugin argument can not be null");
- }
- this.initializePluginItems();
- } else {
- this.cdr.reattach();
- this.cdr.detectChanges();
- }
+ public setPluginMeta(metas: PluginType[]): void {
+ if (!metas || metas.length < 1) {
+ return;
}
+ this._plugins = metas;
+ }
+ get plugins(): PluginType[] {
+ return this._plugins;
+ }
- public initializePluginItems() {
- // console.log(this.plugins);
- PluginsComponent.initializePluginItems(this, this.plugins, true, (success: boolean, hList: HeteroList[], showExtensionPoint: boolean) => {
- if (success) {
- this.showExtensionPoint.open = showExtensionPoint;
- this._heteroList = hList;
- this.afterInit.emit(this._heteroList);
- this.cdr.reattach();
- this.cdr.detectChanges();
- }
- this.ajaxOccur.emit(new PluginSaveResponse(success, false));
- });
- }
+ constructor(tisService: TISService, private router: Router, route: ActivatedRoute, modalService: NzModalService
+ , notification: NzNotificationService
+ , private cdr: ChangeDetectorRef, private drawerService: NzDrawerService) {
+ super(tisService, route, modalService, notification);
+ this.cdr.detach();
+ }
- submitForm(value: any): void {
- }
+ ngAfterViewInit(): void {
+ // console.log("ngAfterViewInit");
+ }
- protected initialize(app: CurrentCollection): void {
- }
+ ngOnInit() {
+ // super.ngOnInit();
+ }
- _savePlugin(event: MouseEvent) {
- let e = this.savePluginEventCreator();// new SavePluginEvent();
- e.verifyConfig = false;
- this.savePluginSetting(event, e);
+ ngOnDestroy(): void {
+ if (this.subscription) {
+ this.subscription.unsubscribe();
}
+ }
- @Input()
- private savePluginEventCreator = () => new SavePluginEvent();
- savePluginSetting(event: MouseEvent, savePluginEvent: SavePluginEvent) {
- this._savePluginInfo(event, savePluginEvent, this.plugins, this._heteroList);
+ ngAfterContentInit(): void {
+ if (this.savePlugin) {
+ this.subscription = this.savePlugin.subscribe((e: SavePluginEvent) => {
+ this.savePluginSetting(null, e || new SavePluginEvent());
+ });
}
+ this.ajaxOccur.emit(new PluginSaveResponse(false, true, null));
+ // console.log("shallInitializePluginItems:"+ this.shallInitializePluginItems);
+ if (this.shallInitializePluginItems) {
+ if (!this.plugins || this.plugins.length < 1) {
+ throw new Error("plugin argument can not be null");
+ }
+ this.initializePluginItems();
+ } else {
+ this.cdr.reattach();
+ this.cdr.detectChanges();
+ this.ajaxOccur.emit(new PluginSaveResponse(true, false, null));
+ }
+ }
+
+
+ public initializePluginItems() {
+ // console.log(this.plugins);
+ PluginsComponent.initializePluginItems(this, this.plugins, true, (success: boolean, hList: HeteroList[], showExtensionPoint: boolean) => {
+ if (success) {
+ this.showExtensionPoint.open = showExtensionPoint;
+ this._heteroList = hList;
+ this.afterInit.emit(this._heteroList);
+ this.cdr.reattach();
+ this.cdr.detectChanges();
+ }
+
+ this.ajaxOccur.emit(new PluginSaveResponse(success, false,null));
+ });
+ }
+
+ submitForm(value: any): void {
+ }
+
+ protected initialize(app: CurrentCollection): void {
+ }
+
+ _savePlugin(event: MouseEvent) {
+ let e = this.savePluginEventCreator();// new SavePluginEvent();
+ e.verifyConfig = false;
+ this.savePluginSetting(event, e);
+ }
+
+ @Input()
+ private savePluginEventCreator = () => new SavePluginEvent();
+
+ savePluginSetting(event: MouseEvent, savePluginEvent: SavePluginEvent) {
+ this._savePluginInfo(event, savePluginEvent, this.plugins, this._heteroList);
+ }
+
+ _savePluginInfo(event: MouseEvent, savePluginEvent: SavePluginEvent, pluginTypes: PluginType[], _heteroList: HeteroList[]) {
+ // console.log(JSON.stringify(this._heteroList.items));
+ this.ajaxOccur.emit(new PluginSaveResponse(false, true, savePluginEvent));
+ // console.log(this.plugins);
+ // let pluginMeta = PluginsComponent.getPluginMetaParams(this.plugins);
+ // 如果 传入的tisService 中设置了appname的header那可以通过plugin的表单提交一并提交到服务端
+ let formContext = !!savePluginEvent.basicModule ? savePluginEvent.basicModule : this;
+ // console.log(_heteroList);
+ PluginsComponent.postHeteroList(formContext, pluginTypes, _heteroList, savePluginEvent, this.errorsPageShow, (r) => {
+ // 成功了
+ this.ajaxOccur.emit(new PluginSaveResponse(r.success, false, savePluginEvent));
+ if (!savePluginEvent.verifyConfig && !savePluginEvent.createOrGetNotebook) {
+ this.afterSave.emit(new PluginSaveResponse(r.success, false, savePluginEvent ,r.bizresult));
+ } else {
+ if (savePluginEvent.verifyConfig && r.success) {
+ if (!r.msg || r.msg.length < 1) {
+ this.notification.create('success', '校验成功', "表单配置无误");
+ }
+ }
- _savePluginInfo(event: MouseEvent, savePluginEvent: SavePluginEvent, pluginTypes: PluginType[], _heteroList: HeteroList[]) {
- // console.log(JSON.stringify(this._heteroList.items));
- this.ajaxOccur.emit(new PluginSaveResponse(false, true));
- // console.log(this.plugins);
- // let pluginMeta = PluginsComponent.getPluginMetaParams(this.plugins);
- // 如果 传入的tisService 中设置了appname的header那可以通过plugin的表单提交一并提交到服务端
- let formContext = !!savePluginEvent.basicModule ? savePluginEvent.basicModule : this;
- // console.log(_heteroList);
- PluginsComponent.postHeteroList(formContext, pluginTypes, _heteroList, savePluginEvent, this.errorsPageShow, (r) => {
- // 成功了
- this.ajaxOccur.emit(new PluginSaveResponse(r.success, false));
- if (!savePluginEvent.verifyConfig && !savePluginEvent.createOrGetNotebook) {
- this.afterSave.emit(new PluginSaveResponse(r.success, false, r.bizresult));
- } else {
- if (savePluginEvent.verifyConfig && r.success) {
- if (!r.msg || r.msg.length < 1) {
- this.notification.create('success', '校验成功', "表单配置无误");
- }
- }
-
- if (savePluginEvent.createOrGetNotebook && r.success) {
- if (this.startNotebook.observers.length > 0) {
- this.startNotebook.emit(new PluginSaveResponse(r.success, false, r.bizresult));
- } else {
- const drawerRef = this.drawerService.create({
- nzWidth: "80%",
- nzPlacement: "right",
- nzContent: NotebookwrapperComponent,
- nzContentParams: {},
- nzClosable: false
- });
- // this.router.navigate()
-
- this.router.navigate(["/", {outlets: {"zeppelin": `z/zeppelin/notebook/${r.bizresult}`}}], {relativeTo: this.route})
- }
- }
- }
-
- if (!this.errorsPageShow && r.success) {
- // 如果在其他流程中嵌入执行(showSaveButton = false) 一般不需要显示成功信息
- if (this.showSaveButton && r.msg.length > 0) {
- // this.notification.create('success', '成功dd', r.msg[0]);
- }
- return;
- }
-
- this.processResult(r);
- this.cdr.detectChanges();
- let pluginErrorFields = r.errorfields;
- // console.log(pluginErrorFields);
- let index = 0;
- // let tmpHlist: HeteroList[] = [];
- _heteroList.forEach((h) => {
- let items: Item[] = h.items;
- let errorFields = pluginErrorFields[index++];
- // console.log(errorFields);
- Item.processErrorField(errorFields, items);
+ if (savePluginEvent.createOrGetNotebook && r.success) {
+ if (this.startNotebook.observers.length > 0) {
+ this.startNotebook.emit(new PluginSaveResponse(r.success, false, r.bizresult));
+ } else {
+ const drawerRef = this.drawerService.create({
+ nzWidth: "80%",
+ nzPlacement: "right",
+ nzContent: NotebookwrapperComponent,
+ nzContentParams: {},
+ nzClosable: false
});
- this.cdr.detectChanges();
- }, (err) => {
- this.ajaxOccur.emit(new PluginSaveResponse(false, false));
- });
+ // this.router.navigate()
- if (event) {
- event.stopPropagation();
+ this.router.navigate(["/", {outlets: {"zeppelin": `z/zeppelin/notebook/${r.bizresult}`}}], {relativeTo: this.route})
+ }
}
- }
+ }
- removeItem(hlist: HeteroList, i: Item) {
- let arr = hlist.items;
- let newArr: Item[] = [];
- arr.forEach(function (e) {
- if (e !== i) {
- newArr.push(e);
- }
- });
- hlist.items = newArr;
- }
-
- startScroll(event: NzAnchorLinkComponent) {
- // console.log(event);
- }
-
- addNewPluginItem(h: HeteroList, d: Descriptor) {
- Descriptor.addNewItem(h, d, false, (_, propVal) => propVal);
+ if (!this.errorsPageShow && r.success) {
+ // 如果在其他流程中嵌入执行(showSaveButton = false) 一般不需要显示成功信息
+ if (this.showSaveButton && r.msg.length > 0) {
+ // this.notification.create('success', '成功dd', r.msg[0]);
+ }
+ return;
+ }
+
+ this.processResult(r);
+ this.cdr.detectChanges();
+ let pluginErrorFields = r.errorfields;
+ // console.log(pluginErrorFields);
+ let index = 0;
+ // let tmpHlist: HeteroList[] = [];
+ _heteroList.forEach((h) => {
+ let items: Item[] = h.items;
+ let errorFields = pluginErrorFields[index++];
+ // console.log(errorFields);
+ Item.processErrorField(errorFields, items);
+ });
+ this.cdr.detectChanges();
+ }, (err) => {
+ this.ajaxOccur.emit(new PluginSaveResponse(false, false, savePluginEvent));
+ });
+
+ if (event) {
+ event.stopPropagation();
}
+ }
+
+ removeItem(hlist: HeteroList, i: Item) {
+ let arr = hlist.items;
+ let newArr: Item[] = [];
+ arr.forEach(function (e) {
+ if (e !== i) {
+ newArr.push(e);
+ }
+ });
+ hlist.items = newArr;
+ }
+
+ startScroll(event: NzAnchorLinkComponent) {
+ // console.log(event);
+ }
+
+ addNewPluginItem(h: HeteroList, d: Descriptor) {
+ Descriptor.addNewItem(h, d, false, (_, propVal) => propVal);
+ }
+
+
+ updateHeteroListDesc(h: HeteroList) {
+
+ PluginsComponent.getAllDesc(this, h.extensionPoint, h.endType)
+ .then((descMap) => {
+ if (h.descriptors.size !== descMap.size) {
+ h.updateDescriptor(descMap);
+ this.cdr.detectChanges();
+ }
+ });
+ }
- updateHeteroListDesc(h: HeteroList) {
+ static getAllDesc(form: BasicFormComponent, extensionPoint: string, entype: string): Promise