Skip to content

Commit

Permalink
Merge pull request #42 from eolinker/fix/enviroment_manage_select_sta…
Browse files Browse the repository at this point in the history
…tus_error

fix: enviroment manage inital select status error
  • Loading branch information
buqiyuan committed May 23, 2022
2 parents 4a53b55 + df433d9 commit 2ff4006
Showing 1 changed file with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ export class EnvComponent implements OnInit, OnDestroy {
];

private destroy$: Subject<void> = new Subject<void>();
constructor(
private storage: StorageService,
private message: NzMessageService,
private store: Store
) {}
constructor(private storage: StorageService, private message: NzMessageService, private store: Store) {}

get envUuid(): number {
return Number(localStorage.getItem('env:selected')) || 0;
Expand All @@ -56,7 +52,7 @@ export class EnvComponent implements OnInit, OnDestroy {
this.destroy$.complete();
}

getAllEnv() {
getAllEnv(uuid?: number) {
const projectID = 1;
this.storage.run('environmentLoadAllByProjectID', [projectID], (result: StorageHandleResult) => {
if (result.status !== StorageHandleStatus.success) {
Expand All @@ -65,7 +61,7 @@ export class EnvComponent implements OnInit, OnDestroy {
return;
}
this.envList = result.data;
this.handleSwitchEnv(result.data[0].uuid);
this.handleSwitchEnv(uuid ?? result.data[0].uuid);
});
}

Expand Down Expand Up @@ -110,22 +106,25 @@ export class EnvComponent implements OnInit, OnDestroy {
}
const data = parameters.filter((it) => it.name && it.value);
if (uuid) {
this.storage.run('environmentUpdate', [{ ...other, name, parameters: data }, uuid], (result: StorageHandleResult) => {
if (result.status === StorageHandleStatus.success) {
this.message.success('编辑成功');
this.getAllEnv();
} else {
this.message.success('编辑失败');
this.storage.run(
'environmentUpdate',
[{ ...other, name, parameters: data }, uuid],
(result: StorageHandleResult) => {
if (result.status === StorageHandleStatus.success) {
this.message.success('编辑成功');
this.getAllEnv(this.activeUuid);
} else {
this.message.success('编辑失败');
}
}
});
);
} else {
this.storage.run('environmentCreate', [{ ...other, name, parameters: data }], (result: StorageHandleResult) => {
if (result.status === StorageHandleStatus.success) {
this.message.success('新增成功');
this.envInfo = result.data;
this.activeUuid = Number(result.data.uuid);
this.handleSwitchEnv(result.data.uuid);
this.getAllEnv();
this.getAllEnv(result.data.uuid);
} else {
this.message.success('新增失败');
}
Expand All @@ -141,6 +140,7 @@ export class EnvComponent implements OnInit, OnDestroy {

handleShowModal() {
this.isVisible = true;
this.handleSwitchEnv(this.envUuid);
}

handleEnvSelectStatus(event) {
Expand Down

0 comments on commit 2ff4006

Please sign in to comment.