Skip to content

Commit

Permalink
add external service to ExternalServiceDecorator
Browse files Browse the repository at this point in the history
  • Loading branch information
baisui1981 committed Mar 30, 2024
1 parent 47feef8 commit 1e743bd
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 35 deletions.
6 changes: 4 additions & 2 deletions .idea/workspace.xml

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

2 changes: 1 addition & 1 deletion src/base/datax.worker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class DataxWorkerComponent extends AppFormComponent implements AfterViewI
this.multiViewDAG = new MultiViewDAG(configFST, this._componentFactoryResolver, this.containerRef);

let next = (params) => {
console.log(params);
// console.log(params);
DataxWorkerComponent.getJobWorkerMeta(this, params, this.processMeta).then((dataXWorkerStatus) => {
if (dataXWorkerStatus.k8sReplicationControllerCreated) {
this.multiViewDAG.loadComponent(DataxWorkerRunningComponent, dataXWorkerStatus);
Expand Down
45 changes: 38 additions & 7 deletions src/base/datax.worker.running.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {PluginsComponent} from "../common/plugins.component";
import {languages} from "monaco-editor";
import {NzTabSetComponent} from "ng-zorro-antd/tabs/tabset.component";
import {LaunchK8SClusterWaittingProcessComponent} from "../common/launch.waitting.process.component";
import {DataxWorkerComponent} from "./datax.worker.component";

export const KEY_APPNAME = "appname";

Expand Down Expand Up @@ -137,7 +138,8 @@ export const KEY_APPNAME = "appname";
<incr-pod-logs-status *ngIf="selectedPod" [selectedPod]="selectedPod"
[processMeta]="this.dto.processMeta" [rcDeployments]="dto.rcDeployments"
[msgSubject]="this.msgSubject"
[logType]="logtype"></incr-pod-logs-status>
[logType]="logtype"
(afterOnePodRelaunch)="logsStatusOnePodLauch()"></incr-pod-logs-status>
</ng-template>
</nz-tab>
</ng-container>
Expand Down Expand Up @@ -214,7 +216,8 @@ export const KEY_APPNAME = "appname";
<ng-template #unableToUseK8SController>
可直接打开{{this.dto.processMeta.pageHeader}}控制台 &nbsp;<a target="_blank" [href]="server_port_host"><i nz-icon nzType="link" nzTheme="outline"></i>控制台</a>
可直接打开{{this.dto.processMeta.pageHeader}}控制台 &nbsp;<a target="_blank" [href]="server_port_host"><i
nz-icon nzType="link" nzTheme="outline"></i>控制台</a>
</ng-template>
</nz-alert>
Expand All @@ -230,12 +233,12 @@ export const KEY_APPNAME = "appname";
</ng-template>
<ng-template #controller>
<span nz-icon nzType="setting" nzTheme="outline"></span>操作
</ng-template>
<ng-template #extraTemplate>
<button nz-button nzType="link"><i nz-icon nzType="sync" nzTheme="outline"></i>更新</button>
<button nz-button nzType="link" (click)="refreshStatus()"><i nz-icon nzType="sync" nzTheme="outline"></i>更新
</button>
</ng-template>
</nz-spin>
`
Expand Down Expand Up @@ -293,6 +296,34 @@ export class DataxWorkerRunningComponent extends AppFormComponent implements Aft
super(tisService, route, modalService, notification);
}

refreshStatus() {
this.reloadStatus().then((status) => {
this.successNotify(this.dto.processMeta.pageHeader + "状态已更新");
});
}

private reloadStatus(): Promise<DataXJobWorkerStatus> {
return DataxWorkerComponent.getJobWorkerMeta(this, this.route.snapshot.params, this.dto.processMeta)
.then((dataXWorkerStatus) => {
if (dataXWorkerStatus.k8sReplicationControllerCreated) {
// Object.assign(this.dto,dataXWorkerStatus)
for (let key in dataXWorkerStatus) {
this.dto[key] = dataXWorkerStatus[key];
}
return dataXWorkerStatus;
}
});
}

logsStatusOnePodLauch() {

this.reloadStatus().then(status => {
this.router.navigate(["."], {relativeTo: this.route, fragment: "profile"});
this.tabSelectIndex = 0;
})

}

public gotoPage(page: number): void {
// this.tisService._zone.runOutsideAngular(()=>{
this.httpPost('/coredefine/corenodemanage.ajax'
Expand All @@ -317,7 +348,7 @@ export class DataxWorkerRunningComponent extends AppFormComponent implements Aft
let params = this.route.snapshot.params;
this.route.fragment.subscribe((fragment) => {
let targetTab = fragment;//['targetTab'];
// console.log(targetTab);
//console.log(targetTab);
switch (targetTab) {
case 'log':
if (!this.podNameSub) {
Expand Down Expand Up @@ -436,7 +467,7 @@ export class DataxWorkerRunningComponent extends AppFormComponent implements Aft
cpt.enableComponent();
if (r.success) {
this.dto.processMeta.afterSuccessDelete(this);
// this.nextStep.emit(Object.assign(new DataxWorkerDTO(), {processMeta: this.dto.processMeta}));
// this.nextStep.emit(Object.assign(new DataxWorkerDTO(), {processMeta: this.dto.processMeta}));
}
});

Expand Down Expand Up @@ -654,7 +685,7 @@ export class DataxWorkerRunningComponent extends AppFormComponent implements Aft
`
,
styles:[
styles: [
`.union-pod {
font-size: 9px;
color: #5d5d5d;
Expand Down
68 changes: 43 additions & 25 deletions src/runtime/incr.pod.logs.status.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@
* limitations under the License.
*/

import {AfterContentInit, AfterViewInit, Component, Input, OnDestroy, ViewChild} from "@angular/core";
import {
AfterContentInit,
AfterViewInit,
Component,
EventEmitter,
Input,
OnDestroy,
Output,
ViewChild
} from "@angular/core";
import {TISService} from "../common/tis.service";
import {AppFormComponent, CurrentCollection, WSMessage} from "../common/basic.form.component";
import {ActivatedRoute, Router} from "@angular/router";
Expand All @@ -42,14 +51,15 @@ import {PodsListComponent} from "../base/datax.worker.running.component";
<nz-page-header-title>
<nz-space>
<span *nzSpaceItem><nz-tag >
<span *nzSpaceItem><nz-tag>
<ng-container [ngSwitch]="this.logMonitorTimeout">
<span *ngSwitchCase="false" nz-icon [nzType]="'sync'" [nzSpin]="true"></span>
<span *ngSwitchCase="true" nz-icon nzType="stop" nzTheme="outline"></span>
</ng-container>
{{this._selectedPod?.phase}}</nz-tag>
<!-- {{this._selectedPod?.name}}--></span>
<nz-select *nzSpaceItem nzPlaceHolder="Choose" nzShowSearch [ngModel]="this._selectedPod?.name" (ngModelChange)="targetPodChange($event)">
<!-- {{this._selectedPod?.name}}--></span>
<nz-select *nzSpaceItem nzPlaceHolder="Choose" nzShowSearch [ngModel]="this._selectedPod?.name"
(ngModelChange)="targetPodChange($event)">
<nz-option-group *ngFor="let rc of this.rcDeployments" [nzLabel]="rc.name">
<nz-option *ngFor="let pod of rc.pods" [nzValue]="pod.name" [nzLabel]="pod.name"></nz-option>
</nz-option-group>
Expand All @@ -59,7 +69,10 @@ import {PodsListComponent} from "../base/datax.worker.running.component";
</nz-page-header-title>
<nz-page-header-extra>
<nz-space>
<button *nzSpaceItem nz-button nzType="primary" (click)="relauchIncrProcess()"><span nz-icon nzType="reload" nzTheme="outline"></span>重启</button>
<button *nzSpaceItem nz-button nzType="primary" (click)="relauchIncrProcess()"><span nz-icon
nzType="reload"
nzTheme="outline"></span>重启
</button>
</nz-space>
Expand Down Expand Up @@ -92,15 +105,19 @@ export class IncrPodLogsStatusComponent extends AppFormComponent implements Afte
logMonitorTimeout = false;
_selectedPod: K8sPodState;

@Output()
afterOnePodRelaunch = new EventEmitter();

@Input()
rcDeployments: Array<RCDeployment> =[];
rcDeployments: Array<RCDeployment> = [];

// podStatChange: Subject<K8sPodState> = new Subject<K8sPodState>();
targetPodChange(targetPod: any) {
// console.log(event);
// console.log(event);

PodsListComponent.viewPodLog(this.processMeta, this.route, this.router, {name:targetPod});
PodsListComponent.viewPodLog(this.processMeta, this.route, this.router, {name: targetPod});
}

@Input()
set selectedPod(podStat: K8sPodState) {
// console.log("set selectedPod");
Expand Down Expand Up @@ -199,28 +216,29 @@ export class IncrPodLogsStatusComponent extends AppFormComponent implements Afte
relauchIncrProcess() {
this._transactionProcessing = true;

// this.processMeta.targetNameGetter()
console.log(this.logType);
// this.processMeta.targetNameGetter()
// console.log(this.logType);
switch (this.logType) {
case LogType.DATAX_WORKER_POD_LOG:
this.httpPost('/coredefine/corenodemanage.ajax'
, "event_submit_do_relaunch_pod_process=y&action=datax_action&podName=" + this.selectedPod.name + "&targetName=" + this.processMeta.targetNameGetter(this.route.snapshot.params)// this.processMeta.targetName
)
.then((r) => {

if (r.success) {
this.successNotify(`已经成功触发重启Powerjob实例${this.selectedPod.name}`);
setTimeout(() => {
// console.log("navigate");
this.router.navigate(["/base/datax-worker", "profile"], {relativeTo: this.route});
this._transactionProcessing = false;
}, 3000);
} else {
, "event_submit_do_relaunch_pod_process=y&action=datax_action&podName="
+ this.selectedPod.name + "&targetName=" + this.processMeta.targetNameGetter(this.route.snapshot.params)
).then((r) => {

if (r.success) {
this.successNotify(`已经成功触发重启实例${this.selectedPod.name}`);
setTimeout(() => {
// console.log("navigate");
this.afterOnePodRelaunch.emit();
// this.processMeta.endType
this._transactionProcessing = false;
}
}, (reason) => {
}, 3000);
} else {
this._transactionProcessing = false;
});
}
}, (reason) => {
this._transactionProcessing = false;
});
return;
case LogType.INCR_DEPLOY_STATUS_CHANGE:
this.httpPost('/coredefine/corenodemanage.ajax', "event_submit_do_relaunch_incr_process=y&action=core_action")
Expand Down

0 comments on commit 1e743bd

Please sign in to comment.