Skip to content

Commit

Permalink
fix: invalid with copy api
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed May 30, 2022
1 parent 74e838e commit baad9bd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { NzTreeSelectComponent } from 'ng-zorro-antd/tree-select';

import { Subject } from 'rxjs';
import { debounceTime, take, takeUntil, pairwise, filter } from 'rxjs/operators';
import { Message, MessageService } from '../../../shared/services/message';
import { MessageService } from '../../../shared/services/message';
import { StorageService } from '../../../shared/services/storage';

import {
Expand Down Expand Up @@ -137,7 +137,6 @@ export class ApiEditComponent implements OnInit, OnDestroy {
this.watchTabChange();
this.watchGroupIDChange();
this.watchUri();
this.watchApiAction();
}

ngOnDestroy() {
Expand Down Expand Up @@ -180,22 +179,6 @@ export class ApiEditComponent implements OnInit, OnDestroy {
}
}

/**
* Api Operation triggle tab change
*/
private watchApiAction() {
this.messageService
.get()
.pipe(takeUntil(this.destroy$))
.subscribe((inArg: Message) => {
switch (inArg.type) {
case 'saveApi':
// this.saveApi();
break;
}
});
}

private watchTabChange() {
this.apiTab.tabChange$
.pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export class ApiGroupTreeComponent implements OnInit, OnDestroy {
switch (inArg.type) {
case 'addApiSuccess':
case 'editApiSuccess':
case 'copyApiSuccess':
case 'deleteApiSuccess':
case 'bulkDeleteApiSuccess':
case 'updateGroupSuccess': {
Expand All @@ -183,6 +184,7 @@ export class ApiGroupTreeComponent implements OnInit, OnDestroy {
*/
operateApiEvent(inArg: NzFormatEmitEvent | any): void {
inArg.event.stopPropagation();
console.log('operateApiEvent inArg', inArg);
this.messageService.send({ type: inArg.eventName, data: inArg.node });
}
/**
Expand Down
20 changes: 16 additions & 4 deletions src/workbench/browser/src/app/pages/api/tab/api-tab.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { TabItem } from './tab.model';
import { ApiData } from 'eo/platform/browser/IndexedDB';
import { ApiData, StorageHandleResult, StorageHandleStatus } from 'eo/platform/browser/IndexedDB';
import { ApiTabService } from './api-tab.service';
import { Subject, takeUntil } from 'rxjs';
import { Message, MessageService } from '../../../shared/services/message';
import { StorageService } from 'eo/workbench/browser/src/app/shared/services/storage';
import { EoMessageService } from 'eo/workbench/browser/src/app/eoui/message/eo-message.service';
@Component({
selector: 'eo-api-tab',
templateUrl: './api-tab.component.html',
Expand All @@ -16,7 +18,7 @@ export class ApiTabComponent implements OnInit, OnDestroy {
/**
* Current selected tab index.
*/
selectedIndex: number = 0;
selectedIndex = 0;
/**
* Default tabs of api.
*/
Expand All @@ -33,7 +35,9 @@ export class ApiTabComponent implements OnInit, OnDestroy {
private router: Router,
private route: ActivatedRoute,
public tabSerive: ApiTabService,
private messageService: MessageService
private messageService: MessageService,
private message: EoMessageService,
private storage: StorageService
) {}
ngOnInit(): void {
this.watchApiAction();
Expand Down Expand Up @@ -105,6 +109,15 @@ export class ApiTabComponent implements OnInit, OnDestroy {
return;
}
this.appendTab(tab);

this.storage.run('apiDataCreate', [tabContent, tabContent.uuid], (result: StorageHandleResult) => {
if (result.status === StorageHandleStatus.success) {
this.message.success('复制成功');
this.messageService.send({ type: `copyApiSuccess`, data: result.data });
} else {
this.message.success('失败');
}
});
}
private appendTab(tab) {
if (this.tabSerive.tabs.length >= this.MAX_TAB_LIMIT) return;
Expand Down Expand Up @@ -239,7 +252,6 @@ export class ApiTabComponent implements OnInit, OnDestroy {
case 'copyApi':
case 'gotoAddApi':
this.appendOrSwitchTab('edit', inArg.data ?? {});
this.messageService.send({ type: 'saveApi', data: {} });
break;
case 'addApiSuccess':
case 'editApiSuccess':
Expand Down

0 comments on commit baad9bd

Please sign in to comment.