Skip to content

Commit

Permalink
Merge branch 'main' of github.com:eolinker/eoapi
Browse files Browse the repository at this point in the history
  • Loading branch information
kungfuboy committed May 18, 2022
2 parents 1f4b50f + d6b106b commit 61094d4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 36 deletions.
10 changes: 1 addition & 9 deletions src/workbench/browser/src/app/pages/api/api.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ export class ApiComponent implements OnInit, OnDestroy {
];
private destroy$: Subject<void> = new Subject<void>();

constructor(
private route: ActivatedRoute,
private apiService: ApiService,
private messageService: MessageService
) {}
constructor(private route: ActivatedRoute, private apiService: ApiService, private messageService: MessageService) {}

ngOnInit(): void {
this.watchChangeRouter();
Expand All @@ -60,10 +56,6 @@ export class ApiComponent implements OnInit, OnDestroy {
case 'gotoBulkDeleteApi':
this.apiService.bulkDelete(inArg.data.uuids);
break;
case 'exportApi':{
this.apiService.export(inArg.data);
break;
}
}
});
}
Expand Down
29 changes: 10 additions & 19 deletions src/workbench/browser/src/app/pages/api/api.service.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
import { Injectable } from '@angular/core';
import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal';
import { NzModalService } from 'ng-zorro-antd/modal';
import { ApiData, StorageHandleResult, StorageHandleStatus } from '../../../../../../platform/browser/IndexedDB';
import { ExportApiComponent } from '../../shared/components/export-api/export-api.component';
import { MessageService } from '../../shared/services/message';
import { ModalService } from '../../shared/services/modal.service';
import { StorageService } from '../../shared/services/storage';
@Injectable()
export class ApiService {
constructor(
private nzModalService: NzModalService,
private modalService: ModalService,
private messageService: MessageService,
private storage: StorageService
) {}

copy(apiData: ApiData): void {
delete apiData.uuid;
delete apiData.createdAt;
apiData.name += ' Copy';
window.sessionStorage.setItem('apiDataWillbeSave', JSON.stringify(apiData));
this.messageService.send({ type: 'copyApi', data: apiData });
copy({ uuid, createdAt, ...data }: ApiData): void {
data.name += ' Copy';
window.sessionStorage.setItem('apiDataWillbeSave', JSON.stringify(data));
this.messageService.send({ type: 'copyApi', data });
}

delete(apiData: ApiData): void {
delete({ name, uuid }: ApiData): void {
this.nzModalService.confirm({
nzTitle: '删除确认?',
nzContent: `确认要删除数据 <strong title="${apiData.name}">${
apiData.name.length > 50 ? apiData.name.slice(0, 50) + '...' : apiData.name
nzContent: `确认要删除数据 <strong title="${name}">${
name.length > 50 ? name.slice(0, 50) + '...' : name
}</strong> 吗?删除后不可恢复!`,
nzOnOk: () => {
this.storage.run('apiDataRemove', [apiData.uuid], (result: StorageHandleResult) => {
this.storage.run('apiDataRemove', [uuid], (result: StorageHandleResult) => {
if (result.status === StorageHandleStatus.success) {
this.messageService.send({ type: 'deleteApiSuccess', data: { uuid: apiData.uuid } });
this.messageService.send({ type: 'deleteApiSuccess', data: { uuid } });
}
});
},
Expand All @@ -44,8 +39,4 @@ export class ApiService {
}
});
}
export(apiData: ApiData) {

}
bulkExport(groups) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@
<li nz-menu-item (click)="addSubGroup(node)">
<a>新建子分组</a>
</li>
<!-- <li nz-menu-item (click)="operateApiEvent({ event: $event, eventName: 'exportApiGroup', node: node })">
<a>导出 API</a>
</li> -->
<li nz-menu-item (click)="editGroup(node)">
<a>编辑</a>
</li>
Expand Down Expand Up @@ -129,9 +126,6 @@
>
<a>复制</a>
</li>
<!-- <li nz-menu-item (click)="operateApiEvent({ event: $event, eventName: 'exportApi', node: apiDataItems[node.key] })">
<a>导出 API</a>
</li> -->
<li nz-menu-item (click)="operateApiEvent({ event: $event, eventName: 'gotoDeleteApi', node: apiDataItems[node.key] })">
<a>删除</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ export class ApiGroupTreeComponent implements OnInit, OnDestroy {
}
getApis() {
this.storage.run('apiDataLoadAllByProjectID', [this.projectID], (result: StorageHandleResult) => {
if (result.status === StorageHandleStatus.success) {
const { success, empty } = StorageHandleStatus;
if ([success, empty].includes(result.status)) {
let apiItems = {};
result.data.forEach((item) => {
delete item.updatedAt;
Expand All @@ -136,7 +137,6 @@ export class ApiGroupTreeComponent implements OnInit, OnDestroy {
});
});
this.apiDataItems = apiItems;
this.messageService.send({ type: 'loadApi', data: this.apiDataItems });
this.generateGroupTreeData();
this.restoreExpandStatus();
}
Expand Down

0 comments on commit 61094d4

Please sign in to comment.